예제 #1
0
        private void LogViewer_Shown(object sender, EventArgs e)
        {
            var logs = Directory.GetFiles(EventsFolder, "*.log");

            if (!logs.Any())
            {
                NothingToShow();
            }

            foreach (var log in logs)
            {
                var sr = new StreamReader(log);
                if (sr.ReadLine() != logheader)
                {
                    sr.Dispose();
                    continue;
                }
                var date  = Tools.GetConfigString(sr.ReadLine());
                var count = Convert.ToInt16(Tools.GetConfigString(sr.ReadLine()));

                if (count <= 0)
                {
                    sr.Dispose();
                    continue;
                }

                Logs.Add(log);
                cboLogs.Items.Add(date);
                sr.Dispose();
            }

            picWorking.Visible = false;
        }
예제 #2
0
        private void LoadConfig()
        {
            if (!File.Exists(config))
            {
                return;
            }
            var sr   = new StreamReader(config);
            var line = sr.ReadLine();

            if (string.IsNullOrWhiteSpace(line))
            {
                sr.Dispose();
                return;
            }
            var count = Convert.ToInt16(Regex.Match(line, @"\d+").Value);

            for (var i = 0; i < count; i++)
            {
                var folder = Tools.GetConfigString(sr.ReadLine());
                if (Directory.Exists(folder))
                {
                    lstFolders.Items.Add(folder);
                }
            }
            chkSubDirs.Checked = sr.ReadLine().Contains("True");
            DoMaximize         = sr.ReadLine().Contains("True");
            sr.Dispose();
            CheckFolderCount();
        }
예제 #3
0
        private void LoadConfig()
        {
            if (!File.Exists(config))
            {
                return;
            }
            var sr = new StreamReader(config);

            try
            {
                sr.ReadLine(); //skip initial line
                var folder = Tools.GetConfigString(sr.ReadLine());
                if (!string.IsNullOrWhiteSpace(folder) && Directory.Exists(folder))
                {
                    Log("Loading last used folder...");
                    txtFolder.Text = folder;
                }
                artistSongTool.Checked   = sr.ReadLine().Contains("True");
                songTool.Checked         = sr.ReadLine().Contains("True");
                songByArtistTool.Checked = sr.ReadLine().Contains("True");
                albumArtTool.Checked     = sr.ReadLine().Contains("True");
                rB3IconTool.Checked      = sr.ReadLine().Contains("True");
                sr.Dispose();
            }
            catch (Exception)
            {
                sr.Dispose();
                Tools.DeleteFile(config);
            }
        }
예제 #4
0
        private void PS3Scanner_Shown(object sender, EventArgs e)
        {
            //load last used IP address
            if (File.Exists(PS3IP))
            {
                var sr = new StreamReader(PS3IP);
                try
                {
                    Log("Found configuration file ... loading");
                    var ip      = Tools.GetConfigString(sr.ReadLine());
                    var port    = Tools.GetConfigString(sr.ReadLine());
                    var timeout = Tools.GetConfigString(sr.ReadLine());
                    var tries   = Tools.GetConfigString(sr.ReadLine());
                    var wait    = Tools.GetConfigString(sr.ReadLine());

                    sr.Dispose();

                    if (!string.IsNullOrWhiteSpace(ip))
                    {
                        ipAddress.Text = ip;
                        try
                        {
                            numPort.Value = Convert.ToDecimal(port);
                        }
                        catch (Exception)
                        {
                            numPort.Value = 21;
                        }
                        try
                        {
                            numTimeOut.Value = Convert.ToDecimal(timeout);
                        }
                        catch (Exception)
                        {
                            numTimeOut.Value = 2000;
                        }
                        try
                        {
                            numTries.Value = Convert.ToDecimal(tries);
                        }
                        catch (Exception)
                        {
                            numTries.Value = 5;
                        }
                        try
                        {
                            numWait.Value = Convert.ToDecimal(wait);
                        }
                        catch (Exception)
                        {
                            numWait.Value = 100;
                        }
                        Log("Ready");
                        return;
                    }
                }
                catch (Exception)
                {
                    sr.Dispose();
                }
            }

            //default value
            numPort.Value = 21;

            //nothing saved, try to get it from DNS
            var localIP = "";
            var host    = Dns.GetHostEntry(Dns.GetHostName());

            foreach (var ip in host.AddressList.Where(ip => ip.AddressFamily == AddressFamily.InterNetwork))
            {
                localIP = ip.ToString();
            }
            ipAddress.Text = !string.IsNullOrWhiteSpace(localIP) ? localIP : "192.168.0.1";
            Log("Ready");
        }