Exemplo n.º 1
0
    private void ChangeColor(Color color)
    {
        Command command = new ChangeColorCommand(changeColorReceiver, color, objectTarget);

        command.Execute();
        InsertCommand(command);
    }
        /*  private readonly TraficLightsWorker _trafficWorker;
         *
         * public ChangeColorCommandHandler(TraficLightsWorker traffic)
         * {
         *    _trafficWorker = traffic;
         * }*/

        public Task Handle(ChangeColorCommand notification, int id, CancellationToken cancellationToken)
        {
            //   _trafficWorker.CurrentTrafficLight.ColorSwitchTimer.Change(Timeout.Infinite, Timeout.Infinite);

            /*
             *
             *          if (_trafficWorker.CurrentTrafficLight.Color == Colors.Red)
             *          {
             *              _trafficWorker.CurrentTrafficLight.Color = Colors.Yellow;
             *              _trafficWorker.CurrentTrafficLight.IsSwitchingDown = true;
             *          }
             *          else if (_trafficWorker.CurrentTrafficLight.Color == Colors.Yellow && _trafficWorker.CurrentTrafficLight.IsSwitchingDown)
             *          {
             *              _trafficWorker.CurrentTrafficLight.Color = Colors.Green;
             *              _trafficWorker.CurrentTrafficLight.IsSwitchingDown = false;
             *          }
             *
             *          else if (_trafficWorker.CurrentTrafficLight.Color == Colors.Yellow && !_trafficWorker.CurrentTrafficLight.IsSwitchingDown)
             *          {
             *              this._trafficWorker.CurrentTrafficLight.Color = Colors.Red;
             *          }
             *          else if (_trafficWorker.CurrentTrafficLight.Color == Colors.Green)
             *          {
             *              this._trafficWorker.CurrentTrafficLight.Color = Colors.Yellow;
             *          }
             *
             *          _trafficWorker.InvokeChanges();
             *       //   _trafficWorker.CurrentTrafficLight.ColorSwitchTimer.Change(500, Timeout.Infinite);
             *
             *          return Task.CompletedTask;
             *      }*/

            return(Task.CompletedTask);
        }
Exemplo n.º 3
0
        private void cbColor_SelectedIndexChanged(object sender, EventArgs e)
        {
            // create and execute new command
            ICommand command = new ChangeColorCommand(rects, Color.FromName(cbColor.Text));

            manager.Execute(command);
        }
Exemplo n.º 4
0
        private void ChangeColor(EnumColor _textColor)
        {
            ChangeColorCommand ccc;

            ccc = new ChangeColorCommand(Editor, _textColor);
            Commands.Push(ccc);
            ccc.Execute();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Opens color dialog to select new arcs color
        /// </summary>
        private void ArcsColorDialogOpen_Click(object sender, EventArgs e)
        {
            if (GraphStyleColorDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            var command = new ChangeColorCommand(graphDrawing, typeof(Arc),
                                                 graphDrawing.ArcsColor, GraphStyleColorDialog.Color);

            command.Executed += (s, ea) =>
            {
                ArcsColorPanel.BackColor = graphDrawing.ArcsColor;
                graphDrawing.DrawTheWholeGraph(digraph);
                DrawingSurface.Image = graphDrawing.Image;
            };

            commandsManager.Execute(command);
        }
 public ClassifierSingleCommandContext(
     Classifier classifier,
     ClassifierDictionary classifierDictionary,
     DeletionService deletionService,
     IRelationService relationService,
     IAskUserBeforeDeletionService askUserService,
     MessageSystem messageSystem)
 {
     Rename = new RenameClassifierCommand(
         classifier,
         classifierDictionary,
         new ClassifierValidationService(classifierDictionary),
         messageSystem);
     ChangeBaseClass = new ChangeBaseClassCommand(
         classifier,
         classifierDictionary,
         messageSystem);
     Delete = new DeleteClassifierCommand(classifier, deletionService,askUserService);
     Visibility = new ShowOrHideSingleObjectCommand(classifier, messageSystem);
     ChangeClassifierColor = new ChangeColorCommand(classifier, messageSystem);
     ChangeNoteColor = new ChangeNoteColorCommand(classifier.Note,messageSystem);
     ChangeNoteText = new ChangeNoteTextCommand(classifier.Note,messageSystem);
     ChangeIsInterface = new MakeClassifierToInterfaceCommand(classifier, relationService);
 }
 public PostitViewModel()
 {
     TextCommand = new ChangeTextCommand(this);
     ColorCommand = new ChangeColorCommand(this);
 }
Exemplo n.º 8
0
        /// <summary>
        /// This method checks if the command line has a valid insert command at the valid position.
        /// </summary>
        /// <param name="commandLine">The command line the user has written.</param>
        /// <exception cref="ArgumentNullException">
        /// If the commandLine is null.
        /// </exception>
        /// <returns>An instanced insert command if the command is valid or null if the command is not valid.</returns>
        public static IEditorCommand Parse(string commandLine)
        {
            if (commandLine == null)
            {
                throw new ArgumentNullException();
            }

            string[] possibleCommands = commandLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (possibleCommands.Length < 3)
            {
                return(null);
            }

            string value = possibleCommands[1];
            int    editorValue;

            try
            {
                editorValue = int.Parse(value);
            }
            catch
            {
                return(null);
            }

            string[] newpossibleCommands = new string[possibleCommands.Length - 1];
            newpossibleCommands[0] = possibleCommands[0];

            if (newpossibleCommands.Length == 2)
            {
                newpossibleCommands[1] = possibleCommands[2];
            }
            else if (newpossibleCommands.Length == 3)
            {
                newpossibleCommands[1] = possibleCommands[2];
                newpossibleCommands[2] = possibleCommands[3];
            }

            commandLine = string.Join(" ", newpossibleCommands);
            string         command       = newpossibleCommands[1].ToLower();
            ITurtleCommand turtleCommand = null;

            switch (command)
            {
            case "move":
                turtleCommand = MoveCommand.Parse(commandLine);
                break;

            case "rotate":
                turtleCommand = RotateCommand.Parse(commandLine);
                break;

            case "sleep":
                turtleCommand = SleepCommand.Parse(commandLine);
                break;

            case "penup":
                turtleCommand = PenUpCommand.Parse(commandLine);
                break;

            case "pendown":
                turtleCommand = PenDownCommand.Parse(commandLine);
                break;

            case "changecolor":
                turtleCommand = ChangeColorCommand.Parse(commandLine);
                break;

            case "changetracksymbol":
                turtleCommand = ChangeTrackSymbolCommand.Parse(commandLine);
                break;

            case "changeturtlesymbol":
                turtleCommand = ChangeTurtleSymbolCommand.Parse(commandLine);
                break;
            }

            if (turtleCommand != null && editorValue > 0)
            {
                turtleValue = turtleCommand.GetValue();
                return(new InsertCommand(editorValue, turtleCommand));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// This method checks if the command line has a valid add command at the valid position.
        /// </summary>
        /// <param name="commandLine">The command line the user has written.</param>
        /// <exception cref="ArgumentNullException">
        /// If the commandLine is null.
        /// </exception>
        /// <returns>An instanced add command if the command is valid or null if the command is not valid.</returns>
        public static IEditorCommand Parse(string commandLine)
        {
            if (commandLine == null)
            {
                throw new ArgumentNullException();
            }

            string[] possibleCommands = commandLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (possibleCommands.Length <= 1 || possibleCommands.Length >= 4)
            {
                return(null);
            }

            string         command       = possibleCommands[1].ToLower();
            ITurtleCommand turtleCommand = null;

            switch (command)
            {
            case "move":
                turtleCommand = MoveCommand.Parse(commandLine);
                break;

            case "rotate":
                turtleCommand = RotateCommand.Parse(commandLine);
                break;

            case "sleep":
                turtleCommand = SleepCommand.Parse(commandLine);
                break;

            case "penup":
                turtleCommand = PenUpCommand.Parse(commandLine);
                break;

            case "pendown":
                turtleCommand = PenDownCommand.Parse(commandLine);
                break;

            case "changecolor":
                turtleCommand = ChangeColorCommand.Parse(commandLine);
                break;

            case "changetracksymbol":
                turtleCommand = ChangeTrackSymbolCommand.Parse(commandLine);
                break;

            case "changeturtlesymbol":
                turtleCommand = ChangeTurtleSymbolCommand.Parse(commandLine);
                break;
            }

            if (turtleCommand != null)
            {
                return(new AddCommand(turtleCommand));
            }
            else
            {
                return(null);
            }
        }