btnOK_Click
        (
            object sender,
            EventArgs e
        )
        {
            AssertValid();

            if (!DoDataExchange(true))
            {
                return;
            }

            this.UseWaitCursor = true;

            try
            {
                GroupByVertexAttribute();

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);
            }
            finally
            {
                this.UseWaitCursor = false;
            }
        }
        btnOK_Click
        (
            object sender,
            System.EventArgs e
        )
        {
            if (!DoDataExchange(true))
            {
                return;
            }

            try
            {
                ImportFromEdgeWorkbook();
            }
            catch (ImportWorkbookException oImportWorkbookException)
            {
                this.ShowWarning(oImportWorkbookException.Message);
                return;
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);
                return;
            }

            DialogResult = DialogResult.OK;
            this.Close();
        }
Example #3
0
        SelectGroupTableRows()
        {
            AssertValid();

            SheetHelper oSheetHelper = m_oGroupWorksheet.SheetHelper;

            if (!oSheetHelper.TableExists)
            {
                return;
            }

            m_bIgnoreSelectionEvents = true;

            try
            {
                oSheetHelper.SelectTableRowsByColumnValues <String>(
                    GroupTableColumnNames.Name,
                    m_oTaskPane.GetSelectedCollapsedGroupNames(),
                    ExcelUtil.TryGetNonEmptyStringFromCell
                    );
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);
            }
            finally
            {
                m_bIgnoreSelectionEvents = false;
            }
        }
Example #4
0
        btnOK_Click
        (
            object sender,
            EventArgs e
        )
        {
            AssertValid();

            if (!DoDataExchange(true))
            {
                return;
            }

            try
            {
                AutoFillWorkbookWithScheme();
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        btnOK_Click
        (
            object sender,
            System.EventArgs e
        )
        {
            if (!DoDataExchange(true))
            {
                return;
            }

            this.Cursor = Cursors.WaitCursor;

            try
            {
                ImportFromMatrixWorkbook();
            }
            catch (ImportWorkbookException oImportWorkbookException)
            {
                this.ShowWarning(oImportWorkbookException.Message);
                return;
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

            DialogResult = DialogResult.OK;
            this.Close();
        }
Example #6
0
        SelectEdgeOrVertexTableRows
        (
            Boolean bSelectEdgeTableRows
        )
        {
            AssertValid();

            Sheets1And2Helper oSheets1And2Helper = bSelectEdgeTableRows ?
                                                   m_oEdgeWorksheet.Sheets1And2Helper :
                                                   m_oVertexWorksheet.Sheets1And2Helper;

            if (!oSheets1And2Helper.TableExists)
            {
                return;
            }

            m_bIgnoreSelectionEvents = true;

            try
            {
                oSheets1And2Helper.SelectTableRowsByRowIDs(bSelectEdgeTableRows ?
                                                           m_oTaskPane.GetSelectedEdgeRowIDs() :
                                                           m_oTaskPane.GetSelectedVertexRowIDs()
                                                           );
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);
            }
            finally
            {
                m_bIgnoreSelectionEvents = false;
            }
        }
        ConvertNodeXLWorkbook
        (
            String sOtherWorkbookFile,
            String sConvertedWorkbookFile
        )
        {
            AssertValid();
            Debug.Assert(!String.IsNullOrEmpty(sOtherWorkbookFile));
            Debug.Assert(!String.IsNullOrEmpty(sConvertedWorkbookFile));

            try
            {
                NodeXLWorkbookConverter.ConvertNodeXLWorkbook(sOtherWorkbookFile,
                                                              sConvertedWorkbookFile);
            }
            catch (NodeXLWorkbookConversionException
                   oNodeXLWorkbookConversionException)
            {
                this.ShowWarning(oNodeXLWorkbookConversionException.Message);

                return(false);
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);

                return(false);
            }

            return(true);
        }
        StartImageCreation()
        {
            AssertValid();

            // Read the workbook into a new IGraph.

            IGraph oGraph;

            try
            {
                oGraph = ReadWorkbook(m_oWorkbook);
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);
                this.State = DialogState.Idle;

                return;
            }

            lblStatus.Text = "Creating subgraph images.";

            ICollection <IVertex> oSelectedVertices = new IVertex[0];

            if (m_oCreateSubgraphImagesDialogUserSettings.SelectedVerticesOnly)
            {
                // Get the vertices corresponding to the selected rows in the
                // vertex worksheet.

                oSelectedVertices = GetSelectedVertices(
                    oGraph, m_oSelectedVertexNames);
            }

            m_oSubgraphImageCreator.CreateSubgraphImagesAsync(
                oGraph,
                oSelectedVertices,
                m_oCreateSubgraphImagesDialogUserSettings.Levels,
                m_oCreateSubgraphImagesDialogUserSettings.SaveToFolder,
                m_oCreateSubgraphImagesDialogUserSettings.Folder,
                m_oCreateSubgraphImagesDialogUserSettings.ImageSizePx,
                m_oCreateSubgraphImagesDialogUserSettings.ImageFormat,
                m_oCreateSubgraphImagesDialogUserSettings.InsertThumbnails,
                m_oCreateSubgraphImagesDialogUserSettings.ThumbnailSizePx,
                m_oCreateSubgraphImagesDialogUserSettings.SelectedVerticesOnly,
                m_oCreateSubgraphImagesDialogUserSettings.SelectVertex,
                m_oCreateSubgraphImagesDialogUserSettings.SelectIncidentEdges,
                new GeneralUserSettings(),
                new LayoutUserSettings()
                );
        }
Example #9
0
        btnOK_Click
        (
            object sender,
            System.EventArgs e
        )
        {
            if (!DoDataExchange(true))
            {
                return;
            }

            m_oAutomateTasksUserSettings.Save();

            try
            {
                if (m_oAutomateTasksUserSettings.AutomateThisWorkbookOnly)
                {
                    TaskAutomator.AutomateThisWorkbook(m_oThisWorkbook,
                                                       m_oAutomateTasksUserSettings.TasksToRun, m_oRibbon);
                }
                else
                {
                    TaskAutomator.AutomateFolder(
                        m_oAutomateTasksUserSettings.FolderToAutomate,
                        m_oAutomateTasksUserSettings.TasksToRun,
                        m_oThisWorkbook.Application);
                }
            }
            catch (UnauthorizedAccessException oUnauthorizedAccessException)
            {
                // This occurs when a workbook is read-only.

                this.ShowWarning(
                    "A problem occurred while running tasks.  Details:"
                    + "\r\n\r\n"
                    + oUnauthorizedAccessException.Message
                    );

                return;
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        OnLoad
        (
            EventArgs e
        )
        {
            AssertValid();

            base.OnLoad(e);

            // Start the calculations.

            try
            {
                if (m_oGraphMetricCalculators != null)
                {
                    // Use the specified graph metric calculators.

                    m_oGraphMetricCalculationManager.CalculateGraphMetricsAsync(
                        m_oWorkbook, m_oGraphMetricCalculators,
                        m_oGraphMetricUserSettings);
                }
                else
                {
                    // Use a default list of graph metric calculators.

                    m_oGraphMetricCalculationManager.CalculateGraphMetricsAsync(
                        m_oWorkbook, m_oGraphMetricUserSettings);
                }
            }
            catch (Exception oException)
            {
                // An exception was thrown from the synchronous code within
                // CalculateGraphMetricsAsync().  (Exceptions thrown from the
                // asynchronous code are handled by the
                // GraphMetricCalculationCompleted event handler.)

                ErrorUtil.OnException(oException);

                this.Close();
            }
        }
        GraphMetricCalculationManager_GraphMetricCalculationCompleted
        (
            object sender,
            RunWorkerCompletedEventArgs e
        )
        {
            AssertValid();

            Exception oException = e.Error;

            if (oException != null)
            {
                if (oException is GraphMetricException)
                {
                    // This is a known exception.

                    this.ShowWarning(oException.Message);
                }
                else
                {
                    // The exception is unexpected.

                    ErrorUtil.OnException(oException);
                }
            }
            else if (!e.Cancelled)
            {
                Debug.Assert(e.Result is GraphMetricColumn[]);

                WriteGraphMetricColumnsToWorkbook(
                    ( GraphMetricColumn[] )e.Result);

                // Everything succeeded.

                this.DialogResult = DialogResult.OK;
            }

            this.Close();
        }
        WriteGraphMetricColumnsToWorkbook
        (
            GraphMetricColumn [] aoGraphMetricColumns
        )
        {
            Debug.Assert(aoGraphMetricColumns != null);
            AssertValid();

            Microsoft.Office.Interop.Excel.Application oApplication =
                m_oWorkbook.Application;

            GraphMetricWriter oGraphMetricWriter = new GraphMetricWriter();

            oApplication.ScreenUpdating = false;

            try
            {
                oGraphMetricWriter.WriteGraphMetricColumnsToWorkbook(
                    aoGraphMetricColumns, m_oWorkbook);

                // Let the user know that graph metrics have been calculated.

                oGraphMetricWriter.ActivateRelevantWorksheet(
                    aoGraphMetricColumns, m_oWorkbook);
            }
            catch (Exception oException)
            {
                oApplication.ScreenUpdating = true;

                ErrorUtil.OnException(oException);

                this.Close();
                return;
            }

            oApplication.ScreenUpdating = true;
        }
Example #13
0
        btnOK_Click
        (
            object sender,
            System.EventArgs e
        )
        {
            AssertValid();

            if (!DoDataExchange(true))
            {
                return;
            }

            this.Cursor = Cursors.WaitCursor;
            Exception oExpectedException = null;

            try
            {
                OpenUcinetFile();
            }
            catch (IOException oIOException)
            {
                oExpectedException = oIOException;
            }
            catch (UnauthorizedAccessException oUnauthorizedAccessException)
            {
                oExpectedException = oUnauthorizedAccessException;
            }
            catch (FormatException oFormatException)
            {
                oExpectedException = oFormatException;
            }
            catch (Exception oUnexpectedException)
            {
                ErrorUtil.OnException(oUnexpectedException);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

            if (oExpectedException != null)
            {
                String sMessage =
                    "The file could not be opened.  Details:\n\n"
                    + oExpectedException.Message;

                if (oExpectedException is FormatException)
                {
                    sMessage +=
                        "\n\nThis does not appear to be a UCINET full matrix DL"
                        + " file.  "
                        + FormatMessage
                    ;
                }

                this.ShowWarning(sMessage);
                return;
            }

            DialogResult = DialogResult.OK;
            this.Close();
        }
        OnImageCreationCompleted
        (
            RunWorkerCompletedEventArgs e
        )
        {
            AssertValid();

            if (e.Cancelled)
            {
                this.State = DialogState.Idle;

                lblStatus.Text = "Image creation stopped.";
            }
            else if (e.Error != null)
            {
                this.State = DialogState.Idle;

                Exception oException = e.Error;

                if (oException is System.IO.IOException)
                {
                    lblStatus.Text = "Image creation error.";

                    this.ShowWarning(oException.Message);
                }
                else
                {
                    ErrorUtil.OnException(oException);
                }
            }
            else
            {
                // Success.  Were temporary images created that need to be inserted
                // into the vertex worksheet?

                Debug.Assert(e.Result is TemporaryImages);

                TemporaryImages oTemporaryImages = (TemporaryImages)e.Result;

                if (oTemporaryImages.Folder != null)
                {
                    // Yes.  Insert them, then delete the temporary images.

                    this.State = DialogState.PopulatingImageColumn;

                    String sLastStatusFromSubgraphImageCreator = lblStatus.Text;

                    lblStatus.Text =
                        "Inserting subgraph thumbnails into the worksheet.  Please"
                        + " wait...";

                    TableImagePopulator.PopulateColumnWithImages(m_oWorkbook,
                                                                 WorksheetNames.Vertices, TableNames.Vertices,
                                                                 VertexTableColumnNames.SubgraphImage,
                                                                 VertexTableColumnNames.VertexName, oTemporaryImages
                                                                 );

                    lblStatus.Text = sLastStatusFromSubgraphImageCreator;
                }

                this.State = DialogState.Idle;

                if (m_eMode == DialogMode.Automate)
                {
                    this.Close();
                }
            }
        }
Example #15
0
        AutomateFolder
        (
            String folderToAutomate,
            AutomationTasks tasksToRun,
            Microsoft.Office.Interop.Excel.Application application
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(folderToAutomate));
            Debug.Assert(application != null);

            foreach (String sFileName in Directory.GetFiles(folderToAutomate,
                                                            "*.xlsx"))
            {
                String sFilePath = Path.Combine(folderToAutomate, sFileName);

                try
                {
                    if (!NodeXLWorkbookUtil.FileIsNodeXLWorkbook(sFilePath))
                    {
                        continue;
                    }
                }
                catch (IOException)
                {
                    // Skip any workbooks that are already open, or that have any
                    // other problems that prevent them from being opened.

                    continue;
                }

                // Ideally, the Excel API would be used here to open the workbook
                // and run the AutomateThisWorkbook() method on it.  Two things
                // make that impossible:
                //
                //   1. When you open a workbook using
                //      Application.Workbooks.Open(), you get only a native Excel
                //      workbook, not an "extended" ThisWorkbook object or its
                //      associated Ribbon object.  AutomateThisWorkbook() requires
                //      a Ribbon object.
                //
                //      Although a GetVstoObject() extension method is available to
                //      convert a native Excel workbook to an extended workbook,
                //      that method doesn't work on a native workbook opened via
                //      the Excel API -- it always returns null.
                //
                //      It might be possible to refactor AutomateThisWorkbook() to
                //      require only a native workbook.  However, problem 2 would
                //      still make things impossible...
                //
                //   2. If this method is being run from a modal dialog, which it
                //      is (see AutomateTasksDialog), then code in the workbook
                //      that needs to be automated doesn't run until the modal
                //      dialog closes.
                //
                // The following code works around these problems.

                try
                {
                    // Store an "automate tasks on open" flag in the workbook,
                    // indicating that task automation should be run on it the next
                    // time it's opened.  This can be done via the Excel API.

                    Microsoft.Office.Interop.Excel.Workbook oWorkbookToAutomate =
                        ExcelUtil.OpenWorkbook(sFilePath, application);

                    PerWorkbookSettings oPerWorkbookSettings =
                        new PerWorkbookSettings(oWorkbookToAutomate);

                    oPerWorkbookSettings.AutomateTasksOnOpen = true;
                    oWorkbookToAutomate.Save();
                    oWorkbookToAutomate.Close(false, Missing.Value, Missing.Value);

                    // Now open the workbook in another instance of Excel, which
                    // bypasses problem 2.  Code in the workbook's Ribbon will
                    // detect the flag's presence, run task automation on it, close
                    // the workbook, and close the other instance of Excel.

                    OpenWorkbookToAutomate(sFilePath);
                }
                catch (Exception oException)
                {
                    ErrorUtil.OnException(oException);
                    return;
                }
            }
        }
Example #16
0
        OnEdgeOrVertexTableSelectionChange
        (
            Boolean bChangeInEdgeTable
        )
        {
            AssertValid();

            Sheets1And2Helper oSheets1And2Helper = bChangeInEdgeTable ?
                                                   m_oEdgeWorksheet.Sheets1And2Helper :
                                                   m_oVertexWorksheet.Sheets1And2Helper;

            if (IgnoreTableSelectionChange(oSheets1And2Helper))
            {
                return;
            }

            m_bIgnoreSelectionEvents = true;

            try
            {
                // (The following comments are for the bChangeInEdgeTable=true
                // case.

                // Get an array of unique row IDs for all edge rows that have at
                // least one cell selected.

                ICollection <Int32> oSelectedRowIDs =
                    oSheets1And2Helper.GetSelectedRowIDs();

                // Select those edges (and possibly their adjacent vertices) in the
                // TaskPane.  This will cause the TaskPane.SelectionChangedInGraph
                // event to fire, but this class will ignore it because
                // m_bIgnoreSelectionEvents is currently set to true.

                if (bChangeInEdgeTable)
                {
                    m_oTaskPane.SetSelectedEdgesByRowID(oSelectedRowIDs);
                }
                else
                {
                    m_oTaskPane.SetSelectedVerticesByRowID(oSelectedRowIDs);
                }

                // The selection in the vertex table may now be out of sync with
                // the TaskPane.  Ideally, the vertex table would be updated right
                // now.  However, you can't select rows in a worksheet that isn't
                // active.  As a workaround, set a flag that will cause the
                // selection in the vertex table to be updated the next time the
                // vertex worksheet is activated.
                //
                // It would be possible to avoid deferring the selection by turning
                // off screen updating and temporarily selecting the vertex
                // worksheet.  Selecting a worksheet is slow, however, even with
                // screen updating turned off.  It takes about 250ms on a fast
                // machine.  That's too slow to keep up with the user if he is
                // scrolling through a table with the down-arrow key, for example.

                if (bChangeInEdgeTable)
                {
                    m_bUpdateVertexSelectionOnActivation = true;
                }
                else
                {
                    m_bUpdateEdgeSelectionOnActivation = true;
                }

                // Selecting an edge or vertex invalidates any selected groups.

                m_bUpdateGroupSelectionOnActivation = true;

                // Enable the "set visual attribute" buttons in the Ribbon.

                m_oThisWorkbook.EnableSetVisualAttributes();
            }
            catch (COMException)
            {
                // A user reported a bug in which Application.Intersect() throws a
                // COMException with an HRESULT of 0x800AC472.
                // (Application.Intersect() gets called indirectly by
                // OnSelectionChangedInTable().)  The bug occurred while switching
                // windows.  I couldn't reproduce the bug, but the following post
                // suggests that the HRESULT, which is VBA_E_IGNORE, occurs when an
                // object model call is made while the object model is "suspended."
                //
                // http://social.msdn.microsoft.com/forums/en-US/vsto/thread/
                // 9168f9f2-e5bc-4535-8d7d-4e374ab8ff09/
                //
                // Other posts also mention that it can occur during window
                // switches.
                //
                // I can't reproduce the bug and I'm not sure of the root cause,
                // but catching and ignoring the error should lead to nothing worse
                // than a mouse click being ignored.
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);
            }
            finally
            {
                m_bIgnoreSelectionEvents = false;
            }
        }
Example #17
0
        AutomateThisWorkbook
        (
            ThisWorkbook thisWorkbook,
            AutomationTasks tasksToRun,
            Ribbon ribbon
        )
        {
            Debug.Assert(thisWorkbook != null);
            Debug.Assert(ribbon != null);

            Microsoft.Office.Interop.Excel.Workbook oWorkbook =
                thisWorkbook.InnerObject;

            if ((tasksToRun & AutomationTasks.MergeDuplicateEdges) != 0)
            {
                // In general, automation is best performed by simulating a click
                // of a Ribbon button, thus avoiding any duplicate code.

                if (!ribbon.OnMergeDuplicateEdgesClick(false))
                {
                    return;
                }
            }

            if ((tasksToRun & AutomationTasks.CalculateGraphMetrics) != 0)
            {
                // In this case, clicking the corresponding Ribbon button opens a
                // GraphMetricsDialog, which allows the user to edit the graph
                // metric settings before calculating the graph metrics.  The
                // actual calculations are done by CalculateGraphMetricsDialog, so
                // just use that dialog directly.

                CalculateGraphMetricsDialog oCalculateGraphMetricsDialog =
                    new CalculateGraphMetricsDialog(oWorkbook,
                                                    new GraphMetricUserSettings());

                if (oCalculateGraphMetricsDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            if ((tasksToRun & AutomationTasks.AutoFillWorkbook) != 0)
            {
                // In this case, clicking the corresponding Ribbon button opens an
                // AutoFillWorkbookDialog, which allows the user to edit the
                // autofill settings before autofilling the workbook.  The actual
                // autofilling is done by WorkbookAutoFiller, so just use that
                // class directly.

                try
                {
                    WorkbookAutoFiller.AutoFillWorkbook(
                        oWorkbook, new AutoFillUserSettings(oWorkbook));

                    ribbon.OnWorkbookAutoFilled(false);
                }
                catch (Exception oException)
                {
                    ErrorUtil.OnException(oException);
                    return;
                }
            }

            if ((tasksToRun & AutomationTasks.CreateSubgraphImages) != 0)
            {
                ribbon.OnCreateSubgraphImagesClick(
                    CreateSubgraphImagesDialog.DialogMode.Automate);
            }

            if ((tasksToRun & AutomationTasks.CalculateClusters) != 0)
            {
                if (!ribbon.OnCalculateClustersClick())
                {
                    return;
                }
            }

            if ((tasksToRun & AutomationTasks.ReadWorkbook) != 0)
            {
                // If the vertex X and Y columns were autofilled, the layout type
                // was set to LayoutType.Null.  This will cause
                // TaskPane.ReadWorkbook() to display a warning.  Temporarily turn
                // the warning off.

                NotificationUserSettings oNotificationUserSettings =
                    new NotificationUserSettings();

                Boolean bOldLayoutTypeIsNull =
                    oNotificationUserSettings.LayoutTypeIsNull;

                oNotificationUserSettings.LayoutTypeIsNull = false;
                oNotificationUserSettings.Save();

                if ((tasksToRun & AutomationTasks.SaveGraphImageFile) != 0)
                {
                    if (String.IsNullOrEmpty(thisWorkbook.Path))
                    {
                        throw new InvalidOperationException(
                                  WorkbookNotSavedMessage);
                    }

                    // After the workbook is read and the graph is laid out, save
                    // an image of the graph to a file.

                    GraphLaidOutEventHandler oGraphLaidOutEventHandler = null;

                    oGraphLaidOutEventHandler =
                        delegate(Object sender, GraphLaidOutEventArgs e)
                    {
                        // This delegate remains forever, even when the dialog
                        // class is destroyed.  Prevent it from being called again.

                        thisWorkbook.GraphLaidOut -= oGraphLaidOutEventHandler;

                        SaveGraphImageFile(e.NodeXLControl, thisWorkbook.FullName);
                    };

                    thisWorkbook.GraphLaidOut += oGraphLaidOutEventHandler;
                }

                ribbon.OnReadWorkbookClick();

                oNotificationUserSettings.LayoutTypeIsNull = bOldLayoutTypeIsNull;
                oNotificationUserSettings.Save();
            }
        }
Example #18
0
        btnCustomizeVertexMenu_Click
        (
            object sender,
            EventArgs e
        )
        {
            AssertValid();

            const String Message =
                "Use this to add custom menu items to the menu that appears when"
                + " you right-click a vertex in the NodeXL graph."
                + "\r\n\r\n"
                + "Clicking \"Yes\" below will add a pair of columns to the"
                + " Vertices worksheet -- one for menu item text and another for"
                + " the action to take when the menu item is selected."
                + "\r\n\r\n"
                + "For example, if you add the column pair and enter \"Send Mail"
                + " To\" for a vertex's menu item text and \"mailto:[email protected]\""
                + " for the action, then right-clicking the vertex in the NodeXL"
                + " graph and selecting \"Send Mail To\" from the right-click menu"
                + " will open a new email message addressed to [email protected]."
                + "\r\n\r\n"
                + "If you want to open a Web page when the menu item is selected,"
                + " enter an URL for the action."
                + "\r\n\r\n"
                + "If you want to add more than one custom menu item to a vertex's"
                + " right-click menu, run this again to add another pair of"
                + " columns."
                + "\r\n\r\n"
                + "Do you want to add a pair of columns to the Vertices worksheet?"
            ;

            if (MessageBox.Show(Message, this.ApplicationName,
                                MessageBoxButtons.YesNo, MessageBoxIcon.Information) !=
                DialogResult.Yes)
            {
                return;
            }

            // Create and use the object that adds the columns to the vertex
            // table.

            TableColumnAdder oTableColumnAdder = new TableColumnAdder();

            this.UseWaitCursor = true;

            try
            {
                oTableColumnAdder.AddColumnPair(m_oWorkbook,
                                                WorksheetNames.Vertices, TableNames.Vertices,
                                                VertexTableColumnNames.CustomMenuItemTextBase,
                                                VertexTableColumnWidths.CustomMenuItemText,
                                                VertexTableColumnNames.CustomMenuItemActionBase,
                                                VertexTableColumnWidths.CustomMenuItemAction
                                                );

                this.UseWaitCursor = false;
            }
            catch (Exception oException)
            {
                this.UseWaitCursor = false;

                ErrorUtil.OnException(oException);
            }
        }
Example #19
0
        CheckForUpdate()
        {
            // Get the version of the installed version of the application.

            FileVersionInfo oCurrentFileVersionInfo =
                AssemblyUtil2.GetFileVersionInfo();

            // Get the version information for the latest version of the
            // application.

            Int32 iLatestVersionFileMajorPart   = 0;
            Int32 iLatestVersionFileMinorPart   = 0;
            Int32 iLatestVersionFileBuildPart   = 0;
            Int32 iLatestVersionFilePrivatePart = 0;

            try
            {
                GetLatestVersionInfo(out iLatestVersionFileMajorPart,
                                     out iLatestVersionFileMinorPart,
                                     out iLatestVersionFileBuildPart,
                                     out iLatestVersionFilePrivatePart
                                     );
            }
            catch (WebException)
            {
                FormUtil.ShowWarning(
                    "The Web site from which updates are obtained could not be"
                    + " reached.  Either an Internet connection isn't available,"
                    + " or the Web site isn't available."
                    );

                return;
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);

                return;
            }

            if (
                iLatestVersionFileMajorPart > oCurrentFileVersionInfo.FileMajorPart
                ||
                iLatestVersionFileMinorPart > oCurrentFileVersionInfo.FileMinorPart
                ||
                iLatestVersionFileBuildPart > oCurrentFileVersionInfo.FileBuildPart
                ||
                iLatestVersionFilePrivatePart >
                oCurrentFileVersionInfo.FilePrivatePart
                )
            {
                String sMessage = String.Format(

                    "A new version of {0} is available.  Do you want to open the"
                    + " Web page from which the new version can be downloaded?"
                    ,
                    FormUtil.ApplicationName
                    );

                if (MessageBox.Show(sMessage, FormUtil.ApplicationName,
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Information) ==
                    DialogResult.Yes)
                {
                    Process.Start(ProjectInformation.DownloadPageUrl);
                }
            }
            else
            {
                FormUtil.ShowInformation(String.Format(

                                             "You have the latest version of {0}."
                                             ,
                                             FormUtil.ApplicationName
                                             ));
            }
        }