private void ChangeTool(object toolParam) { switch (toolParam.ToString()) { case "Hand": ToolCursor = new StandardToolCursor("hand.cur"); _toolBehavior = new LayoutToolBehavior(); ActiveIcon = "cursor"; break; case "VSplit": ToolCursor = new StandardToolCursor("vsplit.cur"); _toolBehavior = new CleaveScreenVerticalToolBehavior(); ActiveIcon = "cleave"; break; case "Start": ToolCursor = new SpriteCursor(_playerSprite, 8, 1); _toolBehavior = new StartPointToolBehavior(8, 1); ActiveIcon = "start"; break; case "Continue": ToolCursor = new SpriteCursor(_playerSprite); _toolBehavior = new ContinuePointToolBehavior(); ActiveIcon = "continue"; break; } if (ToolChanged != null) { ToolChanged(this, new ToolChangedEventArgs(_toolBehavior)); } }
private ToolOutcome Apply(IActionQueue actionQueue, IToolBehavior toolBehavior, IToolBrush toolBrush, IEnumerable <Vector> inputPositions) { IEnumerable <Vector> toolPositions = toolBrush.ComputePositions(inputPositions); var action = toolBehavior.CreateActions(toolPositions); void ValidatedAction(World gs) { if (Validate(gs, toolBehavior, toolPositions)) { action(gs); } else { throw new InvalidOperationException("Action is not valid"); } } // TODO: don't use exception to control the flow. Need google for this. try { actionQueue.ExecuteSynchronously(ValidatedAction); return(ToolOutcome.Success); } catch (InvalidOperationException) { return(ToolOutcome.Failure); } }
internal ToolHandler(IToolBehavior <ToolDataT> tool, WeakReference <MixedRealityExtensionApp> appRef, IActor attachedActor) : base(tool, appRef, attachedActor) { RegisterActionHandler(tool.Holding, nameof(tool.Holding)); RegisterActionHandler(tool.Using, nameof(tool.Using)); _toolBehavior = tool; _toolBehavior.Using.ActionStateChanging += OnUsingStateChanging; ToolData = new ToolDataT(); }
private void TestFromLocation() { ToolCursor = new SpriteCursor(_playerSprite); _toolBehavior = new TestLocationToolBehavior(); ActiveIcon = null; if (ToolChanged != null) { ToolChanged(this, new ToolChangedEventArgs(_toolBehavior)); } }
private void UpdateTool(object toolParam = null) { switch (toolParam.ToString()) { case "Hand": _toolCursor = new StandardToolCursor("hand.cur"); _toolBehavior = null; ActiveIcon = "cursor"; break; case "Entity": _toolCursor = new SpriteCursor(SelectedEntity.DefaultSprite, SnapHorizontal ? HorizSnapAmount : 1, SnapVertical ? VertSnapAmount : 1); _toolBehavior = new EntityToolBehavior(SelectedEntity.Entity, SnapHorizontal ? HorizSnapAmount : 1, SnapVertical ? VertSnapAmount : 1); ActiveIcon = ""; break; } if (ToolChanged != null) { ToolChanged(this, new ToolChangedEventArgs(_toolBehavior)); } }
private ToolPreviewOutcome Preview(IWorldView worldView, IToolBehavior toolBehavior, IToolBrush toolBrush, IEnumerable <Vector> inputPositions) { IEnumerable <Vector> toolPositions = toolBrush.ComputePositions(inputPositions); return(toolBehavior.Preview(worldView, toolPositions)); }
private static bool Validate(IWorldView worldView, IToolBehavior toolBehavior, IEnumerable <Vector> toolPositions) { return(toolBehavior.Preview(worldView, toolPositions).IsPossible()); }
private void ChangeTool(object toolParam) { switch (toolParam.ToString()) { case "Hand": ToolCursor = new StandardToolCursor("hand.cur"); _toolBehavior = new LayoutToolBehavior(); ActiveIcon = "cursor"; break; case "VSplit": ToolCursor = new StandardToolCursor("vsplit.cur"); _toolBehavior = new CleaveScreenVerticalToolBehavior(); ActiveIcon = "cleave"; break; case "Start": ToolCursor = new ResourceCursor("start_full.png"); _toolBehavior = new StartPointToolBehavior(); ActiveIcon = "start"; break; case "Continue": ToolCursor = new ResourceCursor("continue_full.png"); _toolBehavior = new ContinuePointToolBehavior(); ActiveIcon = "continue"; break; } if (ToolChanged != null) { ToolChanged(this, new ToolChangedEventArgs(_toolBehavior)); } }
public ToolChangedEventArgs(IToolBehavior tool) { Tool = tool; }