Пример #1
0
        private void onLoad()
        {
            this.errorList = new List<Error>();

            this.errorListView1.SmallImageList = new ImageList();
            this.errorListView1.SmallImageList.TransparentColor = Color.White;

            this.errorListView1.SmallImageList.Images.Add("warning", IMSEnterprise.Properties.Resources.warning);
            this.errorListView1.SmallImageList.Images.Add("error", IMSEnterprise.Properties.Resources.error);

            this.totErrorLabel.Text = "0 error(s)";
            this.totWarningLabel.Text = "0 warning(s)";

            this.eLvwColumnSorter = new ListViewColumnSorter();
            this.lvwColumnSorter = new ListViewColumnSorter();
            this.listView.ListViewItemSorter = this.lvwColumnSorter;
            this.errorListView1.ListViewItemSorter = this.eLvwColumnSorter;

            this.MinimumSize = new Size(1024, this.Size.Height);

            this.searchInput.GotFocus += this.searchInput_Enter;
            this.searchInput.LostFocus += this.searchInput_Leave;
            this.searchInput.Tag = 0;

            this.documentationExists();

            this.KeyPreview = true;

            enterpriseList.ShowNodeToolTips = true;
            saveToolStripMenuItem.Enabled = false;
            sourceIdLabel.Height = 20;
            progressBar.Hide();
            // get IMSEnterprise.config
            this.IMSSettings = new IMSSettings();
            this.initSettings();
            // prepare the bgw for reading files
            bgwIMS.DoWork += bgwIMS_DoWork;
            bgwIMS.RunWorkerCompleted += bgwIMS_RunWorkerCompleted;
            bgwIMS.WorkerSupportsCancellation = true;

            if(this.IMSSettings.Startup.FileToOpen.Choice != 3)
            {
                if (Uri.IsWellFormedUriString(this.IMSSettings.Startup.FileToOpen.Value, UriKind.Absolute)) // file to open is a uri
                {
                    UrlInputDialog url = new UrlInputDialog(this.IMSSettings.Startup.FileToOpen.Value);
                    url.StartPosition = FormStartPosition.CenterScreen;
                    url.Text = "Downloading...";
                    if (url.ShowDialog() == DialogResult.OK)
                    {
                        this.downloadAndProcessTime = Convert.ToInt32(url.Timer.ElapsedMilliseconds);
                        this.currentFilePath = url.CurrentFilePath;
                        this.recentSaved = false;
                        if (this.IMSSettings.Startup.FileToOpen.Choice == 0)
                            this.IMSSettings.Startup.FileToOpen.Value = url.Uri;

                        this.enableLoadingMode();
                        bgwIMS.RunWorkerAsync();
                    }
                    else // download was interupted
                    {
                        this.fileNotFound();
                    }
                }
                else // file to open is a local file
                {
                    if (IMSSettings.Startup.FileToOpen.Value != null) // file to open had no value
                    {
                        FileInfo info = new FileInfo(@IMSSettings.Startup.FileToOpen.Value);
                        if (!info.Exists) // file didnt exist
                        {
                            this.fileNotFound();
                        }
                        else // file did exist
                        {

                            this.currentFilePath = @IMSSettings.Startup.FileToOpen.Value;

                            this.enableLoadingMode();
                            bgwIMS.RunWorkerAsync(); // start processing the file
                        }
                    }
                }
            }
        }
Пример #2
0
        private void openFromUrlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Check if the file was edited and saved before opening the url file.
            if (this.recentSaved == false)
            {
                DialogResult result = MessageBox.Show("You are about to load another file without saving, do you want to save the file before continuing?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result != DialogResult.No)
                {
                    if (this.currentFilePath != "" || this.newFile != true)
                    {
                        this.writeToFile(false);
                    }
                    else
                    {
                        this.saveAsToolStripMenuItem_Click(sender, e);
                    }
                }
            }
            
            UrlInputDialog urlDialog = new UrlInputDialog(ref this.currentFilePath, ref this.recentSaved);
            
            var uresult = urlDialog.ShowDialog();
            if (uresult == DialogResult.OK)
            {
                if (this.IMSSettings.Startup.FileToOpen.Choice == 0)
                {
                    this.IMSSettings.Startup.FileToOpen.Value = urlDialog.Uri;
                    this.IMSSettings.Save();
                }

                this.currentUrl = urlDialog.Uri;
                this.downloadAndProcessTime = Convert.ToInt32(urlDialog.Timer.ElapsedMilliseconds);
                this.currentFilePath = urlDialog.CurrentFilePath;

                this.enableLoadingMode();
                this.bgwIMS.RunWorkerAsync();
            }
            
        }