public StoredVulnInfo ClonePossibleStored(ValueInfo valInfo) { return new StoredVulnInfo() { ICantFeelIt = valInfo.PossibleStoredTaint.ICantFeelIt, StorageName = valInfo.PossibleStoredTaint.StorageName, StorageOrigin = valInfo.PossibleStoredTaint.StorageOrigin, Taint = valInfo.NestedVariablePossibleStoredDefaultTaintFactory() }; }
/// <summary> /// Validate /// </summary> public override void Validate(ValueInfo info) { var doubleValue = (double)Convert.ChangeType(info.Value, typeof(double)); if (doubleValue <= Number) { throw new ValidationException("{0}: {1} is not more than {2}".FormatWith( info.Name, info.Value, Number)); } }
public static ValueInfo AnalyzeBlock(ValueInfo block) { if (block.Block.AstEntryNode == null) return null; if (VarInfoStorage.ContainsKey(block.Block)) { return VarInfoStorage[block.Block]; } // type, value, arraytree var astNode = block.Block.AstEntryNode; VarInfoStorage.Add(block.Block, block); return block; }
public void Validate(ValueInfo info) { string path = string.Empty; if (info.Value is Uri) { path = ((Uri)info.Value).LocalPath; } else { path = Environment.ExpandEnvironmentVariables((string)info.Value); } if (!Directory.Exists(path)) { throw new ValidationException("{0}: '{1}' is not an existing directory".FormatWith( info.Name, path)); } }
public SchedulingGenome(SchedulingGenomePopulation population) { this.population = population; this.scheduler = population.Scheduler; int maxSchedulingSteps = InstructionNodes.Count; schedule = new InstructionNode[ maxSchedulingSteps, MachineDescription.ExecutionUnits]; instructionInfos = new Hashtable(InstructionNodes.Count); foreach (InstructionNode iNode in InstructionNodes) instructionInfos[iNode] = new InstructionInfo(); valueInfos = new Hashtable(RegisterValues.Count); foreach (ValueNode vNode in RegisterValues) valueInfos[vNode] = new ValueInfo(); isValid = false; generationOfBirth = population.GA.Generation; }
public CreateTableStatement(ValueInfo valueInfo) : this(valueInfo.Name) { AddColumns(valueInfo.Elements); }
protected void AddValueDeleteStatement(IValue value, ValueInfo valueInfo) { var builder = new ComplexCommandBuilder(); var idParameter = value.Id.ToParameter(); builder.AddParameter(idParameter); var whereClause = string.Format("{0}.{1} = {2}", valueInfo.Name, valueInfo.Identifer.Name, idParameter.Name); var statement = new DeleteStatement(valueInfo.Name, whereClause); builder.AddStatement(statement); Add(builder); }
public static RegistryValueInfo[] GetValues(RegistryHive hive, string path) { ValueInfo[] ret = new ValueInfo[] { }; uint error = 0; try { if (!NativeRegistry.GetValues((global::Registry.RegistryHive)hive, path, out ret)) { error = NativeRegistry.GetError(); } } catch (Exception ex) { error = (uint)ex.HResult; } LastError = error; if (ret == null) { return new RegistryValueInfo[] { }; } RegistryValueInfo[] ret2 = new RegistryValueInfo[ret.Length]; for (int i = 0; i < ret.Length; i++) { ret2[i].Length = ret[i].Length; ret2[i].Name = ret[i].Name; ret2[i].Type = (RegistryType)ret[i].Type; } return ret2; }
private void RunSync(IReadOnlyList <object> argumentValues) { // Defines arguments. for (var i = 0; i < _methodDeclaration.Arguments.Count; i++) { var argumentDeclaration = _methodDeclaration.Arguments[i]; var variableDeclaration = new VariableDeclaration(argumentDeclaration.Name.Identifier, argumentDeclaration.IsArray) { Id = argumentDeclaration.Id, Line = argumentDeclaration.Line, Column = argumentDeclaration.Column, StartOffset = argumentDeclaration.StartOffset, NodeLength = argumentDeclaration.NodeLength }; var variableRef = new VariableReferenceExpression(variableDeclaration) { VariableDeclarationID = argumentDeclaration.Id, Line = argumentDeclaration.Line, Column = argumentDeclaration.Column, StartOffset = argumentDeclaration.StartOffset, NodeLength = argumentDeclaration.NodeLength }; AddVariable(variableDeclaration, searchInParents: false); SetVariable(variableRef, argumentValues[i]); } if (IsAborted) { return; } // Execute statements var block = new BlockInterpreter(BaZicInterpreter, this, ExecutionFlowId, false, null, _methodDeclaration.Statements); block.Run(); if (BaZicInterpreter.Verbose && !IsAborted) { VerboseLog(L.BaZic.Runtime.Interpreters.MethodInterpreter.FormattedEndExecution(_invokeMethod.MethodName, ReturnedValue, ValueInfo.GetValueInfo(ReturnedValue))); } foreach (var variable in Variables) { if (DebugCallInfo.Variables.Remove(variable)) { variable.Dispose(); } } DebugCallInfo = null; if (!_invokeMethod.Await && _methodDeclaration.IsAsync) { GC.Collect(); GC.WaitForPendingFinalizers(); } }
public RangeValue(TValue value, ValueInfo valueInfo) { Value = value; ValueInfo = valueInfo; }
private ExpressionInfo Expr_Array(XmlNode node) { var arrayItems = node.GetSubNode(AstConstants.Subnode + ":" + AstConstants.Subnodes.Items) .GetSubNode(AstConstants.Scalar + ":" + AstConstants.Scalars.Array) .GetSubnodes(AstConstants.Node + ":" + AstConstants.Nodes.Expr_ArrayItem); var varInfo = new ValueInfo(); foreach (var arrayItem in arrayItems) { var info = Handle_Expr_ArrayItem(arrayItem); var arrayVar = new Variable(info.Item1.ToString(), VariableScope.Instance) { Info = info.Item2 }; varInfo.Variables[info.Item1] = arrayVar; } return new ExpressionInfo() { ExpressionTaint = new TaintSets(), ValueInfo = varInfo }; }
public static string Builder(ValueInfo valueInfo) { return(Builder(valueInfo.Data, valueInfo.IsArray)); }
private void GetImageAndStrSize(Graphics drawZoonGraphic,RectangleF drawRect, ValueInfo valueInfo, float oneSwitchHeight, float oldImageHeight, out float imageSize, out SizeF strSize, out bool isDrawStr) { imageSize = 0; strSize = SizeF.Empty; isDrawStr = true; if (!valueInfo.IsValid) { isDrawStr = false; strSize.Width = 0; } else { strSize = GetStrSize(drawZoonGraphic, valueInfo.Value.ToString()); } if (strSize.Height > oneSwitchHeight || strSize.Width + ImageAndStrInterval * 3 > drawRect.Width) { isDrawStr = false; strSize.Width = 0; } float imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 3; imageSize = Math.Min(imageWidth, oldImageHeight); if (imageSize < MinImageSize) { isDrawStr = false; strSize.Width = 0; imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 2; imageSize = Math.Min(imageWidth, oldImageHeight); } if (imageSize < 0) { imageSize = 0; } }
//note: the value is unescaped, so offsets within it are not valid void VisitPureLiteral(ValueInfo info, MSBuildValueKind kind, string value, int offset) { IReadOnlyList <ConstantInfo> knownVals = info.Values ?? kind.GetSimpleValues(false); if (knownVals != null && knownVals.Count != 0) { foreach (var kv in knownVals) { if (string.Equals(kv.Name, value, StringComparison.OrdinalIgnoreCase)) { return; } } AddError($"Unknown value '{value}'"); return; } switch (kind) { case MSBuildValueKind.Guid: case MSBuildValueKind.ProjectKindGuid: if (!Guid.TryParseExact(value, "B", out _)) { AddError("Invalid GUID value"); } break; case MSBuildValueKind.Int: if (!long.TryParse(value, out _)) { AddError("Invalid integer value"); } break; case MSBuildValueKind.Bool: if (!bool.TryParse(value, out _)) { AddError("Invalid boolean value"); } break; case MSBuildValueKind.Url: if (!Uri.TryCreate(value, UriKind.Absolute, out _)) { AddError("Invalid URL"); } break; case MSBuildValueKind.Version: if (!Version.TryParse(value, out _)) { AddError("Invalid version"); } break; case MSBuildValueKind.TargetName: if (Document.GetSchemas().GetTarget(value) == null) { AddWarning("Target is not defined"); } break; case MSBuildValueKind.PropertyName: if (Document.GetSchemas().GetProperty(value) == null) { AddWarning("Unknown property name"); } break; case MSBuildValueKind.ItemName: if (Document.GetSchemas().GetItem(value) == null) { AddWarning("Unknown item name"); } break; case MSBuildValueKind.Lcid: if (int.TryParse(value, out int lcid) && lcid > 0) { try { CultureInfo.GetCultureInfo(lcid); } catch (CultureNotFoundException) { AddError("Unknown LCID"); } } else { AddError("Invalid LCID"); } break; } void AddError(string e) => this.AddError(e, offset, value.Length); void AddWarning(string e) => this.AddWarning(e, offset, value.Length); }
/// <summary> /// 绘制一个串口的发送卡 /// </summary> /// <param name="drawX">绘制的X</param> /// <param name="drawY">绘制的Y</param> /// <param name="commPort">串口名称</param> /// <param name="drawGraphics">绘制Graphics</param> private void DrawOneCommPortSender(int drawX, int drawY, string commPort, Graphics drawGraphics) { if (_curAllSenderStatusDic == null || !_curAllSenderStatusDic.ContainsKey(commPort) || _curAllSenderStatusDic[commPort] == null || _curAllSenderStatusDic[commPort].Count <= 0) { return; } Point lineStart = Point.Empty; Point lineEnd = Point.Empty; drawGraphics.DrawImage(Properties.Resources.CommPort, drawX, drawY, OneCommPortInfoImagePixel, OneCommPortInfoImagePixel); lineStart.X = drawX + OneCommPortInfoImagePixel; lineStart.Y = drawY + OneCommPortInfoImagePixel / 2; lineEnd.X = lineStart.X + CommPortLineLength; lineEnd.Y = lineStart.Y; drawGraphics.DrawLine(CommPortLinePen, lineStart, lineEnd); SizeF stringSizeF = drawGraphics.MeasureString(commPort, _commPortFont); drawGraphics.DrawString(commPort, _commPortFont, CommPortStrBrush, new PointF(lineStart.X, lineStart.Y - stringSizeF.Height)); Rectangle senderRect = new Rectangle(lineEnd.X, drawY + SenderSizeOffset / 2, OneCommPortInfoImagePixel - SenderSizeOffset, OneCommPortInfoImagePixel - SenderSizeOffset); int senderCnt = _curAllSenderStatusDic[commPort].Count; string indexStr = ""; PointF strPointF; SenderInfo senderGridInfo = null; List <SenderInfo> senderGridInfoList = new List <SenderInfo>(); WorkStatusType status = WorkStatusType.Unknown; ValueInfo tempRefreshReate; for (byte i = 0; i < senderCnt; i++) { if (i > 0) { senderRect.X += SenderConnectLineLength + OneCommPortInfoImagePixel - SenderSizeOffset; } status = _curAllSenderStatusDic[commPort][i]; if (status == WorkStatusType.OK) { SenderBrush = new SolidBrush(Color.Green); } else if (status == WorkStatusType.Error) { SenderBrush = new SolidBrush(Color.Yellow); } else if (status == WorkStatusType.SenderCardError) { SenderBrush = new SolidBrush(Color.DarkOrange); } else { SenderBrush = new SolidBrush(Color.Gray); } tempRefreshReate = new ValueInfo(); if (_curAllSenderRefreshDic == null || !_curAllSenderRefreshDic.ContainsKey(commPort) || _curAllSenderRefreshDic[commPort] == null || i >= _curAllSenderRefreshDic[commPort].Count) { tempRefreshReate.IsValid = false; } else { tempRefreshReate.IsValid = _curAllSenderRefreshDic[commPort][i].IsValid; tempRefreshReate.Value = _curAllSenderRefreshDic[commPort][i].Value; } drawGraphics.FillRectangle(SenderBrush, senderRect); drawGraphics.DrawRectangle(SenderBoarderAndLinePen, senderRect); indexStr = (i + 1).ToString(); stringSizeF = drawGraphics.MeasureString(indexStr, _senderStrFont); strPointF = new PointF(senderRect.X + (senderRect.Width - stringSizeF.Width) / 2, senderRect.Y + (senderRect.Height - stringSizeF.Height) / 2); drawGraphics.DrawString(indexStr, _senderStrFont, SenderIndexBrush, strPointF); RedundantStateType rState = RedundantStateType.Unknown; float weightCount = senderRect.Width; if (_commPortData.ContainsKey(commPort) && _commPortData[commPort] > 0) { weightCount = senderRect.Width / (float)_commPortData[commPort]; } float heightCount = (float)senderRect.Width / 4 * 3; PointF newPoint = senderRect.Location; PointF startPoint = new PointF(0, 0); PointF endPoint = new PointF(0, 0); PointF[] pointList = new PointF[4]; int step = 0; int masterSender = SenderConnectLineLength + OneCommPortInfoImagePixel - SenderSizeOffset; if (_tempRedundancyDict != null && _tempRedundancyDict.ContainsKey(commPort) && _tempRedundancyDict[commPort] != null && _commPortData.ContainsKey(commPort) && _redundantStateType.ContainsKey(commPort) && _redundantStateType[commPort] != null && _redundantStateType[commPort].Count > 0) { for (int j = 0; j < _commPortData[commPort]; j++) { if (j >= _redundantStateType[commPort][i].RedundantStateTypeList.Count) { rState = RedundantStateType.Unknown; } else { rState = _redundantStateType[commPort][i].RedundantStateTypeList[j]; } if (rState == RedundantStateType.OK) { SenderBrush = new SolidBrush(Color.Green); CommPortLine.Color = Color.Green; step += 4; } else if (rState == RedundantStateType.Error) { CommPortLine.Color = Color.Red; if (_tempRedundancyDict.ContainsKey(commPort)) { for (int k = 0; k < _tempRedundancyDict[commPort].Count; k++) { SenderRedundancyInfo senderInfo = _tempRedundancyDict[commPort][k]; if (senderInfo.SlaveSenderIndex == i && senderInfo.SlavePortIndex == j) { SenderBrush = new SolidBrush(Color.Yellow); break; } else { SenderBrush = new SolidBrush(Color.Green); } } } step += 4; } else { CommPortLine.Color = Color.Gray; SenderBrush = new SolidBrush(Color.Gray); step += 4; } RectangleF portRect = new RectangleF(newPoint.X + weightCount * j, newPoint.Y + heightCount, weightCount, senderRect.Height / 4); drawGraphics.FillRectangle(SenderBrush, portRect); if (_tempRedundancyDict.ContainsKey(commPort)) { for (int k = 0; k < _tempRedundancyDict[commPort].Count; k++) { SenderRedundancyInfo senderInfo = _tempRedundancyDict[commPort][k]; if (senderInfo.SlaveSenderIndex == i && senderInfo.SlavePortIndex == j) { pointList[0] = new PointF(newPoint.X + weightCount * j + weightCount / 2, newPoint.Y + senderRect.Height); pointList[1] = new PointF(newPoint.X + weightCount * j + weightCount / 2, newPoint.Y + senderRect.Height + step); if (senderInfo.MasterSenderIndex > senderInfo.SlaveSenderIndex) { pointList[2] = new PointF(newPoint.X + masterSender + weightCount * senderInfo.MasterPortIndex + weightCount / 2, newPoint.Y + senderRect.Height + step); pointList[3] = new PointF(newPoint.X + masterSender + weightCount * senderInfo.MasterPortIndex + weightCount / 2, newPoint.Y + senderRect.Height); } else if (senderInfo.MasterSenderIndex < senderInfo.SlaveSenderIndex) { pointList[2] = new PointF(newPoint.X - masterSender + weightCount * senderInfo.MasterPortIndex + weightCount / 2, newPoint.Y + senderRect.Height + step); pointList[3] = new PointF(newPoint.X - masterSender + weightCount * senderInfo.MasterPortIndex + weightCount / 2, newPoint.Y + senderRect.Height); } else { pointList[2] = new PointF(newPoint.X + weightCount * senderInfo.MasterPortIndex + weightCount / 2, newPoint.Y + senderRect.Height + step); pointList[3] = new PointF(newPoint.X + weightCount * senderInfo.MasterPortIndex + weightCount / 2, newPoint.Y + senderRect.Height); } drawGraphics.DrawLines(CommPortLine, pointList); if (rState == RedundantStateType.Error) { PointF centerPoint = new PointF(pointList[2].X + (pointList[1].X - pointList[2].X) / 2, pointList[1].Y); startPoint = new PointF(centerPoint.X - 4, centerPoint.Y - 4); endPoint = new PointF(centerPoint.X + 4, centerPoint.Y + 4); drawGraphics.DrawLine(CommPortLine, startPoint, endPoint); startPoint = new PointF(centerPoint.X - 4, centerPoint.Y + 4); endPoint = new PointF(centerPoint.X + 4, centerPoint.Y - 4); drawGraphics.DrawLine(CommPortLine, startPoint, endPoint); } break; } } } } CommPortLine.Color = Color.Black; for (int j = 1; j < _commPortData[commPort]; j++) { startPoint = new PointF(newPoint.X + weightCount * j, newPoint.Y + heightCount); endPoint = new PointF(newPoint.X + weightCount * j, newPoint.Y + senderRect.Height); drawGraphics.DrawLine(CommPortLine, startPoint, endPoint); } startPoint = new PointF(newPoint.X, newPoint.Y + heightCount); endPoint = new PointF(newPoint.X + senderRect.Width, newPoint.Y + heightCount); drawGraphics.DrawLine(CommPortLine, startPoint, endPoint); } if (i < senderCnt - 1) { lineStart.X = senderRect.Right; lineStart.Y = drawY + OneCommPortInfoImagePixel / 2; lineEnd.X = senderRect.Right + SenderConnectLineLength; lineEnd.Y = lineStart.Y; drawGraphics.DrawLine(SenderBoarderAndLinePen, lineStart, lineEnd); } senderGridInfo = new SenderInfo(); senderGridInfo.CommPort = commPort; senderGridInfo.SenderIndex = i; senderGridInfo.SenderRect = senderRect; senderGridInfo.Status = status; senderGridInfo.RefreshRateInfo = tempRefreshReate; if (_commPortData.ContainsKey(commPort) && _redundantStateType.ContainsKey(commPort) && i < _redundantStateType[commPort].Count) { for (int j = 0; j < _commPortData[commPort]; j++) { if (j < _redundantStateType[commPort][i].RedundantStateTypeList.Count) { senderGridInfo.RedundantStateTypeList.Add(j, _redundantStateType[commPort][i].RedundantStateTypeList[j]); } } } senderGridInfoList.Add(senderGridInfo); } _curAllSenderGridDic.Add(commPort, senderGridInfoList); }
public static (MSBuildDiagnosticDescriptor, object[]) GetExpressionError(ExpressionError error, ValueInfo info) { (MSBuildDiagnosticDescriptor, object[]) Return(MSBuildDiagnosticDescriptor desc, params object[] args) => (desc, args); return(error.Kind switch { ExpressionErrorKind.MetadataDisallowed => Return(MetadataDisallowed, DescriptionFormatter.GetKindNoun(info), info.Name), ExpressionErrorKind.EmptyListEntry => Return(EmptyListValue), ExpressionErrorKind.ExpectingItemName => Return(ExpectingItemName), ExpressionErrorKind.ExpectingRightParen => Return(ExpectingChars1, ')'), ExpressionErrorKind.ExpectingRightParenOrPeriod => Return(ExpectingChars2, ')', '.'), ExpressionErrorKind.ExpectingPropertyName => Return(ExpectingPropertyName), ExpressionErrorKind.ExpectingMetadataName => Return(ExpectingMetadataName), ExpressionErrorKind.ExpectingMetadataOrItemName => Return(ExpectingMetadataOrItemName), ExpressionErrorKind.ExpectingRightAngleBracket => Return(ExpectingChars1, '>'), ExpressionErrorKind.ExpectingRightParenOrDash => Return(ExpectingChars2, ')', '-'), ExpressionErrorKind.ItemsDisallowed => Return(ItemsDisallowed, DescriptionFormatter.GetKindNoun(info), info.Name), ExpressionErrorKind.ExpectingMethodOrTransform => Return(ExpectingFunctionOrTransform), ExpressionErrorKind.ExpectingMethodName => Return(ExpectingFunctionName), ExpressionErrorKind.ExpectingLeftParen => Return(ExpectingChars1, '('), ExpressionErrorKind.ExpectingRightParenOrComma => Return(ExpectingChars2, ')', ','), ExpressionErrorKind.ExpectingRightParenOrValue => Return(ExpectingRightParenOrValue), ExpressionErrorKind.ExpectingValue => Return(ExpectingValue), ExpressionErrorKind.CouldNotParseNumber => Return(CouldNotParseNumber), ExpressionErrorKind.IncompleteValue => Return(IncompleteValue), ExpressionErrorKind.ExpectingBracketColonColon => Return(ExpectingChars1, "]::"), ExpressionErrorKind.ExpectingClassName => Return(ExpectingClassName), ExpressionErrorKind.ExpectingClassNameComponent => Return(IncompleteClassName), ExpressionErrorKind.IncompleteString => Return(IncompleteString), ExpressionErrorKind.IncompleteProperty => Return(IncompleteProperty) });
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public async Task SetValueAsync <T> (IPropertyInfo property, ValueInfo <T> value, PropertyVariation variation = null) { if (variation != null) { throw new NotSupportedException(); // TODO } value = new ValueInfo <T> { CustomExpression = value.CustomExpression, Source = value.Source, ValueDescriptor = value.ValueDescriptor, Value = value.Value }; if (value.Source != ValueSource.Local && ValueEvaluator != null) { value.Value = (T)ValueEvaluator(property, value.ValueDescriptor); } else if (value.Source == ValueSource.Unset || (property.ValueSources.HasFlag(ValueSources.Default) && Equals(value.Value, default(T))) && value.ValueDescriptor == null) { this.values.Remove(property); PropertyChanged?.Invoke(this, new EditorPropertyChangedEventArgs(property)); return; } object softValue = value; if (typeof(T) != property.Type) { IPropertyConverter converter = property as IPropertyConverter; object v; if (converter != null && converter.TryConvert(value.Value, property.Type, out v)) { var softType = typeof(ValueInfo <>).MakeGenericType(property.Type); softValue = Activator.CreateInstance(softType); softType.GetProperty("Value").SetValue(softValue, v); softType.GetProperty("Source").SetValue(softValue, value.Source); } if (typeof(T).Name == "IReadOnlyList`1") { var list = (IReadOnlyList <int>)value.Value; int iv = 0; foreach (int flag in list) { iv |= flag; } softValue = new ValueInfo <int> { Value = iv, Source = value.Source }; } } // Set to resource won't pass values so we will store it on the info since we just pass it back in GetValue if (value.Source == ValueSource.Resource && value.ValueDescriptor is Resource) { var rt = value.ValueDescriptor.GetType(); if (rt.IsGenericType && typeof(T).IsAssignableFrom(rt.GetGenericArguments()[0])) { var pi = rt.GetProperty("Value"); value.Value = (T)pi.GetValue(value.ValueDescriptor); } } this.values[property] = softValue; PropertyChanged?.Invoke(this, new EditorPropertyChangedEventArgs(property)); }
/// <summary> /// Create field processing func /// </summary> internal Func <Expr, Dictionary <Attr.Col, object>, Expr> ModifyFieldExpr(SqlFuncPreprocessingCtx src, string targetDescrMask) { var maskPartsOnlyLocation = new string[4] { null, null, src.DefaultLocationForValueInfo, null }; string[] maskParts; if (targetDescrMask == null) { maskParts = maskPartsOnlyLocation; } else { maskParts = ValueInfo.FourParts(targetDescrMask); if (maskParts[2] == null) { maskParts[2] = src.DefaultLocationForValueInfo; } } string subst(string name, Dictionary <Attr.Col, object> attrs) { switch (name) { case nameof(START_TIME): src.isTimed = true; return(null); case nameof(END_TIME): case nameof(END_TIME__DT): case nameof(INS_OUTS_SEPARATOR): return(null); } bool isFixedAlias = attrs.GetBool(Attr.Col.FixedAlias); bool isPK = attrs.GetBool(Attr.Col.PK); var nameDescr = Combine(name, isFixedAlias ? maskPartsOnlyLocation : maskParts, isPK).descr; if (nameDescr.Length > 30) { throw new Generator.Exception($"Alias is too long: {nameDescr}, {nameDescr.Length}>30"); } string lkupDescr; if (attrs != null && attrs.TryGetValue(Attr.Col.Lookup, out var lookup)) { lkupDescr = ValueInfo.OverrideByMask(name, lookup.ToString()); } else { lkupDescr = nameDescr; lookup = null; } var vi = ValueInfo.Create(lkupDescr, true);//, src.ldr.defaultLocationForValueInfo); if (vi == null) { return(nameDescr); } //nameDescr = vi.ToString(); string lkupTable = null; if (templates.TryGetValue(vi.unit.Name, out var fields)) { // when templated by 'units', remove 'units' part var parts = ValueInfo.FourParts(lkupDescr); parts[2] = parts[3] = null; // remove location and units from lookup table name lkupTable = ValueInfo.FromParts(parts); parts = ValueInfo.FourParts(nameDescr); parts[3] = null; // remove units, needed only for templating purposes nameDescr = ValueInfo.FromParts(parts); } else if (templates.TryGetValue(vi.quantity.Name, out fields)) { lkupTable = lkupDescr; var parts = ValueInfo.FourParts(lkupDescr); parts[2] = null; // remove LOCATION part from lookup table name lkupTable = ValueInfo.FromParts(parts); } else if (lookup != null) { throw new KeyNotFoundException($"Can't found template table named '{vi.unit}' or {vi.quantity.Name} for lookup attribute '{lkupDescr}' of '{name}'"); } if (!isPK && fields.sql != null) { if (!extraFuncs.ContainsKey(lkupTable)) { AddExtraFunc(lkupTable, () => NewCodeLookupDict(src, fields, lkupTable, attrs)); } } return(nameDescr); } return((arg, attrs) => { string p = null; switch (arg.nodeType) { case ExprType.Alias: var ae = (AliasExpr)arg; if ((p = subst(ae.alias, attrs)) == null) { return arg; } return new AliasExpr(ae.expr, new ReferenceExpr(p)); case ExprType.Sequence: var args = ((SequenceExpr)arg).args; int n = args.Count; if ((p = subst(args[n - 1].ToString(), attrs)) == null) { return arg; } return new SequenceExpr(args.Take(n - 1).Concat(new[] { new ReferenceExpr(p) }).ToList()); case ExprType.Reference: var re = (ReferenceExpr)arg; if ((p = subst(re.name, attrs)) == null) { return arg; } return new AliasExpr(re, new ReferenceExpr(p)); default: return arg; } }); }
private static object GetInstance(ValueInfo valueInfo) { // Convert a ValueInfo to an actual object instance object instance = null; // First create the object if (valueInfo.ConstructorParams.Count == 0) { instance = valueInfo.Type == typeof(string) ? valueInfo.Value.Clone() : Activator.CreateInstance(valueInfo.Type); } else { Type[] paramTypeArray = valueInfo.ConstructorParams.Select(param => param.Type).ToArray(); ConstructorInfo constructor = valueInfo.Type.GetConstructor(paramTypeArray); if (constructor != null) instance = constructor.Invoke(valueInfo.ConstructorParams.Select(param => GetInstance(param)).ToArray()); } // Then set any properties foreach (Setter setter in valueInfo.Setters) { PropertyInfo propertyInfo = valueInfo.Type.GetProperty(setter.PropertyName, PropertyLookupType); if (instance == null) throw new InvalidOperationException("Could not find a property named '" + setter.PropertyName + "'."); if (setter.ValueInfo != null) propertyInfo.SetValue(instance, GetInstance(setter.ValueInfo), null); else if (setter.ListInfo != null) propertyInfo.SetValue(instance, GetInstance(setter.ListInfo), null); else throw new InvalidOperationException("Setter '" + setter.PropertyName + "' doesn't have a valueInfo, nor listInfo, specified. Must have one (and only one) of either."); } if (valueInfo.Setters.Count == 0 && valueInfo.Value != null) { // this is a built-in type and we need to go ahead and set the value // of the instance using the converter if(valueInfo.Converter.CanConvertTo(null, valueInfo.Type)) instance = valueInfo.Converter.ConvertTo(valueInfo.Value, valueInfo.Type); } return instance; }
public SelectStatement(ValueInfo valueInfo, IFilter filter, EntityInfo rootInfo, string rootIdAlias) { builder.AppendFormat("select distinct {0}.{1} {2} from {3}", rootInfo.Name, rootInfo.Identifier.Name, rootIdAlias, valueInfo.Name); var previousName = valueInfo.Name; var parent = valueInfo.Parent; while (parent != null) { builder.AppendFormat(" inner join {0} on {0}.Id = {1}.Parent", parent.Name, previousName); previousName = parent.Name; parent = parent.Parent; } if (!string.IsNullOrEmpty(filter.WhereClause)) builder.AppendFormat(" where {0}", filter.WhereClause.Trim()); if (valueInfo.Sequence != null) builder.AppendFormat(" order by {0}.{1}", valueInfo.Name, valueInfo.Sequence.Name); }
private void DrawImageAndStr(Graphics drawZoonGraphic, Image drawImage, ValueInfo valueInfo, RectangleF drawRect, float oneSwitchHeight, float imageSize, SizeF strSize, bool isDrawStr, int switchIndex) { float fRegionStartX = drawRect.X; float fRegionStartY = drawRect.Y; float fRegionEndX = drawRect.X + drawRect.Width; float fRegionEndY = drawRect.Y + drawRect.Height; RectangleF imageRectF = new RectangleF(fRegionStartX + ImageAndStrInterval, fRegionStartY + oneSwitchHeight * switchIndex + (oneSwitchHeight - imageSize) / 2, imageSize, imageSize); PointF lineStartPoint = new PointF(fRegionStartX, fRegionStartY + oneSwitchHeight * switchIndex); PointF lineEndPoint = new PointF(fRegionEndX, fRegionStartY + oneSwitchHeight * switchIndex); //���Ʊ��� drawZoonGraphic.FillRectangle(_switchBrush, fRegionStartX, fRegionStartY + oneSwitchHeight * switchIndex, drawRect.Width - DrawOffset, oneSwitchHeight); drawZoonGraphic.DrawImage(drawImage, imageRectF); if (switchIndex > 0) { drawZoonGraphic.DrawLine(_switchPen, lineStartPoint, lineEndPoint); } if (isDrawStr) { RectangleF strRectF = new RectangleF(fRegionStartX + imageSize + ImageAndStrInterval * 2, fRegionStartY + oneSwitchHeight * switchIndex, drawRect.Width - imageSize - ImageAndStrInterval * 2, oneSwitchHeight); DrawStrForLeft(drawZoonGraphic, valueInfo.Value.ToString(), strRectF); } }
/// <inheritdoc/> internal override void Run() { var methodInterpreter = ParentInterpreter.GetParentMethodInterpreter(); if (ParentInterpreter.IsAborted) { return; } var returnValue = ParentInterpreter.RunExpression(Statement.Expression); if (ParentInterpreter.IsAborted) { return; } methodInterpreter.ReturnedValue = returnValue; ParentInterpreter.State.ExitMethod = true; if (BaZicInterpreter.Verbose && !ParentInterpreter.IsAborted) { var valueString = methodInterpreter.ReturnedValue == null ? L.BaZic.Runtime.Debugger.ValueInfo.Null : $"{returnValue} ({ValueInfo.GetValueInfo(returnValue)})"; ParentInterpreter.VerboseLog(L.BaZic.Runtime.Interpreters.Statements.ReturnInterpreter.FormattedReturn(valueString)); } }
public static string GetMessage(this ExpressionErrorKind errorKind, ValueInfo info, out bool isWarning) { isWarning = false; switch (errorKind) { case ExpressionErrorKind.MetadataDisallowed: return($"{Name ()} does not allow metadata"); case ExpressionErrorKind.EmptyListEntry: isWarning = true; return($"Empty list value"); case ExpressionErrorKind.ExpectingItemName: return($"Expecting item name"); case ExpressionErrorKind.ExpectingRightParen: return($"Expecting ')'"); case ExpressionErrorKind.ExpectingRightParenOrPeriod: return($"Expecting ')' or '.'"); case ExpressionErrorKind.ExpectingPropertyName: return($"Expecting property name"); case ExpressionErrorKind.ExpectingMetadataName: return($"Expecting metadata name"); case ExpressionErrorKind.ExpectingMetadataOrItemName: return($"Expecting metadata or item name"); case ExpressionErrorKind.ExpectingRightAngleBracket: return($"Expecting '>'"); case ExpressionErrorKind.ExpectingRightParenOrDash: return($"Expecting '-' or ')'"); case ExpressionErrorKind.ItemsDisallowed: return($"{Name ()} does not allow metadata"); case ExpressionErrorKind.ExpectingMethodOrTransform: return($"Expecting item function or transform"); case ExpressionErrorKind.ExpectingMethodName: return("Expecting method name"); case ExpressionErrorKind.ExpectingLeftParen: return("Expecting '('"); case ExpressionErrorKind.ExpectingRightParenOrComma: return("Expecting ')' or ','"); case ExpressionErrorKind.ExpectingRightParenOrValue: return("Expecting ',' or value"); case ExpressionErrorKind.ExpectingValue: return("Expecting value"); case ExpressionErrorKind.CouldNotParseNumber: return("Invalid numeric value"); case ExpressionErrorKind.IncompleteValue: return("Incomplete value"); case ExpressionErrorKind.ExpectingBracketColonColon: return("Expecting ']::'"); case ExpressionErrorKind.ExpectingClassName: return("Expecting class name"); case ExpressionErrorKind.ExpectingClassNameComponent: return("Incomplete class name"); case ExpressionErrorKind.IncompleteString: return("Incomplete string"); case ExpressionErrorKind.IncompleteProperty: return("Incomplete property"); default: return($"Invalid expression: {errorKind}"); } string Name() => DescriptionFormatter.GetTitleCaseKindName(info); }
public SelectStatement(ValueInfo valueInfo, string rootName, string rootIdAlias) { builder.AppendFormat("select distinct {0}.* from {0}", valueInfo.Name); var previousName = valueInfo.Name; var previousIdName = valueInfo.Identifer.Name; var parent = valueInfo.Parent; while (parent != null) { builder.AppendFormat(" inner join {0} on {0}.Id = {1}.Parent", parent.Name, previousName); previousName = parent.Name; previousIdName = parent.Identifier.Name; parent = parent.Parent; } if (!string.IsNullOrEmpty(rootName) && !string.IsNullOrEmpty(rootIdAlias)) builder.AppendFormat(" inner join {0} on {0}.{1} = {2}.{3}", rootName, rootIdAlias, previousName, previousIdName); if (valueInfo.Sequence != null) builder.AppendFormat(" order by {0}.{1}", valueInfo.Name, valueInfo.Sequence.Name); }
public object GetValue(byte formatByte, ValueInfo valueInfo, byte[] contentBytes) { return(null); }
private ValueInfo GetValue(XmlElement valueElement) { var value = new ValueInfo { Type = GetValueType(valueElement) }; value.Converter = GetValueConverter(valueElement, value.Type); // get the constructor params and setters for the value value.ConstructorParams.AddRange(GetValueConstructorParams(valueElement)); value.Setters.AddRange(GetSetters(valueElement)); // if there are no constructorParams or setters, // look for the value of the XmlElement if (value.Setters.Count == 0 && value.ConstructorParams.Count == 0) { value.Value = valueElement.GetAttribute(ValueAttribute); // this is the final value, so if we still don't have a converter then it's an error. if (value.Converter == null) throw new FileFormatException("There is no converter for the type \"" + value.Type + "\"");//don't localize --Ron } return value; }
public void SetPropertyValueInfoAsProppyType <T> (DescriptorPropertyInfo info, ValueInfo <T> value, PropertyVariation variations) { try { info.SetValue(this, value.Value); } catch (Exception ex) { LoggingService.LogError("Error setting the value", ex); } }
async Task <CompletionContext> GetExpressionCompletionsAsync(ValueInfo info, ExpressionCompletion.TriggerState triggerState, ExpressionCompletion.ListKind listKind, int triggerLength, ExpressionNode triggerExpression, IReadOnlyList <ExpressionNode> comparandVariables, MSBuildResolveResult rr, SnapshotPoint triggerLocation, MSBuildRootDocument doc, CancellationToken token) { var kind = MSBuildCompletionExtensions.InferValueKindIfUnknown(info); if (!ExpressionCompletion.ValidateListPermitted(listKind, kind)) { return(CompletionContext.Empty); } bool allowExpressions = kind.AllowExpressions(); kind = kind.GetScalarType(); if (kind == MSBuildValueKind.Data || kind == MSBuildValueKind.Nothing) { return(CompletionContext.Empty); } bool isValue = triggerState == ExpressionCompletion.TriggerState.Value || triggerState == ExpressionCompletion.TriggerState.PropertyOrValue || triggerState == ExpressionCompletion.TriggerState.ItemOrValue || triggerState == ExpressionCompletion.TriggerState.MetadataOrValue; var items = new List <CompletionItem> (); if (comparandVariables != null && isValue) { foreach (var ci in ExpressionCompletion.GetComparandCompletions(doc, comparandVariables)) { items.Add(CreateCompletionItem(ci, doc, rr)); } } if (isValue) { switch (kind) { case MSBuildValueKind.NuGetID: return(await GetPackageNameCompletions(doc, triggerLocation.Position - triggerLength, triggerLength)); case MSBuildValueKind.NuGetVersion: return(await GetPackageVersionCompletions(doc, rr)); case MSBuildValueKind.Sdk: case MSBuildValueKind.SdkWithVersion: return(await GetSdkCompletions(doc, token)); case MSBuildValueKind.Guid: items.Add(CreateSpecialItem("New GUID", "Inserts a new GUID", KnownImages.Add, MSBuildSpecialCommitKind.NewGuid)); break; case MSBuildValueKind.Lcid: items.AddRange(GetLcidCompletions()); break; } } //TODO: better metadata support IEnumerable <BaseInfo> cinfos; if (info.Values != null && info.Values.Count > 0 && isValue) { cinfos = info.Values; } else { //FIXME: can we avoid awaiting this unless we actually need to resolve a function? need to propagate async downwards await provider.FunctionTypeProvider.EnsureInitialized(token); cinfos = ExpressionCompletion.GetCompletionInfos(rr, triggerState, kind, triggerExpression, triggerLength, doc, provider.FunctionTypeProvider); } if (cinfos != null) { foreach (var ci in cinfos) { items.Add(CreateCompletionItem(ci, doc, rr)); } } if ((allowExpressions && isValue) || triggerState == TriggerState.BareFunctionArgumentValue) { items.Add(CreateSpecialItem("$(", "Property reference", KnownImages.MSBuildProperty, MSBuildSpecialCommitKind.PropertyReference)); } if (allowExpressions && isValue) { items.Add(CreateSpecialItem("@(", "Item reference", KnownImages.MSBuildItem, MSBuildSpecialCommitKind.ItemReference)); //FIXME metadata } if (items.Count > 0) { return(CreateCompletionContext(items)); } return(CompletionContext.Empty); }
/// <summary> /// /// </summary> /// <param name="monitorData"></param> /// <param name="fanCnt"></param> /// <param name="alarmCnt"></param> /// <param name="hasAlarm"></param> public static void GetFanAlarmInfo(ScannerMonitorData monitorData, uint fanCount, int threshold, out bool hasValidFan, out uint alarmCnt) { alarmCnt = 0; hasValidFan = false; if (monitorData == null || !monitorData.IsConnectMC) { return; } if (fanCount == 0) { hasValidFan = true; return; } if (monitorData.FanSpeedOfMonitorCardCollection != null && monitorData.FanSpeedOfMonitorCardCollection.Count != 0) { MonitorInfoResult oneSwitchRes; ValueInfo valueInfo; for (int n = 0; n < fanCount; n++) { if (n < monitorData.FanSpeedOfMonitorCardCollection.Count) { valueInfo = monitorData.FanSpeedOfMonitorCardCollection[n]; } else { valueInfo = new ValueInfo(); valueInfo.IsValid = false; } GetOneFanOrPowerAlarmInfo(valueInfo, threshold, out oneSwitchRes); if (oneSwitchRes != MonitorInfoResult.Unknown) { hasValidFan = true; if (oneSwitchRes == MonitorInfoResult.Alarm) { alarmCnt++; } } } } }
DbgEngineLocalsValueNodeInfo[] GetNodesCore(DbgEvaluationInfo evalInfo, DbgValueNodeEvaluationOptions options, DbgLocalsValueNodeEvaluationOptions localsOptions) { DbgEngineLocalsValueNodeInfo[] valueNodes = null; try { var module = evalInfo.Frame.Module; if (module == null) { return(Array.Empty <DbgEngineLocalsValueNodeInfo>()); } var languageDebugInfo = evalInfo.Context.TryGetLanguageDebugInfo(); if (languageDebugInfo == null) { return(Array.Empty <DbgEngineLocalsValueNodeInfo>()); } var methodDebugInfo = languageDebugInfo.MethodDebugInfo; // All the variables windows use the same cached module references so make sure we pass // in the same arguments so it won't get recreated every time the method gets called. var info = dbgAliasProvider.GetAliases(evalInfo); var refsResult = dbgModuleReferenceProvider.GetModuleReferences(evalInfo.Runtime, evalInfo.Frame, info.typeReferences); if (refsResult.ErrorMessage != null) { return new[] { CreateInternalErrorNode(evalInfo, refsResult.ErrorMessage) } } ; // Since we attach this to the module, the module doesn't have to be part of Key var state = StateWithKey <GetNodesState> .GetOrCreate(module, this); var localsOptionsKey = localsOptions & ~(DbgLocalsValueNodeEvaluationOptions.ShowCompilerGeneratedVariables | DbgLocalsValueNodeEvaluationOptions.ShowDecompilerGeneratedVariables); var key = new GetNodesState.Key(methodDebugInfo.DecompilerSettingsVersion, methodDebugInfo.Method.MDToken.ToInt32(), languageDebugInfo.MethodVersion, refsResult.ModuleReferences, MethodDebugScopeUtils.GetScope(methodDebugInfo.Scope, languageDebugInfo.ILOffset), options, localsOptionsKey); var evalOptions = DbgEvaluationOptions.None; if ((options & DbgValueNodeEvaluationOptions.NoFuncEval) != 0) { evalOptions |= DbgEvaluationOptions.NoFuncEval; } if ((localsOptions & DbgLocalsValueNodeEvaluationOptions.ShowRawLocals) != 0) { evalOptions |= DbgEvaluationOptions.RawLocals; } ValueInfo[] valueInfos; byte[] assemblyBytes; int compilerGeneratedCount; int decompilerGeneratedCount; if (key.Equals(state.CachedKey)) { valueInfos = state.CachedValueInfos; assemblyBytes = state.CachedAssemblyBytes; decompilerGeneratedCount = state.CachedDecompilerGeneratedCount; compilerGeneratedCount = state.CachedCompilerGeneratedCount; } else { var compilationResult = expressionCompiler.CompileGetLocals(evalInfo, refsResult.ModuleReferences, evalOptions); evalInfo.CancellationToken.ThrowIfCancellationRequested(); if (compilationResult.IsError) { return new[] { CreateInternalErrorNode(evalInfo, compilationResult.ErrorMessage) } } ; decompilerGeneratedCount = GetDecompilerGeneratedVariablesCount(methodDebugInfo.Scope, languageDebugInfo.ILOffset); valueInfos = new ValueInfo[compilationResult.CompiledExpressions.Length + decompilerGeneratedCount]; int valueInfosIndex = 0; compilerGeneratedCount = 0; for (int i = 0; i < compilationResult.CompiledExpressions.Length; i++, valueInfosIndex++) { if ((compilationResult.CompiledExpressions[i].ResultFlags & DbgDotNetCompiledExpressionResultFlags.CompilerGenerated) != 0) { compilerGeneratedCount++; } valueInfos[valueInfosIndex] = new CompiledExpressionValueInfo(compilationResult.CompiledExpressions, i); } if (decompilerGeneratedCount > 0) { var scope = methodDebugInfo.Scope; for (;;) { foreach (var local in scope.Locals) { if (local.IsDecompilerGenerated) { valueInfos[valueInfosIndex] = new DecompilerGeneratedVariableValueInfo(local.Name); valueInfosIndex++; } } bool found = false; foreach (var childScope in scope.Scopes) { if (childScope.Span.Start <= languageDebugInfo.ILOffset && languageDebugInfo.ILOffset < childScope.Span.End) { found = true; scope = childScope; break; } } if (!found) { break; } } } if (valueInfos.Length != valueInfosIndex) { throw new InvalidOperationException(); } assemblyBytes = compilationResult.Assembly; state.CachedKey = key; state.CachedValueInfos = valueInfos; state.CachedAssemblyBytes = assemblyBytes; state.CachedILInterpreterState = null; state.CachedDecompilerGeneratedCount = decompilerGeneratedCount; state.CachedCompilerGeneratedCount = compilerGeneratedCount; } int count = valueInfos.Length; if ((localsOptions & DbgLocalsValueNodeEvaluationOptions.ShowCompilerGeneratedVariables) == 0) { count -= compilerGeneratedCount; } if ((localsOptions & DbgLocalsValueNodeEvaluationOptions.ShowDecompilerGeneratedVariables) == 0) { count -= decompilerGeneratedCount; } valueNodes = count == 0 ? Array.Empty <DbgEngineLocalsValueNodeInfo>() : new DbgEngineLocalsValueNodeInfo[count]; var valueCreator = new DbgDotNetValueCreator(valueNodeFactory, dnILInterpreter, evalInfo, options, evalOptions, assemblyBytes); int w = 0; for (int i = 0; i < valueInfos.Length; i++) { evalInfo.CancellationToken.ThrowIfCancellationRequested(); var valueInfo = valueInfos[i]; DbgEngineLocalsValueNodeInfo valueNodeInfo; switch (valueInfo.Kind) { case ValueInfoKind.CompiledExpression: var compExpr = (CompiledExpressionValueInfo)valueInfo; if ((localsOptions & DbgLocalsValueNodeEvaluationOptions.ShowCompilerGeneratedVariables) == 0 && compExpr.IsCompilerGenerated) { continue; } valueNodeInfo = new DbgEngineLocalsValueNodeInfo( compExpr.IsParameter ? DbgLocalsValueNodeKind.Parameter : DbgLocalsValueNodeKind.Local, valueCreator.CreateValueNode(ref state.CachedILInterpreterState, ref compExpr.CompiledExpressionResult)); break; case ValueInfoKind.DecompilerGeneratedVariable: if ((localsOptions & DbgLocalsValueNodeEvaluationOptions.ShowDecompilerGeneratedVariables) == 0) { continue; } var decGen = (DecompilerGeneratedVariableValueInfo)valueInfo; valueNodeInfo = new DbgEngineLocalsValueNodeInfo(DbgLocalsValueNodeKind.Local, valueNodeFactory.CreateError(evalInfo, new DbgDotNetText(new DbgDotNetTextPart(BoxedTextColor.Local, decGen.Name)), dnSpy_Debugger_DotNet_Resources.DecompilerGeneratedVariablesCanNotBeEvaluated, decGen.Name, false)); break; default: throw new InvalidOperationException(); } valueNodes[w++] = valueNodeInfo; } if (w != valueNodes.Length) { throw new InvalidOperationException(); } return(valueNodes); } catch (Exception ex) { if (valueNodes != null) { evalInfo.Runtime.Process.DbgManager.Close(valueNodes.Select(a => a.ValueNode).Where(a => a != null)); } if (!ExceptionUtils.IsInternalDebuggerError(ex)) { throw; } return(new[] { CreateInternalErrorNode(evalInfo, PredefinedEvaluationErrorMessages.InternalDebuggerError) }); } }
/// <summary> /// ��ȡ���߸澯���� /// </summary> /// <param name="scanBordAddr"></param> /// <param name="clr"></param> public static void GetMCPowerAlarmInfo(ScannerMonitorData monitorData, uint powerCount, float alarmThreshold,float faultThreshold, out bool hasValidPower, out uint alarmCnt) { alarmCnt = 0; hasValidPower = false; if (monitorData == null || !monitorData.IsConnectMC) { return; } if (powerCount == 0) { hasValidPower = true; return; } if (monitorData.VoltageOfMonitorCardCollection != null && monitorData.VoltageOfMonitorCardCollection.Count != 0) { MonitorInfoResult oneSwitchRes; ValueInfo valueInfo; int powerIndexInList = 0; for (int n = 0; n < powerCount; n++) { powerIndexInList = n + 1; if (powerIndexInList < monitorData.VoltageOfMonitorCardCollection.Count) { valueInfo = monitorData.VoltageOfMonitorCardCollection[powerIndexInList]; } else { valueInfo = new ValueInfo(); valueInfo.IsValid = false; } GetOneFanOrPowerAlarmInfo(valueInfo, alarmThreshold,faultThreshold, out oneSwitchRes); if (oneSwitchRes != MonitorInfoResult.Unknown) { hasValidPower = true; if (oneSwitchRes == MonitorInfoResult.Alarm) { alarmCnt++; } else if (oneSwitchRes == MonitorInfoResult.Fault) { alarmCnt++; } } } } }
private async Task PushValuesAsync(FlaggableChoiceViewModel <TValue> changedChoice) { SetError(null); using (await AsyncWork.RequestAsyncWork(this)) { try { // Snapshot current choices so we don't catch updates mid-push for multi-editors var currentChoices = Choices.ToDictionary(c => c, c => c.IsFlagged); foreach (IObjectEditor editor in Editors) { ValueInfo <IReadOnlyList <TValue> > value = await editor.GetValueAsync <IReadOnlyList <TValue> > (Property, Variation); HashSet <TValue> current; if (value.Value == null || value.Source == ValueSource.Unset) { current = new HashSet <TValue> (); } else { current = new HashSet <TValue> (value.Value); } foreach (var choice in currentChoices) { if (!choice.Value.HasValue) { continue; } if (choice.Value.Value) { current.Add(choice.Key.Value); } else { current.Remove(choice.Key.Value); } } IReadOnlyList <TValue> values = current.ToArray(); if (this.validator != null) { if (!this.validator.IsValid(values)) { // Some combinables simply don't have a valid "none", but if we're going from indeterminate we still need to // update the value, so we'll flip the changed value to true in that case so we don't go right back to indeterminate if (values.Count == 0) { changedChoice.IsFlagged = true; // We're explicitly triggering a change and need the update here so we need to update our snapshot. currentChoices = Choices.ToDictionary(c => c, c => c.IsFlagged); } continue; } } if (this.coerce != null) { values = this.coerce.CoerceValue(values); } await editor.SetValueAsync(Property, new ValueInfo <IReadOnlyList <TValue> > { Source = ValueSource.Local, Value = values }); } } catch (Exception ex) { if (ex is AggregateException aggregate) { aggregate = aggregate.Flatten(); ex = aggregate.InnerExceptions[0]; } SetError(ex.ToString()); } } }
public static void GetOneFanOrPowerAlarmInfo(ValueInfo valueInfo, float threshold, out MonitorInfoResult resType) { //-50 ��������ܴﵽ�Ĺ��Ϸ�ֵ GetOneFanOrPowerAlarmInfo(valueInfo, threshold, -50, out resType); }
public override string ToString() { return($"KeyType:{BasicString}, HashType:{HashString}, RedisKey:{RedisKey}, Length:[{KeyLength},{ValueLength}], ObjectValue:{ValueInfo.ToString()}"); }
public static void GetOneFanOrPowerAlarmInfo(ValueInfo valueInfo, float alarmThreshold, float faultThreshold, out MonitorInfoResult resType) { resType = MonitorInfoResult.Unknown; if (valueInfo.IsValid) { if (valueInfo.Value < faultThreshold) { resType = MonitorInfoResult.Fault; } else if (valueInfo.Value < alarmThreshold) { //����ת�ٻ��ѹֵС����ֵʱ��ΪΪ�澯��Ϣ resType = MonitorInfoResult.Alarm; } else { resType = MonitorInfoResult.Ok; } } }
/// <summary> /// Validate /// </summary> public void Validate(ValueInfo info) { if (!Regex.IsMatch(info.Value.ToSafeString(string.Empty), Pattern)) { throw new ValidationException("{0}: '{1}' does not match regex '{2}'".FormatWith( info.Name, info.Value, Pattern)); } }
protected override void VisitValueExpression( XElement element, XAttribute attribute, MSBuildLanguageElement resolvedElement, MSBuildLanguageAttribute resolvedAttribute, ValueInfo info, MSBuildValueKind kind, ExpressionNode node) { switch (node.Find(offset)) { case ExpressionItem ei: rr.ReferenceKind = MSBuildReferenceKind.Item; rr.ReferenceOffset = ei.NameOffset; rr.ReferenceLength = ei.Name.Length; rr.Reference = ei.Name; break; case ExpressionProperty ep: rr.ReferenceKind = MSBuildReferenceKind.Property; rr.ReferenceOffset = ep.NameOffset; rr.Reference = ep.Name; rr.ReferenceLength = ep.Name.Length; break; case ExpressionMetadata em: if (em.ItemName == null || offset >= em.MetadataNameOffset) { rr.ReferenceKind = MSBuildReferenceKind.Metadata; rr.ReferenceOffset = em.MetadataNameOffset; rr.Reference = (em.GetItemName(), em.MetadataName); rr.ReferenceLength = em.MetadataName.Length; } else { rr.ReferenceKind = MSBuildReferenceKind.Item; rr.ReferenceOffset = em.ItemNameOffset; rr.Reference = em.ItemName; rr.ReferenceLength = em.ItemName.Length; } break; case ExpressionLiteral lit: kind = kind.GetScalarType(); if (lit.IsPure) { VisitPureLiteral(info, kind, lit); if (kind == MSBuildValueKind.TaskOutputParameterName) { rr.ReferenceKind = MSBuildReferenceKind.TaskParameter; rr.ReferenceOffset = lit.Offset; rr.ReferenceLength = lit.Value.Length; rr.Reference = (element.ParentElement().Name.Name, lit.Value); break; } } switch (kind) { case MSBuildValueKind.File: case MSBuildValueKind.FileOrFolder: case MSBuildValueKind.ProjectFile: case MSBuildValueKind.TaskAssemblyFile: var pathNode = lit.Parent as Expression ?? (ExpressionNode)lit; var path = MSBuildNavigation.GetPathFromNode(pathNode, (MSBuildRootDocument)Document); if (path != null) { rr.ReferenceKind = MSBuildReferenceKind.FileOrFolder; rr.ReferenceOffset = path.Offset; rr.ReferenceLength = path.Length; rr.Reference = path.Paths; } break; } break; } }
protected override void DrawGrid(Graphics drawZoonGraphic, RectangularGridInfo curGird) { if (curGird == null) { return; } if (_isDisplayAll) { return; } IGridBiningObject customObj = (IGridBiningObject)curGird.CustomObj; Color backColor = Color.Gray; int nValue = 0; bool bTempOrHumiInvalid = false; if (customObj.Type == GridType.ScanBoardGird) { ScanBoardGridBindObj scanBoardGridObj = (ScanBoardGridBindObj)customObj; #region ��ȡ���ӱ�����ɫ if (customObj != null) { switch (_curType) { case MonitorDisplayType.SBStatus: GetMonitorColorAndValue.GetSBStatusColorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.MCStatus: GetMonitorColorAndValue.GetMCStatusColorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Smoke: GetMonitorColorAndValue.GetSmokeColorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Temperature: bTempOrHumiInvalid = !GetMonitorColorAndValue.DetectTempIsValidAndGetInfo(_clrGradePartition, _curMonitorConfigInfo.TempDisplayType, scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref nValue, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Humidity: bTempOrHumiInvalid = !GetMonitorColorAndValue.DetectHumiValidAndGetInfo(_clrGradePartition, scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref nValue, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Fan: curGird.Style.BackColor = Color.Gray; break; case MonitorDisplayType.Power: curGird.Style.BackColor = Color.Gray; break; case MonitorDisplayType.RowLine: GetMonitorColorAndValue.GetRowLineCorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, scanBoardGridObj.ScanBoardAndMonitorInfo.RowLineStatus, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.GeneralSwitch: GetMonitorColorAndValue.GetGeneralSwitchClr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, scanBoardGridObj.ScanBoardAndMonitorInfo.GeneralSwitchList, ref backColor); curGird.Style.BackColor = backColor; break; } } #endregion base.DrawGrid(drawZoonGraphic, curGird); #region ���Ƹ����ϵ��ַ�����ͼ�� if (scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData == null) { return; } RectangleF drawRect = new RectangleF(curGird.DrawRegion.X + this.DefaultStyle.BoardWidth / 2, curGird.DrawRegion.Y + this.DefaultStyle.BoardWidth / 2, curGird.DrawRegion.Width - this.DefaultStyle.BoardWidth, curGird.DrawRegion.Height - this.DefaultStyle.BoardWidth); ScannerMonitorData monitorInfo = (ScannerMonitorData)scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData.Clone(); if (customObj != null && monitorInfo != null) { if (_curType == MonitorDisplayType.Temperature || _curType == MonitorDisplayType.Humidity) { #region ������ʪ���ַ��� if (bTempOrHumiInvalid) { return; } _strSize = GetStrSize(drawZoonGraphic, nValue.ToString()); if (_strSize.Width > drawRect.Width || _strSize.Height > drawRect.Height) { //���ܽ��ַ������Ƴ��� return; } DrawStrForCenter(drawZoonGraphic, nValue.ToString(), drawRect); #endregion } else if (_curType == MonitorDisplayType.Fan || _curType == MonitorDisplayType.Power) { ValueInfo valueInfo = new ValueInfo(); float fSwitchHeight = 0; Image drawImage = null; bool isDrawStr = false; float drawImageHeight = 0; float imageSize = 0; if (_curType == MonitorDisplayType.Fan) { #region ���Ʒ��ȷָ��� _curMCFanCnt = GetMonitorColorAndValue.GetMonitorFanCnt(_curMonitorConfigInfo.MCFanInfo, curGird.Key); if (_curMCFanCnt <= 0) { return; } if ((curGird.DrawRegion.Height - DrawOffset * 2) < _curMCFanCnt * _switchPen.Width || _curMCFanCnt <= 0) { //��ȡʵ�ʻ��Ƶķ��ȸ���ʧ�� return; } fSwitchHeight = (float)drawRect.Height / _curMCFanCnt; drawImageHeight = fSwitchHeight - ImageAndStrInterval * 2; for (int i = 0; i < _curMCFanCnt; i++) { isDrawStr = true; if (monitorInfo.FanSpeedOfMonitorCardCollection == null || i >= monitorInfo.FanSpeedOfMonitorCardCollection.Count) { valueInfo = new ValueInfo(); valueInfo.IsValid = false; } else { valueInfo = monitorInfo.FanSpeedOfMonitorCardCollection[i]; } //��ȡ���ȵ�ͼƬ���ַ������ƴ�С GetImageAndStrSize(drawZoonGraphic,drawRect, valueInfo, fSwitchHeight, drawImageHeight, out imageSize, out _strSize, out isDrawStr); //��ȡ���Ƶ�ͼƬ GetDrawImage(valueInfo, PicType.Fan, _curMonitorConfigInfo.MCFanInfo.AlarmThreshold, ref drawImage); //����ͼƬ���ַ��� DrawImageAndStr(drawZoonGraphic, drawImage, valueInfo, drawRect, fSwitchHeight, imageSize, _strSize, isDrawStr, i); #region �������� #region ��ȡ�ַ�����ͼƬ���ƵĴ�С //if (!valueInfo.IsValid) //{ // isDrawStr = false; // _strSize.Width = 0; //} //else //{ // _strSize = GetStrSize(drawZoonGraphic, valueInfo.Value.ToString()); //} //if (_strSize.Height > fSwitchHeight // || _strSize.Width + ImageAndStrInterval * 3 > drawRect.Width) //{ // isDrawStr = false; // _strSize.Width = 0; //} //imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 3; //imageSize = Math.Min(imageWidth, drawImageHeight); //if (imageSize < MinImageSize) //{ // isDrawStr = false; // _strSize.Width = 0; // imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 2; // imageSize = Math.Min(imageWidth, drawImageHeight); //} //if (imageSize < 0) //{ // imageSize = 0; //} #endregion #region �����ַ�����ͼƬ //imageRectF = new RectangleF(fRegionStartX + ImageAndStrInterval, // fRegionStartY + fSwitchHeight * i + (fSwitchHeight - imageSize) / 2, // imageSize, imageSize); //lineStartPoint = new PointF(fRegionStartX, fRegionStartY + fSwitchHeight * i); //lineEndPoint = new PointF(fRegionEndX, fRegionStartY + fSwitchHeight * i); ////���Ʊ��� //drawZoonGraphic.FillRectangle(_switchBrush, fRegionStartX, fRegionStartY + fSwitchHeight * i, // drawRect.Width - DrawOffset, fSwitchHeight); //drawZoonGraphic.DrawImage(drawImage, imageRectF); //if (i > 0) //{ // drawZoonGraphic.DrawLine(_switchPen, lineStartPoint, lineEndPoint); //} //if (isDrawStr) //{ // strRectF = new RectangleF(fRegionStartX + imageSize + ImageAndStrInterval * 2, // fRegionStartY + fSwitchHeight * i, // drawRect.Width - imageSize - ImageAndStrInterval * 2, // fSwitchHeight); // DrawStrForLeft(drawZoonGraphic, valueInfo.Value.ToString(), strRectF); //} #endregion #endregion } #endregion } else if (_curType == MonitorDisplayType.Power) { #region ���Ƶ�Դ�ָ��� _curMCPowerCnt = GetMonitorColorAndValue.GetMonitorPowerCnt(_curMonitorConfigInfo.MCPowerInfo, curGird.Key); if (_curMCPowerCnt <= 0) { return; } if ((drawRect.Height - DrawOffset * 2) < _curMCPowerCnt * _switchPen.Width) { return; } fSwitchHeight = (float)drawRect.Height / _curMCPowerCnt; drawImageHeight = fSwitchHeight - ImageAndStrInterval * 2; int powerIndexInList = 0; for (int i = 0; i < _curMCPowerCnt; i++) { powerIndexInList = i + 1; isDrawStr = true; if (monitorInfo.VoltageOfMonitorCardCollection == null || powerIndexInList >= monitorInfo.VoltageOfMonitorCardCollection.Count) { valueInfo = new ValueInfo(); valueInfo.IsValid = false; } else { valueInfo = monitorInfo.VoltageOfMonitorCardCollection[powerIndexInList]; } //��ȡ��Դ��ͼƬ���ַ������ƴ�С GetImageAndStrSize(drawZoonGraphic, drawRect, valueInfo, fSwitchHeight, drawImageHeight, out imageSize, out _strSize, out isDrawStr); //��ȡ���Ƶ�ͼƬ GetDrawImage(valueInfo, PicType.Power, _curMonitorConfigInfo.MCPowerInfo.AlarmThreshold, ref drawImage); //����ͼƬ���ַ��� DrawImageAndStr(drawZoonGraphic, drawImage, valueInfo, drawRect, fSwitchHeight, imageSize, _strSize, isDrawStr, i); #region �������� #region ��ȡ�ַ�����ͼƬ���ƵĴ�С //if (!valueInfo.IsValid) //{ // isDrawStr = false; // _strSize.Width = 0; //} //else //{ // _strSize = GetStrSize(drawZoonGraphic, valueInfo.Value.ToString("#0.00")); //} //if (_strSize.Height > fSwitchHeight // || _strSize.Width + ImageAndStrInterval * 3 > drawRect.Width) //{ // isDrawStr = false; // _strSize.Width = 0; //} //imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 3; //imageSize = Math.Min(imageWidth, drawImageHeight); //if (imageSize < MinImageSize) //{ // isDrawStr = false; // _strSize.Width = 0; // imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 2; // imageSize = Math.Min(imageWidth, drawImageHeight); //} //if (imageSize < 0) //{ // imageSize = 0; //} #endregion #region �����ַ�����ͼƬ //imageRectF = new RectangleF(fRegionStartX + ImageAndStrInterval, // fRegionStartY + fSwitchHeight * i + (fSwitchHeight - imageSize) / 2, // imageSize, imageSize); //lineStartPoint = new PointF(fRegionStartX, fRegionStartY + fSwitchHeight * i); //lineEndPoint = new PointF(fRegionEndX, fRegionStartY + fSwitchHeight * i); //GetDrawImage(valueInfo, PicType.Power, // _curMonitorConfigInfo.MCPowerInfo.AlarmThreshold, // ref drawImage); ////���Ʊ��� //drawZoonGraphic.FillRectangle(_switchBrush, fRegionStartX, fRegionStartY + fSwitchHeight * i, // drawRect.Width - DrawOffset, fSwitchHeight); //drawZoonGraphic.DrawImage(drawImage, imageRectF); //if (i > 0 && i < _curMCPowerCnt) //{ // drawZoonGraphic.DrawLine(_switchPen, lineStartPoint, lineEndPoint); //} //if (isDrawStr) //{ // strRectF = new RectangleF(fRegionStartX + imageSize + ImageAndStrInterval * 2, // fRegionStartY + fSwitchHeight * i, // drawRect.Width - imageSize - ImageAndStrInterval * 2, // fSwitchHeight); // DrawStrForLeft(drawZoonGraphic, valueInfo.Value.ToString("#0.00"), strRectF); //} #endregion #endregion } #endregion } } } #endregion } else if (customObj.Type == GridType.ComplexScreenGrid) { ComplexScreenGridBindObj complexScreenGridObj = (ComplexScreenGridBindObj)customObj; #region ��ȡ���ӱ�����ɫ backColor = Color.Gray; if (complexScreenGridObj.ComplexScreenLayout.IsAllMonitorDataIsValid) { switch (_curType) { case MonitorDisplayType.SBStatus: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.SBStatusErrCount > 0 || complexScreenGridObj.ComplexScreenLayout.AlarmInfo.SBStatusErrCount > 0) { backColor = Color.Red; } else { backColor = Color.Green; } break; case MonitorDisplayType.MCStatus: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.MCStatusErrCount > 0 || complexScreenGridObj.ComplexScreenLayout.AlarmInfo.MCStatusErrCount > 0) { backColor = Color.Red; } else { backColor = Color.Green; } break; case MonitorDisplayType.Smoke: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.SmokeAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.SmokeAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Temperature: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.TemperatureAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.TemperatureAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Humidity: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.HumidityAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.HumidityAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Fan: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.FanAlarmSwitchCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.FanAlarmSwitchCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Power: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.PowerAlarmSwitchCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.PowerAlarmSwitchCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.RowLine: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.SoketAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.SoketAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.GeneralSwitch: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.GeneralSwitchErrCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.GeneralSwitchErrCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; } } curGird.Style.BackColor = backColor; #endregion base.DrawGrid(drawZoonGraphic, curGird); #region ���Ƹ������ı߽� //drawZoonGraphic.DrawRectangle(_screenBoarderPen, // curGird.DrawRegion.X + _screenBoarderPen.Width / 2, // curGird.DrawRegion.Y + _screenBoarderPen.Width / 2, // curGird.DrawRegion.Width - _screenBoarderPen.Width, // curGird.DrawRegion.Height - _screenBoarderPen.Width); #endregion } else if (customObj.Type == GridType.ScreenGrid) { ScreenGridBindObj screenGridObj = (ScreenGridBindObj)customObj; if (!screenGridObj.ScreenIsValid) { curGird.Style.BackColor = Color.Gray; base.DrawGrid(drawZoonGraphic, curGird); } #region ���Ƹ��ӱ߽� --- ��ʾ���߽� drawZoonGraphic.DrawRectangle(_screenBoarderPen, curGird.DrawRegion.X + _screenBoarderPen.Width / 2, curGird.DrawRegion.Y + _screenBoarderPen.Width / 2, curGird.DrawRegion.Width - _screenBoarderPen.Width, curGird.DrawRegion.Height - _screenBoarderPen.Width); #endregion } }
void VisitPureLiteral(ValueInfo info, MSBuildValueKind kind, ExpressionLiteral node) { string value = node.GetUnescapedValue(); rr.ReferenceOffset = node.Offset; rr.ReferenceLength = node.Value.Length; rr.Reference = value; switch (kind) { case MSBuildValueKind.TaskOutputParameterName: rr.ReferenceKind = MSBuildReferenceKind.TaskParameter; return; case MSBuildValueKind.TargetName: rr.ReferenceKind = MSBuildReferenceKind.Target; return; case MSBuildValueKind.NuGetID: rr.ReferenceKind = MSBuildReferenceKind.NuGetID; return; case MSBuildValueKind.PropertyName: rr.ReferenceKind = MSBuildReferenceKind.Property; return; case MSBuildValueKind.ItemName: rr.ReferenceKind = MSBuildReferenceKind.Item; return; case MSBuildValueKind.TargetFramework: rr.ReferenceKind = MSBuildReferenceKind.TargetFramework; return; case MSBuildValueKind.TargetFrameworkIdentifier: rr.ReferenceKind = MSBuildReferenceKind.TargetFrameworkIdentifier; return; case MSBuildValueKind.TargetFrameworkVersion: rr.ReferenceKind = MSBuildReferenceKind.TargetFrameworkVersion; return; case MSBuildValueKind.TargetFrameworkProfile: rr.ReferenceKind = MSBuildReferenceKind.TargetFrameworkProfile; return; } IReadOnlyList <ConstantInfo> knownVals = info.Values ?? kind.GetSimpleValues(false); if (knownVals != null && knownVals.Count != 0) { foreach (var kv in knownVals) { if (string.Equals(kv.Name, value, StringComparison.OrdinalIgnoreCase)) { rr.ReferenceKind = MSBuildReferenceKind.KnownValue; return; } } } }
private void GetDrawImage(ValueInfo valueInfo, PicType picType, float threshod, ref Image drawImage) { if (valueInfo.IsValid) { if (valueInfo.Value < threshod) { //�澯 drawImage = FanAndPowerRepaintInfo.AlarmImage[(int)picType]; _switchBrush.Color = Color.Yellow; } else { //���� drawImage = FanAndPowerRepaintInfo.OKImage[(int)picType]; _switchBrush.Color = Color.Green; } } else { //��Ч drawImage = FanAndPowerRepaintInfo.InvalidImage[(int)picType]; _switchBrush.Color = Color.Gray; } }
private ValueInfo GetValueInfo(Stream stream, int headerSize) { var bytes = NumericParser.ReadInt32(stream, headerSize); return(ValueInfo.ForContent(headerSize, bytes)); }
/// <summary> /// Validate /// </summary> public abstract void Validate(ValueInfo info);
protected override void VisitValueExpression( XElement element, XAttribute attribute, MSBuildLanguageElement resolvedElement, MSBuildLanguageAttribute resolvedAttribute, ValueInfo info, MSBuildValueKind kind, ExpressionNode node) { switch (node.Find(offset)) { case ExpressionItemName ei: rr.ReferenceKind = MSBuildReferenceKind.Item; rr.ReferenceOffset = ei.Offset; rr.ReferenceLength = ei.Name.Length; rr.Reference = ei.Name; break; case ExpressionPropertyName propName: rr.ReferenceKind = MSBuildReferenceKind.Property; rr.ReferenceOffset = propName.Offset; rr.Reference = propName.Name; rr.ReferenceLength = propName.Length; break; case ExpressionMetadata em: if (em.ItemName == null || offset >= em.MetadataNameOffset) { rr.ReferenceKind = MSBuildReferenceKind.Metadata; rr.ReferenceOffset = em.MetadataNameOffset; rr.Reference = (em.GetItemName(), em.MetadataName); rr.ReferenceLength = em.MetadataName.Length; } else { rr.ReferenceKind = MSBuildReferenceKind.Item; rr.ReferenceOffset = em.ItemNameOffset; rr.Reference = em.ItemName; rr.ReferenceLength = em.ItemName.Length; } break; case ExpressionFunctionName name: rr.ReferenceOffset = name.Offset; rr.ReferenceLength = name.Name.Length; if (name.Parent is ExpressionItemNode item) { rr.ReferenceKind = MSBuildReferenceKind.ItemFunction; rr.Reference = name.Name; } else if (name.Parent is ExpressionPropertyFunctionInvocation prop) { if (prop.Target is ExpressionClassReference classRef) { rr.ReferenceKind = MSBuildReferenceKind.StaticPropertyFunction; rr.Reference = (classRef.Name, name.Name); } else { var type = functionTypeProvider?.ResolveType(prop.Target) ?? MSBuildValueKind.Unknown; rr.ReferenceKind = MSBuildReferenceKind.PropertyFunction; rr.Reference = (type, name.Name); } } break; case ExpressionClassReference cr: if (!string.IsNullOrEmpty(cr.Name)) { if (cr.Parent is ExpressionArgumentList) { rr.ReferenceKind = MSBuildReferenceKind.Enum; } else if (cr.Parent is ExpressionPropertyFunctionInvocation) { rr.ReferenceKind = MSBuildReferenceKind.ClassName; } else { break; } rr.ReferenceOffset = cr.Offset; rr.Reference = cr.Name; rr.ReferenceLength = cr.Length; } break; case ExpressionText lit: kind = kind.GetScalarType(); if (lit.IsPure) { VisitPureLiteral(element, info, kind, lit); if (kind == MSBuildValueKind.TaskOutputParameterName) { rr.ReferenceKind = MSBuildReferenceKind.TaskParameter; rr.ReferenceOffset = lit.Offset; rr.ReferenceLength = lit.Value.Length; rr.Reference = (element.ParentElement.Name.Name, lit.Value); break; } } switch (kind) { case MSBuildValueKind.File: case MSBuildValueKind.FileOrFolder: case MSBuildValueKind.ProjectFile: case MSBuildValueKind.TaskAssemblyFile: var pathNode = lit.Parent as ConcatExpression ?? (ExpressionNode)lit; var path = MSBuildNavigation.GetPathFromNode(pathNode, (MSBuildRootDocument)Document); if (path != null) { rr.ReferenceKind = MSBuildReferenceKind.FileOrFolder; rr.ReferenceOffset = path.Offset; rr.ReferenceLength = path.Length; rr.Reference = path.Paths; } break; } break; } }
public SelectStatement(ValueInfo valueInfo, IFilter filter) : this(valueInfo, filter, string.Format("select distinct {0}.*", valueInfo.Name)) { }
void VisitPureLiteral(XElement element, ValueInfo info, MSBuildValueKind kind, ExpressionText node) { string value = node.GetUnescapedValue(); rr.ReferenceOffset = node.Offset; rr.ReferenceLength = node.Value.Length; rr.Reference = value; switch (kind) { case MSBuildValueKind.TaskOutputParameterName: rr.ReferenceKind = MSBuildReferenceKind.TaskParameter; return; case MSBuildValueKind.TargetName: rr.ReferenceKind = MSBuildReferenceKind.Target; return; case MSBuildValueKind.NuGetID: rr.ReferenceKind = MSBuildReferenceKind.NuGetID; return; case MSBuildValueKind.PropertyName: rr.ReferenceKind = MSBuildReferenceKind.Property; return; case MSBuildValueKind.ItemName: rr.ReferenceKind = MSBuildReferenceKind.Item; return; case MSBuildValueKind.TaskName: rr.ReferenceKind = MSBuildReferenceKind.Task; return; case MSBuildValueKind.TargetFramework: rr.ReferenceKind = MSBuildReferenceKind.TargetFramework; return; case MSBuildValueKind.TargetFrameworkIdentifier: rr.ReferenceKind = MSBuildReferenceKind.TargetFrameworkIdentifier; return; case MSBuildValueKind.TargetFrameworkVersion: rr.ReferenceKind = MSBuildReferenceKind.TargetFrameworkVersion; return; case MSBuildValueKind.TargetFrameworkProfile: rr.ReferenceKind = MSBuildReferenceKind.TargetFrameworkProfile; return; case MSBuildValueKind.MetadataName: //this is used for KeepMetadata/RemoveMetadata. //reasonable to resolve from first item in include. var itemName = MSBuildMetadataReferenceCollector.GetIncludeExpression(element) .WithAllDescendants() .OfType <ExpressionItemName> () .FirstOrDefault(); if (itemName != null) { rr.Reference = (itemName.Name, value); rr.ReferenceKind = MSBuildReferenceKind.Metadata; } return; } IReadOnlyList <ConstantInfo> knownVals = info.Values ?? kind.GetSimpleValues(false); if (knownVals != null && knownVals.Count != 0) { foreach (var kv in knownVals) { if (string.Equals(kv.Name, value, StringComparison.OrdinalIgnoreCase)) { rr.ReferenceKind = MSBuildReferenceKind.KnownValue; rr.Reference = kv; return; } } } }
public SelectStatement(ValueInfo valueInfo, IFilter filter, string selectClause) { builder.Append(selectClause); builder.AppendFormat(" from {0}", valueInfo.Name); var previousName = valueInfo.Name; var parent = valueInfo.Parent; if (filter.AutoJoin) { while (parent != null) { builder.AppendFormat(" inner join {0} on {0}.Id = {1}.Parent", parent.Name, previousName); previousName = parent.Name; parent = parent.Parent; } } if (!string.IsNullOrEmpty(filter.JoinClause)) builder.AppendFormat(" {0}", filter.JoinClause); if (!string.IsNullOrEmpty(filter.WhereClause)) builder.AppendFormat(" where {0}", filter.WhereClause.Trim()); if (valueInfo.Sequence != null) builder.AppendFormat(" order by {0}.{1}", valueInfo.Name, valueInfo.Sequence.Name); }
/// <summary> /// ˢ�����н��տ���Ӧ������ʾ /// </summary> private void UpdateAllScanBoardInfo() { Color backColor = Color.Gray; int nValue = 0; string displayStr = ""; ValueInfo valueInfo; bool hasErrFanOrPower = false; string monitorDataKey = ""; ScannerMonitorData monitorData = null; ScanBoardRowLineStatus rowLineData = null; List<bool> generalStatus = null; for (int i = 0; i < _curAllScanBoardMonitorInfList.Count; i++) { if (_curAllScanBoardMonitorInfList[i] != null) { hasErrFanOrPower = false; monitorDataKey = _curAllScanBoardMonitorInfList[i].SBRectKey; backColor = Color.Gray; displayStr = ""; if (_curAllScanBoardMonitorInfList[i].MonitorData != null) { monitorData = (ScannerMonitorData)_curAllScanBoardMonitorInfList[i].MonitorData.Clone(); } else { monitorData = null; } if (_curAllScanBoardMonitorInfList[i].RowLineStatus != null) { rowLineData = (ScanBoardRowLineStatus)_curAllScanBoardMonitorInfList[i].RowLineStatus.Clone(); } else { rowLineData = null; } generalStatus = _curAllScanBoardMonitorInfList[i].GeneralSwitchList; switch (_curType) { #region ��ȡ������ɫ����ʾ���ַ��� case MonitorDisplayType.SBStatus: GetMonitorColorAndValue.GetSBStatusColorAndStr(monitorData, ref backColor); break; case MonitorDisplayType.MCStatus: GetMonitorColorAndValue.GetMCStatusColorAndStr(monitorData, ref backColor); break; case MonitorDisplayType.Smoke: GetMonitorColorAndValue.GetSmokeColorAndStr(monitorData, ref backColor); break; case MonitorDisplayType.Temperature: #region Temperature if (GetMonitorColorAndValue.DetectTempIsValidAndGetInfo(_clrGradePartition, _curMonitorConfigInfo.TempDisplayType, monitorData, ref nValue, ref backColor)) { displayStr = nValue.ToString(); } //else //{ // displayStr = CommonStr.StatusNoticeStr[(int)CommonStr.NoticeType.Unkown]; //} #endregion break; case MonitorDisplayType.Humidity: #region Humidity if (GetMonitorColorAndValue.DetectHumiValidAndGetInfo(_clrGradePartition, monitorData, ref nValue, ref backColor)) { displayStr = nValue.ToString(); } //else //{ // displayStr = CommonStr.StatusNoticeStr[(int)CommonStr.NoticeType.Unkown]; //} #endregion break; case MonitorDisplayType.Fan: #region ���� if (monitorData == null) { break; } _curMCFanCnt = GetMonitorColorAndValue.GetMonitorFanCnt(_curMonitorConfigInfo.MCFanInfo, monitorDataKey); if (_curMCFanCnt == 0) { break; } for (int j = 0; j < _curMCFanCnt; j++) { if (j > 0) { displayStr += "-"; } valueInfo = new ValueInfo(); if (monitorData.FanSpeedOfMonitorCardCollection == null || j >= monitorData.FanSpeedOfMonitorCardCollection.Count) { valueInfo.IsValid = false; } else { valueInfo = monitorData.FanSpeedOfMonitorCardCollection[j]; } GetFanOneSwitchInfo(valueInfo, ref hasErrFanOrPower, ref backColor, ref displayStr); } #endregion break; case MonitorDisplayType.Power: #region ��Դ if (monitorData == null) { break; } _curMCPowerCnt = GetMonitorColorAndValue.GetMonitorPowerCnt(_curMonitorConfigInfo.MCPowerInfo, monitorDataKey); if (_curMCPowerCnt == 0) { break; } int powerIndex = 0; for (int j = 0; j < _curMCPowerCnt; j++) { if (j > 0) { displayStr += "-"; } powerIndex = j + 1; //��ؿ���ѹ valueInfo = new ValueInfo(); if (monitorData.VoltageOfMonitorCardCollection == null || powerIndex >= monitorData.VoltageOfMonitorCardCollection.Count) { valueInfo.IsValid = false; } else { valueInfo = monitorData.VoltageOfMonitorCardCollection[powerIndex]; } GetPowerOneSwitchInfo(valueInfo, ref hasErrFanOrPower, ref backColor, ref displayStr); } #endregion break; case MonitorDisplayType.RowLine: GetMonitorColorAndValue.GetRowLineCorAndStr(monitorData, rowLineData, ref backColor); break; case MonitorDisplayType.GeneralSwitch: GetMonitorColorAndValue.GetGeneralSwitchClr(monitorData, generalStatus, ref backColor); break; #endregion } UpdateOneScanBoardInfo(i, backColor, displayStr, _curAllScanBoardMonitorInfList[i].ScanBordInfo); } } }
public Task SetValueAsync <T> (IPropertyInfo property, ValueInfo <T> value, PropertyVariation variations = null) { value = new ValueInfo <T> { CustomExpression = value.CustomExpression, Source = value.Source, ValueDescriptor = value.ValueDescriptor, SourceDescriptor = value.SourceDescriptor, Value = value.Value }; if (!this.values.TryGetValue(property, out IDictionary <PropertyVariation, object> propertyValues)) { this.values[property] = propertyValues = new Dictionary <PropertyVariation, object> (); } if (value.Source != ValueSource.Local && ValueEvaluator != null) { value.Value = (T)ValueEvaluator(property, value.ValueDescriptor, value.SourceDescriptor); } else if (value.Source == ValueSource.Unset || (property.ValueSources.HasFlag(ValueSources.Default) && Equals(value.Value, default(T))) && value.ValueDescriptor == null && value.SourceDescriptor == null) { if (propertyValues.Remove(variations ?? NeutralVariations)) { PropertyChanged?.Invoke(this, new EditorPropertyChangedEventArgs(property, variations)); return(Task.CompletedTask); } } object softValue = value; if (typeof(T) != property.Type) { IPropertyConverter converter = property as IPropertyConverter; bool changeValueInfo = false; object v = value.Value; if (ReferenceEquals(value.Value, null) && property.Type.IsValueType) { if ((property.ValueSources & ValueSources.Default) == ValueSources.Default) { v = Activator.CreateInstance(property.Type); changeValueInfo = true; } } else if (converter != null && converter.TryConvert(value.Value, property.Type, out v)) { changeValueInfo = true; } if (changeValueInfo) { var softType = typeof(ValueInfo <>).MakeGenericType(property.Type); softValue = Activator.CreateInstance(softType); softType.GetProperty("Value").SetValue(softValue, v); softType.GetProperty("ValueDescriptor").SetValue(softValue, value.ValueDescriptor); softType.GetProperty("Source").SetValue(softValue, value.Source); softType.GetProperty("SourceDescriptor").SetValue(softValue, value.SourceDescriptor); } if (typeof(T).Name == "IReadOnlyList`1") { var list = (IReadOnlyList <int>)value.Value; int iv = 0; foreach (int flag in list) { iv |= flag; } softValue = new ValueInfo <int> { Value = iv, Source = value.Source }; } } // Set to resource won't pass values so we will store it on the info since we just pass it back in GetValue if (value.Source == ValueSource.Resource && value.SourceDescriptor is Resource) { Type rt = value.SourceDescriptor.GetType(); if (rt.IsGenericType) { Type ta = rt.GetGenericArguments()[0]; if (typeof(T).IsAssignableFrom(ta)) { PropertyInfo pi = rt.GetProperty("Value"); value.Value = (T)pi.GetValue(value.SourceDescriptor); } else { TypeConverter converter = TypeDescriptor.GetConverter(ta); if (converter != null && converter.CanConvertTo(typeof(T))) { PropertyInfo pi = rt.GetProperty("Value"); value.Value = (T)converter.ConvertTo(pi.GetValue(value.SourceDescriptor), typeof(T)); } } } } propertyValues[variations ?? NeutralVariations] = softValue; PropertyChanged?.Invoke(this, new EditorPropertyChangedEventArgs(property, variations)); return(Task.CompletedTask); }
protected override void DrawGrid(Graphics drawZoonGraphic, RectangularGridInfo curGird) { if (curGird == null) { return; } if (_isDisplayAll) { return; } IGridBiningObject customObj = (IGridBiningObject)curGird.CustomObj; Color backColor = Color.Gray; int nValue = 0; bool bTempOrHumiInvalid = false; if (customObj.Type == GridType.ScanBoardGird) { ScanBoardGridBindObj scanBoardGridObj = (ScanBoardGridBindObj)customObj; #region 获取格子背景颜色 if (customObj != null) { switch (_curType) { case MonitorDisplayType.SBStatus: GetMonitorColorAndValue.GetSBStatusColorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.MCStatus: GetMonitorColorAndValue.GetMCStatusColorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Smoke: GetMonitorColorAndValue.GetSmokeColorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Temperature: bTempOrHumiInvalid = !GetMonitorColorAndValue.DetectTempIsValidAndGetInfo(_clrGradePartition, _curMonitorConfigInfo.TempDisplayType, scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref nValue, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Humidity: bTempOrHumiInvalid = !GetMonitorColorAndValue.DetectHumiValidAndGetInfo(_clrGradePartition, scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref nValue, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Fan: curGird.Style.BackColor = Color.Gray; break; case MonitorDisplayType.Power: curGird.Style.BackColor = Color.Gray; break; case MonitorDisplayType.RowLine: GetMonitorColorAndValue.GetRowLineCorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, scanBoardGridObj.ScanBoardAndMonitorInfo.RowLineStatus, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.GeneralSwitch: GetMonitorColorAndValue.GetGeneralSwitchClr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, scanBoardGridObj.ScanBoardAndMonitorInfo.GeneralSwitchList, ref backColor); curGird.Style.BackColor = backColor; break; } } #endregion base.DrawGrid(drawZoonGraphic, curGird); #region 绘制格子上的字符串和图标 if (scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData == null) { return; } RectangleF drawRect = new RectangleF(curGird.DrawRegion.X + this.DefaultStyle.BoardWidth / 2, curGird.DrawRegion.Y + this.DefaultStyle.BoardWidth / 2, curGird.DrawRegion.Width - this.DefaultStyle.BoardWidth, curGird.DrawRegion.Height - this.DefaultStyle.BoardWidth); ScannerMonitorData monitorInfo = (ScannerMonitorData)scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData.Clone(); if (customObj != null && monitorInfo != null) { if (_curType == MonitorDisplayType.Temperature || _curType == MonitorDisplayType.Humidity) { #region 绘制温湿度字符串 if (bTempOrHumiInvalid) { return; } _strSize = GetStrSize(drawZoonGraphic, nValue.ToString()); if (_strSize.Width > drawRect.Width || _strSize.Height > drawRect.Height) { //不能将字符串绘制出来 return; } DrawStrForCenter(drawZoonGraphic, nValue.ToString(), drawRect); #endregion } else if (_curType == MonitorDisplayType.Fan || _curType == MonitorDisplayType.Power) { ValueInfo valueInfo = new ValueInfo(); float fSwitchHeight = 0; Image drawImage = null; bool isDrawStr = false; float drawImageHeight = 0; float imageSize = 0; if (_curType == MonitorDisplayType.Fan) { #region 绘制风扇分割线 _curMCFanCnt = GetMonitorColorAndValue.GetMonitorFanCnt(_curMonitorConfigInfo.MCFanInfo, curGird.Key); if (_curMCFanCnt <= 0) { return; } if ((curGird.DrawRegion.Height - DrawOffset * 2) < _curMCFanCnt * _switchPen.Width || _curMCFanCnt <= 0) { //获取实际绘制的风扇个数失败 return; } fSwitchHeight = (float)drawRect.Height / _curMCFanCnt; drawImageHeight = fSwitchHeight - ImageAndStrInterval * 2; for (int i = 0; i < _curMCFanCnt; i++) { isDrawStr = true; if (monitorInfo.FanSpeedOfMonitorCardCollection == null || i >= monitorInfo.FanSpeedOfMonitorCardCollection.Count) { valueInfo = new ValueInfo(); valueInfo.IsValid = false; } else { valueInfo = monitorInfo.FanSpeedOfMonitorCardCollection[i]; } //获取风扇的图片和字符串绘制大小 GetImageAndStrSize(drawZoonGraphic, drawRect, valueInfo, fSwitchHeight, drawImageHeight, out imageSize, out _strSize, out isDrawStr); //获取绘制的图片 GetDrawImage(valueInfo, PicType.Fan, _curMonitorConfigInfo.MCFanInfo.AlarmThreshold, ref drawImage); //绘制图片和字符串 DrawImageAndStr(drawZoonGraphic, drawImage, valueInfo, drawRect, fSwitchHeight, imageSize, _strSize, isDrawStr, i); #region 废弃代码 #region 获取字符串和图片绘制的大小 //if (!valueInfo.IsValid) //{ // isDrawStr = false; // _strSize.Width = 0; //} //else //{ // _strSize = GetStrSize(drawZoonGraphic, valueInfo.Value.ToString()); //} //if (_strSize.Height > fSwitchHeight // || _strSize.Width + ImageAndStrInterval * 3 > drawRect.Width) //{ // isDrawStr = false; // _strSize.Width = 0; //} //imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 3; //imageSize = Math.Min(imageWidth, drawImageHeight); //if (imageSize < MinImageSize) //{ // isDrawStr = false; // _strSize.Width = 0; // imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 2; // imageSize = Math.Min(imageWidth, drawImageHeight); //} //if (imageSize < 0) //{ // imageSize = 0; //} #endregion #region 绘制字符串和图片 //imageRectF = new RectangleF(fRegionStartX + ImageAndStrInterval, // fRegionStartY + fSwitchHeight * i + (fSwitchHeight - imageSize) / 2, // imageSize, imageSize); //lineStartPoint = new PointF(fRegionStartX, fRegionStartY + fSwitchHeight * i); //lineEndPoint = new PointF(fRegionEndX, fRegionStartY + fSwitchHeight * i); ////绘制背景 //drawZoonGraphic.FillRectangle(_switchBrush, fRegionStartX, fRegionStartY + fSwitchHeight * i, // drawRect.Width - DrawOffset, fSwitchHeight); //drawZoonGraphic.DrawImage(drawImage, imageRectF); //if (i > 0) //{ // drawZoonGraphic.DrawLine(_switchPen, lineStartPoint, lineEndPoint); //} //if (isDrawStr) //{ // strRectF = new RectangleF(fRegionStartX + imageSize + ImageAndStrInterval * 2, // fRegionStartY + fSwitchHeight * i, // drawRect.Width - imageSize - ImageAndStrInterval * 2, // fSwitchHeight); // DrawStrForLeft(drawZoonGraphic, valueInfo.Value.ToString(), strRectF); //} #endregion #endregion } #endregion } else if (_curType == MonitorDisplayType.Power) { #region 绘制电源分割线 _curMCPowerCnt = GetMonitorColorAndValue.GetMonitorPowerCnt(_curMonitorConfigInfo.MCPowerInfo, curGird.Key); if (_curMCPowerCnt <= 0) { return; } if ((drawRect.Height - DrawOffset * 2) < _curMCPowerCnt * _switchPen.Width) { return; } fSwitchHeight = (float)drawRect.Height / _curMCPowerCnt; drawImageHeight = fSwitchHeight - ImageAndStrInterval * 2; int powerIndexInList = 0; for (int i = 0; i < _curMCPowerCnt; i++) { powerIndexInList = i + 1; isDrawStr = true; if (monitorInfo.VoltageOfMonitorCardCollection == null || powerIndexInList >= monitorInfo.VoltageOfMonitorCardCollection.Count) { valueInfo = new ValueInfo(); valueInfo.IsValid = false; } else { valueInfo = monitorInfo.VoltageOfMonitorCardCollection[powerIndexInList]; } //获取电源的图片和字符串绘制大小 GetImageAndStrSize(drawZoonGraphic, drawRect, valueInfo, fSwitchHeight, drawImageHeight, out imageSize, out _strSize, out isDrawStr); //获取绘制的图片 GetDrawImage(valueInfo, PicType.Power, _curMonitorConfigInfo.MCPowerInfo.AlarmThreshold, ref drawImage); //绘制图片和字符串 DrawImageAndStr(drawZoonGraphic, drawImage, valueInfo, drawRect, fSwitchHeight, imageSize, _strSize, isDrawStr, i); #region 废弃代码 #region 获取字符串和图片绘制的大小 //if (!valueInfo.IsValid) //{ // isDrawStr = false; // _strSize.Width = 0; //} //else //{ // _strSize = GetStrSize(drawZoonGraphic, valueInfo.Value.ToString("#0.00")); //} //if (_strSize.Height > fSwitchHeight // || _strSize.Width + ImageAndStrInterval * 3 > drawRect.Width) //{ // isDrawStr = false; // _strSize.Width = 0; //} //imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 3; //imageSize = Math.Min(imageWidth, drawImageHeight); //if (imageSize < MinImageSize) //{ // isDrawStr = false; // _strSize.Width = 0; // imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 2; // imageSize = Math.Min(imageWidth, drawImageHeight); //} //if (imageSize < 0) //{ // imageSize = 0; //} #endregion #region 绘制字符串和图片 //imageRectF = new RectangleF(fRegionStartX + ImageAndStrInterval, // fRegionStartY + fSwitchHeight * i + (fSwitchHeight - imageSize) / 2, // imageSize, imageSize); //lineStartPoint = new PointF(fRegionStartX, fRegionStartY + fSwitchHeight * i); //lineEndPoint = new PointF(fRegionEndX, fRegionStartY + fSwitchHeight * i); //GetDrawImage(valueInfo, PicType.Power, // _curMonitorConfigInfo.MCPowerInfo.AlarmThreshold, // ref drawImage); ////绘制背景 //drawZoonGraphic.FillRectangle(_switchBrush, fRegionStartX, fRegionStartY + fSwitchHeight * i, // drawRect.Width - DrawOffset, fSwitchHeight); //drawZoonGraphic.DrawImage(drawImage, imageRectF); //if (i > 0 && i < _curMCPowerCnt) //{ // drawZoonGraphic.DrawLine(_switchPen, lineStartPoint, lineEndPoint); //} //if (isDrawStr) //{ // strRectF = new RectangleF(fRegionStartX + imageSize + ImageAndStrInterval * 2, // fRegionStartY + fSwitchHeight * i, // drawRect.Width - imageSize - ImageAndStrInterval * 2, // fSwitchHeight); // DrawStrForLeft(drawZoonGraphic, valueInfo.Value.ToString("#0.00"), strRectF); //} #endregion #endregion } #endregion } } } #endregion } else if (customObj.Type == GridType.ComplexScreenGrid) { ComplexScreenGridBindObj complexScreenGridObj = (ComplexScreenGridBindObj)customObj; #region 获取格子背景颜色 backColor = Color.Gray; if (complexScreenGridObj.ComplexScreenLayout.IsAllMonitorDataIsValid) { switch (_curType) { case MonitorDisplayType.SBStatus: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.SBStatusErrCount > 0 || complexScreenGridObj.ComplexScreenLayout.AlarmInfo.SBStatusErrCount > 0) { backColor = Color.Red; } else { backColor = Color.Green; } break; case MonitorDisplayType.MCStatus: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.MCStatusErrCount > 0 || complexScreenGridObj.ComplexScreenLayout.AlarmInfo.MCStatusErrCount > 0) { backColor = Color.Red; } else { backColor = Color.Green; } break; case MonitorDisplayType.Smoke: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.SmokeAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.SmokeAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Temperature: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.TemperatureAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.TemperatureAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Humidity: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.HumidityAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.HumidityAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Fan: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.FanAlarmSwitchCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.FanAlarmSwitchCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Power: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.PowerAlarmSwitchCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.PowerAlarmSwitchCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.RowLine: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.SoketAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.SoketAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.GeneralSwitch: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.GeneralSwitchErrCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.GeneralSwitchErrCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; } } curGird.Style.BackColor = backColor; #endregion base.DrawGrid(drawZoonGraphic, curGird); #region 绘制复杂屏的边界 //drawZoonGraphic.DrawRectangle(_screenBoarderPen, // curGird.DrawRegion.X + _screenBoarderPen.Width / 2, // curGird.DrawRegion.Y + _screenBoarderPen.Width / 2, // curGird.DrawRegion.Width - _screenBoarderPen.Width, // curGird.DrawRegion.Height - _screenBoarderPen.Width); #endregion } else if (customObj.Type == GridType.ScreenGrid) { ScreenGridBindObj screenGridObj = (ScreenGridBindObj)customObj; if (!screenGridObj.ScreenIsValid) { curGird.Style.BackColor = Color.Gray; base.DrawGrid(drawZoonGraphic, curGird); } #region 绘制格子边界 --- 显示屏边界 drawZoonGraphic.DrawRectangle(_screenBoarderPen, curGird.DrawRegion.X + _screenBoarderPen.Width / 2, curGird.DrawRegion.Y + _screenBoarderPen.Width / 2, curGird.DrawRegion.Width - _screenBoarderPen.Width, curGird.DrawRegion.Height - _screenBoarderPen.Width); #endregion } }
/// <summary> /// ��ȡ��Դÿһ·����Ϣ /// </summary> /// <param name="valueInfo"></param> /// <param name="hasErrFanOrPower"></param> /// <param name="backClr"></param> /// <param name="strObj"></param> private void GetPowerOneSwitchInfo(ValueInfo valueInfo, ref bool hasErrFanOrPower, ref Color backClr, ref string diplaystr) { if (valueInfo.IsValid) { if (valueInfo.Value < _curMonitorConfigInfo.MCPowerInfo.FaultThreshold) { hasErrFanOrPower = true; backClr = Color.Red; } else if (valueInfo.Value < _curMonitorConfigInfo.MCPowerInfo.AlarmThreshold) { hasErrFanOrPower = true; backClr = Color.Yellow; } else { if (!hasErrFanOrPower) { backClr = Color.Green; } } diplaystr += valueInfo.Value.ToString(); } else { diplaystr += CommonStaticValue.StatusNoticeStr[(int)CommonStaticValue.NoticeType.Unkown]; if (!hasErrFanOrPower) { hasErrFanOrPower = true; backClr = Color.Gray; } } }
protected virtual void VisitValueExpression( XElement element, XAttribute attribute, MSBuildLanguageElement resolvedElement, MSBuildLanguageAttribute resolvedAttribute, ValueInfo info, MSBuildValueKind kind, ExpressionNode node) { }
public Setter(string propertyName, ValueInfo valueInfo) { PropertyName = propertyName; ValueInfo = valueInfo; }
private ValueInfo addElement(ValueInfo info) { binaries.Add(info); return(info); }
private static object GetInstance(object obj, PropertyInfo propertyInfo, ValueInfo valueInfo) { // Convert a ValueInfo to an actual object instance object instance = null; // If the property on 'obj' already exists and doesn't require special constructor // parameters, then re-use it. This fixes problems when the property has been set // already using an object of a derived type, in which case the skin file should // not try to re-create the object, but should instead just set properties on the // existing object. if (propertyInfo != null && propertyInfo.CanRead && valueInfo.ConstructorParams.Count == 0) instance = propertyInfo.GetValue(obj, null); if (instance == null) { // We must create the object for the property. if (valueInfo.ConstructorParams.Count == 0) { instance = valueInfo.Type == typeof (string) ? valueInfo.Value.Clone() : Activator.CreateInstance(valueInfo.Type); } else { Type[] paramTypeArray = valueInfo.ConstructorParams.Select(param => param.Type).ToArray(); ConstructorInfo constructor = valueInfo.Type.GetConstructor(paramTypeArray); if (constructor != null) instance = constructor.Invoke(valueInfo.ConstructorParams.Select( param => GetInstance(null, null, param)).ToArray()); } } // Then set any properties foreach (Setter setter in valueInfo.Setters) { PropertyInfo childPropertyInfo = valueInfo.Type.GetProperty(setter.PropertyName, PropertyLookupType); if (childPropertyInfo == null) { Outputs.WriteLine(OutputMessageType.Warning, "The skin " + ActiveSkin.SkinFile + " attempted to set a property on an object of type " + valueInfo.Type.FullName + ", but this property, " + setter.PropertyName + ", doesn't exist."); continue; } if (setter.ValueInfo != null) childPropertyInfo.SetValue(instance, GetInstance(instance, childPropertyInfo, setter.ValueInfo), null); else if (setter.ListInfo != null) childPropertyInfo.SetValue(instance, GetInstance(setter.ListInfo), null); else throw new InvalidOperationException("Setter '" + setter.PropertyName + "' doesn't have a valueInfo, nor listInfo, specified. Must have one (and only one) of either."); } if (valueInfo.Setters.Count == 0 && valueInfo.Value != null) { // this is a built-in type and we need to go ahead and set the value // of the instance using the converter if(valueInfo.Converter.CanConvertTo(null, valueInfo.Type)) instance = valueInfo.Converter.ConvertTo(null,CultureInfo.InvariantCulture,valueInfo.Value, valueInfo.Type); } return instance; }
protected override void VisitValueExpression(XElement element, XAttribute attribute, MSBuildLanguageElement resolvedElement, MSBuildLanguageAttribute resolvedAttribute, ValueInfo info, MSBuildValueKind kind, ExpressionNode node) { switch (kind.GetScalarType()) { case MSBuildValueKind.TargetName: foreach (var n in node.WithAllDescendants()) { if (n is ExpressionText lit && lit.IsPure) { Navigations.Add(new MSBuildNavigationResult( MSBuildReferenceKind.Target, lit.Value, lit.Offset, lit.Length )); } } break; case MSBuildValueKind.File: case MSBuildValueKind.FileOrFolder: case MSBuildValueKind.ProjectFile: case MSBuildValueKind.TaskAssemblyFile: case MSBuildValueKind.Unknown: if (node is ListExpression list) { foreach (var n in list.Nodes) { var p = GetPathFromNode(n, (MSBuildRootDocument)Document); if (p != null) { Navigations.Add(p); } } } var path = GetPathFromNode(node, (MSBuildRootDocument)Document); if (path != null) { Navigations.Add(path); } break; } }
private Tuple<VariableTreeDimension, ValueInfo> Handle_Expr_ArrayItem(XmlNode node) { VariableTreeDimension arrayKey; var itemInfo = new ValueInfo(); var valueResult = Analyze(node.GetSubNode(AstConstants.Subnode + ":" + AstConstants.Subnodes.Value)); itemInfo.Taints = valueResult.ExpressionTaint; if (valueResult.ValueInfo != null) { itemInfo = valueResult.ValueInfo.AssignmentClone(); } var dimension = node.GetSubNode(AstConstants.Subnode + ":" + AstConstants.Subnodes.Key); Analyze(dimension); // Start dimension resolving - This should probably be refactored! var dimNode = dimension.GetSubNodesByPrefix(AstConstants.Node).SingleOrDefault(); // Rules: // Strings with valid integers are cast // Floats are cast to integer (fraction is truncated) // Bools are cast to integers (true = 1, false = 0) // Null = empty string // Arrays/Objects cannot be used as key. // // Conflict - Last one wins. if (dimNode == null) { arrayKey = new VariableTreeDimension() { Index = -1, Key = "$UKENDT$" }; } else { if (dimNode.Name == AstConstants.Node + ":" + AstConstants.Nodes.Scalar_String) { var stringValue = ScalarNode.GetStringValue(dimNode); arrayKey = new VariableTreeDimension() { Key = stringValue }; double indexValue; if (double.TryParse(stringValue, out indexValue)) { arrayKey.Index = (int)indexValue; } } else if (dimNode.Name == AstConstants.Node + ":" + AstConstants.Nodes.Scalar_LNumber) { var index = ScalarNode.GetLValue(dimNode); arrayKey = new VariableTreeDimension() { Index = index, Key = index.ToString(CultureInfo.InvariantCulture) }; } else if (dimNode.Name == AstConstants.Node + ":" + AstConstants.Nodes.Scalar_DNumber) { var index = (int)ScalarNode.GetDValue(dimNode); arrayKey = new VariableTreeDimension() { Index = index, Key = index.ToString(CultureInfo.InvariantCulture) }; } else { // Default case. ie. Non resolvable dimension arrayKey = new VariableTreeDimension() { Index = -1, Key = "$UKENDT$" }; } } // End dimension resolving. return new Tuple<VariableTreeDimension, ValueInfo>(arrayKey, itemInfo); }
public object GetValue(byte formatByte, ValueInfo valueInfo, byte[] contentBytes) { throw Exceptions.FormatByteNotSupported(formatByte); }