private async void ExecuteMenuItemAsynchronously(CustomMenuItem menuItem) { bool completedSuccessfully = false; try { CancellationTokenSource cancel = new CancellationTokenSource(); Progress <ExecutionProgress> progress = new Progress <ExecutionProgress>(); ApplicationState.Default.NotifyAsyncProcessStarted(cancel, progress, 1); await Task.Run(() => menuItem.AsynchronousEventHandler.Invoke(cancel.Token, progress)); if (!cancel.IsCancellationRequested) { completedSuccessfully = true; } else { ApplicationState.Default.RaiseNotification(new NotificationEventArgs(NotificationType.Information, string.Format(Properties.Resources.MainFormExecuteStopped, menuItem.Text))); } } catch (OperationCanceledException) { ApplicationState.Default.RaiseNotification(new NotificationEventArgs(NotificationType.Information, string.Format(Properties.Resources.MainFormExecuteStopped, menuItem.Text))); } catch (Exception ex) { ApplicationState.Default.RaiseNotification(new NotificationEventArgs(NotificationType.Error, ex.Message, ex)); } ApplicationState.Default.NotifyAsyncProgressStopped(completedSuccessfully); }
/// <summary> /// creates the menu item as a visible object in the 3D scene /// </summary> /// <param name="parentMenu">The menu to which the item belongs</param> /// <param name="parent">The parent menu item</param> public void Create(Menu parentMenu, CustomMenuItem parent) { this.parentMenuItem = parent; this.parentMenu = parentMenu; subMenuOpened = false; if (menuStyle == null) { menuStyle = parentMenu.defaultMenuStyle; } containerInstance = GameObject.Instantiate(menuStyle, parentMenu.transform); menuStyleAdapter = containerInstance.GetComponent <MenuStyleAdapter>(); menuStyleAdapter.Initialize(); menuStyleAdapter.RegisterForClickEvent(OnClick); menuStyleAdapter.UpdateText(text); menuStyleAdapter.UpdateIcon(icon); menuStyleAdapter.ItemEnabled = ItemEnabled; if (markOnClick) { menuStyleAdapter.Marked = marked; } if (onClickEvent == null) { onClickEvent = new StringEvent(); } }
private void InitMenuItems(BuildCommandPackage package, OleMenuCommandService mcs) { this.package = package; LoadCustomCommand(); foreach (var menuHierarchy in _hierarchy2BaseCmdId.Keys) { int menuIdx = 0; for (int j = 0; j < _customMenu.Count; j++) { CustomMenuItem item = _customMenu[j]; if (item.hierarchy == menuHierarchy) { int baseCmdId = getMenuId(item); if (baseCmdId != 0) { var cmdID = new CommandID(CommandSet, baseCmdId + menuIdx); var mc = new OleMenuCommand(new EventHandler(OnCommandExec), cmdID); mc.BeforeQueryStatus += new EventHandler(OnBeforeQueryStatus); mcs.AddCommand(mc); _cmdId2MenuItem[cmdID.ID] = item; menuIdx++; } } } } }
private void LoadCustomCommand() { // $(SolutionRoot) which presents in the field Command, Arguments and WorkingDir stands for root directory of the solution. string configFile = Path.Combine(this.package.UserDataPath + "\\CustomMenu.json"); if (File.Exists(configFile)) { using (FileStream fs = new FileStream(configFile, FileMode.Open)) { DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(CustomMenu)); _customMenu = ser.ReadObject(fs) as CustomMenu; } for (int i = 0; i < _customMenu.Count; i++) { CustomMenuItem item = _customMenu[i]; if (item.name.IndexOf("$") != -1 || item.commandExe.IndexOf("$") != -1 || item.commandArgs.IndexOf("$") != -1 || item.workingDir.IndexOf("$") != -1) { item.includeRelPath = true; } } } }
private static void BadgeOverviewLoaded(UnityWebRequest req) { if (req.responseCode == 200) { JsonStringArray array = JsonUtility.FromJson <JsonStringArray>(req.downloadHandler.text); carouselMenuInstance = CarouselMenu.Show(); List <CustomMenuItem> items = new List <CustomMenuItem>(); for (int i = 0; i < array.array.Count; i++) { CustomMenuItem item = carouselMenuInstance.gameObject.AddComponent <CustomMenuItem>(); item.Init(stextMenuItem, new List <CustomMenuItem>(), false); item.onClickEvent.AddListener(OnCarouselItemClicked); item.Text = array.array[i]; item.MenuItemName = array.array[i]; items.Add(item); } carouselMenuInstance.rootMenu = items; ReplaceWithImages(); } }
/// <summary> /// 导出资源 /// </summary> public void Export() { //保存技能信息 List <SkillStaticData> skillData = new List <SkillStaticData>(); foreach (var it in m_Skills) { skillData.Add(it.Value.skillStaticData); } LocalDB.instance.CreateTable("skill_common", skillData); //保存飞行物信息 GameCenter.Instance.DataManager.skillSummonDB.Save(); //保存 //保存时间轴事件 List <TimeEvent> time_events = new List <TimeEvent>(); foreach (var it in m_Skills) { time_events.AddRange(it.Value.timeLine.timeEvents); } LocalDB.instance.ExecuteNonQuery("delete from time_events"); LocalDB.instance.CreateTable("time_events", time_events); //保存Motion GameCenter.Instance.DataManager.skillMotionDB.Save(); LocalDB.instance.BackupDatabase(); CustomMenuItem.BackUpDataBase(); }
private void OnCommandExec(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); OleMenuCommand menuCommand = sender as OleMenuCommand; if (null != menuCommand) { if (_cmdId2MenuItem.ContainsKey(menuCommand.CommandID.ID)) { CustomMenuItem item = _cmdId2MenuItem[menuCommand.CommandID.ID]; if (item.saveAllFiles) { package.saveAllFiles(); } string exeFile = package.ExpandRelativePath(item.commandExe); string args = package.ExpandRelativePath(item.commandArgs); string workingDir = package.ExpandRelativePath(item.workingDir); CmdHelper cmdHelper = new CmdHelper(this.package); if (item.outputToVS != "") { cmdHelper.setOutputPane(item.outputToVS); } cmdHelper.ExecuteCmd(exeFile, args, workingDir); } } }
private static bool IsParent(int ParentID, int CurrentID, int MaxLoop) { List <CustomMenuItem> mi = GetDisplayMenuRepository(); CustomMenuItem CurrentItem = mi.FirstOrDefault(r => r.ID == CurrentID); CustomMenuItem ParentItem = mi.FirstOrDefault(r => r.ID == ParentID); if (CurrentItem == null || ParentItem == null || CurrentItem == ParentItem) { return(false); } if (CurrentItem.ParentID == ParentItem.ID) { return(true); } for (int i = 1; i <= MaxLoop; i++) { CurrentItem = mi.FirstOrDefault(r => r.ID == CurrentItem.ParentID); if (CurrentItem == null || ParentItem == null || CurrentItem == ParentItem) { return(false); } if (CurrentItem.ParentID == ParentItem.ID) { return(true); } } return(false); }
private static List <CustomMenuItem> GetMenuAllIncludeNoneAdminMenu(int SettingsID, string LanguageCode) { List <CustomMenuItem> pages = _db.AbstractPages.Where(r => r.Visible && r.DomainID == SettingsID && r.ShowInAdminMenu && r.LanguageCode == LanguageCode).OrderBy(r => r.Order).ThenBy(r => r.CreateTime).Select(item => new CustomMenuItem() { Title = item.Title, SeoUrlName = item.SeoUrlName, RouteUrl = item.RouteUrl, RedirectTo = item.RedirectTo, ID = item.ID, Visible = item.Visible, ShowInMenu = item.ShowInMenu, ShowInAdminMenu = item.ShowInAdminMenu, ShowInSitemap = item.ShowInSitemap, ParentID = (item.ParentID == null ? 0 : (int)item.ParentID), Level = ((item.RouteUrl == "d" || item.RouteUrl == "l") ? 0 : -1), IsLangRoot = ((item.RouteUrl == "d" || item.RouteUrl == "l") ? true : false), LangCode = item.LanguageCode, ChangeTime = item.ChangeTime } ).ToList(); CustomMenuItem domainPage = pages.FirstOrDefault(r => r.Level == 0); if (domainPage != null) { domainPage.Level = 0; SetMenuLevel(domainPage, pages); } pages.RemoveAll(r => r.Level == -1); return(pages); }
// Update is called once per frame void Update() { if (Sinput.GetButtonDownRepeating("Up")) { //highlight item above currentMenuItem.highlighted = false; currentMenuItem = currentMenuItem.itemAbove; currentMenuItem.highlighted = true; } if (Sinput.GetButtonDownRepeating("Down")) { //highlight item below currentMenuItem.highlighted = false; currentMenuItem = currentMenuItem.itemBelow; currentMenuItem.highlighted = true; } if (Sinput.GetButtonDown("Submit")) { //select this item currentMenuItem.Select(); Sinput.ResetInputs(); } cam.position = Vector3.Lerp(cam.position, currentMenuItem.camTargetPos.position, Time.deltaTime * 4f); cam.rotation = Quaternion.Slerp(cam.rotation, currentMenuItem.camTargetPos.rotation, Time.deltaTime * 4f); cursor.position = currentMenuItem.cursorTarget.position; }
public static string GetBreadcrumbs(int CurentPageID) { string outValue = ""; CustomMenuItem item1 = RP.GetDisplayMenuRepository().FirstOrDefault(r => r.ID == CurentPageID); if (item1 == null) { return(outValue); } outValue = "<ul>"; outValue = outValue + "<li><a href='" + item1.Url.Replace("~", "") + "'>" + item1.Title + "</a><span>/ </span></li>"; CustomMenuItem item2 = RP.GetDisplayMenuRepository().FirstOrDefault(r => r.ID == item1.ParentID); if (item2 == null) { return(outValue + "</ul>"); } outValue = outValue + "<li><a href='" + item2.Url.Replace("~", "") + "'>" + item2.Title + "</a><span>/ </span></li>"; CustomMenuItem item3 = RP.GetDisplayMenuRepository().FirstOrDefault(r => r.ID == item2.ParentID); if (item3 == null) { return(outValue + "</ul>"); } outValue = outValue + "<li><a href='" + item3.Url.Replace("~", "") + "'>" + item3.Title + "</a><span>/ </span></li>"; CustomMenuItem item4 = RP.GetDisplayMenuRepository().FirstOrDefault(r => r.ID == item3.ParentID); if (item4 == null) { return(outValue + "</ul>"); } outValue = outValue + "<li><a href='" + item4.Url.Replace("~", "") + "'>" + item4.Title + "</a><span>/ </span></li>"; return(outValue); }
public static string GetSubMenuFormated(int startLevel, int MaxLevel, int CurentPageID, out string H) { List <CustomMenuItem> pages = GetDisplayMenuRepository(); CustomMenuItem StartItem = pages.FirstOrDefault(r => r.ID == CurentPageID); List <int> backWay = new List <int>(); int backWayLevel = 0; do { backWay.Add(StartItem.ID); backWayLevel = backWayLevel + 1; StartItem = pages.FirstOrDefault(r => r.ID == StartItem.ParentID); if (StartItem != null && StartItem.RouteUrl == "d") { backWay.Add(StartItem.ID); backWayLevel = backWayLevel + 1; break; } }while (StartItem != null || backWayLevel > 10); try { CurentPageID = backWay[backWayLevel - startLevel]; } catch { H = ""; return(""); } StartItem = pages.FirstOrDefault(r => r.ID == CurentPageID); H = StartItem.Title; return(WriteChildMenu(pages.Where(r => r.Visible == true && r.Level <= MaxLevel).ToList(), StartItem, MaxLevel, startLevel)); }
private void FillCustomMenuItemObject(IMainMenuItem current, CustomMenuItem item) { current.Text = item.Text; current.Order = item.Order; current.Active = item.Active; current.Parent = item.Parent; }
private static void SetMenuLevel(CustomMenuItem item1, List <CustomMenuItem> pages) { foreach (CustomMenuItem item2 in pages.Where(r => r.ParentID == item1.ID).OrderBy(r => r.ID)) { item2.Level = item1.Level + 1; SetMenuLevel(item2, pages); } }
int getMenuId(CustomMenuItem item) { if (_hierarchy2BaseCmdId.ContainsKey(item.hierarchy)) { return(_hierarchy2BaseCmdId[item.hierarchy]); } return(0); }
public void UpdateItemName(string oldname, string newName) { if (allMenuItems.ContainsKey(oldname) && !allMenuItems.ContainsKey(newName)) { CustomMenuItem value = allMenuItems[oldname]; allMenuItems.Remove(oldname); allMenuItems.Add(newName, value); } }
static internal void AddCustomGenericContextMenuItem(CustomMenuItem item) { if (_builtinMenuNames.Contains(item.menuName)) { Debug.LogWarning("Can not use builtin menuName:" + item.menuName); return; } _customMenuItems.Add(item.menuName, item); }
public void MarkOne(CustomMenuItem item) { if (markedItem != null) { markedItem.Marked = false; } item.Marked = true; markedItem = item; }
/// ------------------------------------------------------------------------------------------------- /// <summary> Context set PC. </summary> /// /// <remarks> 19/09/2018. </remarks> /// /// <param name="sender"> Source of the event. </param> /// <param name="e"> Event information. </param> /// ------------------------------------------------------------------------------------------------- private void ContextSetPC(object sender, EventArgs e) { CustomMenuItem customMenuItem = sender as CustomMenuItem; int pc = (int)customMenuItem.value; //MainForm.myNewRegisters.SetRegister(pc,Registers.Z80Register.pc); //Console.WriteLine("hello "+pc.ToString("X4")); }
/// <summary> /// Check if settings have components that require admin rights, give option to restart as admin /// </summary> private static void RunAsAdminCheck() { //If not already running as admin if (!userAccessControl.IsRunAsAdmin()) { #region Lync Custom Menus //If Lync custom menus are defined check if they need updating bool regRequiresUpdate = false; if (Settings.appSettings.Descendants("CustomMenuItems").Elements("MenuItem").Any()) { ModifyRegistry readKey = new ModifyRegistry(); readKey.RegistryView = RegistryView.Registry32; readKey.RegistryHive = RegistryHive.LocalMachine; readKey.ShowError = true; //Read MenuItems from XML foreach (var CustomMenuItem in Settings.appSettings.Descendants("CustomMenuItems").Descendants("MenuItem")) { readKey.SubKey = "SOFTWARE\\Microsoft\\Office\\15.0\\Lync\\SessionManager\\Apps\\" + CustomMenuItem.Element("GUID").Value; foreach (var CustomMenuItemValue in CustomMenuItem.Elements()) { if (CustomMenuItemValue.Name.ToString() != "GUID") { string regKeyName = CustomMenuItemValue.Name.ToString(); string regSettingsValue = CustomMenuItemValue.Value; string regValue = readKey.Read(regKeyName); //MessageBox.Show("Sval: " + regSettingsValue + Environment.NewLine + "regVal: " + regValue); if (regSettingsValue != regValue) { regRequiresUpdate = true; } } } } } //If Lync custom menus need updating prompt to restart as admin if (regRequiresUpdate) { if (MessageBox.Show( "Application settings have enabled Lync custom menus, however you do not have the required permissions. " + "To enable these settings run the application as admin, or remove this configuration from the applications settings." + Environment.NewLine + Environment.NewLine + "Would you like to restart as admin?", "Error creating Lync custom menus", MessageBoxButtons.YesNo) == DialogResult.Yes) { userAccessControl.Elevate(); } } #endregion Lync Custom Menus } }
/// <summary> /// Hides all siblings /// </summary> /// <param name="current">The current menu item which should not be hidden</param> /// <param name="siblings">The menu item list which should be hidden</param> public void HideSiblings(CustomMenuItem current, List <CustomMenuItem> siblings) { foreach (CustomMenuItem item in siblings) { if (item != current) { item.Hide(); } } }
// ------------------------------------------------------------------------------------------------- // Context clear breakpoint // // \param sender // Source of the event. // \param e // Event information. // ------------------------------------------------------------------------------------------------- private void ContextClearBreakpoint(object sender, EventArgs e) { CustomMenuItem customMenuItem = sender as CustomMenuItem; int longaddr = (int)customMenuItem.value; NextAddress na = new NextAddress(longaddr); Program.serialport.RemoveBreakpoint(null, na.GetAddr(), na.GetBank()); MainForm.myBreakpoints.RequestUpdate(); }
private void ContextGotoAddress(object sender, EventArgs e) { CustomMenuItem customMenuItem = sender as CustomMenuItem; Labels.Label l = (Labels.Label)customMenuItem.value; if (l != null) { TraceFile.FocusAddr(l.nextAddress.GetAddr(), l.nextAddress.GetBank()); } }
/// ------------------------------------------------------------------------------------------------- /// <summary> Context add to watch. </summary> /// /// <remarks> 19/09/2018. </remarks> /// /// <param name="sender"> Source of the event. </param> /// <param name="e"> Event information. </param> /// ------------------------------------------------------------------------------------------------- private void ContextAddToWatch(object sender, EventArgs e) { CustomMenuItem customMenuItem = sender as CustomMenuItem; Labels.Label l = (Labels.Label)customMenuItem.value; if (l != null) { MainForm.myWatches.AddWatchLabel(l); } }
public static int GetPageIDByUrl(string Url) { CustomMenuItem cmi = GetDisplayMenuRepository().FirstOrDefault(r => r.Url == "~" + Url); if (cmi != null) { return(cmi.ID); } else { return(0); } }
private void ctxMenu_Copy(Object sender, System.EventArgs e) { CustomMenuItem item = sender as CustomMenuItem; if (item.type == Types.CtxMenuType.ADDRESS_BOOK) { if (dtgAddressBook.CurrentCell != null && dtgAddressBook.CurrentCell.Value != null) { String text = dtgAddressBook.CurrentCell.Value.ToString(); Clipboard.SetText(text); } } }
private void OpenOneTab(CustomMenuItem data) { //这里可以动态加载其他dll文件中的组件 Assembly assem = Assembly.LoadFile($"{Directory.GetCurrentDirectory()}\\{data.DllName}"); var onePage = assem.CreateInstance(data.ClassName); ClosableTab theTabItem = new ClosableTab(); theTabItem.Content = onePage; theTabItem.Title = data.Title; myTabControl.Items.Add(theTabItem); theTabItem.Focus(); }
public void RegisterMenuItems(System.Windows.Forms.ContextMenuStrip contextMenu) { invokeMenuItem = new CustomMenuItem(this, "Invoke", new EventHandler(OnInvokeEvent)); clearAllListenersForThisObject = new CustomMenuItem(this, "Remove Hawkeye's listeners for this object", new EventHandler(ClearListenersForThisObject)); clearAllListeners = new CustomMenuItem(this, "Remove ALL Hawkeye's Listeners", new EventHandler(ClearListeners)); contextMenu.Items.Insert(1, invokeMenuItem); contextMenu.Items.Add(clearAllListenersForThisObject); contextMenu.Items.Add(clearAllListeners); invokeMenuItem.Enabled = false; clearAllListenersForThisObject.Enabled = true; clearAllListeners.Enabled = true; }
/// <summary> /// 获取数据菜单 /// </summary> /// <returns></returns> public ObservableCollection <CustomMenuItem> ReadCustomMenus() { var oldMenus = LoginResultDto.Instance.Attributes.Menus; var customMenus = new ObservableCollection <CustomMenuItem>(); // 添加首页菜单 var mainMenu = GetMenu(CustomMenuItem.KEY_OF_HOME); var newMenu = new CustomMenuItem(1, "1", "", mainMenu.Key, mainMenu.Value, $"./../Images/{mainMenu.Key}.png"); customMenus.Add(newMenu); ReadChildren(1, string.Empty, oldMenus, customMenus); return(customMenus); }
private void GenerateMenus(CustomMenuItem item, MenuItem it) { if (item.Children != null) { foreach (var child in item.Children) { var c = new MenuItem() { Header = child.Title, Tag = child }; c.Click += MenuItem_Click; it.Items.Add(c); GenerateMenus(child, c); } } }
public void onMenuItemSelect(Dropdown selectedDropdown, CustomMenuItem selectedItem) { Debug.Log("Menu Selected: " + selectedItem.MenuLabelText); MapManager mapManager = MapManager.Instance; ; HudManager hudManager = HudManager.Instance; switch (selectedItem.SelectionHandler) { case "newMap": mapManager.DrawEmptyMap(); break; case "loadMap": hudManager.ShowLoadMapDialog(); break; case "saveMap": mapManager.SaveMapData(); break; case "clearMap": mapManager.ClearMapTiles(); break; case "exitEditor": GameObject.FindObjectOfType<LevelManager>().MainMenu(); break; case "selectNeighboring": mapManager.SelectNeighborTiles(); break; case "selectNone": mapManager.SelectNone(); break; case "selectAll": mapManager.SelectAll(); break; } }