private GarminDeviceManager() { try { Logger.Instance.LogText("Creating GarminDeviceManager"); m_TimeoutTimer.Tick += new EventHandler(OnTimeoutTimerTick); m_TimeoutTimer.Interval = 15000; Logger.Instance.LogText("Adding Communicator controller"); IGarminDeviceController newController = new GarminFitnessCommunicatorDeviceController(); newController.InitializationCompleted += new DeviceControllerOperationCompletedEventHandler(OnControllerInitializationCompleted); newController.FindDevicesCompleted += new DeviceControllerOperationCompletedEventHandler(OnControllerFindDevicesCompleted); newController.ExceptionTriggered += new EventHandler<GarminFitnessCommunicatorBridge.ExceptionEventArgs>(OnControllerExceptionTriggered); m_Controllers.Add(newController); } catch (Exception e) { Logger.Instance.LogText(String.Format("Error in GarminDeviceManager constructor, {0}", e.Message)); MessageBox.Show(e.Message + "\n\n" + e.StackTrace); } }
public GarminFitnessCommunicatorDevice(GarminFitnessCommunicatorDeviceController controller, XmlNode deviceXml) { m_TempDirectoryLocation = typeof(PluginMain).Assembly.Location; m_TempDirectoryLocation = m_TempDirectoryLocation.Substring(0, m_TempDirectoryLocation.LastIndexOf('\\')); m_TempDirectoryLocation = m_TempDirectoryLocation.Substring(0, m_TempDirectoryLocation.LastIndexOf('\\')); m_TempDirectoryLocation = m_TempDirectoryLocation + "\\Communicator\\temp\\"; m_Controller = controller; foreach (XmlAttribute attribute in deviceXml.Attributes) { if (attribute.Name.Equals("Number")) { m_DeviceNumber = Int32.Parse(attribute.Value); } else if (attribute.Name.Equals("DisplayName")) { m_DisplayName = attribute.Value; } else if (attribute.Name.Equals("Id")) { m_Id = attribute.Value; } else if (attribute.Name.Equals("SoftwareVersion")) { m_SoftwareVersion = attribute.Value; } else if (attribute.Name.Equals("SupportReadWorkout")) { m_SupportsReadWorkout = Boolean.Parse(attribute.Value); } else if (attribute.Name.Equals("SupportWriteWorkout")) { m_SupportsWriteWorkout = Boolean.Parse(attribute.Value); } else if (attribute.Name.Equals("WorkoutFileTransferPath")) { m_WorkoutFileTransferPath = attribute.Value; } else if (attribute.Name.Equals("SupportsFITWorkouts")) { m_SupportsFITWorkouts = Boolean.Parse(attribute.Value); } else if (attribute.Name.Equals("FITWorkoutFileWriteTransferPath")) { m_FITWorkoutFileWritePath = attribute.Value; } else if (attribute.Name.Equals("FITWorkoutFileReadTransferPath")) { m_FITWorkoutFileReadPath = attribute.Value; } else if (attribute.Name.Equals("SupportsFITWorkoutSchedules")) { m_SupportsFITWorkoutSchedules = Boolean.Parse(attribute.Value); } else if (attribute.Name.Equals("FITWorkoutSchedulesFileWriteTransferPath")) { m_FITWorkoutSchedulesFileWritePath = attribute.Value; } else if (attribute.Name.Equals("FITWorkoutSchedulesFileReadTransferPath")) { m_FITWorkoutSchedulesFileReadPath = attribute.Value; } else if (attribute.Name.Equals("SupportReadProfile")) { m_SupportsReadProfile = Boolean.Parse(attribute.Value); } else if (attribute.Name.Equals("SupportWriteProfile")) { m_SupportsWriteProfile = Boolean.Parse(attribute.Value); } else if (attribute.Name.Equals("SupportsFITSettings")) { m_SupportsFITSettings = Boolean.Parse(attribute.Value); } else if (attribute.Name.Equals("FITSettingsFileWriteTransferPath")) { m_FITSettingsFileWritePath = attribute.Value; } else if (attribute.Name.Equals("FITSettingsFileReadTransferPath")) { m_FITSettingsFileReadPath = attribute.Value; } else if (attribute.Name.Equals("SupportsFITSports")) { m_SupportsFITSports = Boolean.Parse(attribute.Value); } else if (attribute.Name.Equals("FITSportFileWriteTransferPath")) { m_FITSportFileWritePath = attribute.Value; } else if (attribute.Name.Equals("FITSportFileReadTransferPath")) { m_FITSportFileReadPath = attribute.Value; } } }