public override void OnClick() { IEnvelope extent = (this._context.ActiveView).Extent; double xMin = extent.XMin; double y = extent.YMax + 1.0; IElement element = new JTBElement(); IPoint point = new Point(); point.PutCoords(xMin, y); element.Geometry = point; if (new frmJTBElement { JTBElement = element as IJTBElement }.ShowDialog() == System.Windows.Forms.DialogResult.OK) { IGraphicsContainer graphicsContainer = this._context.ActiveView.GraphicsContainer; graphicsContainer.AddElement(element, 0); ElementOperator.FocusOneElement(graphicsContainer as IActiveView, element); } }
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, ""); } }