public static string GetDescription(FlowCategory value) { var fi = value.GetType().GetField(value.ToString()); var attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); if (attributes != null && attributes.Length > 0) return attributes[0].Description; return value.ToString(); }
public static string GetDescription(FlowCategory value) { FieldInfo fi = value.GetType().GetField(value.ToString()); DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); if (attributes != null && attributes.Length > 0) { return(attributes[0].Description); } else { return(value.ToString()); } }
private void BindData(int CurrentPageIndex) { int nStatus = -1; string sKeyword =""; int nPageSize = 1000; int nPageCount = Constants.PAGECOUNT; DataTable dtbPage = new DataTable(); StaticPages objPage = new StaticPages(); dtbPage = objPage.Search(sKeyword, 0,0, nStatus, CurrentPageIndex, nPageSize, ref nPageCount); FlowCategory flow = new FlowCategory(dtbPage, VERTICAL_COLUMN_NAME, HOLIZOTAL_COLUMN_NAME); if (nStatus == -1 && sKeyword == string.Empty) // search all { DataTable objTable = new DataTable(); StaticPages obj = new StaticPages(); objTable = obj.Search("", 0,1, -1, 1, 10000, ref nPageCount); FlowCategory objflow = new FlowCategory(objTable, VERTICAL_COLUMN_NAME, HOLIZOTAL_COLUMN_NAME); objflow.IDColumnName = "StaticPageID"; objflow.ParentIDColumName = "[Parent]"; flow.SortColumnName = "MenuName"; objflow.SortColumnName = "Priority"; objflow.ParentSortDirection = "ASC"; if (objflow.Execute(0)) { int iCurrIndex = 0; if (CurrentPageIndex > 0) iCurrIndex = CurrentPageIndex - 1; mCateData = objflow.DestinationData(); FlowPager pager = new FlowPager(mCateData, nPageSize, "[Parent]"); DataView vwPage = pager.GeneralPageByIndex(iCurrIndex, VERTICAL_COLUMN_NAME); hidSearchStatus.Value = "1"; RpStaticPage.DataSource = vwPage; nPageCount = mCateData.Rows.Count; nPageSize = pager.TotalRecord; } mCateData = objflow.DestinationData(); RpStaticPage.DataBind(); //lblTotalRecord.Text = "Có" + " " + +nPageCount + " " + "Bản ghi được tìm thấy"; } else // Search Active or Inactive { hidSearchStatus.Value = "0"; RpStaticPage.DataBind(); //lblTotalRecord.Text = ConvertData.ConvertToString(nPageCount); } }
private void BindDataToDropCategory() { int nPageCount = 0; ddlCategory.Items.Clear(); DataTable objTable = new DataTable(); StaticPages objStaticPages = new StaticPages(); objTable = objStaticPages.Search("", 0,0, -1, 1, 10000, ref nPageCount); int nCount = objTable.Rows.Count; FlowCategory flow = new FlowCategory(objTable, VERTICAL_COLUMN_NAME, HOLIZOTAL_COLUMN_NAME); flow.IDColumnName = "StaticPageID"; flow.ParentIDColumName = "[Parent]"; flow.SortColumnName = "MenuName"; flow.SortColumnName = "Priority"; flow.ParentSortDirection = "ASC"; if (flow.Execute(0)) { mCateData = flow.DestinationData(); } if (mCateData != null) { foreach (DataRow dr in mCateData.Rows) { if (dr != null) { string sText = Convert.ToString(dr["MenuName"]); Int16 iHolz = Convert.ToInt16(dr[HOLIZOTAL_COLUMN_NAME]); textCreateMarginLeft(ref sText, iHolz); ListItem item = new ListItem(sText, Convert.ToString(dr["StaticPageID"])); ddlCategory.Items.Add(item); } } Utl1.SetNonSelectToControl(ddlCategory, MultipleLanguage.DDL_SELECTVALUE, "0"); } else { ddlCategory.DataSource = mCateData; ddlCategory.DataTextField = "MenuName"; ddlCategory.DataValueField = "StaticPageID"; ddlCategory.DataBind(); Utl1.SetNonSelectToControl(ddlCategory, "Tất cả", "0"); } }
public FlowDesignerCategoryAttribute(FlowCategory category) { this.Category = category; }
private void CreateMenuItems(ContextMenuStrip menu) { // Get list of layer types. List <Type> types = new List <Type>(); foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var t in a.GetTypes()) { if (typeof(Layer).IsAssignableFrom(t)) { types.Add(t); } } } // For each of those layer types, find ones that have // FlowDesignerName and FlowDesignerCategory attributes. List <SelectedType> selectedTypes = new List <SelectedType>(); foreach (var t in types) { bool foundName = false; bool foundCategory = false; string currentName = "<unknown>"; FlowCategory currentCategory = FlowCategory.General; object[] o = t.GetCustomAttributes(true); foreach (var a in o) { if (a is FlowDesignerNameAttribute) { currentName = (a as FlowDesignerNameAttribute).Name; foundName = true; } if (a is FlowDesignerCategoryAttribute) { currentCategory = (a as FlowDesignerCategoryAttribute).Category; foundCategory = true; } } if (foundName && foundCategory) { selectedTypes.Add(new SelectedType { Name = currentName, Category = currentCategory, Type = t }); } } // Sort selected types into bins. var types2d = new Dictionary <FlowCategory, List <SelectedType> >(); var types3d = new Dictionary <FlowCategory, List <SelectedType> >(); foreach (var t in selectedTypes) { if (typeof(Layer2D).IsAssignableFrom(t.Type)) { if (!types2d.Keys.Contains(t.Category)) { types2d.Add(t.Category, new List <SelectedType>()); } types2d[t.Category].Add(t); } else if (typeof(Layer3D).IsAssignableFrom(t.Type)) { if (!types3d.Keys.Contains(t.Category)) { types3d.Add(t.Category, new List <SelectedType>()); } types3d[t.Category].Add(t); } } foreach (var k in types2d.Keys.ToArray()) { types2d[k] = types2d[k].OrderBy(v => v.Name).ToList(); } foreach (var k in types3d.Keys.ToArray()) { types3d[k] = types3d[k].OrderBy(v => v.Name).ToList(); } // If we have at least one entry in the 2D types list, then create // the header and submenus. if (types2d.Count > 0) { menu.Items.Add(new ToolStripMenuItem("2D:") { Enabled = false }); foreach (var c in types2d.Keys) { var cm = new ToolStripMenuItem(Enum.GetName(typeof(FlowCategory), c)); foreach (var l in types2d[c]) { Type t = l.Type; cm.DropDownItems.Add(new ToolStripMenuItem(l.Name, null, (sender, ev) => { this.CreateDynamicLayer(t); }, "c_" + l.Name)); } menu.Items.Add(cm); } } // If we have at least one entry in the 3D types list, then create // the header and submenus. if (types2d.Count > 0) { menu.Items.Add("-"); } if (types3d.Count > 0) { menu.Items.Add(new ToolStripMenuItem("3D:") { Enabled = false }); foreach (var c in types3d.Keys) { var cm = new ToolStripMenuItem(Enum.GetName(typeof(FlowCategory), c)); foreach (var l in types3d[c]) { Type t = l.Type; cm.DropDownItems.Add(new ToolStripMenuItem(l.Name, null, (sender, ev) => { this.CreateDynamicLayer(t); })); } menu.Items.Add(cm); } } // Add other options. if (types2d.Count > 0 || types3d.Count > 0) { menu.Items.Add("-"); } menu.Items.Add(this.c_DisableProcessingMenuItem); menu.Items.Add(this.c_ExportSelectedMenuItem); menu.Items.Add(this.c_RenameSelectedMenuItem); menu.Items.Add(this.c_DeleteSelectedMenuItem); }
private void CreateMenuItems(ContextMenuStrip menu) { // Get list of layer types. List <Type> types = new List <Type>(); foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var t in a.GetTypes()) { if (typeof(IAlgorithm).IsAssignableFrom(t)) { types.Add(t); } } } // For each of those layer types, find ones that have // FlowDesignerName, FlowDesignerCategory and FlowDesignerMajorCategory attributes. List <SelectedType> selectedTypes = new List <SelectedType>(); foreach (var t in types) { bool foundName = false; bool foundCategory = false; string currentName = "<unknown>"; FlowCategory currentCategory = FlowCategory.Undefined; FlowMajorCategory currentMajorCategory = FlowMajorCategory.Undefined; object[] o = t.GetCustomAttributes(true); foreach (var a in o) { if (a is FlowDesignerNameAttribute) { currentName = (a as FlowDesignerNameAttribute).Name; foundName = true; } if (a is FlowDesignerCategoryAttribute) { currentCategory = (a as FlowDesignerCategoryAttribute).Category; foundCategory = true; } if (a is FlowDesignerMajorCategoryAttribute) { currentMajorCategory = (a as FlowDesignerMajorCategoryAttribute).MajorCategory; } } if (foundName && foundCategory) { selectedTypes.Add(new SelectedType { Name = currentName, MajorCategory = currentMajorCategory, Category = currentCategory, Type = t }); } } // Sort selected types into bins. selectedTypes.OrderBy(v => v.Name); menu.Items.Add(new ToolStripMenuItem("Tychaia World Generator") { Enabled = false }); foreach (FlowMajorCategory m in Enum.GetValues(typeof(FlowMajorCategory))) { bool cont = false; foreach (var t in selectedTypes) { if (t.MajorCategory.ToString() == m.ToString()) { cont = true; break; } } if (cont) { menu.Items.Add("-"); menu.Items.Add(new ToolStripMenuItem(FlowDesignerMajorCategoryAttribute.GetDescription(m) + ":") { Enabled = false }); foreach (FlowCategory c in Enum.GetValues(typeof(FlowCategory))) { cont = false; var cm = new ToolStripMenuItem(FlowDesignerCategoryAttribute.GetDescription(c)); foreach (var t in selectedTypes) { if (t.MajorCategory.ToString() == m.ToString() && t.Category.ToString() == c.ToString()) { cont = true; var tempt = t; cm.DropDownItems.Add(new ToolStripMenuItem(t.Name, null, (sender, ev) => { this.CreateDynamicLayer(tempt.Type); }, "c_" + t.Name)); } } if (cont) { menu.Items.Add(cm); } } } } // Add other options. if (selectedTypes.Count > 0) { menu.Items.Add("-"); } menu.Items.Add(this.c_DisableProcessingMenuItem); menu.Items.Add(this.c_ExportSelectedMenuItem); menu.Items.Add(this.c_AnalyseSelectedMenuItem); menu.Items.Add(this.c_TraceSelectedMenuItem); menu.Items.Add(this.c_RenameSelectedMenuItem); menu.Items.Add(this.c_DeleteSelectedMenuItem); }