Ejemplo n.º 1
0
        private void M_AButton_Click(object sender, EventArgs e)
        {
            string APIKey = this.m_KTextBox.Text.Trim();
            bool   valid  = true;

            for (int i = 0; i < APIKey.Length; i++)
            {
                if (APIKey[i] == 9 || APIKey[i] == 13 ||
                    APIKey[i] == 32)
                {
                    valid = false;
                    break;
                }
            }
            if (!valid)
            {
                Error.Reason(Errors.CReason);
                return;
            }
            RegConfig regConfig = new RegConfig();

            regConfig.SetAPIKey(APIKey);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Ejemplo n.º 2
0
        private void M_AButton_Click(object sender, EventArgs e)
        {
            FileInfo fileInfo = new FileInfo(this.m_FTextBox.Text);

            if (!fileInfo.Exists)
            {
                Error.Reason(Errors.AReason);
                return;
            }
            try
            {
                FileStream fileStream = new FileStream(fileInfo.FullName,
                                                       FileMode.Open, FileAccess.Read);
                int length = (int)fileStream.Length;
                if (length >= 100)
                {
                    Error.Reason(Errors.BReason);
                    return;
                }
                byte[] array = new byte[100];
                fileStream.Read(array, 0, length);
                fileStream.Close();
                string APIKey = Encoding.ASCII.GetString(array).Trim();
                bool   valid  = true;
                for (int i = 0; i < APIKey.Length; i++)
                {
                    if (APIKey[i] == 9 || APIKey[i] == 13 ||
                        APIKey[i] == 32)
                    {
                        valid = false;
                        break;
                    }
                }
                if (!valid)
                {
                    Error.Reason(Errors.CReason);
                    return;
                }
                RegConfig regConfing = new RegConfig();
                regConfing.SetAPIKey(APIKey);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (IOException except)
            {
                Error.Reason(except.Message);
            }
        }
Ejemplo n.º 3
0
        public MainWindow()
        {
            // Initialize objects
            this.m_UTimer     = new System.Windows.Forms.Timer();
            this.m_ATimer     = new System.Windows.Forms.Timer();
            this.m_APIManager = new APIManager();
            this.m_RegConfig  = new RegConfig();

            // Setup culture
            string lang    = this.m_RegConfig.GetLang();
            bool   regLang = true;

            if (lang == "")
            {
                lang    = Thread.CurrentThread.CurrentUICulture.Name;
                regLang = false;
            }
            else
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
            }

            // Initialize component
            this.InitializeComponent();

            // Menu language
            lang = Thread.CurrentThread.CurrentUICulture.Name;
            lang = Util.GetNormalizeLang(lang);
            this.SetMenuLang(lang, regLang);

            // Timer <StartUp>
            this.m_UTimer.Interval = 1000;
            this.m_UTimer.Tick    += new EventHandler(this.M_UTimer_Tick);
            this.m_UTimer.Start();

            // Timer <Automatically detecting>
            this.m_ATimer.Interval = 2000;
            this.m_ATimer.Tick    += new EventHandler(this.M_ATimer_Tick);
        }