Пример #1
0
        public static List<Preset> LoadFromFile(string filename)
        {
            List<Preset> result = new List<Preset>();
            try
            {
                if (System.IO.File.Exists(filename))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(filename);
                    XmlElement root = doc.DocumentElement;

                    XmlNodeList bmNodes = root.SelectNodes("preset");
                    if (bmNodes != null)
                    {
                        foreach (XmlNode n in bmNodes)
                        {
                            Preset bm = new Preset();
                            bm.Name = n.SelectSingleNode("Name").InnerText;
                            bm.VisibleColumns = n.SelectSingleNode("VisibleColumns").InnerText;
                            bm.ColumnOrder = n.SelectSingleNode("ColumnOrder").InnerText;
                            result.Add(bm);
                        }
                    }
                }
            }
            catch
            {
            }
            return result;
        }
Пример #2
0
 public static Preset FromCurrentSettings(Preset org, string name)
 {
     Preset result;
     if (org == null)
     {
         result = new Preset();
     }
     else
     {
         result = org;
     }
     result.Name = name;
     result.VisibleColumns = PluginSettings.Instance.VisibleColumns ?? "";
     result.ColumnOrder = PluginSettings.Instance.ColumnOrder ?? "";
     return result;
 }
Пример #3
0
        private void applyPreset(Preset p)
        {
            _initializing = true;

            Properties.Settings.Default.VisibleColumns = p.VisibleColumns;
            Properties.Settings.Default.ColumnOrder = p.ColumnOrder;
            if (!string.IsNullOrEmpty(Properties.Settings.Default.VisibleColumns))
            {
                string[] parts = Properties.Settings.Default.VisibleColumns.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < _fixedColumnCount; i++)
                {
                    cacheListControl1.GeocacheDataGrid.Columns[i].Visibility = parts.Contains(i.ToString()) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;
                    checkedListBoxVisibleColumns.SetItemCheckState(i, cacheListControl1.GeocacheDataGrid.Columns[i].Visibility == System.Windows.Visibility.Visible ? CheckState.Checked : CheckState.Unchecked);
                }
            }
            if (!string.IsNullOrEmpty(Properties.Settings.Default.ColumnOrder))
            {
                try
                {
                    string[] order = Properties.Settings.Default.ColumnOrder.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < order.Length; i++)
                    {
                        cacheListControl1.GeocacheDataGrid.Columns[i].DisplayIndex = int.Parse(order[i]);
                    }
                }
                catch
                {
                }
            }
            Properties.Settings.Default.Save();
            _initializing = false;
        }