コード例 #1
0
        public void OnModelChanged(object sender, ModelChangeEvent e)
        {
            if (e.changeType == EnumDataChange.DC_ADD)
            {
                if (e.modelType == EnumModelType.MT_WorkShape)
                {
                    WorkShapeModel mv = sender as WorkShapeModel;

                    TreeNodeItem rootItem = new TreeNodeItem()
                    {
                        Icon        = @"Images\Project\Bar.png",
                        DisplayName = "工件"
                    };

                    TreeNodeItem dxfItem = new TreeNodeItem()
                    {
                        Icon        = @"Images\Start\LoadDXF.png",
                        DisplayName = mv.ActiveWorkShape.Name
                    };
                    rootItem.Children.Add(dxfItem);
                    m_ItemList.Add(rootItem);

                    TreeNodeItem toolItem = new TreeNodeItem()
                    {
                        Icon        = @"Images\Project\Tool.png",
                        DisplayName = "加工"
                    };
                    m_ItemList.Add(toolItem);
                }
                else if (e.modelType == EnumModelType.MT_Task)
                {
                    TreeNodeItem rootItem = new TreeNodeItem()
                    {
                        Icon        = m_ModelView.ActiveTask.Path.Icon,
                        DisplayName = String.Format("#{0}", m_ModelView.ActiveTask.Id),
                        Tag         = m_ModelView.ActiveTask
                    };
                    m_ItemList[1].Children.Add(rootItem);
                }
            }
            else if (e.changeType == EnumDataChange.DC_DELETE)
            {
                if (e.modelType == EnumModelType.MT_Task)
                {
                    foreach (TreeNodeItem item in m_ItemList[1].Children)
                    {
                        if (item.Tag == m_ModelView.ActiveTask)
                        {
                            m_ItemList[1].Children.Remove(item);
                            break;
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void projectBrowser_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            TreeNodeItem item = this.projectBrowser.SelectedItem as TreeNodeItem;

            if (item == null)
            {
                return;
            }

            MachineTask task = item.Tag as MachineTask;

            if (task != null)
            {
                BeginEditTask(task);
            }
        }