/// <inheritdoc/> protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { if (VisualChildren.Count > 0) { ((ILogical)VisualChildren[0]).NotifyDetachedFromLogicalTree(e); } base.OnDetachedFromLogicalTree(e); }
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); if (Command != null) { Command.CanExecuteChanged += CanExecuteChanged; } }
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); if (Items is IList l && l.Count >= 1 && l[0] is ISelectable s) { SelectSingleItem(s); } }
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { if (e.Root is Window window) { // need to subscribe the event this way because close gets called after all elements get detached window.AddHandler(Window.WindowClosedEvent, (EventHandler <RoutedEventArgs>)OnHostWindowClosed); } base.OnAttachedToLogicalTree(e); }
/*public RibbonGroupsStackPanel() * { * LayoutUpdated += (sneder, args) => UpdateLayoutState(); * }*/ /*protected override void ChildrenChanged(object sender, NotifyCollectionChangedEventArgs e) * { * base.ChildrenChanged(sender, e); * SizeControls(); * }*/ protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); /*Measure(Bounds.Size); * Arrange(Bounds);*/ SizeControls(); }
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { _logicalRoot = null; base.OnDetachedFromLogicalTree(e); foreach (var l in _layers) { ((ILogical)l).NotifyDetachedFromLogicalTree(e); } }
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnDetachedFromLogicalTree(e); _unpremulBitmap?.Dispose(); _unpremulBitmap = null; _premulBitmap?.Dispose(); _unpremulBitmap = null; }
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); _logicalRoot = e.Root; foreach (var l in _layers) { ((ILogical)l).NotifyAttachedToLogicalTree(e); } }
private void OnElementAttached(object sender, LogicalTreeAttachmentEventArgs e) { if (!(sender is StyledElement element)) { return; } SetElement(element); AttachExtensions(); }
/// <summary> /// Called when the control is added to a rooted logical tree. /// </summary> /// <param name="e">The event args.</param> protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); _treeView = this.GetLogicalAncestors().OfType <TreeView>().FirstOrDefault(); if (ItemTemplate == null && _treeView?.ItemTemplate != null) { ItemTemplate = _treeView.ItemTemplate; } }
/// <inheritdoc/> protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnDetachedFromLogicalTree(e); _topLevel = null; if (_popupRoot != null) { ((ISetLogicalParent)_popupRoot).SetParent(null); _popupRoot.Dispose(); _popupRoot = null; } }
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnDetachedFromLogicalTree(e); if (Command != null) { Command.CanExecuteChanged -= CanExecuteChanged; } _gridHack?.Dispose(); _gridHack = null; }
/// <inheritdoc/> protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); _treeView = this.GetLogicalAncestors().OfType <TreeView>().FirstOrDefault(); Level = CalculateDistanceFromLogicalParent <TreeView>(this) - 1; ItemContainerGenerator.UpdateIndex(); if (ItemTemplate == null && _treeView?.ItemTemplate != null) { ItemTemplate = _treeView.ItemTemplate; } }
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { if (_hotkey != null) // Control attached again, set Hotkey to create a hotkey manager for this control { HotKey = _hotkey; } base.OnAttachedToLogicalTree(e); if (Command != null) { Command.CanExecuteChanged += CanExecuteChanged; } }
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { // This will cause the hotkey manager to dispose the observer and the reference to this control if (HotKey != null) { _hotkey = HotKey; HotKey = null; } base.OnDetachedFromLogicalTree(e); if (Command != null) { Command.CanExecuteChanged -= CanExecuteChanged; } }
/// <summary> /// Handles a closed notification from <see cref="ITopLevelImpl.Closed"/>. /// </summary> protected virtual void HandleClosed() { var logicalArgs = new LogicalTreeAttachmentEventArgs(this, this, null); ((ILogical)this).NotifyDetachedFromLogicalTree(logicalArgs); var visualArgs = new VisualTreeAttachmentEventArgs(this, this); OnDetachedFromVisualTreeCore(visualArgs); (this as IInputRoot).MouseDevice?.TopLevelClosed(this); PlatformImpl = null; OnClosed(EventArgs.Empty); Renderer?.Dispose(); Renderer = null; }
/// <summary> /// Sets the control's logical parent. /// </summary> /// <param name="parent">The parent.</param> void ISetLogicalParent.SetParent(ILogical parent) { var old = Parent; if (parent != old) { if (old != null && parent != null) { throw new InvalidOperationException("The Control already has a parent."); } if (_isAttachedToLogicalTree) { var oldRoot = FindStyleRoot(old); if (oldRoot == null) { throw new AvaloniaInternalException("Was attached to logical tree but cannot find root."); } var e = new LogicalTreeAttachmentEventArgs(oldRoot); OnDetachedFromLogicalTreeCore(e); } if (InheritanceParent == null || parent == null) { InheritanceParent = parent as AvaloniaObject; } _parent = (IControl)parent; if (_parent is IStyleRoot || _parent?.IsAttachedToLogicalTree == true) { var newRoot = FindStyleRoot(this); if (newRoot == null) { throw new AvaloniaInternalException("Parent is atttached to logical tree but cannot find root."); } var e = new LogicalTreeAttachmentEventArgs(newRoot); OnAttachedToLogicalTreeCore(e); } RaisePropertyChanged(ParentProperty, old, _parent, BindingPriority.LocalValue); } }
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { _editor = this.FindControl <Standard.CodeEditor.CodeEditor>("editor"); _editor.RequestTooltipContent += _editor_RequestTooltipContent; shell = IoC.Get <IShell>(); _editor.GetObservable(AvalonStudio.Controls.Standard.CodeEditor.CodeEditor.IsDirtyProperty).Subscribe(dirty => { if (dirty && DataContext is EditorViewModel editorVm) { editorVm.Dock = Dock.Left; // Selecting the document event though it already is, causes it to be removed from the temporary document cache. editorVm.IsTemporary = false; shell.SelectedDocument = editorVm; } }); }
public void SetParent(ILogical?parent) { if (this.LogicalParent != null) { if (this.LogicalParent.Traverse(c => c.LogicalParent). OfType <ILogicalRoot>(). FirstOrDefault() is { } root) { var e = new LogicalTreeAttachmentEventArgs( root, this, this.LogicalParent); this.LogicalParent = null; this.OnNotifyDetachedFromLogicalTree(e); } else { this.LogicalParent = null; } }
/// <summary> /// Handles a closed notification from <see cref="ITopLevelImpl.Closed"/>. /// </summary> protected virtual void HandleClosed() { if (_globalStyles is object) { _globalStyles.GlobalStylesAdded -= ((IStyleHost)this).StylesAdded; _globalStyles.GlobalStylesRemoved -= ((IStyleHost)this).StylesRemoved; } var logicalArgs = new LogicalTreeAttachmentEventArgs(this, this, null); ((ILogical)this).NotifyDetachedFromLogicalTree(logicalArgs); var visualArgs = new VisualTreeAttachmentEventArgs(this, this); OnDetachedFromVisualTreeCore(visualArgs); (this as IInputRoot).MouseDevice?.TopLevelClosed(this); PlatformImpl = null; OnClosed(EventArgs.Empty); Renderer?.Dispose(); Renderer = null; }
private void OnAttachedToLogicalTreeCore(LogicalTreeAttachmentEventArgs e) { // This method can be called when a control is already attached to the logical tree // in the following scenario: // - ListBox gets assigned Items containing ListBoxItem // - ListBox makes ListBoxItem a logical child // - ListBox template gets applied; making its Panel get attached to logical tree // - That AttachedToLogicalTree signal travels down to the ListBoxItem if (!_isAttachedToLogicalTree) { _isAttachedToLogicalTree = true; InitializeStylesIfNeeded(true); OnAttachedToLogicalTree(e); } foreach (var child in LogicalChildren.OfType <Control>()) { child.OnAttachedToLogicalTreeCore(e); } }
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { _editor = this.FindControl <Standard.CodeEditor.CodeEditor>("editor"); _editor.RequestTooltipContent += _editor_RequestTooltipContent; shell = IoC.Get <IShell>(); _editor.GetObservable(AvalonStudio.Controls.Standard.CodeEditor.CodeEditor.IsDirtyProperty).Subscribe(dirty => { if (dirty && DataContext is EditorViewModel editorVm) { editorVm.Dock = Dock.Left; // Selecting the document event though it already is, causes it to be removed from the temporary document cache. editorVm.IsTemporary = false; shell.SelectedDocument = editorVm; } }); _editor.AddHandler(PointerWheelChangedEvent, (sender, ee) => { _editorViewModel?.OnPointerWheelChanged(ee); }, Avalonia.Interactivity.RoutingStrategies.Tunnel, handledEventsToo: true); }
/// <inheritdoc /> protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); var newMainWindow = e.Parent as Window; if (!ReferenceEquals(newMainWindow, _mainWindow)) { if (_mainWindow != null) { _mainWindow.PropertyChanged -= this.OnMainWindow_PropertyChanged; } _mainWindow = newMainWindow; if (_mainWindow != null) { _mainWindow.PropertyChanged += this.OnMainWindow_PropertyChanged; } } // Trigger update of this control's state Dispatcher.UIThread.Post(this.UpdateFrameState); }
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { if (_hotkey != null) // Control attached again, set Hotkey to create a hotkey manager for this control { HotKey = _hotkey; } base.OnAttachedToLogicalTree(e); if (Command != null) { Command.CanExecuteChanged += CanExecuteChanged; } var parent = Parent; while (parent is MenuItem) { parent = parent.Parent; } _isEmbeddedInMenu = parent is IMenu; }
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { binder.Dispose(); base.OnDetachedFromLogicalTree(e); }
/// <inheritdoc/> protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); _createdChild = false; InvalidateMeasure(); }
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnDetachedFromLogicalTree(e); ItemContainerGenerator.UpdateIndex(); }
/// <inheritdoc/> protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); _topLevel = e.Root as TopLevel; }
/// <summary> /// Called when the control is added to a rooted logical tree. /// </summary> /// <param name="e">The event args.</param> protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); InvalidateFormattedText(); }
/// <inheritdoc/> protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { _topLevel = null; }
/// <inheritdoc/> protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); this.UpdateSelectionBoxItem(this.SelectedItem); }
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { Order.Add("AttachedToLogicalTree"); base.OnAttachedToLogicalTree(e); }