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


C# Primitive.ToString方法代码示例

本文整理汇总了C#中Primitive.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Primitive.ToString方法的具体用法?C# Primitive.ToString怎么用?C# Primitive.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Primitive的用法示例。


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

示例1: ChangePrimitive

		public override void ChangePrimitive(Primitive primitive)
		{
			// Load sphere and apply effect to sphere.
			ResourceContentManager resourceContentManager = new ResourceContentManager(_serviceProvider, Resources.ResourceManager);
			Model model = resourceContentManager.Load<Model>(primitive.ToString());
			foreach (ModelMesh mesh in model.Meshes)
				foreach (ModelMeshPart meshPart in mesh.MeshParts)
					meshPart.Effect = _effect;
			Model = model;
		}
开发者ID:modulexcite,项目名称:xbuilder,代码行数:10,代码来源:EffectRenderer.cs

示例2: Search

 /// <summary>
 /// Obtain an array of the indices that have values that contain searchstring.
 /// The search is case in-sensitive.
 /// The input array is unchanged and the match array must be previously created with the same size as the array to check.
 /// </summary>
 /// <param name="array">The array to check for matches.</param>
 /// <param name="searchstring">The string to search for.</param>
 /// <param name="match">An array to hold the index of matched values.</param>
 /// <returns>The number of matches found.
 /// </returns>
 public static Primitive Search(Primitive array, Primitive searchstring, Primitive match)
 {
     try
     {
         Array _array = getArray(array);
         Array _match = getArray(match);
         if (null == _array || null == _match) return 0;
         if (_array.maxNumber != _match.maxNumber) return 0;
         int i, count = 0;
         string searchLower = searchstring.ToString().ToLower();
         for (i = 0; i < _array.maxNumber; i++)
         {
             if (_array.array[i].ToLower().Contains(searchLower))
             {
                 _match.array[count++] = (i + 1).ToString();
             }
         }
         for (i = count; i < _array.maxNumber; i++)
         {
             _match.array[i] = "";
         }
         return count;
     }
     catch (Exception ex)
     {
         Utilities.OnError(Utilities.GetCurrentMethod(), ex);
         return 0;
     }
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:39,代码来源:Array.cs

示例3: SetProperty

        public void SetProperty(Primitive objectPath, Primitive value)
        {
            string[] objectList = objectPath.ToString().Split(new char[] { '.' });
            string objectValue = value;

            try
            {
                InvokeHelper invokeHelper = delegate
                {
                    try
                    {
                        Object obj = null;
                        foreach (string key in objectList)
                        {
                            if (key == objectList.First())
                            {
                                obj = (Object)GetType("GraphicsWindow").GetField(key, BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
                                continue;
                            }
                            if (null == obj || key == objectList.Last()) break;
                            if (obj is IEnumerable && !Utilities.isBulitin(obj))
                            {
                                bool bFound = false;
                                foreach (Object objChild in (obj as IEnumerable))
                                {
                                    if (objChild.GetType().GetProperty("Name").GetValue(objChild, null).ToString() == key)
                                    {
                                        obj = objChild;
                                        bFound = true;
                                        break;
                                    }
                                }
                                if (!bFound) return;
                            }
                            else
                            {
                                obj = obj.GetType().GetProperty(key).GetValue(obj, null);
                            }
                        }

                        if (null == obj) return;

                        Object propObject = obj.GetType().GetProperty(objectList.Last()).GetValue(obj, null);
                        Type propType = propObject.GetType();
                        TypeConverter typeConverter = TypeDescriptor.GetConverter(propType);
                        Object propValue = typeConverter.ConvertFromString(objectValue);
                        obj.GetType().GetProperty(objectList.Last()).SetValue(obj, propValue, null);
                    }
                    catch (Exception ex)
                    {
                        Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                    }
                };

                mInvoke.Invoke(null, new object[] { invokeHelper });
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
            }
        }
开发者ID:litdev1,项目名称:LitDev,代码行数:61,代码来源:FormPropertyGrid.cs

示例4: GetProperty

        public string GetProperty(Primitive objectPath)
        {
            string[] objectList = objectPath.ToString().Split(new char[] { '.' });

            try
            {
                InvokeHelperWithReturn ret = new InvokeHelperWithReturn(delegate
                {
                    try
                    {
                        Object obj = null;
                        foreach (string key in objectList)
                        {
                            if (key == objectList.First())
                            {
                                obj = (Object)GetType("GraphicsWindow").GetField(key, BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
                                continue;
                            }
                            if (null == obj || key == objectList.Last()) break;
                            if (obj is IEnumerable && !Utilities.isBulitin(obj))
                            {
                                bool bFound = false;
                                foreach (Object objChild in (obj as IEnumerable))
                                {
                                    if (objChild.GetType().GetProperty("Name").GetValue(objChild, null).ToString() == key)
                                    {
                                        obj = objChild;
                                        bFound = true;
                                        break;
                                    }
                                }
                                if (!bFound) return "";
                            }
                            else
                            {
                                obj = obj.GetType().GetProperty(key).GetValue(obj, null);
                            }
                        }

                        if (null == obj) return "";

                        Object propObject = obj.GetType().GetProperty(objectList.Last()).GetValue(obj, null);
                        return propObject.ToString();
                    }
                    catch (Exception ex)
                    {
                        Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                    }
                    return "";
                });

                return mInvokeWithReturn.Invoke(null, new object[] { ret }).ToString();
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
            }
            return "";
        }
开发者ID:litdev1,项目名称:LitDev,代码行数:59,代码来源:FormPropertyGrid.cs

示例5: StartWithStartInfo

        /// <summary>
        /// Starts a process with start info
        /// </summary>
        /// <param name="fileName">The full file path of the program to start</param>
        /// <param name="windowStyle">Specify the window style as hidden, maximized or minimized.
        /// Use "" to specify normal.</param>
        /// <param name="args">Specify arguments for the process. Use "" to specify nothing.</param>
        ///<returns>The name of the process.</returns>
        /// <example>XApp.StartWithStartInfo("IExplore.exe", "maximized", "www.getjibba.com")</example>
        public static Primitive StartWithStartInfo(Primitive fileName, Primitive windowStyle, Primitive args)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo(fileName);

            if (windowStyle.ToString().ToLower() == "hidden")
                startInfo.WindowStyle = ProcessWindowStyle.Hidden;

            else if (windowStyle.ToString().ToLower() == "maximized")
                startInfo.WindowStyle = ProcessWindowStyle.Maximized;

            else if (windowStyle.ToString().ToLower() == "minimized")
                startInfo.WindowStyle = ProcessWindowStyle.Minimized;
            else
                startInfo.WindowStyle = ProcessWindowStyle.Normal;

            if (args != "")
            {
                startInfo.Arguments = args;
                myProcess = Process.Start(startInfo).ToString();
            }
            else
            {
                myProcess = Process.Start(startInfo).ToString();
            }

            return myProcess;
        }
开发者ID:RichardMurphy,项目名称:X-Extension,代码行数:36,代码来源:XApp.cs

示例6: AddImage

        /// <summary>
        /// Add an image to a geometry object.
        /// A geometry 'skin' may contain several segment images in one image.
        /// </summary>
        /// <param name="shapeName">The 3DView object.</param>
        /// <param name="geometryName">The geometry object.</param>
        /// <param name="textures">A space or colon deliminated list of the texture coordinates for each node.
        /// Each node has 2 values between 0 and 1 indicating the x,y image mapping to the node.
        /// The may be defaulted to "" if the texture has previously been set.</param>
        /// <param name="imageName">
        /// The image to load to the geometry.
        /// Value returned from ImageList.LoadImage or local or network image file.
        /// A colour or gradient brush can also be used here.
        /// </param>
        /// <param name="materialType">A material for the object.
        /// The available options are:
        /// "E" Emmissive - constant brightness.
        /// "D" Diffusive - affected by lights.
        /// "S" Specular - additional specular highlights.</param>
        public static void AddImage(Primitive shapeName, Primitive geometryName, Primitive textures, Primitive imageName, Primitive materialType)
        {
            UIElement obj;
            Type ImageListType = typeof(ImageList);
            Dictionary<string, BitmapSource> _savedImages;
            BitmapSource img;

            try
            {
                if (_objectsMap.TryGetValue((string)shapeName, out obj))
                {
                    InvokeHelper ret = new InvokeHelper(delegate
                    {
                        try
                        {
                            if (obj.GetType() == typeof(Viewport3D))
                            {
                                Geometry geom = getGeometry(geometryName);
                                if (null == geom) return;
                                GeometryModel3D geometry = geom.geometryModel3D;
                                MeshGeometry3D mesh = (MeshGeometry3D)geometry.Geometry;
                                MaterialGroup material = (MaterialGroup)geometry.Material;

                                string[] s;
                                int i;

                                // Create a collection of texture coordinates for the MeshGeometry3D.
                                PointCollection textureCollection = new PointCollection();
                                s = Utilities.getString(textures).Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
                                for (i = 0; i < s.Length; i += 2)
                                {
                                    textureCollection.Add(new Point(Utilities.getDouble(s[i]), Utilities.getDouble(s[i + 1])));
                                }
                                if (textureCollection.Count == mesh.Positions.Count) mesh.TextureCoordinates = textureCollection;

                                Brush brush = null;
                                foreach (GradientBrush iBrush in LDShapes.brushes)
                                {
                                    if (iBrush.name == imageName)
                                    {
                                        brush = iBrush.getBrush();
                                    }
                                }
                                if (null == brush)
                                {
                                    try
                                    {
                                        brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(imageName));
                                    }
                                    catch
                                    {
                                        _savedImages = (Dictionary<string, BitmapSource>)ImageListType.GetField("_savedImages", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);
                                        if (!_savedImages.TryGetValue((string)imageName, out img))
                                        {
                                            imageName = ImageList.LoadImage(imageName);
                                            if (!_savedImages.TryGetValue((string)imageName, out img))
                                            {
                                                return;
                                            }
                                        }
                                        brush = new ImageBrush(img);
                                    }
                                }

                                switch (materialType.ToString().ToLower())
                                {
                                    case "e":
                                        material.Children.Add(new EmissiveMaterial(brush));
                                        break;
                                    case "d":
                                        material.Children.Add(new DiffuseMaterial(brush));
                                        break;
                                    case "s":
                                        material.Children.Add(new SpecularMaterial(brush, specular));
                                        break;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Utilities.OnError(Utilities.GetCurrentMethod(), ex);
//.........这里部分代码省略.........
开发者ID:litdev1,项目名称:LitDev,代码行数:101,代码来源:3DView.cs


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