Esempio n. 1
0
        public ElementCollection CreateHierarchy()
        {
            ElementCollection result = new ElementCollection();

            for (int index = 0; index < elements.Count; index++)
            {
                Element element = elements[index];

                if (element is Entity.Text)
                    result.Add(element);
                else if (element is Expression)
                    result.Add(element);
                else if (element is Tag)
                {
                    result.Add(CollectForTag((Tag) element, ref index));
                }
                else if (element is TagClose)
                {
                    throw new ParseException("Close tag for " + ((TagClose) element).Name + " doesn't have matching start tag.", element.Line, element.Col);
                }
                else
                    throw new ParseException("Invalid element: " + element.GetType().ToString(), element.Line, element.Col);
            }

            return result;
        }
Esempio n. 2
0
            public void RaisesCollectionChangedEvent()
            {
                var collection = new ElementCollection <Axis>(new PlotModel());

                collection.Add(new LinearAxis());
                collection.Add(new LinearAxis());
                collection.Add(new LinearAxis());

                ElementCollectionChangedEventArgs <Axis> eventArgs = null;
                var raisedCount = 0;

                collection.CollectionChanged += (sender, e) =>
                {
                    eventArgs = e;
                    raisedCount++;
                };

                var axis = new LinearAxis();

                collection.Insert(1, axis);

                Assert.AreEqual(1, raisedCount);
                Assert.AreEqual(1, eventArgs.AddedItems.Count);
                Assert.IsTrue(ReferenceEquals(axis, eventArgs.AddedItems[0]));
            }
Esempio n. 3
0
 public void AddElement(BaseElement element)
 {
     if (element.Id == 0)
     {
         element.Id = FictitiousIdHelper.NextId;
     }
     _elements.Add(element);
     element.AppearanceChanged += ElementAppearanceChanged;
     OnAppearancePropertyChanged(new EventArgs());
 }
Esempio n. 4
0
        public void AttachToChart(ElementCollection <Series> chart)
        {
            if (AreSeriesAttached || chart == null)
            {
                return;
            }

            chart.Add(mainSeries);
            foreach (var s in scatterSeries)
            {
                chart.Add(s);
            }
            AreSeriesAttached = true;
        }
Esempio n. 5
0
        void draw(DataTable Count)
        {
            try { chart.Dispose(); }
            catch { }


            chart       = new Chart();
            chart.Use3D = true;
            chart.Dock  = DockStyle.Fill;
            chart.Type  = ChartType.Combo;
            foreach (DataRow dr in Count.Rows)
            {
                Element element = new Element(dr["Month"].ToString(), float.Parse(dr["Missions Number"].ToString()));
                element.Annotation = new Annotation(dr["Missions Number"].ToString());
                ElementCollection eCollection = new ElementCollection();
                eCollection.Add(element);
                Series serie = new Series(dr["Month"].ToString(), eCollection);
                chart.SeriesCollection.Add(serie);
            }
            Form d = new Form();

            d.WindowState = FormWindowState.Maximized;
            chart.Dock    = DockStyle.Fill;
            d.Controls.Add(chart);
            d.Show();
        }
Esempio n. 6
0
        public override ElementCollection EnterElements(string prompt = "Enter elements")
        {
            GetObject gO = new GetObject();

            gO.SetCustomGeometryFilter(new GetObjectGeometryFilter(FilterHandles));
            //gO.GeometryFilter = ObjectType.Curve;
            gO.SetCommandPrompt(prompt);
            if (gO.GetMultiple(1, 0) == GetResult.Cancel)
            {
                throw new OperationCanceledException("Operation cancelled by user");
            }
            var result = new ElementCollection();

            foreach (ObjRef rObj in gO.Objects())
            {
                if (Host.Instance.Handles.Links.ContainsSecond(rObj.ObjectId))
                {
                    Guid guid = Host.Instance.Handles.Links.GetFirst(rObj.ObjectId);

                    ElementTable elementTable = Core.Instance.ActiveDocument?.Model?.Elements;
                    if (elementTable != null && elementTable.Contains(guid))
                    {
                        Element element = Core.Instance.ActiveDocument?.Model?.Elements[guid];
                        if (element != null)
                        {
                            result.Add(element);
                        }
                    }
                }
            }
            return(result);
        }
Esempio n. 7
0
 public static ElementCollection <T> AddRange <T>(this ElementCollection <T> source, IEnumerable <T> collectionToAdd) where T : Element
 {
     foreach (var item in collectionToAdd)
     {
         source.Add(item);
     }
     return(source);
 }
Esempio n. 8
0
        public override bool Execute(ExecutionInfo exInfo = null)
        {
            Elements = new ElementCollection();

            if (Geometry != null)
            {
                // Convert each geometry item:
                foreach (VertexGeometry shape in Geometry)
                {
                    if (shape is Curve) // Convert to linear element
                    {
                        LinearElement element = Model.Create.LinearElement((Curve)shape, exInfo);
                        if (FamiliesFromLayers && shape.Attributes != null && !string.IsNullOrWhiteSpace(shape.Attributes.LayerName))
                        {
                            string        layerName = shape.Attributes.LayerName;
                            SectionFamily sF        = Model.Families.Sections.FindByName(layerName);
                            if (sF == null)
                            {
                                sF = Model.Create.SectionFamily(layerName, exInfo);
                            }
                            element.Family = sF;
                        }
                        Elements.Add(element);
                    }
                    else if (shape is Surface) //Reminder: Meshes are also surfaces!
                    {
                        PanelElement element = Model.Create.PanelElement((Surface)shape, exInfo);
                        if (FamiliesFromLayers && shape.Attributes != null && !string.IsNullOrWhiteSpace(shape.Attributes.LayerName))
                        {
                            string        layerName = shape.Attributes.LayerName;
                            BuildUpFamily fF        = Model.Families.PanelFamilies.FindByName(layerName);
                            if (fF == null)
                            {
                                fF = Model.Create.BuildUpFamily(layerName, exInfo);
                            }
                            element.Family = fF;
                        }
                        Elements.Add(element);
                    }
                }
                Elements.GenerateNodes(new NodeGenerationParameters());
                return(true);
            }
            return(false);
        }
Esempio n. 9
0
        private void AddElements(List <ElementViewModel> cards)
        {
            ElementCollection _elements = (ElementCollection)this.Resources["elements"];

            _elements.Clear();
            foreach (var card in cards)
            {
                _elements.Add(card);
            }
        }
Esempio n. 10
0
        private async void ButtonAddProfile_Click(object sender, RoutedEventArgs e)
        {
            var dialog       = new ProfileDialog();
            var dialogResult = await dialog.ShowAsync();

            if (dialogResult == ContentDialogResult.Primary)
            {
                var profile = dialog.Result;
                if (profile != null)
                {
                    var existingElement = ProfileExists(profile);
                    if (existingElement != null)
                    {
                        var yesNoDialog = new YesNoDialog("Profil bereits vorhanden",
                                                          string.Format("Das Profil mit der Profilnummer '{0:s}', einer Länge von '{1:s}' und der Farbe '{2:s}' ist bereits vorhanden. " +
                                                                        "Soll das vorhandene Profil geändert werden?", profile.ProfileNumber, profile.Length, profile.Surface));
                        await yesNoDialog.ShowAsync();

                        if (yesNoDialog.Result == YesNoDialogType.Yes)
                        {
                            existingElement.Count  += profile.Count;
                            existingElement.Amount += profile.Amount;
                            await UpdateProfile(existingElement);
                        }

                        return;
                    }

                    if (PlantOrder != null)
                    {
                        profile.PlantOrderId = PlantOrder.Id;
                    }

                    if (FileEntry != null)
                    {
                        profile.Filename = FileEntry.Name;
                    }

                    var profileId = await Proxy.CreateProfile(profile);

                    if (profileId > 0)
                    {
                        profile.ProfileId = profileId;
                        var element = AutoMapperConfiguration.Map(profile);
                        ElementCollection.Add(element);
                    }
                    else
                    {
                        var errorDialog = new InfoDialog("Beim Anlegen des Profil's ist ein Fehler aufgetreten!", "Information", InfoDialogType.Error);
                        await errorDialog.ShowAsync();
                    }
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Implements INotifyElementAdded.ElementAdded. Elements will
        /// be added if the ModelElement has a type matching TElement
        /// type parameter
        /// </summary>
        /// <param name="element">The element to add</param>
        protected void ElementAdded(ModelElement element)
        {
            TElement typedElement = element as TElement;

            if (typedElement != null)
            {
                if (VerifyElementType(element))
                {
                    ElementCollection.Add(typedElement);
                }
            }
        }
Esempio n. 12
0
        public virtual ElementCollection GetLinkedNodes()
        {
            var ec = new ElementCollection();

            foreach (var ce in Connects)
            {
                foreach (BaseLinkElement le in ce.Links)
                {
                    ec.Add(le.Connector1 == ce ? le.Connector2.ParentElement : le.Connector1.ParentElement);
                }
            }
            return(ec);
        }
Esempio n. 13
0
        /// <overloads/>
        /// <summary>
        /// Returns the direct descendent children elements, including text nodes.
        /// </summary>
        /// <remarks>
        /// This method returns text portions as <see cref="TextNodeElement"/> objects.
        /// </remarks>
        /// <param name="includeTextNodes">If <c>True</c> the collection will include text parts as <see cref="TextNodeElement"/> objects.</param>
        /// <returns></returns>
        public ElementCollection GetChildNodes(bool includeTextNodes)
        {
            Interop.IHTMLDOMChildrenCollection children = (Interop.IHTMLDOMChildrenCollection)node.childNodes;
            ElementCollection ec = new ElementCollection();
            int length           = children.length;

            for (int i = 0; i < length; i++)
            {
                Interop.IHTMLDOMNode element = children.item(i) as Interop.IHTMLDOMNode;
                if (element != null && element != node)
                {
                    if (element.nodeName.Equals("#text"))
                    {
                        ec.Add(new TextNodeElement(element, this.htmlEditor));
                    }
                    else
                    {
                        ec.Add(this.htmlEditor.GenericElementFactory.CreateElement(element as Interop.IHTMLElement));
                    }
                }
            }
            return(ec);
        }
Esempio n. 14
0
        /// <summary>
        /// Get all linear elements in the specified model which have a mapping entry in this table
        /// </summary>
        /// <param name="inModel"></param>
        /// <returns></returns>
        public ElementCollection AllMappedPanelElements(Model.Model inModel)
        {
            var result = new ElementCollection();

            if (ContainsKey(PanelCategory))
            {
                foreach (Guid guid in this[PanelCategory].Keys)
                {
                    if (inModel.Elements.Contains(guid))
                    {
                        result.Add(inModel.Elements[guid]);
                    }
                }
            }
            return(result);
        }
Esempio n. 15
0
        public void AddZ_LastWins_Moves_To_Last_Element()
        {
            var time0    = new ElementCollection(); time0.xtor();
            var element0 = new Element {
                ScheduleStyle = ElementScheduleStyle.LastWins
            };                                                                            //(MockElement.LastWins);

            time0.Add(element0, 0);
            //
            var time1    = new ElementCollection(); time1.xtor();
            var element1 = new Element {
                ScheduleStyle = ElementScheduleStyle.LastWins
            };                                                                            //(MockElement.LastWins);

            time1.Add(element1, 0);

            Assert.AreEqual(time0.GetCount(), 0);
            Assert.AreEqual(time1.GetCount(), 1);
        }
Esempio n. 16
0
        public void AddZ_Multiple_Keeps_All_Elements()
        {
            var time0    = new ElementCollection(); time0.xtor();
            var element0 = new Element {
                ScheduleStyle = ElementScheduleStyle.Multiple
            };                                                                            //(MockElement.Multiple);

            time0.Add(element0, 0);
            //
            var time1    = new ElementCollection(); time1.xtor();
            var element1 = new Element {
                ScheduleStyle = ElementScheduleStyle.Multiple
            };                                                                            //(MockElement.Multiple);

            time1.Add(element1, 0);

            Assert.AreEqual(time0.GetCount(), 1);
            Assert.AreEqual(time1.GetCount(), 1);
        }
            public void RaisesCollectionChangedEvent()
            {
                var collection = new ElementCollection<Axis>(new PlotModel());

                ElementCollectionChangedEventArgs<Axis> eventArgs = null;
                var raisedCount = 0;

                collection.CollectionChanged += (sender, e) =>
                {
                    eventArgs = e;
                    raisedCount++;
                };

                var axis = new LinearAxis();
                collection.Add(axis);

                Assert.AreEqual(1, raisedCount);
                Assert.AreEqual(1, eventArgs.AddedItems.Count);
                Assert.IsTrue(ReferenceEquals(axis, eventArgs.AddedItems[0]));
            }
Esempio n. 18
0
 public void AddToCollection(IEnumerable <IfElement> ifElements)
 {
     foreach (var item in ifElements)
     {
         int       index;
         IfElement E = CheckElement(item);
         if (E != null)
         {
             index = ElementCollection.IndexOf(E);
             DataRow DR = BOQTable.Rows[index];
             DR.SetField <int>("Number", DR.Field <int>("Number") + 1);
             NumberOfElements[index]++;
         }
         else
         {
             BOQTable.Rows.Add(item.ToString(), 1);
             ElementCollection.Add(item);
             NumberOfElements.Add(1);
         }
     }
 }
Esempio n. 19
0
        private void SetupElements(bool addToCollection)
        {
            if (RowPresenter == null || ElementCollection == null)
            {
                return;
            }

            var rowBindings = RowBindings;

            BeginSetup(rowBindings, addToCollection ? null : Elements);

            for (int i = 0; i < rowBindings.Count; i++)
            {
                var rowBinding = rowBindings[i];
                var element    = rowBinding.Setup(RowPresenter);
                if (addToCollection)
                {
                    ElementCollection.Add(element);
                }
            }
            rowBindings.EndSetup();
        }
        public static bool HandleATMCreateJob(string jobName, ElementCollection elements)
        {
            var excludeList = new List <string>
            {
                "BI_Warehousing_TeamPerformanceTotals",
                "CAF Reject Hist",
                "Chip Card Status Update",
                "PostCard Full Extract",
                "Postilion - HotCard File Creation",
                "Postilion Office - Copy Card and Account Data",
                "sqlops_ActivityDB_Backup_Dbs_ATM_Woodforest"
            };

            if (!excludeList.Contains(jobName))
            {
                return(false);
            }

            elements.Add(jobName.Equals(@"sqlops_ActivityDB_Backup_Dbs_ATM_Woodforest")
                ? new JobDependency($@"\{ConversionBaseHelper.JamsArchonRootFolder}\ATM Create CAF and PBF - Weekend")
                : new JobDependency($@"\{ConversionBaseHelper.JamsArchonRootFolder}\ATM Create CAF and PBF"));

            return(true);
        }
Esempio n. 21
0
        private void AddElement(BlockBinding blockBinding)
        {
            var element = blockBinding.Setup(this);

            ElementCollection.Add(element);
        }
Esempio n. 22
0
        /// <summary>
        /// 根据标签名获取所有同标签名的子元素标签
        /// </summary>
        /// <param name="tagName"></param>
        /// <returns></returns>
        public virtual ElementCollection<Tag> GetChildTagsByTagName(string tagName)
        {
            if (string.IsNullOrEmpty(tagName)) throw new ArgumentNullException("tagName");

            ElementCollection<Tag> tags = new ElementCollection<Tag>();
            //搜索当前元素下的子元素
            foreach (Element item in this.InnerElements)
            {
                if (item is Tag)
                {
                    Tag tag = (Tag)item;
                    if (tagName.Equals(tag.TagName, StringComparison.InvariantCultureIgnoreCase)) tags.Add(tag);

                    //处理其下子元素
                    tags.AddRange(tag.GetChildTagsByTagName(tagName));
                }
            }
            return tags;
        }
Esempio n. 23
0
        /// <summary>
        /// 获取所有具有同名称的模板列表.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public ElementCollection<Template> GetChildTemplatesByName(string name)
        {
            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name");

            ElementCollection<Template> items = new ElementCollection<Template>();
            foreach (Template template in TagContainer.ChildTemplates)
            {
                if (name.Equals(template.Name, StringComparison.InvariantCultureIgnoreCase))
                {
                    items.Add(template);
                }
                items.AddRange(template.GetChildTemplatesByName(name));
            }
            return items;
        }
Esempio n. 24
0
 protected override void CloneOverride ([NotNull] BindableObject obj)
 {
     var source = (Element)obj;
     base.CloneOverride(source);
     if (HasChildren) {
         _children = new ElementCollection(source);
         foreach (Element child in source._children) {
             var childClone = (Element)child.Clone();
             childClone.DataContext = null;
             _children.Add(childClone);
         }
     }
 }