/// <summary> /// Shows the specified is GUI mode. /// </summary> /// <param name="isGUIMode">if set to <c>true</c> [is GUI mode].</param> private void Show(bool isGUIMode) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Process"); bool isFirstInstance = false; _lock = new Mutex(false, _mutexGuid.ToString(), out isFirstInstance); if (!isFirstInstance) { Log.Info(PROC, "Another instance was found."); int processId = Process.GetCurrentProcess().Id; Log.Info(PROC, string.Format("Current Process : [{0:D}]", processId)); if (isGUIMode) { if (Win32Extensions.ShowMessageBox(null, "Another instance is already running.\nPress [Yes] to kill that instance (or) [No] to exit.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { Log.Info(PROC, string.Format("Current Process [{0:D}] was exited with Error Code (1).", processId)); Thread.Sleep(2000); return; } } Process[] existingProcesses = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName); if (existingProcesses != null) { foreach (Process existingProcess in existingProcesses) { try { if (existingProcess.Id != processId) { Log.Info(PROC, string.Format("Killing Process [{0:D}] ...", existingProcess.Id)); existingProcess.Kill(); Log.Info(PROC, string.Format("Process [{0:D}] was successfully killed", existingProcess.Id)); } } catch (Exception ex) { Log.Info(PROC, string.Format("Unable to kill Process [{0:D}]", existingProcess.Id)); Log.Exception(PROC, ex); } } } } Log.Info(PROC, string.Format("Application was opened in [{0}] mode.", (isGUIMode ? "GUI (Debug)" : "Windows Service"))); if (isGUIMode) { ShowMainForm(); } else { StartService(); } }
protected override void OnKeyDown(KeyEventArgs e) { ModuleProc PROC = new ModuleProc("", "OnKeyDown"); try { base.OnKeyDown(e); if (_clipboardCopyMode == ListViewClipboardCopyMode.Disable) { return; } if (e.Control && !e.Shift) { // copy if (e.KeyCode == Keys.C) { IList items = this.Items; IList indices = null; if (this.FullRowSelect) { if (this.MultiSelect && this.SelectedItems != null && this.SelectedItems.Count > 0) { items = this.SelectedItems; } } this.CopyToClipboard(items, indices); } // copy to excel if (e.KeyCode == Keys.E) { var forms = Application.OpenForms; if (forms.Count > 0) { Win32Extensions.ExportControlDataToExcel <object>(forms[0], this, null, (_clipboardCopyMode == ListViewClipboardCopyMode.EnableWithHeaderText), true, true); } } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
void OnTimer_Tick(object sender, EventArgs e) { ModuleProc PROC = new ModuleProc("MarqueeLabel", "OnTimer_Tick"); try { if (!Win32Extensions.IsInDesignMode()) { if ((_position - _scrollAmount) > 0) { _position -= _scrollAmount; } else { _position = this.Width; } this.Invalidate(); } } catch (Exception ex) { Log.Exception(PROC, ex); } }