public RadialMenu() { this.InitializeComponent(); sbHideMainMenu.Completed += (o, a) => { }; sbShowMainMenu.Completed += (o, a) => { Arc arc = new Arc(layoutRoot.ActualWidth, layoutRoot.ActualHeight); arc.ParentMenuId = 0; arc.MenuId = 1; arc.BuildArcAwayFromCenter(DefaultOuterDiameter, defaultOuterBorderWidth, Windows.UI.Colors.Purple, -22, 22); grdButtons.Children.Add(arc); _arcs.Add(arc); arc = new Arc(layoutRoot.ActualWidth, layoutRoot.ActualHeight); arc.ParentMenuId = 0; arc.MenuId = 2; arc.BuildArcAwayFromCenter(DefaultOuterDiameter, defaultOuterBorderWidth, Windows.UI.Colors.Purple, 23, 67); grdButtons.Children.Add(arc); _arcs.Add(arc); arc = new Arc(layoutRoot.ActualWidth, layoutRoot.ActualHeight); arc.ParentMenuId = 0; arc.MenuId = 3; arc.BuildArcAwayFromCenter(DefaultOuterDiameter, defaultOuterBorderWidth, Windows.UI.Colors.Gray, 158, 202); grdButtons.Children.Add(arc); _arcs.Add(arc); }; Messenger.Default.Register<ArcMenuItemSelectedMessage>( this, DoArcMenuItemSelectedMessageCallback); }
private void DoArcMenuItemSelectedMessageCallback(ArcMenuItemSelectedMessage msg) { if (msg.Identifier != "AMS") return; if (isShowingSubMenu) { //Remove all Submenu items foreach (var arc in _arcs) { if (arc.ParentMenuId != 0) arc.Unload(); } //Show all main menu items foreach (var arc in _arcs) { if (arc.ParentMenuId == 0) arc.Visibility = Visibility.Visible; } } else { //Hide main Menu items not related to the main menu item selected foreach (var arc in _arcs) { if (arc.ParentMenuId == 0 && arc.MenuId != int.Parse(msg.Content)) arc.Visibility = Visibility.Collapsed; } //Remove all Submenu items if there are any _arcs.RemoveAll(x=>x.ParentMenuId!=0); //Get ParentArc var parentArc = _arcs.Where(x => x.MenuId == int.Parse((string)msg.Content)).First(); //show submenu if (parentArc.MenuId == 1) { double startAngle = parentArc.AngleStart; Arc arcChild = new Arc(layoutRoot.ActualWidth, layoutRoot.ActualHeight); arcChild.ParentMenuId = parentArc.MenuId; arcChild.MenuId = 10; arcChild.BuildArcTowardsCenter(DefaultOuterDiameter, 60, Windows.UI.Colors.Purple, 2, startAngle, startAngle + 44, false); grdButtons.Children.Add(arcChild); _arcs.Add(arcChild); startAngle += 44; arcChild = new Arc(layoutRoot.ActualWidth, layoutRoot.ActualHeight); arcChild.ParentMenuId = int.Parse((string)msg.Content); arcChild.MenuId = 11; arcChild.BuildArcTowardsCenter(DefaultOuterDiameter, 60, Windows.UI.Colors.Yellow, 2, startAngle + 1, startAngle + 44, false); grdButtons.Children.Add(arcChild); _arcs.Add(arcChild); startAngle += 44; arcChild = new Arc(layoutRoot.ActualWidth, layoutRoot.ActualHeight); arcChild.ParentMenuId = int.Parse((string)msg.Content); arcChild.MenuId = 12; arcChild.BuildArcTowardsCenter(DefaultOuterDiameter, 60, Windows.UI.Colors.Orange, 2, startAngle + 1, startAngle + 44, false); grdButtons.Children.Add(arcChild); _arcs.Add(arcChild); } else if (parentArc.MenuId == 2) { double startAngle = parentArc.AngleStart; Arc arcChild = new Arc(layoutRoot.ActualWidth, layoutRoot.ActualHeight); arcChild.ParentMenuId = parentArc.MenuId; arcChild.MenuId = 10; arcChild.BuildArcTowardsCenter(DefaultOuterDiameter, 60, Windows.UI.Colors.Purple, 2, startAngle, startAngle + 44, false); grdButtons.Children.Add(arcChild); _arcs.Add(arcChild); startAngle += 44; arcChild = new Arc(layoutRoot.ActualWidth, layoutRoot.ActualHeight); arcChild.ParentMenuId = int.Parse((string)msg.Content); arcChild.MenuId = 11; arcChild.BuildArcTowardsCenter(DefaultOuterDiameter, 60, Windows.UI.Colors.Purple, 2, startAngle + 1, startAngle + 44, false); grdButtons.Children.Add(arcChild); _arcs.Add(arcChild); } else if (parentArc.MenuId == 3) { double startAngle = parentArc.AngleStart; Arc arcChild = new Arc(layoutRoot.ActualWidth, layoutRoot.ActualHeight); arcChild.ParentMenuId = parentArc.MenuId; arcChild.MenuId = 10; arcChild.BuildArcTowardsCenter(DefaultOuterDiameter, 60, Windows.UI.Colors.Gray, 2, startAngle, startAngle + 44, false); grdButtons.Children.Add(arcChild); _arcs.Add(arcChild); startAngle += 44; arcChild = new Arc(layoutRoot.ActualWidth, layoutRoot.ActualHeight); arcChild.ParentMenuId = int.Parse((string)msg.Content); arcChild.MenuId = 11; arcChild.BuildArcTowardsCenter(DefaultOuterDiameter, 60, Windows.UI.Colors.Gray, 2, startAngle + 1, startAngle + 44, false); grdButtons.Children.Add(arcChild); _arcs.Add(arcChild); startAngle += 44; arcChild = new Arc(layoutRoot.ActualWidth, layoutRoot.ActualHeight); arcChild.ParentMenuId = int.Parse((string)msg.Content); arcChild.MenuId = 12; arcChild.BuildArcTowardsCenter(DefaultOuterDiameter, 60, Windows.UI.Colors.Gray, 2, startAngle + 1, startAngle + 44, false); grdButtons.Children.Add(arcChild); _arcs.Add(arcChild); startAngle += 44; arcChild = new Arc(layoutRoot.ActualWidth, layoutRoot.ActualHeight); arcChild.ParentMenuId = int.Parse((string)msg.Content); arcChild.MenuId = 13; arcChild.BuildArcTowardsCenter(DefaultOuterDiameter, 60, Windows.UI.Colors.Gray, 2, startAngle + 1, startAngle + 44, false); grdButtons.Children.Add(arcChild); _arcs.Add(arcChild); } } isShowingSubMenu = !isShowingSubMenu; }