public static bool IsDayValid(Dictionary <string, ZValue> values) { int day; //object o = values["day_near_current_date"]; ZValue v = values["day_near_current_date"]; //if (o is string) if (v is ZString) { string s = (string)v; s = s.Replace('o', '0'); s = s.Replace('O', '0'); if (!int.TryParse(s, out day)) { return(false); } } else if (v is ZInt) { day = (int)v; } else { return(false); } Date current = Date.Today; Date previousMonth = current.AddMonths(-1); // date1 = day of current month, date2 = day of previous month return(IsDateValid(current.Year, current.Month, day) || IsDateValid(previousMonth.Year, previousMonth.Month, day)); }
private static void SetHtmlImageValue(HtmlImage htmlImage, string name, ZValue value) { //if (_trace) // Trace.WriteLine($"GetHtmlImage() : set image value \"{name}\" = {value}"); switch (name) { case "nonealign": htmlImage.NoneAlign = (bool)(ZBool)value; break; case "leftalign": htmlImage.LeftAlign = (bool)(ZBool)value; break; case "rightalign": htmlImage.RightAlign = (bool)(ZBool)value; break; case "width": htmlImage.Width = (int)(ZInt)value; break; default: pb.Trace.WriteLine($"unknow value \"{name}\" = {value}"); break; } }
// type_dossier : name public override bool TrySetValues(NamedValues <ZValue> values) { if (!base.TrySetValues(values)) { return(false); } LeMondeType type; if (!TryGetType(values, out type)) { return(false); } if (type != LeMondeType.Unknow) { _type = type; } if (values.ContainsKey("type_dossier")) { ZValue v = values["type_dossier"]; if (v != null && v is ZString) { _dossier = (string)v; } } _typeCode = null; return(true); }
private ZValue ReadZValueFromBsonDocument(BsonReader bsonReader) { // { "_t" : "ZString", "value" : "" } bsonReader.ReadStartDocument(); BsonType type = bsonReader.ReadBsonType(); if (type != BsonType.String) { throw new PBException("error reading ZValue can't find ZValue type \"_t\""); } string name = bsonReader.ReadName(); if (name != "_t") { throw new PBException("error reading ZValue can't find ZValue type \"_t\""); } string typeName = bsonReader.ReadString(); type = bsonReader.ReadBsonType(); name = bsonReader.ReadName(); if (name != "value") { throw new PBException("error reading ZValue can't find ZValue value \"value\""); } ZValue value = null; switch (typeName) { case "ZString": if (type != BsonType.String) { throw new PBException("error reading ZString value is'nt a string ({0})", type); } value = new ZString(bsonReader.ReadString()); break; //case "ZStringArray": // if (type != BsonType.Array) // throw new PBException("error reading ZStringArray value is'nt an array ({0})", type); // value = new ZString(bsonReader.ReadString()); // break; case "ZInt": if (type != BsonType.Int32) { throw new PBException("error reading ZInt value is'nt an int32 ({0})", type); } value = new ZInt(bsonReader.ReadInt32()); break; default: throw new PBException("error reading ZValue type \"{0}\" is'nt a ZValue type", typeName); } type = bsonReader.ReadBsonType(); if (type != BsonType.EndOfDocument) { throw new PBException("error reading ZValue cant find end of document ({0})", type); } bsonReader.ReadEndDocument(); return(value); }
private void AddYear(ZValue value, int index, int length) { if (_trace) { Trace.WriteLine($"add year \"{value}\" index {index} length {length}"); } _years.Add(new ResponseYear(int.Parse((string)value), index, length)); }
private ZString ConvertNumericResponseCodes(ZValue value) { StringBuilder sb = new StringBuilder(); foreach (char c in (string)value) { sb.Append((char)(c + 'A' - '1')); } return((ZString)sb.ToString()); }
protected override MutableObject Mutate(MutableObject mutable) { QuaternionTarget.SetValue(new Quaternion( XValue.GetFirstValue(mutable), YValue.GetFirstValue(mutable), ZValue.GetFirstValue(mutable), WValue.GetFirstValue(mutable)), mutable); return(mutable); }
public VectorSlider(PropertyInfo prop, object owner, float min = 0, float max = 1, NodeType type = NodeType.Float4, bool isInt = false) { InitializeComponent(); property = prop; propertyOwner = owner; this.min = min; this.max = max; switch (type) { case NodeType.Float2: ZView.Visibility = Visibility.Collapsed; WView.Visibility = Visibility.Collapsed; break; case NodeType.Float3: ZView.Visibility = Visibility.Visible; WView.Visibility = Visibility.Collapsed; break; case NodeType.Float4: ZView.Visibility = Visibility.Visible; WView.Visibility = Visibility.Visible; break; } object b = prop.GetValue(owner); if (b == null) { pc = new VectorPropertyContainer(new MVector()); } else { MVector vec = (MVector)b; pc = new VectorPropertyContainer(vec); } pc.OnUpdate += Pc_OnUpdate; var xprop = pc.GetType().GetProperty("XProp"); var yprop = pc.GetType().GetProperty("YProp"); var zprop = pc.GetType().GetProperty("ZProp"); var wprop = pc.GetType().GetProperty("WProp"); XValue.IsInt = isInt; YValue.IsInt = isInt; ZValue.IsInt = isInt; WValue.IsInt = isInt; XValue.Set(min, max, xprop, pc); YValue.Set(min, max, yprop, pc); ZValue.Set(min, max, zprop, pc); WValue.Set(min, max, wprop, pc); }
protected override MutableObject Mutate(MutableObject mutable) { foreach (var entry in VectorScope.GetEntries(mutable)) { Vector3Target.SetValue(new Vector3( XValue.GetFirstValueBelowArrity(entry), YValue.GetFirstValueBelowArrity(entry), ZValue.GetFirstValueBelowArrity(entry)), entry); } return(mutable); }
public override int GetHashCode() { unchecked { var hashCode = XValue.GetHashCode(); hashCode = (hashCode * 397) ^ YValue.GetHashCode(); hashCode = (hashCode * 397) ^ ZValue.GetHashCode(); hashCode = (hashCode * 397) ^ Timestamp.GetHashCode(); return(hashCode); } }
private void SetValue(QuestionValue questionValue, string name, ZValue value) { switch (name.ToLower()) { //case "response": case "choice": // $$pb modif le 03/05/2017 //((QuestionValueResponse)questionValue).Response = (string)value; ((QuestionValueResponse)questionValue).Response = ((string)value).Trim(); break; default: throw new PBFileException($"unknow value \"{name}\" = {value} line {_lineNumber} file \"{_filename}\"", _file, _lineNumber); } }
private Response SetResponse(ZValue value, int index, int length, ResponseQuestion responseQuestion) { if (responseQuestion == null) { responseQuestion = GetResponseQuestion(GetMiddlePosition(index, length)); } if (_trace) { Trace.WriteLine($"set response \"{value}\" question {responseQuestion.QuestionNumber} index {index} length {length}"); } responseQuestion.FoundResponse = true; return(new Response { Category = _category, Year = responseQuestion.Year, QuestionNumber = responseQuestion.QuestionNumber, Responses = (string)value, SourceFile = responseQuestion.SourceFile, SourceLine = responseQuestion.SourceLineNumber }); }
private ResponseQuestion NewQuestion(ZValue value, int index, int length, ResponseQuestion responseQuestion) { if (_trace) { Trace.WriteLine($"new question \"{value}\" index {index} length {length}"); } if (responseQuestion != null) { SaveQuestion(responseQuestion); } responseQuestion = new ResponseQuestion(int.Parse((string)value), index, length) { SourceFile = _sourceFile, SourceLineNumber = _lineNumber }; responseQuestion.Year = GetYear(responseQuestion.Position); return(responseQuestion); }
public static bool TryGetDay(NamedValues <ZValue> values, out int day) { day = 0; if (values.ContainsKey("day")) { ZValue v = values["day"]; if (v is ZString) { day = GetDayNumber((string)v); if (day != 0) { return(true); } } else { Trace.WriteLine("error day should be a string : {0}", v); } } return(false); }
private void UpdateAxisAngleSettings(object sender, EventArgs e) { //Clear prior values myprocTransformGroup.Children.Clear(); WValue.Clear(); XValue.Clear(); YValue.Clear(); ZValue.Clear(); //<SnippetQuaternionView3DN4> //Read new settings Double angle = System.Convert.ToDouble(AngleValue.Text); try { Double xaxis = System.Convert.ToDouble(XAxisValue.Text); Double yaxis = System.Convert.ToDouble(YAxisValue.Text); Double zaxis = System.Convert.ToDouble(ZAxisValue.Text); endQuaternion = new Quaternion(new Vector3D(xaxis, yaxis, zaxis), angle); } catch { XAxisValue.Text = "Axis must be nonzero Vector3D"; YAxisValue.Text = "Axis must be nonzero Vector3D"; ZAxisValue.Text = "Axis must be nonzero Vector3D"; } endRotation.Quaternion = endQuaternion; //</SnippetQuaternionView3DN4> //Update quaternion display WValue.Text = endQuaternion.W.ToString(); XValue.Text = endQuaternion.X.ToString(); YValue.Text = endQuaternion.Y.ToString(); ZValue.Text = endQuaternion.Z.ToString(); //build in some if clauses to determine the animation method to call startAnimation(); }
private QuestionValue GetValue(string name, ZValue value) { switch (name.ToLower()) { case "year": return(new QuestionValueYear { Year = int.Parse((string)value) }); case "questiontype": //return new QuestionValueQuestionType { QuestionType = ((string)value).zParseEnum<QuestionType>(ignoreCase: true) }; return(new QuestionValueQuestionType { QuestionType = GetQuestionType((string)value) }); case "questionnumber": return(new QuestionValueQuestionNumber { QuestionNumber = int.Parse((string)value) }); //case "responsecode": //case "characterresponsecodes": case "characterchoicecode": return(new QuestionValueResponse { ResponseCode = ((string)value)[0] }); //case "numericresponsecodes": case "numericchoicecode": return(new QuestionValueResponse { ResponseCode = ConvertNumericResponseCode(((string)value)[0]) }); //case "pagenumber": // return new QuestionValue { Type = QuestionValueType.None }; default: throw new PBFileException($"unknow value \"{name}\" = {value} line {_lineNumber} file \"{_filename}\"", _file, _lineNumber); } }
public FindNumber Find(string text) { foreach (RegexValues rv in _numberRegexList.Values) { MatchValues matchValues = rv.Match(text); if (matchValues.Success) { NamedValues <ZValue> values = matchValues.GetValues(); if (values.ContainsKey("number")) { int number; ZValue value = values["number"]; if (value is ZString) { if (!int.TryParse((string)value, out number)) { throw new PBException("error finding number text is'nt a number : \"{0}\"", (string)value); } } else if (value is ZInt) { number = (int)value; } else { throw new PBException("error finding number value is'nt a number : {0}", value); } //return new FindNumber { found = true, number = number, remainText = rv.MatchReplace("_"), regexValues = rv }; return(new FindNumber { found = true, number = number, matchValues = matchValues }); } } } return(new FindNumber { found = false }); }
private void SetOption(string option, ZValue value) { switch (option) { case "traceinit": if (!(value is ZBool)) { throw new PBException($"wrong type for runsource option TraceInit {value.GetType().zGetTypeName()}"); } TraceInit((bool)(ZBool)value); break; case "traceduplicatesource": if (!(value is ZBool)) { throw new PBException($"wrong type for runsource option TraceDuplicateSource {value.GetType().zGetTypeName()}"); } ProjectCompiler.TraceDuplicateSource = (bool)(ZBool)value; break; default: throw new PBException($"unknow runsource option \"{option}\""); } }
public bool Equals(Acceleration other) { return(XValue.Equals(other.XValue) && YValue.Equals(other.YValue) && ZValue.Equals(other.ZValue) && Timestamp.Equals(other.Timestamp)); }
// type_code : quo, arg, arh, dos, mde, edu, aut, peh, liv, mag, mdv, sch, scq, sph, sty, nyt, tel // type_quo : // fix_type_quo : // types_quo_sup : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup // type_sup : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup // type_sups : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup // fix_type_eco : // fix_type_tv : public static bool TryGetType(NamedValues <ZValue> values, out LeMondeType type) { type = LeMondeType.Unknow; if (values.ContainsKey("type_code")) { type = GetTypeCode((string)values["type_code"]); if (type == LeMondeType.Unknow) { values.SetError("error unknow le monde type sup : \"{0}\"", values["type_code"]); return(false); } } else if ((values.ContainsKey("type_quo") && values["type_quo"] != null) || values.ContainsKey("fix_type_quo")) { type = LeMondeType.Quotidien; if (values.ContainsKey("types_quo_sup")) { ZValue v = values["types_quo_sup"]; if (v != null && !(v is ZStringArray)) { values.SetError("error creating LeMonde value types_quo_sup should be a string array : {0}", v); return(false); } foreach (string s in (string[])v) { LeMondeType type2 = GetTypeSup(s); if (type2 == LeMondeType.Unknow) { values.SetError("error unknow le monde type sup : \"{0}\"", s); return(false); } type |= type2; } } } else if (values.ContainsKey("type_sup")) { ZValue v = values["type_sup"]; if (!(v is ZString)) { values.SetError("error creating LeMonde value type_sup should be a string : {0}", v); return(false); } type = GetTypeSup((string)v); if (type == LeMondeType.Unknow) { values.SetError("error unknow le monde type sup : \"{0}\"", v); return(false); } } else if (values.ContainsKey("type_sups")) { ZValue v = values["type_sups"]; if (v != null) { if (v is ZString) { LeMondeType type2 = GetTypeSup((string)v); if (type2 == LeMondeType.Unknow) { values.SetError("error unknow le monde type sup : \"{0}\"", (string)v); return(false); } type = type2; } else if (v is ZStringArray) { type = LeMondeType.Unknow; foreach (string s in (string[])v) { LeMondeType type2 = GetTypeSup(s); if (type2 == LeMondeType.Unknow) { values.SetError("error unknow le monde type sup : \"{0}\"", s); //return false; } else { type |= type2; } } } else { values.SetError("error creating LeMonde value type_sups should be a string or string array : {0}", v); return(false); } } } else if (values.ContainsKey("fix_type_eco")) { type = LeMondeType.Economie; } else if (values.ContainsKey("fix_type_tv")) { type = LeMondeType.TV; } return(true); }