public override void SaveControlSettings( Window control, string settingName, SettingsBag <TSettings> settings) { WndSettings setting = new WndSettings(); setting.Location = new Point(control.Left, control.Top); setting.Size = new Size(control.Width, control.Height); PropSetter.SetValue(settings.Settings, settingName, setting); }
protected override void LoadControlSettings( Window control, string settingName, SettingsBag <TSettings> settings) { WndSettings setting = PropSetter.GetValue <WndSettings>(settings.Settings, settingName); //WndSettings setting = settings.GetSettingCmplx<WndSettings>(settingName, WndSettings.Empty); if (!setting.Equals(WndSettings.Empty)) { control.WindowStartupLocation = WindowStartupLocation.Manual; control.Left = setting.Location.X; control.Top = setting.Location.Y; control.Width = setting.Size.Width; control.Height = setting.Size.Height; } }
protected virtual AppManagerSettings LoadSettings2(string path) { AppManagerSettings result = new AppManagerSettings(); XmlReaderSettings sett = new XmlReaderSettings(); sett.IgnoreWhitespace = true; using (XmlReader reader = XmlReader.Create(path, sett)) { reader.ReadStartElement("AppManagerSettings"); reader.ReadStartElement("MianFormRowHeights"); List <double> rowHeights = new List <double>(); if (reader.Name == "Height") { while (reader.IsStartElement()) { reader.ReadStartElement("Height"); rowHeights.Add(reader.ReadContentAsDouble()); reader.ReadEndElement(); } reader.ReadEndElement(); } result.MianFormRowHeights = rowHeights.ToArray(); //reader.ReadToFollowing("MainFormSett"); WndSettings wndSett = new WndSettings(); reader.MoveToAttribute("Left"); wndSett.Location.X = reader.ReadContentAsDouble(); reader.MoveToAttribute("Top"); wndSett.Location.Y = reader.ReadContentAsDouble(); reader.MoveToAttribute("Widht"); wndSett.Size.Width = reader.ReadContentAsDouble(); reader.MoveToAttribute("Height"); wndSett.Size.Height = reader.ReadContentAsDouble(); result.MainFormSett = wndSett; reader.Read(); reader.ReadStartElement("StartMinimized"); result.StartMinimized = reader.ReadContentAsBoolean(); reader.ReadEndElement(); reader.ReadStartElement("AlwaysOnTop"); result.AlwaysOnTop = reader.ReadContentAsBoolean(); reader.ReadEndElement(); reader.ReadStartElement("EnableActivationPanel"); result.EnableActivationPanel = reader.ReadContentAsBoolean(); reader.ReadEndElement(); reader.ReadStartElement("UseShortActivationPanel"); result.UseShortActivationPanel = reader.ReadContentAsBoolean(); reader.ReadEndElement(); if (reader.NodeType == XmlNodeType.Element) { reader.ReadStartElement("CheckNewVersionAtStartUp"); result.CheckNewVersionAtStartUp = reader.ReadContentAsBoolean(); reader.ReadEndElement(); } if (reader.NodeType == XmlNodeType.Element) { reader.ReadStartElement("ActivationPanelColor"); result.ActivationPanelColor = UIHelper.FromARGB(reader.ReadContentAsInt()); reader.ReadEndElement(); } if (reader.NodeType == XmlNodeType.Element) { reader.ReadStartElement("TransparentActivationPanel"); result.TransparentActivationPanel = reader.ReadContentAsBoolean(); reader.ReadEndElement(); } if (reader.NodeType == XmlNodeType.Element) { reader.ReadStartElement("ShowAppTitles"); result.ShowAppTitles = reader.ReadContentAsBoolean(); reader.ReadEndElement(); } if (reader.NodeType == XmlNodeType.Element) { reader.ReadStartElement("StatisticPeriod"); result.StatisticPeriod = reader.ReadContentAsInt(); reader.ReadEndElement(); } reader.ReadEndElement(); } return(result); }
protected virtual AppManagerSettings LoadSettings1(string path) { AppManagerSettings result = new AppManagerSettings(); XmlReaderSettings sett = new XmlReaderSettings(); sett.IgnoreWhitespace = true; using (XmlReader reader = XmlReader.Create(path, sett)) { reader.ReadStartElement("AppManagerSettings"); reader.ReadStartElement("MianFormRowHeights"); List <double> rowHeights = new List <double>(); if (reader.Name == "double") { //var sub = reader.ReadSubtree(); //if (reader.ReadToDescendant("double")) //{ while (reader.IsStartElement()) { reader.ReadStartElement("double"); rowHeights.Add(reader.ReadContentAsDouble()); reader.ReadEndElement(); } reader.ReadEndElement(); } result.MianFormRowHeights = rowHeights.ToArray(); reader.ReadStartElement("MainFormSett"); reader.ReadStartElement("Location"); WndSettings wndSett = new WndSettings(); reader.ReadStartElement("X"); wndSett.Location.X = reader.ReadContentAsDouble(); reader.ReadEndElement(); reader.ReadStartElement("Y"); wndSett.Location.Y = reader.ReadContentAsDouble(); reader.ReadEndElement(); reader.ReadEndElement(); //Location reader.ReadStartElement("Size"); reader.ReadStartElement("Width"); wndSett.Size.Width = reader.ReadContentAsDouble(); reader.ReadEndElement(); reader.ReadStartElement("Height"); wndSett.Size.Height = reader.ReadContentAsDouble(); reader.ReadEndElement(); reader.ReadEndElement(); //Size reader.ReadEndElement(); //MainFormSett result.MainFormSett = wndSett; reader.ReadStartElement("StartMinimized"); result.StartMinimized = reader.ReadContentAsBoolean(); reader.ReadEndElement(); reader.ReadStartElement("AlwaysOnTop"); result.AlwaysOnTop = reader.ReadContentAsBoolean(); reader.ReadEndElement(); reader.ReadStartElement("EnableActivationPanel"); result.EnableActivationPanel = reader.ReadContentAsBoolean(); reader.ReadEndElement(); reader.ReadStartElement("UseShortActivationPanel"); result.UseShortActivationPanel = reader.ReadContentAsBoolean(); reader.ReadEndElement(); reader.ReadEndElement(); } return(result); }