Ejemplo n.º 1
0
        TryGetFilesInPlugInFolder
        (
            out IEnumerable <String> oFileNames
        )
        {
            oFileNames = null;

            String sPlugInFolder = ApplicationUtil.GetPlugInFolder();

            if (!Directory.Exists(sPlugInFolder))
            {
                return(false);
            }

            List <String> oFileNameList = new List <String>();

            foreach (String sSearchPattern in new String[] { "*.dll", "*.exe" })
            {
                oFileNameList.AddRange(Directory.GetFiles(
                                           sPlugInFolder, sSearchPattern));
            }

            oFileNames = oFileNameList;

            return(true);
        }
Ejemplo n.º 2
0
        ExportSelectionToNewNodeXLWorkbook()
        {
            AssertValid();

            // Get the path to the application's template.

            String sTemplatePath;

            if (!ApplicationUtil.TryGetTemplatePath(out sTemplatePath))
            {
                throw new ExportWorkbookException(
                          ApplicationUtil.GetMissingTemplateMessage());
            }

            Workbook oNewNodeXLWorkbook = null;

            CopyTableToNewNodeXLWorkbook(WorksheetNames.Edges,
                                         TableNames.Edges, sTemplatePath, ref oNewNodeXLWorkbook);

            CopyTableToNewNodeXLWorkbook(WorksheetNames.Vertices,
                                         TableNames.Vertices, sTemplatePath, ref oNewNodeXLWorkbook);

            if (oNewNodeXLWorkbook == null)
            {
                throw new ExportWorkbookException(
                          "There are no selected edges or vertices to export to a new"
                          + " workbook."
                          );
            }

            return(oNewNodeXLWorkbook);
        }
        //*************************************************************************
        //  Constructor: GraphMetricCalculationManager()
        //
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="GraphMetricCalculationManager" /> class.
        /// </summary>
        //*************************************************************************

        public GraphMetricCalculationManager()
        {
            m_oBackgroundWorker = null;

            // Set the path to the executable that calculates graph metrics using
            // the SNAP library.

            GraphMetricCalculatorBase.SetSnapGraphMetricCalculatorPath(
                Path.Combine(ApplicationUtil.GetApplicationFolder(),
                             SnapGraphMetricCalculatorFileName));

            AssertValid();
        }
Ejemplo n.º 4
0
        GetMissingTemplateMessage()
        {
            String sTemplatePath;

            ApplicationUtil.TryGetTemplatePath(out sTemplatePath);

            return(String.Format(

                       "The {0} Excel template couldn't be found."
                       + "\r\n\r\n"
                       + "The {0} setup program should have copied the template to"
                       + " {1}.  If you moved the template somewhere else, you won't"
                       + " be able to use this feature."
                       ,
                       ApplicationUtil.ApplicationName,
                       sTemplatePath
                       ));
        }
Ejemplo n.º 5
0
        ConvertNodeXLWorkbook
        (
            String otherWorkbookFile,
            String convertedWorkbookFile
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(otherWorkbookFile));
            Debug.Assert(File.Exists(otherWorkbookFile));
            Debug.Assert(!String.IsNullOrEmpty(convertedWorkbookFile));

            // The application's template is needed to get the customization
            // information.

            String sTemplatePath;

            if (!ApplicationUtil.TryGetTemplatePath(out sTemplatePath))
            {
                throw new NodeXLWorkbookConversionException(
                          ApplicationUtil.GetMissingTemplateMessage());
            }

        #if false  // For testing.
            sTemplatePath = @"E:\NodeXL\ExcelTemplateSetup\"
                            + "TemplateModifiedForClickOnce\NodeXLGraph.xltx";
        #endif

            try
            {
                File.Copy(otherWorkbookFile, convertedWorkbookFile, true);
            }
            catch (UnauthorizedAccessException)
            {
                throw new NodeXLWorkbookConversionException(
                          "The converted copy already exists and is read-only.  It can't"
                          + " be overwritten."
                          );
            }
            catch (IOException oIOException)
            {
                if (oIOException.Message.Contains(
                        "it is being used by another process"))
                {
                    throw new NodeXLWorkbookConversionException(
                              "The converted copy already exists and is open in Excel."
                              + "  It can't be overwritten."
                              );
                }

                throw (oIOException);
            }

            // Remove the other customization.

            try
            {
                if (ServerDocument.IsCustomized(convertedWorkbookFile))
                {
                    ServerDocument.RemoveCustomization(convertedWorkbookFile);
                }
            }
            catch (Microsoft.VisualStudio.Tools.Applications.Runtime.
                   UnknownCustomizationFileException)
            {
                throw new NodeXLWorkbookConversionException(
                          "The file doesn't appear to be an Excel workbook."
                          );
            }

            // Create a ServerDocument from the application's template.  The
            // solution ID and deployment manifest name will be obtained from this.

            using (ServerDocument oTemplateServerDocument =
                       new ServerDocument(sTemplatePath, FileAccess.Read))
            {
                // For some reason, ServerDocument.AddCustomization() also requires
                // a path to the NodeXL assembly file, even though it doesn't get
                // embedded in the document.

                String sAssemblyFile = new Uri(
                    Assembly.GetExecutingAssembly().CodeBase).LocalPath;

                String [] asNonPublicCachedDataMembers;

                ServerDocument.AddCustomization(convertedWorkbookFile,
                                                sAssemblyFile, oTemplateServerDocument.SolutionId,
                                                oTemplateServerDocument.DeploymentManifestUrl, false,
                                                out asNonPublicCachedDataMembers);
            }
        }