public static void AddTestMenu(IAppInstance aAppInstance, Assembly aAssemblyWithTests, IAppSubMenu aParentSubMenu, bool aSeparatorBefore) { var lMenuItem = aParentSubMenu.AddItem("Run Unit Tests", aSeparatorBefore); lMenuItem.ClickHandler = new TestHost(aAppInstance, aAssemblyWithTests); lMenuItem.Visible = true; lMenuItem.Enabled = true; }
private IAppMenuItem CreateMenuItem(IAppSubMenu aParent, string aCaption, AppNotifyHandler.ExecuteDelegate aOnExecute, bool aNewGroup = false) { var item = aParent.AddItem(aCaption, aNewGroup); item.Enabled = true; if (aOnExecute != null) { item.ClickHandler = new AppNotifyHandler(aOnExecute); } return(item); }
private void TestSubmenu(IAppSubMenu aSubMenu) { var testHandler = new AppNotifyHandler(null); // Test Caption aSubMenu.Caption = TestCaption1; Assert.IsTrue(aSubMenu.Caption == TestCaption1, "Cannot Set Caption"); aSubMenu.Caption = TestCaption2; Assert.IsTrue(aSubMenu.Caption == TestCaption2, "Cannot Set Caption"); // Test Enabled aSubMenu.Enabled = true; Assert.IsTrue(aSubMenu.Enabled, "Cannot Set Enabled"); aSubMenu.Enabled = false; Assert.IsFalse(aSubMenu.Enabled, "Cannot Set Enabled"); // Test Visible aSubMenu.Visible = true; Assert.IsTrue(aSubMenu.Visible, "Cannot Set Visible"); aSubMenu.Visible = false; Assert.IsFalse(aSubMenu.Visible, "Cannot Set Visible"); // Test Count, Items, AddSubMenu, AddItem var oldCount = aSubMenu.Count; var testSubMenu1 = aSubMenu.AddSubMenu(TestCaption1, true); Assert.IsTrue(aSubMenu.Items[oldCount++] == testSubMenu1, "Incorrect Items"); var testSubMenu2 = aSubMenu.AddSubMenu(TestCaption2, false); Assert.IsTrue(aSubMenu.Items[oldCount++] == testSubMenu2, "Incorrect Items"); var testItem1 = aSubMenu.AddItem(TestCaption1, true); Assert.IsTrue(aSubMenu.Items[oldCount++] == testItem1, "Incorrect Items"); var testItem2 = aSubMenu.AddItem(TestCaption2, false); Assert.IsTrue(aSubMenu.Items[oldCount++] == testItem2, "Incorrect Items"); Assert.IsTrue(aSubMenu.Count == oldCount, "Incorrect Count"); // Test PopupHandler testSubMenu1.PopupHandler = testHandler; Assert.IsTrue(testSubMenu1.PopupHandler == testHandler, "Cannot Set PopupHandler"); testSubMenu1.PopupHandler = null; Assert.IsTrue(testSubMenu1.PopupHandler == null, "Cannot Set PopupHandler"); }
public static void InitTestEvents(IAppSubMenu aParentSubMenu, bool aSeparatorBefore) { var lSubMenu = aParentSubMenu.AddSubMenu("Open Me", true); lSubMenu.PopupHandler = new AppNotifyHandler(() => { SubMenuPopupCount++; SystemSounds.Beep.Play(); }); lSubMenu.Visible = true; lSubMenu.Enabled = true; var lMenuItem = lSubMenu.AddItem("Click Me", false); lMenuItem.ClickHandler = new AppNotifyHandler(() => { MenuItemClickCount++; SystemSounds.Beep.Play(); }); lMenuItem.Visible = true; lMenuItem.Enabled = true; }
public static void AddTestMenu(IAppInstance aAppInstance, IAppSubMenu aParentSubMenu, bool aSeparatorBefore) { AddTestMenu(aAppInstance, Assembly.GetExecutingAssembly(), aParentSubMenu, aSeparatorBefore); }
private void InitMenu() { var appMenuService = (IAppMenuService)_appInstance; if (appMenuService != null) { var subMenu = appMenuService.AddRootMenu(string.Format("Sample Add-In v{0}", m_version)); subMenu.Visible = true; //subMenu.PopupHandler = new AppNotifyHandler(DoHelloWorld); var item = subMenu.AddItem("Click Me", false); item.ClickHandler = new AppNotifyHandler(DoHelloWorld); item.Visible = true; item.Enabled = true; var item3 = subMenu.AddItem("Application properties...", true); item3.ClickHandler = new AppNotifyHandler(DoAppProperties); item3.Visible = true; item3.Enabled = true; var itemConfig = subMenu.AddItem("Configuration read demo...", true); itemConfig.ClickHandler = new AppNotifyHandler(DoConfigurationDemo); itemConfig.Enabled = true; itemConfig.Visible = true; var itemUnlockCodeNetwork = subMenu.AddItem("Unlock code network", false); itemUnlockCodeNetwork.ClickHandler = new AppNotifyHandler(DoShowUnlockCodeNetwork); itemUnlockCodeNetwork.Enabled = true; itemUnlockCodeNetwork.Visible = true; var itemUnlockCodeEfile = subMenu.AddItem("Unlock code efile", false); itemUnlockCodeEfile.ClickHandler = new AppNotifyHandler(DoShowUnlockCodeEfile); itemUnlockCodeEfile.Enabled = true; itemUnlockCodeEfile.Visible = true; var itemUnlockKey = subMenu.AddItem("Unlock key", false); itemUnlockKey.ClickHandler = new AppNotifyHandler(DoShowUnlockKey); itemUnlockKey.Enabled = true; itemUnlockKey.Visible = true; var itemUniqueId = subMenu.AddItem("Unique ID", false); itemUniqueId.ClickHandler = new AppNotifyHandler(DoShowUniqueID); itemUniqueId.Enabled = true; itemUniqueId.Visible = true; CreateMenuItem(subMenu, "Current Module Name", DoCurrentModuleInfo, false); var item7 = subMenu.AddItem("Trigger exception from Add-In", true); item7.ClickHandler = new AppNotifyHandler(DoTriggerAddinException); item7.Enabled = true; item7.Visible = true; var item8 = subMenu.AddItem("Trigger exception from Application ", false); item8.ClickHandler = new AppNotifyHandler(DoTriggerAppException); item8.Enabled = true; item8.Visible = true; var item4 = subMenu.AddItem("Client file properties...", true); item4.ClickHandler = new AppNotifyHandler(DoClientFileProperties); item4.Enabled = true; item4.Visible = true; var itemUFL = subMenu.AddItem("Print Tax form...", false); itemUFL.ClickHandler = new AppNotifyHandler(DoUFLDemo); itemUFL.Enabled = true; itemUFL.Visible = true; var itemClientLetters = subMenu.AddItem("Client Letters...", false); itemClientLetters.ClickHandler = new AppNotifyHandler(DoClientLettersDemo); itemClientLetters.Enabled = true; itemClientLetters.Visible = true; var itemDiag = subMenu.AddItem("Diagnostic properties...", false); itemDiag.ClickHandler = new AppNotifyHandler(DoDiagDemo); itemDiag.Enabled = true; itemDiag.Visible = true; var item6 = subMenu.AddItem("Return statuses properties...", false); item6.ClickHandler = new AppNotifyHandler(DoReturnStatuses); item6.Enabled = true; item6.Visible = true; var item5 = subMenu.AddItem("Selected Cell properties...", false); item5.ClickHandler = new AppNotifyHandler(DoCurrentCell); item5.Enabled = true; item5.Visible = true; var itemAttachements = subMenu.AddItem("File Attachements...", false); itemAttachements.ClickHandler = new AppNotifyHandler(DoAttachementDemo); itemAttachements.Enabled = true; var item9 = subMenu.AddItem("Query complex data", false); item9.ClickHandler = new AppNotifyHandler(DoQueryComplexData); item9.Enabled = true; item9.Visible = true; var itemAddDiag = subMenu.AddItem("Toggle custom diagnostic", false); itemAddDiag.ClickHandler = new AppNotifyHandler(DoAddDiagDemo); itemAddDiag.Enabled = true; itemAddDiag.Visible = true; var itemCursorDemo = subMenu.AddItem("Hours glass cursor demo", true); itemCursorDemo.ClickHandler = new AppNotifyHandler(DoCursorDemo); itemCursorDemo.Enabled = true; itemCursorDemo.Visible = true; var itemBaunds = subMenu.AddItem("Application window information", false); itemBaunds.ClickHandler = new AppNotifyHandler(DoBaundsDemo); itemBaunds.Enabled = true; itemBaunds.Visible = true; itemBaunds.Visible = true; var itemOpenClientSubMenu = subMenu.AddSubMenu("Programatically Open", false); var itemOpenClientFile = itemOpenClientSubMenu.AddItem("Open client file demo", false); itemOpenClientFile.ClickHandler = new AppNotifyHandler(DoOpenClientFileDemo); itemOpenClientFile.Enabled = true; itemOpenClientFile.Visible = true; var itemOpenClientFileUiDefault = itemOpenClientSubMenu.AddItem("Open client file demo (UIDefault)", false); itemOpenClientFileUiDefault.ClickHandler = new AppNotifyHandler(DoOpenClientFileDemoUiDefault); itemOpenClientFileUiDefault.Enabled = true; itemOpenClientFileUiDefault.Visible = true; var itemOpenClientFileUiSilent = itemOpenClientSubMenu.AddItem("Open client file demo (UI Silent)", false); itemOpenClientFileUiSilent.ClickHandler = new AppNotifyHandler(DoOpenClientFileDemoUiSilent); itemOpenClientFileUiSilent.Enabled = true; itemOpenClientFileUiSilent.Visible = true; var testSubMenu = subMenu.AddSubMenu("Sub Menu", true); _testSubMenu = testSubMenu.AddSubMenu("SubMenu", false); _testSubMenu.AddItem("(empty)", false).Enabled = false; _testMenuItem = testSubMenu.AddItem("Menu Item", false); CreateMenuItem(testSubMenu, "Change 'Submenu' Enabled", () => _testSubMenu.Enabled = !_testSubMenu.Enabled, true); CreateMenuItem(testSubMenu, "Change 'Submenu' Visible", () => _testSubMenu.Visible = !_testSubMenu.Visible, false); CreateMenuItem(testSubMenu, "Change 'MenuItem' Enabled", () => _testMenuItem.Enabled = !_testMenuItem.Enabled, true); CreateMenuItem(testSubMenu, "Change 'MenuItem' Visible", () => _testMenuItem.Visible = !_testMenuItem.Visible, false); } }
public void CleanUp() { RootSubMenu.Visible = false; RootSubMenu = null; AppInstance = null; }
public void Init() { AppInstance = TestHost.CurrentInstance.AppInstance; RootSubMenu = ((IAppMenuService)AppInstance).AddRootMenu("TEST_" + DateTime.Now.ToString("Hmmss")); }