public static IList <Element> Parse(string expression) { //TODO we may want to chache the expressions for better performance ParseContext context = new ParseContext(expression); while (context.TokenPosition < expression.Length) { string c = context.Expression.Substring(context.TokenPosition, 1); if (WhiteSpaceRegExp.IsMatch(c)) { context.TokenPosition++; continue; } if (ElementGrouping.Parse(context)) { continue; } else if (ElementTernaryOperator.Parse(context)) { continue; } else if (ElementOperator.Parse(context)) { continue; } else if (ElementLiteral.Parse(context)) { continue; } else if (ElementVariable.Parse(context)) { continue; } else if (ElementSelector.Parse(context)) { continue; } else { throw new ELException("Invalid character at position" + context.TokenPosition); } } Element.ValidateTokenOrder(context, TokenType.End); if (context.BpOrder.Count != 0) { throw new ELException("Not all parentesis or brakets were closed or ? with out :"); } while (context.Stack.Count > 0) { context.Ouput.Push(context.Stack.Pop()); } //reverse order List <Element> result = new List <Element>(context.Ouput); result.Reverse(); return(result); }
public void ForEach(ElementOperator op) { Size sz = GetSize(); for (int row = 0; row < sz.row; ++row) { for (int col = 0; col < sz.column; ++col) { op(ref _grid[row, col]); } } }
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, ""); } }