コード例 #1
0
        private void Create()
        {
            TableMakerProduct editItem          = new TableMakerProduct();                                                                                 //实例化一个新的model
            TableMakerProductEditViewModel bevm = new TableMakerProductEditViewModel(editItem, _projectService.Items, _tableMakerProductTypeServie.Items); //实例化一个新的view model

            bevm.DisplayName = "Table Maker Product-Create";
            bevm.commandType = CommandType.Create;
            var TableMakerProductViewInstance = new TableMakerProductView();      //实例化一个新的view

            TableMakerProductViewInstance.DataContext = bevm;
            TableMakerProductViewInstance.ShowDialog();                   //设置viewmodel属性
            if (bevm.IsOK == true)
            {
                _tableMakerProductService.FileOperation(editItem);
                _tableMakerProductService.SuperAdd(editItem);
            }
        }
コード例 #2
0
        private void SaveAs()
        {
            TableMakerProduct bc = new TableMakerProduct();                                                                                          //实例化一个新的model
            TableMakerProductEditViewModel bevm = new TableMakerProductEditViewModel(bc, _projectService.Items, _tableMakerProductTypeServie.Items); //实例化一个新的view model

            bevm.FilePath = _selectedItem.FilePath;
            bevm.Project  = bevm.AllProjects.SingleOrDefault(i => i.Id == _selectedItem.Project.Id);
            bevm.TableMakerProductType = bevm.AllTableMakerProductTypes.SingleOrDefault(i => i.Id == _selectedItem.TableMakerProductType.Id);
            bevm.IsValid     = _selectedItem.IsValid;
            bevm.DisplayName = "Table Maker Product-Save As";
            bevm.commandType = CommandType.SaveAs;
            var TableMakerProductViewInstance = new TableMakerProductView();      //实例化一个新的view

            TableMakerProductViewInstance.DataContext = bevm;
            TableMakerProductViewInstance.ShowDialog();
            if (bevm.IsOK == true)
            {
                _tableMakerProductService.SuperAdd(bc);
            }
        }
コード例 #3
0
        private void Edit()
        {
            TableMakerProduct editItem          = new TableMakerProduct();                                                                                 //实例化一个新的model
            TableMakerProductEditViewModel bevm = new TableMakerProductEditViewModel(editItem, _projectService.Items, _tableMakerProductTypeServie.Items); //实例化一个新的view model

            bevm.Id       = _selectedItem.Id;
            bevm.FilePath = _selectedItem.FilePath;
            bevm.Project  = bevm.AllProjects.SingleOrDefault(i => i.Id == _selectedItem.Project.Id);
            bevm.IsValid  = _selectedItem.IsValid;
            bevm.TableMakerProductType = bevm.AllTableMakerProductTypes.SingleOrDefault(i => i.Id == _selectedItem.TableMakerProductType.Id);   //所以改用Id来找到List里的item
            bevm.DisplayName           = "Table Maker Product-Edit";
            bevm.commandType           = CommandType.Edit;
            var TableMakerProductViewInstance = new TableMakerProductView();      //实例化一个新的view

            TableMakerProductViewInstance.DataContext = bevm;
            TableMakerProductViewInstance.ShowDialog();
            if (bevm.IsOK == true)
            {
                _tableMakerProductService.SuperUpdate(editItem);
            }
        }