public SaveAsXml ( System.Stream stream, Encoding encoding ) : void | ||
stream | System.Stream | |
encoding | Encoding | |
Результат | void |
// 销毁 public void Destroy(DockPanel dockPanel) { // 保存配置界面 String applicationPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; String szConfigFile = Path.Combine(Path.GetDirectoryName(applicationPath), "WorldEditor.DockPanel.config"); dockPanel.SaveAsXml(szConfigFile); }
private void Home_FormClosing(object sender, FormClosingEventArgs e) { string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "OSMaker.config"); if (m_bSaveLayout) { dockPanel.SaveAsXml(configFile); } else if (File.Exists(configFile)) { File.Delete(configFile); } Application.Exit(); }
internal static void SaveAsXml(string filePath, WeifenLuo.WinFormsUI.Docking.DockPanel dockPanel) { using (FileStream fs = new FileStream(filePath, FileMode.Create)) { using (MemoryStream ms = new MemoryStream(1 << 12)) { dockPanel.SaveAsXml(ms, System.Text.Encoding.ASCII); byte[] bytes = ms.ToArray(); for (int i = 0; i < bytes.Length; i++) { bytes[i] += (byte)i; } fs.Write(bytes, 0, bytes.Length); } } }
public GR.Memory.ByteBuffer ToBuffer() { GR.Memory.ByteBuffer SettingsData = new GR.Memory.ByteBuffer(); foreach (ToolInfo tool in ToolInfos) { GR.IO.FileChunk chunkTool = tool.ToChunk(); SettingsData.Append(chunkTool.ToBuffer()); } /* * foreach ( C64Studio.LayoutInfo layout in ToolLayout.Values ) * { * layout.StoreLayout(); * SettingsData.Append( layout.ToBuffer() ); * }*/ foreach (AcceleratorKey key in Accelerators.Values) { GR.IO.FileChunk chunkKey = key.ToChunk(); SettingsData.Append(chunkKey.ToBuffer()); } GR.IO.FileChunk chunkSoundSettings = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_SOUND); chunkSoundSettings.AppendU8((byte)(PlaySoundOnSuccessfulBuild ? 1 : 0)); chunkSoundSettings.AppendU8((byte)(PlaySoundOnBuildFailure ? 1 : 0)); chunkSoundSettings.AppendU8((byte)(PlaySoundOnSearchFoundNoItem ? 1 : 0)); SettingsData.Append(chunkSoundSettings.ToBuffer()); GR.IO.FileChunk chunkMainWindowPlacement = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_WINDOW); chunkMainWindowPlacement.AppendString(MainWindowPlacement); SettingsData.Append(chunkMainWindowPlacement.ToBuffer()); GR.IO.FileChunk chunkTabs = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_TABS); chunkTabs.AppendI32(TabSize); chunkTabs.AppendU8((byte)(AllowTabs ? 1 : 0)); chunkTabs.AppendU8((byte)(TabConvertToSpaces ? 1 : 0)); SettingsData.Append(chunkTabs.ToBuffer()); GR.IO.FileChunk chunkFont = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_FONT); chunkFont.AppendString(SourceFontFamily); chunkFont.AppendI32((int)SourceFontSize); chunkFont.AppendU8((byte)(BASICUseNonC64Font ? 1 : 0)); chunkFont.AppendString(BASICSourceFontFamily); chunkFont.AppendI32((int)BASICSourceFontSize); SettingsData.Append(chunkFont.ToBuffer()); foreach (Types.SyntaxElement element in SyntaxColoring.Keys) { GR.IO.FileChunk chunkSyntaxColor = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_SYNTAX_COLORING); chunkSyntaxColor.AppendU32((uint)element); chunkSyntaxColor.AppendU32(SyntaxColoring[element].FGColor); chunkSyntaxColor.AppendU32(SyntaxColoring[element].BGColor); chunkSyntaxColor.AppendI32(SyntaxColoring[element].BGColorAuto ? 1 : 0); SettingsData.Append(chunkSyntaxColor.ToBuffer()); } GR.IO.FileChunk chunkUI = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_UI); chunkUI.AppendU8((byte)(ToolbarActiveMain ? 1 : 0)); chunkUI.AppendU8((byte)(ToolbarActiveDebugger ? 1 : 0)); SettingsData.Append(chunkUI.ToBuffer()); GR.IO.FileChunk chunkRunEmu = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_RUN_EMULATOR); chunkRunEmu.AppendU8((byte)(TrueDriveEnabled ? 1 : 0)); SettingsData.Append(chunkRunEmu.ToBuffer()); GR.IO.FileChunk chunkDefaults = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_DEFAULTS); chunkDefaults.AppendString(DefaultProjectBasePath); SettingsData.Append(chunkDefaults.ToBuffer()); // dockpanel layout GR.IO.FileChunk chunkLayout = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_DPS_LAYOUT); System.IO.MemoryStream memOut = new System.IO.MemoryStream(); PanelMain.SaveAsXml(memOut, Encoding.UTF8); byte[] layoutData = memOut.ToArray(); string xmlOutText = System.Text.Encoding.UTF8.GetString(layoutData); // remove dummy elements (layout of non-tool windows) GR.Strings.XMLParser parser = new GR.Strings.XMLParser(); if (!parser.Parse(xmlOutText)) { Debug.Log("Could not parse XML"); } else { EnumElements(parser); xmlOutText = parser.ToText(); } //Debug.Log( xmlOutText ); chunkLayout.AppendU32((uint)layoutData.Length); chunkLayout.Append(layoutData); SettingsData.Append(chunkLayout.ToBuffer()); memOut.Close(); memOut.Dispose(); GR.IO.FileChunk chunkFindReplace = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_FIND_REPLACE); chunkFindReplace.AppendU8((byte)(LastFindIgnoreCase ? 1 : 0)); chunkFindReplace.AppendU8((byte)(LastFindWholeWord ? 1 : 0)); chunkFindReplace.AppendU8((byte)(LastFindRegexp ? 1 : 0)); chunkFindReplace.AppendU8((byte)(LastFindWrap ? 1 : 0)); chunkFindReplace.AppendU8((byte)LastFindTarget); chunkFindReplace.AppendI32(FindArguments.Count); foreach (var findArg in FindArguments) { chunkFindReplace.AppendString(findArg); } chunkFindReplace.AppendI32(ReplaceArguments.Count); foreach (var replaceArg in ReplaceArguments) { chunkFindReplace.AppendString(replaceArg); } SettingsData.Append(chunkFindReplace.ToBuffer()); GR.IO.FileChunk chunkIgnoredWarnings = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_IGNORED_WARNINGS); chunkIgnoredWarnings.AppendI32(IgnoredWarnings.Count); foreach (Types.ErrorCode ignoredWarning in IgnoredWarnings) { chunkIgnoredWarnings.AppendI32((int)ignoredWarning); } SettingsData.Append(chunkIgnoredWarnings.ToBuffer()); foreach (var pair in GenericTools) { GR.Memory.ByteBuffer data = pair.Value.DisplayDetails(); if (data != null) { GR.IO.FileChunk chunkPanelDisplayDetails = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_PANEL_DISPLAY_DETAILS); chunkPanelDisplayDetails.AppendString(pair.Key); chunkPanelDisplayDetails.AppendU32(data.Length); chunkPanelDisplayDetails.Append(data); SettingsData.Append(chunkPanelDisplayDetails.ToBuffer()); } } // ASM editor settings GR.IO.FileChunk chunkASMEditor = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_ASSEMBLER_EDITOR); chunkASMEditor.AppendU8((byte)(ASMHideLineNumbers ? 1 : 0)); SettingsData.Append(chunkASMEditor.ToBuffer()); // BASIC settings GR.IO.FileChunk chunkBASICParser = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_BASIC_PARSER); chunkBASICParser.AppendU8((byte)(BASICStripSpaces ? 1 : 0)); SettingsData.Append(chunkBASICParser.ToBuffer()); // BASIC key map GR.IO.FileChunk chunkBASICKeyMap = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_BASIC_KEYMAP); chunkBASICKeyMap.AppendI32(BASICKeyMap.Keymap.Count); foreach (var entry in BASICKeyMap.Keymap) { chunkBASICKeyMap.AppendU32((uint)entry.Key); chunkBASICKeyMap.AppendI32((int)entry.Value.KeyboardKey); } SettingsData.Append(chunkBASICKeyMap.ToBuffer()); // environment behaviour settings GR.IO.FileChunk chunkEnvironment = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_ENVIRONMENT); chunkEnvironment.AppendU8((byte)(AutoOpenLastSolution ? 1 : 0)); SettingsData.Append(chunkEnvironment.ToBuffer()); return(SettingsData); }
public void SaveDockSettings(DockPanel dockPanel) { dockPanel.SaveAsXml(kDockSettingsFile); }