Exemple #1
0
        private void ClassificationBoxChanged(object sender, SelectionChangedEventArgs e)
        {
            NodeButton nb     = getSelectedNodeButton();
            ComboBox   source = (ComboBox)e.Source;
            Mode       mode   = (Mode)Enum.Parse(typeof(Mode), source.SelectedValue.ToString());

            nb.association.node.classification = Classification.GetClassificationByMode(mode);
            NodeButton selected = getSelectedNodeButton();

            updateNodeButtons(centerButton.association);
            selected.select = true;
            //refreshList();
            nb.association.treeItem.updateHeader();
        }
Exemple #2
0
        /// <summary>
        /// Traverse up from the current root
        /// </summary>
        public void NavigateUp()
        {
            NodeTreeItem current;
            NodeTreeItem parent;

            current = (NodeTreeItem)nodeListView.SelectedValue;
            if (current == null)
            {
                NodeButton      nb          = getSelectedNodeButton();
                NodeAssociation association = nb.association;
                Node            n           = association.node;
                current = association.treeItem;
            }
            parent = current.parent;
            if (parent != null)
            {
                parent.IsSelected = true;
            }
        }
Exemple #3
0
        public MainWindow()
        {
            InitializeComponent();

            //Find items and pre-fill if applicable
            #region Find UI Elements
            nodeListView   = (TreeView)this.FindName("NodeTreeView");
            propertiesGrid = (Grid)this.FindName("PropertiesGrid");

            classificationBox = (ComboBox)propertiesGrid.FindName("ClassificationBox");
            foreach (Mode mode in (Mode[])Enum.GetValues(typeof(Mode)))
            {
                classificationBox.Items.Add(mode.ToString());
            }

            topButton    = new NodeButton((Canvas)this.FindName("TopButton"));
            rightButton  = new NodeButton((Canvas)this.FindName("RightButton"));
            bottomButton = new NodeButton((Canvas)this.FindName("BottomButton"));
            leftButton   = new NodeButton((Canvas)this.FindName("LeftButton"));
            centerButton = new NodeButton((Canvas)this.FindName("CenterButton"));
            upButton     = (Button)this.FindName("UpButton");

            nodeButtons = new Dictionary <Direction, NodeButton>();
            nodeButtons[Direction.Up]     = topButton;
            nodeButtons[Direction.Right]  = rightButton;
            nodeButtons[Direction.Down]   = bottomButton;
            nodeButtons[Direction.Left]   = leftButton;
            nodeButtons[Direction.Middle] = centerButton;

            foreach (KeyValuePair <Direction, NodeButton> nodeButton in nodeButtons)
            {
                Classification[] classificationArr = new Classification[] { Classification.getNormal(), Classification.getIntermediary(), Classification.getFinal() };
                foreach (Classification temp in classificationArr)
                {
                    if (temp.shape == Shape.Circle)
                    {
                        nodeButton.Value.circle.Fill = new SolidColorBrush(temp.color);
                    }
                    if (temp.shape == Shape.Square)
                    {
                        nodeButton.Value.square.Fill = new SolidColorBrush(temp.color);
                    }
                    if (temp.shape == Shape.Diamond)
                    {
                        nodeButton.Value.diamond.Fill = new SolidColorBrush(temp.color);
                    }
                }

                nodeButton.Value.Visibility = Visibility.Hidden;
                nodeButton.Value.select     = false;

                nodeButton.Value.canvas.MouseLeftButtonDown += new MouseButtonEventHandler(NodeButton_Click);
            }
            #endregion

            upButton.Click += (s, e) => { NavigateUp(); };

            Load();
            if (root == null)
            {
                Node         rootNode = new Node(Classification.getNormal(), Direction.Middle);
                NodeTreeItem rootItem = new NodeTreeItem();
                root = new NodeAssociation(rootNode, rootItem);
            }

            propertiesGrid.IsEnabled = false;

            refreshList();
            NodeTreeItem rootListItem = (NodeTreeItem)nodeListView.Items[0];
            rootListItem.IsSelected = true; //This should trigger a refresh
        }