private int indexFindPlace = 0; //文本查找位置,缺省为文本起点 private void btnSearchContent_Click(object sender, EventArgs e) { if (txtSearchText.Text.Length > 0) //当查找内容不为空时,进行查找 { IRunnerMain mainForm = this.Owner as IRunnerMain; if (mainForm == null) { MessageBox.Show("打开查找失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (mainForm.txtHelp.Text.Length > 0) { if ((indexFindPlace = mainForm.txtHelp.Text.IndexOf(txtSearchText.Text, indexFindPlace)) == -1) { MessageBox.Show("已经查找到最后了!"); indexFindPlace = 0; //没有找到,重置查找位置为文本起点 } else { //选中找到的文本,使其明显 mainForm.txtHelp.Select(indexFindPlace, txtSearchText.Text.Length); mainForm.txtHelp.SelectionStart = indexFindPlace; mainForm.txtHelp.ScrollToCaret();//滚动到光标处 //找到了,置查找位置为下一个位置 indexFindPlace = indexFindPlace + txtSearchText.Text.Length; mainForm.Activate(); } } } }
private void btnRemove_Click(object sender, EventArgs e) { if (lvPlugin.SelectedItems.Count > 0 && lvPlugin.SelectedItems[0] != null) { IRunnerMain mainForm = this.Owner as IRunnerMain; if (mainForm == null) { throw new Exception("The Owner Form:IRunnerMain Can Not Be Null!"); } if (MessageBox.Show("确定移除指定插件吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string keyName = lvPlugin.SelectedItems[0].Tag.ToString(); PluginService service = new PluginService(PubData.AllPlugins); MenuService menuService = new MenuService(PubData.AllPluginMenus); service.RemovePlugin(keyName); ToolStripMenuItem menuItem = (ToolStripMenuItem)menuService.GetMenuItem(keyName); mainForm.tsddbPluginMenu.DropDownItems.Remove(menuItem); menuService.RemoveMenuItem(keyName); // System.IO.File.Delete(lvPlugin.SelectedItems[0].ToolTipText); lvPlugin.Items.Remove(lvPlugin.SelectedItems[0]); } } }
private void btnAddPlugin_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "(Ice Plugin)|*.dll"; openFileDialog.FilterIndex = 1; IRunnerMain mainForm = this.Owner as IRunnerMain; if (mainForm == null) { throw new Exception("The Owner Form:IRunnerMain Can Not Be Null!"); } if (openFileDialog.ShowDialog() == DialogResult.OK) { string fName = openFileDialog.FileName; PluginService service = new PluginService(PubData.AllPlugins); MenuService menuService = new MenuService(PubData.AllPluginMenus); IPlugin plugin = service.AddPlugin(fName); if (plugin != null) { plugin.Enable = true; IRunnerMain.AddPluginToMenu(mainForm.tsddbPluginMenu, plugin, menuService); AddPluginToView(plugin); string dest = PubData.GV_IcePluginsPath + plugin.FullName.Substring(plugin.FullName.LastIndexOf("\\")); MoveFolderTo(plugin.FullName, dest); } } openFileDialog.Dispose(); openFileDialog = null; }
private void btnCancelSearch_Click(object sender, EventArgs e) { this.Hide(); IRunnerMain mainForm = this.Owner as IRunnerMain; if (mainForm != null) { mainForm.Activate(); } }
private void FrmSearchOnline_FormClosing(object sender, FormClosingEventArgs e) { this.Hide(); IRunnerMain mainForm = this.Owner as IRunnerMain; if (mainForm != null) { mainForm.Activate(); e.Cancel = true; } }
private void FrmRunCmd_Activated(object sender, EventArgs e) { int x; int y; IRunnerMain parForm = (IRunnerMain)this.Owner; x = parForm.Left + 20; y = parForm.Top + parForm.Height - this.Height - 35; this.Location = new Point(x, y); txtRunCmd.Focus(); txtRunCmd.SelectAll(); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool bCreatedNew; //Create a new mutex using specific mutex name System.Threading.Mutex m = new System.Threading.Mutex(false, "IRunnerRunOnlyTime", out bCreatedNew); if (bCreatedNew) { objIRunnerMain = new IRunnerMain(args); Application.Run(objIRunnerMain); } else { MessageBox.Show("程序已经在运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Application.Exit(); } //Application.Run(new IRunnerMain(args)); }
private void btnSave_Click(object sender, EventArgs e) { PluginService service = new PluginService(PubData.AllPlugins); MenuService menuService = new MenuService(PubData.AllPluginMenus); string keyName = string.Empty; IRunnerMain mainForm = this.Owner as IRunnerMain; if (mainForm == null) { throw new Exception("The Owner Form:IRunnerMain Can Not Be Null!"); } ToolStripMenuItem menuItem = null; foreach (ListViewItem item in lvPlugin.Items) { keyName = item.Tag.ToString(); if (!item.Checked) { service.UnEnablePlugin(keyName); menuItem = (ToolStripMenuItem)menuService.GetMenuItem(keyName); if (mainForm.tsddbPluginMenu.DropDownItems.Contains(menuItem)) { mainForm.tsddbPluginMenu.DropDownItems.Remove(menuItem); } } else { service.EnablePlugin(keyName); menuItem = (ToolStripMenuItem)menuService.GetMenuItem(keyName); if (!mainForm.tsddbPluginMenu.DropDownItems.Contains(menuItem)) { mainForm.tsddbPluginMenu.DropDownItems.Add(menuItem); } } } this.Close(); }