private void AddInstanceMenu_Click(object sender, EventArgs e) { var result = InputBox.Show(this, "", Resources.NewInstanceName, string.Empty, InputBox_Validating); if (result.Ok) { // trigger the tray icon context menu to show the second instance var mainForm = new MainForm(result.Text); mainForm.Dispose(); LoadInstances(); // reposition the newly added instance so that it's not directly on top of the previous one _mainFormInstances[result.Text].Left = _mainFormInstances[result.Text].Left + 400; _mainFormInstances[result.Text].Top = _mainFormInstances[result.Text].Top + 200; // Save the new position so that it's correctly loaded on next run _mainFormInstances[result.Text].Preferences.Left = _mainFormInstances[result.Text].Left; _mainFormInstances[result.Text].Preferences.Top = _mainFormInstances[result.Text].Top; } }
private void AddInstanceMenu_Click(object sender, EventArgs e) { var result = InputBox.Show(this, "", Resources.NewInstanceName, string.Empty, InputBox_Validating); if (result.Ok) { // trigger the tray icon context menu to show the second instance var mainForm = new MainForm(result.Text); mainForm.Dispose(); LoadInstances(); // reposition the newly added instance so that it's not directly on top of the previous one var rnd = new Random(); var xLoc = rnd.Next(0, Screen.FromHandle(Handle).WorkingArea.Width - _mainFormInstances[result.Text].Width); var yLoc = rnd.Next(0, Screen.FromHandle(Handle).WorkingArea.Height - _mainFormInstances[result.Text].Height); _mainFormInstances[result.Text].Left = xLoc; _mainFormInstances[result.Text].Top = yLoc; // Save the new position so that it's correctly loaded on next run _mainFormInstances[result.Text].Preferences.Left = _mainFormInstances[result.Text].Left; _mainFormInstances[result.Text].Preferences.Top = _mainFormInstances[result.Text].Top; } }
private void AddInstanceMenu_Click(object sender, EventArgs e) { var result = InputBox.Show(this, "", Resources.NewInstanceName, string.Empty, InputBox_Validating); if (result.Ok) { // trigger the tray icon context menu to show the second instance var mainForm = new MainForm(result.Text); mainForm.Dispose(); LoadInstances(); // reposition the newly added instance so that it's not directly on top of the previous one _mainFormInstances[result.Text].Left = _mainFormInstances[result.Text].Left + 400; _mainFormInstances[result.Text].Top = _mainFormInstances[result.Text].Top + 200; // Save the new position so that it's correctly loaded on next run _mainFormInstances[result.Text].Preferences.Left = _mainFormInstances[result.Text].Left; _mainFormInstances[result.Text].Preferences.Top = _mainFormInstances[result.Text].Top; } }