public TrafficViewDialogViewController(TrafficUpdates tu, string origin, string destination) : base(UITableViewStyle.Grouped, null) { string head = "Traffic Update"; secOutput = new Section("Output"); root = new RootElement(head) { secOutput }; Origin = origin; Destination = destination; Root = root; dvc = new DialogViewController(root, true); var tap = new UITapGestureRecognizer(); tap.AddTarget(() => { dvc.View.EndEditing(true); }); dvc.View.AddGestureRecognizer(tap); tu.TrafficUpdate += Display; tap.CancelsTouchesInView = false; dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Refresh, delegate { secOutput.RemoveRange(0, secOutput.Count); tu.Origin = Origin; tu.Destination = Destination; tu.RunSearch("", false, false); }); AppDelegate.navigation.PushViewController(dvc, true); tu.Origin = Origin; tu.Destination = Destination; tu.RunSearch("", false, false); }
public TrafficViewDialogViewController (TrafficUpdates tu, string origin, string destination ) : base (UITableViewStyle.Grouped, null) { string head = "Traffic Update"; secOutput = new Section("Output"); root = new RootElement (head) { secOutput }; Origin = origin; Destination = destination; Root = root; dvc = new DialogViewController (root, true); var tap = new UITapGestureRecognizer (); tap.AddTarget (() =>{ dvc.View.EndEditing (true); }); dvc.View.AddGestureRecognizer (tap); tu.TrafficUpdate += Display; tap.CancelsTouchesInView = false; dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Refresh, delegate { secOutput.RemoveRange(0, secOutput.Count); tu.Origin = Origin; tu.Destination = Destination; tu.RunSearch("", false, false); }); AppDelegate.navigation.PushViewController (dvc, true); tu.Origin = Origin; tu.Destination = Destination; tu.RunSearch("", false, false); }
public void Display (string strText, TrafficUpdates.TrafficMessage trafficMessage) { UIColor uiColor = UIColor.Black; if (trafficMessage == TrafficUpdates.TrafficMessage.Blocked) { uiColor = UIColor.Red; } else if (trafficMessage == TrafficUpdates.TrafficMessage.Heavy) { uiColor = UIColor.Orange; } else if (trafficMessage == TrafficUpdates.TrafficMessage.Normal) { uiColor = UIColor.Green; } else if (trafficMessage == TrafficUpdates.TrafficMessage.Low) { uiColor = UIColor.Purple; } StyledMultilineElement sme = new StyledMultilineElement (strText) { Font = font12, TextColor = uiColor, }; //sme. AppDelegate.navigation.BeginInvokeOnMainThread(delegate { secOutput.Add (sme); }); }
public TrafficDialogViewController() : base(UITableViewStyle.Grouped, null) { tu = new TrafficUpdates(); OnLocationChanged += delegate(UITextField textField, GetLocationActions locActions, string lat, string lng) { textField.Enabled = true; if (locActions == GetLocationActions.UpdateTraffic) { tu.ValidateLocation(string.Format("{0},{1}", lat, lng), GetLocationActions.UpdateTraffic); } else if (locActions == GetLocationActions.SetOrigin) { tu.ValidateLocation(string.Format("{0},{1}", lat, lng), GetLocationActions.SetOrigin); gbViewTraffic.Enabled = true; } else if (locActions == GetLocationActions.SetDestination) { tu.ValidateLocation(string.Format("{0},{1}", lat, lng), GetLocationActions.SetDestination); gbViewTraffic.Enabled = true; } }; tu.PostToChannel += delegate(string channel, TrafficUpdates.TrafficMessage trafficMessage) { AppDelegate.navigation.BeginInvokeOnMainThread(delegate { pnChannel = channel; if (string.IsNullOrWhiteSpace(pnChannel)) { AppDelegate.navigation.BeginInvokeOnMainThread(delegate { new UIAlertView("Error!", "Please enter valid location", null, "OK").Show(); }); } else { tu.PublishMessage(pnChannel, trafficMessage); new UIAlertView("Success!", "Message published", null, "OK").Show(); } gbBlocked.Enabled = true; gbHeavy.Enabled = true; gbNormal.Enabled = true; gbLow.Enabled = true; }); }; tu.AddressUpdate += delegate(string address, string lat, string lng, bool fromAddress, string polylinePoints, GetLocationActions locActions) { AppDelegate.navigation.BeginInvokeOnMainThread(delegate { if (locActions == GetLocationActions.UpdateTraffic) { tfUpdateLocation.Text = address; gbBlocked.Enabled = true; gbHeavy.Enabled = true; gbNormal.Enabled = true; gbLow.Enabled = true; } else if (locActions == GetLocationActions.SetOrigin) { tfOrigin.Text = address; gbViewTraffic.Enabled = true; } else if (locActions == GetLocationActions.SetDestination) { tfDestination.Text = address; gbViewTraffic.Enabled = true; } }); }; UIView labelView = new UIView(new RectangleF(0, 0, this.View.Bounds.Width, 16)); int left = 20; iPhoneLocationManager = new CLLocationManager(); iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyHundredMeters; labelView.AddSubview(new UILabel(new RectangleF(left, 0, this.View.Bounds.Width - left, 16)) { Font = UIFont.BoldSystemFontOfSize(16), BackgroundColor = UIColor.Clear, TextColor = UIColor.FromRGB(76, 86, 108), Text = "Update traffic" }); var dictRect = GetRectanglesForIphone(); int viewHeight = 60; Section secAction = new Section(); secAction.HeaderView = CreateHeaderView(dictRect, viewHeight); tfUpdateLocation = new UITextField(); Section secUpdateLocation = new Section(); RectangleF rectFUpdateLocation = new RectangleF(left, 25, this.View.Bounds.Width - left, 26); secUpdateLocation.HeaderView = CreateTextView(tfUpdateLocation, "Enter Location address", "1100 16th Street, San Francisco, CA 94107, USA", rectFUpdateLocation, GetLocationActions.UpdateTraffic); tfNextStreet = new UITextField(); Section secNextStreet = new Section(); RectangleF rectFNextStreet = new RectangleF(left, 25, this.View.Bounds.Width - left, 26); secNextStreet.HeaderView = CreateTextView(tfNextStreet, "Next Street (direction of traffic)", "339 Arkansas Street, San Francisco, CA 94107, USA", rectFUpdateLocation, GetLocationActions.None); tfOrigin = new UITextField(); Section secOrigin = new Section(); RectangleF rectFOrigin = new RectangleF(left, 25, this.View.Bounds.Width - left, 26); secOrigin.HeaderView = CreateTextView(tfOrigin, "Enter Origin (can be lat, lng)", "Downtown, san francisco", rectFOrigin, GetLocationActions.SetOrigin); tfDestination = new UITextField(); Section secDestination = new Section(); RectangleF rectFDestination = new RectangleF(left, 25, this.View.Bounds.Width - left, 26); secDestination.HeaderView = CreateTextView(tfDestination, "Enter Destination (can be lat, lng)", "725 Folsom • San Francisco, CA 94107", rectFDestination, GetLocationActions.SetDestination); Section secViewTraffic = new Section(); RectangleF rectFViewTraffic = new RectangleF(left, 25, this.View.Bounds.Width - left, 26); secViewTraffic.HeaderView = CreateButtonView(rectFViewTraffic); Root = new RootElement("Traffic") { new Section("Update traffic") { }, secUpdateLocation, secAction, new Section("View traffic") { }, secOrigin, secDestination, secViewTraffic, }; }
public TrafficDialogViewController () : base (UITableViewStyle.Grouped, null) { tu = new TrafficUpdates(); OnLocationChanged += delegate(UITextField textField, GetLocationActions locActions, string lat, string lng) { textField.Enabled = true; if (locActions == GetLocationActions.UpdateTraffic) { tu.ValidateLocation(string.Format ("{0},{1}", lat, lng), GetLocationActions.UpdateTraffic); } else if (locActions == GetLocationActions.SetOrigin) { tu.ValidateLocation(string.Format ("{0},{1}", lat, lng), GetLocationActions.SetOrigin); gbViewTraffic.Enabled = true; } else if (locActions == GetLocationActions.SetDestination) { tu.ValidateLocation(string.Format ("{0},{1}", lat, lng), GetLocationActions.SetDestination); gbViewTraffic.Enabled = true; } }; tu.PostToChannel += delegate(string channel, TrafficUpdates.TrafficMessage trafficMessage) { AppDelegate.navigation.BeginInvokeOnMainThread(delegate { pnChannel = channel; if (string.IsNullOrWhiteSpace (pnChannel)) { AppDelegate.navigation.BeginInvokeOnMainThread (delegate { new UIAlertView ("Error!", "Please enter valid location", null, "OK").Show (); }); } else { tu.PublishMessage (pnChannel, trafficMessage); new UIAlertView ("Success!", "Message published", null, "OK").Show (); } gbBlocked.Enabled = true; gbHeavy.Enabled = true; gbNormal.Enabled = true; gbLow.Enabled = true; }); }; tu.AddressUpdate += delegate(string address, string lat, string lng, bool fromAddress, string polylinePoints, GetLocationActions locActions) { AppDelegate.navigation.BeginInvokeOnMainThread(delegate { if (locActions == GetLocationActions.UpdateTraffic) { tfUpdateLocation.Text = address; gbBlocked.Enabled = true; gbHeavy.Enabled = true; gbNormal.Enabled = true; gbLow.Enabled = true; } else if (locActions == GetLocationActions.SetOrigin) { tfOrigin.Text = address; gbViewTraffic.Enabled = true; } else if (locActions == GetLocationActions.SetDestination) { tfDestination.Text = address; gbViewTraffic.Enabled = true; } }); }; UIView labelView = new UIView(new RectangleF (0, 0, this.View.Bounds.Width, 16)); int left = 20; iPhoneLocationManager = new CLLocationManager (); iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyHundredMeters; labelView.AddSubview(new UILabel (new RectangleF (left, 0, this.View.Bounds.Width - left, 16)){ Font = UIFont.BoldSystemFontOfSize(16), BackgroundColor = UIColor.Clear, TextColor = UIColor.FromRGB(76, 86, 108), Text = "Update traffic" }); var dictRect = GetRectanglesForIphone(); int viewHeight = 60; Section secAction = new Section (); secAction.HeaderView = CreateHeaderView(dictRect, viewHeight); tfUpdateLocation = new UITextField (); Section secUpdateLocation = new Section (); RectangleF rectFUpdateLocation = new RectangleF (left, 25, this.View.Bounds.Width - left, 26); secUpdateLocation.HeaderView = CreateTextView (tfUpdateLocation, "Enter Location address", "1100 16th Street, San Francisco, CA 94107, USA", rectFUpdateLocation, GetLocationActions.UpdateTraffic); tfNextStreet = new UITextField (); Section secNextStreet = new Section (); RectangleF rectFNextStreet = new RectangleF (left, 25, this.View.Bounds.Width - left, 26); secNextStreet.HeaderView = CreateTextView (tfNextStreet, "Next Street (direction of traffic)", "339 Arkansas Street, San Francisco, CA 94107, USA", rectFUpdateLocation, GetLocationActions.None); tfOrigin = new UITextField (); Section secOrigin = new Section (); RectangleF rectFOrigin = new RectangleF (left, 25, this.View.Bounds.Width - left, 26); secOrigin.HeaderView = CreateTextView (tfOrigin, "Enter Origin (can be lat, lng)", "Downtown, san francisco", rectFOrigin, GetLocationActions.SetOrigin); tfDestination = new UITextField (); Section secDestination = new Section (); RectangleF rectFDestination = new RectangleF (left, 25, this.View.Bounds.Width - left, 26); secDestination.HeaderView = CreateTextView (tfDestination, "Enter Destination (can be lat, lng)", "725 Folsom • San Francisco, CA 94107", rectFDestination, GetLocationActions.SetDestination); Section secViewTraffic = new Section (); RectangleF rectFViewTraffic = new RectangleF (left, 25, this.View.Bounds.Width - left, 26); secViewTraffic.HeaderView = CreateButtonView (rectFViewTraffic); Root = new RootElement ("Traffic") { new Section ("Update traffic") { }, secUpdateLocation, secAction, new Section ("View traffic") { }, secOrigin, secDestination, secViewTraffic, }; }
void CheckChannel (TrafficUpdates.TrafficMessage trafficMessage) { gbBlocked.Enabled = false; gbHeavy.Enabled = false; gbNormal.Enabled = false; gbLow.Enabled = false; tu.GetStreetAddress (tfUpdateLocation.Text, trafficMessage); }