Example #1
0
        private void LoadConfig()
        {
            bool loaded = false;

            if (File.Exists("config.xml"))
            {
                try
                {
                    XmlSerializer s = new XmlSerializer(typeof(BelvedereSharp));
                    TextReader    r = new StreamReader("config.xml");
                    _belvedere = (BelvedereSharp)s.Deserialize(r);
                    r.Close();
                    loaded = true;
                }
                catch (Exception)
                {
                    Log.Error("Invalid config.xml, creating new config file.");
                    if (File.Exists("config.xml.err"))
                    {
                        File.Delete("config.xml.err");
                    }
                    File.Move("config.xml", "config.xml.err");
                }
            }
            if (!loaded)
            {
                _belvedere = new BelvedereSharp();
            }

            //listViewFolders
            _folders = _belvedere.Folders;

            if (_folders.Count > 0)
            {
                List <ListViewItem> l = new List <ListViewItem>();
                foreach (BFolder folder in _folders)
                {
                    l.Add(new ListViewItem(new string[] { Path.GetFileName(folder.Path), folder.Path }));
                }
                listViewFolders.BeginUpdate();
                listViewFolders.Items.AddRange(l.ToArray());
                listViewFolders.EndUpdate();
                listViewFolders.Items[0].Selected = true;
                _selectedFolderIndex = 0;

                UpdateListViewRules();
            }
        }
Example #2
0
        private void LoadConfig()
        {
            bool loaded = false;
            if (File.Exists("config.xml"))
            {
                try
                {
                    XmlSerializer s = new XmlSerializer(typeof(BelvedereSharp));
                    TextReader r = new StreamReader("config.xml");
                    _belvedere = (BelvedereSharp)s.Deserialize(r);
                    r.Close();
                    loaded = true;
                }
                catch (Exception)
                {
                    Log.Error("Invalid config.xml, creating new config file.");
                    if (File.Exists("config.xml.err"))
                        File.Delete("config.xml.err");
                    File.Move("config.xml", "config.xml.err");
                }
            }
            if (!loaded)
                _belvedere = new BelvedereSharp();

            //listViewFolders
            _folders = _belvedere.Folders;

            if (_folders.Count > 0)
            {
                List<ListViewItem> l = new List<ListViewItem>();
                foreach (BFolder folder in _folders)
                    l.Add(new ListViewItem(new string[] { Path.GetFileName(folder.Path), folder.Path }));
                listViewFolders.BeginUpdate();
                listViewFolders.Items.AddRange(l.ToArray());
                listViewFolders.EndUpdate();
                listViewFolders.Items[0].Selected = true;
                _selectedFolderIndex = 0;

                UpdateListViewRules();
            }
        }