コード例 #1
0
        // GET: Category
        public ActionResult Index()
        {
            CategoryDisplay categoryDisplay = new CategoryDisplay();

            categoryDisplay.SearchByOptions = GetSearchByOptions();
            return(View(categoryDisplay));
        }
コード例 #2
0
        public IActionResult AddProductToCategory(int id, CategoryDisplay formData)
        {
            Category thisCategory = dbContext.Categories
                                    .FirstOrDefault(c => c.CategoryID == id);

            if (thisCategory == null)
            {
                ModelState.AddModelError("ProductID", "No Product Selected");
            }
            if (!ModelState.IsValid)
            {
                return(Redirect($"categories/{id}"));
            }

            Product addedProduct = dbContext.Products
                                   .SingleOrDefault(p =>
                                                    p.ProductID == formData.AddProductModel.NewProductID);

            Association asc = new Association();

            asc.Category          = thisCategory;
            asc.Product           = addedProduct;
            thisCategory.Products = new List <Association>();
            thisCategory.Products.Add(asc);
            addedProduct.Categories = new List <Association>();
            addedProduct.Categories.Add(asc);
            dbContext.SaveChanges();
            return(RedirectToAction(""));
        }
コード例 #3
0
        public ActionResult Index(CategoryDisplay input)
        {
            CategoryDisplay categoryDisplay = new CategoryDisplay();

            categoryDisplay.Categories      = dbHelper.GetCategory(input.SearchKey, input.SearchBy);
            categoryDisplay.SearchByOptions = GetSearchByOptions();
            return(View(categoryDisplay));
        }
コード例 #4
0
ファイル: VFWSettings.cs プロジェクト: srndpty/VFW
        public void Reset()
        {
            _memberFormat = kDefaultMemberFormat;
            _sequenceFormat = kDefaultSequenceFormat;
            _dictionaryFormat = kDefaultDictionaryFormat;

            DefaultDisplay = CategoryDisplay.BoxedMembersArea;
            DefaultSpacing = 10;
            DisplayReadonlyIfTrue = true;
        }
コード例 #5
0
        public void Reset()
        {
            _memberFormat     = kDefaultMemberFormat;
            _sequenceFormat   = kDefaultSequenceFormat;
            _dictionaryFormat = kDefaultDictionaryFormat;

            DefaultDisplay        = CategoryDisplay.BoxedMembersArea;
            DefaultSpacing        = 10;
            DisplayReadonlyIfTrue = true;
        }
コード例 #6
0
        public override void Reset()
        {
            _memberFormat     = kDefaultMemberFormat;
            _sequenceFormat   = kDefaultSequenceFormat;
            _dictionaryFormat = kDefaultDictionaryFormat;

            //SerializerPopup = kFullSerializer;
            DefaultDisplay        = CategoryDisplay.BoxedMembersArea;
            DefaultSpacing        = 10;
            DisplayReadonlyIfTrue = true;
        }
コード例 #7
0
        public IActionResult DisplayCategory(int id)
        {
            Category selectedCategory = dbContext.Categories
                                        .Include(c => c.Products)
                                        .ThenInclude(asc => asc.Product)
                                        .FirstOrDefault(c => c.CategoryID == id);

            if (selectedCategory == null)
            {
                return(RedirectToAction("Categories"));
            }

            CategoryDisplay thisCategory = new CategoryDisplay();

            thisCategory.Name = selectedCategory.Name;

            List <Product> AllProducts = dbContext.Products.ToList();

            thisCategory.AddProductModel = new AddProduct();
            thisCategory.AddProductModel.OtherProducts = new List <Product>();
            bool found = false;

            foreach (Product p in AllProducts)
            {
                foreach (Association a in selectedCategory.Products)
                {
                    if (a.Product == p)
                    {
                        found = true;
                        thisCategory.Members.Add(p);
                    }
                }
                if (!found)
                {
                    thisCategory.AddProductModel.OtherProducts.Add(p);
                }
            }
            return(View("CategoryDisplay", thisCategory));
        }
コード例 #8
0
        private void BuildCategoryDisplay()
        {
            _categoryDisplays = new List <CategoryDisplay>();

            var _data  = dbHelper.GetTableData("CategoryDisplay", "LanguageCode", "11", _conn);
            int _count = _data.Count / 4;
            int _indx  = 0;

            for (int i = 0; i < _count; i++)
            {
                var catd = new CategoryDisplay();
                catd.CategoryID                 = int.Parse(_data[_indx++]);
                catd.LanguageCode               = int.Parse(_data[_indx++]);
                catd.CategoryDisplayName        = _data[_indx++];
                catd.CategoryDisplayDescription = _data[_indx++];
                _categoryDisplays.Add(catd);

                if (_indx + 1 > _data.Count)
                {
                    break;
                }
            }
        }
コード例 #9
0
        protected virtual void OnGUI()
        {
            if (ShowScriptHeader)
            {
                var scriptKey = RuntimeHelper.CombineHashCodes(id, "script");
                gui.Space(3f);
                using (gui.Horizontal(EditorStyles.toolbarButton))
                {
                    gui.Space(10f);
                    prefs[scriptKey] = gui.Foldout(prefs.ValueOrDefault(scriptKey, false));
                    gui.Space(-12f);

                    if (ScriptField()) // script changed? exit!
                    {
                        return;
                    }
                }

                if (prefs[scriptKey])
                {
                    gui.Space(2f);

                    using (gui.Indent(GUI.skin.textField))
                    {
                        gui.Space(3f);

                        gui.Member(_debug);

                        var mask = gui.BunnyMask("Display", _display);
                        {
                            var newValue = (CategoryDisplay)mask;
                            if (_display != newValue)
                            {
                                _display = newValue;
                                var displayKey = RuntimeHelper.CombineHashCodes(id, "display");
                                prefs[displayKey] = mask;
                            }
                        }

                        var spacing = Mathf.Clamp(gui.Int("Spacing", _spacing), -13, (int)EditorGUIUtility.currentViewWidth / 4);
                        if (_spacing != spacing)
                        {
                            _spacing = spacing;
                            int spacingKey = RuntimeHelper.CombineHashCodes(id, "spacing");
                            prefs[spacingKey] = _spacing;
                            gui.RequestResetIfRabbit();
                        }
                    }
                }
            }

            gui.BeginCheck();

            for (int i = 0; i < _categories.Count; i++)
            {
                var cat = _categories[i];
                cat.Display    = _display;
                cat.Spacing    = _spacing;
                cat.gui        = gui;
                cat.HideHeader = (_display & CategoryDisplay.Headers) == 0;
                if ((_display & CategoryDisplay.CategorySplitter) != 0)
                {
                    gui.Splitter();
                }
                cat.Draw(target);
            }

            if (gui.HasChanged())
            {
#if DBG
                Log("Target changed: " + target);
#endif
                if (target != null)
                {
                    EditorUtility.SetDirty(target);
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Fetches visible members in the inspected target object and assigns them to their corresponding categories
        /// </summary>
        private void Initialize()
        {
            OnBeforeInitialized();

            // fetch visible members
            _visibleMembers = VisibilityLogic.CachedGetVisibleMembers(targetType);

            var drawnByUnity = _visibleMembers
                               .Where(x => x.IsDefined <DrawByUnityAttribute>() || DrawnByUnityTypes.Any(x.GetDataType().IsA));

            _visibleMembers = _visibleMembers.Except(drawnByUnity).ToList();

            _membersDrawnByUnityLayout = drawnByUnity.Select(x => x.Name).ToArray();

            // allocate categories
            _categories = new List <MembersCategory>();

            var multiple    = targetType.GetCustomAttribute <DefineCategoriesAttribute>(true);
            var definitions = targetType.GetCustomAttributes <DefineCategoryAttribute>(true);

            if (multiple != null)
            {
                definitions = definitions.Concat(multiple.names.Select(n => new DefineCategoryAttribute(n, 1000)));
            }

            Func <string, string[]> ParseCategoryPath = fullPath =>
            {
                int      nPaths = fullPath.Split('/').Length;
                string[] result = new string[nPaths];
                for (int i = 0, index = -1; i < nPaths - 1; i++)
                {
                    index     = fullPath.IndexOf('/', index + 1);
                    result[i] = fullPath.Substring(0, index);
                }
                result[nPaths - 1] = fullPath;
                return(result);
            };

            // Order by exclusivity
            var defs = from d in definitions
                       let paths = ParseCategoryPath(d.FullPath)
                                   orderby !d.Exclusive
                                   select new { def = d, paths };

            // Parse paths and resolve definitions
            var resolver = new CategoryDefinitionResolver();
            var lookup   = new Dictionary <string, MembersCategory>();

            foreach (var x in defs)
            {
                var paths = x.paths;
                var d     = x.def;

                MembersCategory parent = null;

                for (int i = 0; i < paths.Length; i++)
                {
                    var path = paths[i];

                    var current = (parent == null ? _categories :
                                   parent.NestedCategories).FirstOrDefault(c => c.FullPath == path);

                    if (current == null)
                    {
                        current = new MembersCategory(path, d.Order, id, prefs);
                        if (i == 0)
                        {
                            _categories.Add(current);
                        }
                        if (parent != null)
                        {
                            parent.NestedCategories.Add(current);
                        }
                    }
                    lookup[path] = current;
                    parent       = current;
                }

                var last = lookup[paths.Last()];
                last.ForceExpand      = d.ForceExpand;
                last.AlwaysHideHeader = d.AlwaysHideHeader;
                resolver.Resolve(_visibleMembers, d).Foreach(last.Members.Add);

                lookup.Clear();
                parent.Members = parent.Members.OrderBy <MemberInfo, float>(VisibilityLogic.GetMemberDisplayOrder).ToList();
            }

            // filter out empty categories
            _categories = _categories.Where(x => x.NestedCategories.Count > 0 || x.Members.Count > 0)
                          .OrderBy(x => x.DisplayOrder)
                          .ToList();

            for (int i = 0; i < _categories.Count; i++)
            {
                var c = _categories[i];
                c.RemoveEmptyNestedCategories();
            }

            var getDisplayOptions = targetType.GetMethod("GetDisplayOptions");

            Assert.IsNotNull(getDisplayOptions);

            // otherwise whatever value is in our settings asset
            // TODO CHANGED: A common interface is now used for both cases.
            var defaultDisplay = typeof(IVFWObject).IsAssignableFrom(getDisplayOptions.DeclaringType) ?
                                 VFWSettings.DefaultDisplay : (CategoryDisplay)getDisplayOptions.Invoke(target);

            //var defaultDisplay = (getDisplayOptions.DeclaringType == typeof(BaseBehaviour) ||
            //                      getDisplayOptions.DeclaringType == typeof(BaseScriptableObject)) ?
            //                      VFWSettings.DefaultDisplay : (CategoryDisplay)getDisplayOptions.Invoke(target);

            int displayKey   = RuntimeHelper.CombineHashCodes(id, "display");
            int displayValue = prefs.ValueOrDefault(displayKey, (int)defaultDisplay);

            _display          = displayValue == -1 ? VFWSettings.DefaultDisplay : (CategoryDisplay)displayValue;
            prefs[displayKey] = (int)_display;

            var spacingKey = RuntimeHelper.CombineHashCodes(id, "spacing");

            _spacing          = prefs.ValueOrDefault(spacingKey, VFWSettings.DefaultSpacing);
            prefs[spacingKey] = _spacing;

            FieldInfo field;

            field = targetType.GetField("dbg", Flags.InstanceAnyVisibility);
            if (field == null)
            {
                ErrorHelper.MemberNotFound(targetType, "dbg");
            }

            _debug = EditorMember.WrapMember(field, target, target, id);

            OnAfterInitialized();
        }
コード例 #11
0
 public CategoryWriter(CategoryViewData rootCategory, HtmlHelper htmlHelper, CategoryDisplay display)
 {
     this.rootCategory = rootCategory;
     this.htmlHelper   = htmlHelper;
     this.display      = display;
 }
コード例 #12
0
        protected virtual void OnGUI()
        {
            if (ShowScriptHeader)
            {
                var scriptKey = RuntimeHelper.CombineHashCodes(id, "script");
                gui.Space(3f);
                using (gui.Horizontal(EditorStyles.toolbarButton))
                {
                    gui.Space(10f);
                    foldouts[scriptKey] = gui.Foldout(foldouts[scriptKey]);
                    gui.Space(-12f);

                    if (ScriptField()) // script changed? exit!
                    {
                        return;
                    }
                }

                if (foldouts[scriptKey])
                {
                    gui.Space(2f);

                    using (gui.Indent(GUI.skin.textField))
                    {
                        gui.Space(3f);
                        if (targetType.IsDefined <HasRequirementsAttribute>())
                        {
                            using (gui.Horizontal())
                            {
                                gui.Space(3f);
                                if (gui.MiniButton("Resolve Requirements", (Layout)null))
                                {
                                    Requirements.Resolve(target, gameObject);
                                }
                            }
                        }

                        gui.Member(_debug);

                        var mask = gui.BunnyMask("Display", _display);
                        {
                            var newValue = (CategoryDisplay)mask;
                            if (_display != newValue)
                            {
                                _display = newValue;
                                var displayKey = RuntimeHelper.CombineHashCodes(id, "display");
                                prefs.Ints[displayKey] = mask;
                            }
                        }

                        var spacing = Mathf.Clamp(gui.Int("Spacing", _spacing), -13, (int)EditorGUIUtility.currentViewWidth / 4);
                        if (_spacing != spacing)
                        {
                            _spacing = spacing;
                            prefs.Ints[id + "spacing".GetHashCode()] = _spacing;
                            gui.RequestResetIfRabbit();
                        }

                        gui.Member(_serializationData, true);
                    }
                }
            }

            gui.BeginCheck();

            for (int i = 0; i < _categories.Count; i++)
            {
                var cat = _categories[i];
                cat.Display    = _display;
                cat.Spacing    = _spacing;
                cat.gui        = gui;
                cat.HideHeader = (_display & CategoryDisplay.Headers) == 0;
                if ((_display & CategoryDisplay.CategorySplitter) != 0)
                {
                    gui.Splitter();
                }
                cat.Draw(target);
            }

            if (gui.HasChanged())
            {
#if DBG
                Log("Target changed: " + target);
#endif
                EditorUtility.SetDirty(target);
                //SerializationManager.MarkModified(target);
            }
        }
コード例 #13
0
 public CategoryWriter(CategoryViewData rootCategory, HtmlHelper htmlHelper, CategoryDisplay display)
 {
     this.rootCategory = rootCategory;
     this.htmlHelper = htmlHelper;
     this.display = display;
 }
コード例 #14
0
ファイル: BaseEditor.cs プロジェクト: vvhh2002/VFW
        /// <summary>
        /// Fetches visible members in the inspected target object and assigns them to their corresponding categories
        /// </summary>
        private void Initialize()
        {
            OnBeforeInitialized();

            // fetch visible members
            _visibleMembers = VisibilityLogic.CachedGetVisibleMembers(targetType);

            var drawnByUnity = _visibleMembers
                .Where(x => x.IsDefined<DrawByUnityAttribute>() || DrawnByUnityTypes.Any(x.GetDataType().IsA));

            _visibleMembers = _visibleMembers.Except(drawnByUnity).ToList();

            _membersDrawnByUnityLayout = drawnByUnity.Select(x => x.Name).ToArray();

            // allocate categories
            _categories = new List<MembersCategory>();

            var multiple	= targetType.GetCustomAttribute<DefineCategoriesAttribute>(true);
            var definitions = targetType.GetCustomAttributes<DefineCategoryAttribute>(true);
            if (multiple != null)
                definitions = definitions.Concat(multiple.names.Select(n => new DefineCategoryAttribute(n, 1000)));

            Func<string, string[]> ParseCategoryPath = fullPath =>
            {
                int nPaths = fullPath.Split('/').Length;
                string[] result = new string[nPaths];
                for (int i = 0, index = -1; i < nPaths - 1; i++)
                {
                    index = fullPath.IndexOf('/', index + 1);
                    result[i] = fullPath.Substring(0, index);
                }
                result[nPaths - 1] = fullPath;
                return result;
            };

            // Order by exclusivity
            var defs = from d in definitions
                       let paths = ParseCategoryPath(d.FullPath)
                       orderby !d.Exclusive
                       select new { def = d, paths };

            // Parse paths and resolve definitions
            var resolver = new CategoryDefinitionResolver();
            var lookup = new Dictionary<string, MembersCategory>();
            foreach (var x in defs)
            {
                var paths = x.paths;
                var d = x.def;

                MembersCategory parent = null;

                for (int i = 0; i < paths.Length; i++)
                {
                    var path = paths[i];

                    var current = (parent == null ?  _categories :
                        parent.NestedCategories).FirstOrDefault(c => c.FullPath == path);

                    if (current == null)
                    {
                        current = new MembersCategory(path, d.Order, id);
                        if (i == 0)
                            _categories.Add(current);
                        if (parent != null)
                            parent.NestedCategories.Add(current);
                    }
                    lookup[path] = current;
                    parent = current;
                }

                var last = lookup[paths.Last()];
                last.ForceExpand = d.ForceExpand;
                last.AlwaysHideHeader = d.AlwaysHideHeader;
                resolver.Resolve(_visibleMembers, d).Foreach(last.Members.Add);

                lookup.Clear();
                parent.Members = parent.Members.OrderBy<MemberInfo, float>(VisibilityLogic.GetMemberDisplayOrder).ToList();
            }

            // filter out empty categories
            _categories = _categories.Where(x => x.NestedCategories.Count > 0 || x.Members.Count > 0)
                                     .OrderBy(x => x.DisplayOrder)
                                     .ToList();

            for (int i = 0; i < _categories.Count; i++)
            {
                var c = _categories[i];
                c.RemoveEmptyNestedCategories();
            }

            var getDisplayOptions = targetType.GetMethod("GetDisplayOptions");
            if (getDisplayOptions == null)
                throw new vMemberNotFound(targetType, "GetDisplayOptions");

            var vfwSettings = VFWSettings.GetInstance();

            // does target override GetDisplayOptions? if so set that as the default value,
            // otherwise whatever value is in our settings asset
            var defaultDisplay = (getDisplayOptions.DeclaringType == typeof(BetterBehaviour) ||
                                  getDisplayOptions.DeclaringType == typeof(BetterScriptableObject)) ?
                                  vfwSettings.DefaultDisplay : (CategoryDisplay)getDisplayOptions.Invoke(target);

            var displayKey = RuntimeHelper.CombineHashCodes(id, "display");
            var displayValue = prefs.Ints.ValueOrDefault(displayKey, (int)defaultDisplay);
            _display = displayValue == -1 ? vfwSettings.DefaultDisplay : (CategoryDisplay)displayValue;
            prefs.Ints[displayKey] = (int)_display;

            var spacingKey = RuntimeHelper.CombineHashCodes(id, "spacing");
            _spacing = prefs.Ints.ValueOrDefault(spacingKey, vfwSettings.DefaultSpacing);
            prefs.Ints[spacingKey] = _spacing;

            var field = targetType.GetMemberFromAll("_serializationData", Flags.InstancePrivate);
            if (field == null)
            {
                if (targetType.IsA<BetterBehaviour>() || targetType.IsA<BetterScriptableObject>())
                    throw new vMemberNotFound(targetType, "_serializationData");
            }
            else _serializationData = EditorMember.WrapMember(field, target, target, id);

            field = targetType.GetField("dbg", Flags.InstanceAnyVisibility);
            if (field == null)
                throw new vMemberNotFound(targetType, "dbg");

            _debug = EditorMember.WrapMember(field, target, target, id);

            OnAfterInitialized();
        }
コード例 #15
0
ファイル: BaseEditor.cs プロジェクト: vvhh2002/VFW
        protected virtual void OnGUI()
        {
            if (ShowScriptHeader)
            {
                var scriptKey = RuntimeHelper.CombineHashCodes(id, "script");
                gui.Space(3f);
                using (gui.Horizontal(EditorStyles.toolbarButton))
                {
                    gui.Space(10f);
                    foldouts[scriptKey] = gui.Foldout(foldouts[scriptKey]);
                    gui.Space(-12f);

                    if (ScriptField()) // script changed? exit!
                        return;
                }

                if (foldouts[scriptKey])
                {
                    gui.Space(2f);

                    using (gui.Indent(GUI.skin.textField))
                    {
                        gui.Space(3f);

                        gui.Member(_debug);

                        var mask = gui.BunnyMask("Display", _display);
                        {
                            var newValue = (CategoryDisplay)mask;
                            if (_display != newValue)
                            {
                                _display = newValue;
                                var displayKey = RuntimeHelper.CombineHashCodes(id, "display");
                                prefs.Ints[displayKey] = mask;
                            }
                        }

                        var spacing = Mathf.Clamp(gui.Int("Spacing", _spacing), -13, (int)EditorGUIUtility.currentViewWidth / 4);
                        if (_spacing != spacing)
                        {
                            _spacing = spacing;
                            prefs.Ints[id + "spacing".GetHashCode()] = _spacing;
                            gui.RequestResetIfRabbit();
                        }

                        if (_serializationData != null)
                            gui.Member(_serializationData, true);
                    }
                }
            }

            gui.BeginCheck();

            for (int i = 0; i < _categories.Count; i++)
            {
                var cat     = _categories[i];
                cat.Display = _display;
                cat.Spacing = _spacing;
                cat.gui = gui;
                cat.HideHeader = (_display & CategoryDisplay.Headers) == 0;
                if ((_display & CategoryDisplay.CategorySplitter) != 0)
                    gui.Splitter();
                cat.Draw(target);
            }

            if (gui.HasChanged())
            {
            #if DBG
                Log("Target changed: " + target);
            #endif
                if (target != null)
                    EditorUtility.SetDirty(target);
            }
        }
コード例 #16
0
        public static string WriteCategories(this HtmlHelper htmlHelper, CategoryViewData rootCategory, CategoryDisplay display)
        {
            var categoryWriter = new CategoryWriter(rootCategory, htmlHelper, display);

            return(categoryWriter.Write());
        }
コード例 #17
0
        /// <summary>
        /// Fetches visible members in the inspected target object and assigns them to their corresponding categories
        /// </summary>
        private void Initialize()
        {
            OnBeforeInitialized();

            // fetch visible members
            _visibleMembers = VFWVisibilityLogic.CachedGetVisibleMembers(targetType).ToList();

            // allocate categories
            _categories = new List <MembersCategory>();

            var multiple    = targetType.GetCustomAttribute <DefineCategoriesAttribute>(true);
            var definitions = targetType.GetCustomAttributes <DefineCategoryAttribute>(true);

            if (multiple != null)
            {
                definitions = definitions.Concat(multiple.names.Select(n => new DefineCategoryAttribute(n, 1000)));
            }

            Func <string, string[]> ParseCategoryPath = fullPath =>
            {
                int      nPaths = fullPath.Split('/').Length;
                string[] result = new string[nPaths];
                for (int i = 0, index = -1; i < nPaths - 1; i++)
                {
                    index     = fullPath.IndexOf('/', index + 1);
                    result[i] = fullPath.Substring(0, index);
                }
                result[nPaths - 1] = fullPath;
                return(result);
            };

            // Order by exclusivity
            var defs = from d in definitions
                       let paths = ParseCategoryPath(d.FullPath)
                                   orderby !d.Exclusive
                                   select new { def = d, paths };

            // Parse paths and resolve definitions
            var resolver = new CategoryDefinitionResolver();
            var lookup   = new Dictionary <string, MembersCategory>();

            foreach (var x in defs)
            {
                var paths = x.paths;
                var d     = x.def;

                MembersCategory parent = null;

                for (int i = 0; i < paths.Length; i++)
                {
                    var path = paths[i];

                    var current = (parent == null ?  _categories :
                                   parent.NestedCategories).FirstOrDefault(c => c.FullPath == path);

                    if (current == null)
                    {
                        current = new MembersCategory(path, d.DisplayOrder, id);
                        if (i == 0)
                        {
                            _categories.Add(current);
                        }
                        if (parent != null)
                        {
                            parent.NestedCategories.Add(current);
                        }
                    }
                    lookup[path] = current;
                    parent       = current;
                }

                var last = lookup[paths.Last()];
                last.ForceExpand      = d.ForceExpand;
                last.AlwaysHideHeader = d.AlwaysHideHeader;
                resolver.Resolve(_visibleMembers, d).Foreach(last.Members.Add);

                lookup.Clear();
                parent.Members = parent.Members.OrderBy <MemberInfo, float>(VFWVisibilityLogic.GetMemberDisplayOrder).ToList();
            }

            // filter out empty categories
            _categories = _categories.Where(x => x.NestedCategories.Count > 0 || x.Members.Count > 0)
                          .OrderBy(x => x.DisplayOrder)
                          .ToList();

            for (int i = 0; i < _categories.Count; i++)
            {
                var c = _categories[i];
                c.RemoveEmptyNestedCategories();
            }

            var displayKey   = RuntimeHelper.CombineHashCodes(id, "display");
            var displayValue = prefs.Ints.ValueOrDefault(displayKey, -1);
            var vfwSettings  = VFWSettings.GetInstance();

            _display = displayValue == -1 ? vfwSettings.DefaultDisplay : (CategoryDisplay)displayValue;
            prefs.Ints[displayKey] = (int)_display;

            var spacingKey = RuntimeHelper.CombineHashCodes(id, "spacing");

            _spacing = prefs.Ints.ValueOrDefault(spacingKey, vfwSettings.DefaultSpacing);
            prefs.Ints[spacingKey] = _spacing;

            var field = targetType.GetAllMembers(typeof(MonoBehaviour), Flags.InstancePrivate)
                        .FirstOrDefault(m => m.Name == "_serializationData");

            if (field == null)
            {
                throw new vMemberNotFound(targetType, "_serializationData");
            }

            _serializationData = EditorMember.WrapMember(field, target, target, id);

            field = targetType.GetField("dbg", Flags.InstanceAnyVisibility);
            if (field == null)
            {
                throw new vMemberNotFound(targetType, "dbg");
            }

            _debug = EditorMember.WrapMember(field, target, target, id);

            OnAfterInitialized();
        }
コード例 #18
0
ファイル: Articles.ascx.cs プロジェクト: xiaopohou/cuyahoga
        protected void rptArticles_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Article     article     = e.Item.DataItem as Article;
                DisplayType displayType = (DisplayType)Enum.Parse(typeof(DisplayType), this.Module.Section.Settings["DISPLAY_TYPE"].ToString());

                HyperLink hpl        = e.Item.FindControl("hplTitle") as HyperLink;
                string    articleUrl = article.GetContentUrl();
                hpl.NavigateUrl = articleUrl;

                Panel pnlSummary = e.Item.FindControl("pnlSummary") as Panel;
                pnlSummary.Visible = (displayType == DisplayType.HeadersAndSummary);
                HyperLink hplReadMore = e.Item.FindControl("hplReadMore") as HyperLink;
                hplReadMore.NavigateUrl = articleUrl;
                hplReadMore.Text        = base.GetText("READMORE");

                Panel pnlContent = e.Item.FindControl("pnlContent") as Panel;
                pnlContent.Visible = (displayType == DisplayType.FullContent);

                Panel pnlArticleInfo = e.Item.FindControl("pnlArticleInfo") as Panel;

                if (this.Module.AllowComments || this.Module.ShowAuthor || this.Module.ShowCategory || this.Module.ShowDateTime)
                {
                    pnlArticleInfo.Visible = true;

                    Label lblDateOnline = e.Item.FindControl("lblDateOnline") as Label;
                    lblDateOnline.Text    = TimeZoneUtil.AdjustDateToUserTimeZone(article.PublishedAt.Value, this.Page.User.Identity).ToString();
                    lblDateOnline.Visible = this.Module.ShowDateTime;

                    Literal litAuthor = e.Item.FindControl("litAuthor") as Literal;
                    litAuthor.Text    = base.GetText("PUBLISHED") + " " + base.GetText("BY");
                    litAuthor.Visible = this.Module.ShowAuthor;
                    HyperLink hplAuthor = e.Item.FindControl("hplAuthor") as HyperLink;
                    hplAuthor.NavigateUrl = this.Module.GetProfileUrl(article.CreatedBy.Id);
                    hplAuthor.Text        = article.CreatedBy.FullName;
                    hplAuthor.Visible     = this.Module.ShowAuthor;

                    Literal litCategory = e.Item.FindControl("litCategory") as Literal;
                    litCategory.Text    = base.GetText("CATEGORIES");
                    litCategory.Visible = this.Module.ShowCategory;

                    CategoryDisplay cadCategories = (CategoryDisplay)e.Item.FindControl("cadCategories");
                    cadCategories.SectionBaseUrl = UrlUtil.GetUrlFromSection(Module.Section);
                    cadCategories.Categories     = article.Categories.ToDictionary(cat => cat.Id, cat => cat.Name);
                    cadCategories.Visible        = this.Module.ShowCategory;

                    HyperLink hplComments = e.Item.FindControl("hplComments") as HyperLink;
                    if (this.Module.AllowComments)
                    {
                        hplComments.NavigateUrl = UrlHelper.GetUrlFromSection(this.Module.Section)
                                                  + String.Format("/{0}#comments", article.Id);
                        hplComments.Text = base.GetText("COMMENTS") + " " + article.Comments.Count.ToString();
                    }
                    else
                    {
                        hplComments.Visible = false;
                    }
                }
                else
                {
                    pnlArticleInfo.Visible = false;
                }
            }
        }