private void Browse_Click(object sender, RoutedEventArgs e)
        {
            using (var openDialog = new OpenFileDialog())
            {
                openDialog.InitializeLifetimeService();
                openDialog.Filter = "License files (*.xml)|*.xml|All files (*.*)|*.*";
                openDialog.Title  = "Select License file";

                var dialogResult = StaThreadRunner.ShowDialogInSTA(() => { return(openDialog.ShowDialog()); });
                if (dialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    var licenseText = NonLockingFileReader.ReadAllTextWithoutLocking(openDialog.FileName);
                    try
                    {
                        LicenseVerifier.Verify(licenseText);
                        var license = LicenseDeserializer.Deserialize(licenseText);

                        if (LicenseExpirationChecker.HasLicenseExpired(license))
                        {
                            var message = string.Format("The license you provided has expired.\r\nEither extend your trial or contact sales to obtain a new license. Or try a different file.");
                            MessageBox.Show(this, message, "License expired", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                            return;
                        }
                        ResultingLicenseText = licenseText;
                        Close();
                    }
                    catch (Exception exception)
                    {
                        var message = string.Format("An error occurred when parsing the license.\r\nMessage: {0}\r\nThe exception details have been appended to your log.", exception.Message);
                        MessageBox.Show(this, message, "Error parsing license", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }
Example #2
0
File: Form1.cs Project: stasikus/SR
        private void load_btn_Click(object sender, EventArgs e)
        {
            try
            {
                String         Location = String.Empty;
                OpenFileDialog frm      = new OpenFileDialog();
                frm.InitializeLifetimeService();
                frm.Filter = "Config Files (*.txt)|*.txt";
                frm.Title  = "Browse Config file";
                DialogResult ret = STAShowDialog(frm);

                if (ret == DialogResult.OK)
                {
                    Location = frm.FileName;
                }

                string path;
                if (Location != "")
                {
                    path = Location;
                    LoadList.loadGroupList(path);
                    loadFromFile_lbl.Text = LoadList.newList.Count.ToString();
                }
                else
                {
                    loadFromFile_lbl.Text = "0";
                }
            }
            catch
            {
                MessageBox.Show("Файл не загружен - что-то пошло не так...");
            }
        }
Example #3
0
        private void btLoadGroupQuestion_Click(object sender, EventArgs e)
        {
            if (_groupquestion != null)
            {
                DialogResult dialogResult = MessageBox.Show("Bạn chắc chắn thay thế bộ câu hỏi hiện tại?", "Mở bộ câu hỏi", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }

#if DEBUG
            openGroupQuestion("D:/Bộ câu hỏi 1.json");
#else
            String         Location = String.Empty;
            OpenFileDialog frm      = new OpenFileDialog();
            frm.InitializeLifetimeService();
            frm.Filter = "Bộ đề (*.json)|*.json";
            frm.Title  = "Browse Config file";
            DialogResult ret = STAShowDialog(frm);


            if (ret == DialogResult.OK)
            {
                Location = frm.FileName;
            }
            if (Location != "")
            {
                openGroupQuestion(Location);
            }
#endif
        }
Example #4
0
        private void Browse_Click(object sender, RoutedEventArgs e)
        {
            var close = false;

            using (var openDialog = new OpenFileDialog())
            {
                openDialog.InitializeLifetimeService();
                openDialog.Filter = "License files (*.xml)|*.xml|All files (*.*)|*.*";
                openDialog.Title  = "Select License file";

                if (ShowDialogInSTA(openDialog) == System.Windows.Forms.DialogResult.OK)
                {
                    string licenseFileSelected = openDialog.FileName;

                    if (ValidateLicenseFile(this, licenseFileSelected))
                    {
                        close = true;
                    }
                }
            }

            if (close)
            {
                this.DialogResult = true;
                this.Close();

                var registered = new Registered();
                registered.ShowDialog();
            }
        }
Example #5
0
        private void openFromFile_Click(object sender, EventArgs e)
        {
            String Location = String.Empty;

            try
            {
                // Kiểm tra xem có bộ câu hỏi nào đang mở hay không
                if (_groupquestion != null)
                {
                    DialogResult dialogResult = MessageBox.Show("Bạn có muốn lưu bạn hiện tại không?", "Lưu", MessageBoxButtons.YesNoCancel);
                    if (dialogResult == DialogResult.Yes)
                    {
                        _groupquestion.SaveToFile(tbQuestionGroupName.Text, tbAddress.Text);
                    }

                    if (dialogResult == DialogResult.Cancel)
                    {
                        return;
                    }
                }
#if DEBUG
                Location = "D:/Bộ câu hỏi 1.json";
#else
                clearValue();


                OpenFileDialog frm = new OpenFileDialog();
                frm.InitializeLifetimeService();
                frm.Filter = "Bộ đề (*.json)|*.json";
                frm.Title  = "Browse Config file";
                DialogResult ret = STAShowDialog(frm);


                if (ret == DialogResult.OK)
                {
                    Location = frm.FileName;
                }
#endif

                if (Location != "")
                {
                    _groupquestion = new MyGroupQuestion();
                    _groupquestion.LoadFromFile(Location);
                    updateListQuestions();
                    tbAddress.Text           = Location;
                    _groupquestion.Address   = Location;
                    tbQuestionGroupName.Text = _groupquestion.Name;

                    tbQuestion.Focus();
                }
            }
            catch (Exception ex)
            {
                MyLogSystem.Log(ex.ToString());
            }
        }
Example #6
0
        private void browseButton_Click(object sender, EventArgs e)
        {
            var close = false;

            using (var openDialog = new OpenFileDialog())
            {
                openDialog.InitializeLifetimeService();
                openDialog.Filter = "License files (*.xml)|*.xml|All files (*.*)|*.*";
                openDialog.Title  = "Select License file";

                if (ShowDialogInSTA(openDialog) == DialogResult.OK)
                {
                    string licenseFileSelected = openDialog.FileName;

                    if (ValidateLicenseFile(this, licenseFileSelected))
                    {
                        close = true;
                    }
                }
            }

            if (close)
            {
                browseButton.Enabled  = false;
                errorPanel.Visible    = false;
                completePanel.Visible = true;
                Height = 376;

                timer.Tick += delegate
                {
                    timer.Enabled = false;
                    DialogResult  = DialogResult.OK;
                };

                timer.Interval = 5000;
                timer.Enabled  = true;
            }
        }
Example #7
0
        void browseButton_Click(object sender, EventArgs e)
        {
            using (var openDialog = new OpenFileDialog())
            {
                openDialog.InitializeLifetimeService();
                openDialog.Filter = "License files (*.xml)|*.xml|All files (*.*)|*.*";
                openDialog.Title  = "Select License file";

                var dialogResult = StaThreadRunner.ShowDialogInSTA(() => { return(openDialog.ShowDialog()); });
                if (dialogResult == DialogResult.OK)
                {
                    var licenseText = NonLockingFileReader.ReadAllTextWithoutLocking(openDialog.FileName);
                    try
                    {
                        SignedXmlVerifier.VerifyXml(licenseText);
                        var license = LicenseDeserializer.Deserialize(licenseText);

                        string downgradeReason;
                        if (LicenseDowngrader.ShouldLicenseDowngrade(license, out downgradeReason))
                        {
                            var message = string.Format("The license you provided has expired.\r\nReason:{0}\r\nClick 'Purchase' to obtain a new license. Or try a different file.\r\nThis message has been appended to your log.", downgradeReason);
                            Logger.Warn(message);
                            MessageBox.Show(this, message, "License expired", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        MessageBox.Show(this, "The new license has been verified. It will now be stored in the Registry for future use.", "License applied", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        ResultingLicenseText = licenseText;
                        Close();
                    }
                    catch (Exception exception)
                    {
                        var message = string.Format("An error occurred when parsing the license.\r\nMessage: {0}\r\nThe exception details have been appended to your log.", exception.Message);
                        Logger.Warn("Error parsing license", exception);
                        MessageBox.Show(this, message, "Error parsing license", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Example #8
0
        private void ShowFileDialog1()
        {
            //파일오픈창 생성 및 설정
            Temp_ofd.InitializeLifetimeService();
            Temp_ofd.Title    = "파일 오픈";
            Temp_ofd.FileName = "Image";
            Temp_ofd.Filter   = "그림 파일 (*.jpg, *.gif, *.bmp) | *.jpg; *.gif; *.bmp; | 모든 파일 (*.*) | *.*";

            //파일 오픈창 로드
            DialogResult dr = STAShowDialog(Temp_ofd);

            if (dr == DialogResult.OK)
            {
                ofd = Temp_ofd;
                pictureBox1.Image    = Image.FromFile(ofd.FileName);
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                //ByteCode = imageToByteArray(Image.FromFile(ofd.FileName));
            }
            else
            {
                MessageBox.Show("파일을 선택해주세요.");
            }
        }
Example #9
0
        void browseButton_Click(object sender, EventArgs e)
        {
            using (var openDialog = new OpenFileDialog())
            {
                openDialog.InitializeLifetimeService();
                openDialog.Filter = "License files (*.xml)|*.xml|All files (*.*)|*.*";
                openDialog.Title  = "Select License file";

                var dialogResult = StaThreadRunner.ShowDialogInSTA(openDialog.ShowDialog);
                if (dialogResult == DialogResult.OK)
                {
                    var licenseText = NonLockingFileReader.ReadAllTextWithoutLocking(openDialog.FileName);
                    try
                    {
                        LicenseVerifier.Verify(licenseText);
                        var license = LicenseDeserializer.Deserialize(licenseText);

                        if (LicenseExpirationChecker.HasLicenseExpired(license))
                        {
                            var message = string.Format("The license you provided has expired, please select another file.");
                            Logger.Warn(message);
                            MessageBox.Show(this, message, "License expired", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        ResultingLicenseText = licenseText;
                        Close();
                    }
                    catch (Exception exception)
                    {
                        var message = string.Format("An error occurred when parsing the license.\r\nMessage: {0}\r\nThe exception details have been appended to your log.", exception.Message);
                        Logger.Warn("Error parsing license", exception);
                        MessageBox.Show(this, message, "Error parsing license", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
        void browseButton_Click(object sender, EventArgs e)
        {
            using (var openDialog = new OpenFileDialog())
            {
                openDialog.InitializeLifetimeService();
                openDialog.Filter = "License files (*.xml)|*.xml|All files (*.*)|*.*";
                openDialog.Title = "Select License file";

                var dialogResult = StaThreadRunner.ShowDialogInSTA(openDialog.ShowDialog);
                if (dialogResult == DialogResult.OK)
                {
                    var licenseText = NonLockingFileReader.ReadAllTextWithoutLocking(openDialog.FileName);
                    try
                    {
                        LicenseVerifier.Verify(licenseText);
                        var license = LicenseDeserializer.Deserialize(licenseText);

                        if (LicenseExpirationChecker.HasLicenseExpired(license))
                        {
                            var message = "The license you provided has expired, select another file.";
                            Logger.Warn(message);
                            MessageBox.Show(this, message, "License expired", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        ResultingLicenseText = licenseText;
                        Close();
                    }
                    catch (Exception exception)
                    {
                        var message = $"An error occurred when parsing the license.\r\nMessage: {exception.Message}\r\nThe exception details have been appended to the log.";
                        Logger.Warn("Error parsing license", exception);
                        MessageBox.Show(this, message, "Error parsing license", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }