コード例 #1
0
ファイル: Form1.cs プロジェクト: yzwbrian/VirusTotalUploader
        private void Form1_Load(object sender, EventArgs e)
        {
            lang = new Languages();                                                                                                                                                                                                                     // Initialize language class
            lang.Init();                                                                                                                                                                                                                                // Run init function

            errw = new ErrorWindow();                                                                                                                                                                                                                   // Initialize ErrorWindow

            label1.Text     = lang.GetString("Drag file here");                                                                                                                                                                                         // Set label text
            linkLabel3.Text = lang.GetString("Settings");                                                                                                                                                                                               // Set settings link text

            if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "Settings.ini"))                                                                                                                                                                   // Check if settings file exists
            {
                MessageBox.Show(lang.GetString("No settings file found!\n\nThis is because you probably opened this app for first time. Please go to settings and add API key."), lang.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); // Show error dialog
            }
            else
            {
                var     parser = new FileIniDataParser();                                                 // Initialize ini file parser
                IniData data   = parser.ReadFile(AppDomain.CurrentDomain.BaseDirectory + "Settings.ini"); // Load settings file
                api   = data["General"]["ApiKey"];                                                        // Get apikey
                theme = data["General"]["Theme"];                                                         // Get theme
            }

            if (theme == "dark")                                        // Check theme
            {
                this.BackColor   = ColorTranslator.FromHtml("#0a0a0a"); // Set back color
                this.ForeColor   = Color.WhiteSmoke;                    // Set fore color
                panel2.BackColor = ColorTranslator.FromHtml("#383838"); // Set panel back color to beautiful grey
                // Set link color
                linkLabel1.LinkColor = ColorTranslator.FromHtml("#b2b2b2");
                linkLabel2.LinkColor = ColorTranslator.FromHtml("#b2b2b2");
                linkLabel3.LinkColor = ColorTranslator.FromHtml("#b2b2b2");
            }

            string[] args = Environment.GetCommandLineArgs(); // Get program arguments
            if (args.Length > 1)
            {
                CheckFile(args[1], api); // Upload file
            }
        }