/// <summary> /// Create a robot command from a MoveTool command. Adjusts for robot specific /// max speeds. May return null if there is no effective move. /// </summary> /// <param name="m"></param> /// <returns></returns> private IRobotCommand CreateRobotCommand(MoveTool m, ICommandGenerator c) { var p = m.Target; p.Z += z_offset; float inches_per_minute = m.Speed == MoveTool.SpeedType.Cutting ? MaxCutSpeed : MaxRapidSpeed; Vector3 delta = lastPosition - p; lastPosition = p; if (delta.Length > 0) { if (Math.Abs(delta.Z) > 0.0001f) { inches_per_minute = Math.Min(MaxZSpeed, inches_per_minute); } return(c.GenerateMoveCommand(p, inches_per_minute / 60.0f)); } else { Console.WriteLine("Ignoring command with length of 0"); return(null); } }
public List <IdPath> Paste(string str) { if (currentSketch == null || currentSketch.GetSketch() == null) { return(null); } var xml = new XmlDocument(); xml.LoadXml(str); if (xml.DocumentElement.Attributes["program"] == null || xml.DocumentElement.Attributes["program"].Value != "NoteCAD") { return(null); } var pos = xml.DocumentElement.Attributes["pos"].Value.ToVector3(); var delta = Tool.MousePos - pos; var sk = currentSketch.GetSketch(); sk.Read(xml.DocumentElement, true); var result = sk.idMapping; sk.idMapping = null; var objs = result.Select(o => sk.GetChild(o.Value)).ToList(); MoveTool.ShiftObjects(objs, delta); return(objs.Select(o => o.id).ToList()); }
public void DefaultMapControlTools() { InitializeControls(); // check for all default tools IMapTool mapTool = mapControl.SelectTool; Assert.IsNotNull(mapTool); SelectTool selectTool = mapTool as SelectTool; Assert.IsNotNull(selectTool); mapTool = mapControl.MoveTool; Assert.IsNotNull(mapTool); MoveTool moveTool = mapTool as MoveTool; Assert.IsNotNull(moveTool); Assert.AreEqual(FallOffPolicyRule.None, moveTool.FallOffPolicy); mapTool = mapControl.GetToolByName("CurvePoint"); Assert.IsNotNull(mapTool); CurvePointTool curvePointTool = mapTool as CurvePointTool; Assert.IsNotNull(curvePointTool); }
public MainWindow() : base( 1280, 720, new GraphicsMode(new ColorFormat(24), 0, 0, 0, ColorFormat.Empty), "Line Rider: Advanced", GameWindowFlags.Default, DisplayDevice.Default, 2, 0, GraphicsContextFlags.Default) { SafeFrameBuffer.Initialize(); PencilTool = new PencilTool(); LineTool = new LineTool(); EraserTool = new EraserTool(); HandTool = new HandTool(); MoveTool = new MoveTool(); SelectedTool = PencilTool; Track = new Editor(); VSync = VSyncMode.On; Context.ErrorChecking = false; WindowBorder = WindowBorder.Resizable; RenderFrame += (o, e) => { Render(); }; UpdateFrame += (o, e) => { GameUpdate(); }; GameService.Initialize(this); RegisterHotkeys(); }
private void zGo_Click(object sender, EventArgs e) { float f = float.Parse(zbox.Text); MoveTool move = new MoveTool(new Vector3(0, 0, f), MoveTool.SpeedType.Rapid); robot.AddCommand(move); }
public MoveToolProperties(MoveTool tool) { InitializeComponent(); Tool = tool; Tool.Invalidated += Tool_Invalidated; Tool_Invalidated(Tool, null); }
public void UpdateMove(ScreenTransformGesture gesture) { var debugController = ApplicationController.Instance.DebugController; debugController.DrawDebugPoint(string.Format("{0} ScreenPos", GetInstanceID()), gesture.ScreenPosition, Color.cyan); MoveTool.UpdateMove(gesture.ScreenPosition - _startDragPosition); }
public void StopMove(ScreenTransformGesture gesture) { MoveTool.StopMove(gesture.ScreenPosition - _startDragPosition); var debugController = ApplicationController.Instance.DebugController; debugController.DeleteDebugPoint(string.Format("{0} ScreenPos", GetInstanceID())); }
private void Awake() { Instance = this; if (GridCellPrefab == null) { Debug.LogFormat("{0} | No GridCellPrefab assigned!", this); return; } _rectTransform = GetComponent <RectTransform>(); _gridLayoutGroup = GetComponent <GridLayoutGroup>(); InitializeGrid(); // Init editor tools MoveTool.Init(this); RotateTool.Init(this); }
public Drawer() { Properties = new Dictionary <string, ConfigValue>(); Brushes = new Dictionary <string, IBrush>(); this["MoveTool"] = new MoveTool(); this["Straw"] = new Straw(); this["Eraser"] = new Eraser(); this["Pencil"] = new Pencil(); Brush = this["MoveTool"]; LayerList = new List <IPaint> { new Canvas { Name = "LastLayer" }, new Canvas { Name = "CurrentLayer" } }; CurrentLayer.Visible = true; }
static ToolManager() { MoveTool = new MoveTool(); SelectTool = new SelectTool(); ScaleTool = new ScaleTool(); RotateTool = new RotateTool(); SelectionService.Service.SelectionChanged.Event += () => { ContextActionService.SetState("selectionEmpty", SelectionService.SelectionCount == 0); }; ContextActionService.Register("tools.selectTool", () => SelectTool.IsEquipped = true); ContextActionService.Register("tools.moveTool", () => MoveTool.IsEquipped = true); ContextActionService.Register("tools.scaleTool", () => ScaleTool.IsEquipped = true); ContextActionService.Register("tools.rotateTool", () => RotateTool.IsEquipped = true); ContextActionService.Register("pickerInsideModels", PickerInsideModels); ContextActionService.Register("groupSelection", GroupSelection); ContextActionService.Register("ungroupSelection", UngroupSelection); }
void IOpenGLDrawable.Draw() { try { var commands = base.GetCommands(); // Draw cut paths GL.Disable(EnableCap.Lighting); GL.Color3(Color.Blue); GL.Begin(PrimitiveType.LineStrip); for (int i = 0; i < commands.Count(); i++) { if (commands[i] is MoveTool) { MoveTool m = commands[i] as MoveTool; Vector3 finalPosition = m.Target; GL.Vertex3(finalPosition); } } GL.End(); GL.PointSize(2); GL.Color3(Color.Red); GL.Begin(PrimitiveType.Points); for (int i = 0; i < commands.Count(); i++) { if (commands[i] is MoveTool) { MoveTool m = commands[i] as MoveTool; Vector3 finalPosition = m.Target; GL.Vertex3(finalPosition); } } GL.End(); GL.PointSize(1); GL.Enable(EnableCap.Lighting); } catch (Exception) { } }
private bool PerformActionImpl() { PointInt32 num2; RectInt32 num3; if (this.clipData == null) { try { using (new WaitCursorChanger(this.documentWorkspace)) { CleanupManager.RequestCleanup(); this.clipData = PdnClipboard.GetDataObject(); } } catch (OutOfMemoryException exception) { ExceptionDialog.ShowErrorDialog(this.documentWorkspace, PdnResources.GetString("PasteAction.Error.OutOfMemory"), exception); return(false); } catch (Exception exception2) { ExceptionDialog.ShowErrorDialog(this.documentWorkspace, PdnResources.GetString("PasteAction.Error.TransferFromClipboard"), exception2); return(false); } } bool handled = false; if (this.documentWorkspace.Tool != null) { this.documentWorkspace.Tool.PerformPaste(this.clipData, out handled); } if (handled) { return(true); } if (this.maskedSurface == null) { try { using (new WaitCursorChanger(this.documentWorkspace)) { this.maskedSurface = ClipboardUtil.GetClipboardImage(this.documentWorkspace, this.clipData); } } catch (OutOfMemoryException exception3) { ExceptionDialog.ShowErrorDialog(this.documentWorkspace, PdnResources.GetString("PasteAction.Error.OutOfMemory"), exception3); return(false); } catch (Exception exception4) { ExceptionDialog.ShowErrorDialog(this.documentWorkspace, PdnResources.GetString("PasteAction.Error.TransferFromClipboard"), exception4); return(false); } } if (this.maskedSurface == null) { MessageBoxUtil.ErrorBox(this.documentWorkspace, PdnResources.GetString("PasteAction.Error.NoImage")); return(false); } RectInt32 cachedGeometryMaskScansBounds = this.maskedSurface.GetCachedGeometryMaskScansBounds(); if ((cachedGeometryMaskScansBounds.Width > this.documentWorkspace.Document.Width) || (cachedGeometryMaskScansBounds.Height > this.documentWorkspace.Document.Height)) { Surface surface; try { using (new WaitCursorChanger(this.documentWorkspace)) { surface = CreateThumbnail(this.maskedSurface); } } catch (OutOfMemoryException) { surface = null; } DialogResult result = ShowExpandCanvasTaskDialog(this.documentWorkspace, surface); int activeLayerIndex = this.documentWorkspace.ActiveLayerIndex; ColorBgra background = this.documentWorkspace.ToolSettings.SecondaryColor.Value; if (result != DialogResult.Cancel) { if (result != DialogResult.Yes) { if (result != DialogResult.No) { throw ExceptionUtil.InvalidEnumArgumentException <DialogResult>(result, "dr"); } goto Label_031D; } using (new PushNullToolMode(this.documentWorkspace)) { int width = Math.Max(cachedGeometryMaskScansBounds.Width, this.documentWorkspace.Document.Width); Size newSize = new Size(width, Math.Max(cachedGeometryMaskScansBounds.Height, this.documentWorkspace.Document.Height)); Document document = CanvasSizeAction.ResizeDocument(this.documentWorkspace.Document, newSize, AnchorEdge.TopLeft, background); if (document == null) { return(false); } SelectionHistoryMemento memento = new SelectionHistoryMemento(null, null, this.documentWorkspace); ReplaceDocumentHistoryMemento memento2 = new ReplaceDocumentHistoryMemento(CanvasSizeAction.StaticName, CanvasSizeAction.StaticImage, this.documentWorkspace); this.documentWorkspace.Document = document; HistoryMemento[] actions = new HistoryMemento[] { memento, memento2 }; CompoundHistoryMemento memento3 = new CompoundHistoryMemento(CanvasSizeAction.StaticName, CanvasSizeAction.StaticImage, actions); this.documentWorkspace.History.PushNewMemento(memento3); this.documentWorkspace.ActiveLayer = (Layer)this.documentWorkspace.Document.Layers[activeLayerIndex]; goto Label_031D; } } return(false); } Label_031D: num3 = this.documentWorkspace.Document.Bounds(); RectDouble visibleDocumentRect = this.documentWorkspace.VisibleDocumentRect; RectInt32? nullable = visibleDocumentRect.Int32Inset(); RectDouble num5 = nullable.HasValue ? ((RectDouble)nullable.Value) : visibleDocumentRect; RectInt32 num6 = num5.Int32Bound; if (num5.Contains(cachedGeometryMaskScansBounds)) { num2 = new PointInt32(0, 0); } else { int num12; int num13; int num16; int num17; if (cachedGeometryMaskScansBounds.X < num5.Left) { num12 = -cachedGeometryMaskScansBounds.X + num6.X; } else if (cachedGeometryMaskScansBounds.Right > num6.Right) { num12 = (-cachedGeometryMaskScansBounds.X + num6.Right) - cachedGeometryMaskScansBounds.Width; } else { num12 = 0; } if (cachedGeometryMaskScansBounds.Y < num5.Top) { num13 = -cachedGeometryMaskScansBounds.Y + num6.Y; } else if (cachedGeometryMaskScansBounds.Bottom > num6.Bottom) { num13 = (-cachedGeometryMaskScansBounds.Y + num6.Bottom) - cachedGeometryMaskScansBounds.Height; } else { num13 = 0; } PointInt32 num14 = new PointInt32(num12, num13); RectInt32 num15 = new RectInt32(cachedGeometryMaskScansBounds.X + num14.X, cachedGeometryMaskScansBounds.Y + num14.Y, cachedGeometryMaskScansBounds.Width, cachedGeometryMaskScansBounds.Height); if (num15.X < 0) { num16 = num12 - num15.X; } else { num16 = num12; } if (num15.Y < 0) { num17 = num13 - num15.Y; } else { num17 = num13; } PointInt32 num18 = new PointInt32(num16, num17); RectInt32 rect = new RectInt32(cachedGeometryMaskScansBounds.X + num18.X, cachedGeometryMaskScansBounds.Y + num18.Y, cachedGeometryMaskScansBounds.Width, cachedGeometryMaskScansBounds.Height); if (num3.Contains(rect)) { num2 = num18; } else { PointInt32 num20 = num18; if (rect.Right > num3.Right) { int num21 = rect.Right - num3.Right; int num22 = Math.Min(num21, rect.Left); num20.X -= num22; } if (rect.Bottom > num3.Bottom) { int num23 = rect.Bottom - num3.Bottom; int num24 = Math.Min(num23, rect.Top); num20.Y -= num24; } num2 = num20; } } RectInt32 b = this.documentWorkspace.VisibleDocumentRect.Int32Bound; RectInt32 a = new RectInt32(cachedGeometryMaskScansBounds.X + num2.X, cachedGeometryMaskScansBounds.Y + num2.Y, cachedGeometryMaskScansBounds.Width, cachedGeometryMaskScansBounds.Height); bool hasZeroArea = RectInt32.Intersect(a, b).HasZeroArea; MoveTool.BeginPaste(this.documentWorkspace, PdnResources.GetString("CommonAction.Paste"), PdnResources.GetImageResource("Icons.MenuEditPasteIcon.png"), this.maskedSurface.SurfaceReadOnly, this.maskedSurface.GeometryMask, num2); if (hasZeroArea) { PointInt32 num25 = new PointInt32(b.Left + (b.Width / 2), b.Top + (b.Height / 2)); PointInt32 num26 = new PointInt32(a.Left + (a.Width / 2), a.Top + (a.Height / 2)); SizeInt32 num27 = new SizeInt32(num26.X - num25.X, num26.Y - num25.Y); PointDouble documentScrollPosition = this.documentWorkspace.DocumentScrollPosition; PointDouble num29 = new PointDouble(documentScrollPosition.X + num27.Width, documentScrollPosition.Y + num27.Height); this.documentWorkspace.DocumentScrollPosition = num29; } return(true); }
void Awake() { instance = this; Global.moveTool = this; }
//bool canMove = true; protected override void OnStart() { input.onEndEdit.AddListener(OnEndEdit); instance = this; }
public void RoutPath(LineStrip line, bool backwards, Vector3 offset) { bool first = true; foreach (Vector3 point in line.Vertices) { // TODO: Pick some unit and stick with it! Inches would be fine. Vector3 pointOffset = point + offset; MoveTool m = new MoveTool(pointOffset, MoveTool.SpeedType.Cutting); if (first) { first = false; if ((finalPosition.Xy - pointOffset.Xy).Length > .0001) { // Need to move the router up, over to new position, then down again. MoveTool m1 = new MoveTool(new Vector3(finalPosition.X, finalPosition.Y, move_height), MoveTool.SpeedType.Rapid); MoveTool m2 = new MoveTool(new Vector3(m.Target.X, m.Target.Y, move_height), MoveTool.SpeedType.Rapid); AddCommand(m1); AddCommand(m2); } } AddCommand(m); } }
/// <summary> /// Initializes a new map /// </summary> public MapControl() { SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true); LostFocus += MapBox_LostFocus; base.AllowDrop = true; tools = new EventedList <IMapTool>(); tools.CollectionChanged += tools_CollectionChanged; // Visible = true, kalo ingin nampilin Arah Utara var northArrowTool = new NorthArrowTool(this) { Anchor = AnchorStyles.Right | AnchorStyles.Top, Visible = false }; Tools.Add(northArrowTool); var scaleBarTool = new ScaleBarTool(this) { Size = new Size(230, 50), Anchor = AnchorStyles.Right | AnchorStyles.Bottom, Visible = true }; Tools.Add(scaleBarTool); // Visible = true, utuk menampilkan legend Map //legendTool = new LegendTool(this) {Anchor = AnchorStyles.Left | AnchorStyles.Top, Visible = false}; //Tools.Add(legendTool); queryTool = new QueryTool(this); Tools.Add(queryTool); // add commonly used tools zoomHistoryTool = new ZoomHistoryTool(this); Tools.Add(zoomHistoryTool); panZoomTool = new PanZoomTool(this); Tools.Add(panZoomTool); wheelPanZoomTool = new PanZoomUsingMouseWheelTool(this) { WheelZoomMagnitude = 0.8 }; //-2}; Tools.Add(wheelPanZoomTool); rectangleZoomTool = new ZoomUsingRectangleTool(this); Tools.Add(rectangleZoomTool); fixedZoomInTool = new FixedZoomInTool(this); Tools.Add(fixedZoomInTool); fixedZoomOutTool = new FixedZoomOutTool(this); Tools.Add(fixedZoomOutTool); selectTool = new SelectTool { IsActive = true }; Tools.Add(selectTool); // Active = true, biar bisa move point... moveTool = new MoveTool { Name = "Move selected vertices", FallOffPolicy = FallOffPolicyRule.None, IsActive = true }; Tools.Add(moveTool); linearMoveTool = new MoveTool { Name = "Move selected vertices (linear)", FallOffPolicy = FallOffPolicyRule.Linear }; Tools.Add(linearMoveTool); deleteTool = new DeleteTool(); Tools.Add(deleteTool); measureTool = new MeasureTool(this); tools.Add(measureTool); profileTool = new CoverageProfileTool(this) { Name = "Make grid profile" }; tools.Add(profileTool); curvePointTool = new CurvePointTool(); Tools.Add(curvePointTool); drawPolygonTool = new DrawPolygonTool(); Tools.Add(drawPolygonTool); snapTool = new SnapTool(); Tools.Add(snapTool); var toolTipTool = new ToolTipTool(); Tools.Add(toolTipTool); MapTool fileHandlerTool = new FileDragHandlerTool(); Tools.Add(fileHandlerTool); Width = 100; Height = 100; mapPropertyChangedEventHandler = new DelayedEventHandler <PropertyChangedEventArgs>(map_PropertyChanged_Delayed) { SynchronizingObject = this, FireLastEventOnly = true, FullRefreshDelay = 300, Filter = (sender, e) => sender is ILayer || sender is VectorStyle || sender is ITheme, Enabled = false }; mapCollectionChangedEventHandler = new DelayedEventHandler <NotifyCollectionChangingEventArgs>(map_CollectionChanged_Delayed) { SynchronizingObject = this, FireLastEventOnly = true, FullRefreshDelay = 300, Filter = (sender, e) => sender is Map || sender is ILayer, Enabled = false }; Map = new Map(ClientSize) { Zoom = 100 }; }
//bool canMove = true; private void Start() { input.onEndEdit.AddListener(OnEndEdit); instance = this; }
/// <summary> /// Initializes a new map /// </summary> public MapControl() { SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true); LostFocus += MapBox_LostFocus; AllowDrop = true; tools = new EventedList <IMapTool>(); tools.CollectionChanged += tools_CollectionChanged; var northArrowTool = new NorthArrowTool(this); northArrowTool.Anchor = AnchorStyles.Right | AnchorStyles.Top; northArrowTool.Visible = false; // activate using commands Tools.Add(northArrowTool); var scaleBarTool = new ScaleBarTool(this); scaleBarTool.Size = new Size(230, 50); scaleBarTool.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; scaleBarTool.Visible = true; Tools.Add(scaleBarTool); legendTool = new LegendTool(this) { Anchor = AnchorStyles.Left | AnchorStyles.Top, Visible = false }; Tools.Add(legendTool); queryTool = new QueryTool(this); Tools.Add(queryTool); // add commonly used tools zoomHistoryTool = new ZoomHistoryTool(this); Tools.Add(zoomHistoryTool); panZoomTool = new PanZoomTool(this); Tools.Add(panZoomTool); wheelZoomTool = new ZoomUsingMouseWheelTool(this); wheelZoomTool.WheelZoomMagnitude = 0.8; Tools.Add(wheelZoomTool); rectangleZoomTool = new ZoomUsingRectangleTool(this); Tools.Add(rectangleZoomTool); fixedZoomInTool = new FixedZoomInTool(this); Tools.Add(fixedZoomInTool); fixedZoomOutTool = new FixedZoomOutTool(this); Tools.Add(fixedZoomOutTool); selectTool = new SelectTool { IsActive = true }; Tools.Add(selectTool); moveTool = new MoveTool(); moveTool.Name = "Move selected vertices"; moveTool.FallOffPolicy = FallOffPolicyRule.None; Tools.Add(moveTool); linearMoveTool = new MoveTool(); linearMoveTool.Name = "Move selected vertices (linear)"; linearMoveTool.FallOffPolicy = FallOffPolicyRule.Linear; Tools.Add(linearMoveTool); deleteTool = new DeleteTool(); Tools.Add(deleteTool); measureTool = new MeasureTool(this); tools.Add(measureTool); profileTool = new GridProfileTool(this); profileTool.Name = "Make grid profile"; tools.Add(profileTool); curvePointTool = new CurvePointTool(); Tools.Add(curvePointTool); snapTool = new SnapTool(); Tools.Add(snapTool); var toolTipTool = new ToolTipTool(); Tools.Add(toolTipTool); MapTool fileHandlerTool = new FileDragHandlerTool(); Tools.Add(fileHandlerTool); Tools.Add(new ExportMapToImageMapTool()); Width = 100; Height = 100; mapPropertyChangedEventHandler = new SynchronizedDelayedEventHandler <PropertyChangedEventArgs>(map_PropertyChanged_Delayed) { FireLastEventOnly = true, Delay2 = 300, Filter = (sender, e) => sender is ILayer || sender is VectorStyle || sender is ITheme, SynchronizeInvoke = this, Enabled = false }; mapCollectionChangedEventHandler = new SynchronizedDelayedEventHandler <NotifyCollectionChangedEventArgs>(map_CollectionChanged_Delayed) { FireLastEventOnly = true, Delay2 = 300, Filter = (sender, e) => sender is Map || sender is ILayer, SynchronizeInvoke = this, Enabled = false }; Map = new Map(ClientSize) { Zoom = 100 }; }
public void Move() { MoveTool.MoveObject(this.gameObject); IsoLayerManager.currentLayer.RemoveDataAtPosition(this.transform.position); }
private void setTool(string name) { if (Tool != null) { Tool.Exit(); } if (tools.ContainsKey(name)) { Tool = tools[name]; } else { switch (name) { case "move": Tool = new MoveTool(Project); break; case "pencil": Tool = new Pencil(Project, MyForeColor); break; case "eraser": Tool = new Eraser(Project); break; case "picker": Tool = new ColorPicker(Project, MyForeColor, MyBackColor); (Tool as ColorPicker).ColorChanged += colorPicker_ColorChanged; break; case "selection": Tool = new SelectionTool(Project); break; case "transform": Tool = new Transform(Project); break; case "shape": Tool = new Shape(Project, MyForeColor, MyBackColor); break; case "stamp": Tool = new CloneStamp(Project); break; case "brush": Tool = new FuzzyBrush(Project); break; default: throw new ArgumentException(); } Tool.Invalidated += Tool_Invalidated; Tool.CursorChanged += Tool_CursorChanged; tools[name] = Tool; } Tool.Init(); updateToolColor(); Tool_CursorChanged(this, null); setToolPanel(); }
public void StartMove(DrawableBase moveHandle, ScreenTransformGesture gesture) { _startDragPosition = gesture.ScreenPosition; MoveTool.StartMove(moveHandle, _startDragPosition, _selectedObjects.ToList()); }