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); } } } }
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("Файл не загружен - что-то пошло не так..."); } }
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) { var 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; } }
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 massage 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 bee 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 parsing the license.\r\nMessage: {0}\r\nThe exception details have 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(() => { return 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); } } } }
public object InitializeLifetimeService() { return(_openFileDialog.InitializeLifetimeService()); }
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(); } }
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()); } }
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 }