private void FlushToDisk(string filePath) { try { XmlTextWriter PreferencesWriter = new XmlTextWriter(filePath, null); PreferencesWriter.Formatting = Formatting.Indented; PreferencesWriter.WriteStartDocument(); PreferencesWriter.WriteStartElement("KinoveaPreferences"); // Format version PreferencesWriter.WriteStartElement("FormatVersion"); PreferencesWriter.WriteString("1.2"); PreferencesWriter.WriteEndElement(); // Preferences PreferencesWriter.WriteElementString("HistoryCount", m_iFilesToSave.ToString()); PreferencesWriter.WriteElementString("Language", m_UICultureName); PreferencesWriter.WriteElementString("TimeCodeFormat", m_TimeCodeFormat.ToString()); PreferencesWriter.WriteElementString("SpeedUnit", m_SpeedUnit.ToString()); PreferencesWriter.WriteElementString("ImageAspectRatio", m_AspectRatio.ToString()); PreferencesWriter.WriteElementString("DeinterlaceByDefault", m_bDeinterlaceByDefault.ToString()); PreferencesWriter.WriteElementString("WorkingZoneSeconds", m_iWorkingZoneSeconds.ToString()); PreferencesWriter.WriteElementString("WorkingZoneMemory", m_iWorkingZoneMemory.ToString()); //m_DefaultFading.ToXml(PreferencesWriter, true); PreferencesWriter.WriteElementString("MaxFading", m_iMaxFading.ToString()); PreferencesWriter.WriteElementString("DrawOnPlay", m_bDrawOnPlay.ToString()); PreferencesWriter.WriteElementString("ExplorerThumbnailsSize", m_iExplorerThumbsSize.ToString()); PreferencesWriter.WriteElementString("ExplorerVisible", m_bIsExplorerVisible.ToString()); PreferencesWriter.WriteElementString("ExplorerSplitterDistance", m_iExplorerSplitterDistance.ToString()); PreferencesWriter.WriteElementString("ActiveFileBrowserTab", m_ActiveFileBrowserTab.ToString()); PreferencesWriter.WriteElementString("ExplorerFilesSplitterDistance", m_iExplorerFilesSplitterDistance.ToString()); PreferencesWriter.WriteElementString("ShortcutsFilesSplitterDistance", m_iShortcutsFilesSplitterDistance.ToString()); if (m_ShortcutFolders.Count > 0) { PreferencesWriter.WriteStartElement("Shortcuts"); foreach (ShortcutFolder sf in m_ShortcutFolders) { sf.ToXml(PreferencesWriter); } PreferencesWriter.WriteEndElement(); } if (m_RecentColors.Count > 0) { PreferencesWriter.WriteStartElement("RecentColors"); foreach (Color col in m_RecentColors) { PreferencesWriter.WriteStartElement("Color"); PreferencesWriter.WriteString(col.R.ToString() + ";" + col.G.ToString() + ";" + col.B.ToString()); PreferencesWriter.WriteEndElement(); } PreferencesWriter.WriteEndElement(); } if (m_CaptureImageDirectory != null && m_CaptureImageDirectory != "") { PreferencesWriter.WriteElementString("CaptureImageDirectory", m_CaptureImageDirectory); } if (m_CaptureImageDirectory != null && m_CaptureImageFile != "") { PreferencesWriter.WriteElementString("CaptureImageFile", m_CaptureImageFile); } if (m_CaptureImageDirectory != null && m_CaptureVideoDirectory != "") { PreferencesWriter.WriteElementString("CaptureVideoDirectory", m_CaptureVideoDirectory); } if (m_CaptureImageDirectory != null && m_CaptureVideoFile != "") { PreferencesWriter.WriteElementString("CaptureVideoFile", m_CaptureVideoFile); } PreferencesWriter.WriteElementString("CaptureImageFormat", m_CaptureImageFormat.ToString()); PreferencesWriter.WriteElementString("CaptureVideoFormat", m_CaptureVideoFormat.ToString()); PreferencesWriter.WriteElementString("CaptureUsePattern", m_bCaptureUsePattern.ToString()); PreferencesWriter.WriteElementString("CapturePattern", m_CapturePattern); PreferencesWriter.WriteElementString("CaptureImageCounter", m_iCaptureImageCounter.ToString()); PreferencesWriter.WriteElementString("CaptureVideoCounter", m_iCaptureVideoCounter.ToString()); PreferencesWriter.WriteElementString("CaptureMemoryBuffer", m_iCaptureMemoryBuffer.ToString()); if (m_DeviceConfigurations.Count > 0) { PreferencesWriter.WriteStartElement("DeviceConfigurations"); foreach (DeviceConfiguration conf in m_DeviceConfigurations) { conf.ToXml(PreferencesWriter); } PreferencesWriter.WriteEndElement(); } // Network cameras : url, format, list of recent url. PreferencesWriter.WriteElementString("NetworkCameraUrl", m_NetworkCameraUrl); PreferencesWriter.WriteElementString("NetworkCameraFormat", m_NetworkCameraFormat.ToString()); if (m_RecentNetworkCameras.Count > 0) { PreferencesWriter.WriteStartElement("RecentNetworkCameras"); foreach (string url in m_RecentNetworkCameras) { PreferencesWriter.WriteStartElement("NetworkCamera"); PreferencesWriter.WriteString(url); PreferencesWriter.WriteEndElement(); } PreferencesWriter.WriteEndElement(); } PreferencesWriter.WriteEndElement(); PreferencesWriter.WriteEndDocument(); PreferencesWriter.Flush(); PreferencesWriter.Close(); } catch (Exception) { log.Error("Error happenned while writing preferences."); } }
private void FlushToDisk(string filePath) { try { XmlTextWriter PreferencesWriter = new XmlTextWriter(filePath, null); PreferencesWriter.Formatting = Formatting.Indented; PreferencesWriter.WriteStartDocument(); PreferencesWriter.WriteStartElement("KinoveaPreferences"); // Format version PreferencesWriter.WriteStartElement("FormatVersion"); PreferencesWriter.WriteString("1.2"); PreferencesWriter.WriteEndElement(); // Preferences PreferencesWriter.WriteElementString("HistoryCount", m_iFilesToSave.ToString()); PreferencesWriter.WriteElementString("Language", m_UICultureName); PreferencesWriter.WriteElementString("TimeCodeFormat", m_TimeCodeFormat.ToString()); PreferencesWriter.WriteElementString("SpeedUnit", m_SpeedUnit.ToString()); PreferencesWriter.WriteElementString("ImageAspectRatio", m_AspectRatio.ToString()); PreferencesWriter.WriteElementString("DeinterlaceByDefault", m_bDeinterlaceByDefault.ToString()); PreferencesWriter.WriteStartElement("GridColorRGB"); PreferencesWriter.WriteString(m_GridColor.R.ToString() + ";" + m_GridColor.G.ToString() + ";" + m_GridColor.B.ToString()); PreferencesWriter.WriteEndElement(); PreferencesWriter.WriteStartElement("Plane3DColorRGB"); PreferencesWriter.WriteString(m_Plane3DColor.R.ToString() + ";" + m_Plane3DColor.G.ToString() + ";" + m_Plane3DColor.B.ToString()); PreferencesWriter.WriteEndElement(); PreferencesWriter.WriteElementString("WorkingZoneSeconds", m_iWorkingZoneSeconds.ToString()); PreferencesWriter.WriteElementString("WorkingZoneMemory", m_iWorkingZoneMemory.ToString()); m_DefaultFading.ToXml(PreferencesWriter, true); PreferencesWriter.WriteElementString("DrawOnPlay", m_bDrawOnPlay.ToString()); PreferencesWriter.WriteElementString("ExplorerThumbnailsSize", m_iExplorerThumbsSize.ToString()); PreferencesWriter.WriteElementString("ExplorerVisible", m_bIsExplorerVisible.ToString()); PreferencesWriter.WriteElementString("ExplorerSplitterDistance", m_iExplorerSplitterDistance.ToString()); PreferencesWriter.WriteElementString("ActiveFileBrowserTab", m_ActiveFileBrowserTab.ToString()); PreferencesWriter.WriteElementString("ExplorerFilesSplitterDistance", m_iExplorerFilesSplitterDistance.ToString()); PreferencesWriter.WriteElementString("ShortcutsFilesSplitterDistance", m_iShortcutsFilesSplitterDistance.ToString()); PreferencesWriter.WriteStartElement("Shortcuts"); foreach (ShortcutFolder sf in m_ShortcutFolders) { sf.ToXml(PreferencesWriter); } PreferencesWriter.WriteEndElement(); PreferencesWriter.WriteElementString("CaptureImageDirectory", m_CaptureImageDirectory); PreferencesWriter.WriteElementString("CaptureVideoDirectory", m_CaptureVideoDirectory); PreferencesWriter.WriteStartElement("RecentColors"); foreach (Color col in m_RecentColors) { PreferencesWriter.WriteStartElement("Color"); PreferencesWriter.WriteString(col.R.ToString() + ";" + col.G.ToString() + ";" + col.B.ToString()); PreferencesWriter.WriteEndElement(); } PreferencesWriter.WriteEndElement(); PreferencesWriter.WriteStartElement("SURFParameters"); PreferencesWriter.WriteElementString("Octaves", m_iSurfOctaves.ToString()); PreferencesWriter.WriteElementString("Intervals", m_iSurfIntervals.ToString()); PreferencesWriter.WriteElementString("InitSample", m_iSurfInitSample.ToString()); PreferencesWriter.WriteElementString("Threshold", m_fSurfThreshold.ToString()); PreferencesWriter.WriteElementString("InterpolationSteps", m_iSurfInterpolationSteps.ToString()); PreferencesWriter.WriteElementString("Upright", m_bSurfUpright.ToString()); PreferencesWriter.WriteEndElement(); PreferencesWriter.WriteEndElement(); PreferencesWriter.WriteEndDocument(); PreferencesWriter.Flush(); PreferencesWriter.Close(); } catch (Exception) { log.Error("Error happenned while writing preferences."); } }