예제 #1
0
        async public static void MethodSnippets()
        {
            #region LayoutProjectItem_GetLayout
            //Reference the layout associated with a layout project item.

            LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout Name"));
            Layout            layout     = await QueuedTask.Run(() => layoutItem.GetLayout()); //Perform on the worker thread

            #endregion LayoutProjectItem_GetLayout


            TextElement elm = layout.FindElement("Text") as TextElement;
            #region Layout_DeleteElement
            //Delete a single layout element.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                layout.DeleteElement(elm);
            });

            #endregion Layout_DeleteElement


            #region Layout_DeleteElements
            //Delete multiple layout elements.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                layout.DeleteElements(item => item.Name.Contains("Clone"));
            });

            #endregion Layout_DeleteElements


            #region Layout_FindElement
            //Find a layout element.  The example below is referencing an existing text element.

            TextElement txtElm = layout.FindElement("Text") as TextElement;
            #endregion Layout_FindElement


            #region Layout_GetSetDefinition
            //Modify a layout's CIM definition

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                CIMLayout cimLayout = layout.GetDefinition();

                //Do something

                layout.SetDefinition(cimLayout);
            });

            #endregion Layout_GetSetDefinition


            #region Layout_GetSetPage
            //Modify a layouts page settings.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                CIMPage page = layout.GetPage();

                //Do something

                layout.SetPage(page);
            });

            #endregion Layout_GetSetPage


            String filePath = null;
            #region Layout_ExportPDF
            //See ProSnippets "Export layout to PDF"
            #endregion Layout_ExportPDF


            #region Layout_ExportMS_PDF
            //Export multiple map series pages to PDF

            //Create a PDF export format
            PDFFormat msPDF = new PDFFormat()
            {
                Resolution               = 300,
                OutputFileName           = filePath,
                DoCompressVectorGraphics = true
            };

            //Set up the export options for the map series
            MapSeriesExportOptions MSExport_custom = new MapSeriesExportOptions()
            {
                ExportPages           = ExportPages.Custom,
                CustomPages           = "1-3, 5",
                ExportFileOptions     = ExportFileOptions.ExportAsSinglePDF,
                ShowSelectedSymbology = false
            };

            //Check to see if the path is valid and export
            if (msPDF.ValidateOutputFilePath())
            {
                layout.Export(msPDF, MSExport_custom); //Export the PDF to a single, multiple page PDF.
            }
            #endregion Layout_ExportMS_PDF


            #region Layout_ExportMS_TIFF
            //Export multiple map series pages to TIFF

            //Create a TIFF export format
            TIFFFormat msTIFF = new TIFFFormat()
            {
                Resolution     = 300,
                OutputFileName = filePath,
                ColorMode      = ColorMode.TwentyFourBitTrueColor,
                HasGeoTiffTags = true,
                HasWorldFile   = true
            };

            //Set up the export options for the map series
            MapSeriesExportOptions MSExport_All = new MapSeriesExportOptions()
            {
                ExportPages           = ExportPages.All,
                ExportFileOptions     = ExportFileOptions.ExportMultipleNames,
                ShowSelectedSymbology = false
            };

            //Check to see if the path is valid and export
            if (msPDF.ValidateOutputFilePath())
            {
                layout.Export(msPDF, MSExport_All); //Export each page to a TIFF and apppend the page name suffix to each output file
            }
            #endregion Layout_ExportMS_TIFF


            #region Layout_RefreshMapSeries
            //Refresh the map series associated with the layout.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                layout.RefreshMapSeries();
            });

            #endregion Layout_RefreshMapSeries


            #region Layout_SaveAsFile
            //Save a layout to a pagx file.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                layout.SaveAsFile(filePath);
            });

            #endregion Layout_SaveAsFile


            #region Layout_SetName
            //Change the name of a layout.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                layout.SetName("New Name");
            });

            #endregion Layout_SetName


            SpatialMapSeries SMS = null;
            #region Layout_SetMapSeries
            //Change the properities of a spacial map series.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                layout.SetMapSeries(SMS);
            });

            #endregion Layout_SetMapSeries


            #region Layout_ShowProperties
            //Open the layout properties dialog.

            //Get the layout associated with a layout project item
            LayoutProjectItem lytItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout Name"));
            Layout            lyt     = await QueuedTask.Run(() => lytItem.GetLayout()); //Worker thread

            //Open the properties dialog
            lyt.ShowProperties(); //GUI thread
            #endregion Layout_ShowProperties
        }
예제 #2
0
        async public static void MethodSnippets()
        {
            #region MapSeries_Constructor1
            //Set up map series export options

            MapSeriesExportOptions MSExport_SinglePage = new MapSeriesExportOptions()
            {
                ExportPages           = ExportPages.Custom,                  //Provide a specific list of pages
                CustomPages           = "1-3, 5",                            //Only used if ExportPages.Custom is set
                ExportFileOptions     = ExportFileOptions.ExportAsSinglePDF, //Export all pages to a single, multi-page PDF
                ShowSelectedSymbology = false                                //Do no show selection symbology in the output
            };
            #endregion MapSeries_Constructor1


            #region MapSeries_Constructor2
            //Set up map series export options

            MapSeriesExportOptions MSExport_IndivPages = new MapSeriesExportOptions()
            {
                ExportPages           = ExportPages.All,                       //All pages
                ExportFileOptions     = ExportFileOptions.ExportMultipleNames, //Export each page to an individual file using page name as a suffix.
                ShowSelectedSymbology = true                                   //Include selection symbology in the output
            };
            #endregion MapSeries_Constructor2



            #region MapSeries_FindPageNumber
            //Return the page number that corresponds to the page name field for an index feature

            Layout layout = LayoutView.Active.Layout;

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                SpatialMapSeries SMS = layout.MapSeries as SpatialMapSeries;
                Row msRow            = SMS.CurrentRow;
                System.Windows.MessageBox.Show(SMS.FindPageNumber(msRow.GetOriginalValue(msRow.FindField("NAME")).ToString()));
            });

            #endregion MapSeries_FindPageNumber


            #region MapSeries_GetSetDefinition
            //Get and modify a map series CIM definition and set the changes back to the layout

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                MapSeries MS        = layout.MapSeries as MapSeries;
                CIMMapSeries CIM_MS = MS.GetDefinition();
                CIM_MS.Enabled      = false;
                MS.SetDefinition(CIM_MS);
                layout.SetMapSeries(MS);
            });

            #endregion MapSeries_GetSetDefinition


            #region MapSeries_SetCurrentPageNumber
            //Set the current page to match a specific page number

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                MapSeries MS = layout.MapSeries as MapSeries;
                MS.SetCurrentPageNumber("IV");
            });

            #endregion MapSeries_SetCurrentPageNumber
        }