private void menuTextBoxKeyUp(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) { //Suche ausführen und Ergebnis anzeigen. ToolStripTextBox miTB = null; if ((miTB = sender as ToolStripTextBox) != null) { //ToolsFenster für Such Ergebnisse #region ToolWindow if (sdf == null) { sdf = new ShowDataForm(); } else if (sdf.IsDisposed || sdf.Disposing) { sdf = new ShowDataForm(); } Properties.Application.Default.Reload(); strFileName = Properties.Application.Default.sourceFile; sdf.Show(); sdf.ReadCsv(miTB.Text, strFileName); sdf.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - sdf.Width - 5, Screen.PrimaryScreen.WorkingArea.Height - sdf.Height - 5); sdf.Focus(); #endregion } } }
public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #if DEBUG string mutexName = "CSV - SUCHTOOL | DEBUG"; #else string mutexName = "CSV - SUCHTOOL | RELEASE"; #endif bool isFirstInstance; mf = null; // mf = new MainForm(); sdf = null; // sdf = new ShowDataForm(); // Anhand einer eindeutig benannten Mutex, feststellen ob bereits eine Instanz der Anwendung läuft // TODO: Optionale Parameter zum Aufrufen der Anwendung erstellen using (Mutex mtx = new Mutex(true, mutexName, out isFirstInstance)) { if (isFirstInstance) { NotificationIcon notificationIcon = new NotificationIcon(); notificationIcon.notifyIcon.Visible = true; //TODO: Option für das Anzeigen des Hauptfensters beim start erstellen // - Beim Schließen des Hauptfensters wird die Anwendung geschlossen. // - Keine neue Instanz des Hauptfensters erzeugen Application.Run(new DummyForm()); notificationIcon.notifyIcon.Dispose(); } else { // The application is already running // TODO: Display message box or change focus to existing application instance // Übergeben optionaler Parameter an bestehenden Prozess (evtl. erst nachfragen) } } // releases the Mutex }