public static Windows.UI.Xaml.UIElement removeFromParent(Windows.UI.Xaml.UIElement child) { if (!(child != null)) { return(null); } var parentWidget = cave.ui.Widget.getParent(child); if (!(parentWidget != null)) { return(null); } var pp = parentWidget as cave.ui.CustomContainerWidget; System.Diagnostics.Debug.WriteLine("[cave.ui.Widget.removeFromParent] (Widget.sling:216:2): Not implemented."); if (pp != null) { pp.onChildWidgetRemoved(child); } var screen = cave.ui.ScreenForWidget.findScreenForWidget(parentWidget); if (screen != null) { cave.ui.Widget.notifyOnRemovedFromScreen(child, screen); } cave.ui.Widget.onWidgetRemovedFromParent(child); return(null); }
public static Point GetPointInWindow(Point client, Windows.UI.Xaml.UIElement element) { //ウィンドウ内での絶対座標を取得する var gt = element.TransformToVisual(Windows.UI.Xaml.Window.Current.Content); return(gt.TransformPoint(client)); }
/// <summary> /// Measures wrapped UWP XAML content using passed in size availableSize /// </summary> /// <param name="availableSize">Available Size</param> /// <returns>XAML DesiredSize</returns> protected override Windows.Foundation.Size MeasureOverride(Windows.Foundation.Size availableSize) { Windows.Foundation.Size desiredSize = new Windows.Foundation.Size(0, 0); Windows.UI.Xaml.UIElement element = Child; if (element != null) { try { element.Measure(new Windows.Foundation.Size(availableSize.Width / _scalingFactor, availableSize.Height / _scalingFactor)); } catch (Exception) { Debugger.Break(); } desiredSize.Width = element.DesiredSize.Width * _scalingFactor; desiredSize.Height = element.DesiredSize.Height * _scalingFactor; } desiredSize.Width = Math.Min(desiredSize.Width, availableSize.Width); desiredSize.Height = Math.Min(desiredSize.Height, availableSize.Height); return(desiredSize); }
public override void initializeWidget() { base.initializeWidget(); var background = cave.ui.CanvasWidget.forColor(context, cave.Color.forRGBADouble((double)0, (double)0, (double)0, 0.80)); cave.ui.Widget.setWidgetClickHandler((Windows.UI.Xaml.UIElement)background, () => { ; }); addWidget((Windows.UI.Xaml.UIElement)background); if (cave.ui.LoadingWidget.displayImage != null) { var img = cave.ui.ImageWidget.forImage(context, cave.ui.LoadingWidget.displayImage); img.setWidgetImageHeight(context.getHeightValue("20mm")); loading = (Windows.UI.Xaml.UIElement)img; } else { var text = cave.ui.LoadingWidget.displayText; if (cape.String.isEmpty(text)) { text = "Loading .."; } var lt = cave.ui.LabelWidget.forText(context, text); lt.setWidgetTextColor(cave.Color.white()); lt.setWidgetFontSize((double)context.getHeightValue("3mm")); loading = (Windows.UI.Xaml.UIElement)lt; } addWidget((Windows.UI.Xaml.UIElement)cave.ui.AlignWidget.forWidget(context, loading, 0.50, 0.50)); start(); }
public static void setWidgetDoubleClickHandler(Windows.UI.Xaml.UIElement widget, System.Action handler) { if (widget is cave.ui.CustomContainerWidget) { if (!(handler != null)) { ((cave.ui.CustomContainerWidget)widget).togglePointerEventHandling(false); } else { ((cave.ui.CustomContainerWidget)widget).togglePointerEventHandling(true); } } if (cave.ui.Widget.existingWidgetDoubleClickHandler != null) { widget.DoubleTapped -= existingWidgetDoubleClickHandler; cave.ui.Widget.existingWidgetDoubleClickHandler = null; } if (handler != null) { existingWidgetDoubleClickHandler = (object sender, Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs e) => { singleClick = false; handler(); }; widget.DoubleTapped += existingWidgetDoubleClickHandler; } }
public static void setWidgetPointerHandlers(Windows.UI.Xaml.UIElement widget, System.Action <double, double> onStartHandler = null, System.Action <double, double> onTouchHandler = null, System.Action <double, double> onEndHandler = null) { if (widget is cave.ui.CustomContainerWidget) { if (onStartHandler == null && onTouchHandler == null && onEndHandler == null) { ((cave.ui.CustomContainerWidget)widget).togglePointerEventHandling(false); } else { ((cave.ui.CustomContainerWidget)widget).togglePointerEventHandling(true); } } if (onStartHandler != null) { System.Diagnostics.Debug.WriteLine("[cave.ui.Widget.setWidgetPointerHandlers] (Widget.sling:1118:3): setWidgetPointerHandlers/onStartHandler: Not implemented"); } if (onTouchHandler != null) { System.Diagnostics.Debug.WriteLine("[cave.ui.Widget.setWidgetPointerHandlers] (Widget.sling:1121:3): setWidgetPointerHandlers/onStartHandler: Not implemented"); } if (onEndHandler != null) { cave.ui.Widget.setWidgetClickHandler(widget, () => { onEndHandler((double)0, (double)0); }); } }
public static void setWidgetClickHandler(Windows.UI.Xaml.UIElement widget, System.Action handler) { if (widget is cave.ui.CustomContainerWidget) { if (!(handler != null)) { ((cave.ui.CustomContainerWidget)widget).togglePointerEventHandling(false); } else { ((cave.ui.CustomContainerWidget)widget).togglePointerEventHandling(true); } } if (cave.ui.Widget.existingWidgetClickHandler != null) { widget.PointerReleased -= existingWidgetClickHandler; cave.ui.Widget.existingWidgetClickHandler = null; } if (handler != null) { existingWidgetClickHandler = async(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) => { singleClick = true; await System.Threading.Tasks.Task.Delay(200); if (singleClick) { handler(); } }; widget.PointerReleased += existingWidgetClickHandler; } }
protected void ArrangeChildOverride(View view, Rect frame) { view.Arranged = frame; view.LayoutSlotWithMarginsAndAlignments = frame; LayoutInformation.SetLayoutSlot(view, frame); }
public void setWidgetContent(Windows.UI.Xaml.UIElement widget) { if (widget != null) { widgetContent = widget; } }
public EffectRenderer(Windows.UI.Xaml.UIElement rootForPointerEvents, Windows.UI.Xaml.UIElement rootOfLayout) { _root = rootForPointerEvents; _rootParent = rootOfLayout; EnableClear = true; Show = true; clock = new Stopwatch(); gestureRecognizer = new Windows.UI.Input.GestureRecognizer(); gestureRecognizer.GestureSettings = Windows.UI.Input.GestureSettings.ManipulationTranslateX | Windows.UI.Input.GestureSettings.ManipulationTranslateY | Windows.UI.Input.GestureSettings.ManipulationTranslateInertia; gestureRecognizer.ManipulationUpdated += gestureRecognizer_ManipulationUpdated; _root.PointerPressed += _root_PointerPressed; _root.PointerReleased += _root_PointerReleased; //_root.PointerEntered += _root_PointerPressed; //_root.PointerExited += _root_PointerReleased; _root.PointerMoved += _root_PointerMoved; _root.PointerWheelChanged += _root_PointerWheelChanged; angleX = 0.16f; angleY = 1.2f; clock.Start(); }
public View AddChild(View child, int index) { _children.Insert(index, child); child.SetParent(this); return(child); }
public View RemoveChild(View child) { _children.Remove(child); child.SetParent(null); return(child); }
public static void SetWrapper(this Windows.UI.Xaml.UIElement element, WindowsXamlHostBase wrapper) { if (IsDesktopWindowsXamlSourcePresent()) { element.SetValue(WrapperProperty, wrapper); } }
/// <summary> /// Find the first child of a specific type. /// </summary> /// <typeparam name="T">Expected type of the searched child</typeparam> /// <param name="view"></param> /// <param name="selector">Additional selector for the child</param> /// <param name="childLevelLimit">Defines the max depth, null if not limit (Should never be used)</param> /// <param name="includeCurrent">Indicates if the current view should also be tested or not.</param> /// <returns></returns> public static T FindFirstChild <T>(this ViewGroup view, Func <T, bool> selector, int?childLevelLimit = null, bool includeCurrent = true) where T : View { Func <View, bool> childSelector; if (selector == null) { childSelector = child => child is T; } else { childSelector = child => { var t = child as T; return(t != null && selector(t)); }; } if (includeCurrent && childSelector(view)) { return(view as T); } var maxDepth = childLevelLimit.HasValue ? childLevelLimit.Value : Int32.MaxValue; return((T)view.EnumerateAllChildren(childSelector, maxDepth).FirstOrDefault()); }
public static void showBelow(cave.GuiApplicationContext ctx, Windows.UI.Xaml.UIElement w, cave.ui.Menu menu) { if (!(w != null)) { return; } if (!(menu != null)) { return; } var widget = w; var context = ctx; var pm = new Windows.UI.Xaml.Controls.MenuFlyout(); var array = menu.getEntries(); if (array != null) { var n = 0; var m = array.Count; for (n = 0; n < m; n++) { var entry = array[n]; if (entry != null) { var i = new Windows.UI.Xaml.Controls.MenuFlyoutItem(); i.Text = entry.title; i.Click += (sender, e) => { entry.handler(); }; pm.Items.Add(i); } } } pm.ShowAt(widget, new Windows.Foundation.Point(0, Widget.getHeight(widget))); }
public View AddChild(View child) { _children.Add(child); child.SetParent(this); return(child); }
/// <summary> /// Sets the scaling factor of the panel /// <param name="newScalingFactor">New scaling factor</param> /// </summary> public void SetScalingFactor(double newScalingFactor) { // Do not touch any user set render transform on the XAML element // if scaling is not necessary and was not enabled before if (newScalingFactor == 1.0f && _scalingFactor == 1.0f) { return; } _scalingFactor = newScalingFactor; Windows.UI.Xaml.UIElement element = Child; if (element == null) { return; } if (newScalingFactor == 1.0f) { element.RenderTransform = null; return; } Windows.UI.Xaml.Media.ScaleTransform newScaleTransform = new Windows.UI.Xaml.Media.ScaleTransform(); newScaleTransform.ScaleX = newScalingFactor; newScaleTransform.ScaleY = newScalingFactor; element.RenderTransform = newScaleTransform; }
public void TitleBarVisiblity(bool visible, Windows.UI.Xaml.UIElement control) { var coreTitleBar = Windows.ApplicationModel.Core.CoreApplication.GetCurrentView().TitleBar; coreTitleBar.ExtendViewIntoTitleBar = !visible; Windows.UI.Xaml.Window.Current.SetTitleBar(control); }
public void addOverlay(Windows.UI.Xaml.UIElement widget) { if (overlayWidget != null) { overlayWidget.addWidget(widget); } }
public static bool hasParent(Windows.UI.Xaml.UIElement widget) { if (!(cave.ui.Widget.getParent(widget) != null)) { return(false); } return(true); }
public static void move(Windows.UI.Xaml.UIElement widget, int x, int y) { var wi = cave.ui.Widget.getMyWidgetInfo(widget); wi.x = (float)x; wi.y = (float)y; widget.UpdateLayout(); }
public static void setAlpha(Windows.UI.Xaml.UIElement widget, double alpha) { if (!(widget != null)) { return; } System.Diagnostics.Debug.WriteLine("[cave.ui.Widget.setAlpha] (Widget.sling:1182:2): Not implemented"); }
public void onEndLoading() { if (overlay != null) { cave.ui.Widget.removeFromParent(overlay); overlay = null; } }
public bool switchWidget(Windows.UI.Xaml.UIElement widget) { if (widget == null) { return(false); } popWidget(); return(pushWidget(widget)); }
partial void OnChildChangedPartial(View previousValue, View newValue) { if (previousValue != null) { RemoveChild(previousValue); } AddChild(newValue); }
public cave.ui.WidgetAnimation addFadeIn(Windows.UI.Xaml.UIElement from) { var ff = from; addCallback((double completion) => { cave.ui.Widget.setAlpha(ff, completion); }); return(this); }
public EffectRenderer(Windows.UI.Xaml.UIElement rootForPointerEvents, Windows.UI.Xaml.UIElement rootOfLayout) { _root = rootForPointerEvents; _rootParent = rootOfLayout; EnableClear = false; Show = true; _root.PointerMoved += root_PointerMoved; }
public static WindowsXamlHostBase GetWrapper(this Windows.UI.Xaml.UIElement element) { if (IsDesktopWindowsXamlSourcePresent()) { return((WindowsXamlHostBase)element.GetValue(WrapperProperty)); } return(null); }
private void OnAddChild(View child) { child.SetParent(this); if (child is FrameworkElement fe) { fe.IsLoaded = IsLoaded; fe.EnterTree(); } }
public void openFileDialog(Windows.UI.Xaml.UIElement widget, string type, System.Action <byte[], string, string, cape.Error> callback) { var cb = callback; System.Diagnostics.Debug.WriteLine("[cave.ui.FileSelectorWidget.openFileDialog] (FileSelectorWidget.sling:172:2): Not implemented"); if (cb != null) { cb(null, null, null, cape.Error.forCode("notSupported")); } }
public EffectRenderer(Windows.UI.Xaml.UIElement rootForPointerEvents, Windows.UI.Xaml.UIElement rootOfLayout) { _root = rootForPointerEvents; _rootParent = rootOfLayout; EnableClear = false; Show = true; clock = new Stopwatch(); _root.PointerMoved += _root_PointerMoved; _root.PointerPressed += _root_PointerPressed; _root.PointerReleased += _root_PointerReleased; }