public void TestTimePeriod_With_Invalid_FromDate_And_Same_UntilDate() { // Arrange DateTime dtFrom = DateTime.Now; TimeElement elementFrom = new TimeElement(dtFrom, false) { IsUntil = true }; var duration = new Mock <Duration>(DateTime.Now); // Act new TimePeriod(elementFrom, elementFrom, duration.Object); }
public void TestTimeElement_As_UntilDate() { // Arrange DateTime dtDate = DateTime.Now; // Act TimeElement element = new TimeElement(dtDate, false); // Assert Assert.AreEqual(dtDate, element.Date); Assert.IsFalse(element.IsFrom); Assert.IsTrue(element.IsUntil); }
public void TestTimePeriod_With_FromDate() { // Arrange DateTime dtFrom = DateTime.Now; TimeElement elementFrom = new TimeElement(dtFrom, true); var duration = new Mock <Duration>(DateTime.Now); // Act TimePeriod period = new TimePeriod(elementFrom, duration.Object); // Assert Assert.AreEqual(elementFrom, period.From); Assert.IsNull(period.Until); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as CalibrationComponent; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if(TypeElement != null) dest.TypeElement = (Code<Hl7.Fhir.Model.DeviceMetric.DeviceMetricCalibrationType>)TypeElement.DeepCopy(); if(StateElement != null) dest.StateElement = (Code<Hl7.Fhir.Model.DeviceMetric.DeviceMetricCalibrationState>)StateElement.DeepCopy(); if(TimeElement != null) dest.TimeElement = (Hl7.Fhir.Model.Instant)TimeElement.DeepCopy(); return dest; }
public void TestTimePeriod_With_FromDate_And_UntilDate() { // Arrange DateTime dtFrom = DateTime.Now; TimeElement elementFrom = new TimeElement(dtFrom, true); DateTime dtUntil = dtFrom.AddMonths(1); TimeElement elementUntil = new TimeElement(dtUntil, false); var duration = new Mock <Duration>(DateTime.Now); // Act TimePeriod period = new TimePeriod(elementFrom, elementUntil, duration.Object); // Assert Assert.AreEqual(elementFrom, period.From); Assert.AreEqual(elementUntil, period.Until); }
public void TestDuration() { // Arrange DateTime dtFrom = DateTime.Now; TimeElement elementFrom = new TimeElement(dtFrom, true); DateTime dtUntil = dtFrom.AddMonths(1); TimeElement elementUntil = new TimeElement(dtUntil, false); var duration = new Mock <Duration>(DateTime.Now); TimePeriod timePeriod = new TimePeriod(elementFrom, elementUntil, duration.Object); // Act Duration duration1 = timePeriod.Duration; // Assert Assert.IsNotNull(duration1); Assert.AreEqual(duration.Object, duration1); }
public void TestBuildTimePeriods() { // Arrange SortedList <DateTime, TimeElement> sortedList = new SortedList <DateTime, TimeElement>(); DateTime dtFrom = new DateTime(2010, 1, 1); TimeElement elementFrom = new TimeElement(dtFrom, true); sortedList.Add(dtFrom, elementFrom); DatePeriodBuilder builder = new DatePeriodBuilder(); // Act IList <TimePeriod> periods = builder.BuildTimePeriods(sortedList); // Assert Assert.AreEqual(1, periods.Count); Assert.AreEqual(elementFrom, periods[0].From); Assert.IsNull(periods[0].Until); }
private static void GetWeather(string method, string city, ref WeatherTxt weatherTxt) { //WeatherTxt weatherTxt = new WeatherTxt(); string appId = File.ReadAllText(@"appId.txt"); string url = "http://api.openweathermap.org/data/2.5/" + method + "?q=" + city + "&mode=xml&units=metric" + appId; string data = @"C:\Users\Владимир\Documents\Visual Studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\bin\Debug\WeatherXml\" + Regex.Replace(System.DateTime.Now.ToLongTimeString(), "[:]", ".") + ".xml"; Console.WriteLine(data); XDocument weather = new XDocument(); weather = XDocument.Load(url); weather.Save(data); if (method == "weather") { foreach (XElement TemElement in weather.Element("current").Elements("temperature")) { XAttribute valueAttribute = TemElement.Attribute("value"); weatherTxt.SetBody(valueAttribute.Value); } weatherTxt.BodyToTxt(weatherTxt.getBody()); } else if (method == "forecast") { foreach (XElement TimeElement in weather.Element("weatherdata").Element("forecast").Elements("time")) { XAttribute valueAttribute = TimeElement.Element("temperature").Attribute("value"); weatherTxt.SetBody(valueAttribute.Value); } weatherTxt.BodyToTxt(weatherTxt.getBody()); } else if (method == "forecast/daily") { foreach (XElement TimeElement in weather.Element("weatherdata").Element("forecast").Elements("time")) { XAttribute valueAttribute = TimeElement.Element("temperature").Attribute("day"); weatherTxt.SetBody(valueAttribute.Value); } weatherTxt.BodyToTxt(weatherTxt.getBody()); } }
public WeatherTxt GetWeather(string method, string city) { url = "http://api.openweathermap.org/data/2.5/" + method + "?q=" + city + "&mode=xml&units=metric" + appId; date = @"H:\Users\denis\\Documents\Visual Studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\bin\\Debug\WeatherXml\" + Regex.Replace(System.DateTime.Now.ToLongTimeString(), "[:]", ".") + ".xml"; Console.WriteLine(date); XDocument weather = new XDocument(); weather = XDocument.Load(url); weather.Save(date); if (method == "weather") { foreach (XElement TemElement in weather.Element("current").Elements("temperature")) { XAttribute valueAttribute = TemElement.Attribute("value"); SetBody(valueAttribute.Value); } BodyToTxt(getBody()); } else if (method == "forecast") { foreach (XElement TimeElement in weather.Element("weatherdata").Element("forecast").Elements("time")) { XAttribute valueAttribute = TimeElement.Element("temperature").Attribute("value"); SetBody(valueAttribute.Value); } BodyToTxt(getBody()); } else if (method == "forecast/daily") { foreach (XElement TimeElement in weather.Element("weatherdata").Element("forecast").Elements("time")) { XAttribute valueAttribute = TimeElement.Element("temperature").Attribute("day"); SetBody(valueAttribute.Value); } BodyToTxt(getBody()); } WeatherTxt weatherTxt = new WeatherTxt(getBodyTxt(), getBody()); return(weatherTxt); }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (ModeElement != null) { result.AddRange(ModeElement.Validate()); } if (TimeElement != null) { result.AddRange(TimeElement.Validate()); } if (Party != null) { result.AddRange(Party.Validate()); } return(result); }
public void SpawnElement(Player player, float time, int position, bool died = false) { TimeElement element = Instantiate(elementTemplate, elementTemplate.transform.parent); element.Show(); element.background.color = player.color; element.player = player; if (time == float.MaxValue) { element.time.text = "died.."; } else { element.time.text = time.ToString("F1") + " <size='27'>sec</size>"; } if (position == int.MaxValue) { element.position.text = ""; } else { element.position.text = position + "."; } element.SetPosition(position); if (died) { element.SetDead(); } else { spawnedElements.Add(element); } }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as Annotation; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Author != null) { dest.Author = (Hl7.Fhir.Model.Element)Author.DeepCopy(); } if (TimeElement != null) { dest.TimeElement = (Hl7.Fhir.Model.FhirDateTime)TimeElement.DeepCopy(); } if (Text != null) { dest.Text = (Hl7.Fhir.Model.Markdown)Text.DeepCopy(); } return(dest); }
public static RootElement TestElements() { RootElement re1 = new RootElement("re1"); Debug.WriteLine(re1.ToString()); Section s1 = new Section(); Debug.WriteLine(s1.ToString()); //Section s2 = new Section(new Android.Views.View(a1)); //Debug.WriteLine(s2.ToString()); Section s3 = new Section("s3"); Debug.WriteLine(s3.ToString()); //Section s4 = new Section // ( // new Android.Views.View(a1) // , new Android.Views.View(a1) // ); //Debug.WriteLine(s4.ToString()); Section s5 = new Section("caption", "footer"); Debug.WriteLine(s5.ToString()); StringElement se1 = new StringElement("se1"); Debug.WriteLine(se1.ToString()); StringElement se2 = new StringElement("se2", delegate() { }); Debug.WriteLine(se2.ToString()); //StringElement se3 = new StringElement("se3", 4); StringElement se4 = new StringElement("se4", "v4"); Debug.WriteLine(se4.ToString()); //StringElement se5 = new StringElement("se5", "v5", delegate() { }); // removed - protected (all with LayoutID) // StringElement se6 = new StringElement("se6", "v6", 4); // Debug.WriteLine(se6.ToString()); // not cross platform! // TODO: make it!?!?!? // AchievementElement BooleanElement be1 = new BooleanElement("be1", true); Debug.WriteLine(be1.ToString()); BooleanElement be2 = new BooleanElement("be2", false, "key"); Debug.WriteLine(be2.ToString()); // Abstract // BoolElement be3 = new BoolElement("be3", true); CheckboxElement cb1 = new CheckboxElement("cb1"); Debug.WriteLine(cb1.ToString()); CheckboxElement cb2 = new CheckboxElement("cb2", true); Debug.WriteLine(cb2.ToString()); CheckboxElement cb3 = new CheckboxElement("cb3", false, "group1"); Debug.WriteLine(cb3.ToString()); CheckboxElement cb4 = new CheckboxElement("cb4", false, "subcaption", "group2"); Debug.WriteLine(cb4.ToString()); DateElement de1 = new DateElement("dt1", DateTime.Now); Debug.WriteLine(de1.ToString()); // TODO: see issues // https://github.com/kevinmcmahon/MonoDroid.Dialog/issues?page=1&state=open EntryElement ee1 = new EntryElement("ee1", "ee1"); Debug.WriteLine(ee1.ToString()); EntryElement ee2 = new EntryElement("ee2", "ee2 placeholder", "ee2 value"); Debug.WriteLine(ee2.ToString()); EntryElement ee3 = new EntryElement("ee3", "ee3 placeholder", "ee3 value", true); Debug.WriteLine(ee3.ToString()); FloatElement fe1 = new FloatElement("fe1"); Debug.WriteLine(fe1.ToString()); FloatElement fe2 = new FloatElement(-0.1f, 0.1f, 3.2f); Debug.WriteLine(fe2.ToString()); FloatElement fe3 = new FloatElement ( null , null // no ctors new Android.Graphics.Bitmap() , 1.0f ); Debug.WriteLine(fe3.ToString()); HtmlElement he1 = new HtmlElement("he1", "http://holisiticware.net"); Debug.WriteLine(he1.ToString()); // TODO: image as filename - cross-platform ImageElement ie1 = new ImageElement(null); Debug.WriteLine(ie1.ToString()); // TODO: not in Kevin's MA.D // ImageStringElement MultilineElement me1 = new MultilineElement("me1"); Debug.WriteLine(me1.ToString()); MultilineElement me2 = new MultilineElement("me2", delegate() { }); Debug.WriteLine(me2.ToString()); MultilineElement me3 = new MultilineElement("me3", "me3 value"); Debug.WriteLine(me3.ToString()); RadioElement rde1 = new RadioElement("rde1"); Debug.WriteLine(rde1.ToString()); RadioElement rde2 = new RadioElement("rde1", "group3"); Debug.WriteLine(rde2.ToString()); // TODO: not in Kevin's MA.D // StyledMultilineElement TimeElement te1 = new TimeElement("TimeElement", DateTime.Now); Debug.WriteLine(te1.ToString()); re1.Add(s1); //re1.Add(s2); re1.Add(s3); //re1.Add(s4); re1.Add(s5); return(re1); }
private void Populate(object callbacks, object o, RootElement root) { MemberInfo last_radio_index = null; var members = o.GetType().GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); Section section = null; foreach (var mi in members) { Type mType = GetTypeForMember(mi); if (mType == null) { continue; } string caption = null; object[] attrs = mi.GetCustomAttributes(false); bool skip = false; foreach (var attr in attrs) { if (attr is SkipAttribute || attr is System.Runtime.CompilerServices.CompilerGeneratedAttribute) { skip = true; } else if (attr is CaptionAttribute) { caption = ((CaptionAttribute)attr).Caption; } else if (attr is SectionAttribute) { if (section != null) { root.Add(section); } var sa = attr as SectionAttribute; section = new Section(sa.Caption, sa.Footer); } } if (skip) { continue; } if (caption == null) { caption = MakeCaption(mi.Name); } if (section == null) { section = new Section(); } Element element = null; if (mType == typeof(string)) { PasswordAttribute pa = null; AlignmentAttribute align = null; EntryAttribute ea = null; object html = null; Action invoke = null; bool multi = false; foreach (object attr in attrs) { if (attr is PasswordAttribute) { pa = attr as PasswordAttribute; } else if (attr is EntryAttribute) { ea = attr as EntryAttribute; } else if (attr is MultilineAttribute) { multi = true; } else if (attr is HtmlAttribute) { html = attr; } else if (attr is AlignmentAttribute) { align = attr as AlignmentAttribute; } if (attr is OnTapAttribute) { string mname = ((OnTapAttribute)attr).Method; if (callbacks == null) { throw new Exception( "Your class contains [OnTap] attributes, but you passed a null object for `context' in the constructor"); } var method = callbacks.GetType().GetMethod(mname); if (method == null) { throw new Exception("Did not find method " + mname); } invoke = delegate { method.Invoke(method.IsStatic ? null : callbacks, new object[0]); }; } } var value = (string)GetValue(mi, o); if (pa != null) { element = new EntryElement(caption, pa.Placeholder, value, true); } else if (ea != null) { element = new EntryElement(caption, ea.Placeholder, value) { KeyboardType = ea.KeyboardType } } ; else if (multi) { element = new MultilineElement(caption, value); } else if (html != null) { element = new HtmlElement(caption, value); } else { var selement = new StringElement(caption, value); element = selement; if (align != null) { selement.Alignment = align.Alignment; } } if (invoke != null) { (element).Tapped += invoke; } } else if (mType == typeof(float)) { var floatElement = new FloatElement(null, null, (float)GetValue(mi, o)); floatElement.Caption = caption; element = floatElement; foreach (object attr in attrs) { if (attr is RangeAttribute) { var ra = attr as RangeAttribute; floatElement.MinValue = ra.Low; floatElement.MaxValue = ra.High; floatElement.ShowCaption = ra.ShowCaption; } } } else if (mType == typeof(bool)) { bool checkbox = false; foreach (object attr in attrs) { if (attr is CheckboxAttribute) { checkbox = true; } } if (checkbox) { element = new CheckboxElement(caption, (bool)GetValue(mi, o)); } else { element = new BooleanElement(caption, (bool)GetValue(mi, o)); } } else if (mType == typeof(DateTime)) { var dateTime = (DateTime)GetValue(mi, o); bool asDate = false, asTime = false; foreach (object attr in attrs) { if (attr is DateAttribute) { asDate = true; } else if (attr is TimeAttribute) { asTime = true; } } if (asDate) { element = new DateElement(caption, dateTime); } else if (asTime) { element = new TimeElement(caption, dateTime); } else { element = new DateTimeElement(caption, dateTime); } } else if (mType.IsEnum) { var csection = new Section(); ulong evalue = Convert.ToUInt64(GetValue(mi, o), null); int idx = 0; int selected = 0; foreach (var fi in mType.GetFields(BindingFlags.Public | BindingFlags.Static)) { ulong v = Convert.ToUInt64(GetValue(fi, null)); if (v == evalue) { selected = idx; } var ca = Attribute.GetCustomAttribute(fi, typeof(CaptionAttribute)) as CaptionAttribute; csection.Add(new RadioElement(ca != null ? ca.Caption : MakeCaption(fi.Name))); idx++; } element = new RootElement(caption, new RadioGroup(null, selected)) { csection }; } else if (mType == typeof(UIImage)) { element = new ImageElement((UIImage)GetValue(mi, o)); } else if (typeof(System.Collections.IEnumerable).IsAssignableFrom(mType)) { var csection = new Section(); int count = 0; if (last_radio_index == null) { throw new Exception("IEnumerable found, but no previous int found"); } foreach (var e in (IEnumerable)GetValue(mi, o)) { csection.Add(new RadioElement(e.ToString())); count++; } var selected = (int)GetValue(last_radio_index, o); if (selected >= count || selected < 0) { selected = 0; } element = new RootElement(caption, new MemberRadioGroup(null, selected, last_radio_index)) { csection }; last_radio_index = null; } else if (typeof(int) == mType) { if (attrs.OfType <RadioSelectionAttribute>().Any()) { last_radio_index = mi; } } else { var nested = GetValue(mi, o); if (nested != null) { var newRoot = new RootElement(caption); Populate(callbacks, nested, newRoot); element = newRoot; } } if (element == null) { continue; } section.Add(element); mappings[element] = new MemberAndInstance(mi, o); } root.Add(section); }
//------------------------------------------------------------------------------ RootElement CreateRoot() { var lds = DynamicSettings.GetPlugin <ILocalDynamicSettingsPlugin>(); var info = new MultilineElement("See the Settings.app for more details"); m_login = new EntryElement("Login", "Your login name", lds.GetSetting <string>(DynamicSettings.LoginSettingName)); m_login.Changed += (object sender, EventArgs e) => { lds.SetSetting(DynamicSettings.LoginSettingName, m_login.Value); lds.SaveSetting(DynamicSettings.LoginSettingName); }; m_airplaneMode = new BooleanElement("Airplane Mode", lds.GetSetting <bool>(DynamicSettings.AirplaneModeSettingName)); m_airplaneMode.ValueChanged += (object sender, EventArgs e) => { lds.SetSetting(DynamicSettings.AirplaneModeSettingName, m_airplaneMode.Value); lds.SaveSetting(DynamicSettings.AirplaneModeSettingName); }; m_notifications = new BooleanElement("Notifications", lds.GetSetting <bool>(DynamicSettings.NotificationsSettingName)); m_notifications.ValueChanged += (object sender, EventArgs e) => { lds.SetSetting(DynamicSettings.NotificationsSettingName, m_notifications.Value); lds.SaveSetting(DynamicSettings.NotificationsSettingName); }; m_brightness = new FloatElementEx(lds.GetSetting <int>(DynamicSettings.BrightnessSettingName), lockable: false, valueChanged: (val) => { lds.SetSetting(DynamicSettings.BrightnessSettingName, val); lds.SaveSetting(DynamicSettings.BrightnessSettingName); }); m_autoBrightness = new BooleanElement("Auto-brightness", lds.GetSetting <bool>(DynamicSettings.AutoBrightnessSettingName)); m_autoBrightness.ValueChanged += (object sender, EventArgs e) => { lds.SetSetting(DynamicSettings.AutoBrightnessSettingName, m_autoBrightness.Value); lds.SaveSetting(DynamicSettings.AutoBrightnessSettingName); }; m_date = new DateElement("Date", lds.GetSetting <DateTime>(DynamicSettings.DateSettingName)); m_date.DateSelected += (DateTimeElement) => { lds.SetSetting(DynamicSettings.DateSettingName, m_date.DateValue); lds.SaveSetting(DynamicSettings.DateSettingName); }; m_time = new TimeElement("Time", lds.GetSetting <DateTime>(DynamicSettings.TimeSettingName)); m_time.DateSelected += (DateTimeElement) => { lds.SetSetting(DynamicSettings.TimeSettingName, m_time.DateValue); lds.SaveSetting(DynamicSettings.TimeSettingName); }; return(new RootElement("Dynamic Settings") { new Section() { info }, new Section() { m_airplaneMode, new RootElement("Notifications", 0, 0) { new Section(null, "Turn off Notifications to disable Sounds " + "Alerts and Home Screen Badges for the applications below.") { m_notifications } } }, new Section() { new RootElement("Brightness") { new Section() { m_brightness, m_autoBrightness, } }, }, new Section() { m_login, }, new Section() { m_date, m_time, }, new Section() { CreateGeneralSection(), } }); }
/// <summary> /// 강의시간이 겹친다면 true를 리턴합니다. /// </summary> public bool CheckOverlap(TimeElement te) { return(te.Overlap(table)); }
/// <summary> /// 강의시간이 겹치거나 연강이 존재하면 true를 리턴합니다. /// </summary> public bool CheckOverlapWithContinuity(TimeElement te) { return(te.OverlapWithContinuity(table)); }
//------------------------------------------------------------------------------ RootElement CreateRoot() { var info = new MultilineElement("See the Settings.app for more details"); m_login = new EntryElement("Login", "Your login name", LocalSettings.Login); m_login.Changed += (object sender, EventArgs e) => { LocalSettings.Login = m_login.Value; LocalSettings.SaveSetting(s => LocalSettings.Login); }; m_password = new EntryElement("Password", "Your password", LocalSettings.Password, true); m_password.Changed += (object sender, EventArgs e) => { LocalSettings.Password = m_password.Value; LocalSettings.SaveSetting(s => LocalSettings.Password); }; m_airplaneMode = new BooleanElement("Airplane Mode", LocalSettings.AirplaneMode); m_airplaneMode.ValueChanged += (object sender, EventArgs e) => { LocalSettings.AirplaneMode = m_airplaneMode.Value; LocalSettings.SaveSetting(s => LocalSettings.AirplaneMode); }; m_notifications = new BooleanElement("Notifications", LocalSettings.Notifications); m_notifications.ValueChanged += (object sender, EventArgs e) => { LocalSettings.Notifications = m_notifications.Value; LocalSettings.SaveSetting(s => LocalSettings.Notifications); }; m_brightness = new FloatElementEx(LocalSettings.Brightness, lockable: false, valueChanged: (val) => { LocalSettings.Brightness = val; LocalSettings.SaveSetting(s => LocalSettings.Brightness); }); m_autoBrightness = new BooleanElement("Auto-brightness", LocalSettings.AutoBrightness); m_autoBrightness.ValueChanged += (object sender, EventArgs e) => { LocalSettings.AutoBrightness = m_autoBrightness.Value; LocalSettings.SaveSetting(s => LocalSettings.AutoBrightness); }; m_date = new DateElement("Date", LocalSettings.Date); m_date.DateSelected += (DateTimeElement) => { LocalSettings.Date = m_date.DateValue; LocalSettings.SaveSetting(s => LocalSettings.Date); }; m_time = new TimeElement("Time", LocalSettings.Time); m_time.DateSelected += (DateTimeElement) => { LocalSettings.Time = m_time.DateValue; LocalSettings.SaveSetting(s => LocalSettings.Time); }; return(new RootElement("Local Settings") { new Section() { info }, new Section() { m_airplaneMode, new RootElement("Notifications", 0, 0) { new Section(null, "Turn off Notifications to disable Sounds " + "Alerts and Home Screen Badges for the applications below.") { m_notifications } } }, new Section() { new RootElement("Brightness") { new Section() { m_brightness, m_autoBrightness, } }, }, new Section() { m_login, m_password, }, new Section() { m_date, m_time, }, new Section() { CreateGeneralSection(), } }); }
void Populate(object callbacks, object o, RootElement root) { MemberInfo last_radio_index = null; var members = o.GetType().GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); Section section = null; foreach (var mi in members) { Type mType = GetTypeForMember(mi); if (mType == null) continue; string caption = null; object[] attrs = mi.GetCustomAttributes(false); bool skip = false; foreach (var attr in attrs) { if (attr is SkipAttribute) skip = true; if (attr is CaptionAttribute) caption = ((CaptionAttribute)attr).Caption; else if (attr is SectionAttribute) { if (section != null) root.Add(section); var sa = attr as SectionAttribute; section = new Section(sa.Caption, sa.Footer); } } if (skip) continue; if (caption == null) caption = MakeCaption(mi.Name); if (section == null) section = new Section(); Element element = null; if (mType == typeof(string)) { PasswordAttribute pa = null; AlignmentAttribute align = null; EntryAttribute ea = null; object html = null; EventHandler invoke = null; bool multi = false; foreach (object attr in attrs) { if (attr is PasswordAttribute) pa = attr as PasswordAttribute; else if (attr is EntryAttribute) ea = attr as EntryAttribute; else if (attr is MultilineAttribute) multi = true; else if (attr is HtmlAttribute) html = attr; else if (attr is AlignmentAttribute) align = attr as AlignmentAttribute; if (attr is OnTapAttribute) { string mname = ((OnTapAttribute)attr).Method; if (callbacks == null) { throw new Exception("Your class contains [OnTap] attributes, but you passed a null object for `context' in the constructor"); } var method = callbacks.GetType().GetMethod(mname); if (method == null) throw new Exception("Did not find method " + mname); invoke = delegate { method.Invoke(method.IsStatic ? null : callbacks, new object[0]); }; } } string value = (string)GetValue(mi, o); if (pa != null) element = new EntryElement(caption, value) { Hint = pa.Placeholder, Password = true }; else if (ea != null) element = new EntryElement(caption, value) { Hint = ea.Placeholder }; else if (multi) element = new MultilineEntryElement(caption, value); else if (html != null) element = new HtmlElement(caption, value); else { var selement = new StringElement(caption, value); element = selement; if (align != null) selement.Alignment = align.Alignment; } if (invoke != null) ((StringElement)element).Click = invoke; } else if (mType == typeof(float)) { var floatElement = new FloatElement(null, null, (int)GetValue(mi, o)); floatElement.Caption = caption; element = floatElement; foreach (object attr in attrs) { if (attr is RangeAttribute) { var ra = attr as RangeAttribute; floatElement.MinValue = ra.Low; floatElement.MaxValue = ra.High; floatElement.ShowCaption = ra.ShowCaption; } } } else if (mType == typeof(bool)) { bool checkbox = false; foreach (object attr in attrs) { if (attr is CheckboxAttribute) checkbox = true; } if (checkbox) element = new CheckboxElement(caption, value: (bool)GetValue(mi, o)); else element = new BooleanElement(caption, (bool)GetValue(mi, o)); } else if (mType == typeof(DateTime)) { var dateTime = (DateTime)GetValue(mi, o); bool asDate = false, asTime = false; foreach (object attr in attrs) { if (attr is DateAttribute) asDate = true; else if (attr is TimeAttribute) asTime = true; } if (asDate) element = new DateElement(caption, dateTime); else if (asTime) element = new TimeElement(caption, dateTime); else element = new DateTimeElement(caption, dateTime); } else if (mType.IsEnum) { var csection = new Section(); ulong evalue = Convert.ToUInt64(GetValue(mi, o), null); int idx = 0; int selected = 0; foreach (var fi in mType.GetFields(BindingFlags.Public | BindingFlags.Static)) { ulong v = Convert.ToUInt64(GetValue(fi, null)); if (v == evalue) selected = idx; csection.Add(new RadioElement(MakeCaption(fi.Name))); idx++; } element = new RootElement(caption, new RadioGroup(null, selected)) { csection }; } else if (mType == typeof(ImageView)) { element = new ImageElement((ImageView)GetValue(mi, o)); } else if (typeof(System.Collections.IEnumerable).IsAssignableFrom(mType)) { var csection = new Section(); int count = 0; if (last_radio_index == null) throw new Exception("IEnumerable found, but no previous int found"); foreach (var e in (IEnumerable)GetValue(mi, o)) { csection.Add(new RadioElement(e.ToString())); count++; } int selected = (int)GetValue(last_radio_index, o); if (selected >= count || selected < 0) selected = 0; element = new RootElement(caption, new MemberRadioGroup(null, selected, last_radio_index)) { csection }; last_radio_index = null; } else if (typeof(int) == mType) { foreach (object attr in attrs) { if (attr is RadioSelectionAttribute) { last_radio_index = mi; break; } } } else { var nested = GetValue(mi, o); if (nested != null) { var newRoot = new RootElement(caption); Populate(callbacks, nested, newRoot); element = newRoot; } } if (element == null) continue; section.Add(element); mappings[element] = new MemberAndInstance(mi, o); } root.Add(section); }
public bool Parse(List <string> firstLineSplit) { bool result = true; try { _unknownDataValues = new Dictionary <string, string>(); List <string> splitData = _rawData.Split(',').ToList(); for (int i = 0; i < splitData.Count; i++) { if (firstLineSplit[i] == AbsolutePressureElement.LogPropertyName) { _absolutePressure = AbsolutePressureElement.Create(splitData[i]); } else if (firstLineSplit[i] == AFRElement.LogPropertyName) { _afr = AFRElement.Create(splitData[i]); } else if (firstLineSplit[i] == APPElement.LogPropertyName) { _app = APPElement.Create(splitData[i]); } else if (firstLineSplit[i] == BoostAirTempElement.LogPropertyName) { _boostAirTemp = BoostAirTempElement.Create(splitData[i]); } else if (firstLineSplit[i] == BoostElement.LogPropertyName) { _boost = BoostElement.Create(splitData[i]); } else if (firstLineSplit[i] == CalculatedLoadElement.LogPropertyName) { _calculatedLoad = CalculatedLoadElement.Create(splitData[i]); } else if (firstLineSplit[i] == CoolantTempElement.LogPropertyName) { _coolantTemp = CoolantTempElement.Create(splitData[i]); } else if (firstLineSplit[i] == HPFPElement.LogPropertyName) { _hpfp = HPFPElement.Create(splitData[i]); } else if (firstLineSplit[i] == InjectorDutyCycleElement.LogPropertyName) { _injectorDutyCycle = InjectorDutyCycleElement.Create(splitData[i]); } else if (firstLineSplit[i] == IntakeTempElement.LogPropertyName) { _intakeTemp = IntakeTempElement.Create(splitData[i]); } else if (firstLineSplit[i] == IntakeValveAdvanceElement.LogPropertyName) { _intakeValveAdvance = IntakeValveAdvanceElement.Create(splitData[i]); } else if (firstLineSplit[i] == KnockRetardElement.LogPropertyName) { _knockRetard = KnockRetardElement.Create(splitData[i]); } else if (firstLineSplit[i] == LTFTElement.LogPropertyName) { _ltft = LTFTElement.Create(splitData[i]); } else if (firstLineSplit[i] == MAFVoltageElement.LogPropertyName) { _mafVoltage = MAFVoltageElement.Create(splitData[i]); } else if (firstLineSplit[i] == MassAirflowElement.LogPropertyName) { _massAirflow = MassAirflowElement.Create(splitData[i]); } else if (firstLineSplit[i] == RPMElement.LogPropertyName) { _rpm = RPMElement.Create(splitData[i]); } else if (firstLineSplit[i] == SparkAdvanceElement.LogPropertyName) { _sparkAdvance = SparkAdvanceElement.Create(splitData[i]); } else if (firstLineSplit[i] == STFTElement.LogPropertyName) { _stft = STFTElement.Create(splitData[i]); } else if (firstLineSplit[i] == ThrottlePositionElement.LogPropertyName) { _throttlePosition = ThrottlePositionElement.Create(splitData[i]); } else if (firstLineSplit[i] == TimeElement.LogPropertyName) { _time = TimeElement.Create(splitData[i]); } else if (firstLineSplit[i] == VehicleSpeedElement.LogPropertyName) { _vehicleSpeed = VehicleSpeedElement.Create(splitData[i]); } else if (firstLineSplit[i] == WGDCElement.LogPropertyName) { _wgdc = WGDCElement.Create(splitData[i]); } else { // Unknown Element Type, add it to our dictionary _unknownDataValues.Add(firstLineSplit[i], splitData[i]); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); result = false; } // We no longer need the raw data after we parse, do this to save memory _rawData = null; return(result); }
private void PopulateTimeDictionary() { //AÑADIR SIGLOS 10 a 14 con strings localizados //10th Century var tenth = new TimeElement(901, 1000, 10); timeValues.Add("tenth century (dates CE)", tenth); //11th Century var eleventh = new TimeElement(1001, 1100, 11); timeValues.Add("eleventh century (dates CE)", eleventh); //12th Century var twelfth = new TimeElement(1101, 1200, 12); timeValues.Add("twelfth century (dates CE)", twelfth); //13th Century var thirteenth = new TimeElement(1201, 1300, 13); timeValues.Add("thirteenth century (dates CE)", thirteenth); //14th Century var fourteenth = new TimeElement(1301, 1400, 14); timeValues.Add("fourteenth century (dates CE)", fourteenth); //15th Century var fifteenth = new TimeElement(1401, 1500, 15); timeValues.Add("fifteenth century (dates CE)", fifteenth); timeValues.Add("siglo quince", fifteenth); timeValues.Add("quindicesimo secolo", fifteenth); timeValues.Add("quinzième siècle", fifteenth); //16th Century var sixteenth = new TimeElement(1501, 1600, 16); timeValues.Add("sixteenth century (dates CE)", sixteenth); timeValues.Add("siglo dieciséis", sixteenth); timeValues.Add("sedicesimo secolo", sixteenth); timeValues.Add("seizième siècle", sixteenth); //17th Century var seventeenth = new TimeElement(1601, 1700, 17); timeValues.Add("seventeenth century (dates CE)", seventeenth); timeValues.Add("siglo diecisiete", seventeenth); timeValues.Add("diciassettesimo secolo", seventeenth); timeValues.Add("dix-septième siècle", seventeenth); //18th Century var eighteenth = new TimeElement(1701, 1800, 18); timeValues.Add("eighteenth century (dates CE)", eighteenth); timeValues.Add("siglo dieciocho", eighteenth); timeValues.Add("diciottesimo secolo", eighteenth); timeValues.Add("dix-huitième siècle", eighteenth); //19th Century var nineteenth = new TimeElement(1801, 1900, 19); timeValues.Add("nineteenth century (dates CE)", nineteenth); timeValues.Add("siglo diecinueve", nineteenth); timeValues.Add("diciannovesimo secolo", nineteenth); timeValues.Add("dix-neuvième siècle", nineteenth); //20th Century var twentieth = new TimeElement(1901, 2000, 20); timeValues.Add("twentieth century (dates CE)", twentieth); timeValues.Add("siglo veinte", twentieth); timeValues.Add("ventesimo secolo", twentieth); timeValues.Add("vingtième siècle", twentieth); }