public override void Preview(string contentName) { verdana = ContentLoader.Load<Font>("Verdana12"); new FontText(verdana, "Play", Rectangle.One); sound = ContentLoader.Load<Sound>(contentName); var trigger = new MouseButtonTrigger(); trigger.AddTag("temporary"); var soundCommand = new Command(() => sound.Play(1)).Add(trigger); soundCommand.AddTag("temporary"); }
protected override void Preview(string contentName) { var verdana = ContentLoader.Load<Font>("Verdana12"); new FontText(verdana, "Play", Rectangle.One); if (Sound != null) DisposeData(); Sound = ContentLoader.Load<Sound>(contentName); trigger = new MouseButtonTrigger(); trigger.AddTag("temporary"); soundCommand = new Command(() => Sound.Play(1)).Add(trigger); soundCommand.AddTag("temporary"); }
private void SetMouseCommands(string obj) { var leftClickTriggerReleasing = new MouseButtonTrigger(MouseButton.Left, State.Releasing); leftClickTriggerReleasing.AddTag("temporary"); var findEntityCommand = new Command(FindEntity2DOnPosition).Add(leftClickTriggerReleasing); findEntityCommand.AddTag("temporary"); var releaseMiddleMouse = new MouseButtonTrigger(MouseButton.Left, State.Releasing); releaseMiddleMouse.AddTag("temporary"); var setReleasingCommand = new Command(position => AddControlToScene(position)).Add(releaseMiddleMouse); setReleasingCommand.AddTag("temporary"); UiEditorScene.SetMousePosition(); }
protected override void Preview(string contentName) { verdana = ContentLoader.Load<Font>("Verdana12"); new FontText(verdana, "Play/Stop", Rectangle.One); music = ContentLoader.Load<Music>(contentName); music.Play(1); var trigger = new MouseButtonTrigger(); trigger.AddTag("temporary"); var musicCommand = new Command(() => //ncrunch: no coverage start { if (music.IsPlaying()) music.Stop(); else music.Play(1); }).Add(trigger); musicCommand.AddTag("temporary"); //ncrunch: no coverage end }
public void SetCommands() { var leftClickTrigger = new MouseButtonTrigger(); leftClickTrigger.AddTag("temporary"); var leftClickCommand = new Command(LeftMouseButton).Add(leftClickTrigger); leftClickCommand.AddTag("temporary"); var middleDragTrigger = new MouseDragTrigger(MouseButton.Middle); middleDragTrigger.AddTag("temporary"); var middleDragCommand = new Command(MiddleMouseDrag).Add(middleDragTrigger); middleDragCommand.AddTag("temporary"); var dragLeftTrigger = new MouseDragTrigger(); dragLeftTrigger.AddTag("temporary"); var dragLeftCommand = new Command(LeftMouseDrag).Add(dragLeftTrigger); dragLeftCommand.AddTag("temporary"); var zoomTrigger = new MouseZoomTrigger(); zoomTrigger.AddTag("temporary"); var zoomCommand = new Command(Zoom).Add(zoomTrigger); zoomCommand.AddTag("temporary"); var leftReleaseTrigger = new MouseButtonTrigger(State.Releasing); leftReleaseTrigger.AddTag("temporary"); var leftReleaseCommand = new Command(LeftMouseRelease).Add(leftReleaseTrigger); leftReleaseCommand.AddTag("temporary"); }
private void SetMouseCommands(string obj) { var leftClickTrigger = new MouseButtonTrigger(); leftClickTrigger.AddTag("temporary"); var findEntityCommand = new Command(FindEntity2DOnPosition).Add(leftClickTrigger); findEntityCommand.AddTag("temporary"); var moveMouse = new MousePositionTrigger(MouseButton.Left, State.Pressed); moveMouse.AddTag("temporary"); var moveImageCommand = new Command( position => uiEditorScene.ControlProcessor.MoveImage(position, SelectedEntity2D, Adder.IsDragging, uiEditorScene.IsSnappingToGrid, uiEditorScene)).Add(moveMouse); moveImageCommand.AddTag("temporary"); var middleMouseClick = new MouseButtonTrigger(MouseButton.Middle); middleMouseClick.AddTag("temporary"); var setLastPositionCommand = new Command(position => uiEditorScene.ControlProcessor.lastMousePosition = position).Add( middleMouseClick); setLastPositionCommand.AddTag("temporary"); var releaseMiddleMouse = new MouseButtonTrigger(MouseButton.Left, State.Releasing); releaseMiddleMouse.AddTag("temporary"); var setReleasingCommand = new Command(position => SetCommandsForReleasing(position)).Add(releaseMiddleMouse); setReleasingCommand.AddTag("temporary"); }
public void SetMousePosition() { var middleClick = new MouseButtonTrigger(); middleClick.AddTag("temporary"); var setLastPositionCommand = new Command(position => SetPosition(position)).Add(middleClick); setLastPositionCommand.AddTag("temporary"); var moveMouse = new MousePositionTrigger(MouseButton.Left, State.Released); moveMouse.AddTag("temporary"); var checkTransformationCommand = new Command(position => CheckIfCanTransformControl(position)).Add(moveMouse); checkTransformationCommand.AddTag("temporary"); var pressAndMoveMouse = new MousePositionTrigger(MouseButton.Left, State.Pressed); pressAndMoveMouse.AddTag("temporary"); var pressOnControlCommand = new Command(position => TransformSelectedControl(position)).Add(pressAndMoveMouse); pressOnControlCommand.AddTag("temporary"); var pressControl = new KeyTrigger(Key.LeftControl); pressControl.AddTag("temporary"); var multiSelectControl = new Command(() => SetMultiSelection(true)).Add(pressControl); multiSelectControl.AddTag("temporary"); var releaseControl = new KeyTrigger(Key.LeftControl, State.Releasing); releaseControl.AddTag("temporary"); var disableMultiSelectControl = new Command(() => SetMultiSelection(false)).Add(releaseControl); disableMultiSelectControl.AddTag("temporary"); }
private static void ChangeMouseButtonInCommandList(string adding, string removing, Trigger trigger) { var mouseButtonTrigger = (MouseButtonTrigger)trigger; if (mouseButtonTrigger.Button.ToString() == removing) { mouseButtonTrigger.Dispose(); mouseButtonTrigger = new MouseButtonTrigger((MouseButton)Enum.Parse(typeof(MouseButton), adding)); } }
private bool CheckWhichButtonForMouseButtonTriggerToUse(bool foundFreeKey, MouseButton button, int index) { if (foundFreeKey) return true; bool keyAlreadyUsed = false; foreach (Trigger newTrigger in GetTriggersOfCommand()) keyAlreadyUsed = CheckIfMouseButtonIsAlreadyUsed(newTrigger, button, keyAlreadyUsed); if (keyAlreadyUsed) return false; var mouseButtonTrigger = new MouseButtonTrigger(button, State.Pressed); GetTriggersOfCommand()[index] = mouseButtonTrigger; return true; }