public bool Equals(TimeZoneViewModel other) { return(!Object.ReferenceEquals(other, null) && ( (posixTz == other.posixTz) && ((object)posixTz != null || originalString == other.originalString) )); }
public static bool LogicallyEquals(TimeZoneViewModel left, TimeZoneViewModel right) { return(Object.ReferenceEquals(left, right) || ( !Object.ReferenceEquals(left, null) && ( PosixTz.LogicallyEquals(left.posixTz, right.posixTz) && ((object)left.posixTz != null || left.originalString == right.originalString) ) )); }
public static int GetLogicalHashCode(TimeZoneViewModel tzm) { if ((object)tzm == null) { return(0); } if ((object)tzm.posixTz != null) { return(tzm.posixTz.GetLogicalHashCode()); } return(HashCode.Get(tzm.originalString)); }
TimeZoneViewModel GetTimeZoneSelection() { TimeZoneViewModel timezonemosel = null; if (timeZonesComboBox.SelectedIndex == -1) { timezonemosel = new TimeZoneViewModel(timeZonesComboBox.Text, timeZonesComboBox.Text, PosixTz.TryParse(timeZonesComboBox.Text)); } else { var tmodel = timeZonesComboBox.SelectedItem as TimeZoneViewModel; if (tmodel != null) { timezonemosel = tmodel; } } return(timezonemosel); }
void InitTimeZones() { //refresh list timeZonesComboBox.Items.Clear(); //Get system timezones list var listSystem = TimeZoneViewModel.GetSystemTimeZones(); listSystem.ForEach(obj => { timeZonesComboBox.Items.Add(obj); }); //try to load and fill manual list //TODO: get rid of hardcoded filename var manualListpath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "custom-time-zones.xml" ); var listManual = TimeZoneViewModel.GetManualTimeZones(manualListpath); if (listManual.Count() != 0) { timeZonesComboBox.Items.Add(new Separator()); listManual.ForEach(obj => { timeZonesComboBox.Items.Add(obj); }); } //Find and try to select device tz TimeZoneViewModel tzmodel = null; ErrorBlock.Visibility = Visibility.Collapsed; if (originPosixTz != null) { if (model.localDateTime != null && model.utcDateTime!=null) { try { if (originPosixTz.ConvertUtcTimeToLocal((DateTime)model.utcDateTime, model.daylightSavings) != (DateTime)model.localDateTime) { //TODO: needs to be localized ErrorMessage.Text = "Validation failed. Local time sent by device differs from calculated."; ErrorBlock.Visibility = Visibility.Visible; }; } catch (Exception err) { dbg.Error(err); //TODO: needs to be localized ErrorMessage.Text = "failed to validate local time"; ErrorBlock.Visibility = Visibility.Visible; } } tzmodel = new TimeZoneViewModel(model.timeZone, model.timeZone, originPosixTz); if (listSystem.Any(f => f == tzmodel)) { timeZonesComboBox.SelectedItem = listSystem.First(f => f == tzmodel); } //else if (listSystem.Any(f => f.LogicallyEquals(tzmodel))) { // timeZonesComboBox.SelectedItem = listSystem.First(f => f.LogicallyEquals(tzmodel)); //} else if (listManual.Any(f => f == tzmodel)) { timeZonesComboBox.SelectedItem = listManual.First(f => f == tzmodel); } //else if (listManual.Any(f => f.LogicallyEquals(tzmodel))) { // timeZonesComboBox.SelectedItem = listSystem.First(f => f.LogicallyEquals(tzmodel)); //} else { timeZonesComboBox.Text = tzmodel.originalString; } } else { //Invalid TZ timeZonesComboBox.Text = model.timeZone; } }
public bool Equals(TimeZoneViewModel other) { return !Object.ReferenceEquals(other, null) && ( (posixTz == other.posixTz) && ((object)posixTz != null || originalString == other.originalString) ); }
public static int GetLogicalHashCode(TimeZoneViewModel tzm) { if ((object)tzm == null) { return 0; } if ((object)tzm.posixTz != null) { return tzm.posixTz.GetLogicalHashCode(); } return HashCode.Get(tzm.originalString); }
public bool LogicallyEquals(TimeZoneViewModel other) { return LogicallyEquals(this, other); }
public static bool LogicallyEquals(TimeZoneViewModel left, TimeZoneViewModel right) { return Object.ReferenceEquals(left, right) || ( !Object.ReferenceEquals(left, null) && ( PosixTz.LogicallyEquals(left.posixTz, right.posixTz) && ((object)left.posixTz != null || left.originalString == right.originalString) ) ); }
TimeZoneViewModel GetTimeZoneSelection() { TimeZoneViewModel timezonemosel = null; if (timeZonesComboBox.SelectedIndex == -1) { timezonemosel = new TimeZoneViewModel(timeZonesComboBox.Text, timeZonesComboBox.Text, PosixTz.TryParse(timeZonesComboBox.Text)); }else{ var tmodel = timeZonesComboBox.SelectedItem as TimeZoneViewModel; if(tmodel != null) timezonemosel = tmodel; } return timezonemosel; }
void InitTimeZones() { //refresh list timeZonesComboBox.Items.Clear(); //Get system timezones list var listSystem = TimeZoneViewModel.GetSystemTimeZones(); listSystem.ForEach(obj => { timeZonesComboBox.Items.Add(obj); }); //try to load and fill manual list //TODO: get rid of hardcoded filename var manualListpath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "custom-time-zones.xml" ); var listManual = TimeZoneViewModel.GetManualTimeZones(manualListpath); if (listManual.Count() != 0) { timeZonesComboBox.Items.Add(new Separator()); listManual.ForEach(obj => { timeZonesComboBox.Items.Add(obj); }); } //Find and try to select device tz TimeZoneViewModel tzmodel = null; ErrorBlock.Visibility = Visibility.Collapsed; if (originPosixTz != null) { if (model.localDateTime != null && model.utcDateTime != null) { try { if (originPosixTz.ConvertUtcTimeToLocal((DateTime)model.utcDateTime, model.daylightSavings) != (DateTime)model.localDateTime) { //TODO: needs to be localized ErrorMessage.Text = "Validation failed. Local time sent by device differs from calculated."; ErrorBlock.Visibility = Visibility.Visible; } ; } catch (Exception err) { dbg.Error(err); //TODO: needs to be localized ErrorMessage.Text = "failed to validate local time"; ErrorBlock.Visibility = Visibility.Visible; } } tzmodel = new TimeZoneViewModel(model.timeZone, model.timeZone, originPosixTz); if (listSystem.Any(f => f == tzmodel)) { timeZonesComboBox.SelectedItem = listSystem.First(f => f == tzmodel); } //else if (listSystem.Any(f => f.LogicallyEquals(tzmodel))) { // timeZonesComboBox.SelectedItem = listSystem.First(f => f.LogicallyEquals(tzmodel)); //} else if (listManual.Any(f => f == tzmodel)) { timeZonesComboBox.SelectedItem = listManual.First(f => f == tzmodel); } //else if (listManual.Any(f => f.LogicallyEquals(tzmodel))) { // timeZonesComboBox.SelectedItem = listSystem.First(f => f.LogicallyEquals(tzmodel)); //} else { timeZonesComboBox.Text = tzmodel.originalString; } } else { //Invalid TZ timeZonesComboBox.Text = model.timeZone; } }
public bool LogicallyEquals(TimeZoneViewModel other) { return(LogicallyEquals(this, other)); }