Exemple #1
0
        public override void Execute(object parameter)
        {
            homeVM.FilterLocation = "";
            homeVM.FilterName     = "";

            homeVM.RefreshData();
        }
        public override void Execute(object parameter)
        {
            if (viewModel.RedoHistory.Count <= 0)
            {
                MessageBox.Show("Nema nsita za redo");
                return;
            }

            BaseCommand cmd  = viewModel.RedoHistory[viewModel.RedoHistory.Count - 1]; //get last item
            Substation  subs = viewModel.SubstationsRedo[viewModel.SubstationsRedo.Count - 1];

            //Mozda napraviti apstraktnu klasu za sve modele, i u njoj apstraktnu metodu GetParams.
            //Kako ne bih pravio undo/redo komande za svaki model

            //za sad nek ide ovako
            object[] parameters = new object[3];
            parameters[0] = subs.Name;
            parameters[1] = subs.Location;

            if (cmd is DeleteSubstation)
            {
                subs.Id = DataProxy.Instance.Proxy.GetIdOfLastAddedSubstation();
            }

            parameters[2] = subs.Id;

            cmd.Execute(parameters);

            viewModel.RedoHistory.Remove(cmd);
            viewModel.SubstationsRedo.RemoveAt(viewModel.SubstationsRedo.Count - 1);

            viewModel.RefreshData();

            LoginVM.Log.Info("REDO command invoked");
        }
        public override void Execute(object parameter)
        {
            if (homeVM.selectedDevice == null || homeVM.selectedDevice.Id == "")
            {
                MessageBox.Show("Select device to delete", "Info");
                return;
            }

            DataProxy.Instance.Proxy.DeleteDevice(homeVM.selectedDevice.Id);
            LoginVM.Log.Info($"Device deleted. Id=('{homeVM.selectedDevice.Id}')");

            homeVM.RefreshData();
        }
Exemple #4
0
        public override void Execute(object parameter)
        {
            if (homeVM.selectedMeasurement == null)
            {
                MessageBox.Show("Select measurement to delete", "Info");
                return;
            }

            DataProxy.Instance.Proxy.DeleteMeasurement(homeVM.selectedMeasurement.Id);
            LoginVM.Log.Info($"Measurement deleted. Id=('{homeVM.selectedMeasurement.Id}')");

            homeVM.RefreshData();
        }
        public override void Execute(object parameter) //SHOULD pass substation as parameter
        {
            if (parameter == null)
            {
                return;
            }

            //Substation subs = viewModel.selectedSubstation as Substation;
            Substation subs = parameter as Substation;

            if (subs == null)
            {
                try
                {
                    //parse parameters sent by undo/redo command
                    object[] parameters = parameter as object[];
                    subs = new Substation()
                    {
                        Name     = parameters[0].ToString(),
                        Location = parameters[1].ToString(),
                        Id       = int.Parse(parameters[2].ToString()),
                    };
                }
                catch (Exception)
                {
                    return;
                }
            }

            DataProxy.Instance.Proxy.DeleteSubstation(subs.Id);
            viewModel.RefreshData();
            LoginVM.Log.Info($"Substation deleted. Id=('{subs.Id}')");

            viewModel.UndoHistory.Add(this);
            viewModel.SubstationsUndo.Add(subs);
        }