KeyboardEditor.ViewModels.KeyboardProfileViewModel.OnBeforeNext C# (CSharp) Method

OnBeforeNext() public method

public OnBeforeNext ( ) : bool
return bool
        public override bool OnBeforeNext()
        {
            //if the model is null, it means that we are creating a new keyboard.
            //So we do create it with the user's information.
            if( _model == null )
            {
                _model = Root.KeyboardContext.Service.Keyboards.Create( Name );
                Root.KeyboardBackup = new KeyboardBackup( _model, _backupFileName );
            }
            else if( _model.Name != Name ) _model.Rename( Name );

            Debug.Assert( _model != null, "The keyboard should be created even if the name is already used." );

            _model.CurrentLayout.H = Height;
            _model.CurrentLayout.W = Width;

            //If the EditedContext is not null, it means that we were modifying a keyboard before finishing and going back all the way to modifying another keyboard.
            //We dispose the previous KeyboardEditionViewModel, to unregister events before setting it to null.
            if( Root.EditedContext != null )
            {
                Root.EditedContext.Dispose();
                Root.EditedContext = null;
            }

            Next = new KeyboardEditionViewModel( Root, WizardManager, _model );
            _stepAchieved = true;

            return _model != null;
        }