private static readonly string ResourcePath = FrameworkInformation.ResourcePath;
private static readonly string MinimalizeIcon = ResourcePath + "minimalize.png";
private static readonly string MaximalizeIcon = ResourcePath + "maximalize.png";
- private static readonly string PreviousIcon = ResourcePath + "smallwindow.png";
private static readonly string CloseIcon = ResourcePath + "close.png";
private static readonly string LeftCornerIcon = ResourcePath + "leftCorner.png";
private static readonly string RightCornerIcon = ResourcePath + "rightCorner.png";
private static readonly string DarkMinimalizeIcon = ResourcePath + "dark_minimalize.png";
- private static readonly string DarkMaximalizeIcon = ResourcePath + "dark_maximalize.png";
private static readonly string DarkPreviousIcon = ResourcePath + "dark_smallwindow.png";
private static readonly string DarkCloseIcon = ResourcePath + "dark_close.png";
private static readonly string DarkLeftCornerIcon = ResourcePath + "dark_leftCorner.png";
private static readonly string DarkRightCornerIcon = ResourcePath + "dark_rightCorner.png";
- private static readonly uint DefaultHeight = 50;
- private static readonly uint DefaultLineThickness = 5;
- private static readonly uint DefaultTouchThickness = 20;
+ private const uint DefaultHeight = 50;
+ private const uint DefaultLineThickness = 5;
+ private const uint DefaultTouchThickness = 20;
private static readonly Color DefaultBackgroundColor = new Color(1, 1, 1, 0.3f);
private static readonly Color DefaultClickedBackgroundColor = new Color(1, 1, 1, 0.4f);
- private static readonly Size2D DefaultMinSize = new Size2D(500, 0);
+ private static readonly Size2D DefaultMinSize = new Size2D(100, 0);
#endregion //Constant Fields
#region Fields
private Color backgroundColor;
private View rootView;
+ private View borderView;
private ImageView minimalizeIcon;
private ImageView maximalizeIcon;
private Timer timer;
private CurrentGesture currentGesture = CurrentGesture.None;
+ private bool disposed = false;
#endregion //Fields
#region Events
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual void CreateBorderView(View rootView)
{
+ if (rootView == null)
+ {
+ return;
+ }
this.rootView = rootView;
rootView.BackgroundColor = DefaultBackgroundColor;
rootView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
rootView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
- View borderView = new View()
+ borderView = new View()
{
Layout = new LinearLayout()
{
/// Determines the behavior of pinch gesture.
private void OnPinchGestureDetected(object source, PinchGestureDetector.DetectedEventArgs e)
{
+ if (e == null)
+ {
+ return;
+ }
if (e.PinchGesture.State == Gesture.StateType.Started)
{
preScale = e.PinchGesture.Scale;
/// Determines the behavior of borders.
private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e)
{
+ if (e == null)
+ {
+ return;
+ }
PanGesture panGesture = e.PanGesture;
if (panGesture.State == Gesture.StateType.Started)
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool OnLeftCornerIconTouched(object sender, View.TouchEventArgs e)
{
+ if (e == null)
+ {
+ return false;
+ }
if (e.Touch.GetState(0) == PointStateType.Down)
{
ClearWindowGesture();
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool OnRightCornerIconTouched(object sender, View.TouchEventArgs e)
{
+ if (e == null)
+ {
+ return false;
+ }
if (e.Touch.GetState(0) == PointStateType.Down)
{
ClearWindowGesture();
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e)
{
+ if (e == null)
+ {
+ return false;
+ }
if (e.Touch.GetState(0) == PointStateType.Up)
{
ClearWindowGesture();
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool OnMaximizeIconTouched(object sender, View.TouchEventArgs e)
{
+ if (e == null)
+ {
+ return false;
+ }
if (e.Touch.GetState(0) == PointStateType.Up)
{
ClearWindowGesture();
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool OnCloseIconTouched(object sender, View.TouchEventArgs e)
{
+ if (e == null)
+ {
+ return false;
+ }
if (e.Touch.GetState(0) == PointStateType.Up)
{
BorderWindow.Destroy();
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual void OnCreated(View rootView)
{
+ if (rootView == null)
+ {
+ return;
+ }
// Register to resize and move through pan gestures.
borderPanGestureDetector = new PanGestureDetector();
borderPanGestureDetector.Attach(rootView);
{
timer.Stop();
timer.Dispose();
+ timer = null;
}
}
return false;
{
WidthResizePolicy = ResizePolicyType.FillToParent,
HeightResizePolicy = ResizePolicyType.FillToParent,
- BackgroundColor = new Vector4(1, 1, 1, 0.5f),
+ BackgroundColor = new Color(1, 1, 1, 0.5f),
};
windowView.TouchEvent += (s, e) =>
{
UpdateIcons();
}
- /// <summary>
- /// Dispose
- /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public virtual void Dispose()
+ protected virtual void Dispose(bool disposing)
{
- ClearWindowGesture();
- BorderWindow.InterceptTouchEvent -= OnWinInterceptedTouch;
- borderPanGestureDetector.Dispose();
- borderPinchGestureDetector.Dispose();
- if (windowView != null)
+ if (disposed)
{
- windowView.Dispose();
+ return;
}
- if (rootView != null)
+ if (disposing)
{
- rootView.Dispose();
+ ClearWindowGesture();
+ if (BorderWindow != null)
+ {
+ BorderWindow.InterceptTouchEvent -= OnWinInterceptedTouch;
+ }
+ borderPanGestureDetector?.Dispose();
+ borderPinchGestureDetector?.Dispose();
+ backgroundColor?.Dispose();
+ minimalizeIcon?.Dispose();
+ maximalizeIcon?.Dispose();
+ closeIcon?.Dispose();
+ leftCornerIcon?.Dispose();
+ rightCornerIcon?.Dispose();
+ timer?.Dispose();
+ windowView?.Dispose();
+ borderView?.Dispose();
+ rootView?.Dispose();
}
+ disposed = true;
+ }
+
+ /// <summary>
+ /// Dispose
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+ global::System.GC.SuppressFinalize(this);
}
#endregion //Methods
"hbo", "linkedin", "youtube"
};
- class TestWindow : BorderWindowInterface
+ class TestWindow : DefaultBorder
{
public override void CreateBorderView(View rootView)
{
borderView.Add(closeIcon);
rootView.Add(borderView);
- minimalizeIcon.TouchEvent += OnMinTouched;
- maximalizeIcon.TouchEvent += OnMaxTouched;
- closeIcon.TouchEvent += OnCloseTouched;
+ minimalizeIcon.TouchEvent += OnMinimizeIconTouched;
+ maximalizeIcon.TouchEvent += OnMaximizeIconTouched;
+ closeIcon.TouchEvent += OnCloseIconTouched;
}
}
{
if (subWindowOne == null)
{
- subWindowOne = new Window("subwin1", new Rectangle(1300, 250, 550, 500), false);
- subWindowOne.EnableBorderWindow();
+ subWindowOne = new Window("subwin1", null, new Rectangle(1300, 250, 550, 500), false);
var mainView = new View()
{
{
if (subWindowTwo == null)
{
- subWindowTwo = new Window("subwin1", new Rectangle(60, 600, 600, 250), false);
- subWindowTwo.EnableBorderWindow();
+ subWindowTwo = new Window("subwin1", null, new Rectangle(60, 600, 600, 250), false);
var mainView = new View()
{