private void OnAllocateKey(object sender, EventArgs args) { StringResource sr = OptionDialogPlugin.Instance.Strings; if (_keyConfigList.SelectedItems.Count == 0) { return; } IGeneralCommand cmd = _keyConfigList.SelectedItems[0].Tag as IGeneralCommand; Debug.Assert(cmd != null); Keys key = _hotKey.Key; IGeneralCommand existing = _keybinds.FindCommand(key); if (existing != null && existing != cmd) //別コマンドへの割当があったら { if (GUtil.AskUserYesNo(this, String.Format(sr.GetString("Message.OptionDialog.AskOverwriteCommand"), existing.Description)) == DialogResult.No) { return; } _keybinds.SetKey(existing, Keys.None); //既存のやつに割当をクリア FindItemFromTag(existing).SubItems[2].Text = ""; } //設定を書き換え _keybinds.SetKey(cmd, key); _keyConfigList.SelectedItems[0].SubItems[2].Text = FormatKey(key); }
private void panelDrop_DragDrop(object sender, DragEventArgs e) { if (e.Effect == DragDropEffects.Copy) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = e.Data.GetData(DataFormats.FileDrop) as string[]; if (files != null) { if (!checkRecursive.Checked && ContainsDirectory(files)) { string message = SFTPPlugin.Instance.StringResource.GetString("SCPForm.RecursiveOptionIsRequired"); DialogResult result = GUtil.AskUserYesNo(this, message, MessageBoxIcon.Information); if (result != DialogResult.Yes) { return; } this.checkRecursive.Checked = true; } StartUpload(files); } } } }
private void OnOK(object sender, EventArgs args) { this.DialogResult = DialogResult.None; try { SSH2UserAuthKey key = SSH2UserAuthKey.FromSECSHStyleFile(_tKeyFile.Text, _tCurrentPassphrase.Text); if (_tNewPassphrase.Text != _tNewPassphraseAgain.Text) { GUtil.Warning(this, GApp.Strings.GetString("Message.ChangePassphrase.PassphraseMismatch")); } else { if (_tNewPassphrase.Text.Length > 0 || GUtil.AskUserYesNo(this, GApp.Strings.GetString("Message.ChangePassphrase.AskEmptyPassphrase")) == DialogResult.Yes) { FileStream s = new FileStream(_tKeyFile.Text, FileMode.Create); key.WritePrivatePartInSECSHStyleFile(s, "", _tNewPassphrase.Text); s.Close(); GUtil.Warning(this, GApp.Strings.GetString("Message.ChangePassphrase.NotifyChanged"), MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } } } catch (Exception ex) { GUtil.Warning(this, ex.Message); } }
protected bool ConfirmToUse(Form ownerForm, string feature) { string messageFormat = SFTPPlugin.Instance.StringResource.GetString("Common.WarnExperimentalFormat"); string message = String.Format(messageFormat, feature); DialogResult result = GUtil.AskUserYesNo(ownerForm, message, MessageBoxIcon.Warning); return(result == DialogResult.Yes); }
private bool VerifyPassphrase() { if (_passphraseBox.Text != _confirmBox.Text) { GUtil.Warning(this, GApp.Strings.GetString("Message.KeyGenWizard.NotMatch")); return(false); } else if (_passphraseBox.Text.Length == 0) { return(DialogResult.Yes == GUtil.AskUserYesNo(this, GApp.Strings.GetString("Message.KeyGenWizard.ConfirmEmptyPassphrase"))); } else { return(true); } }
private void _makeFileAssociationGts_Click(object sender, EventArgs e) { StringResource sr = OptionDialogPlugin.Instance.Strings; if (GUtil.AskUserYesNo(this.ParentForm, sr.GetString("Form.OptionDialog.MakeFileAssociationGtsConfirmation")) != DialogResult.Yes) { return; } try { string exePath = Path.GetFullPath(Application.ExecutablePath); if (exePath.ToLower().EndsWith(".vshost.exe")) { exePath = exePath.Substring(0, exePath.Length - 11) + ".exe"; } if (!File.Exists(exePath)) { throw new Exception("Cannot determine the path of an executable file."); } const string APPID = "Poderosa"; // [HKEY_CURRENT_USER\Software\Classes\.gts] Registry.CurrentUser .OpenSubKey(@"Software\Classes", true) .CreateSubKey(".gts") .SetValue("", APPID, RegistryValueKind.String); // [HKEY_CURRENT_USER\Software\Classes\<APPID>\shell\open\command] string command = "\"" + exePath + "\" -open \"%1\""; Registry.CurrentUser .OpenSubKey(@"Software\Classes", true) .CreateSubKey(APPID + @"\shell\open\command") .SetValue("", command, RegistryValueKind.String); MessageBox.Show(this.ParentForm, sr.GetString("Form.OptionDialog.FileAssociationChanged"), "Poderosa", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { RuntimeUtil.SilentReportException(ex); MessageBox.Show(this.ParentForm, sr.GetString("Form.OptionDialog.FileAssociationFailed"), "Poderosa", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public override bool Commit(ContainerOptions options) { string itemname = null; bool successful = false; try { options.ActionOnLaunch = ToActionOnLaunchCID(_actionOnLaunchBox.SelectedIndex); itemname = GApp.Strings.GetString("Caption.OptionDialog.MRUCount"); options.MRUSize = Int32.Parse(_MRUSize.Text); itemname = GApp.Strings.GetString("Caption.OptionDialog.SerialPortCount"); options.SerialCount = Int32.Parse(_serialCount.Text); options.ShowTabBar = _showTabBar.Checked; options.ShowToolBar = _showToolBar.Checked; options.SplitterPreservesRatio = _splitterRatioBox.Checked; options.TabBarStyle = (TabBarStyle)_tabStyleBox.SelectedIndex; options.ShowStatusBar = _showStatusBar.Checked; options.AskCloseOnExit = _askCloseOnExit.Checked; options.QuitAppWithLastPane = _quitAppWithLastPane.Checked; if (GApp.Options.OptionPreservePlace != (OptionPreservePlace)_optionPreservePlace.SelectedIndex && !GApp.IsRegistryWritable) { GUtil.Warning(this, GApp.Strings.GetString("Message.OptionDialog.RegistryWriteAuthWarning")); return(false); } options.OptionPreservePlace = (OptionPreservePlace)_optionPreservePlace.SelectedIndex; options.Language = (Language)_languageBox.SelectedIndex; if (options.Language == Language.Japanese && GApp.Options.EnvLanguage == Language.English) { if (GUtil.AskUserYesNo(this, GApp.Strings.GetString("Message.OptionDialog.AskJapaneseFont")) == DialogResult.No) { return(false); } } successful = true; } catch (FormatException) { GUtil.Warning(this, String.Format(GApp.Strings.GetString("Message.OptionDialog.InvalidItem"), itemname)); } catch (InvalidOptionException ex) { GUtil.Warning(this, ex.Message); } return(successful); }
private void OnAllocateKey(object sender, EventArgs args) { if (_keyConfigList.SelectedItems.Count == 0) { return; } CID id = (CID)_keyConfigList.SelectedItems[0].Tag; Keys key = _hotKey.Key; int code = GUtil.KeyToControlCode(key); if (code != -1) { if (GUtil.AskUserYesNo(this, String.Format(GApp.Strings.GetString("Message.OptionDialog.AskOverwriteToASCIIInput"), _hotKey.Text, code)) == DialogResult.No) { return; } } Commands.Entry existing = _commands.FindEntry(key); if (existing != null && existing.CID != id) { if (GUtil.AskUserYesNo(this, String.Format(GApp.Strings.GetString("Message.OptionDialog.AskOverwriteCommand"), existing.Description)) == DialogResult.No) { return; } existing.Key = Keys.None; existing.Modifiers = Keys.None; FindListViewItem(existing.CID).SubItems[2].Text = ""; } //設定を書き換え Commands.Entry e = _commands.FindEntry(id); Debug.Assert(e != null); _commands.ModifyKey(e.CID, key & Keys.Modifiers, key & Keys.KeyCode); _keyConfigList.SelectedItems[0].SubItems[2].Text = e.KeyDisplayString; }
public bool Commit(ITerminalEmulatorOptions options) { StringResource sr = OptionDialogPlugin.Instance.Strings; bool successful = false; string itemname = null; try { options.CloseOnDisconnect = _closeOnDisconnect.Checked; options.BeepOnBellChar = _beepOnBellChar.Checked; options.AllowsScrollInAppMode = _allowsScrollInAppMode.Checked; itemname = sr.GetString("Caption.OptionDialog.BufferLineCount"); options.TerminalBufferSize = Int32.Parse(_bufferSize.Text); itemname = sr.GetString("Caption.OptionDialog.MRUCount"); options.CharDecodeErrorBehavior = ((EnumListItem <WarningOption>)_charDecodeErrorBehaviorBox.SelectedItem).Value; options.DisconnectNotification = ((EnumListItem <WarningOption>)_disconnectNotification.SelectedItem).Value; if (_keepAliveCheck.Checked) { itemname = sr.GetString("Caption.OptionDialog.KeepAliveInterval"); options.KeepAliveInterval = Int32.Parse(_keepAliveIntervalBox.Text) * 60000; } else { options.KeepAliveInterval = 0; } foreach (char ch in _additionalWordElementBox.Text) { if (ch >= 0x100) { GUtil.Warning(this, sr.GetString("Message.OptionDialog.InvalidAdditionalWordElement")); return(false); } } options.AdditionalWordElement = _additionalWordElementBox.Text; if (_autoLogCheckBox.Checked) { if (_defaultLogDirectory.Text.Length == 0) { GUtil.Warning(this, sr.GetString("Message.OptionDialog.EmptyLogDirectory")); return(false); } options.DefaultLogType = ((EnumListItem <LogType>)_defaultLogTypeBox.SelectedItem).Value; if (!Directory.Exists(_defaultLogDirectory.Text)) { if (GUtil.AskUserYesNo(this, String.Format(sr.GetString("Message.OptionDialog.AskCreateDirectory"), _defaultLogDirectory.Text)) == DialogResult.Yes) { try { System.IO.Directory.CreateDirectory(_defaultLogDirectory.Text); } catch (Exception) { GUtil.Warning(this, String.Format(sr.GetString("Message.OptionDialog.FailedCreateDirectory"))); } } else { return(false); } } options.DefaultLogDirectory = _defaultLogDirectory.Text; } else { options.DefaultLogType = LogType.None; } options.EnableComplementForNewConnections = _enableComplementForNewConnections.Checked; options.CommandPopupAlwaysOnTop = _commandPopupAlwaysOnTop.Checked; options.CommandPopupInTaskBar = _commandPopupInTaskBar.Checked; options.AlertOnPasteNewLineChar = _alertOnPasteNewLineCharCheck.Checked; successful = true; } catch (InvalidOptionException ex) { GUtil.Warning(this, ex.Message); } catch (Exception) { GUtil.Warning(this, String.Format(sr.GetString("Message.OptionDialog.InvalidItem"), itemname)); } return(successful); }
public override bool Commit(ContainerOptions options) { bool successful = false; string itemname = null; try { options.CloseOnDisconnect = _closeOnDisconnect.Checked; options.BeepOnBellChar = _beepOnBellChar.Checked; options.AdjustsTabTitleToWindowTitle = _adjustsTabTitleToWindowTitle.Checked; options.AllowsScrollInAppMode = _allowsScrollInAppMode.Checked; itemname = GApp.Strings.GetString("Caption.OptionDialog.BufferLineCount"); options.TerminalBufferSize = Int32.Parse(_bufferSize.Text); itemname = GApp.Strings.GetString("Caption.OptionDialog.MRUCount"); options.WarningOption = (WarningOption)_badCharBox.SelectedIndex; options.DisconnectNotification = (DisconnectNotification)_disconnectNotification.SelectedIndex; if (_keepAliveCheck.Checked) { itemname = GApp.Strings.GetString("Caption.OptionDialog.KeepAliveInterval"); options.KeepAliveInterval = Int32.Parse(_keepAliveIntervalBox.Text) * 60000; if (options.KeepAliveInterval <= 0) { throw new FormatException(); } } else { options.KeepAliveInterval = 0; } if (_autoLogCheckBox.Checked) { if (_defaultLogDirectory.Text.Length == 0) { GUtil.Warning(this, GApp.Strings.GetString("Message.OptionDialog.EmptyLogDirectory")); return(false); } options.DefaultLogType = (LogType)EnumDescAttribute.For(typeof(LogType)).FromDescription(_defaultLogTypeBox.Text, LogType.None); if (!System.IO.Directory.Exists(_defaultLogDirectory.Text)) { if (GUtil.AskUserYesNo(this, String.Format(GApp.Strings.GetString("Message.OptionDialog.AskCreateDirectory"), _defaultLogDirectory.Text)) == DialogResult.Yes) { System.IO.Directory.CreateDirectory(_defaultLogDirectory.Text); } else { return(false); } } options.DefaultLogDirectory = _defaultLogDirectory.Text; } else { options.DefaultLogType = LogType.None; } successful = true; } catch (FormatException) { GUtil.Warning(this, String.Format(GApp.Strings.GetString("Message.OptionDialog.InvalidItem"), itemname)); } catch (InvalidOptionException ex) { GUtil.Warning(this, ex.Message); } return(successful); }