Example #1
0
        private void Create()
        {
            Project proj = new Project();                                                             //实例化一个新的model
            ProjectEditViewModel projevm = new ProjectEditViewModel(proj, _batteryTypeService.Items); //实例化一个新的view model

            projevm.DisplayName = "Project-Create";
            var ProjectEditViewInstance = new ProjectView();      //实例化一个新的view

            ProjectEditViewInstance.DataContext = projevm;
            ProjectEditViewInstance.ShowDialog();                   //设置viewmodel属性
            if (projevm.IsOK == true)
            {
                _projectService.SuperAdd(proj);
            }
        }
Example #2
0
        private void SaveAs()
        {
            Project proj = new Project();                                                             //实例化一个新的model
            ProjectEditViewModel projevm = new ProjectEditViewModel(proj, _batteryTypeService.Items); //实例化一个新的view model

            projevm.DisplayName            = "Project-Save As";
            projevm.Name                   = _selectedItem.Name;
            projevm.Customer               = _selectedItem.Customer;
            projevm.BatteryType            = _selectedItem.BatteryType;
            projevm.Description            = _selectedItem.Description;
            projevm.CutoffDischargeVoltage = _selectedItem.CutoffDischargeVoltage;
            projevm.LimitedChargeVoltage   = _selectedItem.LimitedChargeVoltage;
            projevm.AbsoluteMaxCapacity    = _selectedItem.AbsoluteMaxCapacity;
            projevm.VoltagePoints          = _selectedItem.VoltagePoints;

            var ProjectEditViewInstance = new ProjectView();      //实例化一个新的view

            ProjectEditViewInstance.DataContext = projevm;
            ProjectEditViewInstance.ShowDialog();
            if (projevm.IsOK == true)
            {
                _projectService.SuperAdd(proj);
            }
        }