Ejemplo n.º 1
0
 void TerminalNodeMouseDown(object sender, MouseButtonEventArgs e)
 {
     if (!this.isClosing)
     {
         TerminalNode tn = sender as TerminalNode;
         if (tn != null)
         {
             if (this.TerminalNodeSelected != null)
             {
                 tn.Visibility = System.Windows.Visibility.Hidden;
                 this.TerminalNodeSelected(this, this.Type, tn.RootIndex);
             }
         }
     }
 }
Ejemplo n.º 2
0
        void TerminalRootSelector_Loaded(object sender, RoutedEventArgs e)
        {
            if (this.terminalIndex < 0 || this.associatedRootIndexes == null || this.renderInfo == null)
            {
                throw new ArgumentException("Cannot create a root selector using these variables");
            }

            this.mainPanel = this.Template.FindName("mainPanel", this) as RelativePositionPanel;

            if (this.mainPanel == null)
            {
                throw new ArgumentNullException("Cannot find the template item mainPanel");
            }

            Point  start        = new Point(0.5, 0);
            double rotation     = 0;
            double rotationStep = 360.0 / this.associatedRootIndexes.Count;

            foreach (int i in this.associatedRootIndexes)
            {
                RotateTransform rotateTransform = new RotateTransform(rotation, 0.5, 0.5);
                Point           rotatedPoint    = rotateTransform.Transform(start);

                SolidColorBrush backgroundBrush = new SolidColorBrush(renderInfo.HighlightedRootColors[i]);
                if (backgroundBrush.CanFreeze)
                {
                    backgroundBrush.Freeze();
                }

                TerminalNode tn = new TerminalNode()
                {
                    Background = backgroundBrush, RootIndex = i, Cursor = Cursors.Hand
                };
                tn.MouseDown += new MouseButtonEventHandler(TerminalNodeMouseDown);
                RelativePositionPanel.SetRelativePositionX(tn, rotatedPoint.X);
                RelativePositionPanel.SetRelativePositionY(tn, rotatedPoint.Y);
                this.mainPanel.Children.Add(tn);

                rotation += rotationStep;
            }

            this.MouseLeftButtonDown  += new MouseButtonEventHandler(TerminalRootSelector_MouseLeftButtonDown);
            this.MouseRightButtonDown += new MouseButtonEventHandler(TerminalRootSelector_MouseRightButtonDown);
        }