private void FillSubsSurfaceToForm(SettingsLoad load, string surface) { int surfIndex = (int)Enum.Parse(typeof(Settings.OSDSurfaces), surface); subsColor.Text = load.surfaces[surfIndex].Color2; subsFont.Text = load.surfaces[surfIndex].Font2; subsOnViewPort.Checked = load.surfaces[surfIndex].OnViewPort; subsRectColor.Text = load.surfaces[surfIndex].RectColor2; subsRectEnabled.Checked = load.surfaces[surfIndex].RectEnabled; subsRectPadding.Text = paddConv.ConvertToString(load.surfaces[surfIndex].RectPadding); subsPosition.Text = pointConv.ConvertToString(load.surfaces[surfIndex].Position); }
public void WriteXml(XmlWriter writer) { var pointConverter = new PointConverter(); var sizeConverter = new SizeConverter(); writer.WriteStartElement("WindowSettings"); writer.WriteElementString("WindowState", WindowState.ToString()); writer.WriteElementString("Location", pointConverter.ConvertToString(Location)); writer.WriteElementString("Size", sizeConverter.ConvertToString(Size)); writer.WriteElementString("Zoom", Zoom.ToString()); writer.WriteElementString("PositionInText", PositionInText.ToString()); writer.WriteEndElement(); }
/// <summary> /// Save the presentation object to file in specified path, create /// new file in every call. /// </summary> /// <param name="strFilePath">The file full path</param> /// <param name="dicPresentationObjects">The presentation objects</param> public static void SavePresentation(string strFilePath, Dictionary <Point, ObjectDetails> dicPresentationObjects, int nLastElementID) { // Creating xml writer settings XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; try { // Creating the xml writer XmlWriter writer = XmlWriter.Create(strFilePath, settings); PointConverter converter = new PointConverter(); writer.WriteStartDocument(); // Write root element writer.WriteStartElement(ROOT_ELEMENT); writer.WriteAttributeString(LAST_ID_ARRTRIBUTE, nLastElementID.ToString()); foreach (KeyValuePair <Point, ObjectDetails> currentPair in dicPresentationObjects) { // append each object element writer.WriteStartElement(OBJECT_ELEMENT); writer.WriteAttributeString(POINT_ATTRIBUTE, converter.ConvertToString(currentPair.Key)); writer.WriteAttributeString(TYPE_ATTRIBUTE, currentPair.Value.poType.ToString()); writer.WriteAttributeString(NAME_ATTRIBUTE, currentPair.Value.strName); // Close each object element writer.WriteEndElement(); } // Close root element writer.WriteEndElement(); writer.Close(); } catch (Exception ex) { // TODO : write to log throw new Exception("שגיאה בשמירת תצוגה אנא נסה שנית"); } }
public void ConvertToString() { _converter.ConvertToString(new Point(2, 3)).Should().Be("2 3"); _converter.ConvertToString(new Point(-4, -5)).Should().Be("-4 -5"); }
public void SaveConfig() { // local var for marshal-by-reference // prevent runtime exception var tabletMode = mainForm.tabletMode; var cursorType = overlayForm.cursorType; Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings.Remove("Strength"); config.AppSettings.Settings.Add("Strength", smoothingStrength.ToString()); config.AppSettings.Settings.Remove("Interpolation"); config.AppSettings.Settings.Add("Interpolation", smoothingInterpolation.ToString()); config.AppSettings.Settings.Remove("Manual Interpolation"); config.AppSettings.Settings.Add("Manual Interpolation", manualInterpolation.ToString()); config.AppSettings.Settings.Remove("Smooth On Draw"); config.AppSettings.Settings.Add("Smooth On Draw", smoothOnDraw.ToString()); config.AppSettings.Settings.Remove("Stay On Top"); config.AppSettings.Settings.Add("Stay On Top", stayOnTop.ToString()); config.AppSettings.Settings.Remove("Tablet Mode"); config.AppSettings.Settings.Add("Tablet Mode", tabletMode.ToString()); config.AppSettings.Settings.Remove("Overlay Screen"); config.AppSettings.Settings.Add("Overlay Screen", overlayScreen.ToString()); config.AppSettings.Settings.Remove("Disable Overlay"); config.AppSettings.Settings.Add("Disable Overlay", disableOverlay.ToString()); config.AppSettings.Settings.Remove("All Screens"); config.AppSettings.Settings.Add("All Screens", allScreens.ToString()); config.AppSettings.Settings.Remove("Manual Overlay Override"); config.AppSettings.Settings.Add("Manual Overlay Override", manualOverlayOverride.ToString()); config.AppSettings.Settings.Remove("Override Bounds"); RectangleConverter r = new RectangleConverter(); config.AppSettings.Settings.Add("Override Bounds", r.ConvertToString(overrideBounds)); config.AppSettings.Settings.Remove("Disable Catch Up"); config.AppSettings.Settings.Add("Disable Catch Up", disableCatchUp.ToString()); config.AppSettings.Settings.Remove("Snap to Cursor"); config.AppSettings.Settings.Add("Snap to Cursor", snapToCursor.ToString()); config.AppSettings.Settings.Remove("Cursor Graphic"); config.AppSettings.Settings.Add("Cursor Graphic", cursorType.ToString()); config.AppSettings.Settings.Remove("Main Color"); config.AppSettings.Settings.Add("Main Color", ColorTranslator.ToHtml(overlayForm.cursorColor)); config.AppSettings.Settings.Remove("Fill Color"); config.AppSettings.Settings.Add("Fill Color", ColorTranslator.ToHtml(overlayForm.cursorFillColor)); config.AppSettings.Settings.Remove("Disable Auto Detection"); config.AppSettings.Settings.Add("Disable Auto Detection", disableAutoDetection.ToString()); config.AppSettings.Settings.Remove("Tolerance"); config.AppSettings.Settings.Add("Tolerance", tolerance.ToString()); config.AppSettings.Settings.Remove("Tablet Offset Override"); config.AppSettings.Settings.Add("Tablet Offset Override", tabletOffsetOverride.ToString()); config.AppSettings.Settings.Remove("Tablet Offset"); PointConverter p = new PointConverter(); config.AppSettings.Settings.Add("Tablet Offset", p.ConvertToString(tabletOffset)); config.AppSettings.Settings.Remove("Hotkey 1"); config.AppSettings.Settings.Add("Hotkey 1", hotkeys[0].ToString()); config.AppSettings.Settings.Remove("Hotkey 2"); config.AppSettings.Settings.Add("Hotkey 2", hotkeys[1].ToString()); config.AppSettings.Settings.Remove("Hotkey 3"); config.AppSettings.Settings.Add("Hotkey 3", hotkeys[2].ToString()); config.AppSettings.Settings.Remove("Hotkey 4"); config.AppSettings.Settings.Add("Hotkey 4", hotkeys[3].ToString()); config.AppSettings.Settings.Remove("Hotkey 5"); config.AppSettings.Settings.Add("Hotkey 5", hotkeys[4].ToString()); config.AppSettings.Settings.Remove("Hotkey 6"); config.AppSettings.Settings.Add("Hotkey 6", hotkeys[5].ToString()); config.Save(ConfigurationSaveMode.Modified); }