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


C# Collection.SetFacetDisplay方法代码示例

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


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

示例1: MakeCollection

        public static Collection MakeCollection()
        {
            string folder = @"C:\Users\Public\Pictures\Sample Pictures";
            string[] files = Directory.GetFiles(folder);

            Collection coll = new Collection();
            coll.Name = "Sample Pictures";

            bool anyItems = false;
            foreach (string path in files)
            {
                string extension = Path.GetExtension(path);
                bool isJpeg = (0 == string.Compare(".jpg", extension, true));
                bool isPng = (0 == string.Compare(".png", extension, true));

                if (isJpeg || isPng)
                {
                    anyItems = true;

                    FileInfo info = new FileInfo(path);
                    coll.AddItem(Path.GetFileNameWithoutExtension(path), path, null,
                        new ItemImage(path)
                        , new Facet("File name", Path.GetFileName(path)
                            , isJpeg ? "*.jpg" : null
                            , isPng ? "*.png" : null
                            )
                        , new Facet("File size", info.Length / 1000)
                        , new Facet("Creation time", info.CreationTime)
                        , new Facet("Link:", new FacetHyperlink("click to view image", path))
                        );
                }
            }

            if (anyItems)
            {
                coll.SetFacetDisplay("Creation time", false, true, false);
                coll.SetFacetFormat("File size", "#,#0 kb");
            }
            else
            {
                coll.AddItem("No pictures", null,
                    string.Format("The folder \"{0}\" does not contain any JPEG or PNG files.", folder),
                    null);
            }

            return coll;
        }
开发者ID:lramctr,项目名称:Lakshmi-Files,代码行数:47,代码来源:SharedPicturesFactory.cs

示例2: MakeCollection

        // Public Methods
        //======================================================================

        public override Collection MakeCollection(CollectionRequestContext context)
        {
            try
            {
                var crashes = db.Crashes
                    .Include(c => c.Light)
                    .Include(c => c.Weather)
                    .Include(c => c.CrashLocation)
                    .Include(c => c.SurfCondition)
                    .Include(c => c.CrashClass)
                    .Include(c => c.VehCollision)
                    .Include(c => c.ObjectStruck)
                    .Include(c => c.RoadCharacter)
                    .Include(c => c.ContFactor1)
                    .Include(c => c.ContFactor2)
                    .Include(c => c.CrashCategory);

                Collection collection = new Collection();
                collection.Name = "NPS Crashes";

                foreach (var crash in crashes.Take(maxItems))
                {
                    string imgFolder = HttpRuntime.BinDirectory.Substring(0, HttpRuntime.BinDirectory.Length - 5);
                    string imgName = GetImageName(crash.Category);
                    ItemImage image = null;
                    if (imgName != null)
                    {
                        image = new ItemImage(string.Format(@"{0}\Images\{1}", imgFolder, imgName));
                    }

                    collection.AddItem(crash.IncidentNo, null, null, image, GetFacets(crash));
                }

                // Set facet display properties
                collection.SetFacetDisplay("Park Alpha", true, true, true);
                collection.SetFacetDisplay("State", true, true, false);
                collection.SetFacetDisplay("Crash Year", true, true, false);
                collection.SetFacetDisplay("Crash Date", false, true, false);
                collection.SetFacetDisplay("Crash Time", false, true, false);
                collection.SetFacetDisplay("Route ID", true, true, true);
                collection.SetFacetDisplay("Road Name", false, true, true);
                collection.SetFacetDisplay("Node Distance (Ft)", false, true, false);
                collection.SetFacetDisplay("Node Distance (Mi)", false, true, false);
                collection.SetFacetDisplay("Node Direction", false, true, false);
                collection.SetFacetDisplay("Node Number", false, true, false);
                collection.SetFacetDisplay("Node MP", false, true, false);
                collection.SetFacetDisplay("Crash MP", true, true, false);
                collection.SetFacetDisplay("Light Condition", true, true, false);
                collection.SetFacetDisplay("Weather Condition", true, true, false);
                collection.SetFacetDisplay("Crash Location", true, true, false);
                collection.SetFacetDisplay("Surface Condition", true, true, false);
                collection.SetFacetDisplay("Crash Class", true, true, false);
                collection.SetFacetDisplay("Vehicle Collision", true, true, false);
                collection.SetFacetDisplay("Fixed Object Struck", true, true, false);
                collection.SetFacetDisplay("Road Character", true, true, false);
                collection.SetFacetDisplay("Contributing Factor 1", true, true, false);
                collection.SetFacetDisplay("Contributing Factor 2", true, true, false);
                collection.SetFacetDisplay("Contributing Factor 3", false, true, false);
                collection.SetFacetDisplay("Contributing Factor 4", false, true, false);
                collection.SetFacetDisplay("Contributing Factor 5", false, true, false);
                collection.SetFacetDisplay("Contributing Factor 6", false, true, false);
                collection.SetFacetDisplay("Category", true, true, false);
                collection.SetFacetDisplay("Hit & Run", false, true, false);
                collection.SetFacetDisplay("Fatal", false, true, false);
                collection.SetFacetDisplay("Injured", false, true, false);
                collection.SetFacetDisplay("Pedestrian Fatal", false, true, false);
                collection.SetFacetDisplay("Pedestrian Injured", false, true, false);
                collection.SetFacetDisplay("Bikers Fatal", false, true, false);
                collection.SetFacetDisplay("Bikers Injured", false, true, false);
                collection.SetFacetDisplay("Pedestrian", true, true, false);
                collection.SetFacetDisplay("Comments", false, true, true);
                collection.SetFacetDisplay("Spatial Location", true, true, false);

                //collection.SetFacetDisplay("Case Number", false, true, false);
                //collection.SetFacetDisplay("Location", false, true, false);
                //collection.SetFacetDisplay("USPP/NPS Veh. Inv.", false, true, false);
                //collection.SetFacetDisplay("Park Property Dest.", false, true, false);
                //collection.SetFacetDisplay("Data Source", false, true, false);
                //collection.SetFacetDisplay("Latitude", false, true, false);
                //collection.SetFacetDisplay("Longitude", false, true, false);
                //collection.SetFacetDisplay("Save Date", false, true, false);
                //collection.SetFacetDisplay("RIP Cycle", false, true, false);

                // Set facet formats
                //collection.SetFacetFormat("List price", "$#,0.00");

                return collection;
            }
            catch (Exception ex)
            {

                return ErrorCollection.FromException(ex);
            }
        }
开发者ID:lramctr,项目名称:Lakshmi-Files,代码行数:97,代码来源:CrashCollection.cs


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