コード例 #1
0
        /// <summary>
        /// Shut down the build process thread and clean up on exit
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void NamespacesDlg_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (cancellationTokenSource != null && this.DialogResult != DialogResult.Cancel)
            {
                if (MessageBox.Show("A build is currently taking place to obtain namespace information.  Do " +
                                    "you want to abort it and close this form?", Constants.AppName, MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.No)
                {
                    e.Cancel = true;
                    return;
                }

                if (cancellationTokenSource != null)
                {
                    cancellationTokenSource.Cancel();
                    e.Cancel = true;
                }

                return;
            }

            // Add new items that were modified
            foreach (var item in lbNamespaces.Items.OfType <NamespaceSummaryItem>().Where(ns => ns.IsDirty))
            {
                if (nsColl[item.Name] == null)
                {
                    nsColl.Add(item);
                }
            }

            this.DialogResult = nsColl.Any(ns => ns.IsDirty) ? DialogResult.OK : DialogResult.Cancel;

            if (tempProject != null)
            {
                try
                {
                    // Delete the temporary project's working files
                    if (!String.IsNullOrEmpty(tempProject.OutputPath) && Directory.Exists(tempProject.OutputPath))
                    {
                        Directory.Delete(tempProject.OutputPath, true);
                    }
                }
                catch
                {
                    // Eat the exception.  We'll ignore it if the temporary files cannot be deleted.
                }

                tempProject.Dispose();
                tempProject = null;
            }
        }
コード例 #2
0
        /// <summary>
        /// Store the changes and close the dialog box
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnClose_Click(object sender, EventArgs e)
        {
            // Add new items that were modified
            foreach (NamespaceSummaryItem item in lbNamespaces.Items)
            {
                if (item.IsDirty && nsColl[item.Name] == null)
                {
                    nsColl.Add(item);
                }
            }

            this.DialogResult = nsColl.IsDirty ? DialogResult.OK :
                                DialogResult.Cancel;
            this.Close();
        }
コード例 #3
0
        /// <summary>
        /// Shut down the build process thread and clean up on exit
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void NamespacesDlg_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (buildThread != null && buildThread.IsAlive)
            {
                if (MessageBox.Show("A build is currently taking place to obtain namespace information.  Do " +
                                    "you want to abort it and close this form?", Constants.AppName, MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.No)
                {
                    e.Cancel = true;
                    return;
                }

                try
                {
                    this.Cursor = Cursors.WaitCursor;

                    if (buildThread != null)
                    {
                        buildThread.Abort();
                    }

                    while (buildThread != null && !buildThread.Join(1000))
                    {
                        Application.DoEvents();
                    }

                    System.Diagnostics.Debug.WriteLine("Thread stopped");
                }
                finally
                {
                    this.Cursor  = Cursors.Default;
                    buildThread  = null;
                    buildProcess = null;
                }
            }

            // Add new items that were modified
            foreach (NamespaceSummaryItem item in lbNamespaces.Items)
            {
                if (item.IsDirty && nsColl[item.Name] == null)
                {
                    nsColl.Add(item);
                }
            }

            this.DialogResult = nsColl.IsDirty ? DialogResult.OK : DialogResult.Cancel;

            if (tempProject != null)
            {
                try
                {
                    // Delete the temporary project's working files
                    if (!String.IsNullOrEmpty(tempProject.OutputPath) && Directory.Exists(tempProject.OutputPath))
                    {
                        Directory.Delete(tempProject.OutputPath, true);
                    }
                }
                catch
                {
                    // Eat the exception.  We'll ignore it if the temporary files cannot be deleted.
                }

                tempProject.Dispose();
                tempProject = null;
            }

            GC.Collect(2);
            GC.WaitForPendingFinalizers();
            GC.Collect(2);
        }
コード例 #4
0
        /// <summary>
        /// Scan for new namespaces when loaded
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void NamespacesDlg_Activated(object sender, EventArgs e)
        {
            NamespaceSummaryItemCollection nsColl = project.NamespaceSummaries;
            Collection <string>            asmNS, namespaces = new Collection <string>();
            AssemblyLoader loader = null;
            string         path = null;

            // Only load them once and not at design time
            if (namespacesLoaded || this.DesignMode)
            {
                return;
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;
                Application.DoEvents();
                namespacesLoaded = true;

                try
                {
                    // Make sure we start in the project's folder so that
                    // relative paths are resolved correctly.
                    Directory.SetCurrentDirectory(Path.GetDirectoryName(
                                                      project.Filename));

                    loader = AssemblyLoader.CreateAssemblyLoader(project);

                    // Get a list of all unique namespaces in the
                    // documentation assemblies.
                    foreach (DocumentAssembly da in project.Assemblies)
                    {
                        if (da.CommentsOnly)
                        {
                            continue;
                        }

                        try
                        {
                            path  = da.AssemblyPath;
                            asmNS = loader.GetNamespaces(path);

                            foreach (string ns in asmNS)
                            {
                                if (!namespaces.Contains(ns))
                                {
                                    namespaces.Add(ns);
                                }
                            }
                        }
                        catch (FileNotFoundException ex)
                        {
                            System.Diagnostics.Debug.WriteLine(ex);

                            if (MessageBox.Show("Unable to find the assembly '" +
                                                path + "' or one of its dependencies.  You " +
                                                "may need to build it or add a dependency " +
                                                "to the project dependency list.  Do you " +
                                                "want to continue loading the remaining " +
                                                "assemblies?", Constants.AppName,
                                                MessageBoxButtons.YesNo,
                                                MessageBoxIcon.Error) == DialogResult.No)
                            {
                                break;
                            }
                        }
                    }
                }
                finally
                {
                    if (loader != null)
                    {
                        AssemblyLoader.ReleaseAssemblyLoader();
                    }
                }

                // The global namespace (N:) isn't always listed but we'll
                // add it as it does show up in the reflection info anyway.
                if (!namespaces.Contains(String.Empty))
                {
                    namespaces.Add(String.Empty);
                }

                // Add new namespaces to the list
                foreach (string ns in namespaces)
                {
                    if (!nsColl.Contains(ns))
                    {
                        nsColl.Add(new NamespaceSummaryItem(ns));
                    }
                }

                nsColl.Sort();

                // Load the listbox with the namespace items
                foreach (NamespaceSummaryItem nsi in nsColl)
                {
                    lbNamespaces.Items.Add(nsi, nsi.IsDocumented);
                }

                if (lbNamespaces.Items.Count == 0)
                {
                    btnDelete.Enabled = txtSummary.Enabled = false;
                }
                else
                {
                    lbNamespaces.SelectedIndex = 0;
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }