Ejemplo n.º 1
0
        /// <inheritdoc/>
        protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
        {
            if (VisualChildren.Count > 0)
            {
                ((ILogical)VisualChildren[0]).NotifyDetachedFromLogicalTree(e);
            }

            base.OnDetachedFromLogicalTree(e);
        }
Ejemplo n.º 2
0
        protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
        {
            base.OnAttachedToLogicalTree(e);

            if (Command != null)
            {
                Command.CanExecuteChanged += CanExecuteChanged;
            }
        }
Ejemplo n.º 3
0
        protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
        {
            base.OnAttachedToLogicalTree(e);

            if (Items is IList l && l.Count >= 1 && l[0] is ISelectable s)
            {
                SelectSingleItem(s);
            }
        }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
        /*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();
        }
Ejemplo n.º 6
0
 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;
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 10
0
        /// <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;
            }
        }
Ejemplo n.º 11
0
        /// <inheritdoc/>
        protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
        {
            base.OnDetachedFromLogicalTree(e);
            _topLevel = null;

            if (_popupRoot != null)
            {
                ((ISetLogicalParent)_popupRoot).SetParent(null);
                _popupRoot.Dispose();
                _popupRoot = null;
            }
        }
Ejemplo n.º 12
0
        protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
        {
            base.OnDetachedFromLogicalTree(e);

            if (Command != null)
            {
                Command.CanExecuteChanged -= CanExecuteChanged;
            }

            _gridHack?.Dispose();
            _gridHack = null;
        }
Ejemplo n.º 13
0
        /// <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;
            }
        }
Ejemplo n.º 14
0
        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;
            }
        }
Ejemplo n.º 15
0
        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;
            }
        }
Ejemplo n.º 16
0
        /// <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;
        }
Ejemplo n.º 17
0
        /// <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);
            }
        }
Ejemplo n.º 18
0
        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;
                }
            });
        }
Ejemplo n.º 19
0
 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;
         }
     }
Ejemplo n.º 20
0
        /// <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;
        }
Ejemplo n.º 21
0
        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);
            }
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 24
0
        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;
        }
Ejemplo n.º 25
0
 protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
 {
     binder.Dispose();
     base.OnDetachedFromLogicalTree(e);
 }
Ejemplo n.º 26
0
 /// <inheritdoc/>
 protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
 {
     base.OnAttachedToLogicalTree(e);
     _createdChild = false;
     InvalidateMeasure();
 }
Ejemplo n.º 27
0
 protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
 {
     base.OnDetachedFromLogicalTree(e);
     ItemContainerGenerator.UpdateIndex();
 }
Ejemplo n.º 28
0
 /// <inheritdoc/>
 protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
 {
     base.OnAttachedToLogicalTree(e);
     _createdChild = false;
     InvalidateMeasure();
 }
Ejemplo n.º 29
0
 /// <inheritdoc/>
 protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
 {
     base.OnAttachedToLogicalTree(e);
     _topLevel = e.Root as TopLevel;
 }
Ejemplo n.º 30
0
 /// <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();
 }
Ejemplo n.º 31
0
 /// <inheritdoc/>
 protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
 {
     _topLevel = null;
 }
Ejemplo n.º 32
0
 /// <inheritdoc/>
 protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
 {
     base.OnAttachedToLogicalTree(e);
     this.UpdateSelectionBoxItem(this.SelectedItem);
 }
Ejemplo n.º 33
0
 protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
 {
     Order.Add("AttachedToLogicalTree");
     base.OnAttachedToLogicalTree(e);
 }