/// <summary> /// Initializes a new instance of the <see cref="PersonaPostalAddress"/> class. /// </summary> /// <param name="street">The Street Address.</param> /// <param name="city">The City value.</param> /// <param name="state">The State value.</param> /// <param name="country">The country value.</param> /// <param name="postalCode">The postal code value.</param> /// <param name="postOfficeBox">The Post Office Box.</param> /// <param name="locationSource">The location Source.</param> /// <param name="locationUri">The location Uri.</param> /// <param name="formattedAddress">The location street Address in formatted address.</param> /// <param name="latitude">The location latitude.</param> /// <param name="longitude">The location longitude.</param> /// <param name="accuracy">The location accuracy.</param> /// <param name="altitude">The location altitude.</param> /// <param name="altitudeAccuracy">The location altitude Accuracy.</param> public PersonaPostalAddress( string street, string city, string state, string country, string postalCode, string postOfficeBox, LocationSource locationSource, string locationUri, string formattedAddress, double latitude, double longitude, double accuracy, double altitude, double altitudeAccuracy) : this() { this.street = street; this.city = city; this.state = state; this.country = country; this.postalCode = postalCode; this.postOfficeBox = postOfficeBox; this.latitude = latitude; this.longitude = longitude; this.source = locationSource; this.uri = locationUri; this.formattedAddress = formattedAddress; this.accuracy = accuracy; this.altitude = altitude; this.altitudeAccuracy = altitudeAccuracy; }
private CultureInfo cultureInfo = new CultureInfo("en-US"); // e.g. 10.5 and not 10,5 public LocationSourceRecorder(LocationSource locationSource, Boolean pause) { this.updateInterval = Properties.Settings.Default.locationUpdateInterval; Debug.WriteLine("UpdateInterval: " + updateInterval); this.Pause = pause; this.locationSource = locationSource; this.locationSource.Attach(this); if (!Directory.Exists(Properties.Settings.Default.userTrackFolder)) { Directory.CreateDirectory(Properties.Settings.Default.userTrackFolder); } this.xmlWriter = new XmlTextWriter(Properties.Settings.Default.userTrackFolder + locationSource.Id + ".xml", System.Text.Encoding.UTF8); this.xmlWriter.Formatting = Formatting.Indented; this.xmlWriter.WriteStartDocument(false); this.xmlWriter.WriteComment("locationSourceId: " + locationSource.Id); this.xmlWriter.WriteComment("locationSourceName: " + locationSource.Name); this.xmlWriter.WriteStartElement("gpx"); this.xmlWriter.WriteAttributeString("version", "1.1"); this.xmlWriter.WriteAttributeString("creator", "PresenceSimulator"); this.xmlWriter.WriteStartElement("trk"); this.xmlWriter.WriteStartElement("trkseg"); this.xmlWriter.Flush(); }
public LocationSourceRecorder createUserRecorder(LocationSource user) { LocationSourceRecorder userRecorder = new LocationSourceRecorder(user, this.pause); this.userRecorders.Add(userRecorder); return(userRecorder); }
private static void SetOrDeleteValue(IStorePropertyBag propertyBag, NativeStorePropertyDefinition property, LocationSource value) { if (value == Microsoft.Exchange.Data.Storage.LocationSource.None) { propertyBag.Delete(property); return; } propertyBag[property] = value; }
public void execute() { LocationSource locationSource = LocationSourceManager.Instance.createLocationSource("LocationSource" + LocationSourceManager.Instance.LocationSources.Count, detectorFactory.CreateDiscriminator()); MapOverlayForm.Instance.AddUserMarker(locationSource.mapMarker); locationSource.Attach(locationSource.mapMarker); LocationSourceFormView userView = new LocationSourceFormView(locationSource, this.userListContainer); locationSource.Attach(userView); RecorderManager.Instance.createUserRecorder(locationSource); }
public LocationSourceMapMarker(LocationSource user) : base(user.LatLng) { this.locationSource = user; this.OuterPen = new Pen(Color.Black, 2); this.InnerBrush = new SolidBrush(Color.Gray); this.Text = user.Name; this.TextFont = new Font("Arial", 15, FontStyle.Bold); this.TextBrush = Brushes.DarkMagenta; this.Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2); }
public void execute() { LocationSource locationSource = LocationSourceManager.Instance.createLocationSource("LocationSource" + LocationSourceManager.Instance.LocationSources.Count, new DummyDiscriminator()); //user.Discri = new ColorDiscriminator(); LocationSourcePlayer locationSourcePlayer = null; try { locationSourcePlayer = new LocationSourcePlayer(locationSource, path); } catch (XmlException) { LocationSourceManager.Instance.deleteLocationSource(locationSource); System.Windows.Forms.MessageBox.Show("There is an error in your XML file. ", "Format Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); return; } MapOverlayForm.Instance.AddUserMarker(locationSource.mapMarker); locationSource.Attach(locationSource.mapMarker); LocationSourceTrackForm locationSourceView = new LocationSourceTrackForm(locationSource, userListContainer, locationSourcePlayer); }
protected void SetLeftPercent(double x, LocationSource source = LocationSource.Begin) { if (!Dispatcher.CheckAccess()) { Dispatcher.Invoke(() => SetLeftPercent(x)); return; } if (x > 1) { x /= 100; } logger.Information($"Positioning Info: SetLeftPercent({x}, {source})"); if (source == LocationSource.Center) { x -= GetWidthPercent() / 2; } else if (source == LocationSource.End) { x -= GetWidthPercent(); } logger.Information($"Positioning Info: SetLeftPercent: x = {x}"); logger.Information($"Positioning Info: SetLeftPercent: ActualWidth = {ActualWidth}"); logger.Information($"Positioning Info: SetLeftPercent: GetWidthPercent() = {GetWidthPercent()}"); var screenRect = Screen.FromPoint(MyCursor.Position).Bounds; var desiredX = screenRect.X + (screenRect.Width * x); logger.Information($"Positioning Info: SetLeftPercent: Screen.Bounds.Width = {screenRect.Width}"); logger.Information($"Positioning Info: SetLeftPercent: Screen.Bounds.X = {screenRect.X}"); logger.Information($"Positioning Info: SetLeftPercent: Left = {desiredX}"); LeftLocationSource = source; Left = (int)desiredX; EnsureBounds(); }
protected void SetTopPercent(double y, LocationSource source = LocationSource.Begin) { if (!Dispatcher.CheckAccess()) { Dispatcher.Invoke(() => SetTopPercent(y)); return; } if (y > 1) { y /= 100; } logger.Information($"Positioning Info: SetTopPercent({y}, {source})"); if (source == LocationSource.Center) { y -= GetHeightPercent() / 2; } else if (source == LocationSource.End) { y -= GetHeightPercent(); } logger.Information($"Positioning Info: SetTopPercent: y = {y}"); logger.Information($"Positioning Info: SetTopPercent: ActualHeight = {ActualHeight}"); logger.Information($"Positioning Info: SetTopPercent: GetHeightPercent() = {GetHeightPercent()}"); var screenRect = Screen.FromPoint(MyCursor.Position).Bounds; var desiredY = screenRect.Y + (screenRect.Height * y); logger.Information($"Positioning Info: SetTopPercent: Screen.Bounds.Height = {screenRect.Height}"); logger.Information($"Positioning Info: SetTopPercent: Screen.Bounds.Y = {screenRect.Y}"); logger.Information($"Positioning Info: SetTopPercent: Top = {desiredY}"); TopLocationSource = source; Top = (int)desiredY; EnsureBounds(); }
private CultureInfo cultureInfo = new CultureInfo("en-US"); // e.g. 10.5 and not 10,5 public LocationSourcePlayer(LocationSource user, String path) { this.user = user; try { track = new XPathDocument(path); } catch (XmlException xmlEcxeption) { throw xmlEcxeption; } trackNav = track.CreateNavigator(); // extract user name from second comment String userNameComment = trackNav.SelectSingleNode("comment()[2]").ToString(); String userName = userNameComment.Substring(20); this.user.Name = userName; this.setupTrkptIterator(); }
public void fetchUpdatesFromSelectedUserTest() { target = NetworkServer.Instance; target.Start(); client = new TcpClient(); locationUpdateServerEndPoint = new IPEndPoint(IPAddress.Parse(Broadcaster.getOwnIP()), PresenceSimulator.Properties.Settings.Default.updateProviderPort); LocationSourceManager.Instance.Shutdown(); LocationSource user = LocationSourceManager.Instance.createLocationSource("Foo", new ColorDiscriminator()); client.Connect(locationUpdateServerEndPoint); NetworkStream stream = client.GetStream(); StreamReader reader = new StreamReader(stream); StreamWriter writer = new StreamWriter(stream); string lsId = LocationSourceManager.Instance.LocationSources[0].Id.ToString(); string answer = "<?xml version=\"1.0\"?><user id=\"" + lsId + "\"/>"; writer.WriteLine(answer); writer.Flush(); TimerCallback timerDelegate = new TimerCallback(this.changeLocationSource); Timer changeLSTimer = new Timer(timerDelegate, new AutoResetEvent(false), 1000, 250); string update = reader.ReadLine(); update = reader.ReadLine(); changeLSTimer.Dispose(); Assert.AreEqual("<trkpt lat=\"1\" lon=\"2\"><time /></trkpt>", update); writer.Close(); reader.Close(); client.Close(); target.Stop(); }
private void userSelection() { if (!TcpClient.Connected) { NetworkServer.Instance.removeConnection(this); return; } // wait for user selection XmlDocument doc = new XmlDocument(); string userSelection = this.reader.ReadLine(); if (userSelection == null) { NetworkServer.Instance.removeConnection(this); return; } doc.InnerXml = userSelection; XmlElement root = doc.DocumentElement; // fetch selected user from user manager String selectedId = root.GetAttribute("id"); Guid userId = System.Guid.Parse(selectedId); LocationSource selectedUser = LocationSourceManager.Instance.getLocationSourceById(userId); if (selectedUser != null) { this.sendXmlHeader(); this.locationSource = selectedUser; this.locationSource.Attach(this); NetworkServer.Instance.Log("client selected user: " + this.locationSource.Name); } else { NetworkServer.Instance.removeConnection(this); return; } }
/// <summary> /// Tries to read element from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>True if element was read.</returns> internal override bool TryReadElementFromXml(EwsServiceXmlReader reader) { switch (reader.LocalName) { case XmlElementNames.Street: this.street = reader.ReadValue <string>(); return(true); case XmlElementNames.City: this.city = reader.ReadValue <string>(); return(true); case XmlElementNames.State: this.state = reader.ReadValue <string>(); return(true); case XmlElementNames.Country: this.country = reader.ReadValue <string>(); return(true); case XmlElementNames.PostalCode: this.postalCode = reader.ReadValue <string>(); return(true); case XmlElementNames.PostOfficeBox: this.postOfficeBox = reader.ReadValue <string>(); return(true); case XmlElementNames.PostalAddressType: this.type = reader.ReadValue <string>(); return(true); case XmlElementNames.Latitude: this.latitude = reader.ReadValue <double>(); return(true); case XmlElementNames.Longitude: this.longitude = reader.ReadValue <double>(); return(true); case XmlElementNames.Accuracy: this.accuracy = reader.ReadValue <double>(); return(true); case XmlElementNames.Altitude: this.altitude = reader.ReadValue <double>(); return(true); case XmlElementNames.AltitudeAccuracy: this.altitudeAccuracy = reader.ReadValue <double>(); return(true); case XmlElementNames.FormattedAddress: this.formattedAddress = reader.ReadValue <string>(); return(true); case XmlElementNames.LocationUri: this.uri = reader.ReadValue <string>(); return(true); case XmlElementNames.LocationSource: this.source = reader.ReadValue <LocationSource>(); return(true); default: return(false); } }
public DeleteLocationSourceCommand(LocationSource locationSource) { this.locationSource = locationSource; }
public override bool Supports(LocationSource source) { return true; }
public LocationSourceTrackForm(LocationSource locationSource, Panel parent, LocationSourcePlayer locationSourcePlayer) { this.locationSource = locationSource; this.parent = parent; this.locationSourcePlayer = locationSourcePlayer; this.container = new GroupBox(); this.container.Width = this.parent.Width - 25; this.container.Height = 132; parent.Controls.Add(container); Label nameLabel = new Label(); nameLabel.Text = "Name:"; nameLabel.Location = new System.Drawing.Point(5, 14); nameLabel.AutoSize = true; container.Controls.Add(nameLabel); name = new Label(); name.Text = this.locationSource.Name; name.Location = new System.Drawing.Point(45, 14); name.AutoSize = true; container.Controls.Add(name); Label latLabel = new Label(); latLabel.Text = "Lat:"; latLabel.Location = new System.Drawing.Point(5, 40); latLabel.AutoSize = true; container.Controls.Add(latLabel); lat = new Label(); lat.Text = "unknown"; lat.Location = new System.Drawing.Point(45, 40); lat.Width = 85; lat.Height = 13; container.Controls.Add(lat); Label lngLabel = new Label(); lngLabel.Text = "Lng:"; lngLabel.Location = new System.Drawing.Point(5, 60); lngLabel.AutoSize = true; container.Controls.Add(lngLabel); lng = new Label(); lng.Text = "unknown"; lng.Location = new System.Drawing.Point(45, 60); lng.Width = 85; lng.Height = 13; container.Controls.Add(lng); play = new CheckBox(); play.Appearance = Appearance.Button; play.Text = "Play"; play.Location = new System.Drawing.Point(5, 80); play.Width = 40; play.Click += delegate { this.stop.Enabled = true; this.stop.Checked = false; this.play.Checked = true; this.play.Enabled = false; this.locationSourcePlayer.Play(); }; container.Controls.Add(play); pause = new CheckBox(); pause.Appearance = Appearance.Button; pause.Text = "Pause"; pause.Location = new System.Drawing.Point(46, 80); pause.Width = 45; pause.Click += delegate { if (this.pause.Checked) { this.locationSourcePlayer.Pause = true; } else { this.locationSourcePlayer.Pause = false; } }; container.Controls.Add(pause); stop = new CheckBox(); stop.Appearance = Appearance.Button; stop.Checked = true; stop.Enabled = false; stop.Text = "Stop"; stop.Location = new System.Drawing.Point(92, 80); stop.Width = 40; stop.Click += delegate { this.pressStop(); }; container.Controls.Add(stop); Button removeUser = new Button(); removeUser.Text = "Remove Track"; removeUser.Location = new System.Drawing.Point(5, 103); removeUser.Width = 127; removeUser.Click += delegate { new DeleteLocationSourceCommand(this.locationSource).execute(); }; container.Controls.Add(removeUser); this.locationSource.Attach(this); this.locationSourcePlayer.RegisterUserTrackForm(this); }
public static ContextInfo GetUserContextInfo() { IntPtr hActive = GetActiveWindow(); if (hActive == IntPtr.Zero) { return(null); } uint pId = 0; NativeMethods.GetWindowThreadProcessId(hActive, out pId); var title = GetWindowTitle(hActive); var fileName = GetProcessFilename(pId); var fileNameKey = Path.GetFileName(fileName).ToUpperInvariant(); string location = null; LocationSource locationSource = LocationSource.None; if (ddeTargets.ContainsKey(fileNameKey)) { try { using (var c = new NDde.Client.DdeClient(ddeTargets[fileNameKey], "WWW_GetWindowInfo")) { if (c.TryConnect() == 0) { locationSource = LocationSource.DDE; var res = c.Request("0xFFFFFFFF", int.MaxValue); if (res != null) { res = res.TrimEnd('\0'); var parts = res.Split(','); location = parts[0].Trim('\"'); } } } } catch (NDde.DdeException ex) { Debug.Write(ex); } } if (locationSource == LocationSource.None && pathLookups.ContainsKey(fileNameKey)) { var textHWnd = LookupWindow(hActive, pathLookups[fileNameKey]); if (textHWnd != IntPtr.Zero) { locationSource = LocationSource.Typed; location = ReadWindowText(textHWnd); } } return(new ContextInfo { HWnd = hActive, FileName = fileName, Title = title, ProcessId = pId, Location = location, LocationSource = locationSource, }); }
/// <summary> /// Factory method for obtaining an instance of a provider /// </summary> /// <param name='sourceType'> /// Type of location that weather data will be retrieved from. /// </param> /// <param name='source'> /// The string value of the source to give to the provider. /// </param> /// <returns> /// An instance of IWeather containing weather data from the provider. /// </returns> /// <exception cref='ArgumentException'> /// Is thrown when the provider cannot fetch weather data for the /// LocationSource provided. /// </exception> private IWeather getInstance(LocationSource sourceType, string source) { // Go through the available providers until we get one that can fulfill the request foreach (WeatherProvider provider in _providers) { if (provider.Supports(sourceType)) { provider.Location = source; provider.Source = sourceType; provider.Update(); return (IWeather)provider; } } // No providers can fullfill the request throw new ArgumentException(String.Format("No available provider supports a {0} source", source)); }
/// <summary> /// Determines if the provider supports the specified LocationSource. /// </summary> /// <param name='source'> /// The LocationSource to test support for. /// </param> /// <returns> /// True if the provider supports the given source, false otherwise /// </returns> public abstract bool Supports(LocationSource source);
/// <summary> /// Tries to read element from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>True if element was read.</returns> internal override bool TryReadElementFromXml(EwsServiceXmlReader reader) { switch (reader.LocalName) { case XmlElementNames.Street: this.street = reader.ReadValue<string>(); return true; case XmlElementNames.City: this.city = reader.ReadValue<string>(); return true; case XmlElementNames.State: this.state = reader.ReadValue<string>(); return true; case XmlElementNames.Country: this.country = reader.ReadValue<string>(); return true; case XmlElementNames.PostalCode: this.postalCode = reader.ReadValue<string>(); return true; case XmlElementNames.PostOfficeBox: this.postOfficeBox = reader.ReadValue<string>(); return true; case XmlElementNames.PostalAddressType: this.type = reader.ReadValue<string>(); return true; case XmlElementNames.Latitude: this.latitude = reader.ReadValue<double>(); return true; case XmlElementNames.Longitude: this.longitude = reader.ReadValue<double>(); return true; case XmlElementNames.Accuracy: this.accuracy = reader.ReadValue<double>(); return true; case XmlElementNames.Altitude: this.altitude = reader.ReadValue<double>(); return true; case XmlElementNames.AltitudeAccuracy: this.altitudeAccuracy = reader.ReadValue<double>(); return true; case XmlElementNames.FormattedAddress: this.formattedAddress = reader.ReadValue<string>(); return true; case XmlElementNames.LocationUri: this.uri = reader.ReadValue<string>(); return true; case XmlElementNames.LocationSource: this.source = reader.ReadValue<LocationSource>(); return true; default: return false; } }
/// <summary> /// Loads from json. /// </summary> /// <param name="jsonProperty">The json property.</param> /// <param name="service"></param> internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service) { foreach (string key in jsonProperty.Keys) { switch (key) { case XmlElementNames.Street: this.street = jsonProperty.ReadAsString(key); break; case XmlElementNames.City: this.city = jsonProperty.ReadAsString(key); break; case XmlElementNames.Country: this.country = jsonProperty.ReadAsString(key); break; case XmlElementNames.PostalCode: this.postalCode = jsonProperty.ReadAsString(key); break; case XmlElementNames.PostOfficeBox: this.postOfficeBox = jsonProperty.ReadAsString(key); break; case XmlElementNames.PostalAddressType: this.type = jsonProperty.ReadAsString(key); break; case XmlElementNames.Latitude: this.latitude = jsonProperty.ReadAsDouble(key); break; case XmlElementNames.Longitude: this.longitude = jsonProperty.ReadAsDouble(key); break; case XmlElementNames.Accuracy: this.accuracy = jsonProperty.ReadAsDouble(key); break; case XmlElementNames.Altitude: this.altitude = jsonProperty.ReadAsDouble(key); break; case XmlElementNames.AltitudeAccuracy: this.altitudeAccuracy = jsonProperty.ReadAsDouble(key); break; case XmlElementNames.FormattedAddress: this.formattedAddress = jsonProperty.ReadAsString(key); break; case XmlElementNames.LocationUri: this.uri = jsonProperty.ReadAsString(key); break; case XmlElementNames.LocationSource: this.source = jsonProperty.ReadEnumValue <LocationSource>(key); break; default: break; } } }
public override bool Supports(LocationSource source) { return source != LocationSource.LatitudeLongitude; }