/// <summary> /// 获取皮肤信息 /// </summary> /// <returns></returns> private static Dictionary <int, EnumInfo> GetSkin() { List <EnumInfo> lstInfo = EnumUnit.GetEnumInfos(typeof(DialogSkin)); Dictionary <int, EnumInfo> dic = CommonMethods.ListToDictionary <int, EnumInfo>(lstInfo, "Value"); return(dic); }
/// <summary> /// 获取GridView的数据的排序方式 /// </summary> /// <param name="gv">GridView</param> /// <param name="lstSort">排序</param> /// <returns></returns> protected virtual string GetGridViewOrderString(GridView gv) { SortList lstSort = new SortList(); FillOrderBy(gv.ClientID, lstSort); StringBuilder sbRet = new StringBuilder(); foreach (Sort objSort in lstSort) { string name = objSort.PropertyName; foreach (DataControlField col in gv.Columns) { if (name == col.SortExpression) { sbRet.Append(col.HeaderText); sbRet.Append("-"); sbRet.Append(EnumUnit.GetEnumDescription(objSort.SortType)); sbRet.Append(","); } } } if (sbRet.Length > 0) { sbRet.Remove(sbRet.Length - 1, 1); } return(sbRet.ToString()); }
private void BindKeys(ComboBox cmb) { List <EnumInfo> lstKeys = EnumUnit.GetEnumInfos(typeof(Keys)); cmb.Items.Clear(); List <ComboBoxItem> lstValue = new List <ComboBoxItem>(); foreach (EnumInfo info in lstKeys) { int val = (int)info.Value; if (val >= 48 && val <= 120) { string name = info.FieldName; if (name.Length == 2 && name[0] == 'D') { name = name.Substring(1); } ComboBoxItem item = new ComboBoxItem(name, (int)info.Value); lstValue.Add(item); } } cmb.DisplayMember = "FieldName"; cmb.ValueMember = "Value"; cmb.DataSource = lstValue; }
private void BindModifiers(ComboBox cmb) { List <EnumInfo> lstModifiers = EnumUnit.GetEnumInfos(typeof(KeyModifiers)); cmb.Items.Clear(); List <ComboBoxItem> lstValue = new List <ComboBoxItem>(); foreach (EnumInfo info in lstModifiers) { string name = info.FieldName; if (name == "Control") { name = "Ctrl"; } else if (name == "Windows" || name == "All") { continue; } ComboBoxItem item = new ComboBoxItem(name, (int)info.Value); lstValue.Add(item); } cmb.DisplayMember = "FieldName"; cmb.ValueMember = "Value"; cmb.DataSource = lstValue; }
/// <summary> /// 初始化缓存类型 /// </summary> private void InitLazyType() { cmbLazy.DisplayMember = "Description"; cmbLazy.ValueMember = "Value"; List <EnumInfo> lst = EnumUnit.GetEnumInfos(typeof(LazyType)); cmbLazy.DataSource = lst; }
/// <summary> /// 填充数据层实际类型 /// </summary> /// <param name="rowIndex"></param> private void FillDBRealType(int rowIndex) { int len = Convert.ToInt32(gvField.Rows[rowIndex].Cells["ColLength"].Value); DbType type = (DbType)EnumUnit.GetEnumInfoByName(typeof(DbType), gvField.Rows[rowIndex].Cells["ColParamType"].Value.ToString()).Value; gvField.Rows[rowIndex].Cells["DBRealType"].Value = _ida.DBTypeToSQL(type, len); }
private void ShowPower(EnumUnit unit) //这个监控是两个一起监控 { StringBuilder sb = new StringBuilder(); sb.Clear(); sb.Append(Math.Round(Pw1000USB_1.GetPowerValue(unit), 3).ToString()); sb.Append(" "); sb.Append(unit.ToString()); sb.Append(","); sb.Append(Math.Round(Pw1000USB_2.GetPowerValue(unit), 3).ToString()); sb.Append(unit.ToString()); Messenger.Default.Send(new Tuple <string, string, string>(cfg.Name, "ShowPower", sb.ToString()), "WorkFlowMessage"); }
/// <summary> /// 填充注释设置 /// </summary> private void FillSummary() { List <EnumInfo> infos = EnumUnit.GetEnumInfos(typeof(SummaryShowItem)); foreach (EnumInfo info in infos) { if (info.FieldName != "All") { ComboBoxItem item = new ComboBoxItem(info.Description, (int)info.Value); clbSummary.Items.Add(item); } } }
private void BindKeys() { List <EnumInfo> lstModifiers = EnumUnit.GetEnumInfos(typeof(KeyModifiers)); cmbModifiers.Items.Clear(); List <ComboBoxItem> lstValue = new List <ComboBoxItem>(); foreach (EnumInfo info in lstModifiers) { string name = info.FieldName; if (name == "Control") { name = "Ctrl"; } else if (name == "Windows" || name == "All") { continue; } ComboBoxItem item = new ComboBoxItem(name, (int)info.Value); lstValue.Add(item); } cmbModifiers.DisplayMember = "FieldName"; cmbModifiers.ValueMember = "Value"; cmbModifiers.DataSource = lstValue; List <EnumInfo> lstKeys = EnumUnit.GetEnumInfos(typeof(Keys)); cmbKeys.Items.Clear(); lstValue = new List <ComboBoxItem>(); foreach (EnumInfo info in lstKeys) { int val = (int)info.Value; if (val >= 48 && val <= 120) { string name = info.FieldName; if (name.Length == 2 && name[0] == 'D') { name = name.Substring(1); } ComboBoxItem item = new ComboBoxItem(name, (int)info.Value); lstValue.Add(item); } } cmbKeys.DisplayMember = "FieldName"; cmbKeys.ValueMember = "Value"; cmbKeys.DataSource = lstValue; }
/// <summary> /// 转换成字段信息 /// </summary> /// <returns></returns> public EntityParam ToParamInfo() { EntityParam ep = new EntityParam(); ep.FieldName = FieldName; ep.Description = Summary; ep.ParamName = ParamName; ep.PropertyName = PropertyName; ep.SqlType = (DbType)EnumUnit.GetEnumInfoByName(typeof(DbType), DbType).Value; ep.PropertyType = EntityPropertyType; //ep.AllowNull = IsNullProperty(_fInfo.MemberTypeShortName); ep.AllowNull = AllowNull; ep.ReadOnly = ReadOnly; ep.Description = Description; return(ep); }
public double GetPowerValue(EnumUnit unit) { int err = tlpm.measPower(out double value); if (err == 0) { int n = 1; switch (unit) { case EnumUnit.mW: n = 1000; break; case EnumUnit.μW: n = 1000000; break; } return(value * n); } return(0.0f); }
/// <summary> /// 填充字段信息 /// </summary> /// <param name="entity"></param> /// <param name="lstParam"></param> private void FillParams(EntityConfig entity, List <EntityParam> lstParam, List <TableRelationAttribute> lstRelation) { foreach (EntityParamField param in entity.EParamFields) { if (!param.IsGenerate) { continue; } DbType dbt = (DbType)EnumUnit.GetEnumInfoByName(typeof(DbType), param.DbType).Value; EntityParam pInfo = new EntityParam("", param.ParamName, "", dbt, param.EntityPropertyType, param.Summary, param.Length, param.AllowNull, param.ReadOnly); lstParam.Add(pInfo); } foreach (EntityRelationItem relation in entity.ERelation) { if (relation.IsToDB && relation.IsGenerate && relation.IsParent) { EntityConfig parent = new EntityConfig(relation.FInfo.MemberType, DesignerInfo); if (parent == null) { continue; } EntityParamField childProperty = entity.GetParamInfoByPropertyName(relation.SourceProperty); if (childProperty == null) { continue; } EntityParamField parentProperty = parent.GetParamInfoByPropertyName(relation.TargetProperty); if (parentProperty == null) { continue; } lstRelation.Add(new TableRelationAttribute("", "", entity.TableName, parent.TableName, childProperty.ParamName, parentProperty.ParamName, "", relation.IsParent)); } } }
public double GetPowerValue(EnumUnit unit) { string strValue = Query("READ?").ToString(); if (double.TryParse(strValue, out double value)) { int n = 1; switch (unit) { case EnumUnit.mW: n = 1000; break; case EnumUnit.μW: n = 1000000; break; } return(value * n); } return(0.0f); }
/// <summary> /// 初始化属性 /// </summary> private void InitPropertys() { _lstProperty = new List <UIModelItem>(); List <ClrProperty> lstClrProperty = EntityConfig.GetAllMember <ClrProperty>(_classType, true); EntityConfig entity = new EntityConfig(_classType, DesignerInfo); Stack <EntityConfig> stkEntity = EntityConfig.GetEntity(entity, DesignerInfo); foreach (ClrProperty property in lstClrProperty) { UIModelItem item = new UIModelItem(property); EntityParamField finfo = EntityConfig.FindParamInfoByName(stkEntity, item.PropertyName); if (finfo != null) { bool isPK = EnumUnit.ContainerValue((int)finfo.EntityPropertyType, (int)EntityPropertyType.PrimaryKey); TableInfo tinfo = new TableInfo(isPK, finfo.ParamName, finfo.Length, finfo.ReadOnly, (DbType)EnumUnit.GetEnumInfoByName(typeof(DbType), finfo.DbType).Value); item.TabInfo = tinfo; } else { EntityRelationItem rel = EntityConfig.FindRelInfoByName(stkEntity, item.PropertyName); if (rel != null) { RelationInfo rinfo = new RelationInfo(rel.TargetProperty, rel.SourceProperty, rel.IsParent, rel.TypeName, rel.TypeFullName); item.RelInfo = rinfo; } } _lstProperty.Add(item); } }
// Methods public override void DoPaint(DiagramPaintEventArgs e, ShapeElement parentShape) { base.DoPaint(e, parentShape); Font font = this.GetFont(e.View); CDCompartment compartment = parentShape as CDCompartment; if (compartment != null) { ListField listField = null; foreach (ShapeField field2 in compartment.ShapeFields) { if (field2 is ListField) { listField = field2 as ListField; break; } } float MemberLineHeight = (float)listField.GetItemHeight(parentShape); float MemberStartMargin = 0f; float stringMargin = 0.02f; if (listField != null) { int itemCount = compartment.GetItemCount(listField); for (int i = 0; i < itemCount; i++) { ItemDrawInfo itemDrawInfo = new ItemDrawInfo(); MemberStartMargin = (float)listField.GetItemRectangle(parentShape, i, 0).Y; compartment.GetItemDrawInfo(listField, i, itemDrawInfo); if (itemDrawInfo.Disabled) { continue; } string[] strArray = itemDrawInfo.Text.Split(new char[] { ':', '(', '{', '<' }); Member menberByName = this.GetMenberByName(parentShape.ParentShape, strArray[0].Trim()); if ((menberByName == null)) { continue; } string docSummary = menberByName.DocSummary; string genericTypeName = ""; genericTypeName = menberByName.MemberTypeShortName; BackBrush.Color = Color.White; VarBrush.Color = Color.Blue; ModifierBrush.Color = Color.Blue; NameBrush.Color = Color.Black; SummaryBrush.Color = Color.Green; SelectedShapesCollection seleShapes = this._FromAddin.SelectedShapes; if (seleShapes != null) { foreach (DiagramItem item in seleShapes) { if (((item.Shape == compartment) && (item.Field == listField)) && (item.SubField.SubFieldHashCode == i)) { this.BackBrush.Color = SystemColors.Highlight; VarBrush.Color = Color.White; NameBrush.Color = Color.White; SummaryBrush.Color = Color.White; ModifierBrush.Color = Color.White; break; } } } float recX = (float)itemDrawInfo.ImageMargin;//0.16435f RectangleD bound = parentShape.BoundingBox; float width = (float)bound.Width; //float MemberStartMargin = 0.26f; e.Graphics.FillRectangle(this.BackBrush, VSConfigManager.CurConfig.MemberMarginX, MemberStartMargin, width, MemberLineHeight); float curX = VSConfigManager.CurConfig.MemberMarginX; string memberTypeName = menberByName.MemberTypeName.TrimEnd('?', '[', ']'); if (BackBrush.Color == Color.White)//非选中状态 { if ((memberTypeName != "void") && (menberByName.MemberTypeLookupName == memberTypeName)) { VarBrush.Color = Color.DodgerBlue; } //if (!menberByName.IsSpecialName) //{ // VarBrush.Color = Color.DodgerBlue; //} } string curStr = null; if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.TypeName)) { if (menberByName.IsStatic) { curStr = "static"; e.Graphics.DrawString(curStr, font, ModifierBrush, curX, MemberStartMargin + stringMargin); curX += e.Graphics.MeasureString(curStr, font).Width; } curStr = genericTypeName + " "; e.Graphics.DrawString(curStr, font, this.VarBrush, curX, MemberStartMargin + stringMargin); curX += e.Graphics.MeasureString(curStr, font).Width; } if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.MemberName)) { curStr = menberByName.Name; if (menberByName is ClrMethod) { curStr += "()"; } e.Graphics.DrawString(curStr, font, this.NameBrush, curX, MemberStartMargin + stringMargin); curX += e.Graphics.MeasureString(curStr, font).Width; } if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.Summary)) { if (!string.IsNullOrEmpty(curStr)) { curStr = ":"; } else { curStr = ""; } curStr += HttpUtility.HtmlDecode(docSummary); e.Graphics.DrawString(curStr, font, this.SummaryBrush, curX, MemberStartMargin + stringMargin); } } } } }
// Methods public override void DoPaint(DiagramPaintEventArgs e, ShapeElement parentShape) { base.DoPaint(e, parentShape); Font font = this.GetFont(e.View); CDCompartment compartment = parentShape as CDCompartment; if (compartment != null) { ListField listField = null; foreach (ShapeField field2 in compartment.ShapeFields) { if (field2 is ListField) { listField = field2 as ListField; break; } } float MemberLineHeight = (float)listField.GetItemHeight(parentShape); if (listField != null) { int itemCount = compartment.GetItemCount(listField); for (int i = 0; i < itemCount; i++) { ItemDrawInfo itemDrawInfo = new ItemDrawInfo(); compartment.GetItemDrawInfo(listField, i, itemDrawInfo); if (!itemDrawInfo.Disabled) { string[] strArray = itemDrawInfo.Text.Split(new char[] { ':', '(', '{' }); Member menberByName = this.GetMenberByName(parentShape.ParentShape, strArray[0].Trim()); if ((menberByName != null)) { string docSummary = menberByName.DocSummary; this.BackBrush.Color = Color.White; this.SummaryBrush.Color = Color.Green; this.NameBrush.Color = Color.Black; SelectedShapesCollection seleShapes = this._FromAddin.SelectedShapes; if (seleShapes != null) { foreach (DiagramItem item in seleShapes) { if (((item.Shape == compartment) && (item.Field == listField)) && (item.SubField.SubFieldHashCode == i)) { this.BackBrush.Color = SystemColors.Highlight; this.SummaryBrush.Color = Color.White; this.NameBrush.Color = Color.White; break; } } } float height = 0.19f; float recX = (float)itemDrawInfo.ImageMargin;//0.16435f RectangleD bound = parentShape.BoundingBox; float width = (float)bound.Width; e.Graphics.FillRectangle(this.BackBrush, 0f, (0f + MemberLineHeight * (float)i), width, MemberLineHeight); DBConfigInfo dbInfo = DBConfigInfo.LoadInfo(_FromAddin.GetDesignerInfo()); string curStr = null; float curX = 0f; if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.MemberName)) { curStr = menberByName.Name; e.Graphics.DrawString(curStr, font, this.NameBrush, curX, (0f + MemberLineHeight * (float)i + 0.02f)); curX += e.Graphics.MeasureString(curStr, font).Width; } if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.Summary)) { if (!string.IsNullOrEmpty(curStr)) { curStr = ":"; } else { curStr = ""; } curStr += HttpUtility.HtmlDecode(menberByName.DocSummary); e.Graphics.DrawString(curStr, font, this.SummaryBrush, curX, (0f + MemberLineHeight * (float)i + 0.02f)); } } } } } } }
public string DisplayInfo(KeyWordInfomation info, string tableName) { StringBuilder sb = new StringBuilder(); IDBAdapter idba = info.DBInfo.CurrentDbAdapter; bool isPrimary = EnumUnit.ContainerValue((int)_propertyType, (int)EntityPropertyType.PrimaryKey); bool isAutoIdentity = EnumUnit.ContainerValue((int)_propertyType, (int)EntityPropertyType.Identity); bool needIdentity = false; bool putType = true; sb.Append(idba.FormatParam(ParamName) + " "); if (isAutoIdentity && TableChecker.IsIdentityType(SqlType)) { if (idba.IdentityIsType) { sb.Append(idba.DBIdentity(tableName, _paramName)); sb.Append(" "); putType = false; } else { needIdentity = true; } } if (putType) { sb.Append(idba.DBTypeToSQL(SqlType, Length) + " "); } bool allowNULL = _allowNull & (!isPrimary); //if (isPrimary) //{ // sb.Append(" primary key "); //} //else //{ if (isPrimary && info.PrimaryKeys == 1) { sb.Append(" PRIMARY KEY "); } else { if (allowNULL) { sb.Append("NULL "); } else { sb.Append("NOT NULL "); } } //} if (needIdentity && isAutoIdentity && TableChecker.IsIdentityType(SqlType)) { sb.Append(idba.DBIdentity(tableName, _paramName)); } string comment = idba.GetColumnDescriptionSQL(this, info.DBInfo); if (!string.IsNullOrEmpty(comment)) { sb.Append(" "); sb.Append(comment); } return(sb.ToString()); }