// Selects the ammount of damage a click does to a tile
    void UpdateToolSelection(SelectedTool tool)
    {
        currentTool = tool;
        switch (currentTool)
        {
        case SelectedTool.HAMMER:
            toolStrength = 4;
            break;

        case SelectedTool.PICKAXE:
            toolStrength = 3;
            break;

        case SelectedTool.TROWEL:
            toolStrength = 2;
            break;

        case SelectedTool.NONE:
            toolStrength = 0;
            break;

        default:
            break;
        }
    }
Esempio n. 2
0
 public void Update(GameTime gametime)
 {
     if (HasToolSelected)
     {
         SelectedTool.Update(gametime);
     }
 }
Esempio n. 3
0
 void RemoveTool(IList <Rectangle> updates)
 {
     if (SelectedTool != null)
     {
         SelectedTool.RemoveDrawing(updates);
     }
 }
Esempio n. 4
0
        private void handleMouseUp(MouseEventArgs param)
        {
            if (param == null)
            {
                throw new InvalidOperationException(GetFunctionName());
            }
            var sender = param.Source as IInputElement;

            if (sender == null)
            {
                throw new InvalidOperationException(GetFunctionName());
            }

            bool isScreenDirty = false;

            // Ist die Kamera Bewegung aktiviert?
            if ((Keyboard.Modifiers & ModifierKeys.Alt) > 0)
            {
                _camera.OnMouseUp(param, ref isScreenDirty);
            }
            else
            {
                SelectedTool.OnMouseUp(param, ref isScreenDirty);
                //_tool.OnMouseUp(param);
            }
            Mouse.OverrideCursor = null;
            if (isScreenDirty)
            {
                _dxElement.Render();
            }
        }
Esempio n. 5
0
 internal override void UIUpdate()
 {
     try
     {
         base.UIUpdate();
         flyCam.Update();
         if (toolLineProperty.visible)
         {
             toolLineProperty.UIUpdate();
         }
         if (toolSetting.visible)
         {
             toolSetting.UIUpdate();
         }
         if (SelectedTool.isShapeTool())
         {
             toolShape.Update();
         }
         if (SelectedTool == ToolType.Image)
         {
             toolImage.UIUpdate();
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
 }
Esempio n. 6
0
        public void SelectTool(ITool tool)
        {
            ITool oldTool = null;
            ITool newTool = null;

            if (tool.IsActivatable)
            {
                if (ActivatedTools.Contains(tool))
                {
                    ActivatedTools.Remove(tool);
                }
                else
                {
                    ActivatedTools.Add(tool);
                }

                tool.IsActivated = ActivatedTools.Contains(tool);
            }
            else
            {
                oldTool = SelectedTool;

                SelectedTool?.Unselect();
                SelectedTool = tool;
                SelectedTool.Select();

                newTool = SelectedTool;
            }

            ToolSelected?.Invoke(this, new ToolSelectedEventArgs(oldTool, newTool));
        }
Esempio n. 7
0
        public override void OnKeyDown(KeyEventArgs e)
        {
            var allowToolSelection = true;

            if (SelectedTool != null)
            {
                SelectedTool.OnKeyDown(e);
                allowToolSelection = SelectedTool.AllowToolShortcuts;
            }

            if (!e.Handled && allowToolSelection)
            {
                foreach (var tool in Tools)
                {
                    if (e.KeyData == tool.Accelerator && tool != SelectedTool)
                    {
                        SelectedTool = tool;
                        e.Handled    = true;
                        break;
                    }
                }
            }
            if (!e.Handled)
            {
                base.OnKeyDown(e);
            }
        }
Esempio n. 8
0
        public void UndoInternal(bool IncludeSelectionOperation = false)
        {
            if (undoStack.Count == 0)
            {
                return;
            }
            PostFilter undoFilter;

            do
            {
                undoFilter = undoStack.Pop();
                redoStack.Push(undoFilter);
                undoFilter.Undo();
            } while ((!IncludeSelectionOperation && (undoFilter is SelectionOperation)) && (undoStack.Count != 0));

            if (!(undoFilter is EditingActivatedOperation || undoFilter is SelectionOperation || undoFilter is SetColorOperation))
            {
                ClearCanvas(false);
                RecreateCanvasViewModel();
                UpdateUIElements();
                DisplaySettingsTool.SliceImage();
                if (undoStack.Count == 0)
                {
                    UnsavedChanges = false;
                }
            }
            else
            {
                UpdateUIElements();
            }
            SelectedTool.OnUndo();
        }
Esempio n. 9
0
        public void RedoInternal(bool IncludeSelectionOperation = false)
        {
            if (redoStack.Count == 0)
            {
                return;
            }
            PostFilter redoFilter;

            do
            {
                redoFilter = redoStack.Pop();
                undoStack.Push(redoFilter);
                redoFilter.Apply();
            } while ((!IncludeSelectionOperation && redoFilter is SelectionOperation) && redoStack.Count != 0);

            if (!(redoFilter is EditingDeactivatedOperation || redoFilter is SelectionOperation || redoFilter is SetColorOperation))
            {
                ClearCanvas(false);
                RecreateCanvasViewModel();
                UpdateUIElements();
                DisplaySettingsTool.SliceImage();
            }
            else
            {
                UpdateUIElements();
            }
            SelectedTool.OnRedo();
        }
Esempio n. 10
0
        private void handleMouseDown(MouseEventArgs param)
        {
            _dxElement.Focusable = true;
            Keyboard.Focus(_dxElement);
            if (param == null)
            {
                throw new InvalidOperationException(GetFunctionName());
            }

            bool isScreenDirty = false;

            if ((Keyboard.Modifiers & ModifierKeys.Alt) > 0)
            {
                _camera.OnMouseDown(param, ref isScreenDirty);
            }
            else
            {
                SelectedTool.OnMouseDown(param, ref isScreenDirty);
            }
            //_tool.OnMouseDown(param);
            if (isScreenDirty)
            {
                // Render
                _dxElement.Render();
            }
        }
Esempio n. 11
0
 internal override void UIDraw()
 {
     try
     {
         if (visible || ModContent.GetInstance <TeraCADConfig>().isDrawShpes)
         {
             toolShape.DrawShapes();
         }
         if (SelectedTool.isShapeTool())
         {
             toolShape.Draw();
         }
         if (ui.isDisplayRangeRectangle && !InfinityRange)
         {
             DrawRangeRectangle();
         }
         if (SelectedTool == ToolType.Image)
         {
             toolImage.UIDraw();
         }
         if (toolSetting.visible)
         {
             toolSetting.UIDraw();
         }
         if (toolLineProperty.visible)
         {
             toolLineProperty.UIDraw();
         }
         base.UIDraw();
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
 }
Esempio n. 12
0
 private void toolsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     additionalSettingsGrid.DataContext = SelectedTool;
     lineWidthRow.Height   = new GridLength(40);
     strokeColorRow.Height = new GridLength(40);
     fillColorRow.Height   = new GridLength(40);
     if (SelectedTool is BrushTool || SelectedTool is LineTool)
     {
         fillColorRow.Height = new GridLength(0);
     }
     else if (SelectedTool is EllipseTool)
     {
         roundedCornersRow.Height = new GridLength(0);
     }
     else if (SelectedTool is PaintBucketTool)
     {
         lineWidthRow.Height   = new GridLength(0);
         strokeColorRow.Height = new GridLength(0);
     }
     else if (!SelectedTool.RequiresAdditionalSettings())
     {
         lineWidthRow.Height   = new GridLength(0);
         strokeColorRow.Height = new GridLength(0);
         fillColorRow.Height   = new GridLength(0);
     }
 }
Esempio n. 13
0
 public void KeyPress(Gdk.Key key)
 {
     if (SelectedTool != null)
     {
         SelectedTool.KeyPress(key);
     }
 }
Esempio n. 14
0
 public void ManipulationDelta(ManipulationDeltaEventArgs e)
 {
     if (SelectedTool != null && !IsWorking)
     {
         SelectedTool.Delta(e);
     }
 }
Esempio n. 15
0
 void RedrawTool()
 {
     if (SelectedTool != null)
     {
         SelectedTool.Redraw();
     }
 }
Esempio n. 16
0
 private void rbtnEllipce_CheckedChanged(object sender, EventArgs e)
 {
     if (rbtnEllipce.Checked)
     {
         _toolType = SelectedTool.Ellipse;
         ApplyMovedControl();
     }
 }
Esempio n. 17
0
 private void rbtnRect_CheckedChanged(object sender, EventArgs e)
 {
     if (rbtnRect.Checked)
     {
         _toolType = SelectedTool.Rect;
         ApplyMovedControl();
     }
 }
Esempio n. 18
0
 void ApplyTool(IList <Rectangle> updates)
 {
     if (SelectedTool != null)
     {
         SelectedTool.ApplyDrawing(updates);
         this.BGI.UpdateRegion(updates);
     }
 }
Esempio n. 19
0
 public void ManipulationStarted(double imgWidth, double imgHeight, ManipulationStartedEventArgs e)
 {
     if (SelectedTool != null && !IsWorking)
     {
         SelectedTool.ImageWidth  = imgWidth;
         SelectedTool.ImageHeight = imgHeight;
         SelectedTool.Started(e);
     }
 }
Esempio n. 20
0
    // Change the currently selected tool
    void SelectTool(SelectedTool tool)
    {
        // If no change, nothing to do
        if (tool == selected_tool)
        {
            return;
        }

        // If selected tool is not the laser pointer, ensure the laser pointer GameObject is turned off
        if (tool != SelectedTool.LASER_POINTER)
        {
            laserPointer.SetActive(false);
            laserPointerScript.leftHandGuideline.SetActive(true);
            laserPointerScript.rightHandGuideline.SetActive(true);
        }

        if (tool != SelectedTool.BRUSH)
        {
            brush.SetActive(false);
        }

        // Log the change in tool
        Debug.Log(string.Format("Selected Tool {0}", tool));

        Vector2 offset = new Vector2(0, 64);

        if (SelectedTool.HAND == tool)
        {
            Cursor.SetCursor(hand_cursor, offset, CursorMode.ForceSoftware);
        }
        else if (SelectedTool.BRUSH == tool)
        {
            Cursor.SetCursor(brush_cursor, offset, CursorMode.ForceSoftware);
            brush.SetActive(true);
        }
        else if (SelectedTool.FOOD == tool)
        {
            Cursor.SetCursor(food_cursor, offset, CursorMode.ForceSoftware);
        }
        else if (SelectedTool.LASER_POINTER == tool)
        {
            Cursor.SetCursor(laser_cursor, offset, CursorMode.ForceSoftware);

            // Turn off vive controller laser pointers
            laserPointerScript.leftHandGuideline.SetActive(false);
            laserPointerScript.rightHandGuideline.SetActive(false);

            //Activate laser pointer gameobject
            laserPointer.SetActive(true);
        }
        else if (SelectedTool.LITTER_SCOOPER == tool)
        {
            Cursor.SetCursor(litter_cursor, offset, CursorMode.ForceSoftware);
        }

        selected_tool = tool;
    }
Esempio n. 21
0
        public override void OnMouseMove(MouseEventArgs e)
        {
            SelectedTool?.OnMouseMove(new MouseEventArgs(e.Buttons, e.Modifiers, e.Location * BGI.Scale, e.Delta, e.Pressure));

            if (!e.Handled)
            {
                base.OnMouseMove(e);
            }
        }
Esempio n. 22
0
 private void mainImage_MouseLeave(object sender, MouseEventArgs e)
 {
     if (Drawing)
     {
         Drawing = false;
         SelectedTool.EndDrawing(GetPoint(e));
         Draw();
     }
     this.Cursor = Cursors.Arrow;
 }
Esempio n. 23
0
 public void ManipulationEnded(ManipulationCompletedEventArgs e)
 {
     if (SelectedTool != null && !IsWorking)
     {
         SelectedTool.Ended(e);
         CanApply   = true;
         _noChanges = false;
         UndoCommand.RaiseCanExecuteChanged();
     }
 }
Esempio n. 24
0
 internal void Canvas_MouseMove(Avalonia.Point dominoPoint, PointerEventArgs e)
 {
     if (iscopying)
     {
         DrawPasteOverlay(dominoPoint, e);
     }
     else
     {
         SelectedTool?.MouseMove(dominoPoint, e);
     }
 }
Esempio n. 25
0
 internal override void KeyPressed(object sender, KeyEventArgs args)
 {
     if (iscopying && args.Key == Key.Escape)
     {
         FinalizePaste(true);
         args.Handled = true;
     }
     if (!args.Handled)
     {
         SelectedTool.KeyPressed(args);
     }
 }
Esempio n. 26
0
        public static void SetTool(Tool tool)
        {
            if (SelectedTool != null && tool != SelectedTool)
            {
                SelectedTool.Stop();
                SelectedTool.OnChangingTool();
            }

            if (tool == CurrentTools.HandTool)
            {
                _selected = HandTool;
                HandTool.Stop();
                _quickpan = false;
            }
            else if (tool == CurrentTools.LineTool)
            {
                _selected = LineTool;
            }
            else if (tool == CurrentTools.BezierTool)
            {
                _selected = BezierTool;
            }
            else if (tool == CurrentTools.PencilTool)
            {
                _selected = PencilTool;
            }
            else if (tool == CurrentTools.EraserTool)
            {
                if (SelectedTool == EraserTool)
                {
                    EraserTool.Swatch.Selected = LineType.All;
                }
                _selected = EraserTool;
            }
            else if (tool == CurrentTools.MoveTool)
            {
                if (SelectedTool == MoveTool)
                {
                    MoveTool.Swatch.Selected = LineType.All;
                }
                _selected = MoveTool;
            }
            else if (tool == CurrentTools.SelectTool)
            {
                if (SelectedTool == SelectTool)
                {
                    SelectTool.Swatch.Selected = LineType.All;
                }
                _selected = SelectTool;
            }
        }
Esempio n. 27
0
 public void SetCursorPosition(Point value, bool invalidate)
 {
     if (cursorPosition != value)
     {
         Point pos = cursorPosition;
         cursorPosition = value;
         cursorPosition.Restrict(new Rectangle(CurrentPage.Canvas.Size));
         if (SelectedTool != null)
         {
             SelectedTool.OnSetCursorPosition(pos, cursorPosition, invalidate);
         }
         OnCursorPositionChanged(EventArgs.Empty);
     }
 }
Esempio n. 28
0
        public override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (!AllowEditing)
            {
                return;
            }

            if (SelectedTool != null)
            {
                SelectedTool.OnMouseMove(e);
            }
        }
Esempio n. 29
0
    private DrawingColor drawingColorComp;                                            //drawing color

    //Use this for Initialization
    void Start()
    {
        fontSizeType     = FontSizeType.PEN;
        fontSize         = FontSize.MEDIUM;
        selectedTool     = SelectedTool.PEN;
        lineColor        = new Color(0, 147, 68, 100) / 255.0f;
        prevColor        = lineColor;
        drawingMaterial  = GameObject.Find("green (Drawing Level)").GetComponent <DrawingColor> ().drawingMaterial;
        previousMaterial = drawingMaterial;

        if (middleCam == null)
        {
            middleCam = GameObject.FindGameObjectWithTag("MiddleCam").GetComponent <Camera> ();                                    //setting up middle camera reference
        }

        if (drawResizerOb == null)
        {
            drawResizerOb = GameObject.Find("Draw-Resizer (Drawing Level)");
        }

        if (toolsAnimator == null)
        {
            toolsAnimator = GameObject.Find("Tools").GetComponent <Animator> ();
        }

        if (brushObFollowTarget == null)
        {
            brushObFollowTarget = GameObject.Find("brush (Drawing Level)").GetComponent <FollowTarget> ();
        }

        if (deleteObFollowTarget == null)
        {
            deleteObFollowTarget = GameObject.Find("eraser (Drawing Level)").GetComponent <FollowTarget> ();
        }

        if (penObFollowTarget == null)
        {
            penObFollowTarget = GameObject.Find("pencil (Drawing Level)").GetComponent <FollowTarget> ();
        }

        if (colorsWheelControllerComp == null)
        {
            colorsWheelControllerComp = GameObject.Find("ColorsWheel (Drawing Level)").GetComponent <ColorsWheelController> ();
        }

        drawResizerBackground = drawResizerOb.transform.Find("draw-resizer-background (Drawing Level)").gameObject;
        SetDrawResizerColor();
        SetFontSize();
    }
Esempio n. 30
0
        public void CreateImageAtXY(string imageKey, double x, double y)
        {
            PixbufRepository.AddOrUpdatePixbufByName(imageKey);
            var point       = new Cairo.PointD(x / Zoom, y / Zoom);
            var sectionView = getSectionViewByXY(x, y);
            var localpoint  = sectionView.PointInSectionByAbsolutePoint(point);

            ToolBoxService.SetToolByName("ImageTool");
            SelectedTool.CreateNewControl(sectionView);
            var image = (SelectedControl.ControlModel as Image);

            image.ImageKey          = imageKey;
            image.Location          = new MonoReports.Model.Point(localpoint.X, localpoint.Y);
            SelectedTool.CreateMode = false;
        }
Esempio n. 31
0
		private DrawingColor drawingColorComp;//drawing color

		//Use this for Initialization
		void Start ()
		{
				fontSizeType = FontSizeType.PEN;
				fontSize = FontSize.MEDIUM;
				selectedTool = SelectedTool.PEN;
				lineColor = new Color (0, 147, 68, 100) / 255.0f;
				prevColor = lineColor;
				drawingMaterial = GameObject.Find ("green (Drawing Level)").GetComponent<DrawingColor> ().drawingMaterial;
				previousMaterial = drawingMaterial;

				if (middleCam == null) {
						middleCam = GameObject.FindGameObjectWithTag ("MiddleCam").GetComponent<Camera> ();//setting up middle camera reference
				}

				if (drawResizerOb == null) {
						drawResizerOb = GameObject.Find ("Draw-Resizer (Drawing Level)");
				}

				if (toolsAnimator == null) {
						toolsAnimator = GameObject.Find ("Tools").GetComponent<Animator> ();
				}

				if (brushObFollowTarget == null) {
						brushObFollowTarget = GameObject.Find ("brush (Drawing Level)").GetComponent<FollowTarget> ();
				}

				if (deleteObFollowTarget == null) {
						deleteObFollowTarget = GameObject.Find ("eraser (Drawing Level)").GetComponent<FollowTarget> ();
				}

				if (penObFollowTarget == null) {
						penObFollowTarget = GameObject.Find ("pencil (Drawing Level)").GetComponent<FollowTarget> ();
				}

				if (colorsWheelControllerComp == null) {
						colorsWheelControllerComp = GameObject.Find ("ColorsWheel (Drawing Level)").GetComponent<ColorsWheelController> ();
				}
	
				drawResizerBackground = drawResizerOb.transform.Find ("draw-resizer-background (Drawing Level)").gameObject;
				SetDrawResizerColor ();
				SetFontSize ();
		}
Esempio n. 32
0
		//tools events
		public void ToolsEvents (GameObject toolOb)
		{
				if (toolOb == null) {
						return;
				}

				string toolName = toolOb.name;
				string obTag = toolOb.tag;
				bool checkSelectedTool = false;
				bool checkFontSize = false;
				bool checkPrevColor = false;
				bool checkDrawResizerColor = false;

				if (toolName == "small-size-circle (Drawing Level)") {
						fontSize = FontSize.SMALL;
						checkFontSize = true;
						checkDrawResizerColor = true;
				} else if (toolName == "med-size-circle (Drawing Level)") {
						fontSize = FontSize.MEDIUM;
						checkFontSize = true;
						checkDrawResizerColor = true;
				} else if (toolName == "larg-size-circle (Drawing Level)") {
						fontSize = FontSize.LARGE;
						checkFontSize = true;
						checkDrawResizerColor = true;
				} else if (toolName == "trash (Drawing Level)") {
						ClearBoard ();
						colorsWheelControllerComp.ScrollingRelease (360, 0);
				} else if (obTag == "WheelColor") {
						checkDrawResizerColor = true;
						checkPrevColor = true;
						drawingColorComp = toolOb.GetComponent<DrawingColor> ();
						lineColor = drawingColorComp.color;
						drawingMaterial = drawingColorComp.drawingMaterial;
						previousMaterial = drawingMaterial;
						if (DrawingLevel.isEraserSelected) {
								checkSelectedTool = true;
								checkFontSize = true;
								fontSizeType = FontSizeType.PEN;
								selectedTool = SelectedTool.PEN;
						}
				} else if (toolName == "eraser (Drawing Level)") {
						DrawingLevel.isEraserSelected = true;
						selectedTool = SelectedTool.DELETE;
						checkDrawResizerColor = true;
						checkSelectedTool = true;
						lineColor = Color.white;
						drawingMaterial = DrawingColor.whiteMaterial;
				} else if (toolName == "pencil (Drawing Level)") {
						DrawingLevel.isEraserSelected = false;
						selectedTool = SelectedTool.PEN;
						checkDrawResizerColor = true;
						checkSelectedTool = true;
						checkFontSize = true;
						fontSizeType = FontSizeType.PEN;
						lineColor = prevColor;
						drawingMaterial = previousMaterial;
				} else if (toolName == "brush (Drawing Level)") {
						DrawingLevel.isEraserSelected = false;
						selectedTool = SelectedTool.BRUSH;
						checkDrawResizerColor = true;
						checkSelectedTool = true;
						checkFontSize = true;
						fontSizeType = FontSizeType.BRUSH;
						lineColor = prevColor;
						drawingMaterial = previousMaterial;
				}

				if (checkDrawResizerColor) {
						if (checkPrevColor) {
								prevColor = lineColor;
						}
						SetDrawResizerColor ();
				} 

				if (checkSelectedTool) {
						SetSelectedTool ();
				}

				if (checkFontSize) {
						SetFontSize ();
				}
		}