Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Loaded event of this control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void This_Loaded(object sender, RoutedEventArgs e)
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                this.NodeViewer = LayoutHelper.FindLogicalParent <UcNodeViewer>(this, true);
                if (this.NodeViewer == null)
                {
                    this.NodeViewer = LayoutHelper.FindVisualParent <UcNodeViewer>(this, true);
                }

                if (this.NodeViewer != null && !this.IsPreview)
                {
                    this.treeDesigner = LayoutHelper.FindLogicalParent <UcTreeDesigner>(this.NodeViewer, true);
                    if (this.treeDesigner != null)
                    {
                        this.treeDesigner.RegisterIOHandle(this);

                        DisposablesHandler.Instance.AddDisposeConnection(this,
                                                                         PropertyChangedHandle.GetDistinctInstance(this.treeDesigner, "ConnectingIOHandle", this.OnTreeDesignerConnectingIOHandleChanged));
                    }

                    DisposablesHandler.Instance.AddDisposeConnection(this,
                                                                     PropertyChangedHandle.GetDistinctInstance(this.NodeViewer, "IsSelected", this.OnNodeViewerIsSelectedChanged));
                }
            }
            LoadedCompletely = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Property Changed Callback method of the IsSelected Dependency Property.
        /// </summary>
        /// <param name="sender">The instance of the class that had the IsSelected property changed.</param>
        /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void OnIsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            UcNodeViewer subject  = (UcNodeViewer)sender;
            bool         newValue = (bool)e.NewValue;
            bool         oldValue = (bool)e.OldValue;

            if (newValue)
            {
                UcTreeDesigner treeDesigner = LayoutHelper.FindLogicalParent <UcTreeDesigner>(subject, true);
                if (treeDesigner != null)
                {
                    treeDesigner.onNodeViewerSelected(subject);
                }
            }
        }