コード例 #1
0
        public static void LoadConfig()
        {
            _log_path = System.IO.Path.GetDirectoryName(
                System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
                );

            if (!File.Exists(ConfigPath))
            {
                string appdata = Environment.GetEnvironmentVariable("APPDATA");
                if (!Directory.Exists(appdata + "\\FileManager"))
                {
                    Directory.CreateDirectory(appdata + "\\FileManager");
                }
            }
            try
            {
                XDocument doc  = XDocument.Load(ConfigPath);
                XElement  root = doc.Root;

                /// Records
                XElement record = root.Element("record");
                Histories.Clear();
                Stars.Clear();
                foreach (XElement c in record.Element("history").Elements("item"))
                {
                    ConnectionRecord connectionRecord = new ConnectionRecord
                    {
                        Info      = c.Element("ip").Value,
                        IsStarred = c.Element("star").Value != "0"
                    };
                    Histories.Add(connectionRecord);
                    if (connectionRecord.IsStarred)
                    {
                        Stars.Add(connectionRecord.Copy());
                    }
                }

                /// Settings
                XElement settings = root.Element("settings");

                ClickCloseToMinimize            = bool.Parse(settings.Element("ClickCloseToMinimize").Value);
                UpdateLengthThreshold           = long.Parse(settings.Element("UpdateLengthThreshold").Value);
                UpdateTimeThreshold             = int.Parse(settings.Element("UpdateTimeThreshold").Value);
                SaveRecordInterval              = int.Parse(settings.Element("SaveRecordInterval").Value);
                ConnectionMonitorRecordCount    = int.Parse(settings.Element("ConnectionMonitorRecordCount").Value);
                ConnectionMonitorRecordInterval = int.Parse(settings.Element("ConnectionMonitorRecordInterval").Value);
                DefaultServerPort    = int.Parse(settings.Element("DefaultPort").Value);
                ThreadLimit          = int.Parse(settings.Element("ThreadLimit").Value);
                SmallFileThreshold   = long.Parse(settings.Element("SmallFileLimit").Value);
                SocketSendTimeout    = int.Parse(settings.Element("SocketSendTimeout").Value);
                SocketReceiveTimeout = int.Parse(settings.Element("SocketReceiveTimeout").Value);
            }
            catch (Exception)
            {
                SaveConfig();
            }
        }
コード例 #2
0
 public static void Star(ConnectionRecord connectionRecord)
 {
     connectionRecord.Star();
     Stars.Insert(0, connectionRecord.Copy());
     SaveConfig();
 }