private void CloseMenu()
 {
     if (menu != null)
     {
         menu.Show = false;
         menu      = null;
     }
 }
        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var pos = e.GetPosition(this);

            var target = GetTarget(e.Source);

            if (target != null)
            {
                CloseMenu();

                menu = target.ContextMenu as WpfCircularMenu;
                menu.ShowAt(this, pos);
            }
        }
        public CalculatorControl()
        {
            SizeChanged += MainControl_SizeChanged;
            MouseDown   += MainControl_MouseDown;
            Background   = new SolidColorBrush(Colors.White);

            var hg = RenderSize.Height;
            var wd = RenderSize.Width;

            UpdateControls();
            Children.Add(display);

            // Context menu creation
            contextMenu = new WpfCircularMenu
            {
                CloseOnSelection = true,
                CenterRadius     = 20,
                RingSize         = 50,
                Items            = new List <WpfCircularMenuItem>()
                {
                    new WpfCircularMenuItem
                    {
                        Text                 = "Left",
                        TargetAngle          = Math.PI,
                        TargetSize           = Math.PI / 6,
                        ShapeBackgroundColor = Colors.Yellow.WinColor(),
                        Command              = Option1
                    },
                    new WpfCircularMenuItem
                    {
                        Text = "Rojo",
                        ShapeBackgroundColor = Colors.Red.WinColor(),
                        Command = Option1
                    },
                    new WpfCircularMenuItem
                    {
                        Text = "Verde",
                        ShapeBackgroundColor = Colors.Green.WinColor(),
                        Command = Option1
                    },
                    new WpfCircularMenuItem
                    {
                        Text = "Azul",
                        ShapeBackgroundColor = Colors.Blue.WinColor(),
                        Command = Option1
                    },
                    new WpfCircularMenuItem
                    {
                        Text                 = "Top",
                        TargetAngle          = Math.PI / 2,
                        TargetSize           = Math.PI / 6,
                        ShapeBackgroundColor = Colors.Yellow.WinColor(),
                        Command              = Option1
                    },
                    new WpfCircularMenuItem
                    {
                        Text                 = "Right",
                        TargetAngle          = 0,
                        TargetSize           = Math.PI / 6,
                        ShapeBackgroundColor = Colors.Yellow.WinColor(),
                        Command              = Option1
                    },
                }
            };
        }