public MainWindowViewModel(VideoPlayer videoPlayerIn) { this.exportQueueViewModel = new ExportQueueViewModel(); OpenFileCommand = new OpenFileCommand(this, videoPlayerIn); OpenExportQueueCommand = new OpenExportQueueCommand(this, this.exportQueueViewModel); OpenSettingsCommand = new OpenSettingsCommand(this); OpenAboutCommand = new OpenAboutCommand(this); PlayOrPauseCommand = new PlayOrPauseCommand(this, videoPlayerIn); SetSectionStartCommand = new SetSectionStartCommand(this, videoPlayerIn); SetSectionEndCommand = new SetSectionEndCommand(this, videoPlayerIn); BackwardCommand = new BackwardCommand(this, videoPlayerIn); ForwardCommand = new ForwardCommand(this, videoPlayerIn); StepBackwardCommand = new SeekCommand(this, videoPlayerIn, () => - videoPlayerIn.FrameTime); StepForwardCommand = new SeekCommand(this, videoPlayerIn, () => videoPlayerIn.FrameTime); Step1sBackwardCommand = new SeekCommand(this, videoPlayerIn, () => - TimeSpan.FromSeconds(1)); Step1sForwardCommand = new SeekCommand(this, videoPlayerIn, () => TimeSpan.FromSeconds(1)); PlayFromSelectionStartCommand = new PlayFromSelectionStartCommand(this, videoPlayerIn); PlaySelectionCommand = new PlaySelectionCommand(this, videoPlayerIn); PlayUntilSelectionEndCommand = new PlayUntilSelectionEndCommand(this, videoPlayerIn); ExportSelectionCommand = new ExportSelectionCommand(this); NextVideoCommand = new NextVideoCommand(this, videoPlayerIn); AddToQueueCommand = new AddToQueueCommand(this, this.exportQueueViewModel); AudioVolume = ApplicationSettings.AudioVolume; }
/// <summary> /// Does the command job. /// </summary> private void DoCommandJob() { IPEndPoint udpEndPoint = new IPEndPoint(IPAddress.Any, ListenCommandPort); if (this.ToMulticast) { IPAddress multicastAdress = IPAddress.Parse(this.ForwardHostVideo); ListenCUdpPort.JoinMulticastGroup(multicastAdress); _logger.Debug("Forward Command from multicast {0}:{1} => TCP interleaved {2}", this.ForwardHostVideo, ListenCommandPort, ForwardInterleavedCommand); } else { _logger.Debug("Forward Command from {0} => TCP interleaved {1}", ListenCommandPort, ForwardInterleavedCommand); } byte[] frame; try { do { frame = ListenCUdpPort.Receive(ref udpEndPoint); ForwardCommand.BeginSendData(ForwardInterleavedCommand, frame, new AsyncCallback(EndSendCommand), frame); }while (true); //The break of the loop is made by close wich raise an exception } catch (ObjectDisposedException) { _logger.Debug("Forward command closed"); } catch (SocketException) { _logger.Debug("Forward command closed"); } }
private ICommand Forward(XTablePortable table, ICommand command) { ForwardCommand cmd = (ForwardCommand)command; List <KeyValuePair <IData, IData> > list = table.Forward(cmd.FromKey, cmd.FromKey != null, cmd.ToKey, cmd.ToKey != null).Take(cmd.PageCount).ToList(); return(new ForwardCommand(cmd.PageCount, cmd.FromKey, cmd.ToKey, list)); }
private void BrowserOnLoadingStateChanged(object o, LoadingStateChangedEventArgs loadingStateChangedEventArgs) { _dispatcher.InvokeAsync(() => { BackCommand.RaiseCanExecuteChanged(); ForwardCommand.RaiseCanExecuteChanged(); }); }
public IEnumerable <KeyValuePair <IData, IData> > Forward(IData from, bool hasFrom, IData to, bool hasTo) { if (hasFrom && hasTo && IndexDescriptor.KeyComparer.Compare(from, to) > 0) { throw new ArgumentException("from > to"); } from = hasFrom ? from : default(IData); to = hasTo ? to : default(IData); List <KeyValuePair <IData, IData> > records = null; IData nextKey = null; var command = new ForwardCommand(PageCapacity, from, to, null); Execute(command); records = command.List; nextKey = records != null && records.Count == PageCapacity ? records[records.Count - 1].Key : null; while (records != null) { Task task = null; List <KeyValuePair <IData, IData> > _records = null; int returnCount = nextKey != null ? records.Count - 1 : records.Count; if (nextKey != null) { task = Task.Factory.StartNew(() => { var _command = new ForwardCommand(PageCapacity, nextKey, to, null); Execute(_command); _records = _command.List; nextKey = _records != null && _records.Count == PageCapacity ? _records[_records.Count - 1].Key : null; }); } for (int i = 0; i < returnCount; i++) { yield return(records[i]); } records = null; if (task != null) { task.Wait(); } if (_records != null) { records = _records; } } }
private void OnBrowserNavigated(object sender, System.Windows.Navigation.NavigationEventArgs e) { WebAddress = e.Uri == null ? "" : e.Uri.OriginalString; var doc = Browser.Browser.Document as HTMLDocument; Header = doc.title == "" ? Header : doc.title; ForwardCommand.RaiseCanExecuteChanged(); BackCommand.RaiseCanExecuteChanged(); }
public void TestRobotMoveCommand() { var world = new MartianWorld(3, 3); var rotateLeft = new ForwardCommand(world); var robot = new Robot(new Point(0, 0), RobotOrientation.North); rotateLeft.ExecuteCommandFor(robot); Assert.AreEqual(robot.Coordinates, new Point(0, 1)); }
public void Setup() { _gridMock = new Mock <IGrid>(); _gridMock.Setup(x => x.Width).Returns(5); _gridMock.Setup(x => x.Height).Returns(5); _gridMock.Setup(x => x.IsScent(It.IsAny <Point>())).Returns(false); _gridMock.Setup(x => x.IsOutside(It.IsAny <Point>())).Returns(false); _robot = Robot.Construct("3 3 N", _gridMock.Object); _command = new ForwardCommand(); }
private ICommand Forward(XTable table, ICommand command) { ForwardCommand cmd = (ForwardCommand)command; List <KeyValuePair <IData, IData> > list = new List <KeyValuePair <IData, IData> >(); foreach (var item in table.Forward(cmd.FromKey, cmd.FromKey != null, cmd.ToKey, cmd.ToKey != null).Take(cmd.PageCount)) { list.Add(item); } return(new ForwardCommand(cmd.PageCount, cmd.FromKey, cmd.ToKey, list)); }
/// <summary> /// Ends the send command. /// </summary> /// <param name="result">The result.</param> private void EndSendCommand(IAsyncResult result) { try { ForwardCommand.EndSendData(result); byte[] frame = (byte[])result.AsyncState; CommandFrameSended(frame); } catch (Exception error) { _logger.Error("Error during command forwarding", error); } }
/// <summary> /// Makes from a string and value a command /// </summary> /// <param name="command"></param> /// <param name="value"></param> /// <returns>Command</returns> public IDroneCommand makeCommand(string command, double value = 0) { IDroneCommand droneCommand = null; if (command.Equals("Start")) { droneCommand = new StartCommand(_droneController); } else if (command.Equals("Land")) { droneCommand = new LandCommand(_droneController); } else if (command.Equals("Rise")) { droneCommand = new RiseCommand(_droneController, value); } else if (command.Equals("Fall")) { droneCommand = new FallCommand(_droneController, value); } else if (command.Equals("Right")) { droneCommand = new RightCommand(_droneController, value); } else if (command.Equals("Left")) { droneCommand = new LeftCommand(_droneController, value); } else if (command.Equals("Forward")) { droneCommand = new ForwardCommand(_droneController, value); } else if (command.Equals("Backward")) { droneCommand = new BackwardCommand(_droneController, value); } else if (command.Equals("Turn")) { droneCommand = new TurnCommand(_droneController, (int)value); } else if (command.Equals("TakePicture")) { droneCommand = new TakePictureCommand(_droneController, (int)value); } else if (command.Equals("FollowLine")) { droneCommand = new FollowLineCommand(_droneController); } return(droneCommand); }
public static void Execute() { ConsoleExtension.WriteSeparator("Email example"); var email = new Email(); var readCommand = new ReadCommand(email); var forwardCommand = new ForwardCommand(email); var deleteCommand = new DeleteCommand(email); var toolbar = new Toolbar(readCommand, forwardCommand, deleteCommand); toolbar.ReadEmail(); toolbar.ForwardEmail(); toolbar.DeleteEmail(); }
private void OnForwardButtonClick(object sender, EventArgs e) { if (CurrentStepNumber < StepCount - 1) { CurrentStepNumber++; if ((ForwardCommand != null) && (ForwardCommand.CanExecute(CurrentStepNumber))) { ForwardCommand.Execute(CurrentStepNumber); } } else { // finished last step if ((WizardCompleteCommand != null) && (WizardCompleteCommand.CanExecute(null))) { WizardCompleteCommand.Execute(null); } } }
public virtual void OnNavigatedTo(NavigationContext navigationContext) { RegionNavigationService = navigationContext.NavigationService; BackCommand.RaiseCanExecuteChanged(); ForwardCommand.RaiseCanExecuteChanged(); }