public AutomationCommand(MenuOptionViewModel parent, IAutomationExtension automation)
            {
                this.parent = parent;
                this.automation = automation;
                this.menu = (IMenuCommand)automation;
                this.status = automation as ICommandStatus ?? new NullQueryStatus();

                parent.IsVisible = this.menu.Visible;
                parent.IsEnabled = this.menu.Enabled;

                var propertyChanged = automation as INotifyPropertyChanged;

                if (propertyChanged != null)
                {
                    propertyChanged.PropertyChanged += this.OnMenuPropertyChanged;
                }
            }
            public AutomationCommand(MenuOptionViewModel parent, IAutomationExtension automation)
            {
                this.parent     = parent;
                this.automation = automation;
                menu            = automation as IMenuCommand;
                status          = automation as ICommandStatus ?? new NullQueryStatus();

                parent.IsVisible = menu == null || menu.Visible;
                parent.IsEnabled = menu == null || menu.Enabled;

                var propertyChanged = automation as INotifyPropertyChanged;

                if (propertyChanged != null)
                {
                    propertyChanged.PropertyChanged += OnMenuPropertyChanged;
                }
            }
Example #3
0
        private void UpdateActionCompleted(ICommandStatus result)
        {
            string commandType = "", message = "";

            this.pbCollection.IsIndeterminate = false;

            switch (result.CommandType)
            {
            case CommandType.IISCollectionStart:
                commandType = "IIS Collection Start";
                break;

            case CommandType.IISCollectionStop:
                commandType = "IIS Collection Stop";
                break;

            case CommandType.ServiceCollectionStart:
                commandType = "Service Start";
                break;

            case CommandType.ServiceCollectionStop:
                commandType = "Service Stop";
                break;

            case CommandType.ProcessCollectionStart:
                commandType = "Process Collection Start";
                break;

            case CommandType.ProcessCollectionStop:
                commandType = "Process Collection Stop";
                break;
            }

            if (result is WindowsServiceCollectionCommandStatus)
            {
                WindowsServiceCollectionCommandStatus wsStatus = (WindowsServiceCollectionCommandStatus)result;
                AddToLog(wsStatus.InfoMessages);
            }
            else if (result is ProcessCollectionCommandStatus)
            {
                ProcessCollectionCommandStatus pStatus = (ProcessCollectionCommandStatus)result;

                if (result.Success)
                {
                    message         = string.Format("Process {0} {1} successfully for Intellitrace Collection.", pStatus.ProcessName, (pStatus.CommandType == CommandType.ProcessCollectionStart ? "started" : "stopped"));
                    this.processIds = pStatus.ProcessIDs;
                    foreach (int id in processIds)
                    {
                        AddToLog(string.Format("process id = {0}", id));
                    }
                }
                else
                {
                    message = string.Format("Process {0} Failed to {1} for Intellitrace Collection - {2}.", pStatus.ProcessName, (pStatus.CommandType == CommandType.ProcessCollectionStart ? "start" : "stop"), result.ErrorMesage);
                }
                AddToLog(message);
            }
            else if (result is CommandStatus)
            {
                if (result.Success)
                {
                    message = string.Format("{0} Successful.", commandType);
                }
                else
                {
                    message = string.Format("{0} Failed - {1}.", commandType, result.ErrorMesage);
                }
                AddToLog(message);
            }
            this.Cursor = Cursors.Arrow;
        }