private void btnOK_Click(object sender, EventArgs e) { if (this.mapGridBorderPropertyPage_0.OutlineSymbol != null) { IElement element = new RectangleElementClass(); IFillSymbol symbol = new SimpleFillSymbolClass { Outline = this.mapGridBorderPropertyPage_0.OutlineSymbol }; (symbol as ISimpleFillSymbol).Style = esriSimpleFillStyle.esriSFSNull; (element as IFillShapeElement).Symbol = symbol; IEnvelope envelope = (this.imapFrame_0 as IElement).Geometry.Envelope; envelope.Expand(1.0, 1.0, false); element.Geometry = envelope; IFrameElement element2 = new FrameElementClass(); (element2 as IElement).Geometry = envelope; IGroupElement group = new GroupElementClass(); this.igraphicsContainer_0.MoveElementToGroup(element, group); this.igraphicsContainer_0.MoveElementToGroup(element2 as IElement, group); this.igraphicsContainer_0.AddElement(group as IElement, 0); } if (this.mapGridBorderPropertyPage_0.IsGenerateGraphics) { this.m_pMapGrid.GenerateGraphics(this.imapFrame_0, this.igraphicsContainer_0); } }
private void btnOK_Click(object sender, EventArgs e) { try { bool flag = false; if (this.chkNewFrameElement.Checked) { IGraphicsContainerSelect select; IEnumElement selectedElements; IGraphicsContainer container; flag = true; IFrameElement element = new FrameElementClass(); IEnvelope printableBounds = null; IElement element2 = null; if (this.rdoPlaceSelectElement.Checked) { select = this.ipageLayout_0 as IGraphicsContainerSelect; selectedElements = select.SelectedElements; selectedElements.Reset(); element2 = selectedElements.Next(); if (element2 == null) { return; } printableBounds = element2.Geometry.Envelope; for (element2 = selectedElements.Next(); element2 != null; element2 = selectedElements.Next()) { printableBounds.Union(element2.Geometry.Envelope); } } else if (this.rdoPlaceAllElement.Checked) { container = this.ipageLayout_0 as IGraphicsContainer; container.Reset(); element2 = container.Next(); if (element2 == null) { return; } printableBounds = element2.Geometry.Envelope; for (element2 = container.Next(); element2 != null; element2 = container.Next()) { printableBounds.Union(element2.Geometry.Envelope); } } else { printableBounds = this.ipageLayout_0.Page.PrintableBounds; } printableBounds.Expand(0.5, 0.5, false); (element as IElement).Geometry = printableBounds; if (this.chkGroup.Checked) { IGroupElement group = new GroupElementClass(); container = this.ipageLayout_0 as IGraphicsContainer; container.MoveElementToGroup(element as IElement, group); select = this.ipageLayout_0 as IGraphicsContainerSelect; selectedElements = null; if (this.rdoPlaceAllElement.Checked) { select.SelectAllElements(); } selectedElements = select.SelectedElements; selectedElements.Reset(); for (element2 = selectedElements.Next(); element2 != null; element2 = selectedElements.Next()) { container.MoveElementToGroup(element2, group); } this.iframeElement_0 = group as IFrameElement; } else { this.iframeElement_0 = element; } } IStyleGalleryItem selectStyleGalleryItem = null; selectStyleGalleryItem = this.cboBorder.GetSelectStyleGalleryItem(); IBorder item = null; if (selectStyleGalleryItem != null) { item = selectStyleGalleryItem.Item as IBorder; (item as IFrameDecoration).HorizontalSpacing = (double)this.txtGap.Value; (item as IFrameDecoration).VerticalSpacing = (double)this.txtGap.Value; (item as IFrameDecoration).CornerRounding = (short)this.txtRound.Value; } IBackground background = null; selectStyleGalleryItem = this.cboBackground.GetSelectStyleGalleryItem(); if (selectStyleGalleryItem != null) { background = selectStyleGalleryItem.Item as IBackground; (background as IFrameDecoration).HorizontalSpacing = (double)this.txtGap.Value; (background as IFrameDecoration).VerticalSpacing = (double)this.txtGap.Value; (background as IFrameDecoration).CornerRounding = (short)this.txtRound.Value; } IShadow shadow = null; selectStyleGalleryItem = this.cboShadow.GetSelectStyleGalleryItem(); if (selectStyleGalleryItem != null) { shadow = selectStyleGalleryItem.Item as IShadow; (shadow as IFrameDecoration).HorizontalSpacing = (double)this.txtGap.Value; (shadow as IFrameDecoration).VerticalSpacing = (double)this.txtGap.Value; (shadow as IFrameDecoration).CornerRounding = (short)this.txtRound.Value; } this.iframeElement_0.Border = item; this.iframeElement_0.Background = background; (this.iframeElement_0 as IFrameProperties).Shadow = shadow; if (flag) { (this.ipageLayout_0 as IGraphicsContainer).AddElement(this.iframeElement_0 as IElement, 0); ElementOperator.FocusOneElement(this.ipageLayout_0 as IActiveView, this.iframeElement_0 as IElement); } } catch (Exception exception) { Logger.Current.Error("", exception, ""); } }