private void ShowAdorner() { if (this.adorner == null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { ContentControl designerItem = this.DataContext as ContentControl; Canvas canvas = VisualTreeHelper.GetParent(designerItem) as Canvas; this.adorner = new ResizeRotateAdorner(designerItem); adornerLayer.Add(this.adorner); if (this.ShowDecorator) { this.adorner.Visibility = Visibility.Visible; } else { this.adorner.Visibility = Visibility.Hidden; } } } else { this.adorner.Visibility = Visibility.Visible; } }
private static void AssertTemplatedAdornerTypee(Adorner adorner, [CallerMemberName] string caller = null) { if (adorner?.GetType() != TemplatedAdornerType) { throw new InvalidOperationException($"{caller} can only be called on {TemplatedAdornerType}"); } }
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { canvas = this.GetVisualChild<Canvas>(); adornerlayer = AdornerLayer.GetAdornerLayer(this); var designableDragAndResizeChrome = new DesignableResizeChrome(selection); selectionAdorner = new DesignableResizeAdorner(canvas, selection, designableDragAndResizeChrome); }
private void ShowAdorner() { if (adorner == null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { ContentControl designerItem = this.DataContext as ContentControl; Canvas canvas = Algorithm.FindVisualParent<Canvas>(designerItem); adorner = new DesignerItemAdorner(designerItem,new ResizeRotateControl()); adornerLayer.Add(adorner); if (ShowDecorator) { adorner.Visibility = Visibility.Visible; } else { adorner.Visibility = Visibility.Collapsed; } } } else { adorner.Visibility = Visibility.Visible; } }
public void ShowAdorner() { if (this.adorner == null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { ContentControl element = this.DataContext as ContentControl; Canvas canvas = VisualTreeHelper.GetParent(element) as Canvas; this.adorner = new ResizeAdorner(element); adornerLayer.Add(this.adorner); if (this.ShowDecorator) { this.adorner.Visibility = Visibility.Visible; } else { this.adorner.Visibility = Visibility.Hidden; } } } else { this.adorner.Visibility = Visibility.Visible; } }
private void ResizeThumb_DragStarted(object sender, DragStartedEventArgs e) { this.designerItem = this.DataContext as ContentControl; if (this.designerItem != null) { this.canvas = VisualTreeHelper.GetParent(this.designerItem) as ContentPresenter; if (this.canvas != null) { this.transformOrigin = this.designerItem.RenderTransformOrigin; this.rotateTransform = this.designerItem.RenderTransform as RotateTransform; if (this.rotateTransform != null) { this.angle = this.rotateTransform.Angle * Math.PI / 180.0; } else { this.angle = 0.0d; } AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.canvas); if (adornerLayer != null) { this.adorner = new SizeAdorner(this.designerItem); adornerLayer.Add(this.adorner); } } } }
private void item_OnDragStop(Adorner adorner) { if (OnDragStop != null) { OnDragStop(adorner); } }
private void item_OnDragStart(Adorner adorner) { if (OnDragStart != null) { OnDragStart(adorner); } }
void MakeAdorner(UIElement uiElement, object data, object target, bool isOpening, bool canDrop, string message) { // get adorner layer FrameworkElement el = this.AssociatedObject; while (el != null && (!(el is UserControl) || AdornerLayer.GetAdornerLayer(el) == null)) { el = (FrameworkElement)VisualTreeHelper.GetParent(el); } if (el != null) { _adornerLayer = AdornerLayer.GetAdornerLayer(el); // make adorner if (AdornerType == null) { _adorner = new DropAdorner(uiElement, data, target, isOpening, canDrop, message); } else { _adorner = (System.Windows.Documents.Adorner)Activator.CreateInstance(AdornerType, new object[] { uiElement, data, target, isOpening, canDrop, message }); } _adornerLayer.Add(this._adorner); // set adorner z-order var setZOrderMethodInfo = _adornerLayer.GetType().GetMethod("SetAdornerZOrder", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); setZOrderMethodInfo.Invoke(_adornerLayer, new object[] { _adorner, 1 }); } }
public AdorneredTooltip(Adorner adorner, bool adornerLayerVisible) { Argument.IsNotNull(() => adorner); _adornerLayerVisible = adornerLayerVisible; _adorner = adorner; _visible = _adorner.Visibility == Visibility.Visible; }
void RemoveAdorner() { if (_adornerLayer != null && _adorner != null) { _adornerLayer.Remove(_adorner); } _adorner = null; _adornerLayer = null; }
private void RemoveAdorner() { if (this.adorner != null) { this.adornerLayer.Remove(this.adorner); this.adorner = null; this.adornerLayer = null; } }
public void Add(FrameworkElement parentControl, Adorner tooltip, bool adornerLayerVisibility) { if (!Contains(parentControl)) { CreateAdornersList(parentControl); } GetAdorners(parentControl).Add(_factory.Create(tooltip, adornerLayerVisibility)); }
public static void TryAddAdorner <T>(this UIElement elem, System.Windows.Documents.Adorner adorner) where T : System.Windows.Documents.Adorner { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(elem); if (adornerLayer != null && !adornerLayer.ContainsAdorner <T>(elem)) { adornerLayer.Add(adorner); } }
private void ResizeDecorator_Unloaded(object sender, RoutedEventArgs e) { if (_adorner != null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) adornerLayer.Remove(_adorner); _adorner = null; } }
private void DesignerItemDecorator_Unloaded(object sender, RoutedEventArgs e) { if (this.adorner != null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { adornerLayer.Remove(this.adorner); } this.adorner = null; } }
private void ResizeThumb_DragCompleted(object sender, DragCompletedEventArgs e) { if (adorner != null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.canvas); if (adornerLayer != null) { adornerLayer.Remove(this.adorner); } adorner = null; } }
private void AddAdorner(UIElement newFocus) { if (this.adornerLayer == null) { if (newFocus is Window) { return; } this.CreateNewAdornerLayer(newFocus); } this.adorner = new RectangleAdorner(newFocus, this.adornerSettings); this.adornerLayer.Add(this.adorner); }
void dc_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "LeftPictureLocation") { var doesThisWork = VisualTreeHelper.GetChild(leftItemsControl, 0); var doesThisWorkt = VisualTreeHelper.GetChild(doesThisWork, 0); var doesThisWorktt = VisualTreeHelper.GetChild(doesThisWorkt, 0); canvasToTouch = (Canvas)doesThisWorktt; myAdornerLayer = AdornerLayer.GetAdornerLayer((Visual)doesThisWorktt); ad = new SimpleCircleAdorner((UIElement)doesThisWorktt); myAdornerLayer.Add(ad); myAdornerLayer.IsHitTestVisible = false; } }
private static void Show(Adorner adorner, bool retry) { var adornerLayer = AdornerLayer.GetAdornerLayer(adorner.AdornedElement); if (adornerLayer != null) { ////Debug.WriteLine(nameof(Show)); adornerLayer.Remove(adorner); adornerLayer.Add(adorner); } else if (retry) { // try again later, perhaps giving layout a chance to create the adorner layer adorner.Dispatcher.BeginInvoke( DispatcherPriority.Loaded, new DispatcherOperationCallback(ShowAdornerOperation), new object[] { adorner }); } }
private void ShowAdorner() { if (_adorner == null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { DesignerItem designerItem = DataContext as DesignerItem; _adorner = new ResizeAdorner(designerItem); adornerLayer.Add(_adorner); if (ShowDecorator) _adorner.Visibility = Visibility.Visible; else _adorner.Visibility = Visibility.Hidden; } } else _adorner.Visibility = Visibility.Visible; }
public void Remove(Adorner adorner) { if (_Adorners.ContainsValue(adorner)) { _AdornerLayer.Remove(adorner); string name = string.Empty; foreach (string key in _Adorners.Keys) { if (_Adorners[key].Equals(adorner)) { name = key; break; } } if (!String.IsNullOrWhiteSpace(name)) { _Adorners.Remove(name); } } }
private void CircleCanvas_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Console.Out.WriteLine("OnMouseLeftButtonDown"); var layer = AdornerLayer.GetAdornerLayer(this.CircleCanvas); if (this.adorner != null) { layer.Remove(this.adorner); this.adorner = null; } var shape = e.Source as Shape; if (shape != null) { shape.InputHitTest(e.GetPosition(shape)); this.isMoving = true; this.currentPoint = e.GetPosition(this.CircleCanvas); this.currentShape = shape; this.adorner = new Resources.Controls.Adorners.SelectionAdorner(shape); layer.Add(this.adorner); this.CircleCanvas.CaptureMouse(); } e.Handled = true; }
public override void DesignMode() { if (!IsDesignMode) { AdornerLayer = new Adorner(this); AdornerLayer.Selected += OnSelected; AdornerLayer.IsLockScale = true; } }
public override void DesignMode() { if (!IsDesignMode) { AdornerLayer = new Adorner(this); AdornerLayer.Selected += OnSelected; AdornerLayer.IsLockScale = true; var menu = new ContextMenu(); var menuItem = new MenuItem() { Header = "属性" }; menuItem.Click += PropertyMenuItem_Click; menu.Items.Add(menuItem); AdornerLayer.SetValue(ContextMenuService.ContextMenuProperty, menu); } }
public FocusAdorner(FrameworkElement adornedElement) : base(adornedElement) { if (_currentLayer != null) { _currentLayer.Remove(_currentAdorner); } _currentLayer = AdornerLayer.GetAdornerLayer(adornedElement); if (_currentLayer == null) return; _currentAdorner = this; _currentLayer.Add(_currentAdorner); IsHitTestVisible = false; Opacity = 0.5; }
void Connection_Unloaded(object sender, RoutedEventArgs e) { // do some housekeeping when Connection is unloaded // remove event handler this.Source = null; this.Sink = null; // remove adorner if (this.connectionAdorner != null) { DesignerCanvas designer = VisualTreeHelper.GetParent(this) as DesignerCanvas; AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { adornerLayer.Remove(this.connectionAdorner); this.connectionAdorner = null; } } }
private void ShowAdorner() { // the ConnectionAdorner is created once for each Connection if (this.connectionAdorner == null) { DesignerCanvas designer = VisualTreeHelper.GetParent(this) as DesignerCanvas; AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { this.connectionAdorner = new ConnectionAdorner(designer, this); adornerLayer.Add(this.connectionAdorner); } } this.connectionAdorner.Visibility = Visibility.Visible; }
void Connection_Unloaded(object sender, RoutedEventArgs e) { // do some housekeeping when Connection is unloaded // remove event handler source.PropertyChanged -= new PropertyChangedEventHandler(OnConnectorPositionChanged); sink.PropertyChanged -= new PropertyChangedEventHandler(OnConnectorPositionChanged); // remove adorner if (this.connectionAdorner != null) { DesignerCanvas designer = VisualTreeHelper.GetParent(this) as DesignerCanvas; AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(designer); if (adornerLayer != null) { adornerLayer.Remove(this.connectionAdorner); this.connectionAdorner = null; } } }
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods /// <summary> /// Add given Adorner to our children /// </summary> /// <param name="adorner">Adorner to add</param> public void Add(Adorner adorner) { Add(adorner, DefaultZOrder); }
/// <summary> /// Constructor /// </summary> internal AdornerInfo(Adorner adorner) { Invariant.Assert(adorner != null); _adorner = adorner; }
private void HideTargetAdorner() { AdornerLayer myAdornerLayer = AdornerLayer.GetAdornerLayer(Viewport); if (targetAdorner != null) myAdornerLayer.Remove(targetAdorner); targetAdorner = null; }
private void ShowTargetAdorner(Point position) { if (!ShowCameraTarget) return; if (targetAdorner != null) return; AdornerLayer myAdornerLayer = AdornerLayer.GetAdornerLayer(Viewport); targetAdorner = new TargetSymbolAdorner(Viewport, position); myAdornerLayer.Add(targetAdorner); }
/// <summary> /// Shows the target adorner. /// </summary> /// <param name="position"> /// The position. /// </param> public void ShowTargetAdorner(Point position) { if (!this.ShowCameraTarget) { return; } if (this.targetAdorner != null) { return; } var myAdornerLayer = AdornerLayer.GetAdornerLayer(this.Viewport); this.targetAdorner = new TargetSymbolAdorner(this.Viewport, position); myAdornerLayer.Add(this.targetAdorner); }
/// <summary> /// Hides the target adorner. /// </summary> public void HideTargetAdorner() { var myAdornerLayer = AdornerLayer.GetAdornerLayer(this.Viewport); if (this.targetAdorner != null) { myAdornerLayer.Remove(this.targetAdorner); } this.targetAdorner = null; // the adorner sometimes leaves some 'dust', so refresh the viewport this.RefreshViewport(); }
public void Add(Adorner adorner) { _adornerLayer.Add(adorner); }
private void Save_Executed( object sender, ExecutedRoutedEventArgs e ) { if( Save() ) { var adornerLayer = AdornerLayer.GetAdornerLayer( this ); mySavedAdorner = new SavedFeedbackAdorner( ( UIElement )VisualTreeHelper.GetParent( this ) ); adornerLayer.Add( mySavedAdorner ); var dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += OnElapsed; dispatcherTimer.Interval = TimeSpan.FromMilliseconds( 500 ); dispatcherTimer.Start(); } }