private WindowAttribute.Position position;
private Size2D size;
private Window magnifierWindow;
+ private bool visible;
private MagnifierWindow()
{
timer.Tick += TimerTick;
imageList = new List<ImageView>();
labelList = new List<TextLabel>();
+ visible = false;
}
private bool TimerTick(object source, Timer.TickEventArgs e)
{
- if (IsExists())
+ if (visible)
Hide();
return true;
}
}
+ public bool IsVisible
+ {
+ get => visible;
+ }
+
public void Show()
{
+ if (timer.IsRunning())
+ timer.Stop();
+
magnifierWindow = new Window("MagnifierWindow", new Rectangle(position.X, position.Y, size.Width, size.Height), false);
magnifierWindow.BackgroundColor = Color.Transparent;
magnifierWindow.SetAcceptFocus(false);
magnifierWindow.Raise();
- timer.Start();
+ visible = true;
}
public void Hide()
{
- timer.Stop();
-
labelList.ForEach(label =>
{
label.Unparent();
imageList.Clear();
magnifierWindow?.Dispose();
+ visible = false;
}
public void SetPosition(WindowAttribute.Position newPosition)
labelList.Add(textLabel);
}
- public bool IsExists()
- {
- if (imageList.Count != 0 || labelList.Count != 0)
- return true;
-
- return false;
- }
-
- public bool IsRunning()
+ public void StartHideTimer()
{
- return timer.IsRunning();
+ if (!timer.IsRunning())
+ timer.Start();
}
}
}
keystr, magnifierPosition.X, magnifierPosition.Y, width, height,
align, padding_x, padding_y, inner_width, inner_height);
magnifier.AddLabel(magnifierText);
+
+ if (!magnifier.IsVisible)
+ magnifier.Show();
break;
}
case WindowAttribute.WindowType.Popup:
dispose_all_objects();
break;
}
+ case WindowAttribute.WindowType.Magnifier:
+ {
+ if (magnifier.IsVisible)
+ magnifier.Hide();
+ break;
+ }
case WindowAttribute.WindowType.AutoPopup:
{
break;
}
}
-
- if (magnifier.IsExists() && !magnifier.IsRunning())
- magnifier.Show();
};
SclNuiUpdateWindowCb(_update_window_cb, (IntPtr)null);
_onDragStateChangedEvent = (IntPtr key_value, int key_event, int key_type, int event_type, int current_x, int current_y) =>
{
+ SclNuiEventType type = (SclNuiEventType)event_type;
+
+ if (type == SclNuiEventType.Move)
+ {
+
+ }
+ else if (type == SclNuiEventType.Release)
+ {
+ if (magnifier.IsVisible)
+ magnifier.StartHideTimer();
+ }
+ else if (type == SclNuiEventType.Press)
+ {
+ if (magnifier.IsVisible)
+ magnifier.Hide();
+ }
+
return (int)SclNuiEventReturnType.PassOn;
};
SclNuiDragStateChangedCb(_onDragStateChangedEvent);
// - Set the mTouchedInButton to false
case PointStateType.Down:
{
- if (magnifier.IsExists())
- magnifier.Hide();
-
Log.Info("NUIIME", "[MOUSE DOWN] x=" + e.Touch.GetScreenPosition(0).X + ", y=" + e.Touch.GetScreenPosition(0).Y);
if (popup.IsShowing())
SclControllerMousePress((int)WindowAttribute.WindowType.Popup, (int)e.Touch.GetScreenPosition(0).X, (int)e.Touch.GetScreenPosition(0).Y);