public static IReadOnlyLogbook Predicate <TModel>(this TModel model, IEnumerable <Field> fields, IReadOnlyDictionary <Field, ReadOnlyLogbookPredicate <object> > predicates) where TModel : class, IModel, new() { ILogbook logs = Logger.NewLogbook(); Type modelType = typeof(TModel); foreach (Field field in fields) { if (predicates.TryGetValue(field, out ReadOnlyLogbookPredicate <object> predicate)) { if (predicate != null) { PropertyInfo modelProperty = modelType.GetProperty(field.Name); if (modelProperty is null) { throw new PropertyNotFoundException($"{field.Name} named property could not found in {modelType.FullName}"); } object value = modelProperty.GetValue(model); logs.AddRange(predicate.Invoke(value)); } } } return(logs); }
public static IReadOnlyLogbook Build(IFieldCollection fields, IFieldValuePairs fieldValuePairs, IFieldPredicatePairs fieldPredicatePairs, IFieldOperationPairs fieldOperationPairs, out IEnumerable <QueryField> queryFields) { queryFields = Enumerable.Empty <QueryField>(); ILogbook logs = Logger.NewLogbook(); ICollection <QueryField> queryFieldCollection = new Collection <QueryField>(); foreach (Field field in fields) { bool valueFound = fieldValuePairs.TryGetValue(field, out object value); bool predicateFound = fieldPredicatePairs.TryGetValue(field, out ReadOnlyLogbookPredicate <object> predicate); bool operationFound = fieldOperationPairs.TryGetValue(field, out Operation operation); if (valueFound && predicateFound && predicate != null) { logs.AddRange(predicate.Invoke(value)); } if (!logs.Safely) { break; } if (valueFound && operationFound) { queryFieldCollection.Add(new QueryField(field, operation, value)); } } return(logs); }
public static IReadOnlyLogbook Build <TModel>(IFieldCollection fields, IFieldValuePairs fieldValuePairs, IFieldPredicatePairs fieldPredicatePairs, out IEnumerable <QueryField> queryFields) where TModel : class, IModel, new() { queryFields = Enumerable.Empty <QueryField>(); ILogbook logs = Logger.NewLogbook(); if (!fields.IsSubsetOfModel <TModel>()) { logs.Failure("Qualifier fields must be subset of model fields"); return(logs); } ICollection <QueryField> queryFieldCollection = new Collection <QueryField>(); foreach (Field field in fields) { bool valueFound = fieldValuePairs.TryGetValue(field, out object value); bool predicateFound = fieldPredicatePairs.TryGetValue(field, out ReadOnlyLogbookPredicate <object> predicate); if (valueFound && predicateFound && predicate != null) { logs.AddRange(predicate.Invoke(value)); } if (!logs.Safely) { break; } } return(logs); }
public Ship(ILogbook log, int id) { Id = id; ShipNameType = new Histogram <ShipNameType>(log); Level = new Histogram <int>(log); Exp = new Histogram <int>(log); SRate = new Histogram <int>(log); /* * Power = new Histogram<int>(); * Torpedo = new Histogram<int>(); * AntiAir = new Histogram<int>(); * Defense = new Histogram<int>(); * Maneuver = new Histogram<int>(); * AntiSub = new Histogram<int>(); * Scout = new Histogram<int>(); * Luck = new Histogram<int>(); */ EnhancedPower = new Histogram <int>(log); EnhancedTorpedo = new Histogram <int>(log); EnhancedAntiAir = new Histogram <int>(log); EnhancedDefense = new Histogram <int>(log); EnhancedLuck = new Histogram <int>(log); ExistenceLog = new Histogram <ShipExistenceStatus>(log); }
public static void FetchDataFromServer(ILogbook logbook) { // Running in the UI thread - launch the background thread. Synchronizer synchronizer = new Synchronizer(logbook); ThreadPool.QueueUserWorkItem(SynchronizerBackgroundCallback, synchronizer); }
public static IReadOnlyLogbook Predicate <TModel>(this TModel model, IFieldQualifier <TModel> fieldQualifier, IPredicateFieldQualifier <TModel> predicateFieldQualifier, out IEnumerable <Field> fields) where TModel : class, IModel, new() { ILogbook logs = Logger.NewLogbook(); if (fieldQualifier.Build <TModel>(out fields)) { IReadOnlyDictionary <Field, ReadOnlyLogbookPredicate <object> > fieldPredicateMap = predicateFieldQualifier; Type modelType = typeof(TModel); foreach (Field field in fields) { if (fieldPredicateMap.TryGetValue(field, out ReadOnlyLogbookPredicate <object> predicate)) { if (predicate != null) { PropertyInfo modelProperty = modelType.GetProperty(field.Name); if (modelProperty is null) { throw new PropertyNotFoundException($"{field.Name} named property could not found in {modelType.FullName}"); } object value = modelProperty.GetValue(model); logs.AddRange(predicate.Invoke(value)); } } } } else { Type modelType = typeof(TModel); foreach (KeyValuePair <Field, ReadOnlyLogbookPredicate <object> > fieldPredicatePair in predicateFieldQualifier) { Field field = fieldPredicatePair.Key; ReadOnlyLogbookPredicate <object> predicate = fieldPredicatePair.Value; if (predicate is null) { continue; } PropertyInfo modelProperty = modelType.GetProperty(field.Name); if (modelProperty is null) { throw new PropertyNotFoundException($"{field.Name} named property could not found in {modelType.FullName}"); } object value = modelProperty.GetValue(model); logs.AddRange(predicate.Invoke(value)); } } return(logs); }
private void UnregisterCategoryCallback(ILogbook logbook) { if (logbook != null) { foreach (IActivityCategory category in logbook.ActivityCategories) { category.PropertyChanged -= new PropertyChangedEventHandler(OnActivityCategoryDataChanged); } } }
/*public Histogram(ILogbook log, IEnumerable<KeyValuePair<long, T>> data) * { * foreach(var ent in data) backend.Add(ent.Key, ent.Value); * }*/ public Histogram(StoragePremitive p, LinkedList <object> path) { path.AddFirst(this); foreach (var kv in ((Premitives.Dictionary <SignedInteger, StoragePremitive>)p).Convert((k, v) => new KeyValuePair <long, T>(k.Value, revConverter(v, path)))) { backend.Add(kv.Key, kv.Value); } path.RemoveFirst(); _holder = (ILogbook)path.First(x => x is ILogbook); }
public void Save(ILogbook logbook) { try { XmlDocument xmlDoc = new XmlDocument(); XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null); xmlDoc.InsertBefore(xmlDeclaration, xmlDoc.DocumentElement); XmlElement nodeRoot = xmlDoc.CreateElement(xmlTags.rootElement); if (email.Length > 0) { nodeRoot.SetAttribute(xmlTags.email, email); } if (username.Length > 0) { nodeRoot.SetAttribute(xmlTags.username, username); } if (userid.Length > 0) { nodeRoot.SetAttribute(xmlTags.userid, userid); } if (publicKey.Length > 0) { nodeRoot.SetAttribute(xmlTags.publicKey, publicKey); } nodeRoot.SetAttribute(xmlTags.multiple, importMultipleEntries.ToString()); nodeRoot.SetAttribute(xmlTags.bmi, XmlConvert.ToString(updateBMI)); nodeRoot.SetAttribute(xmlTags.manual, XmlConvert.ToString(importManualEntries)); nodeRoot.SetAttribute(xmlTags.ambiguous, XmlConvert.ToString(importAmbiguousEntries)); nodeRoot.SetAttribute(xmlTags.height, XmlConvert.ToString(importHeightEntries)); nodeRoot.SetAttribute(xmlTags.lastupdate, XmlConvert.ToString(lastUpdate)); if (lastLogEntryDate != DateTime.MinValue) { nodeRoot.SetAttribute(xmlTags.logDate, XmlConvert.ToString(lastLogEntryDate, XmlDateTimeSerializationMode.Utc)); } if (lastLogEntry.Length != 0) { nodeRoot.SetAttribute(xmlTags.log, lastLogEntry); } xmlDoc.AppendChild(nodeRoot); byte[] data = Encoding.UTF8.GetBytes(xmlDoc.OuterXml); logbook.SetExtensionData(Plugin.Instance.Id, data); // TODO: Hack to trigger a modified flag on logbook, fix this in core code - if extension data/text changes, flag modified logbook.Athlete.Name = logbook.Athlete.Name; } catch { } }
private void ProcessResponse(ILogbook logbook, LogbookSettings settings, IList <WithingsWebServiceProxy.MeasurementInfo> measurements) { // Running in the UI thread. if (measurements != null) { MeasurementImporter.ImportMeasurements(logbook, settings, measurements); settings.LastUpdate = WithingsWebServiceProxy.GetNowEpoch(); AddLogEntry(settings, ""); } settings.Save(logbook); ExtendSettingsPages.RefreshSettings(); }
public static IReadOnlyLogbook Build <TModel>(this ISearchQuery <TModel> searchQuery, Conjunction conjunction, out QueryGroup queryGroup) where TModel : class, IModel, new() { queryGroup = null; ILogbook logs = Logger.NewLogbook(); logs.AddRange(QueryFieldExtension.Build <TModel>(searchQuery.Fields, searchQuery.ValueMap, searchQuery.PredicateMap, searchQuery.OperationMap, out IEnumerable <QueryField> queryFields)); if (logs.Safely) { queryGroup = new QueryGroup(queryFields, conjunction); } return(logs); }
public override IReadOnlyLogbook Test() { ILogbook logs = Logger.New(); if (NickEnabled) { // ... Examining } if (FullNameEnabled) { // ... Examining } return(logs); }
public void Load(ILogbook logbook) { try { byte[] data = logbook.GetExtensionData(Plugin.Instance.Id); if (data != null && data.Length > 0) { string attr; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(Encoding.UTF8.GetString(data)); XmlElement nodeRoot = xmlDoc.DocumentElement; email = nodeRoot.GetAttribute(xmlTags.email); username = nodeRoot.GetAttribute(xmlTags.username); userid = nodeRoot.GetAttribute(xmlTags.userid); publicKey = nodeRoot.GetAttribute(xmlTags.publicKey); attr = nodeRoot.GetAttribute(xmlTags.multiple); if (attr.Length > 0) { try { importMultipleEntries = (MultipleEntriesUpdateStyles)Enum.Parse(typeof(MultipleEntriesUpdateStyles), attr); } catch { } } updateBMI = XmlConvert.ToBoolean(nodeRoot.GetAttribute(xmlTags.bmi)); importManualEntries = XmlConvert.ToBoolean(nodeRoot.GetAttribute(xmlTags.manual)); importAmbiguousEntries = XmlConvert.ToBoolean(nodeRoot.GetAttribute(xmlTags.ambiguous)); importHeightEntries = XmlConvert.ToBoolean(nodeRoot.GetAttribute(xmlTags.height)); lastUpdate = XmlConvert.ToInt64(nodeRoot.GetAttribute(xmlTags.lastupdate)); attr = nodeRoot.GetAttribute(xmlTags.logDate); if (attr.Length > 0) { lastLogEntryDate = XmlConvert.ToDateTime(attr, XmlDateTimeSerializationMode.Utc); } lastLogEntry = nodeRoot.GetAttribute(xmlTags.log); } } catch { } }
public BasicInfo(ILogbook log) { Level = new Histogram <int>(log); Experience = new Histogram <int>(log); FurnitureCoin = new Histogram <int>(log); Fuel = new Histogram <int>(log); Ammo = new Histogram <int>(log); Steel = new Histogram <int>(log); Bauxite = new Histogram <int>(log); HsBuild = new Histogram <int>(log); HsRepair = new Histogram <int>(log); DevMaterial = new Histogram <int>(log); ModMaterial = new Histogram <int>(log); ExerWins = new Histogram <int>(log); ExerLose = new Histogram <int>(log); OperWins = new Histogram <int>(log); OperLose = new Histogram <int>(log); ExpeWins = new Histogram <int>(log); ExpeLose = new Histogram <int>(log); }
public ConfigureWizard() { InitializeComponent(); Text = ResourceLookup.UI_ConfigureWizard_Title; logbook = Plugin.Instance.Application != null ? Plugin.Instance.Application.Logbook : null; settings = new LogbookSettings(); if (logbook != null) { settings.Load(logbook); } accountInfoPage = new ConfigureWizard_Page_AccountInfo(this); selectUserPage = new ConfigureWizard_Page_SelectUser(this); importSettingsPage = new ConfigureWizard_Page_ImportSettings(this); importHistoryPage = new ConfigureWizard_Page_ImportHistory(this); Pages = new IWizardPage[] { accountInfoPage, selectUserPage, importSettingsPage, importHistoryPage }; }
public static IReadOnlyLogbook Build <TModel>(this IModelQuery <TModel> modelQuery, out TModel model) where TModel : class, IModel, new() { model = null; ILogbook logs = Logger.NewLogbook(); if (modelQuery.Fields.Build <TModel>(out IEnumerable <Field> fields)) { IReadOnlyDictionary <Field, object> valueMap = modelQuery.ValueMap; IReadOnlyDictionary <Field, ReadOnlyLogbookPredicate <object> > predicateMap = modelQuery.PredicateMap; foreach (Field field in fields) { bool valueFound = valueMap.TryGetValue(field, out object value); bool predicateFound = predicateMap.TryGetValue(field, out ReadOnlyLogbookPredicate <object> predicate); if (valueFound && predicateFound && predicate != null) { logs.AddRange(predicate.Invoke(value)); } } if (logs.Safely) { model = new TModel(); Type modelType = typeof(TModel); IEnumerable <Field> modelFields = Field.Parse <TModel>(); foreach (Field modelField in modelFields) { PropertyInfo propertyField = modelType.GetProperty(modelField.Name); propertyField.SetValue(model, valueMap[modelField]); } } } return(logs); }
public void RefreshControls() { settings = new LogbookSettings(); ILogbook logbook = Plugin.Instance.Application != null ? Plugin.Instance.Application.Logbook : null; if (logbook != null) { settings.Load(logbook); } if (settings.PublicKey.Length == 0) { configureButton.Visible = true; tableLayoutPanel.RowStyles[0].Height = 60; settingsPanel.Visible = false; } else { configureButton.Visible = false; tableLayoutPanel.RowStyles[0].Height = 0; settingsPanel.SetSettings(logbook, settings); settingsPanel.Visible = true; } }
private Synchronizer(ILogbook logbook) { this.logbook = logbook; culture = Thread.CurrentThread.CurrentUICulture.ToString(); }
public static void ImportMeasurements(ILogbook logbook, LogbookSettings settings, IList <WithingsWebServiceProxy.MeasurementInfo> measurements) { List <WithingsWebServiceProxy.MeasurementInfo> orderedMeasurements = new List <WithingsWebServiceProxy.MeasurementInfo>(measurements); if (settings.ImportMultipleEntries == LogbookSettings.MultipleEntriesUpdateStyles.Latest) { orderedMeasurements.Sort(new OldestToNewestComparer()); } else { orderedMeasurements.Sort(new NewestToOldestComparer()); } foreach (WithingsWebServiceProxy.MeasurementInfo measurement in orderedMeasurements) { // Skip ambiguous readings unless setting is selected. if (!settings.ImportAmbiguousEntries) { if (measurement.Source == WithingsWebServiceProxy.MeasurementInfo.SourceType.AmbiguousScaleReading) { continue; } } // Always import height if settings is selected (even if manual). if (settings.ImportHeightEntries && !float.IsNaN(measurement.HeightMeters)) { logbook.Athlete.HeightCentimeters = measurement.HeightMeters * 100; } // Skip manual entries unless settings is selected. if (!settings.ImportManualEntries) { if (measurement.Source == WithingsWebServiceProxy.MeasurementInfo.SourceType.ManualEntry || measurement.Source == WithingsWebServiceProxy.MeasurementInfo.SourceType.ProfileCreation) { continue; } } IAthleteInfoEntry athleteInfoEntry = logbook.Athlete.InfoEntries.EntryForDate(measurement.Time.Date); try { // Import weight if (!float.IsNaN(measurement.WeightKilograms) && measurement.WeightKilograms > 0) { //System.Diagnostics.Trace.WriteLine("Weight entry on " + measurement.Time.ToLocalTime().ToShortDateString() + " " + measurement.Time.ToLocalTime().ToShortTimeString() + "=" + measurement.WeightKilograms); float actualKilograms = measurement.WeightKilograms; float roundedKilograms = actualKilograms; switch (Plugin.Instance.Application.SystemPreferences.WeightUnits) { case Weight.Units.Kilogram: roundedKilograms = (float)Math.Round(actualKilograms + 0.005, 1); break; case Weight.Units.Pound: case Weight.Units.Stone: double pounds = Weight.Convert(actualKilograms + 0.005, Weight.Units.Kilogram, Weight.Units.Pound); pounds = Math.Round(pounds, 1); roundedKilograms = (float)Weight.Convert(pounds, Weight.Units.Pound, Weight.Units.Kilogram); break; } bool update = false; if (float.IsNaN(athleteInfoEntry.WeightKilograms)) { update = true; } else { switch (settings.ImportMultipleEntries) { case LogbookSettings.MultipleEntriesUpdateStyles.Earliest: case LogbookSettings.MultipleEntriesUpdateStyles.Latest: update = true; break; case LogbookSettings.MultipleEntriesUpdateStyles.Lowest: if (roundedKilograms < athleteInfoEntry.WeightKilograms) { update = true; } break; case LogbookSettings.MultipleEntriesUpdateStyles.Highest: if (roundedKilograms > athleteInfoEntry.WeightKilograms) { update = true; } break; } } if (update) { //System.Diagnostics.Trace.WriteLine("Weight updated to " + roundedKilograms + " kilograms. actual=" + actualKilograms); athleteInfoEntry.WeightKilograms = roundedKilograms; if (settings.UpdateBMI) { if (!float.IsNaN(logbook.Athlete.HeightCentimeters) && logbook.Athlete.HeightCentimeters > 0) { float meters = logbook.Athlete.HeightCentimeters / 100; athleteInfoEntry.BMI = (float)Math.Round(actualKilograms / (meters * meters), 1); //System.Diagnostics.Trace.WriteLine("BMI updated to " + athleteInfoEntry.BMI); } } } } // Import percent fat if (!float.IsNaN(measurement.PercentFat) && measurement.PercentFat > 0 && measurement.PercentFat < 100) { //System.Diagnostics.Trace.WriteLine("Percent Fat entry on " + measurement.Time.ToLocalTime().ToShortDateString() + " " + measurement.Time.ToLocalTime().ToShortTimeString() + "=" + measurement.PercentFat); float percent = measurement.PercentFat; bool update = false; if (float.IsNaN(athleteInfoEntry.BodyFatPercentage)) { update = true; } else { switch (settings.ImportMultipleEntries) { case LogbookSettings.MultipleEntriesUpdateStyles.Earliest: case LogbookSettings.MultipleEntriesUpdateStyles.Latest: update = true; break; case LogbookSettings.MultipleEntriesUpdateStyles.Lowest: if (percent < athleteInfoEntry.BodyFatPercentage) { update = true; } break; case LogbookSettings.MultipleEntriesUpdateStyles.Highest: if (percent > athleteInfoEntry.BodyFatPercentage) { update = true; } break; } } if (update) { percent = (float)Math.Round(percent + 0.005, 1); //System.Diagnostics.Trace.WriteLine("Body fat % updated to " + percent + "%"); athleteInfoEntry.BodyFatPercentage = percent; } } } catch { } } }
public FitnessDataHandler(ILogbook Logbook, Guid PluginGuid) { #if !ST_2_1 CheckCustomDataFields(Logbook, PluginGuid); #endif }
private void OnLogbookChanged(object sender, ILogbook oldLogbook, ILogbook newLogbook) { if (m_ViewControls[(int)m_CurrentView] != null) { GetCurrentView().RefreshUIFromLogbook(); } RunSetupWizard(); }
/// <summary> /// Currently loaded logbook /// </summary> /// <returns>Returns currently loaded logbook</returns> internal static ILogbook GetLogbook() { logbook = GetApplication().Logbook; return(logbook); }
private Synchronizer(ILogbook logbook) { this.logbook = logbook; culture = Thread.CurrentThread.CurrentUICulture.ToString(); }
private void OnLogbookChanged(object sender, ILogbook oldLogbook, ILogbook newLogbook) { if (oldLogbook != null) { oldLogbook.BeforeSave -= new EventHandler(OnLogbookBeforeSave); } if (newLogbook != null) { newLogbook.BeforeSave += new EventHandler(OnLogbookBeforeSave); } LoadWorkoutsFromLogbook(newLogbook); }
void OnLogbookChanged(object sender, ILogbook oldLogbook, ILogbook newLogbook) { UpdateOptionsUI(); }
private void LoadWorkoutsFromLogbook(ILogbook logbook) { // Load data from logbook byte[] extensionData = logbook.GetExtensionData(GUIDs.PluginMain); if (extensionData != null && extensionData.Length > 0) { try { MemoryStream stream = new MemoryStream(extensionData); byte[] headerBuffer = new byte[Constants.DataHeaderIdString.Length]; String headerIdString; DataVersion version = new DataVersion(0); stream.Read(headerBuffer, 0, Constants.DataHeaderIdString.Length); headerIdString = Encoding.UTF8.GetString(headerBuffer); if (headerIdString == Constants.DataHeaderIdString) { Byte versionNumber = (Byte)stream.ReadByte(); if (versionNumber <= Constants.CurrentVersion.VersionNumber) { version = new DataVersion(versionNumber); } else { MessageBox.Show(GarminFitnessView.GetLocalizedString("DataTooRecentErrorText"), GarminFitnessView.GetLocalizedString("ErrorText"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { // Deserialize using version 0. Replace at start since we skipped some data stream.Position = 0; } Options.Instance.Deserialize(stream, version); GarminWorkoutManager.Instance.Deserialize(stream, version); GarminProfileManager.Instance.Deserialize(stream, version); if (m_PluginOptions != null) { Options.Instance.Deserialize(m_PluginOptions); m_PluginOptions = null; } stream.Close(); } catch (Exception e) { throw e; } } else { GarminWorkoutManager.Instance.RemoveAllWorkouts(); GarminProfileManager.Instance.UserProfile.Cleanup(); Options.Instance.ResetLogbookSettings(); } }
public void CheckCustomDataFields(ILogbook Logbook, Guid PluginGuid) { // Check for custom data fields in the logbook. If they aren't there, create them! foreach (ICustomDataFieldDefinition custDataDef in Logbook.CustomDataFieldDefinitions ) { if(custDataDef.Id == RPEGuid) { RPEField = custDataDef; } else if(custDataDef.Id == FunbeatExportedGuid) { FunbeatExportedField = custDataDef; } else if (custDataDef.Id == TEGuid) { TEField = custDataDef; } else if (custDataDef.Id == RepetitionsGuid) { RepetitionsField = custDataDef; } else if (custDataDef.Id == SetsGuid) { SetsField = custDataDef; } } if(RPEField == null) { RPEField = Logbook.CustomDataFieldDefinitions.Add(RPEGuid, CustomDataFieldDefinitions.StandardObjectType(typeof(IActivity)), CustomDataFieldDefinitions.StandardDataType(CustomDataFieldDefinitions.StandardDataTypes.NumberDataTypeId), "RPE (Borg Scale)"); RPEField.CreatedBy = PluginGuid; } if (FunbeatExportedField == null) { FunbeatExportedField = Logbook.CustomDataFieldDefinitions.Add(FunbeatExportedGuid, CustomDataFieldDefinitions.StandardObjectType(typeof(IActivity)), CustomDataFieldDefinitions.StandardDataType(CustomDataFieldDefinitions.StandardDataTypes.NumberDataTypeId), "Exported to Funbeat"); FunbeatExportedField.CreatedBy = PluginGuid; } if (TEField == null) { TEField = Logbook.CustomDataFieldDefinitions.Add(TEGuid, CustomDataFieldDefinitions.StandardObjectType(typeof(IActivity)), CustomDataFieldDefinitions.StandardDataType(CustomDataFieldDefinitions.StandardDataTypes.NumberDataTypeId), "Training Effect (TE)"); TEField.CreatedBy = PluginGuid; } if (RepetitionsField == null) { RepetitionsField = Logbook.CustomDataFieldDefinitions.Add(RepetitionsGuid, CustomDataFieldDefinitions.StandardObjectType(typeof(IActivity)), CustomDataFieldDefinitions.StandardDataType(CustomDataFieldDefinitions.StandardDataTypes.NumberDataTypeId), "Repetitions"); RepetitionsField.CreatedBy = PluginGuid; } if (SetsField == null) { SetsField = Logbook.CustomDataFieldDefinitions.Add(SetsGuid, CustomDataFieldDefinitions.StandardObjectType(typeof(IActivity)), CustomDataFieldDefinitions.StandardDataType(CustomDataFieldDefinitions.StandardDataTypes.NumberDataTypeId), "Sets"); SetsField.CreatedBy = PluginGuid; } }
public void Load(ILogbook logbook) { try { byte[] data = logbook.GetExtensionData(Plugin.Instance.Id); if (data != null && data.Length > 0) { string attr; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(Encoding.UTF8.GetString(data)); XmlElement nodeRoot = xmlDoc.DocumentElement; email = nodeRoot.GetAttribute(xmlTags.email); username = nodeRoot.GetAttribute(xmlTags.username); userid = nodeRoot.GetAttribute(xmlTags.userid); publicKey = nodeRoot.GetAttribute(xmlTags.publicKey); attr = nodeRoot.GetAttribute(xmlTags.multiple); if (attr.Length > 0) { try { importMultipleEntries = (MultipleEntriesUpdateStyles)Enum.Parse(typeof(MultipleEntriesUpdateStyles), attr); } catch { } } updateBMI = XmlConvert.ToBoolean(nodeRoot.GetAttribute(xmlTags.bmi)); importManualEntries = XmlConvert.ToBoolean(nodeRoot.GetAttribute(xmlTags.manual)); importAmbiguousEntries = XmlConvert.ToBoolean(nodeRoot.GetAttribute(xmlTags.ambiguous)); importHeightEntries = XmlConvert.ToBoolean(nodeRoot.GetAttribute(xmlTags.height)); lastUpdate = XmlConvert.ToInt64(nodeRoot.GetAttribute(xmlTags.lastupdate)); attr = nodeRoot.GetAttribute(xmlTags.logDate); if (attr.Length > 0) lastLogEntryDate = XmlConvert.ToDateTime(attr, XmlDateTimeSerializationMode.Utc); lastLogEntry = nodeRoot.GetAttribute(xmlTags.log); } } catch { } }
public Histogram(ILogbook log) { _holder = log; }
public void Save(ILogbook logbook) { try { XmlDocument xmlDoc = new XmlDocument(); XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null); xmlDoc.InsertBefore(xmlDeclaration, xmlDoc.DocumentElement); XmlElement nodeRoot = xmlDoc.CreateElement(xmlTags.rootElement); if (email.Length > 0) nodeRoot.SetAttribute(xmlTags.email, email); if (username.Length > 0) nodeRoot.SetAttribute(xmlTags.username, username); if (userid.Length > 0) nodeRoot.SetAttribute(xmlTags.userid, userid); if (publicKey.Length > 0) nodeRoot.SetAttribute(xmlTags.publicKey, publicKey); nodeRoot.SetAttribute(xmlTags.multiple, importMultipleEntries.ToString()); nodeRoot.SetAttribute(xmlTags.bmi, XmlConvert.ToString(updateBMI)); nodeRoot.SetAttribute(xmlTags.manual, XmlConvert.ToString(importManualEntries)); nodeRoot.SetAttribute(xmlTags.ambiguous, XmlConvert.ToString(importAmbiguousEntries)); nodeRoot.SetAttribute(xmlTags.height, XmlConvert.ToString(importHeightEntries)); nodeRoot.SetAttribute(xmlTags.lastupdate, XmlConvert.ToString(lastUpdate)); if (lastLogEntryDate != DateTime.MinValue) nodeRoot.SetAttribute(xmlTags.logDate, XmlConvert.ToString(lastLogEntryDate, XmlDateTimeSerializationMode.Utc)); if (lastLogEntry.Length != 0) nodeRoot.SetAttribute(xmlTags.log, lastLogEntry); xmlDoc.AppendChild(nodeRoot); byte[] data = Encoding.UTF8.GetBytes(xmlDoc.OuterXml); logbook.SetExtensionData(Plugin.Instance.Id, data); // TODO: Hack to trigger a modified flag on logbook, fix this in core code - if extension data/text changes, flag modified logbook.Athlete.Name = logbook.Athlete.Name; } catch { } }
private void UnregisterCategoryCallback(ILogbook logbook) { if (logbook != null) { foreach (IActivityCategory category in logbook.ActivityCategories) { UnregisterCategoryCallback(category); } } }
public IList <object> GetFilterCriterias(ILogbook logbook) { return(m_Criterias); }
private void ProcessResponse(ILogbook logbook, LogbookSettings settings, IList<WithingsWebServiceProxy.MeasurementInfo> measurements) { // Running in the UI thread. if (measurements != null) { MeasurementImporter.ImportMeasurements(logbook, settings, measurements); settings.LastUpdate = WithingsWebServiceProxy.GetNowEpoch(); AddLogEntry(settings, ""); } settings.Save(logbook); ExtendSettingsPages.RefreshSettings(); }
private void AppPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e != null && e.PropertyName == "Logbook") { if (m_CurrentLogbook != null) { this.UnregisterCategoryCallback(m_CurrentLogbook); m_CurrentLogbook.CadenceZones.CollectionChanged -= this.OnZoneCategoriesCollectionChanged; m_CurrentLogbook.ClimbZones.CollectionChanged -= this.OnZoneCategoriesCollectionChanged; m_CurrentLogbook.HeartRateZones.CollectionChanged -= this.OnZoneCategoriesCollectionChanged; m_CurrentLogbook.PowerZones.CollectionChanged -= this.OnZoneCategoriesCollectionChanged; m_CurrentLogbook.SpeedZones.CollectionChanged -= this.OnZoneCategoriesCollectionChanged; } if (LogbookChanged != null) { LogbookChanged(this, m_CurrentLogbook, m_App.Logbook); } m_CurrentLogbook = m_App.Logbook; if (m_CurrentLogbook != null) { this.RegisterCategoryCallback(m_CurrentLogbook); m_CurrentLogbook.CadenceZones.CollectionChanged += this.OnZoneCategoriesCollectionChanged; m_CurrentLogbook.ClimbZones.CollectionChanged += this.OnZoneCategoriesCollectionChanged; m_CurrentLogbook.HeartRateZones.CollectionChanged += this.OnZoneCategoriesCollectionChanged; m_CurrentLogbook.PowerZones.CollectionChanged += this.OnZoneCategoriesCollectionChanged; m_CurrentLogbook.SpeedZones.CollectionChanged += this.OnZoneCategoriesCollectionChanged; } } }
public static void FetchDataFromServer(ILogbook logbook) { // Running in the UI thread - launch the background thread. Synchronizer synchronizer = new Synchronizer(logbook); ThreadPool.QueueUserWorkItem(SynchronizerBackgroundCallback, synchronizer); }
private void OnLogbookChanged(object sender, ILogbook oldLogbook, ILogbook newLogbook) { RunSetupWizard(); }
public void SetSettings(ILogbook logbook, LogbookSettings settings) { this.logbook = logbook; this.settings = settings; RefreshControls(); }