Example #1
0
        public void When_command_is_explicitly_set_on_menu_item_data_should_not_try_to_resolve_command_by_name_from_IoC()
        {
            MockRepository mocks = new MockRepository();
            MenuItemData   mid   = new MenuItemData {
                CommandName = "test"
            };

            IWindsorContainer container = mocks.CreateMock <IWindsorContainer>();
            ICommand          command   = mocks.Stub <ICommand>();

            mid.Command = command;

            using (mocks.Record())
            {
                Expect.Call(container.Resolve <ICommand>("test")).Repeat.Never();
            }

            using (mocks.Playback())
            {
                using (IoC.UseLocalContainer(container))
                {
                    Assert.AreSame(command, mid.Command);
                }
            }
        }
Example #2
0
        public void MenuItem(string itemText, Action itemSelected)
        {
            if (m_currentMenu == null)
            {
                return;
            }

            // menu isn't open, don't worry about items
            if (m_activeWidget == null ||
                m_activeWidget.Value != new WidgetId(m_currentMenu.Title, WidgetId.ParentKind.MenuBar))
            {
                return;
            }

            var id = new WidgetId($"{ m_currentMenu.Title }|{ itemText }", WidgetId.ParentKind.MenuBar);

            if (!m_currentMenu.MenuItems.TryGetValue(id, out var item))
            {
                item = new MenuItemData(itemText);
                m_currentMenu.MenuItems[id] = item;
            }

            item.UsedThisFrame = true;
            item.Callback      = itemSelected;
            item.Index         = m_currentMenu.CurrentMenuItemIndex++;
        }
Example #3
0
 private void SetData(MenuItemData data)
 {
     //icon = info.icon;
     icon.sprite        = data.icon;
     normalIconColor    = data.iconNormalColor;
     highlightIconColor = data.iconHighlightColor;
     option             = data.menuOption;
 }
Example #4
0
        private void MenuItemTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            FrameworkElement frameworkElement = sender as FrameworkElement;
            DependencyObject dependencyObject = (DependencyObject)frameworkElement;

            while (!(dependencyObject is ContextMenu))
            {
                dependencyObject = VisualTreeHelper.GetParent(dependencyObject);
            }
            ContextMenu contextMenu = dependencyObject as ContextMenu;
            int         num         = 0;

            contextMenu.IsOpen = num != 0;
            ConversationHeader dataContext1 = ((FrameworkElement)contextMenu).DataContext as ConversationHeader;

            if (!(frameworkElement.DataContext is MenuItemData))
            {
                return;
            }
            MenuItemData dataContext2 = frameworkElement.DataContext as MenuItemData;

            if (dataContext2.Tag == "delete" && MessageBox.Show(CommonResources.Conversation_ConfirmDeletion, CommonResources.Conversation_DeleteDialog, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                ConversationsViewModel.Instance.DeleteConversation(dataContext1);
            }
            if (dataContext2.Tag == "disableEnable")
            {
                ConversationsViewModel.Instance.SetInProgressMain(true, "");
                dataContext1.DisableEnableNotifications((Action <bool>)(res => Execute.ExecuteOnUIThread((Action)(() =>
                {
                    ConversationsViewModel.Instance.SetInProgressMain(false, "");
                    if (res)
                    {
                        return;
                    }
                    ExtendedMessageBox.ShowSafe(CommonResources.Error);
                }))));
            }
            if (!(dataContext2.Tag == "messagesFromGroup") || dataContext1 == null)
            {
                return;
            }
            ConversationsViewModel.Instance.SetInProgressMain(true, "");
            dataContext1.AllowDenyMessagesFromGroup((Action <bool>)(res => Execute.ExecuteOnUIThread((Action)(() =>
            {
                ConversationsViewModel.Instance.SetInProgressMain(false, "");
                if (res)
                {
                    return;
                }
                ExtendedMessageBox.ShowSafe(CommonResources.Error);
            }))));
        }
        /// <summary>
        /// Generic method to navigate to a menu item target
        /// </summary>
        /// <param name="menuItem">Selected menu item</param>
        public void NavigateTo(MenuItemData menuItem)
        {
            var rootFrame = Application.Current.RootVisual as PhoneApplicationFrame;

            if (menuItem.Target != null)
            {
                rootFrame.Navigate(new Uri(menuItem.Target, UriKind.Relative));
            }
            else if (menuItem.TargetUrl != null)
            {
                NavigateTo(new Uri(menuItem.TargetUrl));
            }
        }
		public void WillAddMenuItemToMenuStrip()
		{
			Form f = new Form();
			
			MenuStrip ms = new MenuStrip();
			f.Controls.Add(ms);
			ms.Name = "MainMenu";
			MenuItemData data = new MenuItemData();
			data.Parent = "MainMenu";
			
			MenuExtensions.AddMenuItem(f, data);
			Assert.AreEqual(1, ms.Items.Count);
		}
Example #7
0
        /// <summary>
        /// Add menu item
        /// </summary>
        /// <param name="data">menu item data</param>
        internal void AddItem(MenuItemData data)
        {
            var menuItem = new MenuItem();

            menuItem.Header     = data.Text;
            menuItem.Click     += data.Click;
            menuItem.Tag        = data;
            menuItem.FontFamily = new FontFamily(data.FontName);
            menuItem.FontSize   = data.FontSize;
            menuItem.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(data.ForeGround));

            this._menuItems.Add(data.Id, menuItem);
            this.Items.Add(menuItem);
        }
Example #8
0
        public void WillAddMenuItemToMenuStrip()
        {
            Form f = new Form();

            MenuStrip ms = new MenuStrip();

            f.Controls.Add(ms);
            ms.Name = "MainMenu";
            MenuItemData data = new MenuItemData();

            data.Parent = "MainMenu";

            MenuExtensions.AddMenuItem(f, data);
            Assert.AreEqual(1, ms.Items.Count);
        }
Example #9
0
        protected override void OnClick(MenuItemData target)
        {
            if (target.Type == "decompose")
            {
                var equipConfig = ConfigDatas.ConfigData.GetEquipConfig(UserProfile.InfoEquip.Equipoff[EquipIndex]);
                MainForm.Instance.AddTip(string.Format("|分解装备-|{0}|{1}", HSTypes.I2QualityColor(equipConfig.Quality), equipConfig.Name), "White");
                UserProfile.Profile.InfoBag.AddResource(GameResourceType.Stone, GameResourceBook.GetStoneEquipDecompose(equipConfig.Quality, equipConfig.Level));

                UserProfile.InfoEquip.Equipoff[EquipIndex] = 0;
            }
            else
            {
                return;
            }
            Form.MenuRefresh(EquipIndex);
        }
Example #10
0
        protected override void OnClick(MenuItemData target)
        {
            if (target.Type == "decompose")
            {
                var equipConfig = ConfigDatas.ConfigData.GetEquipConfig(UserProfile.InfoEquip.Equipoff[EquipIndex].BaseId);
                MainTipManager.AddTip(string.Format("|分解装备-|{0}|{1}", HSTypes.I2QualityColor(equipConfig.Quality), equipConfig.Name), "White");
                UserProfile.Profile.InfoBag.AddResource(GameResourceType.Stone, GameResourceBook.InStoneEquipDecompose(equipConfig.Quality, equipConfig.Level));

                UserProfile.InfoEquip.Equipoff[EquipIndex] = new DbEquip();
            }
            else
            {
                return;
            }
            Form.MenuRefresh(EquipIndex);
        }
		public void WillAddMenuItemToToolStripMenuItem()
		{
			Form f = new Form();

			MenuStrip ms = new MenuStrip();
			f.Controls.Add(ms);
			ms.Name = "MainMenu";
			ToolStripMenuItem item = new ToolStripMenuItem();
			item.Name = "Help";
			ms.Items.Add(item);
			MenuItemData data = new MenuItemData();
			data.Parent = "Help";

			MenuExtensions.AddMenuItem(f, data);
			Assert.AreEqual(1, item.DropDownItems.Count);
		}
Example #12
0
 protected override void OnClick(MenuItemData target)
 {
     if (target.Type == "activate")
     {
         int result = UserProfile.InfoCard.SelectedDeck.AddCard(TargetCard);
         if (result != HSErrorTypes.OK)
         {
             Form.AddFlowCenter(HSErrorTypes.GetDescript(result), "Red");
         }
         else
         {
             Form.ActivateCard();
         }
     }
     else if (target.Type == "remove")
     {
         UserProfile.InfoCard.SelectedDeck.RemoveCardById(TargetCard.BaseId);
         Form.ActivateCard();
     }
     else if (target.Type == "delete")
     {
         if (UserProfile.InfoCard.GetCardExp(TargetCard.BaseId) <= 0)
         {
             Form.AddFlowCenter(HSErrorTypes.GetDescript(HSErrorTypes.CardExpNotEnough), "Red");
         }
         else if (MessageBoxEx2.Show("确定要分解多余的碎片?") == DialogResult.OK)
         {
             UserProfile.InfoCard.RemoveCardPiece(TargetCard.BaseId, true);
         }
     }
     else if (target.Type == "levelup")
     {
         if (!UserProfile.InfoCard.CanLevelUp(TargetCard.BaseId))
         {
             Form.AddFlowCenter(HSErrorTypes.GetDescript(HSErrorTypes.CardExpNotEnough), "Red");
         }
         else if (MessageBoxEx2.Show("确定消耗所有碎片提升等级?") == DialogResult.OK)
         {
             UserProfile.InfoCard.CardLevelUp(TargetCard.BaseId);
         }
     }
     else
     {
         return;
     }
     Form.MenuRefresh(false);
 }
Example #13
0
 protected override void OnClick(MenuItemData target)
 {
     if (target.Type == "activate")
     {
         int result = UserProfile.InfoCard.SelectedDeck.AddCard(TargetCard);
         if (result != HSErrorTypes.OK)
         {
             Form.AddFlowCenter(HSErrorTypes.GetDescript(result), "Red");
         }
         else
         {
             Form.ActivateCard();
         }
     }
     else if (target.Type == "remove")
     {
         UserProfile.InfoCard.SelectedDeck.RemoveCardById(TargetCard.BaseId);
         Form.ActivateCard();
     }
     else if (target.Type == "delete")
     {
         if (UserProfile.InfoCard.GetCardExp(TargetCard.BaseId) <= 0)
         {
             Form.AddFlowCenter(HSErrorTypes.GetDescript(HSErrorTypes.CardExpNotEnough), "Red");
         }
         else if (MessageBoxEx2.Show("确定要分解多余的碎片?") == DialogResult.OK)
         {
             UserProfile.InfoCard.RemoveCardPiece(TargetCard.BaseId, true);
         }
     }
     else if (target.Type == "levelup")
     {
         if (!UserProfile.InfoCard.CanLevelUp(TargetCard.BaseId))
         {
             Form.AddFlowCenter(HSErrorTypes.GetDescript(HSErrorTypes.CardExpNotEnough), "Red");
         }
         else if (MessageBoxEx2.Show("确定消耗所有碎片提升等级?") == DialogResult.OK)
         {
             UserProfile.InfoCard.CardLevelUp(TargetCard.BaseId);
         }
     }
     else
     {
         return;
     }
     Form.MenuRefresh(false);
 }
    private void InstantiateMenuItems()
    {
        for (int i = 0; i < itemCount; i++)
        {
            RadialMenuItem item = Instantiate(menuItemPrefab) as RadialMenuItem;
            item.transform.SetParent(radialMenu.transform, false);
            float fillAmount = (float)(360f / itemCount) / 360f;
            float angle      = (360f / itemCount) * i;
            item.image.fillAmount = fillAmount;
            // setup icon image and color

            MenuItemData data = GetMenuItemData(i);
            item.InitializeItem(data);
            item.transform.Rotate(Quaternion.AngleAxis(angle, Vector3.forward).eulerAngles);
            items[i] = item;
        }
    }
Example #15
0
        private void InitMenuViewData(ActionExecutingContext filterContext)
        {
            MenuViewData menuViewData = new MenuViewData();
            User         user         = this._cuyahogaContext.CurrentUser;

            if (user != null && user.IsAuthenticated)
            {
                var       nodes       = this._sitemapProvider.GetMvcChildNodes(this._sitemapProvider.RootNode);
                var       currentNode = this._sitemapProvider.CurrentNode;
                UrlHelper urlHelper   = new UrlHelper(filterContext.RequestContext);

                // mainmenu
                foreach (MvcSiteMapNode node in nodes)
                {
                    if (this._sitemapProvider.IsAccessibleToUser(filterContext.HttpContext, node, this._cuyahogaContext.CurrentSite))
                    {
                        MenuItemData menuItemData = GenerateMenuItemFromSiteMapNode(filterContext, node, currentNode, urlHelper);
                        bool         isSystem     = Convert.ToBoolean(node["system"]);
                        if (isSystem)
                        {
                            menuViewData.AddOptionalMenuItem(menuItemData);
                        }
                        else
                        {
                            menuViewData.AddStandardMenuItem(menuItemData);
                        }
                        if (node.HasChildNodes)
                        {
                            foreach (var childNode in node.ChildNodes)
                            {
                                MvcSiteMapNode mvcChildNode = childNode as MvcSiteMapNode;
                                if (mvcChildNode != null)
                                {
                                    if (this._sitemapProvider.IsAccessibleToUser(filterContext.HttpContext, mvcChildNode,
                                                                                 this._cuyahogaContext.CurrentSite))
                                    {
                                        menuItemData.AddChildMenuItem(GenerateMenuItemFromSiteMapNode(filterContext, mvcChildNode, currentNode, urlHelper));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            filterContext.Controller.ViewData.Add("MenuViewData", menuViewData);
        }
		public void WillThrowIfFindUknownMenuType()
		{
			Form f = new Form();

			TrackBar value = new TrackBar();
			f.Controls.Add(value);
			Control community = new TrackBar();
			community.Name = "Community";
			value.Controls.Add(community);

			MenuItemData data = new MenuItemData();
			data.Parent = "Community";

			MenuExtensions.AddMenuItem(f, data);
			Assert.AreEqual(1, value.Controls.Count);
	
		}
Example #17
0
        static List <MenuItemData> GetSortedMenuItems(UnityEngine.GameObject[] targets)
        {
            var menus    = Unsupported.GetSubmenus("Component");
            var commands = Unsupported.GetSubmenusCommands("Component");

            var          menuItems       = new List <MenuItemData>(menus.Length);
            var          legacyMenuItems = new List <MenuItemData>(menus.Length);
            const string kLegacyString   = "legacy";

            var hasFilterOverride = ModeService.HasExecuteHandler("inspector_filter_component");

            for (var i = 0; i < menus.Length; i++)
            {
                var  menuPath = menus[i];
                bool isLegacy = menuPath.ToLower().Contains(kLegacyString);
                var  item     = new MenuItemData
                {
                    path     = menuPath,
                    command  = commands[i],
                    isLegacy = isLegacy
                };

                if (!hasFilterOverride || ModeService.Execute("inspector_filter_component", targets, menuPath))
                {
                    if (isLegacy)
                    {
                        legacyMenuItems.Add(item);
                    }
                    else
                    {
                        menuItems.Add(item);
                    }
                }
            }

            int comparison(MenuItemData x, MenuItemData y) => string.CompareOrdinal(x.path, y.path);

            menuItems.Sort(comparison);
            legacyMenuItems.Sort(comparison);

            menuItems.AddRange(legacyMenuItems);

            return(menuItems);
        }
    // Use this for initialization
    void Start()
    {
        input     = InputManager.Instance;
        itemCount = menuItems.Length;
        items     = new RadialMenuItem[itemCount];

        radius = radialMenu.GetComponent <RectTransform>().rect.size.x / 2f;

        HideMenu();

        originalScale      = radialMenu.transform.localScale;
        itemInfoDictionary = new Dictionary <int, MenuItemData>(itemCount);
        for (int i = 0; i < itemCount; i++)
        {
            MenuItemData data   = menuItems[i];
            MenuOption   option = data.menuOption;
            AddMenuItemData(data.menuOption, data);
        }
    }
Example #19
0
 private void OptionsButtonTap(object sender, System.Windows.Input.GestureEventArgs e)
 {
     if (this.TapCallback != null)
     {
         this.TapCallback();
         e.Handled = true;
     }
     else
     {
         ISupportMenuActions dataContext = base.DataContext as ISupportMenuActions;
         if (dataContext == null)
         {
             return;
         }
         List <MenuItemData> menuItemsData = dataContext.GetMenuItemsData();
         List <MenuItem>     menuItems     = new List <MenuItem>();
         if (menuItemsData != null)
         {
             using (List <MenuItemData> .Enumerator enumerator = menuItemsData.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     MenuItemData m        = enumerator.Current;
                     MenuItem     menuItem = new MenuItem
                     {
                         Header = m.Title
                     };
                     menuItem.Click += delegate(object s, RoutedEventArgs ev)
                     {
                         m.OnTap.Invoke();
                     };
                     menuItems.Add(menuItem);
                 }
             }
             if (menuItems.Count > 0)
             {
                 this.SetMenu(menuItems);
                 this.ShowMenu();
             }
         }
         e.Handled = true;
     }
 }
		public void WillAddMenuItemToMenu_WhenParentIsNestedMenuItem()
		{
			Form f = new Form();

			MenuStrip ms = new MenuStrip();
			f.Controls.Add(ms);
			ms.Name = "MainMenu";
			ToolStripMenuItem item = new ToolStripMenuItem();
			item.Name = "Help";
			ms.Items.Add(item);
			ToolStripMenuItem community = new ToolStripMenuItem();
			community .Name = "Community";
			item.DropDownItems.Add(community);
			MenuItemData data = new MenuItemData();
			data.Parent = "Community";

			MenuExtensions.AddMenuItem(f, data);
			Assert.AreEqual(1, community.DropDownItems.Count);
		}
Example #21
0
        public void WillThrowIfFindUknownMenuType()
        {
            Form f = new Form();

            TrackBar value = new TrackBar();

            f.Controls.Add(value);
            Control community = new TrackBar();

            community.Name = "Community";
            value.Controls.Add(community);

            MenuItemData data = new MenuItemData();

            data.Parent = "Community";

            MenuExtensions.AddMenuItem(f, data);
            Assert.AreEqual(1, value.Controls.Count);
        }
Example #22
0
        public void WillAddMenuItemToToolStripMenuItem()
        {
            Form f = new Form();

            MenuStrip ms = new MenuStrip();

            f.Controls.Add(ms);
            ms.Name = "MainMenu";
            ToolStripMenuItem item = new ToolStripMenuItem();

            item.Name = "Help";
            ms.Items.Add(item);
            MenuItemData data = new MenuItemData();

            data.Parent = "Help";

            MenuExtensions.AddMenuItem(f, data);
            Assert.AreEqual(1, item.DropDownItems.Count);
        }
Example #23
0
 protected override void OnClick(MenuItemData target)
 {
     if (target.Type == "use")
     {
         UserProfile.InfoBag.UseItemByPos(ItemIndex, HItemTypes.Common);
     }
     else if (target.Type == "throw")
     {
         UserProfile.InfoBag.ClearItemAllByPos(ItemIndex);
     }
     else if (target.Type == "sold")
     {
         UserProfile.InfoBag.SellItemAllByPos(ItemIndex);
     }
     else
     {
         return;
     }
     Form.MenuRefresh();
 }
Example #24
0
 protected override void OnClick(MenuItemData target)
 {
     if (target.Type == "use")
     {
         UserProfile.InfoBag.UseItemByPos(ItemIndex, HItemTypes.Common);
     }
     else if (target.Type == "throw")
     {
         UserProfile.InfoBag.ClearItemAllByPos(ItemIndex);
     }
     else if (target.Type == "sold")
     {
         UserProfile.InfoBag.SellItemAllByPos(ItemIndex);
     }
     else
     {
         return;
     }
     Form.MenuRefresh();
 }
        private void MenuItemFindGenericRef_Click(object sender, RoutedEventArgs e)
        {
            string       guid      = "";
            MenuItemData MenuData  = (sender as MenuItemData);
            IBasicData   basicData = MenuData.Data;

            for (int i = 0; i < basicData.Attributes.Count; i++)
            {
                if ((string)MenuData.Tag == basicData.Attributes[i].Name)
                {
                    guid = basicData.Attributes[i].Value;
                    break;
                }
            }
            if (!string.IsNullOrEmpty(guid))
            {
                //core.SearchItemFromGuidRef(core.ListPrimaryItens, guid);
                core.FindByGuid(core.ListPrimaryItens.Childrens, guid);
            }
        }
Example #26
0
        private static void AddMenuItemInternal(object parent, MenuItemData itemData)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent", "Could not find parent [" + itemData.Parent + "] for " + itemData.Command);
            }

            ToolStripMenuItem item = new ToolStripMenuItem(itemData.Text);

            if (itemData.ShortcutKey != null)
            {
                item.ShortcutKeys = itemData.ShortcutKey.Value;
            }
            item.Name = itemData.Name;
            if (string.IsNullOrEmpty(itemData.Command) == false)
            {
                item.Click += delegate { Commands.Dispatch(itemData.Command); };
            }
            GetMenuAdderFor(parent.GetType()).DynamicInvoke(parent, item);
        }
Example #27
0
        private void MenuItemTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            FrameworkElement frameworkElement = sender as FrameworkElement;
            DependencyObject dependencyObject = (DependencyObject)frameworkElement;

            while (!(dependencyObject is ContextMenu))
            {
                dependencyObject = VisualTreeHelper.GetParent(dependencyObject);
            }
            ContextMenu contextMenu = dependencyObject as ContextMenu;
            int         num         = 0;

            contextMenu.IsOpen = num != 0;
            ConversationHeader dataContext1 = ((FrameworkElement)contextMenu).DataContext as ConversationHeader;

            if (!(frameworkElement.DataContext is MenuItemData))
            {
                return;
            }
            MenuItemData dataContext2 = frameworkElement.DataContext as MenuItemData;

            if (dataContext2.Tag == "delete")
            {
                this.DeleteConversation(dataContext1);
            }
            if (!(dataContext2.Tag == "disableEnable"))
            {
                return;
            }
            this.ConversationsVM.SetInProgressMain(true, "");
            dataContext1.DisableEnableNotifications((Action <bool>)(res => Execute.ExecuteOnUIThread((Action)(() =>
            {
                this.ConversationsVM.SetInProgressMain(false, "");
                if (res)
                {
                    return;
                }
                ExtendedMessageBox.ShowSafe(CommonResources.Error);
            }))));
        }
Example #28
0
        static List <MenuItemData> GetSortedMenuItems()
        {
            var menus    = Unsupported.GetSubmenus("Component");
            var commands = Unsupported.GetSubmenusCommands("Component");

            var          menuItems       = new List <MenuItemData>(menus.Length);
            var          legacyMenuItems = new List <MenuItemData>(menus.Length);
            const string kLegacyString   = "legacy";

            for (var i = 0; i < menus.Length; i++)
            {
                var  menuPath = menus[i];
                bool isLegacy = menuPath.ToLower().Contains(kLegacyString);
                var  item     = new MenuItemData
                {
                    path     = menuPath,
                    command  = commands[i],
                    isLegacy = isLegacy
                };

                if (isLegacy)
                {
                    legacyMenuItems.Add(item);
                }
                else
                {
                    menuItems.Add(item);
                }
            }

            int comparison(MenuItemData x, MenuItemData y) => string.CompareOrdinal(x.path, y.path);

            menuItems.Sort(comparison);
            legacyMenuItems.Sort(comparison);

            menuItems.AddRange(legacyMenuItems);

            return(menuItems);
        }
Example #29
0
 static void CheckInitAllMenuItems()
 {
     if (s_allMenuItems == null || s_allMenuItems.Count == 0)
     {
         var items = SearchAllMenuItems();
         s_allMenuItems = s_allMenuItems ?? new SortedDictionary <String, MenuItemData>();
         s_allMenuItems.Clear();
         var assemblies = new HashSet <String>();
         for (int i = 0; i < items.Count; ++i)
         {
             var item         = new MenuItemData();
             var assemblyName = items[i].Value;
             assemblies.Add(assemblyName);
             s_allMenuItems.Add(items[i].Key, item);
             item.menuItemPath = items[i].Key;
             item.Init();
         }
         s_assemblies = assemblies.ToList();
         s_assemblies.Sort();
         Load();
     }
 }
Example #30
0
        public void WillAddMenuItemToMenu_WhenParentIsNestedMenuItem()
        {
            Form f = new Form();

            MenuStrip ms = new MenuStrip();

            f.Controls.Add(ms);
            ms.Name = "MainMenu";
            ToolStripMenuItem item = new ToolStripMenuItem();

            item.Name = "Help";
            ms.Items.Add(item);
            ToolStripMenuItem community = new ToolStripMenuItem();

            community.Name = "Community";
            item.DropDownItems.Add(community);
            MenuItemData data = new MenuItemData();

            data.Parent = "Community";

            MenuExtensions.AddMenuItem(f, data);
            Assert.AreEqual(1, community.DropDownItems.Count);
        }
Example #31
0
        public void When_command_is_not_specifid_should_try_to_resolve_command_instance_from_IoC_container()
        {
            MockRepository mocks = new MockRepository();
            MenuItemData   mid   = new MenuItemData {
                CommandName = "test"
            };

            IWindsorContainer container = mocks.Stub <IWindsorContainer>();
            ICommand          command   = mocks.Stub <ICommand>();

            using (mocks.Record())
            {
                SetupResult.For(container.Resolve <ICommand>("test")).Return(command);
            }

            using (mocks.Playback())
            {
                using (IoC.UseLocalContainer(container))
                {
                    Assert.AreSame(command, mid.Command);
                }
            }
        }
Example #32
0
        private static void OnSelect(object userdata)
        {
            MenuItemData data = (MenuItemData)userdata;

            data.m_Rule.m_RuleTransform = data.m_NewValue;
        }
    static void OnSelect(object userdata)
    {
        MenuItemData data = (MenuItemData)userdata;

        data.Rule.AutoTransform = data.NewValue;
    }
		private static void AddMenuItemInternal(object parent, MenuItemData itemData)
		{
			if (parent == null)
				throw new ArgumentNullException("parent", "Could not find parent [" + itemData.Parent + "] for " + itemData.Command);

			ToolStripMenuItem item = new ToolStripMenuItem(itemData.Text);
			if (itemData.ShortcutKey != null)
				item.ShortcutKeys = itemData.ShortcutKey.Value;
			item.Name = itemData.Name;
			if (string.IsNullOrEmpty(itemData.Command) == false)
			{
				item.Click += delegate { Commands.Dispatch(itemData.Command); };
			}
			GetMenuAdderFor(parent.GetType()).DynamicInvoke(parent, item);
		}
        private void GenerateContextMenu(TreeViewItemData treeViewItemData)
        {
            //ContextMenu contextMenu = new ContextMenu();
            //contextMenu.AddHandler(ContextMenu.ContextMenuOpeningEvent, new ContextMenuEventHandler(ContextMenu_ContextMenuOpening));

            // itens que não precisão do app
            //if (!string.IsNullOrEmpty(treeViewItemData.Data.GuidRef))
            //{
            //    MenuItemData menuItem = new MenuItemData();
            //    menuItem.Data = treeViewItemData.Data;
            //    menuItem.Header = "Find Ref Item";
            //    menuItem.Click += MenuFindRef_Click;
            //    contextMenu.Items.Add(menuItem);


            //}
            //if (!string.IsNullOrEmpty(treeViewItemData.Data.Guid))
            //{
            //    MenuItemData menuItem = new MenuItemData();
            //    menuItem.Data = treeViewItemData.Data;
            //    menuItem.Header = "Copy Guid";
            //    menuItem.Icon = new System.Windows.Controls.Image() { Source = dataContext.CopyMenuItemImg };
            //    menuItem.Click += MenuCopyGuid_Click;
            //    contextMenu.Items.Add(menuItem);


            //}
            if (treeViewItemData.Data.ContainsAttribute("captionRef"))
            {
                MenuItemData menuItem = new MenuItemData();
                menuItem.Data   = treeViewItemData.Data;
                menuItem.Header = "Find Caption Ref";
                menuItem.Click += MenuItemFindCaptionRef_Click;
                //contextMenu.Items.Add(menuItem);
            }
            //if (treeViewItemData.Data.ContainsAttribute("itemRef"))
            //{
            //    MenuItemData menuItem = new MenuItemData();
            //    menuItem.Data = treeViewItemData.Data;
            //    menuItem.Header = "Find Item Ref";
            //    menuItem.Click += MenuItemFindCaptionRef_Click;
            //    contextMenu.Items.Add(menuItem);
            //}
            for (int i = 0; i < treeViewItemData.Data.Attributes.Count; i++)
            {
                DataClass.Attribute att = treeViewItemData.Data.Attributes[i];
                if (att.Name != "captionRef" && att.Name != "guid" && att.Name != "guidRef" && att.IsGuid)
                {
                    MenuItemData menuItem = new MenuItemData();
                    menuItem.Data   = treeViewItemData.Data;
                    menuItem.Header = string.Format("Find {0}", att.Name);
                    menuItem.Tag    = att.Name;
                    menuItem.Click += MenuItemFindGenericRef_Click;
                    //contextMenu.Items.Add(menuItem);
                }
            }


            //MenuItemData menuItem4 = new MenuItemData();
            //menuItem4.Data = treeViewItemData.Data;
            //menuItem4.Header = "Xml";
            //menuItem4.Click += MenuItemXmlEncode_Click;
            //contextMenu.Items.Add(menuItem4);

            //if (!dataContext.InCorel)
            //    return contextMenu;



            //MenuItemData menuItem2 = new MenuItemData();
            //menuItem2.Data = treeViewItemData.Data;
            //menuItem2.Header = "Try Get Caption Text";
            //menuItem2.Click += MenuItemGetCaptionText_Click;
            //contextMenu.Items.Add(menuItem2);

            //MenuItemData menuItem6 = new MenuItemData();
            //menuItem6.Data = treeViewItemData.Data;
            //menuItem6.Header = "Try highlight this";
            //menuItem6.Click += MenuItemTryHighlight_Click;
            //menuItem6.Icon = new System.Windows.Controls.Image() { Source = dataContext.HighLightButtonImg };
            //contextMenu.Items.Add(menuItem6);

            //if (treeViewItemData.Data.GetType() == typeof(DataClass.CommandBarData))
            //{
            //    MenuItemData menuItem = new MenuItemData();
            //    menuItem.Data = treeViewItemData.Data;
            //    menuItem.Header = "Try Show Command Bar";
            //    menuItem.Click += MenuItemshowCommandBar_Click;
            //    contextMenu.Items.Add(menuItem);

            //    MenuItemData menuItem3 = new MenuItemData();
            //    menuItem3.Data = treeViewItemData.Data;
            //    menuItem3.Header = "Try Hide Command Bar";
            //    menuItem3.Click += MenuItemHideCommandBar_Click;
            //    contextMenu.Items.Add(menuItem3);

            //    MenuItemData menuItem5 = new MenuItemData();
            //    menuItem5.Data = treeViewItemData.Data;
            //    menuItem5.Header = "Command Bar Mode";
            //    menuItem5.Click += MenuItemCommandBarMode_Click;
            //    contextMenu.Items.Add(menuItem5);

            //}
            //if (treeViewItemData.Data.GetType() == typeof(DataClass.OtherData))
            //{
            //    MenuItemData menuItem = new MenuItemData();
            //    menuItem.Data = treeViewItemData.Data;
            //    menuItem.Header = "Try Show this";
            //    menuItem.Click += MenuItemshowItem_Click;
            //    contextMenu.Items.Add(menuItem);
            //}
            //if (treeViewItemData.Data.GetType() == typeof(DataClass.DialogData))
            //{
            //    MenuItemData menuItem = new MenuItemData();
            //    menuItem.Data = treeViewItemData.Data;
            //    menuItem.Header = "Try Show Dialog";
            //    menuItem.Click += MenuItemshowDialog_Click;
            //    contextMenu.Items.Add(menuItem);

            //    MenuItemData menuItem3 = new MenuItemData();
            //    menuItem3.Data = treeViewItemData.Data;
            //    menuItem3.Header = "Try Hide Dialog";
            //    menuItem3.Click += MenuItemHideDialog_Click;
            //    contextMenu.Items.Add(menuItem3);
            //}
            //if (treeViewItemData.Data.GetType() == typeof(DataClass.DockerData))
            //{
            //    MenuItemData menuItem = new MenuItemData();
            //    menuItem.Data = treeViewItemData.Data;
            //    menuItem.Header = "Try Show Docker";
            //    menuItem.Click += MenuItemshowDocker_Click;
            //    contextMenu.Items.Add(menuItem);

            //    MenuItemData menuItem3 = new MenuItemData();
            //    menuItem3.Data = treeViewItemData.Data;
            //    menuItem3.Header = "Try Hide Docker";
            //    menuItem3.Click += MenuItemHideDocker_Click;
            //    contextMenu.Items.Add(menuItem3);
            //}


            //if (treeViewItemData.Data.GetType() == typeof(DataClass.ItemData))
            //{
            //    MenuItemData menuItem = new MenuItemData();
            //    menuItem.Data = treeViewItemData.Data;
            //    menuItem.Header = "Try Invoke Item";
            //    menuItem.Click += MenuItemInvoke_Click;
            //    contextMenu.Items.Add(menuItem);
            //}
            //if (treeViewItemData.Data.TagName == "dockers")
            //{
            //    MenuItemData menuItem = new MenuItemData();
            //    menuItem.Data = treeViewItemData.Data;
            //    menuItem.Header = "Get Dockers Caption";
            //    menuItem.Click += MenuItemGetDockerCaption_Click;
            //    contextMenu.Items.Add(menuItem);

            //    //MenuItemData menuItem12 = new MenuItemData();
            //    //menuItem12.Data = treeViewItemData.Data;
            //    //menuItem12.Header = "Get Dockers Guids";
            //    //menuItem12.Click += MenuItemGetDockersGuid_Click;
            //    //contextMenu.Items.Add(menuItem12);
            //}



            //return contextMenu;
        }
Example #36
0
        static void SetMenuItemAttributes(HIMenuItem item, CommandInfo ci, uint refcon)
        {
            MenuItemData data = new MenuItemData();
            IntPtr       text = IntPtr.Zero;

            try {
                if (ci.IsArraySeparator)
                {
                    data.Attributes |= MenuItemAttributes.Separator;
                }
                else if (!ci.Visible)
                {
                    data.Attributes |= MenuItemAttributes.Hidden;
                }
                else
                {
                    data.Attributes &= ~MenuItemAttributes.Hidden;
                    data.CFText      = CoreFoundation.CreateString(GetCleanCommandText(ci));

                    //disable also when MD main window doesn't have toplevel focus, or commands will be
                    //accessible when modal dialogs are active
                    bool disabled = !ci.Enabled || IsGloballyDisabled;
                    data.Enabled = !disabled;
                    if (disabled)
                    {
                        data.Attributes |= MenuItemAttributes.Disabled;
                    }

                    ushort            glyphCode, charCode, hardwareCode;
                    MenuAccelModifier mod;
                    if (GetAcceleratorKeys(ci.AccelKey, out glyphCode, out charCode, out hardwareCode, out mod))
                    {
                        data.CommandKeyModifiers = mod;
                        if (glyphCode != 0)
                        {
                            data.CommandKeyGlyph = glyphCode;
                            data.Attributes     ^= MenuItemAttributes.UseVirtualKey;
                        }
                        else if (hardwareCode != 0)
                        {
                            data.CommandVirtualKey = (char)hardwareCode;
                            data.Attributes       |= MenuItemAttributes.UseVirtualKey;
                        }
                        else
                        {
                            data.CommandKey  = (char)charCode;
                            data.Attributes ^= MenuItemAttributes.UseVirtualKey;
                        }
                    }
                    //else{
                    //FIXME: remove existing commands if necessary

                    data.Mark = ci.Checked
                                                ? ci.CheckedInconsistent
                                                        ? '-' //FIXME: is this a good symbol for CheckedInconsistent?
                                                        : (char)MenuGlyphs.Checkmark
                                                : '\0';

                    data.ReferenceConstant = refcon;
                }
                HIToolbox.SetMenuItemData(item.MenuRef, item.Index, false, ref data);
            } finally {
                if (text != IntPtr.Zero)
                {
                    CoreFoundation.Release(text);
                }
            }
        }
		public static void AddMenuItem(Control ctrl, MenuItemData data)
		{
			object parent = FindFirst(ctrl, data.Parent);
			AddMenuItemInternal(parent, data);
		}
Example #38
0
		public DemoModuleLoader(MenuItemData[] items)
		{
			this.items = items;
		}
Example #39
0
        private ListHeaderViewModel CreateHeader()
        {
            ListHeaderViewModel listHeaderViewModel = new ListHeaderViewModel();

            listHeaderViewModel.ShowAllVisibility = this.IsHorizontal ? Visibility.Visible : Visibility.Collapsed;
            listHeaderViewModel.OnHeaderTap       = new Action(this.HandleShowAllAction);
            string id = this._videoCategory.id;

            System.Diagnostics.Debug.WriteLine("ListHeaderViewModel.CreateHeader " + id);

            //uint stringHash = 0;// PrivateImplementationDetails.ComputeStringHash(id);

            /*if (stringHash <= 822911587U)
             * {
             *  if (stringHash <= 434841374U)
             *  {
             *      if (stringHash <= 350953279U)
             *      {
             *          if ((int)stringHash != 216585232)
             *          {
             *              if ((int)stringHash != 334175660)
             *              {
             *                  if ((int)stringHash != 350953279 || !(id == "19"))
             *                      goto label_54;
             *              }
             *              else if (!(id == "18"))
             *                  goto label_54;
             *          }
             *          else if (!(id == "69"))
             *              goto label_54;
             *      }
             *      else if ((int)stringHash != 384361422)
             *      {
             *          if ((int)stringHash != 418063755)
             *          {
             *              if ((int)stringHash != 434841374 || !(id == "16"))
             *                  goto label_54;
             *          }
             *          else if (!(id == "15"))
             *              goto label_54;
             *      }
             *      else if (!(id == "63"))
             *          goto label_54;
             *  }
             *  else if (stringHash <= 501951850U)
             *  {
             *      if ((int)stringHash != 451618993)
             *      {
             *          if ((int)stringHash != 468396612)
             *          {
             *              if ((int)stringHash != 501951850 || !(id == "12"))
             *                  goto label_54;
             *          }
             *          else if (!(id == "10"))
             *              goto label_54;
             *      }
             *      else if (!(id == "17"))
             *          goto label_54;
             *  }
             *  else if ((int)stringHash != 518729469)
             *  {
             *      if ((int)stringHash != 806133968)
             *      {
             *          if ((int)stringHash != 822911587 || !(id == "4"))
             *              goto label_54;
             *      }
             *      else if (!(id == "5"))
             *          goto label_54;
             *  }
             *  else if (!(id == "13"))
             *      goto label_54;
             * }
             * else if (stringHash <= 1007465396U)
             * {
             *  if (stringHash <= 873244444U)
             *  {
             *      if ((int)stringHash != 839689206)
             *      {
             *          if ((int)stringHash != 856466825)
             *          {
             *              if ((int)stringHash != 873244444 || !(id == "1"))
             *                  goto label_54;
             *          }
             *          else if (!(id == "6"))
             *              goto label_54;
             *      }
             *      else if (!(id == "7"))
             *          goto label_54;
             *  }
             *  else if ((int)stringHash != 906799682)
             *  {
             *      if ((int)stringHash != 923577301)
             *      {
             *          if ((int)stringHash != 1007465396 || !(id == "9"))
             *              goto label_54;
             *      }
             *      else if (!(id == "2"))
             *          goto label_54;
             *  }
             *  else if (!(id == "3"))
             *      goto label_54;
             * }
             * else if (stringHash <= 1304646146U)
             * {
             *  if ((int)stringHash != 1024243015)
             *  {
             *      if ((int)stringHash != 1278082707)
             *      {
             *          if ((int)stringHash == 1304646146 && id == "ugc")
             *          {
             *              listHeaderViewModel.IconUri = "..\\Resources\\VideoCatalog\\VideosPopular.png";
             *              goto label_56;
             *          }
             *          else
             *              goto label_54;
             *      }
             *      else if (id == "my")
             *      {
             *          listHeaderViewModel.IconUri = "..\\Resources\\VideoCatalog\\VideosMy.png";
             *          goto label_56;
             *      }
             *      else
             *          goto label_54;
             *  }
             *  else if (!(id == "8"))
             *      goto label_54;
             * }
             * else if ((int)stringHash != 1865670964)
             * {
             *  if ((int)stringHash != -1422563803)
             *  {
             *      if ((int)stringHash == -591183440 && id == "series")
             *      {
             *          listHeaderViewModel.IconUri = "..\\Resources\\VideoCatalog\\VideosShows.png";
             *          goto label_56;
             *      }
             *      else
             *          goto label_54;
             *  }
             *  else if (id == "feed")
             *  {
             *      if (!this.AllowFeedNavigateToAll)
             *      {
             *          listHeaderViewModel.ShowAllVisibility = Visibility.Collapsed;
             *          listHeaderViewModel.OnHeaderTap = null;
             *      }
             *      listHeaderViewModel.IconUri = "..\\Resources\\VideoCatalog\\VideosUpdates.png";
             *      goto label_56;
             *  }
             *  else
             *      goto label_54;
             * }*/
            if (id == "ugc")
            {
                listHeaderViewModel.IconUri = "..\\Resources\\VideoCatalog\\VideosPopular.png";
            }
            else if (id == "my")
            {
                listHeaderViewModel.IconUri = "..\\Resources\\VideoCatalog\\VideosMy.png";
            }
            else if (id == "series")
            {
                listHeaderViewModel.IconUri = "..\\Resources\\VideoCatalog\\VideosShows.png";
            }
            else if (id == "feed")
            {
                if (!this.AllowFeedNavigateToAll)
                {
                    listHeaderViewModel.ShowAllVisibility = Visibility.Collapsed;
                    listHeaderViewModel.OnHeaderTap       = null;
                }
                listHeaderViewModel.IconUri = "..\\Resources\\VideoCatalog\\VideosUpdates.png";
            }
            else if (this._videoCategory.type == "channel")
            {
                listHeaderViewModel.ImageUri = this.GetImageUriFor(this.OwnerId);
            }
            else
            {
                listHeaderViewModel.IconUri = string.Format("..\\Resources\\VideoCatalog\\Categories\\VideosCat{0}.png", this._videoCategory.id);
            }



            if (!string.IsNullOrWhiteSpace(this._videoCategory.name))
            {
                listHeaderViewModel.Title = this._videoCategory.name;
            }
            List <MenuItemData> menuItemDataList = new List <MenuItemData>();

            if (this._videoCategory.type == "channel" && this.OwnerId < 0)
            {
                Group gr = this._knownGroups.FirstOrDefault <Group>((Func <Group, bool>)(g => g.id == -this.OwnerId));
                if (gr != null)
                {
                    this._midSubscribeUnsubscribe = new MenuItemData()
                    {
                        Title = gr.IsMember ? CommonResources.GroupPage_Unfollow.ToLowerInvariant() : CommonResources.Group_Follow.ToLowerInvariant()
                    };
                    this._midSubscribeUnsubscribe.OnTap = (Action)(() => new OwnerHeaderWithSubscribeViewModel(gr).SubscribeUnsubscribe(null));
                    menuItemDataList.Add(this._midSubscribeUnsubscribe);
                }
            }
            if (this._videoCategory.can_hide == 1)
            {
                MenuItemData menuItemData1 = new MenuItemData();
                menuItemData1.Title = CommonResources.VideoCatalog_HideCategory;
                Action action = (Action)(() =>
                {
                    int result = 0;
                    if (!int.TryParse(this._videoCategory.id, out result))
                    {
                        return;
                    }
                    VideoService.Instance.HideCatalogSection(result, (Action <BackendResult <ResponseWithId, ResultCode> >)(res => { }));
                    this.CatalogItemsWithHeaderAndFooter.Clear();
                });
                menuItemData1.OnTap = action;
                MenuItemData menuItemData2 = menuItemData1;
                menuItemDataList.Add(menuItemData2);
            }
            if (menuItemDataList.Count > 0)
            {
                listHeaderViewModel.MenuItemDataList          = menuItemDataList;
                listHeaderViewModel.ShowMoreActionsVisibility = Visibility.Visible;
            }
            return(listHeaderViewModel);
        }
 internal MenuItem(MenuItemData data) : base(null)
 {
     this.msaaMenuInfoPtr = IntPtr.Zero;
     data.AddItem(this);
 }
Example #41
0
 /// <summary>
 /// 初始化菜单项
 /// </summary>
 /// <param name="data">菜单项数据</param>
 public MenuItem(MenuItemData data)
 {
     this.Label(data.Label).Icon(data.FontAwesomeIcon).Icon(data.MaterialIcon)
     .Disable(data.Disabled).Link(data.Link).OnClick(data.OnClick).Menu(data.MenuId);
 }
Example #42
0
 internal MenuItem(MenuItemData data)
 : base(null) {
     data.AddItem(this);
     
     #if DEBUG
         _debugText = data.caption;
     #endif 
 }
Example #43
0
 protected virtual void OnClick(MenuItemData target)
 {
     
 }