Esempio n. 1
0
        public void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CommandActions CommandAction = new CommandActions(ApplicationService);

            CommandAction.RegisterCommands();
            (IShell as Window).Closing += VideoPlayerVM_Closing;
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Commands: ");
                Console.WriteLine("add [ClientName] [MethodName] [SessionCount]");
                Console.WriteLine("list");
                Console.WriteLine("start [ClientName]");
                Console.WriteLine("stop [ClientName]");
                Console.WriteLine("list active");
                Console.WriteLine("history");
                Console.WriteLine("Enter a command: ");
                var command = Console.ReadLine();

                string[] commandParams = command.Split(" ");


                switch (commandParams[0])
                {
                case "add":
                    CommandActions.AddNewClient(commandParams[1], commandParams[2], commandParams[3]);
                    break;

                case "list":
                    if (commandParams.Length > 1)
                    {
                        CommandActions.GetActiveClientsInfo();
                    }
                    else
                    {
                        CommandActions.GetClientsInfo();
                    }
                    break;

                case "start":
                    CommandActions.StartSession(commandParams[1]);
                    break;

                case "stop":
                    CommandActions.StopSession(commandParams[1]);
                    break;

                case "history":
                    CommandActions.ShowHistory();
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        private void Button_Command(object sender, CommandEventArgs e)
        {
            int            rowIndex      = -1;
            CommandActions commandAction = (CommandActions)Enum.Parse(typeof(CommandActions), e.CommandName);

            string[] args = e.CommandArgument.ToString().Split(',');
            if (args.Length > 0)
            {
                if (!Int32.TryParse(args[0], out rowIndex))
                {
                    rowIndex = -1;
                }
                if (args.Length > 1)
                {
                    for (int i = 1; i < args.Length; i++)
                    {
                        commandAction = (commandAction | (CommandActions)Enum.Parse(typeof(CommandActions), args[i]));
                    }
                }
            }

            if (this.m_Grid != null)
            {
                switch (commandAction)
                {
                case CommandActions.Edit:
                    //this.m_grid.EditIndex = rowIndex;
                    break;

                case CommandActions.Select:
                    this.m_Grid.SelectedIndex = rowIndex;
                    break;

                case CommandActions.Delete:
                    this.m_Grid.DeleteRow(rowIndex);
                    break;

                case CommandActions.Cancel:
                case CommandActions.Update:
                    this.m_Grid.EditIndex = -1;
                    break;
                }
                this.m_Grid.ActionInternal(this.m_Grid, new CommonGridViewActionEventArgs(commandAction, rowIndex));
                this.m_Grid.DataBind();
            }
            else if (m_MagicForm != null)
            {
                this.m_MagicForm.ActionInternal(this.m_MagicForm, new MagicFormActionEventArgs(commandAction));
            }
        }
        /// <summary>
        /// Runs the test, then runs the undo operation and verifies that the
        /// buffer is identical to the original one.
        /// </summary>
        /// <param name="test">The test.</param>
        private void Undo(Action test)
        {
            // Setup
            TextPosition startingPosition = editor.Caret.Position;

            test();

            // Operation
            CommandActions.Undo(controller);

            // Verification
            Assert.AreEqual(3, buffer.LineCount);
            Assert.AreEqual("Line 1", buffer.GetLineText(0));
            Assert.AreEqual("Line 2", buffer.GetLineText(1));
            Assert.AreEqual("Line 3", buffer.GetLineText(2));
            Assert.AreEqual(startingPosition, editor.Caret.Position);
        }
Esempio n. 5
0
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            this.AcceptChanges();

            IButtonControl btn           = sender as IButtonControl;
            CommandActions commandAction = 0;

            string[] args = btn.CommandName.Split(',');
            for (int i = 0; i < args.Length; i++)
            {
                commandAction = (commandAction | (CommandActions)Enum.Parse(typeof(CommandActions), args[i]));
            }

            if (this.Action != null)
            {
                this.Action(this, new MagicFormActionEventArgs(commandAction));
            }
        }
        private string GetActionString(CommandActions commandAction, bool skipObjectName)
        {
            StringBuilder sb         = new StringBuilder();
            string        actionName = null;

            string         key       = string.Empty;
            CommandActions keyAction = 0;

            if (m_MagicForm != null)
            {
                if (m_MagicForm.CurrentMode == DetailsViewMode.Insert)
                {
                    if ((commandAction & CommandActions.Insert) == CommandActions.Insert)
                    {
                        key       = m_MagicForm.InsertButtonCaption.ToString();
                        keyAction = CommandActions.Insert;
                    }
                }
                else if (m_MagicForm.CurrentMode == DetailsViewMode.Edit)
                {
                    if ((commandAction & CommandActions.Update) == CommandActions.Update)
                    {
                        key       = m_MagicForm.UpdateButtonCaption.ToString();
                        keyAction = CommandActions.Update;
                    }
                }
            }
            else if (m_Grid != null)
            {
                if ((commandAction & CommandActions.Delete) == CommandActions.Delete)
                {
                    key       = m_Grid.DeleteButtonCaption.ToString();
                    keyAction = CommandActions.Delete;
                }
            }

            foreach (CommandActions cmdAction in Enum.GetValues(typeof(CommandActions)))
            {
                if ((commandAction | cmdAction) == commandAction)
                {
                    bool useKey = false;
                    actionName = cmdAction.ToString();
                    if (keyAction > 0)
                    {
                        useKey = (((cmdAction & keyAction) == keyAction));
                        if (useKey)
                        {
                            actionName = key;
                        }
                    }

                    if (!DesignMode)
                    {
                        actionName = Resources.ResourceManager.GetString(string.Concat("AutoGeneratedButtonsField_", actionName, "Button_Text"));
                    }

                    if (sb.Length == 0)
                    {
                        sb.Append(actionName);
                        if (m_MagicForm != null)
                        {
                            if ((!skipObjectName) && useKey && (!string.IsNullOrEmpty(m_MagicForm.ObjectName)))
                            {
                                sb.AppendFormat(" {0}", m_MagicForm.ObjectName);
                            }
                        }
                    }
                    else
                    {
                        sb.AppendFormat(" & {0}", actionName);
                    }
                }
            }
            return(sb.ToString());
        }
Esempio n. 7
0
 private void Info_Click(object sender, EventArgs e)
 {
   if (_MousePressed)
     return;
   _CommandAction = CommandActions.INFORMATION;
 }
 private void InsertButton(Control container, CommandActions commandAction, int rowIndex, ButtonType buttonType, Color buttonColor)
 {
     InsertButton(container, commandAction, rowIndex, buttonType, buttonColor, false);
 }
 private void InsertButton(Control container, CommandActions commandAction, int rowIndex, ButtonType buttonType, Color buttonColor, bool skipObjectName)
 {
     InsertButton(container, commandAction, rowIndex, buttonType, buttonColor, skipObjectName, null);
 }
 private void InsertButton(Control container, CommandActions commandAction, int rowIndex, string cssClass)
 {
     this.InsertButton(container, commandAction, rowIndex, ButtonType.Link, Color.Empty, false, cssClass);
 }
 private void InsertButton(Control container, CommandActions commandAction, int rowIndex, Color buttonColor)
 {
     this.InsertButton(container, commandAction, rowIndex, ButtonType.Link, buttonColor);
 }
Esempio n. 12
0
    private void MapForm_MouseDown(object sender, MouseEventArgs e)
    {
      _MousePressed = true;
      if (e.Button == MouseButtons.Middle)
      {
        _CommandAction = CommandActions.PAN;
        Cursor.Current = Cursors.NoMove2D;
      }

      ptOriginal.X = e.X;
      ptOriginal.Y = e.Y;
      ptLast.X = -1;
      ptLast.Y = -1;
    }
Esempio n. 13
0
    private void Pan_Click(object sender, EventArgs e)
    {
      if (_MousePressed)
        return;

      _CommandAction = CommandActions.PAN;

    }
Esempio n. 14
0
 private void ZoomWindow_Click(object sender, EventArgs e)
 {
   if (_MousePressed)
     return;
   _CommandAction = CommandActions.ZOOM_WINDOW;
 }
Esempio n. 15
0
 public MagicFormActionEventArgs(CommandActions action)
 {
     m_Action = action;
 }
        private void InsertButton(Control container, CommandActions commandAction, int rowIndex, ButtonType buttonType, Color buttonColor, bool skipObjectName, string cssClass)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }
            if (buttonType == ButtonType.Image)
            {
                throw new NotSupportedException(Resources.ExceptionMessage_ImageButtonTypeIsNotSupported);
            }

            IButtonControl buttonControl = null;
            LinkButton     link          = null;
            Button         button        = null;

            string OnClientClick = string.Empty;

            if ((commandAction | CommandActions.Delete) == commandAction)
            {
                string caption = null;
                if (m_Grid != null)
                {
                    if (m_Grid.EnableDeleteConfirmation)
                    {
                        caption = m_Grid.DeleteButtonCaption.ToString();
                    }
                }
                else if (m_MagicForm != null)
                {
                    if (m_MagicForm.EnableDeleteConfirmation)
                    {
                        caption = m_MagicForm.DeleteButtonCaption.ToString();
                    }
                }
                if (caption != null)
                {
                    OnClientClick = string.Concat("return confirm('", Resources.ResourceManager.GetString(string.Concat("AutoGeneratedButtonsField_", caption, "Button_ConfirmText")), "');");
                }
            }

            if (buttonType == ButtonType.Link)
            {
                link = new LinkButton();
                link.OnClientClick = OnClientClick;
                buttonControl      = link;
            }
            else if (buttonType == ButtonType.Button)
            {
                button = new Button();
                button.OnClientClick = OnClientClick;
                buttonControl        = button;
            }

            string cmdString = commandAction.ToString().Replace(" ", string.Empty);

            WebControl ctl = (buttonControl as WebControl);

            ctl.ID = string.Concat("btn", cmdString.Replace(",", string.Empty));
            if (!buttonColor.IsEmpty)
            {
                ctl.ForeColor = buttonColor;
            }
            if (!string.IsNullOrEmpty(cssClass))
            {
                ctl.CssClass = cssClass;
            }

            buttonControl.Text             = GetActionString(commandAction, skipObjectName);
            buttonControl.CommandName      = cmdString.Split(',')[0];
            buttonControl.CommandArgument  = string.Concat(rowIndex, ",", cmdString);
            buttonControl.Command         += new CommandEventHandler(Button_Command);
            buttonControl.CausesValidation = false;

            if (m_MagicForm != null)
            {
                if (((commandAction | CommandActions.Update) == commandAction) || (commandAction | CommandActions.Insert) == commandAction)
                {
                    buttonControl.ValidationGroup  = m_MagicForm.ValidationGroupInternal;
                    buttonControl.CausesValidation = true;
                }
            }

            container.Controls.Add(ctl);
        }
Esempio n. 17
0
 public CommonGridViewActionEventArgs(CommandActions action, int rowIndex)
 {
     m_Action   = action;
     m_RowIndex = rowIndex;
 }
        private void InitializeMagicFormCell(DataControlFieldCell cell, int rowIndex)
        {
            bool modernTheme = (m_MagicForm.Theme == MasterPageTheme.Modern);

            cell.CssClass = "Mf_B";

            Control container = cell;

            if (this.m_MagicForm.ShowRequiredTable)
            {
                container = MagicForm.AddRequiredTable(cell);
            }

            CommandActions action          = 0;
            bool           showCloseButton = false;

            if (m_MagicForm.CurrentMode == DetailsViewMode.Edit && m_ShowEditButton)
            {
                action          = CommandActions.Update;
                showCloseButton = ((m_MagicForm.ShowCloseButton == CloseButtonVisibilityMode.Always) ||
                                   (m_MagicForm.ShowCloseButton == CloseButtonVisibilityMode.Edit));
            }
            else if (m_MagicForm.CurrentMode == DetailsViewMode.Insert && m_ShowInsertButton)
            {
                action          = CommandActions.Insert;
                showCloseButton = ((m_MagicForm.ShowCloseButton == CloseButtonVisibilityMode.Always) ||
                                   (m_MagicForm.ShowCloseButton == CloseButtonVisibilityMode.Insert));
            }

            if (action > 0)
            {
                ButtonType type  = ButtonType.Button;
                Color      color = Color.Black;
                if (showCloseButton)
                {
                    if (m_MagicForm.ShowCloseButtonSeparate)
                    {
                        InsertButton(container, action, rowIndex, type, (modernTheme ? Color.Empty : color));
                        InsertButtonSeparator(container);
                        type  = ButtonType.Link;
                        color = Color.Blue;
                    }
                    InsertButton(container, (action | CommandActions.Close), rowIndex, type, (modernTheme ? Color.Empty : color), m_MagicForm.ShowCloseButtonSeparate, null);
                }
                else
                {
                    InsertButton(container, action, rowIndex, type, (modernTheme ? Color.Empty : color));
                }
            }

            if (m_MagicForm.ShowCancelButton)
            {
                InsertButtonSeparator(container);
                InsertButton(container, CommandActions.Cancel, rowIndex, "Cancel");
            }

            if (m_ShowDeleteButton && m_MagicForm.CurrentMode != DetailsViewMode.Insert)
            {
                InsertButtonSeparator(container);
                InsertButton(container, CommandActions.Delete, rowIndex, "Delete");
            }
        }
Esempio n. 19
0
 public CommandAttribute(string name, CommandActions actions)
 {
     Name    = name;
     Actions = actions;
 }
 public Action(string actionStr, CommandActions action)
 {
     actionString = actionStr;
     commandAction = action;
 }