HighLight BackgroundColor UIButton on TouchUpInside is fired in MonoTouch

 using System;

using System.Drawing;

using System.IO;

using System.Text;



using MonoTouch;

using MonoTouch.UIKit;

using MonoTouch.CoreGraphics;

using MonoTouch.ObjCRuntime;



namespace DicomViewerApplication

{

public static class SwapUIButtonColor

{

#region field

private static UIButton _previousButton;

private static UIButton _currentButton;

#endregion


#region prop

public static UIButton PreviousButton {

get

{

return _previousButton;

}

set

{

_previousButton = value;

}

}

public static UIButton CurrentButton {

get

{

return _currentButton;

}

set

{

_currentButton = value;

}

}

#endregion


#region SwapColor() highlight the button on click

public static bool SwapColor (UIButton sender, bool isPrevBakGraound)

{

if (isPrevBakGraound == false)

{

InitApplyColorBorder (sender);

SwapUIButtonColor.PreviousButton = sender;

return true;

} else

{

if (SwapUIButtonColor.PreviousButton != sender)

{

InitApplyColorBorder (sender);

SwapUIButtonColor.CurrentButton = PreviousButton;

PreviousButton = sender;


SwapUIButtonColor.CurrentButton.Layer.BorderColor = (UIColor.Black).CGColor;

SwapUIButtonColor.CurrentButton.Layer.BorderWidth = 0f;

SwapUIButtonColor.CurrentButton.Layer.CornerRadius = 0f;

return true;

} else if (SwapUIButtonColor.PreviousButton == sender)

{

InitApplyColorBorder (sender);

SwapUIButtonColor.PreviousButton = sender;

return true ;

}

return true ;

}

}

#endregion


static void InitApplyColorBorder (UIButton sender)

{

sender.Layer.BorderColor = (UIColor.Red).CGColor;

sender.Layer.BorderWidth = 1.0f;

sender.Layer.CornerRadius = 10f;

}

}

}





 private UIButton btnBrightness

btnBrightness = UIButton.FromType (UIButtonType.RoundedRect);

			btnBrightness.Frame = new RectangleF (540, 20, 95, 37);

			btnBrightness.SetTitle ("Brightness", UIControlState.Normal);
----



btnBrightness.TouchUpInside += (sender, e) => {

				//ImgView.Hidden = false;

				WindowLevelingTool.OnBrightClick (ImgView);			

				isPrevBakGraound = SwapUIButtonColor.SwapColor (btnBrightness, isPrevBakGraound);

			};

Ebook Download
View all
Learn
View all