Example #1
0
        private readonly bool direction; // true= Up, false = Down

        public CurveShape(Canvas canvas, Point Start, Point End, bool direction) : base(canvas, Start, End)
        {
            bezierSegment         = new BezierSegment();
            Name                  = "CurvePathx" + Global_Mouse.EncodeTransmissionTimestamp();
            props.name            = Name;
            props._shape.Name     = Name;
            props._pointHead.Name = Name;
            props._pointTail.Name = Name;
            props._arrow.Name     = Name;
            this.direction        = direction;
            RenderTransformOrigin = new Point(0, 1);
            controlPoint          = new Point();
            Draw();
        }
Example #2
0
 public StraightShape(Canvas canvas, Point Start, Point End) : base(canvas, Start, End)
 {
     lineSegment           = new LineSegment();
     lineSegment.IsStroked = true;
     Name                  = "StraightPathx" + Global_Mouse.EncodeTransmissionTimestamp();
     props.name            = Name;
     props._shape.Name     = Name;
     props._pointHead.Name = Name;
     props._pointTail.Name = Name;
     props._arrow.Name     = Name;
     RenderTransformOrigin = new Point(0, 0.5);
     Height                = 20;
     props._start.X        = 0;
     props._start.Y        = (Height / 2);
     props._end.Y          = (Height / 2);
     Draw();
 }
        public RobotShape(Canvas pCanvas)
        {
            //th = new Thread(DrawCircle);
            //DrawCircle();
            //th.IsBackground = true;
            //th.Start();

            ToolTip          = "";
            ToolTipOpening  += ChangeToolTipContent;
            props.isSelected = false;
            props.isHovering = false;
            ContextMenu      = new ContextMenu();
            //===================================
            MenuItem editItem = new MenuItem();

            editItem.Header = "Edit";
            editItem.Click += EditMenu;
            //===================================
            MenuItem removeItem = new MenuItem();

            removeItem.Header = "Remove";
            removeItem.Click += RemoveMenu;
            ContextMenu.Items.Add(editItem);
            ContextMenu.Items.Add(removeItem);
            //====================EVENT=====================
            //MouseLeave += MouseLeavePath;
            //MouseMove += MouseHoverPath;
            //MouseLeftButtonDown += MouseLeftButtonDownPath;
            //MouseRightButtonDown += MouseRightButtonDownPath;
            //===================CREATE=====================
            Name               = "Robotx" + Global_Mouse.EncodeTransmissionTimestamp();
            props.name         = Name;
            props.position     = new Point();
            props.mainGrid     = new Grid();
            props.statusGrid   = new Grid();
            props.statusBorder = new Border();
            props.rbID         = new Label();
            props.rbTask       = new Label();
            props.headLed      = new Rectangle();
            props.tailLed      = new Rectangle();
            props.eightCorner  = new List <Point>();
            for (int i = 0; i < 8; i++)
            {
                Point temp = new Point();
                props.eightCorner.Add(temp);
            }
            props.rbRotateTransform      = new RotateTransform();
            props.rbTranslate            = new TranslateTransform();
            props.rbTransformGroup       = new TransformGroup();
            props.contentRotateTransform = new RotateTransform();
            props.contentTranslate       = new TranslateTransform();
            props.contentTransformGroup  = new TransformGroup();
            //robotProperties = new Properties(this);
            //===================STYLE=====================
            //Robot border
            Width                 = 22;
            Height                = 15;
            BorderThickness       = new Thickness(1);
            BorderBrush           = new SolidColorBrush(Colors.Linen);
            Background            = new SolidColorBrush(Colors.Black);
            CornerRadius          = new CornerRadius(3);
            RenderTransformOrigin = new Point(0.5, 0.5);
            //mainGrid
            props.mainGrid.Background = new SolidColorBrush(Colors.Transparent);
            for (int i = 0; i < 3; i++)
            {
                ColumnDefinition colTemp = new ColumnDefinition();
                colTemp.Name = Name + "xL" + i;
                if ((i == 0) || (i == 2))
                {
                    colTemp.Width = new GridLength(1);
                }
                props.mainGrid.ColumnDefinitions.Add(colTemp);
            }
            //headLed
            props.headLed.Height = 7;
            props.headLed.Fill   = new SolidColorBrush(Colors.DodgerBlue);
            Grid.SetColumn(props.headLed, 2);
            //tailLed
            props.tailLed.Height = 7;
            props.tailLed.Fill   = new SolidColorBrush(Colors.OrangeRed);
            Grid.SetColumn(props.tailLed, 0);
            //statusBorder
            props.statusBorder.Width  = 10;
            props.statusBorder.Height = 13;
            props.statusBorder.RenderTransformOrigin = new Point(0.5, 0.5);
            Grid.SetColumn(props.statusBorder, 1);
            //statusGrid
            for (int i = 0; i < 2; i++)
            {
                RowDefinition rowTemp = new RowDefinition();
                rowTemp.Name = Name + "xR" + i;
                props.statusGrid.RowDefinitions.Add(rowTemp);
            }
            //rbID
            props.rbID.Padding             = new Thickness(0);
            props.rbID.Margin              = new Thickness(-5, 0, -5, 0);
            props.rbID.HorizontalAlignment = HorizontalAlignment.Center;
            props.rbID.VerticalAlignment   = VerticalAlignment.Bottom;
            props.rbID.Content             = "27";
            props.rbID.Foreground          = new SolidColorBrush(Colors.Yellow);
            props.rbID.FontFamily          = new FontFamily("Calibri");
            props.rbID.FontSize            = 6;
            props.rbID.FontWeight          = FontWeights.Bold;
            Grid.SetRow(props.rbID, 0);

            //rbTask
            props.rbTask.Padding             = new Thickness(0);
            props.rbTask.Margin              = new Thickness(-5, -1, -5, -1);
            props.rbTask.HorizontalAlignment = HorizontalAlignment.Center;
            props.rbTask.VerticalAlignment   = VerticalAlignment.Top;
            props.rbTask.Content             = "9999";
            props.rbTask.Foreground          = new SolidColorBrush(Colors.LawnGreen);
            props.rbTask.FontFamily          = new FontFamily("Calibri");
            props.rbTask.FontSize            = 6;
            props.rbTask.FontWeight          = FontWeights.Bold;
            Grid.SetRow(props.rbTask, 1);

            //===================CHILDREN===================
            props.statusGrid.Children.Add(props.rbID);
            props.statusGrid.Children.Add(props.rbTask);
            props.statusBorder.Child = props.statusGrid;
            props.mainGrid.Children.Add(props.headLed);
            props.mainGrid.Children.Add(props.tailLed);
            props.mainGrid.Children.Add(props.statusBorder);
            props.rbTransformGroup.Children.Add(props.rbRotateTransform);
            props.rbTransformGroup.Children.Add(props.rbTranslate);
            RenderTransform = props.rbTransformGroup;
            props.contentTransformGroup.Children.Add(props.contentRotateTransform);
            props.contentTransformGroup.Children.Add(props.contentTranslate);
            props.statusBorder.RenderTransform = props.contentTransformGroup;
            props.canvas = pCanvas;
            Child        = props.mainGrid;
            props.canvas.Children.Add(this);

            //====================FINAL=====================
        }