public static string EnumSystemDataSourceString(EnumSystemDataSource enumSystemDataSource) { string str = "System.{0}"; str = String.Format(str, (int)enumSystemDataSource); return(str); }
public static string EnumSystemDataSourceVisibleString(EnumSystemDataSource enumSystemDataSource) { string str = Language.Current.DataSource_System + ".{0}"; str = String.Format(str, EnumDescConverter.Get(typeof(EnumSystemDataSource)).Select("Value='" + (int)enumSystemDataSource + "'")[0]["Text"].ToString()); return(str); }
public static string DataSourceVisibleString(WindowEntity formEntity, string str, out bool warning) { warning = false; if (str == null || str == String.Empty) { warning = true; return(String.Empty); } if (!str.StartsWith("FormElement.") && !str.StartsWith("System.")) { warning = true; throw new ArgumentException(); } string visibleStr; string[] strArray = str.Split('.'); switch (strArray[0]) { case "FormElement": UIElement formElement = formEntity.FindFormElementById(strArray[1]); if (formElement == null) { warning = true; return(String.Empty); } visibleStr = FormElementVisibleString(formElement); break; case "System": EnumSystemDataSource enumSystemDataSource = (EnumSystemDataSource)Enum.Parse(typeof(EnumSystemDataSource), strArray[1]); visibleStr = EnumSystemDataSourceVisibleString(enumSystemDataSource); break; default: throw new NotImplementedException(); } return(visibleStr); }
private void ComboBoxDrawItem(object sender, DrawItemEventArgs dea) { if (dea.Index < 0 || dea.Index >= this.Items.Count) { return; } Graphics g = dea.Graphics; Brush stringColor = SystemBrushes.ControlText; if ((dea.State & DrawItemState.Selected) == DrawItemState.Selected) { if ((dea.State & DrawItemState.Focus) == DrawItemState.Focus) { g.FillRectangle(SystemBrushes.Highlight, dea.Bounds); stringColor = SystemBrushes.HighlightText; } else { g.FillRectangle(SystemBrushes.Window, dea.Bounds); } } else { g.FillRectangle(SystemBrushes.Window, dea.Bounds); } object item = this.Items[dea.Index]; int xPos = dea.Bounds.X; //绘制下拉项目 string typeString = String.Empty; if (item is UIElement) { UIElement site = item as UIElement; if (site != null) { string name = site.FullCode; using (Font f = new Font(this.Font, FontStyle.Bold)) { g.DrawString(name, f, stringColor, xPos, dea.Bounds.Y); xPos += (int)g.MeasureString(name + "-", f).Width; } //TODO:因为数据列不在FormElementEntityTypes中,所 以数据列的类型名子获取不能 //见FormElementEntityTypeCollection 182行 typeString = "(" + site.Name + ") " + FormElementEntityDevTypes.Instance.GetName(site); } } else if (item is EnumSystemDataSource) { EnumSystemDataSource systemDataSourrce = (EnumSystemDataSource)item; string name = systemDataSourrce.ToString(); using (Font f = new Font(this.Font, FontStyle.Bold)) { g.DrawString(name, f, stringColor, xPos, dea.Bounds.Y); xPos += (int)g.MeasureString(name + "-", f).Width; } typeString = EnumDescConverter.Get(typeof(EnumSystemDataSource)).Select( "Value = '" + Convert.ToInt32(systemDataSourrce) + "'")[0]["Text"].ToString(); } // string typeString = item.GetType().ToString(); g.DrawString(typeString, this.Font, stringColor, xPos, dea.Bounds.Y); }