当前位置: 首页>>代码示例>>C#>>正文


C# OpenFileDialog.InitializeLifetimeService方法代码示例

本文整理汇总了C#中System.Windows.Forms.OpenFileDialog.InitializeLifetimeService方法的典型用法代码示例。如果您正苦于以下问题:C# OpenFileDialog.InitializeLifetimeService方法的具体用法?C# OpenFileDialog.InitializeLifetimeService怎么用?C# OpenFileDialog.InitializeLifetimeService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.OpenFileDialog的用法示例。


在下文中一共展示了OpenFileDialog.InitializeLifetimeService方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: load_btn_Click

        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("Файл не загружен - что-то пошло не так...");
           }
        }
开发者ID:stasikus,项目名称:SR,代码行数:31,代码来源:Form1.cs

示例2: Browse_Click

        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);
                    }
                }
            }
        }
开发者ID:nulltoken,项目名称:ServiceMatrix,代码行数:34,代码来源:TrialExpired.xaml.cs

示例3: browseButton_Click

        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;
            }
        }
开发者ID:ranji,项目名称:NServiceBus,代码行数:38,代码来源:TrialExpired.cs

示例4: browseButton_Click

        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);
                    }
                }
            }
        }
开发者ID:hzacchi,项目名称:NServiceBus,代码行数:38,代码来源:LicenseExpiredForm.cs

示例5: browseButton_Click

        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);
                    }
                }
            }
        }
开发者ID:huurneman,项目名称:NServiceBus,代码行数:36,代码来源:LicenseExpiredForm.cs

示例6: Browse_Click

        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();
            }
        }
开发者ID:nanohex,项目名称:ServiceMatrix,代码行数:30,代码来源:TrialExpired.xaml.cs

示例7: openFromFile_Click

        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());
            }
        }
开发者ID:hieuntp2,项目名称:TruongChuyen,代码行数:52,代码来源:CreateQuestion.cs

示例8: btLoadGroupQuestion_Click

        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
        }
开发者ID:hieuntp2,项目名称:TruongChuyen,代码行数:29,代码来源:Server.cs


注:本文中的System.Windows.Forms.OpenFileDialog.InitializeLifetimeService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。