当前位置: 首页>>代码示例>>C#>>正文


C# Element类代码示例

本文整理汇总了C#中Element的典型用法代码示例。如果您正苦于以下问题:C# Element类的具体用法?C# Element怎么用?C# Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Element类属于命名空间,在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TextureAtlas

		/// <summary>
		/// Creates texture atlas from stream.
		/// </summary>
		/// <param name="device"></param>
		public TextureAtlas ( RenderSystem rs, Stream stream, bool useSRgb = false )
		{
			var device = rs.Game.GraphicsDevice;

			using ( var br = new BinaryReader(stream) ) {
			
				br.ExpectFourCC("ATLS", "texture atlas");
				
				int count = br.ReadInt32();
				
				for ( int i=0; i<count; i++ ) {
					var element = new Element();
					element.Index	=	i;
					element.Name	=	br.ReadString();
					element.X		=	br.ReadInt32();
					element.Y		=	br.ReadInt32();
					element.Width	=	br.ReadInt32();
					element.Height	=	br.ReadInt32();

					elements.Add( element );
				}				

				int ddsFileLength	=	br.ReadInt32();
				
				var ddsImageBytes	=	br.ReadBytes( ddsFileLength );

				texture	=	new UserTexture( rs, ddsImageBytes, useSRgb );
			}


			dictionary	=	elements.ToDictionary( e => e.Name );
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:36,代码来源:TextureAtlas.cs

示例2: Serialize

 /// <summary>
 /// Serializes the specified <see cref="Element"/> to XML.
 /// </summary>
 /// <param name="root">
 /// The <c>Element</c> to serialize, including all its children.
 /// </param>
 /// <remarks>
 /// The generated XML will be indented and have a full XML
 /// declaration header.
 /// </remarks>
 /// <exception cref="ArgumentNullException">root is null.</exception>
 public void Serialize(Element root)
 {
     var settings = new XmlWriterSettings();
     settings.Indent = true;
     //settings.NamespaceHandling = NamespaceHandling.OmitDuplicates;
     this.Serialize(root, settings);
 }
开发者ID:shocky,项目名称:MissionPlanner,代码行数:18,代码来源:Serializer.cs

示例3: ExportFooting

        /// <summary>
        /// Exports an element to IFC footing.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="element">
        /// The element.
        /// </param>
        /// <param name="geometryElement">
        /// The geometry element.
        /// </param>
        /// <param name="ifcEnumType">
        /// The string value represents the IFC type.
        /// </param>
        /// <param name="productWrapper">
        /// The IFCProductWrapper.
        /// </param>
        public static void ExportFooting(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement,
           string ifcEnumType, IFCProductWrapper productWrapper)
        {
            // export parts or not
            bool exportParts = PartExporter.CanExportParts(element);
            if (exportParts && !PartExporter.CanExportElementInPartExport(element, element.Level.Id, false))
                return;

            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                using (IFCPlacementSetter setter = IFCPlacementSetter.Create(exporterIFC, element))
                {
                    using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
                    {                      
                        ecData.SetLocalPlacement(setter.GetPlacement());
                      
                        IFCAnyHandle prodRep = null;
                        if (!exportParts)
                        {
                            ElementId catId = CategoryUtil.GetSafeCategoryId(element);

                            BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
                            prodRep = RepresentationUtil.CreateBRepProductDefinitionShape(element.Document.Application, exporterIFC,
                               element, catId, geometryElement, bodyExporterOptions, null, ecData);
                            if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodRep))
                            {
                                ecData.ClearOpenings();
                                return;
                            }
                        }

                        string instanceGUID = ExporterIFCUtils.CreateGUID(element);
                        string origInstanceName = exporterIFC.GetName();
                        string instanceName = NamingUtil.GetNameOverride(element, origInstanceName);
                        string instanceDescription = NamingUtil.GetDescriptionOverride(element, null);
                        string instanceObjectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
                        string instanceElemId = NamingUtil.CreateIFCElementId(element);
                        Toolkit.IFCFootingType footingType = GetIFCFootingType(element, ifcEnumType);

                        IFCAnyHandle footing = IFCInstanceExporter.CreateFooting(file, instanceGUID, exporterIFC.GetOwnerHistoryHandle(),
                            instanceName, instanceDescription, instanceObjectType, ecData.GetLocalPlacement(), prodRep, instanceElemId, footingType);

                        if (exportParts)
                        {
                            PartExporter.ExportHostPart(exporterIFC, element, footing, productWrapper, setter, setter.GetPlacement(), null);
                        }

                        productWrapper.AddElement(footing, setter, ecData, LevelUtil.AssociateElementToLevel(element));

                        OpeningUtil.CreateOpeningsIfNecessary(footing, element, ecData, exporterIFC, ecData.GetLocalPlacement(), setter, productWrapper);

                        PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper);
                    }
                }

                tr.Commit();
            }
        }
开发者ID:whztt07,项目名称:BIM-IFC,代码行数:78,代码来源:FootingExporter.cs

示例4: Calculate

        /// <summary>
        /// Calculates the end hook angle for a rebar.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="extrusionCreationData">The IFCExtrusionCreationData.</param>
        /// <param name="element">The element to calculate the value.</param>
        /// <param name="elementType">The element type.</param>
        /// <returns>
        /// True if the operation succeed, false otherwise.
        /// </returns>
        public override bool Calculate(ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType)
        {
            RebarBendData bendData = null;
            if (element is Rebar)
                bendData = (element as Rebar).GetBendData();
            else if (element is RebarInSystem)
                bendData = (element as RebarInSystem).GetBendData();
            
            if (bendData != null)
            {
                if (bendData.HookLength1 > MathUtil.Eps())
                {
                    ElementId hookAtEndTypeId;
                    if (ParameterUtil.GetElementIdValueFromElement(element, BuiltInParameter.REBAR_ELEM_HOOK_END_TYPE, out hookAtEndTypeId) != null)
                    {
                        RebarHookType rebarHookType = element.Document.GetElement(hookAtEndTypeId) as RebarHookType;
                        if (rebarHookType != null)
                        {
							//HookAngle is measured in radians, so scale directly.
                            m_Angle = rebarHookType.HookAngle *180 / Math.PI;
                            return true;
                        }
                    }
                }
            }
            return false;
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:37,代码来源:ISOCD3766BendingEndHookCalculator.cs

示例5: UpdateVisibility

        public void UpdateVisibility(Element element)
        {
            var mainWindow = MainWindow.MIns;
            if (mainWindow == null)
                return;

            if (element?.GetElementType() == null)
                return;

            switch (element.GetElementType().GetElementType())
            {
                case ElementType.Type.BUILDING_CITYGUARD_HOUSE:
                    EnableCanvas(mainWindow.recruit_cityguard);
                    break;

                case ElementType.Type.BUILDING_MOONGLOW_TOWER:
                    EnableCanvas(mainWindow.recruit_mage);
                    EnableCanvas(mainWindow.recruit_warlock);
                    break;

                case ElementType.Type.BUILDING_STABLE:
                    EnableCanvas(mainWindow.recruit_crossbow);
                    EnableCanvas(mainWindow.recruit_knight);
                    EnableCanvas(mainWindow.recruit_paladin);
                    break;

                case ElementType.Type.BUILDING_TRAINING_GROUND:
                    EnableCanvas(mainWindow.recruit_berserker);
                    EnableCanvas(mainWindow.recruit_guardian);
                    EnableCanvas(mainWindow.recruit_ranger);
                    EnableCanvas(mainWindow.recruit_templar);
                    break;
            }
        }
开发者ID:FelixLeChat,项目名称:LordOfUltima,代码行数:34,代码来源:UnitRecruitmentVisibility.cs

示例6: PathViewModel

        public PathViewModel(RepositoryNavigationRequest request, AbstractTreeNode node)
        {
            Elements = new List<Element>();

            CurrentItem = new Element(
                new RepositoryNavigationRequest(request) { Path = node.Path },
                request.Treeish,
                node);

            var currentNode = node;

            while (currentNode.Parent != null)
            {
                currentNode = currentNode.Parent;
                if (currentNode.Parent != null)
                {
                    Elements.Add(
                        new Element(new RepositoryNavigationRequest(request) { Path = currentNode.Path },
                        request.Treeish,
                        currentNode));
                }
            }

            Elements = new List<Element>(Elements.Reverse());
            Root = new Element(request, request.Treeish, currentNode);
            IsRootEqualToCurrentItem = (currentNode == node);
        }
开发者ID:robertwilczynski,项目名称:GitPrise,代码行数:27,代码来源:PathViewModel.cs

示例7: Calculate

 /// <summary>
 /// Calculates perimeter for a slab.
 /// </summary>
 /// <param name="exporterIFC">
 /// The ExporterIFC object.
 /// </param>
 /// <param name="extrusionCreationData">
 /// The IFCExtrusionCreationData.
 /// </param>
 /// <param name="element">
 /// The element to calculate the value.
 /// </param>
 /// <param name="elementType">
 /// The element type.
 /// </param>
 /// <returns>
 /// True if the operation succeed, false otherwise.
 /// </returns>
 public override bool Calculate(ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType)
 {
     if (extrusionCreationData == null)
         return false;
     m_Perimeter = extrusionCreationData.ScaledOuterPerimeter;
     return m_Perimeter > MathUtil.Eps();
 }
开发者ID:whztt07,项目名称:BIM-IFC,代码行数:25,代码来源:SlabPerimeterCalculator.cs

示例8: MemberAccess

 public MemberAccess(TextPosition tp, Element acs, string member)
     : base(tp)
 {
     Access = acs;
     Member = member;
     AppendChild(Access);
 }
开发者ID:B-head,项目名称:Dreit-prototype,代码行数:7,代码来源:MemberAccess.cs

示例9: BinarySearch

        // Извърша двоично търсене.
        private static int BinarySearch(Element<int>[] elements, int elementToSearch)
        {
            int leftIndex = 0;
            int rightIndex = elements.Length - 1;
            int result = NotFound;
            while (leftIndex <= rightIndex)
            {
                int midIndex = (leftIndex + rightIndex) / 2;
                if (elementToSearch < elements[midIndex].Key)
                {
                    rightIndex = midIndex - 1;
                }
                else if (elementToSearch > elements[midIndex].Key)
                {
                    leftIndex = midIndex + 1;
                }
                else
                {
                    result = midIndex;
                    break;
                }
            }

            return result;
        }
开发者ID:plamenyovchev,项目名称:C-Sharp-Translation-Sources,代码行数:26,代码来源:BinarySearchIterative.cs

示例10: ElementHandle

		public override void ElementHandle(XmppStream stream, Element element, XmppHandlerContext context)
		{
			context.Sender.SendTo(stream, new Compressed());
			var connection = context.Sender.GetXmppConnection(stream.ConnectionId);
			connection.SetStreamTransformer(new GZipTransformer());
			context.Sender.ResetStream(stream);
		}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:7,代码来源:CompressionHandler.cs

示例11: OnTriggerEnter2D

 /// <summary>
 /// Called when the collider associated encounters another collider.
 /// Check if the object encountered is an element, if it is the case, it is put in <see cref="ElementDetected"/>.
 /// </summary>
 /// <param name="other">The collider encountered.</param>
 void OnTriggerEnter2D(Collider2D other)
 {
     Component com = other.gameObject.GetComponent<Element>();
     Element element = com as Element;
     if (element != null)
         ElementDetected = element;
 }
开发者ID:Cedric-Paris,项目名称:PuzzleGameProject,代码行数:12,代码来源:ElementObserver.cs

示例12: CheckArgs

 private void CheckArgs(Jid jid, Element element)
 {
     if (jid == null) throw new ArgumentNullException("jid");
     if (element == null) throw new ArgumentNullException("element");
     if (string.IsNullOrEmpty(element.TagName)) throw new ArgumentNullException("element.TagName");
     if (string.IsNullOrEmpty(element.Namespace)) throw new ArgumentNullException("element.Namespace");
 }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:7,代码来源:DbPrivateStore.cs

示例13: GetPrivate

        public Element GetPrivate(Jid jid, Element element)
        {
            CheckArgs(jid, element);

            var elementStr = ExecuteScalar<string>(new SqlQuery("jabber_private").Select("element").Where("jid", jid.Bare).Where("tag", element.TagName).Where("namespace", element.Namespace));
            return !string.IsNullOrEmpty(elementStr) ? ElementSerializer.DeSerializeElement<Element>(elementStr) : null;
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:7,代码来源:DbPrivateStore.cs

示例14: GetIFCCoveringType

        /// <summary>
        /// Gets IFC covering type for an element.
        /// </summary>
        /// <param name="element">
        /// The element.
        /// </param>
        /// <param name="typeName">
        /// The type name.
        /// </param>
        public static Toolkit.IFCCoveringType GetIFCCoveringType(Element element, string typeName)
        {
            string value = null;
            if (!ParameterUtil.GetStringValueFromElementOrSymbol(element, "IfcType", out value))
            {
                value = typeName;
            }
            if (String.IsNullOrEmpty(value))
                return Toolkit.IFCCoveringType.NotDefined;

            string newValue = NamingUtil.RemoveSpacesAndUnderscores(value);

            if (String.Compare(newValue, "USERDEFINED", true) == 0)
                return Toolkit.IFCCoveringType.UserDefined;
            if (String.Compare(newValue, "CEILING", true) == 0)
                return Toolkit.IFCCoveringType.Ceiling;
            if (String.Compare(newValue, "FLOORING", true) == 0)
                return Toolkit.IFCCoveringType.Flooring;
            if (String.Compare(newValue, "CLADDING", true) == 0)
                return Toolkit.IFCCoveringType.Cladding;
            if (String.Compare(newValue, "ROOFING", true) == 0)
                return Toolkit.IFCCoveringType.Roofing;
            if (String.Compare(newValue, "INSULATION", true) == 0)
                return Toolkit.IFCCoveringType.Insulation;
            if (String.Compare(newValue, "MEMBRANE", true) == 0)
                return Toolkit.IFCCoveringType.Membrane;
            if (String.Compare(newValue, "SLEEVING", true) == 0)
                return Toolkit.IFCCoveringType.Sleeving;
            if (String.Compare(newValue, "WRAPPING", true) == 0)
                return Toolkit.IFCCoveringType.Wrapping;

            return Toolkit.IFCCoveringType.NotDefined;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:42,代码来源:CeilingExporter.cs

示例15: AddResource

        public void AddResource(Element element)
        {
            locker.EnterWriteLock();
            try
            {
                CreateDir();
                string filePath = Path.Combine(this.path, ResXResourceFileHelper.GetFileName(element.Category, element.Culture));
                XDocument document = GetResxDocument(filePath);

                if (document == null)
                {
                    document = CreateResXDocument();
                }
                var exists = document.Root.Elements("data")
                   .FirstOrDefault(d => d.Attribute("name").Value == element.Name);
                if (exists == null)
                {
                    document.Root.Add(
                    new XElement("data",
                        new XAttribute("name", element.Name),
                        new XAttribute(XNamespace.Xml + "space", "preserve"),
                        new XElement("value", element.Value)));
                    document.Save(filePath);
                }
            }
            finally
            {
                locker.ExitWriteLock();
            }
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:30,代码来源:ResXResource.cs


注:本文中的Element类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。