Exemplo n.º 1
0
        internal void Change()
        {
            // in yet in change mode
            if (_currentChangeMode == E_ChangeMode.no_change)
            {
                // check if changing is possible and switch controls
                _currentChangeMode = DoChange();

                // switch label if changing possible
                if (_currentChangeMode != E_ChangeMode.no_change)
                {
                    Window.Location_ChangeButton.Content = "Save";
                }
            }
            else
            {
                // re-enable controls again
                ResetControlState();

                // save the changes to the database
                SaveChangeChanges();

                // ask maincontroler to reload data from database and refresh all controls
                // maincontroler needs to take care of this since it not only settings tab
                MainControler.ReloadAndRefreshControls();

                // reset the modes
                _currentChangeMode = E_ChangeMode.no_change;
            }
        }
Exemplo n.º 2
0
        internal E_ChangeMode DoChange()
        {
            E_ChangeMode changeMode = E_ChangeMode.no_change;

            // check which controls have text and objects (are in DB)
            var hasShootingLocationText = !string.IsNullOrEmpty(Window.Location_SubjectLocationControl.GetCurrentText());
            var shootingLocationInDB    = Window.Location_SubjectLocationControl.GetCurrentObject() != null;

            var hasParkingLocationText = !string.IsNullOrEmpty(Window.ParkingLocationControl.GetCurrentText());
            var parkingLocationInDB    = Window.ParkingLocationControl.GetCurrentObject() != null;

            if (shootingLocationInDB && !parkingLocationInDB)
            {
                SwitchChangeModeShootingLocation();
                changeMode = E_ChangeMode.change_shootingLocation;
            }

            else if (!shootingLocationInDB && parkingLocationInDB)
            {
                SwitchChangeModeParkingLocation();
                changeMode = E_ChangeMode.change_parkingLocation;
            }

            else if (shootingLocationInDB && parkingLocationInDB)
            {
                EditChangeSelectionWindow window = new EditChangeSelectionWindow(EditChangeSelectionWindow.EMode.change);
                window.ShowDialog();

                if (window.DialogResult is true)
                {
                    if (window.ShootingLocationRadioButton.IsChecked is true)
                    {
                        SwitchChangeModeShootingLocation();
                        changeMode = E_ChangeMode.change_shootingLocation;
                    }
                    else if (window.ParkingLocationRadioButton.IsChecked is true)
                    {
                        SwitchChangeModeParkingLocation();
                        changeMode = E_ChangeMode.change_parkingLocation;
                    }
                }
            }

            // changing is not possible - probably user wants to edit values that are not added to DB yet
            else
            {
                ShowMessage("Changing not possible (you might have entered new values)", E_MessageType.info);
            }

            return(changeMode);
        }
Exemplo n.º 3
0
        public LocationTabControler(MainWindowControler mainControler, MainWindow window) : base(window, mainControler)
        {
            DisplayItem = new LocationDisplayItem();

            Window.LocationContentGrid.DataContext  = DisplayItem;
            Window.ShootingLocationControl.Leaving += ShootingLocationNameControl_Leaving;
            Window.ParkingLocationControl.Leaving  += ParkingLocationControl_Leaving;

            RefreshShootingLocationsFromDB();
            RefreshParkingLocationsFromDB();

            _listerWindow = new LocationListerWindow(base.Window, this);

            _currentChangeMode = E_ChangeMode.no_change;
        }