Beispiel #1
0
        /// <summary>
        /// this function determines witch method has to be called based on te mode which the user has selected
        /// </summary>
        /// <param name="sender">the mouse</param>
        /// <param name="e">the date for the selected mouse events</param>
        private void Canvas_OnMouseUp(object sender, MouseButtonEventArgs e)
        {
            switch (_currentMode)
            {
            case ModeSwitch.Line:
                DrawLine();
                break;

            case ModeSwitch.Ellipse:
                DrawEllipse();
                break;

            case ModeSwitch.Rectangle:
                DrawRectangle();
                break;

            case ModeSwitch.Triangle:
                DrawTriangle();
                break;

            case ModeSwitch.Resize:
                if (_selectedShape != null)
                {
                    ResizeShape(_selectedShape);
                    _selectedShape = null;
                }
                break;

            case ModeSwitch.Move:
                if (_selectedShape != null)
                {
                    MoveShape(_selectedShape);
                    _selectedShape = null;
                }
                break;

            case ModeSwitch.Delete:
                if (_selectedShape != null)
                {
                    DeleteShape(_selectedShape);
                    _selectedShape = null;
                }
                break;

            case ModeSwitch.Selector:
                AddToBoxList(_selectedShape);
                break;

            case ModeSwitch.Display:
                if (_selectedShape != null)
                {
                    DisplayGroup(_selectedShape);
                    _selectedShape = null;
                }
                break;

            default:
                return;
            }
        }
Beispiel #2
0
        /// <summary>
        /// finds the box where the shape is located
        /// </summary>
        /// <param name="shape">the given shape</param>
        /// <param name="head">checks if the shape is not located in the main box</param>
        /// <returns>returns the box if a shape is locted in one (witch is not the main box) or null when the shape is not found in a box</returns>
        public Boxer FindBox(GodShape shape, bool head = true)
        {
            foreach (var component in _components)
            {
                if (component.Equals(shape))
                {
                    if (!head)
                    {
                        return(this);
                    }

                    return(null);
                }

                if (component is Boxer box)
                {
                    var result = box.FindBox(shape, false);
                    if (result != null)
                    {
                        return(result);
                    }
                }
            }
            return(null);
        }
Beispiel #3
0
        private void Canvas_OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            _startPoint = e.GetPosition(this);
            HitTestResult result =
                VisualTreeHelper.HitTest(Canvas, Mouse.GetPosition(Canvas));

            _selectedShape = result.VisualHit as GodShape;
        }
Beispiel #4
0
 /// <summary>
 /// Adds the component to a box
 /// </summary>
 /// <param name="component">the component to be added</param>
 public void Add(GodShape component)
 {
     component.Depth += "-";
     if (component is Boxer)
     {
         var x = (Boxer)component;
         foreach (var comp in x.GetChildren())
         {
             comp.Depth += "-";
             if (comp is Boxer)
             {
                 var y = (Boxer)comp;
                 y.Indentation();
             }
         }
     }
     _components.Add(component);
 }
Beispiel #5
0
 /// <summary>
 /// the constructor of DisplayGroup
 /// </summary>
 /// <param name="component">the selected component</param>
 public DisplayGroup(GodShape component)
 {
     _component = component;
 }
Beispiel #6
0
 /// <summary>
 /// the constructor of the Move class
 /// </summary>
 /// <param name="component">the component that needs to be moved</param>
 /// <param name="newPosition">the new position where the component needs to go</param>
 /// <param name="oldPosition">the old position of the component</param>
 public Move(GodShape component, Vector newPosition, Vector oldPosition)
 {
     _component      = component;
     _positionResult = oldPosition + -1 * newPosition;
 }
Beispiel #7
0
 public Ornament(GodShape godShape) : base(godShape)
 {
 }
Beispiel #8
0
 /// <summary>
 /// the constructor of the Resize class
 /// </summary>
 /// <param name="component">the component that has to be resized</param>
 /// <param name="distance">the distance of the old component and the new component</param>
 public Resize(GodShape component, Vector distance)
 {
     _component = component;
     _distance  = distance;
 }
Beispiel #9
0
 /// <summary>
 /// detaches the component from its box
 /// </summary>
 /// <param name="component">the component to be detached</param>
 public void Detach(GodShape component)
 {
     _components.Remove(component);
 }
Beispiel #10
0
 /// <summary>
 /// Adds the component to a box
 /// </summary>
 /// <param name="component">the component to be added</param>
 /// <param name="depth">the depth if nested deeper in the hierarchy</param>
 public void Add(GodShape component, string depth)
 {
     component.Depth = depth;
     _components.Add(component);
 }
 /// <summary>
 /// constructor of the command
 /// </summary>
 /// <param name="component">the component to be deleted</param>
 public Delete(GodShape component)
 {
     _component = component;
 }
Beispiel #12
0
 public void SetComponent(GodShape component)
 {
     Component = component;
     Width     = component.Width;
     Height    = component.Height;
 }
Beispiel #13
0
 protected Decorator(GodShape p)
 {
     Component = p;
 }
 /// <summary>
 /// the constructor of the Draw class
 /// </summary>
 /// <param name="component"></param>
 public Draw(GodShape component)
 {
     _component = component;
 }