static public ShapeTemplate GetShapeTemplate(GraphicStencil stencil) { int i; if (stencil != null) { ElementTemplate[] elementTemplate = new ElementTemplate[stencil.Elements.Count]; i = 0; foreach (Element element in stencil.Elements) { elementTemplate[i] = Element(element); i++; } ElementTemplate[] decorationTemplate = new ElementTemplate[stencil.Decorations.Count]; i = 0; foreach (Element decoration in stencil.Decorations) { decorationTemplate[i] = Element(decoration); i++; } return(new ShapeTemplate(elementTemplate, decorationTemplate, null, stencil.fillMode, stencil.Tag)); } else { return(null); } }
private ShapeTemplate GetShapeTemplate(SysCAD.Protocol.ModelStencil stencil) { int i; if (stencil != null) { ElementTemplate[] elementTemplate = new ElementTemplate[stencil.Elements.Count]; i = 0; foreach (Element element in stencil.Elements) { elementTemplate[i] = Element(element); i++; } ElementTemplate[] decorationTemplate = new ElementTemplate[stencil.Decorations.Count]; i = 0; foreach (Element decoration in stencil.Decorations) { decorationTemplate[i] = Element(decoration); i++; } return(new ShapeTemplate(elementTemplate, decorationTemplate, null, System.Drawing.Drawing2D.FillMode.Alternate, stencil.Tag)); } else { return(null); } }
/// <summary> /// TODO /// </summary> private void DGrid_OnLoadingRowDetails(object?sender, DataGridRowDetailsEventArgs e) { ElementTemplate element = e.Row.Item as ElementTemplate; if (element.MadeOf == null) { e.Row.DetailsVisibility = Visibility.Collapsed; } }
object CreateContent() { if (ElementTemplate == null) { return(null); } var o = ElementTemplate.CreateContent(); return(o); }
static Cell RealizeItemTemplate(ITemplatedItemsList <Cell> templatedItems, ElementTemplate template, object context) { var index = templatedItems.GetGlobalIndexOfItem(context); if (index > -1) { return(templatedItems[index]); } return(template.CreateContent() as Cell); }
static Cell RealizeGroupedHeaderTemplate(TemplatedItemsList <ItemsView <Cell>, Cell> templatedItems, ElementTemplate template, object context) { var index = templatedItems.GetGlobalIndexOfGroup(context); if (index > -1) { return(templatedItems[index]); } return(template.CreateContent() as Cell); }
/// <summary> /// Transform <see cref="Product"/> and <see cref="Material"/> into <see cref="ElementTemplate"/> /// </summary> /// <returns>Return a list of <see cref="ElementTemplate"/> based on products and materials</returns> private List <ElementTemplate> Convert() { List <ElementTemplate> elements = new List <ElementTemplate>(); if (((ComboBoxItem)CurrentPage.FilterbyComboBox.SelectedItem).Content.Equals("Construction materials") || ((ComboBoxItem)CurrentPage.FilterbyComboBox.SelectedItem).Content.Equals("All")) { foreach (var material in Materials) { ElementTemplate element = new ElementTemplate { Label = material.Label, PriceString = material.Price + " €", Quantity = material.Quantity }; elements.Add(element); } } if (((ComboBoxItem)CurrentPage.FilterbyComboBox.SelectedItem).Content.Equals("Final products") || ((ComboBoxItem)CurrentPage.FilterbyComboBox.SelectedItem).Content.Equals("All")) { foreach (var product in Products) { var listMadeOf = new List <NeededProductTemplate>(); foreach (var matprod in MaterialsProducts) { if (matprod.IdProduct == product.Id) { var label = Materials.First(x => x.Id == matprod.IdMaterial).Label; var quantity = matprod.QuantityNeeded; listMadeOf.Add(new NeededProductTemplate { Material = label, QuantityNeeded = quantity }); } } ElementTemplate element = new ElementTemplate { Label = product.Label, PriceString = $"{product.Price:C}", Quantity = product.Quantity, AvailableUntilString = $"⚠ Product available until : {product.AvailableUntil:D} ⚠", ColorDate = product.AvailableUntil >= DateTime.Today ? Brushes.Lime : Brushes.Red, MadeOf = listMadeOf }; elements.Add(element); } } return(elements); }
static Cell RealizeGroupedItemTemplate(ITemplatedItemsList <Cell> templatedItems, ElementTemplate template, object context) { var indices = templatedItems.GetGroupAndIndexOfItem(context); if (indices.Item1 > -1 && indices.Item2 > -1) { var group = templatedItems.GetGroup(indices.Item1); return(group[indices.Item2]); } return(template.CreateContent() as Cell); }
/// <summary> /// 서로 호환 가능 여부를 반환합니다. /// </summary> /// <param name="other">비교할 필드</param> /// <returns>True, 호환 가능 시</returns> public bool IsCompatibleWith(Field other) { if (Type != other.Type) { return(false); } //if (Type == FieldType.Ref && !DirectsSameRefenceTarget(other)) //{ // return false; //} //else if (Type == FieldType.Schema && !DirectsSameRefenceTarget(other)) { return(false); } else if (Type == FieldType.List) { if (ElementTemplate == null || other.ElementTemplate == null) { return(false); } if (ElementCount != other.ElementCount) { return(false); } if (!ElementTemplate.IsCompatibleWith(ElementTemplate)) { return(false); } } if (AutoIncrement != other.AutoIncrement || Unique != other.Unique || NonSerialized != other.NonSerialized || Nullable != other.Nullable) { return(false); } if (!Groups.SequenceEqual(other.Groups) || !DisableTags.SequenceEqual(other.DisableTags) || !CompositKeys.SequenceEqual(other.CompositKeys)) { return(false); } return(true); }
private ElementTemplate AddElement(ElementProxy el) { var position = new Point(); el.Position = position; var et = new ElementTemplate(el); et.MouseDown += Rectangle_MouseDown; et.MouseMove += Rectangle_MouseMove; et.MouseUp += Rectangle_MouseUp; SchemeCanvas.Children.Add(et); et.WantsToBeDeleted += DeleteElement; et.AddOperation += AddNewOperation; return(et); }
void SetTemplate(ElementTemplate dt, INode node) { dt.LoadTemplate = () => { var cnode = node.Clone(); var context = new HydrationContext { ParentContext = Context, RootAssembly = Context.RootAssembly, RootElement = Context.RootElement, ExceptionHandler = Context.ExceptionHandler }; cnode.Accept(new XamlNodeVisitor((n, parent) => n.Parent = parent), node.Parent); //set parents for {StaticResource} cnode.Accept(new ExpandMarkupsVisitor(context), null); cnode.Accept(new NamescopingVisitor(context), null); cnode.Accept(new CreateValuesVisitor(context), null); cnode.Accept(new RegisterXNamesVisitor(context), null); cnode.Accept(new FillResourceDictionariesVisitor(context), null); cnode.Accept(new ApplyPropertiesVisitor(context, true), null); return(context.Values[cnode]); }; }
void SetTemplate(ElementTemplate dt, INode node) { #pragma warning disable 0612 ((IDataTemplate)dt).LoadTemplate = () => { #pragma warning restore 0612 var context = new HydratationContext { ParentContext = Context, RootElement = Context.RootElement }; node.Accept(new ExpandMarkupsVisitor(context), null); node.Accept(new NamescopingVisitor(context), null); node.Accept(new CreateValuesVisitor(context), null); node.Accept(new RegisterXNamesVisitor(context), null); node.Accept(new FillResourceDictionariesVisitor(context), null); node.Accept(new ApplyPropertiesVisitor(context, true), null); return(context.Values[node]); }; }
void SetTemplate(ElementTemplate dt, INode node) { #pragma warning disable 0612 ((IDataTemplate)dt).LoadTemplate = () => { #pragma warning restore 0612 var cnode = node.Clone(); var context = new HydrationContext { ParentContext = Context, RootElement = Context.RootElement }; cnode.Accept(new XamlNodeVisitor((n, parent) => n.Parent = parent), node.Parent); //set parents for {StaticResource} cnode.Accept(new ExpandMarkupsVisitor(context), null); cnode.Accept(new NamescopingVisitor(context), null); cnode.Accept(new CreateValuesVisitor(context), null); cnode.Accept(new RegisterXNamesVisitor(context), null); cnode.Accept(new FillResourceDictionariesVisitor(context), null); cnode.Accept(new ApplyPropertiesVisitor(context, true), null); return(context.Values [cnode]); }; }
public ShapeTemplate CreateShapeTemplate() { int count = 0; ArrayList alDecorations = new ArrayList(); RectangleF rect = getBoundingRect(); ElementTemplate[] etContour = null; ElementTemplate[] etTextArea = null; ElementTemplate[] etDecorations = null; etContour = ((Outline)outLines[0]).getElements(rect); for (int i = 1; i < outLines.Count; ++i) { Outline outLine = (Outline)outLines[i]; if (outLine is Contour) { etTextArea = outLine.getElements(rect); } else { etDecorations = outLine.getElements(rect); alDecorations.Add(etDecorations); count += etDecorations.Length; } } ElementTemplate[] allDecorations = new ElementTemplate[count]; count = 0; foreach (ElementTemplate[] eta in alDecorations) { eta.CopyTo(allDecorations, count); count += eta.Length; } return(new ShapeTemplate(etContour, allDecorations, etTextArea, System.Drawing.Drawing2D.FillMode.Winding, "test")); }
void SetTemplate(ElementTemplate dt, INode node) { #pragma warning disable 0612 ((IDataTemplate)dt).LoadTemplate = () => { #pragma warning restore 0612 var context = new HydratationContext { ParentContext = Context, RootElement = Context.RootElement }; node.Accept(new ExpandMarkupsVisitor(context), null); node.Accept(new NamescopingVisitor(context), null); node.Accept(new CreateValuesVisitor(context), null); node.Accept(new RegisterXNamesVisitor(context), null); node.Accept(new FillResourceDictionariesVisitor(context), null); node.Accept(new ApplyPropertiesVisitor(context, true), null); return context.Values[node]; }; }