Example #1
0
        private void RevertImage(Grid gd, string key)
        {
            KMenuItem item = gd.Tag as KMenuItem;

            foreach (UIElement ui in gd.Children)
            {
                if (ui is Image)
                {
                    Image img = ui as Image;
                    img.SetImage(item.Icon + key);
                    break;
                }
            }
        }
Example #2
0
        void gdItem_TouchUp(object sender, TouchEventArgs e)
        {
            Grid gd = sender as Grid;

            this.RevertImage(gd, "_on.png");
            KMenuItem item = gd.Tag as KMenuItem;

            this.ChangeStatus(this.gdOpen);
            if (this.FireEvent != null)
            {
                KMenuArgs arg = new KMenuArgs(item.Id);
                this.FireEvent(this, arg);
            }
        }
Example #3
0
        public void Render()
        {
            Point  rendreSize   = GetRenderSize();
            double yCenter      = this.RenderOrientation == LayoutOrirentation.Bottom ? 0 : rendreSize.Y;
            Point  centerP      = new Point(rendreSize.X / 2, yCenter);
            double itemRadius   = rendreSize.X / 10;
            double centerRadius = itemRadius * 0.84;
            Brush  centerColor  = this.CenterColor == null ? Brushes.BurlyWood : this.CenterColor;

            EllipseGeometry centerClip = new EllipseGeometry(new Point(centerRadius, centerRadius), centerRadius, centerRadius);

            this.gdOpen = this.GetItemContainer(centerRadius, centerClip, centerColor);
            gdOpen.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            gdOpen.VerticalAlignment   = this.RenderOrientation == LayoutOrirentation.Bottom ? VerticalAlignment.Top : VerticalAlignment.Bottom;
            KMenuItem cancelItem = new KMenuItem("cancel", "cancel");

            gdOpen.Tag = cancelItem;
            gdOpen.MouseLeftButtonUp += gdOpen_MouseLeftButtonUp;
            gdOpen.Loaded            += gdOpen_Loaded;
            Image centerIcon = this.GetItemIcon(cancelItem.Icon + "_on.png");

            gdOpen.Children.Add(centerIcon);

            this.gdRoot.Children.Add(gdOpen);

            if (this.Items.Count > 1)
            {
                EllipseGeometry clip = new EllipseGeometry(new Point(itemRadius, itemRadius), itemRadius, itemRadius);

                Brush foreground = this.ItemColor == null ? Brushes.BurlyWood : this.ItemColor;
                this.cvsRoot.Children.Clear();

                double radius = itemRadius * 4;

                bool   isOdd = this.Items.Count % 2 == 1;
                double angle = Math.PI / (isOdd ? (this.Items.Count - 1) : (this.Items.Count + 1));
                for (int i = 0; i < this.Items.Count; i++)
                {
                    int    angleIndex = isOdd ? i : (i + 1);
                    double itemAngle  = angle * angleIndex + Math.PI;
                    double xpos       = radius * Math.Cos(itemAngle);
                    double ypos       = radius * Math.Sin(itemAngle);
                    Grid   gdItem     = GetItemContainer(itemRadius, clip, foreground);


                    gdItem.Tag = this.Items[i];

                    Image img = GetItemIcon(this.Items[i].Icon + "_on.png");
                    gdItem.Children.Add(img);

                    //TextBlock txt = new TextBlock();
                    //txt.Text = this.Items[i].Title;
                    //txt.Foreground = Brushes.White;
                    //txt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    //txt.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
                    //txt.Margin = new Thickness(0, 0, 0, 10);
                    //gdItem.Children.Add(txt);

                    //gdItem.TouchDown += gdItem_TouchDown;
                    //gdItem.TouchUp += gdItem_TouchUp;
                    //gdItem.TouchLeave += gdItem_TouchLeave;

                    gdItem.MouseLeftButtonDown += gdItem_MouseLeftButtonDown;
                    gdItem.MouseLeftButtonUp   += gdItem_MouseLeftButtonUp;
                    gdItem.MouseLeave          += gdItem_MouseLeave;

                    Canvas.SetLeft(gdItem, centerP.X + xpos - itemRadius);
                    double yPosWithRender = this.RenderOrientation == LayoutOrirentation.Bottom ? centerP.Y - ypos : centerP.Y + ypos - gdItem.Height;
                    Canvas.SetTop(gdItem, yPosWithRender);

                    this.cvsRoot.Children.Add(gdItem);
                    _rotShowStbs.Add(BuildRotAnimation(gdItem, -240, 0));
                    _rotHideStbs.Add(BuildRotAnimation(gdItem, 0, -240));
                }
            }
        }