コード例 #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
        public MainWindow()
        {
            InitializeComponent();

            m_ModelView          = new SectionBarModel();
            mainGrid.DataContext = m_ModelView;

            projectBrowser.ItemsSource = m_ItemList;

            // commands
            CommandBindings.Add(new CommandBinding(ApplicationCommands.New, OnNew));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, OnSave));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, OnOpen));

            CommandBindings.Add(new CommandBinding(TheCommands.LoadModel, OnLoadModel));
            CommandBindings.Add(new CommandBinding(TheCommands.Export, OnExport));

            CommandBindings.Add(new CommandBinding(TheCommands.AddCircleHole, OnAddCircleHole));

            CommandBindings.Add(new CommandBinding(TheCommands.ZoomToFit, OnZoomToFit));
            CommandBindings.Add(new CommandBinding(TheCommands.ZoomOut, OnZoomOut));
            CommandBindings.Add(new CommandBinding(TheCommands.ZoomIn, OnZoomIn));
            CommandBindings.Add(new CommandBinding(TheCommands.ViewWH, OnViewWH));
            CommandBindings.Add(new CommandBinding(TheCommands.ViewXH, OnViewXH));
            CommandBindings.Add(new CommandBinding(TheCommands.View3D, OnView3D));

            m_StockedDrills = new ObservableCollection <KnifeTool>();
            m_StockedDrills.Add(new KnifeTool());
            KnifeTool dp2 = new KnifeTool();

            dp2.Name        = "2";
            dp2.RotateSpeed = 15000;
            m_StockedDrills.Add(dp2);

            m_UIFactory = new PathShapeUIFactory();
        }