示例#1
0
        //*************************************************************************
        //  Method: SaveImage()
        //
        /// <summary>
        /// Saves the graph image to a file.
        /// </summary>
        //*************************************************************************
        protected void SaveImage()
        {
            AssertValid();

            if (oNodeXLControl.IsLayingOutGraph)
            {
            return;
            }

            // Get the size of the image.

            GraphImageUserSettings oGraphImageUserSettings =
            new GraphImageUserSettings();

            Int32 iWidth, iHeight;

            if (oGraphImageUserSettings.UseControlSize)
            {
            Size oNodeXLControlSizePx = ehNodeXLControlHost.ClientSize;
            iWidth = oNodeXLControlSizePx.Width;
            iHeight = oNodeXLControlSizePx.Height;

            if (iWidth == 0 || iHeight == 0)
            {
                // The size is unusable.

                FormUtil.ShowWarning(
                    "The graph is too small to save.  Make the graph window"
                    + " larger."
                    );

                return;
            }
            }
            else
            {
            Size oImageSize = oGraphImageUserSettings.ImageSize;
            iWidth = oImageSize.Width;
            iHeight = oImageSize.Height;
            }

            if (m_oSaveGraphImageFileDialog == null)
            {
            m_oSaveGraphImageFileDialog =
                new SaveGraphImageFileDialog(String.Empty, "GraphImage");

            m_oSaveGraphImageFileDialog.DialogTitle = "Save Image to File";
            }

            m_oSaveGraphImageFileDialog.ShowDialogAndSaveGraphImage(oNodeXLControl,
            iWidth, iHeight);
        }
示例#2
0
        //*************************************************************************
        //  Constructor: TaskPane()
        //
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskPane" /> class.
        /// </summary>
        ///
        /// <param name="thisWorkbook">
        /// The workbook.
        /// </param>
        ///
        /// <param name="ribbon">
        /// The application's ribbon.
        /// </param>
        //*************************************************************************
        public TaskPane(
            ThisWorkbook thisWorkbook,
            Ribbon ribbon
            )
        {
            Debug.Assert(thisWorkbook != null);
            Debug.Assert(ribbon != null);

            InitializeComponent();

            m_oWorkbook = thisWorkbook.InnerObject;
            m_oRibbon = ribbon;

            // The WpfImageUtil uses the screen DPI in its image handling.

            Graphics oGraphics = this.CreateGraphics();
            WpfImageUtil.ScreenDpi = oGraphics.DpiX;
            oGraphics.Dispose();

            // Get the template version from the per-workbook settings.

            PerWorkbookSettings oPerWorkbookSettings =
            this.PerWorkbookSettings;

            m_iTemplateVersion = oPerWorkbookSettings.TemplateVersion;

            m_bHandlingLayoutChanged = false;
            m_iEnableGraphControlsCount = 0;
            m_oEdgeRowIDDictionary = null;
            m_oVertexRowIDDictionary = null;
            m_oSaveGraphImageFileDialog = null;
            m_oDynamicFilterDialog = null;

            GeneralUserSettings oGeneralUserSettings = new GeneralUserSettings();
            LayoutUserSettings oLayoutUserSettings = new LayoutUserSettings();

            LayoutType eInitialLayout = oLayoutUserSettings.Layout;

            // Instantiate an object that populates the sbLayout
            // ToolStripSplitButton and handles its LayoutChanged event.

            m_oLayoutManagerForToolStripSplitButton =
            new LayoutManagerForToolStripSplitButton();

            m_oLayoutManagerForToolStripSplitButton.AddItems(this.sbLayout);
            m_oLayoutManagerForToolStripSplitButton.Layout = eInitialLayout;

            // Instantiate an object that populates the msiContextLayout
            // context menu and handles the Clicked events on the child menu items.

            m_oLayoutManagerForContextMenu = new LayoutManagerForMenu();
            m_oLayoutManagerForContextMenu.AddMenuItems(this.msiContextLayout);
            m_oLayoutManagerForContextMenu.Layout = eInitialLayout;

            m_oLayoutManagerForToolStripSplitButton.LayoutChanged +=
            new EventHandler(this.LayoutManager_LayoutChanged);

            m_oLayoutManagerForContextMenu.LayoutChanged +=
            new EventHandler(this.LayoutManager_LayoutChanged);

            thisWorkbook.VisualAttributeSetInWorkbook +=
            new EventHandler(ThisWorkbook_VisualAttributeSetInWorkbook);

            thisWorkbook.CollapseOrExpandGroups +=
            new CollapseOrExpandGroupsEventHandler(
                ThisWorkbook_CollapseOrExpandGroups);

            thisWorkbook.WorksheetContextMenuManager.RequestVertexCommandEnable +=
            new RequestVertexCommandEnableEventHandler(
                WorksheetContextMenuManager_RequestVertexCommandEnable);

            thisWorkbook.WorksheetContextMenuManager.RequestEdgeCommandEnable +=
            new RequestEdgeCommandEnableEventHandler(
                WorksheetContextMenuManager_RequestEdgeCommandEnable);

            thisWorkbook.WorksheetContextMenuManager.RunVertexCommand +=
            new RunVertexCommandEventHandler(
                WorksheetContextMenuManager_RunVertexCommand);

            thisWorkbook.WorksheetContextMenuManager.RunEdgeCommand +=
            new RunEdgeCommandEventHandler(
                WorksheetContextMenuManager_RunEdgeCommand);

            // There is no Closing event on the TaskPane and no parent form whose
            // Closing event can be handled.  Instead, using the Shutdown event on
            // the workbook to perform closing tasks.

            thisWorkbook.Shutdown += new EventHandler(ThisWorkbook_Shutdown);

            m_oRibbon.Layout = eInitialLayout;

            m_oRibbon.RibbonControlsChanged +=
            new RibbonControlsChangedEventHandler(
                Ribbon_RibbonControlsChanged);

            m_oRibbon.RunRibbonCommand += new RunRibbonCommandEventHandler(
            Ribbon_RunRibbonCommand);

            CreateNodeXLControl(oGeneralUserSettings);
            CreateGraphZoomAndScaleControl();

            oNodeXLControl.GraphScale =
            ( new GraphZoomAndScaleUserSettings() ).GraphScale;

            ApplyGeneralUserSettings(oGeneralUserSettings);
            ApplyLayoutUserSettings(oLayoutUserSettings);

            this.ShowGraphLegend = m_oRibbon.ShowGraphLegend;

            UpdateAutoFillResultsLegend(oPerWorkbookSettings);
            UpdateDynamicFiltersLegend();
            UpdateAxes(oPerWorkbookSettings);

            AssertValid();
        }