public void InitializePreference(IPreferenceBuilder builder, IPreferenceFolder folder) { _schemeTemplate = builder.DefineFolderArray(folder, this, "scheme"); _preferenceFolderArray = folder.FindChildFolderArray("scheme"); Debug.Assert(_preferenceFolderArray != null); _namePreference = builder.DefineStringValue(_schemeTemplate, "name", "", null); _promptPreference = builder.DefineStringValue(_schemeTemplate, "prompt", GenericShellScheme.DEFAULT_PROMPT_REGEX, null); _backspacePreference = builder.DefineStringValue(_schemeTemplate, "backspace", "", null); _commandListPreference = builder.DefineStringValue(_schemeTemplate, "commands", "", null); }
public void InitializePreference(IPreferenceBuilder builder, IPreferenceFolder folder) { _schemeTemplate = builder.DefineFolderArray(folder, this, "scheme"); _preferenceFolderArray = folder.FindChildFolderArray("scheme"); Debug.Assert(_preferenceFolderArray != null); _namePreference = builder.DefineStringValue(_schemeTemplate, "name", "", null); _promptPreference = builder.DefineStringValue(_schemeTemplate, "prompt", GenericShellScheme.DEFAULT_PROMPT_REGEX, null); _backspacePreference = builder.DefineStringValue(_schemeTemplate, "backspace", "", null); _commandListPreference = builder.DefineStringValue(_schemeTemplate, "commands", "", null); }
public void SaveToPreference() { IPreferenceFolderArray ma = _rootPreference.FindChildFolderArray(_moduleDefinitionTemplate.Id); ma.Clear(); foreach (MacroModule m in _entries) { IPreferenceFolder f = ma.CreateNewFolder(); ma.ConvertItem(f, _pathPreferenceTemplate).AsString().Value = m.Path; ma.ConvertItem(f, _titlePreferenceTemplate).AsString().Value = m.Title; ma.ConvertItem(f, _additionalAssembliesPreferenceTemplate).AsString().Value = m.FormatAdditionalAssemblies(); ma.ConvertItem(f, _tracePreferenceTemplate).AsBool().Value = m.DebugMode; } }
public void TestFolderArrayRead() { FolderArraySupplier supplier = new FolderArraySupplier(); InitPreference(supplier, "unittest {\r\n foo {\r\n i=20\r\n s=vieri\r\n}\r\nfoo {\r\n i=10\r\n s=bobo\r\n}\r\n"); IPreferenceFolder root = supplier.RootFolder; IPreferenceFolderArray array = root.FindChildFolderArray("foo"); Assert.AreEqual(2, array.Folders.Length); IPreferenceFolder foo1 = array.Folders[0]; Assert.AreEqual("vieri", ((IStringPreferenceItem)foo1.FindItem("s")).Value); //ToDo 文字列検索はいやらしい IPreferenceFolder foo2 = array.Folders[1]; Assert.AreEqual("bobo", ((IStringPreferenceItem)foo2.FindItem("s")).Value); }
public void InitializePreference(IPreferenceBuilder builder, IPreferenceFolder folder) { _originalFolder = folder; _adapter = new CoreServicePreferenceAdapter(folder); _adapter.DefineItems(builder); AboutBoxUtil.InitPreference(builder, folder); _windowTemplatePreference = builder.DefineFolderArray(folder, this, "mainwindow"); _windowArrayPreference = folder.FindChildFolderArray("mainwindow"); Debug.Assert(_windowArrayPreference != null); _windowPositionPreference = builder.DefineStringValue(_windowTemplatePreference, "position", "", null); _windowSplitFormatPreference = builder.DefineStringValue(_windowTemplatePreference, "format", "", null); _toolBarFormatPreference = builder.DefineStringValue(_windowTemplatePreference, "toolbar", "", null); _tabRowCountPreference = builder.DefineIntValue(_windowTemplatePreference, "tabrowcount", 1, null); //add listener folder.AddChangeListener(new ChangeListener(_adapter)); }
public void TestFolderArrayWrite() { FolderArraySupplier supplier = new FolderArraySupplier(); InitPreference(supplier, "unittest {\r\n}\r\n"); IPreferenceFolder root = supplier.RootFolder; IPreferenceFolderArray array = root.FindChildFolderArray("foo"); IPreferenceFolder foo1 = array.CreateNewFolder(); IPreferenceFolder foo2 = array.CreateNewFolder(); //((IStringPreferenceItem)foo2.FindItem("s")).Value = "zlatan"; //((IIntPreferenceItem)foo1.FindItem("i")).Value = 5; array.ConvertItem(foo2, supplier._s).AsString().Value = "zlatan"; array.ConvertItem(foo1, supplier._i).AsInt().Value = 5; _poderosaApplication.Shutdown(); Assert.AreEqual("unittest {\r\n foo {\r\n i=5\r\n }\r\n foo {\r\n s=zlatan\r\n }\r\n}\r\n", Dump(_rootNote)); }
public void LoadFromPreference() { IPreferenceFolderArray ma = _rootPreference.FindChildFolderArray(_moduleDefinitionTemplate.Id); if (ma == null || ma.Folders.Length == 0) { InitSample(); } else { _entries.Clear(); foreach (IPreferenceFolder f in ma.Folders) { MacroModule m = new MacroModule(_entries.Count, ma.ConvertItem(f, _pathPreferenceTemplate).AsString().Value, ma.ConvertItem(f, _titlePreferenceTemplate).AsString().Value); m.AdditionalAssemblies = ma.ConvertItem(f, _additionalAssembliesPreferenceTemplate).AsString().Value.Split(';'); m.DebugMode = ma.ConvertItem(f, _tracePreferenceTemplate).AsBool().Value; _entries.Add(m); } } _touchedPreference = true; }
public int TabRowCountAt(int index) { IPreferenceFolderArray a = _windowArrayPreference; return(a.ConvertItem(a.Folders[index], _tabRowCountPreference).AsInt().Value); }
public string ToolBarFormatAt(int index) { IPreferenceFolderArray a = _windowArrayPreference; return(a.ConvertItem(a.Folders[index], _toolBarFormatPreference).AsString().Value); }
public string WindowPositionAt(int index) { IPreferenceFolderArray a = _windowArrayPreference; return(a.ConvertItem(a.Folders[index], _windowPositionPreference).AsString().Value); }
public void InitializePreference(IPreferenceBuilder builder, IPreferenceFolder folder) { _originalFolder = folder; _adapter = new CoreServicePreferenceAdapter(folder); _adapter.DefineItems(builder); AboutBoxUtil.InitPreference(builder, folder); _windowTemplatePreference = builder.DefineFolderArray(folder, this, "mainwindow"); _windowArrayPreference = folder.FindChildFolderArray("mainwindow"); Debug.Assert(_windowArrayPreference != null); _windowPositionPreference = builder.DefineStringValue(_windowTemplatePreference, "position", "", null); _windowSplitFormatPreference = builder.DefineStringValue(_windowTemplatePreference, "format", "", null); _toolBarFormatPreference = builder.DefineStringValue(_windowTemplatePreference, "toolbar", "", null); _tabRowCountPreference = builder.DefineIntValue(_windowTemplatePreference, "tabrowcount", 1, null); //add listener folder.AddChangeListener(new ChangeListener(_adapter)); }
public void Import(IPreferenceFolderArray newvalues) { throw new Exception("unsupported"); }
/// <summary> /// 読み込み /// </summary> public void LoadFromPreference() { IPreferenceFolderArray fa = _rootPreference.FindChildFolderArray(_profileDefinition.Id); foreach (IPreferenceFolder f in fa.Folders) { ConnectProfileStruct prof = new ConnectProfileStruct(); prof.HostName = fa.ConvertItem(f, _hostName).AsString().Value; if (fa.ConvertItem(f, _protocol).AsString().Value == "Telnet") { prof.Protocol = ConnectionMethod.Telnet; } else if (fa.ConvertItem(f, _protocol).AsString().Value == "SSH1") { prof.Protocol = ConnectionMethod.SSH1; } else if (fa.ConvertItem(f, _protocol).AsString().Value == "SSH2") { prof.Protocol = ConnectionMethod.SSH2; } prof.Port = fa.ConvertItem(f, _port).AsInt().Value; if (fa.ConvertItem(f, _authType).AsString().Value == "Password") { prof.AuthType = AuthType.Password; } else if (fa.ConvertItem(f, _authType).AsString().Value == "PublicKey") { prof.AuthType = AuthType.PublicKey; } else if (fa.ConvertItem(f, _authType).AsString().Value == "KeyboardInteractive") { prof.AuthType = AuthType.KeyboardInteractive; } prof.KeyFile = fa.ConvertItem(f, _keyFile).AsString().Value; prof.UserName = fa.ConvertItem(f, _userName).AsString().Value; prof.Password = fa.ConvertItem(f, _password).AsString().Value; prof.AutoLogin = fa.ConvertItem(f, _autoLogin).AsBool().Value; prof.LoginPrompt = fa.ConvertItem(f, _loginPrompt).AsString().Value; prof.PasswordPrompt = fa.ConvertItem(f, _passwordPrompt).AsString().Value; prof.ExecCommand = fa.ConvertItem(f, _execCommand).AsString().Value; prof.SUUserName = fa.ConvertItem(f, _suUserName).AsString().Value; prof.SUPassword = fa.ConvertItem(f, _suPassword).AsString().Value; prof.SUType = fa.ConvertItem(f, _suType).AsString().Value; if (fa.ConvertItem(f, _charCode).AsString().Value == "ISO8859_1") { prof.CharCode = EncodingType.ISO8859_1; } else if (fa.ConvertItem(f, _charCode).AsString().Value == "UTF8") { prof.CharCode = EncodingType.UTF8; } else if (fa.ConvertItem(f, _charCode).AsString().Value == "EUC_JP") { prof.CharCode = EncodingType.EUC_JP; } else if (fa.ConvertItem(f, _charCode).AsString().Value == "SHIFT_JIS") { prof.CharCode = EncodingType.SHIFT_JIS; } else if (fa.ConvertItem(f, _charCode).AsString().Value == "GB2312") { prof.CharCode = EncodingType.GB2312; } else if (fa.ConvertItem(f, _charCode).AsString().Value == "BIG5") { prof.CharCode = EncodingType.BIG5; } else if (fa.ConvertItem(f, _charCode).AsString().Value == "EUC_CN") { prof.CharCode = EncodingType.EUC_CN; } else if (fa.ConvertItem(f, _charCode).AsString().Value == "EUC_KR") { prof.CharCode = EncodingType.EUC_KR; } else if (fa.ConvertItem(f, _charCode).AsString().Value == "UTF8_Latin") { prof.CharCode = EncodingType.UTF8_Latin; } else if (fa.ConvertItem(f, _charCode).AsString().Value == "OEM850") { prof.CharCode = EncodingType.OEM850; } if (fa.ConvertItem(f, _newLine).AsString().Value == "CR") { prof.NewLine = NewLine.CR; } else if (fa.ConvertItem(f, _newLine).AsString().Value == "LF") { prof.NewLine = NewLine.LF; } else if (fa.ConvertItem(f, _newLine).AsString().Value == "CRLF") { prof.NewLine = NewLine.CRLF; } prof.TelnetNewLine = fa.ConvertItem(f, _telnetNewLine).AsBool().Value; if (fa.ConvertItem(f, _terminalType).AsString().Value == "KTerm") { prof.TerminalType = TerminalType.KTerm; } else if (fa.ConvertItem(f, _terminalType).AsString().Value == "VT100") { prof.TerminalType = TerminalType.VT100; } else if (fa.ConvertItem(f, _terminalType).AsString().Value == "XTerm") { prof.TerminalType = TerminalType.XTerm; } prof.CommandSendInterval = fa.ConvertItem(f, _commandSendInterval).AsInt().Value; prof.PromptRecvTimeout = fa.ConvertItem(f, _promptRecvTimeout).AsInt().Value; prof.ProfileItemColor = Poderosa.ParseUtil.ParseColor(fa.ConvertItem(f, _profileItemColor.PreferenceItem).AsString().Value, Color.Black); prof.Description = fa.ConvertItem(f, _description).AsString().Value; // 表示オプション prof.RenderProfile = ConnectProfilePlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile(); prof.RenderProfile.ForeColor = Poderosa.ParseUtil.ParseColor(fa.ConvertItem(f, _terminalFontColor.PreferenceItem).AsString().Value, Color.White); prof.RenderProfile.BackColor = Poderosa.ParseUtil.ParseColor(fa.ConvertItem(f, _terminalBGColor.PreferenceItem).AsString().Value, Color.Black); prof.RenderProfile.ESColorSet = new EscapesequenceColorSet(); prof.RenderProfile.ESColorSet.ResetToDefault(); prof.RenderProfile.ESColorSet[0] = new ESColor(Poderosa.ParseUtil.ParseColor(fa.ConvertItem(f, _terminalESCColor0.PreferenceItem).AsString().Value, Color.Black), false); prof.RenderProfile.ESColorSet[1] = new ESColor(Poderosa.ParseUtil.ParseColor(fa.ConvertItem(f, _terminalESCColor1.PreferenceItem).AsString().Value, Color.Red), false); prof.RenderProfile.ESColorSet[2] = new ESColor(Poderosa.ParseUtil.ParseColor(fa.ConvertItem(f, _terminalESCColor2.PreferenceItem).AsString().Value, Color.Green), false); prof.RenderProfile.ESColorSet[3] = new ESColor(Poderosa.ParseUtil.ParseColor(fa.ConvertItem(f, _terminalESCColor3.PreferenceItem).AsString().Value, Color.Yellow), false); prof.RenderProfile.ESColorSet[4] = new ESColor(Poderosa.ParseUtil.ParseColor(fa.ConvertItem(f, _terminalESCColor4.PreferenceItem).AsString().Value, Color.Blue), false); prof.RenderProfile.ESColorSet[5] = new ESColor(Poderosa.ParseUtil.ParseColor(fa.ConvertItem(f, _terminalESCColor5.PreferenceItem).AsString().Value, Color.Magenta), false); prof.RenderProfile.ESColorSet[6] = new ESColor(Poderosa.ParseUtil.ParseColor(fa.ConvertItem(f, _terminalESCColor6.PreferenceItem).AsString().Value, Color.Cyan), false); prof.RenderProfile.ESColorSet[7] = new ESColor(Poderosa.ParseUtil.ParseColor(fa.ConvertItem(f, _terminalESCColor7.PreferenceItem).AsString().Value, Color.White), false); prof.RenderProfile.FontName = fa.ConvertItem(f, _terminalAsciiFont).AsString().Value; prof.RenderProfile.CJKFontName = fa.ConvertItem(f, _terminalCjkFont).AsString().Value; prof.RenderProfile.FontSize = fa.ConvertItem(f, _terminalFontSize).AsInt().Value; prof.RenderProfile.UseClearType = fa.ConvertItem(f, _terminalClearType).AsBool().Value; prof.RenderProfile.EnableBoldStyle = fa.ConvertItem(f, _terminalBoldStyle).AsBool().Value; prof.RenderProfile.ForceBoldStyle = fa.ConvertItem(f, _terminalForceBoldStyle).AsBool().Value; prof.RenderProfile.BackgroundImageFileName = fa.ConvertItem(f, _terminalBGImage).AsString().Value; if (fa.ConvertItem(f, _terminalBGImagePos).AsString().Value == "Center") { prof.RenderProfile.ImageStyle = ImageStyle.Center; } else if (fa.ConvertItem(f, _terminalBGImagePos).AsString().Value == "TopLeft") { prof.RenderProfile.ImageStyle = ImageStyle.TopLeft; } else if (fa.ConvertItem(f, _terminalBGImagePos).AsString().Value == "TopRight") { prof.RenderProfile.ImageStyle = ImageStyle.TopRight; } else if (fa.ConvertItem(f, _terminalBGImagePos).AsString().Value == "BottomLeft") { prof.RenderProfile.ImageStyle = ImageStyle.BottomLeft; } else if (fa.ConvertItem(f, _terminalBGImagePos).AsString().Value == "BottomRight") { prof.RenderProfile.ImageStyle = ImageStyle.BottomRight; } else if (fa.ConvertItem(f, _terminalBGImagePos).AsString().Value == "Scaled") { prof.RenderProfile.ImageStyle = ImageStyle.Scaled; } else if (fa.ConvertItem(f, _terminalBGImagePos).AsString().Value == "HorizontalFit") { prof.RenderProfile.ImageStyle = ImageStyle.HorizontalFit; } else if (fa.ConvertItem(f, _terminalBGImagePos).AsString().Value == "VerticalFit") { prof.RenderProfile.ImageStyle = ImageStyle.VerticalFit; } // パスワード複合化 if (prof.Password != "") { prof.Password = DecryptString(prof.Password, ConnectProfilePlugin.PLUGIN_ID); } if (prof.SUPassword != "") { prof.SUPassword = DecryptString(prof.SUPassword, ConnectProfilePlugin.PLUGIN_ID); } // プロファイル追加 ConnectProfilePlugin.Profiles.AddProfile(prof); } _preferenceLoaded = true; }
/// <summary> /// 保存 /// </summary> public void SaveToPreference() { // 一度も読み込まれていない場合は読み込む(フォームが一度も表示されてない場合に設定が消滅してしまう) if (this.PreferenceLoaded != true) { this.LoadFromPreference(); } IPreferenceFolderArray fa = _rootPreference.FindChildFolderArray(_profileDefinition.Id); fa.Clear(); foreach (ConnectProfileStruct prof in ConnectProfilePlugin.Profiles) { IPreferenceFolder f = fa.CreateNewFolder(); // パスワード暗号化(キーはPLUGIN_ID) string pw = ""; string supw = ""; if (prof.Password != "") { pw = EncryptString(prof.Password, ConnectProfilePlugin.PLUGIN_ID); } if (prof.SUPassword != "") { supw = EncryptString(prof.SUPassword, ConnectProfilePlugin.PLUGIN_ID); } // 値代入 fa.ConvertItem(f, _hostName).AsString().Value = prof.HostName; fa.ConvertItem(f, _protocol).AsString().Value = prof.Protocol.ToString(); fa.ConvertItem(f, _port).AsInt().Value = prof.Port; fa.ConvertItem(f, _authType).AsString().Value = prof.AuthType.ToString(); fa.ConvertItem(f, _keyFile).AsString().Value = prof.KeyFile; fa.ConvertItem(f, _userName).AsString().Value = prof.UserName; fa.ConvertItem(f, _password).AsString().Value = (pw != null) ? pw : ""; fa.ConvertItem(f, _autoLogin).AsBool().Value = prof.AutoLogin; fa.ConvertItem(f, _loginPrompt).AsString().Value = prof.LoginPrompt; fa.ConvertItem(f, _passwordPrompt).AsString().Value = prof.PasswordPrompt; fa.ConvertItem(f, _execCommand).AsString().Value = prof.ExecCommand; fa.ConvertItem(f, _suUserName).AsString().Value = prof.SUUserName; fa.ConvertItem(f, _suPassword).AsString().Value = (supw != null) ? supw : ""; fa.ConvertItem(f, _suType).AsString().Value = prof.SUType; fa.ConvertItem(f, _charCode).AsString().Value = prof.CharCode.ToString(); fa.ConvertItem(f, _newLine).AsString().Value = prof.NewLine.ToString(); fa.ConvertItem(f, _telnetNewLine).AsBool().Value = prof.TelnetNewLine; fa.ConvertItem(f, _terminalType).AsString().Value = prof.TerminalType.ToString(); fa.ConvertItem(f, _terminalFontColor.PreferenceItem).AsString().Value = Convert.ToString(prof.RenderProfile.ForeColor.ToArgb(), 16); fa.ConvertItem(f, _terminalBGColor.PreferenceItem).AsString().Value = Convert.ToString(prof.RenderProfile.BackColor.ToArgb(), 16); fa.ConvertItem(f, _terminalESCColor0.PreferenceItem).AsString().Value = Convert.ToString(prof.RenderProfile.ESColorSet[0].Color.ToArgb(), 16); fa.ConvertItem(f, _terminalESCColor1.PreferenceItem).AsString().Value = Convert.ToString(prof.RenderProfile.ESColorSet[1].Color.ToArgb(), 16); fa.ConvertItem(f, _terminalESCColor2.PreferenceItem).AsString().Value = Convert.ToString(prof.RenderProfile.ESColorSet[2].Color.ToArgb(), 16); fa.ConvertItem(f, _terminalESCColor3.PreferenceItem).AsString().Value = Convert.ToString(prof.RenderProfile.ESColorSet[3].Color.ToArgb(), 16); fa.ConvertItem(f, _terminalESCColor4.PreferenceItem).AsString().Value = Convert.ToString(prof.RenderProfile.ESColorSet[4].Color.ToArgb(), 16); fa.ConvertItem(f, _terminalESCColor5.PreferenceItem).AsString().Value = Convert.ToString(prof.RenderProfile.ESColorSet[5].Color.ToArgb(), 16); fa.ConvertItem(f, _terminalESCColor6.PreferenceItem).AsString().Value = Convert.ToString(prof.RenderProfile.ESColorSet[6].Color.ToArgb(), 16); fa.ConvertItem(f, _terminalESCColor7.PreferenceItem).AsString().Value = Convert.ToString(prof.RenderProfile.ESColorSet[7].Color.ToArgb(), 16); fa.ConvertItem(f, _terminalAsciiFont).AsString().Value = prof.RenderProfile.FontName.ToString(); fa.ConvertItem(f, _terminalCjkFont).AsString().Value = prof.RenderProfile.CJKFontName.ToString(); fa.ConvertItem(f, _terminalFontSize).AsInt().Value = (int)prof.RenderProfile.FontSize; fa.ConvertItem(f, _terminalClearType).AsBool().Value = prof.RenderProfile.UseClearType; fa.ConvertItem(f, _terminalBoldStyle).AsBool().Value = prof.RenderProfile.EnableBoldStyle; fa.ConvertItem(f, _terminalForceBoldStyle).AsBool().Value = prof.RenderProfile.ForceBoldStyle; fa.ConvertItem(f, _terminalBGImage).AsString().Value = prof.RenderProfile.BackgroundImageFileName; fa.ConvertItem(f, _terminalBGImagePos).AsString().Value = prof.RenderProfile.ImageStyle.ToString(); fa.ConvertItem(f, _commandSendInterval).AsInt().Value = prof.CommandSendInterval; fa.ConvertItem(f, _promptRecvTimeout).AsInt().Value = prof.PromptRecvTimeout; fa.ConvertItem(f, _profileItemColor.PreferenceItem).AsString().Value = Convert.ToString(prof.ProfileItemColor.ToArgb(), 16); fa.ConvertItem(f, _description).AsString().Value = prof.Description; } }