Exemple #1
0
 /// <summary>
 /// An equals function, compares this instance of FreeFormObject to another instance of FreeFormObject and returns whether or not they are equal.
 /// </summary>
 /// <param name="p">An instance of FreeFormObject to be compared</param>
 /// <returns>A boolean value representing equality</returns>
 public bool Equals(FreeFormObject p)
 {
     return(_type == p._type &&
            _x == p._x &&
            _y == p._y &&
            _width == p._width &&
            _height == p._height &&
            _angle == p._angle);
 }
Exemple #2
0
        public static void RemoveKeySequenceElement(FreeFormObject element)
        {
            ContentControl existingControl = FindElementByTag(element);

            if (existingControl != null)
            {
                static_canvas.Children.Remove(existingControl);
            }
        }
Exemple #3
0
        public static void AddKeySequenceElement(FreeFormObject element, Color element_color, String element_name)
        {
            ContentControl existingControl = FindElementByTag(element);

            if (existingControl == null)
            {
                ContentControl newcontrol = new ContentControl();
                newcontrol.Width  = element.Width;
                newcontrol.Height = element.Height;
                newcontrol.SetValue(Selector.IsSelectedProperty, true);
                newcontrol.SetValue(Canvas.TopProperty, (double)(element.Y + Effects.grid_baseline_y));
                newcontrol.SetValue(Canvas.LeftProperty, (double)(element.X + Effects.grid_baseline_x));
                RotateTransform transform = new RotateTransform();
                transform.Angle = element.Angle;
                newcontrol.SetValue(RenderTransformProperty, transform);
                newcontrol.Style        = style;
                newcontrol.Tag          = element;
                newcontrol.SizeChanged += Newcontrol_SizeChanged;
                var descriptor = DependencyPropertyDescriptor.FromProperty(
                    Canvas.LeftProperty, typeof(ContentControl)
                    );
                descriptor.AddValueChanged(newcontrol, OnCanvasLeftChanged);
                var descriptor_top = DependencyPropertyDescriptor.FromProperty(
                    Canvas.TopProperty, typeof(ContentControl)
                    );
                descriptor_top.AddValueChanged(newcontrol, OnCanvasTopChanged);
                var descriptor_angle = DependencyPropertyDescriptor.FromProperty(
                    RenderTransformProperty, typeof(ContentControl)
                    );
                descriptor_angle.AddValueChanged(newcontrol, OnAngleChanged);

                Shape content = new Rectangle();

                content      = new Rectangle();
                content.Fill = new SolidColorBrush(element_color);

                content.IsHitTestVisible = false;
                content.Opacity          = 0.50D;

                Grid content_grid = new Grid();
                content_grid.IsHitTestVisible = false;
                content_grid.Children.Add(content);

                Label label = new Label();
                label.Foreground       = new SolidColorBrush(Color.FromRgb(0, 0, 0));
                label.Content          = element_name;
                label.IsHitTestVisible = false;
                content_grid.Children.Add(label);

                newcontrol.Content = content_grid;

                static_canvas.Children.Add(newcontrol);
            }
        }
Exemple #4
0
        private static ContentControl FindElementByTag(FreeFormObject tag)
        {
            ContentControl foundElement = null;

            foreach (var child in static_canvas.Children)
            {
                if (child is ContentControl && tag.Equals((child as ContentControl).Tag))
                {
                    foundElement = child as ContentControl;
                    break;
                }
            }

            return(foundElement);
        }