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;
}
}
}
|