コード例 #1
0
        public T GetCommandFromCommandButtons <T>(object sender) where T : CommandBase
        {
            CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender;

            if (commandButtonsControl.DataContext != null && commandButtonsControl.DataContext is CommandBase)
            {
                return((T)commandButtonsControl.DataContext);
            }
            return(null);
        }
コード例 #2
0
        private async void PlayButton_Click(object sender, RoutedEventArgs e)
        {
            this.PlayButton.Visibility = Visibility.Collapsed;
            this.StopButton.Visibility = Visibility.Visible;

            this.newCommand = await this.GetNewCommand();

            if (this.newCommand != null)
            {
                await CommandButtonsControl.TestCommand(this.newCommand);
            }
            this.SwitchToPlay();
        }
コード例 #3
0
        private async void PlayButton_Click(object sender, RoutedEventArgs e)
        {
            this.PlayButton.Visibility = Visibility.Collapsed;
            this.StopButton.Visibility = Visibility.Visible;

            this.EditButton.IsEnabled   = false;
            this.DeleteButton.IsEnabled = false;
            this.EnableDisableToggleSwitch.IsEnabled = false;

            CommandBase command = this.GetCommandFromCommandButtons <CommandBase>(this);
            await CommandButtonsControl.TestCommand(command);

            this.SwitchToPlay();

            this.RaiseEvent(new RoutedEventArgs(CommandButtonsControl.PlayClickedEvent, this));
        }
コード例 #4
0
        public T GetCommandFromCommandButtons <T>(object sender) where T : CommandBase
        {
            CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender;

            if (commandButtonsControl.DataContext != null)
            {
                if (commandButtonsControl.DataContext is CommandBase)
                {
                    return((T)commandButtonsControl.DataContext);
                }
                else if (commandButtonsControl.DataContext is EventCommandItem)
                {
                    EventCommandItem commandItem = (EventCommandItem)commandButtonsControl.DataContext;
                    return((T)((CommandBase)commandItem.Command));
                }
            }
            return(null);
        }