void CreateNewBatteryType()
        {
            BatteryTypeClass     newBatteryType = new BatteryTypeClass();
            BatteryTypeViewModel workspace      = new BatteryTypeViewModel(newBatteryType, _repositories._batterytypeRepository);

            this.Workspaces.Add(workspace);
            this.SetActiveWorkspace(workspace);
        }
Пример #2
0
        /// <summary>
        /// Create a new battery type, based on the given value.  This method is invoked by the SaveAsCommand.
        /// </summary>
        public void SaveAs()
        {
            BatteryTypeClass newBatteryType =
                new BatteryTypeClass(
                    this._batterytype.Manufactor,
                    this._batterytype.Name,
                    this._batterytype.Material,
                    this._batterytype.LimitedChargeVoltage,
                    this._batterytype.RatedCapacity,
                    this._batterytype.NominalVoltage,
                    this._batterytype.TypicalCapacity,
                    this._batterytype.CutoffDischargeVoltage);
            BatteryTypeViewModel workspace = new BatteryTypeViewModel(base.mainWindowViewModel, newBatteryType, this._batterytypeRepository);

            this.mainWindowViewModel.Workspaces.Add(workspace);
            this.mainWindowViewModel.SetActiveWorkspace(workspace);
        }
        /*void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
         * {
         *  if (e.NewItems != null && e.NewItems.Count != 0)
         *      foreach (BatteryModelViewModel batmodVM in e.NewItems)
         *          batmodVM.PropertyChanged += this.OnBatteryModelViewModelPropertyChanged;
         *
         *  if (e.OldItems != null && e.OldItems.Count != 0)
         *      foreach (BatteryModelViewModel batmodVM in e.OldItems)
         *          batmodVM.PropertyChanged -= this.OnBatteryModelViewModelPropertyChanged;
         * }*/

        /*void OnBatteryModelViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
         * {
         *  string IsSelected = "IsSelected";
         *
         *  // Make sure that the property name we're referencing is valid.
         *  // This is a debugging technique, and does not execute in a Release build.
         *  (sender as BatteryModelViewModel).VerifyPropertyName(IsSelected);
         *
         *  // When a customer is selected or unselected, we must let the
         *  // world know that the TotalSelectedSales property has changed,
         *  // so that it will be queried again for a new value.
         *  if (e.PropertyName == IsSelected)
         *      this.OnPropertyChanged("TotalSelectedSales");
         * }*/

        void OnBatteryModelAddedToRepository(object sender, ItemAddedEventArgs <BatteryTypeClass> e)
        {
            var viewModel = new BatteryTypeViewModel(base.mainWindowViewModel, e.NewItem, _batterytypeRepository);

            this.AllBatteryModels.Add(viewModel);
        }