Beispiel #1
0
        void Group.Draw(Canvas c)
        {
            UIManager.Clear();
            if (UIManager.ShowSecondaryMenu)
            {
                if (!UIManager.inMenuSession)
                {
                    UIManager.initialX = UIManager.FirstHand.X;
                    UIManager.initialY = UIManager.FirstHand.Y;
                    UIManager.inMenuSession = true;
                }

                System.Windows.Media.Brush primaryColor = ProfileManager.ActiveProfile.PrimaryColor;
                System.Windows.Media.Brush secondaryColor = ProfileManager.ActiveProfile.SecondaryColor;
                System.Windows.Media.Brush fill = ColorUtil.FromHTML("#88FFFFFF");

                double centerX = UIManager.initialX;
                double centerY = UIManager.initialY;

                double leftAreaX = UIManager.initialX - 1.25 * UIManager.SUBMENU_DIAMETER;
                double leftAreaY = UIManager.initialY;

                if (UIManager.FirstHandNumber == 2)
                {
                    leftAreaX = UIManager.initialX + 1.25 * UIManager.SUBMENU_DIAMETER;
                }

                if (UIManager.FirstHand.X > leftAreaX - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.X < leftAreaX + UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.Y > leftAreaY - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.Y < leftAreaY + UIManager.SUBMENU_DIAMETER / 2)
                {
                    leftSelected = true;

                }

                else if (UIManager.FirstHand.X > centerX - UIManager.MENU_DIAMETER / 2 && UIManager.FirstHand.X < centerX + UIManager.MENU_DIAMETER / 2 && UIManager.FirstHand.Y > centerY - UIManager.MENU_DIAMETER / 2 && UIManager.FirstHand.Y < centerY + UIManager.MENU_DIAMETER / 2)
                {
                    if (leftSelected)
                    {
                        UIManager.SelectedGroup = UIManager.MainGroup;
                    }

                    leftSelected = false;
                }

                CanvasUtil.DrawEllipse(c, centerX, centerY, UIManager.MENU_DIAMETER, UIManager.MENU_DIAMETER, primaryColor, fill, null);

                if (leftSelected)
                {
                    CanvasUtil.DrawEllipse(c, leftAreaX, leftAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, UIManager.MainGroup.IsActive ? secondaryColor : Brushes.LightGray, fill, System.Windows.Media.Brushes.White);
                }
                else
                {
                    CanvasUtil.DrawEllipse(c, leftAreaX, leftAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, UIManager.MainGroup.IsActive ? secondaryColor : Brushes.LightGray, fill, null);
                }

                System.Windows.Controls.Image image0 = ImageUtil.GetResourceImage(((Group)this).Name);
                CanvasUtil.DrawImageInCircle(c, image0, UIManager.MENU_DIAMETER, centerX, centerY);

                System.Windows.Controls.Image image1 = ImageUtil.GetResourceImage(UIManager.MainGroup.Name);
                CanvasUtil.DrawImageInCircle(c, image1, UIManager.SUBMENU_DIAMETER, leftAreaX, leftAreaY);
            }
            else if (UIManager.FirstHandNumber != 0 && UIManager.FirstHand.IsSelected && !UIManager.inMenuSession)
            {
                if (!inSession)
                {
                    UIManager.initialX = UIManager.FirstHand.X;
                    UIManager.initialY = UIManager.FirstHand.Y;
                    inSession = true;
                }

                System.Windows.Media.Brush primaryColor = ProfileManager.ActiveProfile.PrimaryColor;
                System.Windows.Media.Brush secondaryColor = ProfileManager.ActiveProfile.SecondaryColor;
                System.Windows.Media.Brush fill = ColorUtil.FromHTML("#88FFFFFF");

                Brush color = null;

                int i = 0;
                foreach (Point2D p in pointsLeft)
                {
                    if (UIManager.FirstHandNumber == 1)
                    {
                        color = ColorUtil.FromHTML(colors[i]);
                    }
                    else
                    {
                        color = ColorUtil.FromHTML(colors[colors.Count - 1 - i]);
                    }
                    UIManager.Draw(p, color, Brushes.Transparent);
                    i++;
                }

                if (pointsLeft.Count > 10)
                {
                    pointsLeft.Dequeue();
                }

                Point2D currentPoint = new Point2D(UIManager.FirstHand.X, UIManager.FirstHand.Y);
                pointsLeft.Enqueue(currentPoint);
            }
            else
            {
                pointsLeft.Clear();
                inSession = false;
                UIManager.inMenuSession = false;
                leftSelected = false;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Get distance between 2 points in an XOY plane
 /// </summary>
 /// <param name="a">Point A</param>
 /// <param name="b">Point b</param>
 /// <returns></returns>
 public static Double GetDistance2D(Point2D a, Point2D b)
 {
     Double dist = Math.Sqrt(Math.Pow(b.X - a.X, 2) + Math.Pow(b.Y - a.Y, 2));
     return dist;
 }
Beispiel #3
0
        void Group.Draw(Canvas c)
        {
            if ((instance.brush == null || UIManager.inMenuSession || UIManager.ShowSecondaryMenu) && UIManager.FirstHandNumber != 0 && UIManager.FirstHand.IsSelected)
            {
                UIManager.InPaint = false;

                if (!UIManager.inMenuSession)
                {
                    UIManager.initialX = UIManager.FirstHand.X;
                    UIManager.initialY = UIManager.FirstHand.Y;
                    UIManager.inMenuSession = true;
                }

                System.Windows.Media.Brush primaryColor = ProfileManager.ActiveProfile.PrimaryColor;
                System.Windows.Media.Brush secondaryColor = ProfileManager.ActiveProfile.SecondaryColor;
                System.Windows.Media.Brush fill = ColorUtil.FromHTML("#88FFFFFF");

                double centerX = UIManager.initialX;
                double centerY = UIManager.initialY;

                double leftAreaX = UIManager.initialX - 1.25 * UIManager.SUBMENU_DIAMETER;
                double leftAreaY = UIManager.initialY;

                double rightAreaX = UIManager.initialX + 1.25 * UIManager.SUBMENU_DIAMETER;
                double rightAreaY = UIManager.initialY;

                double upAreaX = UIManager.initialX;
                double upAreaY = UIManager.initialY - 1.25 * UIManager.SUBMENU_DIAMETER;

                double downAreaX = UIManager.initialX;
                double downAreaY = UIManager.initialY + 1.25 * UIManager.SUBMENU_DIAMETER;

                if (UIManager.FirstHand.X > rightAreaX - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.X < rightAreaX + UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.Y > rightAreaY - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.Y < rightAreaY + UIManager.SUBMENU_DIAMETER / 2)
                {
                    rightSelected = true;
                    leftSelected = false;
                    upSelected = false;
                    downSelected = false;
                }
                else if (UIManager.FirstHand.X > leftAreaX - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.X < leftAreaX + UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.Y > leftAreaY - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.Y < leftAreaY + UIManager.SUBMENU_DIAMETER / 2)
                {
                    leftSelected = true;
                    rightSelected = false;
                    upSelected = false;
                    downSelected = false;
                }
                else if (UIManager.FirstHand.X > upAreaX - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.X < upAreaX + UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.Y > upAreaY - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.Y < upAreaY + UIManager.SUBMENU_DIAMETER / 2)
                {
                    upSelected = true;
                    leftSelected = false;
                    rightSelected = false;
                    downSelected = false;
                }
                else if (UIManager.FirstHand.X > downAreaX - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.X < downAreaX + UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.Y > downAreaY - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.Y < downAreaY + UIManager.SUBMENU_DIAMETER / 2)
                {
                    downSelected = true;
                    leftSelected = false;
                    rightSelected = false;
                    upSelected = false;
                }
                else if (UIManager.FirstHand.X > centerX - UIManager.MENU_DIAMETER / 2 && UIManager.FirstHand.X < centerX + UIManager.MENU_DIAMETER / 2 && UIManager.FirstHand.Y > centerY - UIManager.MENU_DIAMETER / 2 && UIManager.FirstHand.Y < centerY + UIManager.MENU_DIAMETER / 2)
                {
                    if (leftSelected && Groups[0].IsActive)
                    {
                        UIManager.SelectedGroup = Groups[0];
                        brush = null;
                    }
                    else if (rightSelected && Groups[1].IsActive)
                    {
                        UIManager.Clear();
                    }
                    else if (upSelected && Groups[2].IsActive)
                    {
                        brush = ((PaintColor)Groups[2]).Brush;
                    }
                    else if (downSelected && Groups[3].IsActive)
                    {
                        brush = ((PaintColor)Groups[3]).Brush;
                    }

                    leftSelected = false;
                    rightSelected = false;
                    upSelected = false;
                    downSelected = false;
                }

                CanvasUtil.DrawEllipse(c, centerX, centerY, UIManager.MENU_DIAMETER, UIManager.MENU_DIAMETER, primaryColor, fill, null);

                if (leftSelected)
                {
                    CanvasUtil.DrawEllipse(c, leftAreaX, leftAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, Groups[0].IsActive ? secondaryColor : Brushes.LightGray, fill, System.Windows.Media.Brushes.White);
                }
                else
                {
                    CanvasUtil.DrawEllipse(c, leftAreaX, leftAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, Groups[0].IsActive ? secondaryColor : Brushes.LightGray, fill, null);
                }

                if (rightSelected)
                {
                    CanvasUtil.DrawEllipse(c, rightAreaX, rightAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, Groups[1].IsActive ? secondaryColor : Brushes.LightGray, fill, Brushes.White);
                }
                else
                {
                    CanvasUtil.DrawEllipse(c, rightAreaX, rightAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, Groups[1].IsActive ? secondaryColor : Brushes.LightGray, fill, null);
                }

                if (upSelected)
                {
                    CanvasUtil.DrawEllipse(c, upAreaX, upAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, Groups[2].IsActive ? secondaryColor : Brushes.LightGray, fill, Brushes.White);
                }
                else
                {
                    CanvasUtil.DrawEllipse(c, upAreaX, upAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, Groups[2].IsActive ? secondaryColor : Brushes.LightGray, fill, null);
                }

                if (downSelected)
                {
                    CanvasUtil.DrawEllipse(c, downAreaX, downAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, Groups[3].IsActive ? secondaryColor : Brushes.LightGray, fill, Brushes.White);
                }
                else
                {
                    CanvasUtil.DrawEllipse(c, downAreaX, downAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, Groups[3].IsActive ? secondaryColor : Brushes.LightGray, fill, null);
                }

                System.Windows.Controls.Image image0 = ImageUtil.GetResourceImage("paint");
                CanvasUtil.DrawImageInCircle(c, image0, UIManager.MENU_DIAMETER, centerX, centerY);

                System.Windows.Controls.Image image1 = ImageUtil.GetResourceImage(Groups[0].Name);
                CanvasUtil.DrawImageInCircle(c, image1, UIManager.SUBMENU_DIAMETER, leftAreaX, leftAreaY);

                System.Windows.Controls.Image image2 = ImageUtil.GetResourceImage(Groups[1].Name);
                CanvasUtil.DrawImageInCircle(c, image2, UIManager.SUBMENU_DIAMETER, rightAreaX, rightAreaY);

                System.Windows.Controls.Image image3 = ImageUtil.GetResourceImage(Groups[2].Name);
                CanvasUtil.DrawImageInCircle(c, image3, UIManager.SUBMENU_DIAMETER, upAreaX, upAreaY);

                System.Windows.Controls.Image image4 = ImageUtil.GetResourceImage(Groups[3].Name);
                CanvasUtil.DrawImageInCircle(c, image4, UIManager.SUBMENU_DIAMETER, downAreaX, downAreaY);

            }
            else if (UIManager.FirstHandNumber != 0 && UIManager.FirstHand.IsSelected && !UIManager.inMenuSession)
            {
                if (!inSession)
                {
                    initialX = UIManager.FirstHand.X;
                    initialY = UIManager.FirstHand.Y;
                    inSession = true;
                    lastX = initialX;
                    lastY = initialY;
                }

                if (brush != null)
                {
                    UIManager.InPaint = true;
                    UIManager.inMenuSession = false;

                    CanvasUtil.DrawEllipse(c, UIManager.FirstHand.X, UIManager.FirstHand.Y, 40, 40, Brushes.Black, brush, brush);

                    System.Windows.Media.Brush primaryColor = ProfileManager.ActiveProfile.PrimaryColor;
                    System.Windows.Media.Brush secondaryColor = ProfileManager.ActiveProfile.SecondaryColor;
                    System.Windows.Media.Brush fill = ColorUtil.FromHTML("#88FFFFFF");

                    double centerX = initialX;
                    double centerY = initialY;

                    Point2D last = new Point2D(lastX, lastY);
                    Point2D current = new Point2D(UIManager.FirstHand.X, UIManager.FirstHand.Y);

                    if (GeometryUtil.GetDistance2D(last, current) > 50)
                    {
                        Line myLine = new Line();
                        myLine.Stroke = brush;
                        myLine.X1 = lastX;
                        myLine.X2 = UIManager.FirstHand.X;
                        myLine.Y1 = lastY;
                        myLine.Y2 = UIManager.FirstHand.Y;
                        myLine.StrokeThickness = 10;

                        UIManager.Draw(myLine);

                        lastX = UIManager.FirstHand.X;
                        lastY = UIManager.FirstHand.Y;
                    }
                }

            }
            else
            {
                inSession = false;
                UIManager.inMenuSession = false;
                leftSelected = false;
                rightSelected = false;
                upSelected = false;
                downSelected = false;
            }

            if (brush != null)
            {
                String resource = "paint_";
                if (brush.ToString().Equals("#FFFF0000"))
                {
                    resource += "red";
                }
                else if (brush.ToString().Equals("#FF0000FF"))
                {
                    resource += "blue";
                }
                else if (brush.ToString().Equals("#FF00FF00"))
                {
                    resource += "green";
                }
                else
                {
                    resource += "orange";
                }

                CanvasUtil.DrawEllipse(c, c.Width / 2, 75, 150, 150, ProfileManager.ActiveProfile.PrimaryColor, ColorUtil.FromHTML("#88FFFFFF"), Brushes.White);
                CanvasUtil.DrawImageInCircle(c, ImageUtil.GetResourceImage(resource), 150, c.Width / 2, 75);
            }
        }
Beispiel #4
0
        /// <summary>
        /// draw a circle (point) on both screens
        /// </summary>
        /// <param name="myLine"></param>
        /// <param name="stroke"></param>
        /// <param name="fill"></param>
        public static void Draw(Point2D myPoint, Brush stroke, Brush fill)
        {
            if (mainw != null)
            {

                Point2D myPoint1 = new Point2D(myPoint.X, myPoint.Y);

                myPoint1.X = myPoint.X + mainw.userCanvasWindow.canvas.Width / 2 - mainw.userCanvas.Width / 2;
                myPoint1.Y = myPoint.Y + mainw.userCanvasWindow.canvas.Height / 2 - mainw.userCanvas.Height / 2;
                CanvasUtil.DrawEllipse(mainw.userCanvasWindow.canvas, myPoint1.X, myPoint1.Y, 50, 50, stroke, fill, null, 5);

                Point2D myPoint2 = new Point2D(myPoint.X, myPoint.Y);
                myPoint2.X = myPoint1.X * mainw.presentationCanvasWindow.canvas.Width / mainw.userCanvasWindow.canvas.Width;
                myPoint2.Y = myPoint1.Y * mainw.presentationCanvasWindow.canvas.Height / mainw.userCanvasWindow.canvas.Height;

                CanvasUtil.DrawEllipse(mainw.presentationCanvasWindow.canvas, myPoint2.X, myPoint2.Y, 50, 50, stroke, fill, null, 5);
            }
        }