Esempio n. 1
0
 public AdbTools(TextBlock context)
 {
     this.Context = context;
     _cmd = new Command();
     _cmds = new List<Command>();
     _executor = new CommandExecutor();
 }
Esempio n. 2
0
		public MainWindow()
		{
			_accessRuleDataService = new AccessRuleDataService();
			_userDataService = new UserDataService();

			var culture = CultureInfo.GetCultureInfo("fa-IR");

			Dispatcher.Thread.CurrentCulture = culture;
			Dispatcher.Thread.CurrentUICulture = culture;

			LocalizationManager.UpdateValues();

			InitializeComponent();
			AccessList = new List<Tuple<string, AccessType>>();
			LoginCommand = new Command(Login);
			_newTabNumber = 1;

			// temp
			//Login(null);
			//SetValue(LoginProperty, true);
			//.

			Closing += (s, e) => Soheil.Core.PP.PPItemManager.Abort();

			if (Environment.UserName == "Bizhan" || Environment.UserName == "Bizz")
			{
				//SingularList = new Core.ViewModels.PP.PPTableVm(AccessType.Full);
				//chrometabs.AddTab(CreateSingularTab(SoheilEntityType.ProductPlanTable), true);
			}
		}
Esempio n. 3
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MainWindowViewModel"/> class.
		/// </summary>
		public MainWindowViewModel(IMacroService macroService, IUIVisualizerService uiVisualizerService, IMessageService messageService)
		{
			Argument.IsNotNull(() => macroService);
			Argument.IsNotNull(() => uiVisualizerService);
			Argument.IsNotNull(() => messageService);

			//_familyService = familyService;
			this.macroService = macroService;
			this.uiVisualizerService = uiVisualizerService;
			this.messageService = messageService;
			
			InputTest = new Command(OnInputTestExecute);
			MacroSave = new Command(OnSaveMacroExecute);
			MacroAdd = new Command(OnMacroAddExecute);
			MacroRecord = new Command(OnMacroRecordExecute);
			MacroEdit = new Command(OnMacroEditExecute, OnEditMacroCanExecute);
			MacroAdd = new Command(OnMacroAddExecute);
			MacroCopy = new Command(OnMacroCopyExecute);
			MacroDelete = new Command(OnMacroDeleteExecute);
			MacroRun = new Command(OnMacroRunExecute);
			MacroLoad = new Command(OnMacroLoadExecute);
			OpenSettings = new Command(OnOpenSettingsExecute);
			// TODO: Move code above to constructor
			
			Util.Initialize();
			//AddFamily = new Command(OnAddFamilyExecute);
			//EditFamily = new Command(OnEditFamilyExecute, OnEditFamilyCanExecute);
			//RemoveFamily = new Command(OnRemoveFamilyExecute, OnRemoveFamilyCanExecute);
			
		}
        private Task ExecuteGetIdentiferToken(Command cmd, TextBox ctx, bool createNoWindow = true)
        {
            return Task.Run(async () =>
            {
                Process process = new Process
                {
                    StartInfo =
                    {
                        FileName = "cmd.exe",
                        UseShellExecute = false,
                        CreateNoWindow = createNoWindow,
                        RedirectStandardOutput = true,
                        RedirectStandardInput = true
                    }
                };
                process.OutputDataReceived += async (sender, args) =>
                {
                    try
                    {
                        await ctx.Dispatcher.InvokeAsync(() => ctx.Text = ctx.Text + "\n" + StringLinesRemover.RemoveCmdData(args.Data), DispatcherPriority.Background);
                    }
                    catch
                    {

                    }
                };
                process.Start();
                process.BeginOutputReadLine();
                await ctx.Dispatcher.InvokeAsync(() => ctx.Text = string.Empty);
                process.StandardInput.WriteLine(cmd.Text);
                process.WaitForExit();
            });
        }
Esempio n. 5
0
 public DirectoryItem(String directoryName, String fullPath, Command<DirectoryItem> isSelectedCommand)
 {
     DirectoryName = directoryName;
     FullPath = fullPath;
     SubDirectories = new ObservableCollection<DirectoryItem>();            
     IsSelectedCommand = isSelectedCommand;            
 }
 public Task Execute(Command cmd, TextBlock context, bool createNoWindow = true)
 {
     return Task.Run(async () =>
     {
         _processStartInfo = new ProcessStartInfo
         {
             UseShellExecute = false,
             RedirectStandardInput = true,
             RedirectStandardOutput = true,
             RedirectStandardError = true,
             FileName = "cmd.exe",
             CreateNoWindow = createNoWindow
         };
         _process = new Process { StartInfo = _processStartInfo };
         _process.OutputDataReceived += (sender, args) => _adapter.Adapt(context, args.Data);
         _process.ErrorDataReceived += (sender, args) => _adapter.Adapt(context, args.Data);
         _process.Start();
         _process.BeginErrorReadLine();
         _process.BeginOutputReadLine();
         await _process.StandardInput.WriteLineAsync(cmd.Text);
         await _process.StandardInput.FlushAsync();
         _process.StandardInput.Dispose();
         _process.Close();
         _process.Kill();
     });
 }
 public FastbootTools(TextBlock context)
 {
     Context = context;
     _executor = new CommandExecutor();
     _cmd = new Command();
     _cmds = new List<Command>();
 }
Esempio n. 8
0
        public DrawingControl()
        {
            this.Background = new SolidColorBrush(Colors.White);
            this.SizeChanged += DrawingControl_SizeChanged;

            CommandUndo = new Command(Undo, null, "Undo", "Drawing");
            CommandRedo = new Command(Redo, null, "Redo", "Drawing");
        }
        protected override void Arrange()
        {
            subject = new DoubleClickControl();
            command = new Command();

            DoubleClickCommand.SetCommand(subject, command);
            DoubleClickCommand.SetCommandParameter(subject, 1);
        }
Esempio n. 10
0
        public void InitializeToolbar()
        {
            ShowToolbarButtonText = IsolatedStorage.GetSetting("ShowToolbarText", true);

            CommandNew = new Command(New, GetImageFromResource("New.png"), "New", "Drawing");
            CommandOpen = new Command(Open, GetImageFromResource("Open.png"), "Open", "Drawing");
            CommandSave = new Command(Save, GetImageFromResource("Save.png"), "Save", "Drawing");
            CommandPrint = new Command(Print, GetImageFromResource("Print.png"), "Print", "Drawing");
            CommandSamples = new Command(Samples, GetImageFromResource("Samples.png"), "Samples", "Drawing");
            CommandSettings = new Command(OpenSettings, GetImageFromResource("Repair.png"), "Settings", "Drawing");
            CommandHomepage = new Command(Homepage, GetImageFromResource("Homepage.png"), "Homepage", "Drawing");
            CommandParse = new Command(ParseToAst, GetImageFromResource("Parse.png"), "Parse", "Parsing");
            CommandParseOptions = new Command(DisplayParseOptions, GetImageFromResource("ParseOptions.png"), "Def and Theorem Options", "Parsing");
            CommandProblemCharacteristics = new Command(DisplayProblemCharacteristics, GetImageFromResource("ParseOptions.png"), "Desired Problem Characteristics", "Parsing");
            CommandEnterSolution = new Command(DisplayEnterSolution, GetImageFromResource("Parse.png"), "Enter Solution", "Parsing");
            CommandManageGivens = new Command(DisplayManageGivens, GetImageFromResource("ParseOptions.png"), "Manage Givens", "Parsing");
            CommandStartRegionShading = new Command(StartRegionShading, GetImageFromResource("Play.png"), "Start Shading", "Regions");
            CommandMakeBookProblem = new Command(DrawBookProblem, GetImageFromResource("Draw.png"), "Book Problem", "Parsing");
            CommandSynthProblem = new Command(SynthesizeProblem, GetImageFromResource("Draw.png"), "Synthesize Problem", "Parsing");
            CommandClearRegionShading = new Command(ClearRegionShading, GetImageFromResource("Trash.png"), "Clear Shading", "Regions");
            CommandClearRegionShading.Icon.Opacity = 0.2;

            drawingHost.DrawingControl.CommandUndo.Icon = GetImageFromResource("Undo.png");
            drawingHost.DrawingControl.CommandRedo.Icon = GetImageFromResource("Redo.png");

            drawingHost.AddToolbarButton(drawingHost.CommandToggleGrid);
            drawingHost.AddToolbarButton(CommandNew);
            drawingHost.AddToolbarButton(CommandOpen);
            drawingHost.AddToolbarButton(CommandSave);
            drawingHost.AddToolbarButton(CommandPrint);
            drawingHost.AddToolbarButton(drawingHost.DrawingControl.CommandUndo);
            drawingHost.AddToolbarButton(drawingHost.DrawingControl.CommandRedo);
            drawingHost.AddToolbarButton(CommandSamples);
            drawingHost.AddToolbarButton(CommandSettings);
            drawingHost.AddToolbarButton(drawingHost.CommandShowFigureExplorer);
            drawingHost.AddToolbarButton(CommandHomepage);
            drawingHost.AddToolbarButton(drawingHost.CommandToggleOrtho);
            drawingHost.AddToolbarButton(drawingHost.CommandToggleSnapToGrid);
            drawingHost.AddToolbarButton(drawingHost.CommandToggleSnapToPoint);
            drawingHost.AddToolbarButton(drawingHost.CommandToggleSnapToCenter);
            drawingHost.AddToolbarButton(drawingHost.CommandToggleLabelNewPoints);
            drawingHost.AddToolbarButton(drawingHost.CommandTogglePolar);

            drawingHost.AddToolbarButton(CommandParse);
            drawingHost.AddToolbarButton(drawingHost.CommandShowAIDebugWindow);
            drawingHost.AddToolbarButton(CommandParseOptions);
            //drawingHost.AddToolbarButton(CommandProblemCharacteristics);
            drawingHost.AddToolbarButton(CommandManageGivens);
            drawingHost.AddToolbarButton(CommandEnterSolution);
            drawingHost.AddToolbarButton(CommandMakeBookProblem);
            drawingHost.AddToolbarButton(CommandSynthProblem);
            drawingHost.AddToolbarButton(CommandStartRegionShading);
            drawingHost.AddToolbarButton(CommandClearRegionShading);

            drawingHost.Ribbon.GetPanel("Drawing").HeaderContent.Icon = GetImageFromResource("SaveFormDesign.png");
        }
        private void SaveSkypeAvatar(string userHandle, string Path)
        {
            if (!System.IO.Path.IsPathRooted(Path))
                throw new ArgumentException("Filename does not contain full path!", "rootedPathFileName");

            var extension = System.IO.Path.GetExtension(Path);
            if (extension != null && !extension.Equals(".jpg"))
                throw new ArgumentException("Filename does not represent jpg file!", "rootedPathFileName");

            var cmd = new Command {Command = string.Format("GET USER {0} AVATAR 1 {1}", userHandle, Path)};
            handler._skype.SendCommand(cmd);
        }
Esempio n. 12
0
        public CommandToolButton(Command command)
        {
            Command = command;
            command.AddObserver(this);

            buttonGrid = new ButtonGrid(command.Icon, command.Name);
            if (command.Icon is CheckBox)
            {
                command.Icon.IsHitTestVisible = false;
            }
            Content = buttonGrid;
            buttonGrid.MouseLeftButtonDown += Content_MouseLeftButtonDown;
        }
        public ImageTranscodeViewModel()
        {
            OkCommand = new Command(async () =>
            {
                CancellableOperationProgressView progress = new CancellableOperationProgressView();
                ImageTranscodeProgressViewModel vm = new ImageTranscodeProgressViewModel(this);
                progress.DataContext = vm;              

                Task task = vm.startTranscodeAsync();
                progress.Show();
                OnClosingRequest();
                await task;

                MiscUtils.insertIntoHistoryCollection(Settings.Default.ImageTranscodeOutputDirectoryHistory, OutputPath);
            });


            DefaultsCommand = new Command(() =>
            {
                setDefaults();
            });

            CancelCommand = new Command(() =>
            {
                OnClosingRequest();
            });

            DirectoryPickerCommand = new Command(() =>
            {
                DirectoryPickerView directoryPicker = new DirectoryPickerView();
                DirectoryPickerViewModel vm = (DirectoryPickerViewModel)directoryPicker.DataContext;
                vm.InfoString = "Select Transcode Output Path";
                vm.SelectedPath = OutputPath;
                vm.PathHistory = OutputPathHistory;

                if (directoryPicker.ShowDialog() == true)
                {
                    OutputPath = vm.SelectedPath;
                }

            });

            OutputPathHistory = Settings.Default.ImageTranscodeOutputDirectoryHistory;            
            OutputFormatCollectionView = new ListCollectionView(outFormats);
            JpegRotationCollectionView = new ListCollectionView(Enum.GetNames(typeof(Rotation)));
            PngInterlacingCollectionView = new ListCollectionView(Enum.GetNames(typeof(PngInterlaceOption)));
            TiffCompressionCollectionView = new ListCollectionView(Enum.GetNames(typeof(TiffCompressOption)));

            setDefaults();
        }
Esempio n. 14
0
        private void update(Command cmd)
        {
            if (cmd.valid)
            {
                Valid.Content = "Valid";
                Valid.Foreground = new SolidColorBrush(Colors.Green);
            }
            else
            {
                Valid.Content = "Invalid";
                Valid.Foreground = new SolidColorBrush(Colors.Red);
            }

            UD.Content = cmd.UD;
            RL.Content = cmd.RL;
            FB.Content = cmd.FB;
            TRL.Content = cmd.TRL;
        }
 public Task<string> Execute(Command cmd, bool createNoWindow = true)
 {
     return Task.Run(async () =>
     {
         _processStartInfo = new ProcessStartInfo
         {
             UseShellExecute = false,
             RedirectStandardInput = true,
             RedirectStandardOutput = true,
             RedirectStandardError = true,
             FileName = "cmd.exe",
             CreateNoWindow = createNoWindow
         };
         _process = new Process { StartInfo = _processStartInfo };
         _process.Start();
         await _process.StandardInput.WriteLineAsync(cmd.Text);
         await _process.StandardInput.FlushAsync();
         _process.StandardInput.Dispose();
         string output = await _process.StandardOutput.ReadToEndAsync();
         return output;
     });
 }
Esempio n. 16
0
        protected virtual void SetupLayout()
        {
            this.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            this.RowDefinitions.Add(new RowDefinition());
            this.ColumnDefinitions.Add(new ColumnDefinition());
            this.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

            CreateRibbon();
            CreateCanvas();
            CreatePropertyGrid();
            CreateStatusBar();
            CreateFigureExplorer();

            this.Children.Add(Ribbon);
            this.Children.Add(DrawingAdorner); //DrawingControl);
            this.Children.Add(propertyGridScrollViewer);
            this.Children.Add(StatusBar);
            this.Children.Add(FigureExplorer);

            FigureExplorer.Visible = Settings.Instance.ShowFigureExplorer;

            Grid.SetColumnSpan(Ribbon, 2);
            Grid.SetColumn(FigureExplorer, 1);
            Grid.SetRow(FigureExplorer, 1);
            Grid.SetRow(DrawingAdorner,1); //DrawingControl, 1);
            Grid.SetRow(propertyGridScrollViewer, 1);
            Grid.SetRow(StatusBar, 1);

            CommandToggleGrid = new Command(ToggleGrid, CartesianGrid.GetIcon(), "Grid", BehaviorCategories.Coordinates);
            CommandToggleOrtho = new Command(ToggleOrtho, new CheckBox(), "Ortho", BehaviorCategories.Selection);
            CommandToggleSnapToGrid = new Command(ToggleSnapToGrid, new CheckBox(), "Snap to grid", BehaviorCategories.Selection);
            CommandToggleSnapToPoint = new Command(ToggleSnapToPoint, new CheckBox(), "Snap to point", BehaviorCategories.Selection);
            CommandToggleLabelNewPoints = new Command(ToggleLabelNewPoints, new CheckBox(), "Label New Points", BehaviorCategories.Points);
            CommandTogglePolar = new Command(TogglePolar, new CheckBox(), "Polar", BehaviorCategories.Selection);
            CommandToggleSnapToCenter = new Command(ToggleSnapToCenter, new CheckBox(), "Snap to Center", BehaviorCategories.Selection);
            CommandShowFigureExplorer = new Command(ToggleFigureExplorer, new CheckBox() { IsChecked = FigureExplorer.Visible }, "Figure List", BehaviorCategories.Drawing);
        }
Esempio n. 17
0
 public void SendCommand(Command c)
 {
     atWorker.sendCommand(c);
 }
Esempio n. 18
0
            // this tries to "merge" the incoming command with the accumulated queue
            // for example, if we get SetHorizontalOffset incoming, all "horizontal"
            // commands in the queue get removed and replaced with incoming one,
            // since horizontal position is going to end up at the specified offset anyways.
            private bool OptimizeCommand(Command command)
            {
                if(_lastWritePosition != _lastReadPosition) //buffer has something
                {

                    if(   (   command.Code == Commands.SetHorizontalOffset
                           && _array[_lastWritePosition].Code == Commands.SetHorizontalOffset)
                       || (   command.Code == Commands.SetVerticalOffset
                           && _array[_lastWritePosition].Code == Commands.SetVerticalOffset)
                       || (command.Code == Commands.MakeVisible
                           && _array[_lastWritePosition].Code == Commands.MakeVisible))
                    {
                        //if the last command was "set offset" or "make visible", simply replace it and
                        //don't insert new command
                        _array[_lastWritePosition].Param = command.Param;
                        _array[_lastWritePosition].MakeVisibleParam = command.MakeVisibleParam;
                        return true;
                    }
                }
                return false;
            }
Esempio n. 19
0
            //returns false if capacity is used up and entry ignored
            internal void Enqueue(Command command)
            {
                if(_lastWritePosition == _lastReadPosition) //buffer is empty
                {
                    _array = new Command[_capacity];
                    _lastWritePosition = _lastReadPosition = 0;
                }

                if(!OptimizeCommand(command)) //regular insertion, if optimization didn't happen
                {
                    _lastWritePosition = (_lastWritePosition + 1) % _capacity;

                    if(_lastWritePosition == _lastReadPosition) //buffer is full
                    {
                        // throw away the oldest entry and continue to accumulate fresh input
                        _lastReadPosition = (_lastReadPosition + 1) % _capacity;
                    }

                    _array[_lastWritePosition] = command;
                }
            }
Esempio n. 20
0
        public void ProcessMessage(Command command)
        {
            try
            {
                if (command is CommandConnectionSuccessful)
                {
                    CommandConnectionSuccessful commandConnectionSuccessful = command as CommandConnectionSuccessful;
                    m_ClientId = commandConnectionSuccessful.ClientId;
                    //m_IsServerConnectionEstablished = true;
                }
                else if (command is CommandChatMessage)
                {
                    Task.Factory.StartNew(() =>
                    {
                        CommandChatMessage commandChatMessage = command as CommandChatMessage;
                        MessageBox.Show(commandChatMessage.Contents);
                    }, CancellationToken.None, TaskCreationOptions.None, m_TaskScheduler);
                }
                else if (command is CommandNotifyGame)
                {
                    Task.Factory.StartNew(() =>
                    {
                        CommandNotifyGame commandNotifyGame = command as CommandNotifyGame;
                        CommandNotifyGame game = GameLobbyCollection.Where(x => x.GameId == commandNotifyGame.GameId).FirstOrDefault();
                        if (game != null)
                        {
                            GameLobbyCollection.Remove(game);

                        }
                        GameLobbyCollection.Add(commandNotifyGame);
                    }, CancellationToken.None, TaskCreationOptions.None, m_TaskScheduler);
                }

                else if (command is CommandServerError)
                {
                    Task.Factory.StartNew(() =>
                    {
                        CommandServerError commandServerError = command as CommandServerError;
                        MessageBox.Show(commandServerError.ErrorMessage);
                    }, CancellationToken.None, TaskCreationOptions.None, m_TaskScheduler);
                }

                else if (command is CommandJoinGameSuccessful)
                {
                    CommandJoinGameSuccessful commandJoinGameSuccessful = command as CommandJoinGameSuccessful;
                    m_GameId = commandJoinGameSuccessful.GameId;
                    CommandChatMessage commandChatMessage = new CommandChatMessage(m_ClientId + " has joined the game.");
                    commandChatMessage.GameId = m_GameId;
                    SendMessageToServer(commandChatMessage.ToXml());

                    Task.Factory.StartNew(() =>
                    {
                        btnJoin.Visibility = Visibility.Hidden;
                        btnCreate.Visibility = Visibility.Hidden;
                    }, CancellationToken.None, TaskCreationOptions.None, m_TaskScheduler);
                }

            }
            catch (Exception ex)
            {
                // error handling
            }
        }
        public ObservableCollection<Node> FillProjects()
        {
            var comm = new Command(DatabaseManager.Instance.Connection);
            var nodes = new ObservableCollection<Node>();

            var Freelancers = DatabaseLoader.ComputeFreelansers(comm).ToList();
            //var Costumers = DatabaseLoader.ComputeCostumers(comm).ToList();
            var Tasks = DatabaseLoader.ComputeTasks(comm).ToList();
            var Projects = DatabaseLoader.ComputeProjects(comm).ToList();

            foreach(var project in Projects)
            {
                Node nodeProject = project;
                Node nodeLead = Freelancers.Where(p => p.PersonId == project.TeamLeadId).First();
                foreach (var task in Tasks)
                {
                    if (task.ProjectId == project.Idproject)
                    {
                        Node node = task;
                        foreach (var freelancer in Freelancers)
                        {
                            if (freelancer.PersonId == task.ExecutorId)
                            {

                                node.Children.Add(freelancer);
                            }

                        }
                        nodeProject.Children.Add(node);
                    }
                }

                nodes.Add(nodeProject);
                if (nodeLead!=null)
                    nodeProject.Children.Add(nodeLead);

            }

            Node temp = new HeaderNode();
            temp.Text = "Projects";
            temp.IsExpanded = true;
            foreach (var node in nodes)
                temp.Children.Add(node);

            var tempList = new ObservableCollection<MVVM.Node>();
            tempList.Add(temp);
            return tempList;
        }
        public ObservableCollection<Node> FillFreelancer()
        {
            var comm = new Command(DatabaseManager.Instance.Connection);
            var nodes = new ObservableCollection<Node>();

            var Freelancers = DatabaseLoader.ComputeFreelansers(comm).ToList();
            //var Costumers = DatabaseLoader.ComputeCostumers(comm).ToList();
            var Tasks = DatabaseLoader.ComputeTasks(comm).ToList();
            //var Projects = DatabaseLoader.ComputeProjects(comm).ToList();

            foreach (var freelancer in Freelancers)
            {
                Node parentNode = freelancer;

                foreach (var task in Tasks)
                {
                    if (task.Id == freelancer.PersonId)
                    {
                        Node childNode = task;
                        parentNode.Children.Add(task);
                    }
                }
                nodes.Add(parentNode);

            }

            Node temp = new MVVM.HeaderNode();
            temp.Text = "Freelancers";
            temp.IsExpanded = true;
            foreach (var node in nodes)
                temp.Children.Add(node);

            var tempList = new ObservableCollection<MVVM.Node>();
            tempList.Add(temp);
            return tempList;
        }
Esempio n. 23
0
 public SearchTextBox()
 {
     ClearTextCommand = new Command<object>(o => Text = string.Empty, o => !string.IsNullOrEmpty(Text));
 }
Esempio n. 24
0
 /// <summary>
 /// Handler for the Command port.  ExecuteCommandInteractive and ExecuteCommandSilently
 /// post commands to this port.
 /// </summary>
 /// <param name="cmd"></param>
 private void commandHandler(Command cmd)
 {
     PythonExecuting.Invoke(this, new EventArgs());
     Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new ThreadStart(
         delegate() { commandLineBox.IsEnabled = false; }));
     try
     {
         if (cmd.IsInteractive)
             pe.ExecuteToConsole(cmd.CommandString);
         else
             pe.Execute(cmd.CommandString);
     }
     catch (Exception err)
     {
         LogText(Strings.FromExceptionMessage(err) + "\n", ErrColor);
     }
     Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new ThreadStart(
         delegate() { commandLineBox.IsEnabled = true; commandLineBox.Focus(); }));
     PythonFinished.Invoke(this, new EventArgs());
 }
Esempio n. 25
0
 public AdbTools()
 {
     _cmd = new Command();
     _cmds = new List<Command>();
     _executor = new CommandExecutor();
 }
Esempio n. 26
0
        private void KinectControlerHasNewControl(object sender, ControlDataReadyEventArgs e)
        {
            if (frameCounter <= 0)
            {
                Console.WriteLine("Left : "+e.PowerLeft+", Right : "+e.PowerRight);

                Command commandToSend = Command.stand;

                if (e.PowerLeft == 0 && e.PowerRight == 0)
                {
                    commandToSend = Command.stand;
                    Console.WriteLine("Stand");
                } else if (e.PowerLeft == 0 && e.PowerRight > 0)
                {
                    commandToSend = Command.right;
                    Console.WriteLine("Right");
                } else if (e.PowerLeft > 0 && e.PowerRight == 0)
                {
                    commandToSend = Command.left;
                    Console.WriteLine("Left");
                }
                else if (e.PowerLeft > 0 && e.PowerRight > 0)
                {
                    commandToSend = Command.forward;
                    Console.WriteLine("Forward");
                }
                else if (e.PowerLeft < 0 || e.PowerRight < 0)
                {
                    commandToSend = Command.backward;
                    Console.WriteLine("Backward");
                }
                else
                {
                    commandToSend = Command.stand;
                    Console.WriteLine("Default : stand");
                }

                if (this.commanderReady)
                {
                    if (commandToSend != lastCommandSent)
                    {
                        this.commander.sendCommand(commandToSend);
                        lastCommandSent = commandToSend;
                    }
                }
                else
                {
                    Console.WriteLine("Trying to send command while commander isn't ready");
                }

                frameCounter = WORK_RATE;
            } else {
                frameCounter--;
            }
        }
Esempio n. 27
0
 public CommandToolButton AddToolbarButton(Command command)
 {
     return Ribbon.AddToolButton(command);
 }
 private bool SendControlCommand(Command command, short value )
 {
     try
     {
         var controlPacket = new UsbSetupPacket((byte)UsbRequestType.TypeVendor, (byte)command, value, 0, 0);
         object buffer = null;
         int transferred;
         bool result = MyUsbDevice.ControlTransfer(ref controlPacket, buffer, 0, out transferred);
         return result;
     }
     catch (Exception exception)
     {
         Log("");
         Log("An error occurred during control transmission:");
         Log(exception.Message);
     }
     return false;
 }
Esempio n. 29
0
 public virtual void RaiseCommandExecuted(Command command)
 {
     // Do nothing when a command is executed but allow this to be overridden.
 }
Esempio n. 30
0
 public CommandToolButton AddToolButton(Command command)
 {
     var button = new CommandToolButton(command);
     AddToolButton(button, command.Category);
     return button;
 }