예제 #1
0
        void LoadSceneCommand_Executing(object sender, CancelCommandEventArgs args)
        {
            //  Use the serialization engine.
            var engine = SharpGL.Serialization.SerializationEngine.Instance;

            //  Create an open file dialog.
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = engine.Filter;

            //  Show the dialog.
            if (openFileDialog.ShowDialog() != true)
            {
                //  Cancel any loading.
                args.Cancel = true;
                return;
            }

            //  Load the scene.
            Scene scene = engine.LoadScene(openFileDialog.FileName);

            //  Set the args.
            args.Parameter = scene;

            //  Create in the current OpenGL context.
            scene.CreateInContext(viewModel.Scene.CurrentOpenGLContext);

            //  Switch the scene over.
            viewModel.SelectedElements.Clear();
            viewModel.Scene = scene;
        }
예제 #2
0
        private void ShowPopupCommandOnExecuting(object sender, CancelCommandEventArgs args)
        {
            var shell = ApexBroker.GetShell();

            ViewModel.PopupResult =
                shell.ShowPopup(new SimplePopup());
        }
예제 #3
0
        public override async void DoExecute(object paramObject)
        {
            if (IsExecuting)
            {
                return;
            }

            var args = new CancelCommandEventArgs
            {
                Parameter = paramObject,
                Cancel    = false
            };

            InvokeExecuting(args);

            if (args.Cancel)
            {
                return;
            }

            // We are executing.
            IsExecuting = true;
            CancelCommand.NotifyCanExecuteChanged();
            _cts   = new CancellationTokenSource();
            _token = _cts.Token;
            await DoExecuteAsync(paramObject);
        }
예제 #4
0
        private void ShowFadePopupCommandOnExecuting(object sender, CancelCommandEventArgs args)
        {
            var shell = ApexBroker.GetShell();

            shell.PopupAnimationHelper = new FadeInOutPopupAnimationHelper();
            shell.ShowPopup(new CustomisedPopup());
        }
예제 #5
0
        public virtual void DoExecute(object param)
        {
            //  Вызывает выполнении команды с возможностью отмены
            CancelCommandEventArgs args =
                new CancelCommandEventArgs()
            {
                Parameter = param, Cancel = false
            };

            InvokeExecuting(args);

            //  Если событие было отменено -  останавливаем.
            if (args.Cancel)
            {
                return;
            }

            //  Вызываем действие с / без параметров, в зависимости от того. Какое было устанвленно.
            InvokeAction(param);

            //  Call the executed function.
            InvokeExecuted(new CommandEventArgs()
            {
                Parameter = param
            });
        }
예제 #6
0
        /// <summary>
        /// The invoke executing.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        private void InvokeExecuting(CancelCommandEventArgs args)
        {
            CancelCommandEventHandler executing = Executing;

            if (executing != null)
            {
                executing(this, args);
            }
        }
예제 #7
0
 /// <summary>
 /// Handles the Executed event of the DealNewGameCommand control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="args">The <see cref="Apex.MVVM.CommandEventArgs"/> instance containing the event data.</param>
 void SpiderDealNewGameCommand_Executing(object sender, CancelCommandEventArgs args)
 {
     //  If we've made any moves, update the stats.
     if (SpiderSolitaireViewModel.Moves > 0)
     {
         SpiderSolitaireStatistics.UpdateStatistics(SpiderSolitaireViewModel);
     }
     Save();
 }
예제 #8
0
        protected void InvokeExecuting(CancelCommandEventArgs args)
        {
            CancelCommandEventHandler executing = Executing;

            //  Call the executed event.
            if (executing != null)
            {
                executing(this, args);
            }
        }
예제 #9
0
 void OnFuncCommandExecuting(object sender, CancelCommandEventArgs args)
 {
     if (String.IsNullOrWhiteSpace(this.TextToSearch))
     {
         App.ShowWarning("Нечего искать!");
         args.Cancel = true;
         return;
     }
     args.Parameter = this;
     Status         = "Ожидание данных ...";
     State          = State.Busy;
 }
예제 #10
0
        /// <summary>
        /// Handles the Executing event of the FileSaveAsCommand control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="Apex.MVVM.CancelCommandEventArgs"/> instance containing the event data.</param>
        void FileSaveAsCommand_Executing(object sender, CancelCommandEventArgs args)
        {
            //  Create a Save File Dialog.
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            //  If the user cancels, end the command.
            if (saveFileDialog.ShowDialog() != true)
            {
                //  Cancel the command.
                args.Cancel = true;
                return;
            }

            //  Set the parameter to the path.
            args.Parameter = saveFileDialog.FileName;
        }
예제 #11
0
        private void ToolStripMenuItem_Click(System.Object sender, System.EventArgs e)
        {
            Command cmd = GetCommandForInstance((ToolStripDropDownItem)sender);
            CancelCommandEventArgs args = new CancelCommandEventArgs();

            args.Checked = cmd.Checked;
            args.Enabled = cmd.Enabled;
            args.Visible = cmd.Visible;
            if (this.CommandExecute != null)
            {
                this.CommandExecute(sender, args);
            }
            if (args.Cancel == false)
            {
                cmd.Enabled = args.Enabled;
                cmd.Checked = args.Checked;
                cmd.Visible = args.Visible;
                cmd.Execute();
            }
        }
예제 #12
0
        //Check

        private void ListView_DoubleClick(object sender, System.EventArgs e)
        {
            Command cmd = GetCommandForInstance((ListView)sender);
            CancelCommandEventArgs args = new CancelCommandEventArgs();

            args.Checked = cmd.Checked;
            args.Enabled = cmd.Enabled;
            args.Visible = cmd.Visible;
            if (this.CommandExecute != null)
            {
                this.CommandExecute(sender, args);
            }
            if (args.Cancel == false)
            {
                cmd.Enabled = args.Enabled;
                cmd.Checked = args.Checked;
                cmd.Visible = args.Visible;
                cmd.Execute();
            }
        }
예제 #13
0
        // Execution event handler
        private void toolbar_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
        {
            Command cmd = GetCommandForInstance(e.Button);
            CancelCommandEventArgs args = new CancelCommandEventArgs();

            args.Checked = cmd.Checked;
            args.Enabled = cmd.Enabled;
            args.Visible = cmd.Visible;
            if (this.CommandExecute != null)
            {
                this.CommandExecute(sender, args);
            }
            if (args.Cancel == false)
            {
                cmd.Enabled = args.Enabled;
                cmd.Checked = args.Checked;
                cmd.Visible = args.Visible;
                cmd.Execute();
            }
        }
        private void TextBox_Event(object sender, System.EventArgs e)
        {
            Command cmd = GetCommandForInstance((ToolStripTextBox)sender);
            CancelCommandEventArgs args = new CancelCommandEventArgs();

            args.Checked = cmd.Checked;
            args.Enabled = cmd.Enabled;
            args.Visible = cmd.Visible;
            if (this.CommandExecute != null)
            {
                this.CommandExecute(sender, args);
            }
            if (args.Cancel == false)
            {
                cmd.Enabled = args.Enabled;
                cmd.Checked = args.Checked;
                cmd.Visible = args.Visible;
                cmd.Execute();
            }
        }
예제 #15
0
        private void Check_CheckedChanged(System.Object sender, System.EventArgs e)
        {
            Command cmd = GetCommandForInstance((System.Windows.Forms.CheckBox)sender);
            CancelCommandEventArgs args = new CancelCommandEventArgs();

            args.Checked = cmd.Checked;
            args.Enabled = cmd.Enabled;
            args.Visible = cmd.Visible;
            if (this.CommandExecute != null)
            {
                this.CommandExecute(sender, args);
            }
            if (args.Cancel == false)
            {
                cmd.Enabled = args.Enabled;
                cmd.Checked = args.Checked;
                cmd.Visible = args.Visible;
                cmd.Execute();
            }
        }
예제 #16
0
        void SaveCommand_Executing(object sender, CancelCommandEventArgs args)
        {
            var sglSerializer = new SharpGL.Serialization.SharpGL.SharpGLXmlFormat();

            //  Create an open file dialog.
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = sglSerializer.Filter;

            //  Show the dialog.
            if (saveFileDialog.ShowDialog() != true)
            {
                //  Cancel any loading.
                args.Cancel = true;
                return;
            }


            //  Set the args.
            args.Parameter = saveFileDialog.FileName;
        }
예제 #17
0
        /// <summary>
        /// Handles the Executing event of the LoadDataCommand control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="Apex.MVVM.CancelCommandEventArgs"/> instance containing the event data.</param>
        void LoadDataCommand_Executing(object sender, CancelCommandEventArgs args)
        {
            //  Create an open file dialog.
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = SerializationEngine.Instance.Filter;

            //  Show the dialog.
            if (openFileDialog.ShowDialog() != true)
            {
                //  Cancel any loading.
                args.Cancel = true;
                return;
            }

            //  Load the scene.
            Scene scene = SerializationEngine.Instance.LoadScene(openFileDialog.FileName);

            //  Set the args.
            args.Parameter = scene;
        }
 private void input_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Enter)
     {
         Command cmd = GetCommandForInstance((ToolStripTextBox)sender);
         CancelCommandEventArgs args = new CancelCommandEventArgs();
         args.Checked = cmd.Checked;
         args.Enabled = cmd.Enabled;
         args.Visible = cmd.Visible;
         if (this.CommandExecute != null)
         {
             this.CommandExecute(sender, args);
         }
         if (args.Cancel == false)
         {
             cmd.Enabled = args.Enabled;
             cmd.Checked = args.Checked;
             cmd.Visible = args.Visible;
             cmd.Execute();
         }
     }
 }
예제 #19
0
        private void OnExportContentCommandExecuting(object sender, CancelCommandEventArgs args)
        {
            Shared.IWaitableObject parent = null;
            Control control = this;

            while (control != null && control.DataContext != null && !(control.DataContext is Shared.IWaitableObject))
            {
                parent  = control.DataContext as Shared.IWaitableObject;
                control = control.Parent as Control;
            }
            if (control != null)
            {
                parent = control.DataContext as Shared.IWaitableObject;
            }
            else
            {
                return;
            }
            if (parent != null)
            {
                parent.State = Shared.State.Busy;
            }
        }
예제 #20
0
 protected virtual void OnCommandPreExecute(object sender, CancelCommandEventArgs e)
 {
     if (PreExecute != null)
         PreExecute(sender, e);
 }
예제 #21
0
 /// <summary>
 /// Handles the Executing event of the FileExitCommand control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="args">The <see cref="Apex.MVVM.CancelCommandEventArgs"/> instance containing the event data.</param>
 void FileExitCommand_Executing(object sender, CancelCommandEventArgs args)
 {
     //  Close the application.
     Close();
 }
예제 #22
0
 void DeleteContactCommand_Executing(object sender, CancelCommandEventArgs args)
 {
     args.Cancel = MessageBox.Show("Are you sure?", "Sure?", MessageBoxButton.YesNoCancel) != MessageBoxResult.Yes;
 }
 void OnFuncCommandExecuting(object sender, CancelCommandEventArgs args)
 {
     args.Parameter = this;
     Status         = "Ожидание данных ...";
     State          = State.Busy;
 }
예제 #24
0
 protected void InvokeExecuting(CancelCommandEventArgs args)
 {
     Executing?.Invoke(this, args);
 }