private void Representation_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { ToolState CurrAppState = Global.APP_STATE_; switch (CurrAppState) { case ToolState.SELECT_MOVE_: if (e.Button == System.Windows.Forms.MouseButtons.Left) { #if DEBUG Console.Write(Global.APP_SELECT_MOVE_); #endif } break; case ToolState.ADD_REMOVE_: #if DEBUG Console.Write(Global.APP_ADD_REMOVE_); #endif break; default: #if DEBUG Console.Write(Global.APP_STATE_DEFAULT_CASE_); #endif break; } }
private void Representation_MouseEnter(object sender, EventArgs e) { ToolState CurrAppState = Global.APP_STATE_; switch (CurrAppState) { case ToolState.SELECT_MOVE_: Representation.Cursor = System.Windows.Forms.Cursors.Cross; break; default: break; } RepresentationTTIP = new System.Windows.Forms.ToolTip { AutoPopDelay = 15000, // Warning! MSDN states this is Int32, but anything over 32767 will fail. ShowAlways = true, ToolTipTitle = Name, InitialDelay = 200, ReshowDelay = 200, UseAnimation = true }; RepresentationTTIP.SetToolTip(Representation, "Galactic position:\n\t" + Galactic_Position.ToString()); #if DEBUG Console.Write("Mouse over {0}\n", Name); #endif }
public BrushRecolor() { Singleton <Input> .INSTANCE.AddHandler(new InputHandler() { mouseuphandler = (e) => { if (!Active) { return; } if (e.Button == MouseButton.Right && Singleton <Input> .INSTANCE.Keydown(Key.AltLeft) && state == ToolState.Base) { state = ToolState.Disabled; if (Singleton <Input> .INSTANCE.mouseup(MouseButton.Left)) { CleanForToolReset(); state = ToolState.Start; } } if (state == ToolState.Disabled && e.Button == MouseButton.Left) { state = ToolState.Start; CleanForToolReset(); } } }); }
public override bool Details(ref Transform value, ToolState tool) { var changed = false; var translation = value.Position; var scale = value.Scale; var origin = value.Origin;
void SelectTool() { int i = 0; foreach (Transform tool in transform) { if (selectedTool == 0) { currentState = ToolState.Empty; } if (selectedTool == 1 && woodCutterAvailable) { currentState = ToolState.WoodAxe; } if (selectedTool == 2 && stoneCutterAvailable) { currentState = ToolState.StoneAxe; } if (selectedTool == 3 && huntingToolAvailable) { currentState = ToolState.Spear; } i++; } }
public Result <bool> AddToolState(ToolState state) { Result <bool> rlt = new Result <bool>(); try { var old = Db.ToolStates.FirstOrDefault(p => p.Code == state.Code); if (old != null) { rlt.HasError = true; rlt.Msg = "工具状态编码重复!"; } else { Db.ToolStates.Add(state); Db.SaveChanges(); } } catch (Exception ex) { LogUtil.WriteLog(ex); rlt.HasError = true; rlt.Msg = ex.Message; } return(rlt); }
public override ToolState Configure(ToolState tool) { ImGui.InputFloat("Min", ref tool.X); ImGui.InputFloat("Max", ref tool.Y); return(tool); }
override public void Init() { base.Init(); m_BaseScale = transform.localScale; m_BoundsState = BoundsState.Off; m_BoundsShowAmount = 0.0f; m_CurrentState = ToolState.Off; m_EnterAmount = 0.0f; m_TeleportFadeState = TeleportFadeState.Default; m_TeleportFadeAmount = 0.0f; m_TeleportParabola = GetComponent <LineRenderer>(); m_TeleportParabola.positionCount = m_TeleportParabolaPoints; for (int i = 0; i < m_TeleportParabolaPoints; ++i) { m_TeleportParabola.SetPosition(i, Vector3.zero); } m_TeleportParabola.material.SetColor("_EmissionColor", Color.black * 15.0f); m_TeleportParabola.enabled = false; LineRenderer rBadIconLine = m_BadTeleportIcon.GetComponentInChildren <LineRenderer>(); rBadIconLine.material.SetColor("_EmissionColor", Color.red * 15.0f); m_TeleportPlaceIconBaseScale = m_TeleportPlaceIcon.localScale; }
protected override void _fill_state(long now, out ToolState rr_tool_state) { lock (this) { var o = new ToolState(); o.ts = DateTimeUtil.TimeSpec3Now(RobotRaconteurNode.s); o.seqno = _state_seqno; o.command = _last_command; if (_gripper_current_state == null || _gripper_current_signals == null // TODO: Gripper isn't publishing unless state changes? //|| (now - _last_gripper_state > 2000) ) { o.tool_state_flags = (uint)ToolStateFlags.communication_failure; o.sensor = new double[0]; } else { o.sensor = new double[] { double.Parse(_get_signal_or_default("right_vacuum_gripper_tip_object_kg", "0")) }; bool has_error = bool.Parse(_get_signal_or_default("has_error", "true")); bool is_gripping = bool.Parse(_get_signal_or_default("is_gripping", "false")); uint f = 0; if (has_error) { f |= (uint)ToolStateFlags.error; } if (!has_error) { f |= (uint)ToolStateFlags.enabled; } f |= (uint)ToolStateFlags.ready; if (is_gripping) { f |= (uint)ToolStateFlags.gripping; } if (is_gripping) { o.position = 1; _position = o.position; f |= (uint)ToolStateFlags.closed; } else { o.position = 0; _position = o.position; f |= (uint)ToolStateFlags.opened; } o.tool_state_flags = f; } rr_tool_state = o; } }
public override void Start() { Plugin.Log.Info("Start tool"); toolState_ = ToolState.Active; G.Sys.LevelEditor_.OpenComponentSelectMenu("Select Custom Component", new Action <HierarchyComponentData>(OnItemSelected), new MenuPanel.OnPanelPop(OnMenuPop)); printMessage_ = "Select a component to add to the current object"; }
/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); double sx = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, _editor.Project.Options.SnapX) : x; double sy = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, _editor.Project.Options.SnapY) : y; switch (_currentState) { case ToolState.None: { _shape = XLine.Create( sx, sy, _editor.Project.CurrentStyleLibrary.Selected, _editor.Project.Options.PointShape, _editor.Project.Options.DefaultIsStroked); if (_editor.Project.Options.TryToConnect) { var result = TryToConnectStart(_shape as XLine, sx, sy); if (!result) { _editor.TryToSplitLine(x, y, _shape.Start); } } _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_shape); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateOne(); Move(_shape); _editor.Project.CurrentContainer.HelperLayer.Invalidate(); _currentState = ToolState.One; _editor.CancelAvailable = true; } break; case ToolState.One: { var line = _shape as XLine; if (line != null) { line.End.X = sx; line.End.Y = sy; if (_editor.Project.Options.TryToConnect) { var result = TryToConnectEnd(_shape as XLine, sx, sy); if (!result) { _editor.TryToSplitLine(x, y, _shape.End); } } _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_shape); Remove(); Finalize(_shape); _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, _shape); _currentState = ToolState.None; _editor.CancelAvailable = false; } } break; } }
public BrushRecolor() { Singleton<Input>.INSTANCE.AddHandler(new InputHandler() { mouseuphandler = (e) => { if (!Active) return; if (e.Button == MouseButton.Right && Singleton<Input>.INSTANCE.Keydown(Key.AltLeft) && state == ToolState.Base) { state = ToolState.Disabled; if (Singleton<Input>.INSTANCE.mouseup(MouseButton.Left)) { CleanForToolReset(); state = ToolState.Start; } } if (state == ToolState.Disabled && e.Button == MouseButton.Left) { state = ToolState.Start; CleanForToolReset(); } } }); }
/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); var editor = _serviceProvider.GetService<ProjectEditor>(); var pathTool = _serviceProvider.GetService<ToolPath>(); double sx = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, editor.Project.Options.SnapX) : x; double sy = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, editor.Project.Options.SnapY) : y; switch (_currentState) { case ToolState.None: { _line.Start = editor.TryToGetConnectionPoint(sx, sy) ?? XPoint.Create(sx, sy, editor.Project.Options.PointShape); if (!pathTool.IsInitialized) { pathTool.InitializeWorkingPath(_line.Start); } else { _line.Start = pathTool.GetLastPathPoint(); } _line.End = XPoint.Create(sx, sy, editor.Project.Options.PointShape); pathTool.GeometryContext.LineTo( _line.End, editor.Project.Options.DefaultIsStroked, editor.Project.Options.DefaultIsSmoothJoin); editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateOne(); Move(null); _currentState = ToolState.One; editor.CancelAvailable = true; } break; case ToolState.One: { _line.End.X = sx; _line.End.Y = sy; if (editor.Project.Options.TryToConnect) { var end = editor.TryToGetConnectionPoint(sx, sy); if (end != null) { var figure = pathTool.Geometry.Figures.LastOrDefault(); var line = figure.Segments.LastOrDefault() as XLineSegment; line.Point = end; } } _line.Start = _line.End; _line.End = XPoint.Create(sx, sy, editor.Project.Options.PointShape); pathTool.GeometryContext.LineTo(_line.End, editor.Project.Options.DefaultIsStroked, editor.Project.Options.DefaultIsSmoothJoin); editor.Project.CurrentContainer.WorkingLayer.Invalidate(); Move(null); _currentState = ToolState.One; } break; } }
private void initIsland() { island = new Island(IslandWidth, IslandHeight); GameObject islandGameObject = Instantiate(IslandPrefab, new Vector3(0, 0, 0), Quaternion.identity); islandView = islandGameObject.GetComponent <IslandView>(); islandView.Init(IslandWidth, IslandHeight); islandView.OnEnterTerrainCell = enterTerrainCellHandler; islandView.OnReleaseTerrainCell = releaseTerrainCellHandler; for (int x = 0; x < IslandWidth; x++) { for (int y = 0; y < IslandHeight; y++) { Vector2Int position = new Vector2Int(x, y); TerrainViewFeature terrainViewFeature; TerrainTallFeature terrainTallFeature; terrainViewFeatureOfPosition(position, out terrainViewFeature, out terrainTallFeature); islandView.SetTerrainFeature(position, terrainViewFeature, terrainTallFeature); } } // UI grid.Init(); toolPanel.Init(); toolPanel.OnWaterClick = () => state = ToolState.Water; toolPanel.OnTallClick = () => state = ToolState.Tall; }
public override ToolState Configure(ToolState tool) { var isFinite = float.IsFinite(tool.X) || float.IsFinite(tool.Y); if (ImGui.Checkbox("Finite", ref isFinite)) { if (isFinite) { tool.X = 0.0f; tool.Y = 1.0f; } else { tool.X = float.NegativeInfinity; tool.Y = float.PositiveInfinity; } } if (isFinite) { ImGui.InputFloat("Min", ref tool.X); ImGui.InputFloat("Max", ref tool.Y); } ImGui.InputFloat("Speed", ref tool.Z); return(tool); }
/// <inheritdoc/> public override void RightDown(double x, double y) { base.RightDown(x, y); switch (_currentState) { case ToolState.None: break; case ToolState.One: case ToolState.Two: case ToolState.Three: { _toolPath.RemoveLastSegment <XCubicBezierSegment>(); _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_toolPath._path); Remove(); if (_toolPath._path.Geometry.Figures.LastOrDefault().Segments.Length > 0) { Finalize(null); _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, _toolPath._path); } else { _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); } _toolPath.DeInitializeWorkingPath(); _currentState = ToolState.None; _editor.CancelAvailable = false; } break; } }
public levelEditor() { InitializeComponent(); //set toolstate to wall initially toolState = ToolState.Wall; tileState = new TileState[26, 26]; }
/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); double sx = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, _editor.Project.Options.SnapX) : x; double sy = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, _editor.Project.Options.SnapY) : y; switch (_currentState) { case ToolState.None: { var style = _editor.Project.CurrentStyleLibrary.Selected; _text = XText.Create( sx, sy, _editor.Project.Options.CloneStyle ? style.Clone() : style, _editor.Project.Options.PointShape, "Text", _editor.Project.Options.DefaultIsStroked); var result = _editor.TryToGetConnectionPoint(sx, sy); if (result != null) { _text.TopLeft = result; } _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_text); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateOne(); Move(_text); _currentState = ToolState.One; _editor.CancelAvailable = true; } break; case ToolState.One: { if (_text != null) { _text.BottomRight.X = sx; _text.BottomRight.Y = sy; var result = _editor.TryToGetConnectionPoint(sx, sy); if (result != null) { _text.BottomRight = result; } _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_text); Remove(); Finalize(_text); _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, _text); _currentState = ToolState.None; _editor.CancelAvailable = false; } } break; } }
/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); var editor = _serviceProvider.GetService<ProjectEditor>(); double sx = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, editor.Project.Options.SnapX) : x; double sy = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, editor.Project.Options.SnapY) : y; switch (_currentState) { case ToolState.None: { var style = editor.Project.CurrentStyleLibrary.Selected; _ellipse = XEllipse.Create( sx, sy, editor.Project.Options.CloneStyle ? style.Clone() : style, editor.Project.Options.PointShape, editor.Project.Options.DefaultIsStroked, editor.Project.Options.DefaultIsFilled); var result = editor.TryToGetConnectionPoint(sx, sy); if (result != null) { _ellipse.TopLeft = result; } editor.Project.CurrentContainer.WorkingLayer.Shapes = editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_ellipse); editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateOne(); Move(_ellipse); _currentState = ToolState.One; editor.CancelAvailable = true; } break; case ToolState.One: { if (_ellipse != null) { _ellipse.BottomRight.X = sx; _ellipse.BottomRight.Y = sy; var result = editor.TryToGetConnectionPoint(sx, sy); if (result != null) { _ellipse.BottomRight = result; } editor.Project.CurrentContainer.WorkingLayer.Shapes = editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_ellipse); Remove(); base.Finalize(_ellipse); editor.Project.AddShape(editor.Project.CurrentContainer.CurrentLayer, _ellipse); _currentState = ToolState.None; editor.CancelAvailable = false; } } break; } }
public void StartDragging(Body entity) { SelectedBody = entity; OrigTransform = SelectedBody.LocalTransform; State = ToolState.Dragging; SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_confirm_selection, SelectedBody.Position, 0.1f); OverrideOrientation = false; CurrentOrientation = 0.0f; }
/// <inheritdoc/> public override void Remove() { base.Remove(); _currentState = ToolState.None; _selection.Remove(); _selection = null; }
protected override void EndPointerSequenceCore(PointerEventInfo info, ILevelGeometry viewport) { _state = _state.EndPointerSequence(info, viewport); /*switch (info.Type) { case PointerEventType.Primary: EndSelectObjectSequence(info, viewport); break; }*/ }
public void SetToolState(ToolState state) { if (state == ToolState.None) { UIManager.instance.InputPanel.SetAllActive(false); } else { UIManager.instance.InputPanel.SetAllActive(true); } toolState = state; }
protected override void EndPointerSequenceCore(PointerEventInfo info, ILevelGeometry viewport) { _state = _state.EndPointerSequence(info, viewport); /*switch (info.Type) { * case PointerEventType.Primary: * EndSelectObjectSequence(info, viewport); * break; * }*/ }
void LoadDataSourceAccessRules(ISystemContext context, ToolState tool, DsatsDemo.DataSource.DeclarationType declaration) { if (declaration == null || declaration.AccessRules == null) { return; } BaseInstanceState folder = tool.FindChildBySymbolicName(context, DsatsDemo.BrowseNames.AccessRules); if (folder == null) { return; } foreach (DsatsDemo.DataSource.AccessRuleType rule in declaration.AccessRules) { NodeId phaseId = new NodeId("Phases/" + rule.Phase, NamespaceIndex); NodeId lockId = new NodeId("Locks/" + rule.Lock, NamespaceIndex); AccessRuleState node = new AccessRuleState(null); node.ReferenceTypeId = Opc.Ua.ReferenceTypeIds.HasComponent; node.Create( context, new NodeId(declaration.Path + "/" + declaration.BrowseName + "/AccessRules/" + rule.Phase, NamespaceIndex), new QualifiedName(rule.Phase, NamespaceIndex), null, true); node.AddReference(Opc.Ua.ReferenceTypeIds.Organizes, true, folder.NodeId); folder.AddReference(Opc.Ua.ReferenceTypeIds.Organizes, false, node.NodeId); AddPredefinedNode(context, node); NodeState target = FindPredefinedNode(phaseId, typeof(NodeState)); if (target != null) { NodeId referenceTypeId = new NodeId(DsatsDemo.ReferenceTypes.HasPhase, NamespaceIndex); node.AddReference(referenceTypeId, false, target.NodeId); target.AddReference(referenceTypeId, true, node.NodeId); } target = (DsatsDemo.LockConditionState)FindPredefinedNode(lockId, typeof(DsatsDemo.LockConditionState)); if (target != null) { NodeId referenceTypeId = new NodeId(DsatsDemo.ReferenceTypes.HasLock, NamespaceIndex); node.AddReference(referenceTypeId, false, target.NodeId); target.AddReference(referenceTypeId, true, node.NodeId); } tool.SetPhaseLock(phaseId, lockId); } }
public override ToolState Configure(ToolState tool) { var size = new Vector2(tool.X, tool.Y); if (ImGui.InputFloat2("Max preview size", ref size)) { tool.X = Math.Clamp(size.X, MinPreviewSize, MaxPreviewSize); tool.Y = Math.Clamp(size.Y, MinPreviewSize, MaxPreviewSize); } return(tool); }
private void Add() { if (!Global.HasRight("0202")) { MessageAlert.Alert("权限不足!"); return; } ToolState state = new ToolState(); MessengerInstance.Send <object>(state, MsgToken.OpenToolStateInfo); }
public override bool Details(ref Point value, ToolState tool) { bool slide(ref int x) => ImGui.DragInt(ToolUtils.NoLabel, ref x, 1, (int)tool.X, (int)tool.Y); var aspectRatio = value.X / (float)value.Y; var changed = ToolUtils.DetailsRow("X", ref value.X, slide); changed |= ToolUtils.DetailsRow("Y", ref value.Y, slide); return(changed); }
public override bool Details(ref Texture2D value, ToolState tool) { ToolUtils.TextRow("Width", $"{value.Width}"); ToolUtils.TextRow("Height", $"{value.Width}"); ToolUtils.TextRow("Format", $"{value.Format}"); if (ToolUtils.ButtonRow(ToolUtils.NoLabel, "Inspect")) { this.ImageInspector.SetImage(value); } return(false); }
public ObjectSelectTool(ILayerContext layerContext, ObjectLayer layer, Size gridSize, ObjectSelectionManager selectionManager) : base(layerContext, layer, gridSize) { _annots = layerContext.Annotations; _viewport = layerContext.Geometry; _selectionManager = selectionManager; _layerContext = layerContext; InitializeCommandManager(); _state = new SelectionStandbyToolState(this); }
public override bool HeaderValue(ref Color value, ToolState tool) { var color = value.ToVector4(); if (ImGui.ColorEdit4(ToolUtils.NoLabel, ref color)) { value = new Color(color); return(true); } return(false); }
public void Download(bool async, Action onRepaint) { threadOdsURL = odsURL; threadOdsFileName = dataPath + "/Resources Localization/" + odsFileName + ".ods"; state = LangEditor.ToolState.None; if (async) { if (isDone) { isDone = false; if (onRepaint != null) { onRepaint(); } thread = new Thread(ThreadDownload); thread.Start(); } } else { state = LangEditor.ToolState.None; WWW www = new WWW(odsURL); state = LangEditor.ToolState.Downloading; while (!www.isDone) { } ; if (!string.IsNullOrEmpty(www.error)) { state = LangEditor.ToolState.Error; } else { state = LangEditor.ToolState.Downloaded; if (ByteArrayToFile(threadOdsFileName, www.bytes)) { Debug.Log("Saved ods : " + threadOdsFileName); state = LangEditor.ToolState.ODSSaved; ODSToDictionary(threadOdsFileName); state = LangEditor.ToolState.TXTSaved; } else { Debug.LogError("LIKELY SHARING VIOLATION ON THE FILE : " + threadOdsFileName); } } if (onRepaint != null) { onRepaint(); } } }
public Form1() { InitializeComponent(); this.Figures = new List <Figure>(); this.Figures.Add(new Square(50, 50, 50, 50)); this.Figures.Add(new Ellipsis(100, 50, 50, 50)); mouseState = new MouseState(); mouseState.Changed += mouseState_Changed; toolState = ToolState.Rectangle; handleToolChange(); }
public override bool Details(ref Vector3 value, ToolState tool) { var pitch = (float)Math.Asin(-value.Y); var yaw = (float)Math.Atan2(value.X, value.Z); var changed = DetailsRow("Yaw", ref yaw); changed |= DetailsRow("Pitch", ref pitch); var rotation = Matrix.CreateFromYawPitchRoll(yaw, pitch, 0.0f); value = -Vector3.TransformNormal(Vector3.Forward, rotation); return(changed); }
public bool OnRaycastHitchanged(Input input, QbMatrix matrix, RaycastHit hit, ref Colort color, MouseButtonEventArgs e) { lastmatrix = matrix; switch (state) { case ToolState.Start: if ((e != null && e.IsPressed && e.Button == MouseButton.Left) || (e == null && input.mousedown(MouseButton.Left))) { state = ToolState.Base; Singleton<Raycaster>.INSTANCE.testdirt = true; startPosition = new VoxelLocation(hit, false); endPosition = new VoxelLocation(hit, false); volume = new VoxelVolume(startPosition, endPosition); modifiedVoxels.Clear(); EnumerateVolume(volume, lastvolume, matrix, ref color, modifiedVoxels); lastvolume = volume; return true; } break; case ToolState.Base: if ((e != null && e.IsPressed && e.Button == MouseButton.Left) || (e == null && input.mousedown(MouseButton.Left))) { endPosition = new VoxelLocation(hit, false); volume = new VoxelVolume(startPosition, endPosition); EnumerateVolume(volume, lastvolume, matrix, ref color, modifiedVoxels); CleanLastVolume(lastvolume, volume, matrix, modifiedVoxels); lastvolume = volume; return true; } else if ((e != null && !e.IsPressed && e.Button == MouseButton.Left) || (e == null && input.mouseup(MouseButton.Left))) { state = ToolState.Start; lastvolume = VoxelVolume.NEGATIVE_ZERO; Singleton<UndoRedo>.INSTANCE.AddUndo(BrushType, matrix, volume, color, modifiedVoxels); return true; } break; case ToolState.Limit: break; } return false; }
/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); var editor = _serviceProvider.GetService<ProjectEditor>(); switch (_currentState) { case ToolState.None: { editor.Dehover(editor.Project.CurrentContainer.CurrentLayer); if (editor.Renderers[0].State.SelectedShape == null && editor.Renderers[0].State.SelectedShapes != null) { var result = ShapeHitTestPoint.HitTest(editor.Project.CurrentContainer.CurrentLayer.Shapes, new Vector2(x, y), editor.Project.Options.HitThreshold); if (result != null) { _startX = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, editor.Project.Options.SnapX) : x; _startY = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, editor.Project.Options.SnapY) : y; _historyX = _startX; _historyY = _startY; GenerateMoveSelectionCache(); _currentState = ToolState.One; editor.CancelAvailable = true; break; } } if (editor.TryToSelectShape(editor.Project.CurrentContainer.CurrentLayer, x, y)) { _startX = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, editor.Project.Options.SnapX) : x; _startY = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, editor.Project.Options.SnapY) : y; _historyX = _startX; _historyY = _startY; GenerateMoveSelectionCache(); _currentState = ToolState.One; editor.CancelAvailable = true; break; } _rectangle = XRectangle.Create( x, y, editor.Project.Options.SelectionStyle, null, true, true); editor.Project.CurrentContainer.WorkingLayer.Shapes = editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_rectangle); editor.Project.CurrentContainer.WorkingLayer.Invalidate(); _currentState = ToolState.One; editor.CancelAvailable = true; } break; case ToolState.One: { if (_rectangle != null) { _rectangle.BottomRight.X = x; _rectangle.BottomRight.Y = y; editor.Project.CurrentContainer.WorkingLayer.Shapes = editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_rectangle); editor.Project.CurrentContainer.WorkingLayer.Invalidate(); _currentState = ToolState.None; editor.CancelAvailable = false; } } break; } }
/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); var editor = _serviceProvider.GetService<ProjectEditor>(); double sx = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, editor.Project.Options.SnapX) : x; double sy = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, editor.Project.Options.SnapY) : y; switch (_currentState) { case ToolState.None: { var style = editor.Project.CurrentStyleLibrary.Selected; _connectedPoint3 = false; _connectedPoint4 = false; _arc = XArc.Create( sx, sy, editor.Project.Options.CloneStyle ? style.Clone() : style, editor.Project.Options.PointShape, editor.Project.Options.DefaultIsStroked, editor.Project.Options.DefaultIsFilled); var result = editor.TryToGetConnectionPoint(sx, sy); if (result != null) { _arc.Point1 = result; } editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateOne(); Move(_arc); _currentState = ToolState.One; editor.CancelAvailable = true; } break; case ToolState.One: { if (_arc != null) { _arc.Point2.X = sx; _arc.Point2.Y = sy; _arc.Point3.X = sx; _arc.Point3.Y = sy; var result = editor.TryToGetConnectionPoint(sx, sy); if (result != null) { _arc.Point2 = result; } editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateTwo(); Move(_arc); _currentState = ToolState.Two; } } break; case ToolState.Two: { if (_arc != null) { _arc.Point3.X = sx; _arc.Point3.Y = sy; _arc.Point4.X = sx; _arc.Point4.Y = sy; var result = editor.TryToGetConnectionPoint(sx, sy); if (result != null) { _arc.Point3 = result; _connectedPoint3 = true; } else { _connectedPoint3 = false; } editor.Project.CurrentContainer.WorkingLayer.Shapes = editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_arc); editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateThree(); Move(_arc); _currentState = ToolState.Three; } } break; case ToolState.Three: { if (_arc != null) { _arc.Point4.X = sx; _arc.Point4.Y = sy; var result = editor.TryToGetConnectionPoint(sx, sy); if (result != null) { _arc.Point4 = result; _connectedPoint4 = true; } else { _connectedPoint4 = false; } editor.Project.CurrentContainer.WorkingLayer.Shapes = editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_arc); Remove(); Finalize(_arc); editor.Project.AddShape(editor.Project.CurrentContainer.CurrentLayer, _arc); _currentState = ToolState.None; editor.CancelAvailable = false; } } break; } }
/// <inheritdoc/> public override void RightDown(double x, double y) { base.RightDown(x, y); var editor = _serviceProvider.GetService<ProjectEditor>(); switch (_currentState) { case ToolState.None: break; case ToolState.One: case ToolState.Two: case ToolState.Three: { editor.Project.CurrentContainer.WorkingLayer.Shapes = editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_arc); editor.Project.CurrentContainer.WorkingLayer.Invalidate(); Remove(); _currentState = ToolState.None; editor.CancelAvailable = false; } break; } }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); EntityManager.Update(gameTime, currentGameState); switch (currentGameState) { case GameState.Ingame: break; case GameState.LevelEditing: Vector2 mousePosition = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); if (InputState.mouseLeftClick.Evaluate()) { if (tileButtonClickable.isWithinRectangle(mousePosition)) { foreach (DrawableComponent drawable in sceneryToolSprites) drawable.Visible = false; foreach (DrawableComponent drawable in tileToolSprites) drawable.Visible = true; foreach (DrawableComponent drawable in objectiveToolSprites) drawable.Visible = false; currentToolState = ToolState.Tile; tileButtonSprite.Color = Color.White; objectiveButtonSprite.Color = new Color(100, 100, 100); sceneryButtonSprite.Color = new Color(100, 100, 100); } if (sceneryButtonClickable.isWithinRectangle(mousePosition)) { foreach (DrawableComponent drawable in sceneryToolSprites) drawable.Visible = true; foreach (DrawableComponent drawable in tileToolSprites) drawable.Visible = false; foreach (DrawableComponent drawable in objectiveToolSprites) drawable.Visible = false; currentToolState = ToolState.Scenery; tileButtonSprite.Color = new Color(100, 100, 100); objectiveButtonSprite.Color = new Color(100, 100, 100); sceneryButtonSprite.Color = Color.White; } if (objectiveButtonClickable.isWithinRectangle(mousePosition)) { foreach (DrawableComponent drawable in sceneryToolSprites) drawable.Visible = false; foreach (DrawableComponent drawable in tileToolSprites) drawable.Visible = false; foreach (DrawableComponent drawable in objectiveToolSprites) drawable.Visible = true; currentToolState = ToolState.Objectives; tileButtonSprite.Color = new Color(100, 100, 100); objectiveButtonSprite.Color = Color.White; sceneryButtonSprite.Color = new Color(100, 100, 100); } switch (currentToolState) { case ToolState.Tile: if (floorRadioClickable.isWithinRectangle(mousePosition)) { currentTileType = TileType.Floor; floorRadioSprite.Color = Color.Yellow; windowRadioSprite.Color = Color.White; wallRadioSprite.Color = Color.White; wallPaperRadioSprite.Color = Color.White; placingTileSprite.setCurrentFrameX(2); } if (wallRadioClickable.isWithinRectangle(mousePosition)) { currentTileType = TileType.Wall; floorRadioSprite.Color = Color.White; windowRadioSprite.Color = Color.White; wallRadioSprite.Color = Color.Yellow; wallPaperRadioSprite.Color = Color.White; placingTileSprite.setCurrentFrameX(1); } if (wallPaperRadioClickable.isWithinRectangle(mousePosition)) { currentTileType = TileType.Wallpaper; floorRadioSprite.Color = Color.White; windowRadioSprite.Color = Color.White; wallRadioSprite.Color = Color.White; wallPaperRadioSprite.Color = Color.Yellow; placingTileSprite.setCurrentFrameX(4); } if (windowRadioClickable.isWithinRectangle(mousePosition)) { currentTileType = TileType.Glass; floorRadioSprite.Color = Color.White; windowRadioSprite.Color = Color.Yellow; wallRadioSprite.Color = Color.White; wallPaperRadioSprite.Color = Color.White; placingTileSprite.setCurrentFrameX(3); } if (!toolbarClickable.isWithinRectangle(mousePosition)) { Entity tile = new Entity(tileLayer, GameState.LevelEditing); SpriteSheetComponent tileSprite = new SpriteSheetComponent(new Rectangle((int)placingTileSprite.Destination.X, (int)placingTileSprite.Destination.Y, 50, 50), tileSpriteSheet); tile.AddComponent(tileSprite); switch (currentTileType) { case TileType.Floor: tileSprite.setCurrentFrameX(2); break; case TileType.Wall: tileSprite.setCurrentFrameX(1); break; case TileType.Grass: tileSprite.setCurrentFrameX(0); break; case TileType.Wallpaper: tileSprite.setCurrentFrameX(4); break; case TileType.Glass: tileSprite.setCurrentFrameX(3); break; } TileComponent tileTile = new TileComponent(currentTileType); tile.AddComponent(tileTile); tiles.Add(tile); EntityManager.AddEntity(tile); } break; case ToolState.Scenery: if (upLayerClickable.isWithinRectangle(mousePosition)) { if (currentLayer < maxEditableLayer - 1) { currentLayer++; layerNumberText.Text = "Layer: " + currentLayer.ToString(); UpdateLayerColor(); } } else if (downLayerClickable.isWithinRectangle(mousePosition)) { if (currentLayer > 0) { currentLayer--; layerNumberText.Text = "Layer: " + currentLayer.ToString(); UpdateLayerColor(); } } else if (upSceneryClickable.isWithinRectangle(mousePosition)) { if (currentSceneryOption < sceneryOptions.Count - 1) { currentSceneryOption++; sceneryPreviewSprite.Texture = sceneryOptions[currentSceneryOption]; placingScenerySprite.Texture = sceneryOptions[currentSceneryOption]; placingScenerySprite.SpriteWidth = sceneryOptions[currentSceneryOption].Width; placingScenerySprite.SpriteHeight = sceneryOptions[currentSceneryOption].Height; } } else if (downSceneryClickable.isWithinRectangle(mousePosition)) { if (currentSceneryOption > 0) { currentSceneryOption--; sceneryPreviewSprite.Texture = sceneryOptions[currentSceneryOption]; placingScenerySprite.Texture = sceneryOptions[currentSceneryOption]; placingScenerySprite.SpriteWidth = sceneryOptions[currentSceneryOption].Width; placingScenerySprite.SpriteHeight = sceneryOptions[currentSceneryOption].Height; } } else if (!toolbarClickable.isWithinRectangle(mousePosition)) { //We arent clicking wihtin the toolbar Entity scenery = new Entity(currentLayer, GameState.LevelEditing); SpriteComponent scenerySprite = new SpriteComponent(new Rectangle( (int)mousePosition.X + (int)Camera.Pos.X, (int)mousePosition.Y + (int)Camera.Pos.Y, sceneryOptions[currentSceneryOption].Width, sceneryOptions[currentSceneryOption].Height), sceneryOptions[currentSceneryOption]); scenery.AddComponent(scenerySprite); layersOfScenery[currentLayer].Add(scenerySprite); EntityManager.AddEntity(scenery); UpdateLayerColor(); } break; case ToolState.Objectives: if (playerSpawnRadioClickable.isWithinRectangle(mousePosition)) { visitorSpawnRadioSprite.Color = Color.White; playerSpawnRadioSprite.Color = Color.Yellow; objectiveToolState = ObjectiveToolState.PlayerSpawn; } else if (visitorSpawnRadioClickable.isWithinRectangle(mousePosition)) { objectiveToolState = ObjectiveToolState.VisitorSpawn; visitorSpawnRadioSprite.Color = Color.Yellow; playerSpawnRadioSprite.Color = Color.White; } else if (!toolbarClickable.isWithinRectangle(mousePosition)) { //If you are not pressing the toolbar if (objectiveToolState == ObjectiveToolState.PlayerSpawn) { playerSpawnText.Destination = new Vector2(mousePosition.X + Camera.Pos.X, mousePosition.Y + Camera.Pos.Y); } else if (objectiveToolState == ObjectiveToolState.VisitorSpawn) { visitorSpawnText.Destination = new Vector2(mousePosition.X + Camera.Pos.X, mousePosition.Y + Camera.Pos.Y); } } break; default: break; } } if (InputState.upHold.Evaluate() && InputState.downHold.Evaluate()) { } if (InputState.leftHold.Evaluate() && InputState.rightHold.Evaluate()) { } if (InputState.upClick.Evaluate()) { Camera.Move(new Vector2(0, -10)); } if (InputState.rightClick.Evaluate()) { Camera.Move(new Vector2(10, 0)); } if (InputState.downClick.Evaluate()) { Camera.Move(new Vector2(0, 10)); } if (InputState.leftClick.Evaluate()) { Camera.Move(new Vector2(-10, 0)); } //Moving the current selection switch (currentToolState) { case ToolState.Tile: placingTileSprite.Destination = new Vector2((mousePosition.X + Camera.Pos.X) - ((mousePosition.X + Camera.Pos.X) % 50f), (mousePosition.Y + Camera.Pos.Y) - ((mousePosition.Y + Camera.Pos.Y) % 50)); break; case ToolState.Scenery: placingScenerySprite.Destination = new Vector2(mousePosition.X + Camera.Pos.X, mousePosition.Y + Camera.Pos.Y); break; case ToolState.Objectives: break; } break; } base.Update(gameTime); }
public void Download(bool async, Action onRepaint){ threadOdsURL = odsURL; threadOdsFileName = dataPath + "/Resources Localization/" + odsFileName + ".ods"; state = LangEditor.ToolState.None; if(async){ if(isDone){ isDone = false; if(onRepaint != null) onRepaint(); thread = new Thread(ThreadDownload); thread.Start(); } } else { state = LangEditor.ToolState.None; WWW www = new WWW(odsURL); state = LangEditor.ToolState.Downloading; while(!www.isDone){}; if(!string.IsNullOrEmpty(www.error)){ state = LangEditor.ToolState.Error; } else { state = LangEditor.ToolState.Downloaded; if(ByteArrayToFile(threadOdsFileName, www.bytes)){ Debug.Log("Saved ods : " + threadOdsFileName); state = LangEditor.ToolState.ODSSaved; ODSToDictionary(threadOdsFileName); state = LangEditor.ToolState.TXTSaved; } else { Debug.LogError("LIKELY SHARING VIOLATION ON THE FILE : " + threadOdsFileName); } } if(onRepaint != null) onRepaint(); } }
public void ThreadDownload(){ try{ WebRequest request = WebRequest.Create (threadOdsURL); request.Credentials = CredentialCache.DefaultCredentials; WebResponse response = request.GetResponse (); if(((HttpWebResponse)response).StatusCode == HttpStatusCode.OK) state = LangEditor.ToolState.Downloaded; else { state = LangEditor.ToolState.Error; Debug.LogError(((HttpWebResponse)response).StatusDescription); } byte[] b; using(Stream s = response.GetResponseStream ()){; b = ReadFully(s); } response.Close (); if(state == ToolState.Downloaded){ if(ByteArrayToFile(threadOdsFileName, b)){ Debug.Log("Saved ods : " + threadOdsFileName); state = LangEditor.ToolState.ODSSaved; ODSToDictionary(threadOdsFileName); state = LangEditor.ToolState.TXTSaved; } else { Debug.LogError("LIKELY SHARING VIOLATION ON THE FILE : " + threadOdsFileName); } } } catch ( Exception e ){ state = LangEditor.ToolState.Error; Debug.Log(e.Message); } finally { isDone = true; } }
/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); var editor = _serviceProvider.GetService<ProjectEditor>(); var pathTool = _serviceProvider.GetService<ToolPath>(); double sx = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, editor.Project.Options.SnapX) : x; double sy = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, editor.Project.Options.SnapY) : y; switch (_currentState) { case ToolState.None: { _cubicBezier.Point1 = editor.TryToGetConnectionPoint(sx, sy) ?? XPoint.Create(sx, sy, editor.Project.Options.PointShape); if (!pathTool.IsInitialized) { pathTool.InitializeWorkingPath(_cubicBezier.Point1); } else { _cubicBezier.Point1 = pathTool.GetLastPathPoint(); } _cubicBezier.Point2 = XPoint.Create(sx, sy, editor.Project.Options.PointShape); _cubicBezier.Point3 = XPoint.Create(sx, sy, editor.Project.Options.PointShape); _cubicBezier.Point4 = XPoint.Create(sx, sy, editor.Project.Options.PointShape); pathTool.GeometryContext.CubicBezierTo( _cubicBezier.Point2, _cubicBezier.Point3, _cubicBezier.Point4, editor.Project.Options.DefaultIsStroked, editor.Project.Options.DefaultIsSmoothJoin); editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateOne(); Move(null); _currentState = ToolState.One; editor.CancelAvailable = true; } break; case ToolState.One: { _cubicBezier.Point4.X = sx; _cubicBezier.Point4.Y = sy; if (editor.Project.Options.TryToConnect) { var point3 = editor.TryToGetConnectionPoint(sx, sy); if (point3 != null) { var figure = pathTool.Geometry.Figures.LastOrDefault(); var cubicBezier = figure.Segments.LastOrDefault() as XCubicBezierSegment; cubicBezier.Point3 = point3; _cubicBezier.Point4 = point3; } } editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateTwo(); Move(null); _currentState = ToolState.Two; } break; case ToolState.Two: { _cubicBezier.Point2.X = sx; _cubicBezier.Point2.Y = sy; if (editor.Project.Options.TryToConnect) { var point1 = editor.TryToGetConnectionPoint(sx, sy); if (point1 != null) { var figure = pathTool.Geometry.Figures.LastOrDefault(); var cubicBezier = figure.Segments.LastOrDefault() as XCubicBezierSegment; cubicBezier.Point1 = point1; _cubicBezier.Point2 = point1; } } editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateThree(); Move(null); _currentState = ToolState.Three; } break; case ToolState.Three: { _cubicBezier.Point3.X = sx; _cubicBezier.Point3.Y = sy; if (editor.Project.Options.TryToConnect) { var point2 = editor.TryToGetConnectionPoint(sx, sy); if (point2 != null) { var figure = pathTool.Geometry.Figures.LastOrDefault(); var cubicBezier = figure.Segments.LastOrDefault() as XCubicBezierSegment; cubicBezier.Point2 = point2; _cubicBezier.Point3 = point2; } } _cubicBezier.Point1 = _cubicBezier.Point4; _cubicBezier.Point2 = XPoint.Create(sx, sy, editor.Project.Options.PointShape); _cubicBezier.Point3 = XPoint.Create(sx, sy, editor.Project.Options.PointShape); _cubicBezier.Point4 = XPoint.Create(sx, sy, editor.Project.Options.PointShape); pathTool.GeometryContext.CubicBezierTo( _cubicBezier.Point2, _cubicBezier.Point3, _cubicBezier.Point4, editor.Project.Options.DefaultIsStroked, editor.Project.Options.DefaultIsSmoothJoin); editor.Project.CurrentContainer.WorkingLayer.Invalidate(); Remove(); ToStateOne(); Move(null); _currentState = ToolState.One; } break; } }
/// <inheritdoc/> public override async void LeftDown(double x, double y) { base.LeftDown(x, y); var editor = _serviceProvider.GetService<ProjectEditor>(); double sx = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, editor.Project.Options.SnapX) : x; double sy = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, editor.Project.Options.SnapY) : y; switch (_currentState) { case ToolState.None: { if (editor.ImageImporter == null) return; var key = await editor.ImageImporter.GetImageKeyAsync(); if (key == null || string.IsNullOrEmpty(key)) return; var style = editor.Project.CurrentStyleLibrary.Selected; _image = XImage.Create( sx, sy, editor.Project.Options.CloneStyle ? style.Clone() : style, editor.Project.Options.PointShape, key); var result = editor.TryToGetConnectionPoint(sx, sy); if (result != null) { _image.TopLeft = result; } editor.Project.CurrentContainer.WorkingLayer.Shapes = editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_image); editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateOne(); Move(_image); _currentState = ToolState.One; editor.CancelAvailable = true; } break; case ToolState.One: { if (_image != null) { _image.BottomRight.X = sx; _image.BottomRight.Y = sy; var result = editor.TryToGetConnectionPoint(sx, sy); if (result != null) { _image.BottomRight = result; } editor.Project.CurrentContainer.WorkingLayer.Shapes = editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_image); Remove(); base.Finalize(_image); editor.Project.AddShape(editor.Project.CurrentContainer.CurrentLayer, _image); _currentState = ToolState.None; editor.CancelAvailable = false; } } break; } }
protected override void StartPointerSequenceCore(PointerEventInfo info, ILevelGeometry viewport) { _state = _state.StartPointerSequence(info, viewport); /*switch (info.Type) { case PointerEventType.Primary: StartSelectObjectSequence(info, viewport); break; case PointerEventType.Secondary: _selectionManager.ClearSelection(); if (_rotationAnnot != null) { _annots.Remove(_rotationAnnot); _rotationAnnot = null; } UpdatePropertyProvider(); break; }*/ UpdatePointerSequence(info, viewport); }
protected override void DisposeManaged() { _state = _state.Cancel(); base.DisposeManaged(); }
/// <inheritdoc/> public override void LeftUp(double x, double y) { base.LeftUp(x, y); var editor = _serviceProvider.GetService<ProjectEditor>(); switch (_currentState) { case ToolState.None: break; case ToolState.One: { if (editor.IsSelectionAvailable()) { double sx = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, editor.Project.Options.SnapX) : x; double sy = editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, editor.Project.Options.SnapY) : y; if (_historyX != sx || _historyY != sy) { double dx = sx - _historyX; double dy = sy - _historyY; var previous = new { DeltaX = -dx, DeltaY = -dy, Points = _pointsCache, Shapes = _shapesCache }; var next = new { DeltaX = dx, DeltaY = dy, Points = _pointsCache, Shapes = _shapesCache }; editor.Project?.History?.Snapshot(previous, next, (state) => { if (state.Points != null) { ProjectEditor.MoveShapesBy(state.Points, state.DeltaX, state.DeltaY); } if (state.Shapes != null) { ProjectEditor.MoveShapesBy(state.Shapes, state.DeltaX, state.DeltaY); } }); } DisposeMoveSelectionCache(); _currentState = ToolState.None; editor.CancelAvailable = false; break; } if (_rectangle != null) { _rectangle.BottomRight.X = x; _rectangle.BottomRight.Y = y; editor.Project.CurrentContainer.WorkingLayer.Shapes = editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_rectangle); editor.Project.CurrentContainer.WorkingLayer.Invalidate(); _currentState = ToolState.None; editor.TryToSelectShapes(editor.Project.CurrentContainer.CurrentLayer, _rectangle); editor.CancelAvailable = false; } } break; } }
/// <inheritdoc/> public override void RightDown(double x, double y) { base.RightDown(x, y); var editor = _serviceProvider.GetService<ProjectEditor>(); var pathTool = _serviceProvider.GetService<ToolPath>(); switch (_currentState) { case ToolState.None: break; case ToolState.One: { pathTool.RemoveLastSegment<XLineSegment>(); editor.Project.CurrentContainer.WorkingLayer.Shapes = editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(pathTool.Path); Remove(); if (pathTool.Path.Geometry.Figures.LastOrDefault().Segments.Length > 0) { Finalize(null); editor.Project.AddShape(editor.Project.CurrentContainer.CurrentLayer, pathTool.Path); } else { editor.Project.CurrentContainer.WorkingLayer.Invalidate(); } pathTool.DeInitializeWorkingPath(); _currentState = ToolState.None; editor.CancelAvailable = false; } break; } }