private void Remove(NotificationEventArgs s) { if (s == null) return; // REVIEW TODO fix if (s.Timer != null) s.Timer.Stop(); if (!Notifications.Contains(s)) return; s.OnClosing(); Notifications.Remove(s); }
void InstanceDeleteNotification(NotificationEventArgs args) { if (args == null) return; var tbd = new List<FrameworkElement>(); foreach (FrameworkElement a in _view.bFreeText.Children) { if (a.Tag is Guid && (Guid)a.Tag == args.Id) tbd.Add(a); } foreach (var fe in tbd) { _view.bFreeText.Children.Remove(fe); } Remove(args); }
public void ShowText(string text, double margin = 0, double marginLeft = double.NaN, double marginTop = double.NaN, double marginRight = double.NaN, double marginBottom = double.NaN, string background = "#FF641946", string foreground = "White", string horAlign = "Left", string verAlign = "Top", double sizex = double.NaN, double sizey = double.NaN, double fontSize = 40, string fontFamily = "Segoe UI", string textAlignment="Left", double duration = 5000, bool canbedeleted = true, string script = "") { if (!IsActive()) return; var horizontalAlignment = (HorizontalAlignment) Enum.Parse(typeof(HorizontalAlignment), horAlign); // .TryParse() HorizontalAlignment.Left; var verticalAlignment = (VerticalAlignment) Enum.Parse(typeof(VerticalAlignment), verAlign); var marginTotal = new Thickness(margin); var textalignment = (TextAlignment) Enum.Parse(typeof (TextAlignment), textAlignment); var fontfamily = new FontFamily(fontFamily); if(!double.IsNaN(marginLeft) || !double.IsNaN(marginRight) || !double.IsNaN(marginTop) || !double.IsNaN(marginBottom) ) { marginTotal = new Thickness(marginLeft, marginTop, marginRight, marginBottom); } Execute.OnUIThread(()=> { var n = new NotificationEventArgs() { Text = text, Background = (Brush)new BrushConverter().ConvertFromString(background), Foreground = (Brush)new BrushConverter().ConvertFromString(foreground), HorizontalAlignment = horizontalAlignment, VerticalAlignment = verticalAlignment, TextAlignment = textalignment, FontFamily = fontfamily, Size = new Size(sizex, sizey), Margin = marginTotal, FontSize = fontSize, Duration = TimeSpan.FromMilliseconds(duration), Style = NotificationStyle.FreeText }; n.Click += (e, s) => { AppState.TriggerScriptCommand(this, "scrpt:"+script); //Console.WriteLine("Test"); }; AppState.TriggerNotification(n); }); //if (canbedeleted) _ownNotifications.Add(n.Id); }
public void AddNetwork() { if (Networks == null) Networks = new BindableCollection<Network>(); var title = string.IsNullOrEmpty(networkName) ? Model.Id : networkName; var network = Networks.FirstOrDefault(n => string.Equals(n.Title, title, StringComparison.InvariantCultureIgnoreCase)) ?? new Network {Title = title}; // Only add the network in case its unique if (!Networks.Contains(network)) Networks.Add(network); UpdateNetworkNamesLabel(); SelectedNetwork = network; lastPoi = PoI; if (Model == null || Model.DataServer == null) return; foreach (var service in Model.DataServer.Services.OfType<PoiService>().Where(s => s.IsSubscribed)) { service.Tapped += ServiceOnTapped; } var notificationEventArgs = new NotificationEventArgs { Id = Guid.NewGuid(), Background = Brushes.White, Foreground = Brushes.Black, Header = "Add a network", Text = "Press OK when done.", Duration = TimeSpan.FromDays(1), Options = new List<string> { "OK", "Cancel" } }; notificationEventArgs.OptionClicked += (sender, args) => { foreach (var service in Model.DataServer.Services.OfType<PoiService>()) { service.Tapped -= ServiceOnTapped; } switch (args.Option) { case "OK": break; case "Cancel": RemoveNetwork(selectedNetwork); break; } }; AppState.TriggerNotification(notificationEventArgs); }
/// <summary> /// IMB bus variable updated /// </summary> /// <param name="pImbVariableName"></param> /// <param name="pImbVariableContent"></param> private void ReceivedServiceNotificationOnImbBus(string pImbVariableName, string pImbVariableContent) { if (mLastProcessedImbVariables.ContainsKey(pImbVariableName)) if (mLastProcessedImbVariables[pImbVariableName] == pImbVariableContent) return; // IMB variable didn't change since mLastProcessedImbVariables[pImbVariableName] = pImbVariableContent; // IMB variable message structure: "Service:<message>" var v = pImbVariableContent.Split('|'); var sharedServiceGuid = Guid.Parse(pImbVariableName.Split(':')[1]); var shadowPoiService = (PoiService)Services.FirstOrDefault(k => k.Id == sharedServiceGuid); // Check if service is already known var isSharedServiceAlreadyKnown = (shadowPoiService != null); // Is the shared service already known bool isSharedServiceStoppedNotification = (v.Length == 1); // When there is no service name bool isSharedServiceNotification = (v.Length == 2); if (isSharedServiceNotification) { var imbHandleSharingService = int.Parse(v[0]); // The IMB handle of client sharing this service var sharedServiceName = v[1]; ImbClientStatus sharedServiceHosting = null; string hostingClient = "unknown"; // Is the user friendly name known for IMB id? if (AppState.Imb.Clients.TryGetValue(imbHandleSharingService, out sharedServiceHosting)) { hostingClient = sharedServiceHosting.Name; }; if (shadowPoiService == null) { LogCs.LogMessage( String.Format("Received notification on IMB bus of new shared service '{0}' (hosted by IMB client {1} ({2}))", sharedServiceName, imbHandleSharingService, hostingClient)); shadowPoiService = CreateShadowServiceForSharedService( sharedServiceName, sharedServiceGuid, imbHandleSharingService); } else { if (shadowPoiService.Name != sharedServiceName) { LogCs.LogMessage( String.Format("Received notification on IMB bus: shared service '{0}' is renamed to '{1}' ({2})", shadowPoiService.Name, sharedServiceName, sharedServiceGuid)); shadowPoiService.Name = sharedServiceName; // Update name NotifyOfPropertyChange(() => DynamicServices); } } Execute.OnUIThread(() => { // At startup, the active group may not be initialized if (AppState.Imb.ActiveGroup == null && AppState.Imb.Groups != null && AppState.Imb.Groups.Count > 0) { var group = AppState.Imb.Groups.FirstOrDefault(g => g.IsActive); if (group != null) { LogCs.LogMessage(String.Format("Auto join IMB group '{0}' (first group where this IMB client is member of) ", group.Name)); AppState.Imb.JoinGroup(group); } } // Is the shared service part of the active IMB group? if (AppState.Imb.ActiveGroup != null && AppState.Imb.ActiveGroup.Layers.Contains(sharedServiceGuid)) { if (isSharedServiceAlreadyKnown) { if (!shadowPoiService.IsLocal) return; LogCs.LogMessage(String.Format("The shared service '{0}' is shared in active IMB group '{1}': auto subscribe", shadowPoiService.Name, AppState.Imb.ActiveGroup.Name)); Subscribe(shadowPoiService); } else { shadowPoiService.Start(); LogCs.LogMessage(String.Format("The new created shared service '{0}' is shared in active IMB group '{1}': auto start service", shadowPoiService.Name, AppState.Imb.ActiveGroup.Name)); } AppState.TriggerNotification(sharedServiceName + " layer shared in " + AppState.Imb.ActiveGroup.Name, pathData: MenuHelpers.LayerIcon); } else { if (!mHandledServices.Contains(sharedServiceGuid)) { mHandledServices.Add(sharedServiceGuid); // Look like old code; The framework now tries to join the first group it sees. // Is some cases to group is found bool handled = false; if (OnNewSharedService != null) { var args = new JoinSharedServiceEventArgs(sharedServiceName, sharedServiceGuid, imbHandleSharingService); OnNewSharedService(this, args); // Join new shared service or not? if ((args.JoinSharedService.HasValue) && (args.JoinSharedService.Value)) { LogCs.LogMessage(String.Format("The eventhandler OnNewSharedService returned to join shared service '{0}'", shadowPoiService.Name)); JoinSharedService(isSharedServiceAlreadyKnown, shadowPoiService); mHandledServices.Remove(shadowPoiService.Id); } handled = args.JoinSharedService.HasValue; } if (!handled) { if (AppState.Config.GetBool("CsFramework.ShowJoinServiceNotification", true)) { LogCs.LogMessage(String.Format("Ask user with notification message to join shared service '{0}'", shadowPoiService.Name)); var nea = new NotificationEventArgs { Text = "Do you want to join?", Header = sharedServiceName + " now available", Duration = new TimeSpan(0, 0, 30), Background = AppState.AccentBrush, Image = new BitmapImage( new Uri( @"pack://application:,,,/csCommon;component/Resources/Icons/layers4.png")), Foreground = Brushes.White, Options = new List<string> { "Yes", "No" } }; nea.Closing += (services, e) => mHandledServices.Remove(sharedServiceGuid); nea.OptionClicked += (s, n) => { mHandledServices.Remove(shadowPoiService.Id); if (n.Option == "Yes") { LogCs.LogMessage(String.Format("User confirmed to join shared service '{0}'", shadowPoiService.Name)); JoinSharedService(isSharedServiceAlreadyKnown, shadowPoiService); } }; AppState.TriggerNotification(nea); } else { mHandledServices.Remove(shadowPoiService.Id); LogCs.LogMessage(String.Format("The config value 'CsFramework.ShowJoinServiceNotification' is false and event OnNewSharedService not set, no join dialog shown for shared service '{0}'", shadowPoiService.Name)); } } } } }); } else if (isSharedServiceStoppedNotification) { Execute.OnUIThread(() => { LogCs.LogMessage(String.Format("Received notification on IMB bus: shared service '{0}' is not avaliable anymore.", shadowPoiService.Name)); AppState.TriggerNotification("Layer '" + shadowPoiService.Name + "' is not available anymore"); DeleteService(shadowPoiService); }); } // else parse error! }
public void Export() { try { var ap = Appraisals.Where(a => a.IsSelected && File.Exists(a.FileName)).Select(a => a).ToList(); if (!ap.Any()) { AppStateSettings.Instance.TriggerNotification(string.Format("No appraisals created or selected", "export")); return; } var imagePaths = ap.Select(a => a.FileName).ToList(); var titles = ap.Select(a => a.Title).ToList(); var at = Path.ChangeExtension(Path.Combine(Path.GetDirectoryName(imagePaths[0]), "export - " + DateTime.Now.Ticks.ToString()), "pptx"); var pptFactory = new PowerPointFactory(at); pptFactory.CreateTitleAndImageSlides(imagePaths, titles); var ne = new NotificationEventArgs() { Header = "Export", Text = "Finished creating PowerPoint" }; ne.Foreground = Brushes.Black; ne.Background = Brushes.LightBlue; ne.Options = new List<string> { "Open" }; ne.OptionClicked += (f, b) => { Process.Start(at); }; AppStateSettings.Instance.TriggerNotification(ne); } catch (Exception) { AppStateSettings.Instance.TriggerNotification(string.Format("Error creating PowerPoint, check if folder exist", "export")); } }
public void Restore(Backup b) { var nea = new NotificationEventArgs { Text = "Are you sure?", Header = "Restoring this backup will discard all changes in current version", Duration = new TimeSpan(0, 0, 30), Background = Brushes.Red, PathData = MenuHelpers.BackupIcon, Foreground = Brushes.White, Options = new List<string> { "Yes", "No" } }; nea.OptionClicked += (s, n) => { if (n.Option != "Yes") return; Service.Layer.Stop(); File.Copy(b.FileName,Service.FileName,true); AppState.TriggerNotification("Backup was restored. You will need to start the layer manually"); }; AppState.TriggerNotification(nea); }
/// <summary> /// The create notifications. /// </summary> /// <param name="pHeader"> /// The p Header. /// </param> /// <param name="pMessage"> /// The p Message. /// </param> private void AddNotification(string pHeader, string pMessage) { this.HideNotification(); this.mNotification = new NotificationEventArgs { Duration = new TimeSpan(1, 0, 0, 0), Header = pHeader, Background = this.AppState.AccentBrush, Foreground = Brushes.White, Text = pMessage, Options = new List<string> { NotificationFinish, NotificationCancel } }; this.mNotification.OptionClicked += this.mIconModeNotification_OptionClicked; this.AppState.TriggerNotification(this.mNotification); }
/// <summary> /// The hide notification. /// </summary> private void HideNotification() { if (this.mNotification != null) { this.mNotification.OptionClicked -= this.mIconModeNotification_OptionClicked; this.AppState.TriggerDeleteNotification(this.mNotification); this.mNotification = null; } }
private void DeleteService() { var nea = new NotificationEventArgs { Text = "Are you sure?", Header = "Delete " + service.Name, Duration = new TimeSpan(0, 0, 45), Background = Brushes.Red, Image = new BitmapImage(new Uri(@"pack://application:,,,/csCommon;component/Resources/Icons/Delete.png")), Foreground = Brushes.White, Options = new List<string> { "Yes", "No" } }; nea.OptionClicked += (ts, n) => { if (n.Option != "Yes") return; if (service.IsSubscribed && service.Mode == Mode.server) service.MakeLocal(); if (IsStarted) Stop(); AppState.DataServer.DeleteService(service); plugin.UpdateLayerTabs(service, this); }; AppStateSettings.Instance.TriggerNotification(nea); }
private void UpdateMenu() { circularMenuItem.Items.Clear(); lineColor = ColorCircularMenuItem.CreateColorMenu("Line", 5); lineColor.Color = Colors.Black; circularMenuItem.Items.Add(lineColor); fillColor = ColorCircularMenuItem.CreateColorMenu("Fill", 6); fillColor.Color = Colors.Transparent; //circularMenuItem.Items.Add(fillColor); sketchMenuItem = new CircularMenuItem { Title = "Draw", Id = "Draw", CanCheck = true, Fill = Brushes.White, Icon = "pack://application:,,,/csCommon;component/Resources/Icons/freehand.png" }; Draw = new Draw(AppState.ViewDef.MapControl) { DrawMode = DrawMode.Freehand, LineSymbol = new SimpleLineSymbol {Color = Brushes.Black, Width = 3} }; Draw.DrawBegin += MyDrawObject_DrawBegin; Draw.DrawComplete += MyDrawObjectDrawComplete; sketchMenuItem.Selected += (s, f) => { selectedPoiType = new PoI { Service = SketchService, DrawingMode = DrawingModes.Polyline, StrokeColor = lineColor.Color, FillColor = Colors.Transparent, StrokeWidth = 3, }; Draw.LineSymbol = new SimpleLineSymbol {Color = new SolidColorBrush(lineColor.Color), Width = 3}; //sketchMenuItem.Fill = AppState.AccentBrush; Draw.IsEnabled = true; drawingNotification = new NotificationEventArgs { Id = Guid.NewGuid(), Style = NotificationStyle.Popup, Duration = TimeSpan.FromHours(1), Header = "Drawing activated", Foreground = Brushes.White, Background = AppState.AccentBrush, Image = new BitmapImage(new Uri("pack://application:,,,/csCommon;component/Resources/Icons/Pen.png")) }; AppState.TriggerNotification(drawingNotification); }; var clear = new CircularMenuItem { Title = "Clear", Id = "Clear", CanCheck = true, Position = 3, Icon = "pack://application:,,,/csCommon;component/Resources/Icons/appbar.delete.png" }; clear.Selected += (s, f) => { while (SketchService.PoIs.Any()) SketchService.PoIs.RemoveAt(0); }; circularMenuItem.Items.Add(sketchMenuItem); circularMenuItem.Items.Add(clear); }
void CommandChannelOnNormalEvent(TEventEntry aEvent, IMB3.ByteBuffers.TByteBuffer aPayload) { var l = aPayload.ReadString(); var ss = l.Split('|'); switch (ss[0]) { case "point": Execute.OnUIThread(() => { var xp = Convert.ToDouble(ss[1], CultureInfo.InvariantCulture); var yp = Convert.ToDouble(ss[2], CultureInfo.InvariantCulture); var c = AppState.Imb.FindClient(long.Parse(ss[3])); if (c != null) { var nea = new NotificationEventArgs() { Duration = TimeSpan.FromSeconds(5), Options = new List<string> { "Zoom to" }, PathData = MenuHelpers.PointerIcon, Header = "Pointer triggered by " + c.Name, Background = AppState.AccentBrush, Foreground = System.Windows.Media.Brushes.Black, }; nea.OptionClicked += (e, f) => AppState.ViewDef.ZoomAndPoint(new Point(yp, xp), false); AppState.TriggerNotification(nea); } AppState.ViewDef.AddGeoPointer(new GeoPointerArgs() { Position = new MapPoint(yp, xp), Duration = TimeSpan.FromSeconds(2) }); }); break; case "map": if (!string.Equals(l, lastMapEvent) && FollowMap) { lastMapEvent = l; var x = Convert.ToDouble(ss[1], CultureInfo.InvariantCulture); var y = Convert.ToDouble(ss[2], CultureInfo.InvariantCulture); var r = Convert.ToDouble(ss[3], CultureInfo.InvariantCulture); Execute.OnUIThread(delegate { var w = (AppState.ViewDef.MapControl.ActualWidth / 2) * r; var h = (AppState.ViewDef.MapControl.ActualHeight / 2) * r; var env = new Envelope(x - w, y - h, x + w, y + h); AppState.ViewDef.MapControl.Extent = env; }); skipNext = true; } break; } }
private void UpdateCalloutActions() { var effStyle = Poi.NEffectiveStyle; if (effStyle.CanEdit.Value) { var editCallout = new CallOutAction { IconBrush = new SolidColorBrush(effStyle.CallOutForeground.Value), Title = "Edit", Path = "M0,44.439791L18.98951,54.569246 0.47998798,62.66881z M17.428029,12.359973L36.955557,23.568769 21.957478,49.686174 20.847757,46.346189 15.11851,45.756407 14.138656,42.166935 8.5292659,41.966761 6.9493899,38.037481 2.4399572,38.477377z M26.812517,0.0009765625C27.350616,-0.012230873,27.875986,0.10826397,28.348372,0.3782568L42.175028,8.3180408C43.85462,9.2780154,44.234529,11.777948,43.02482,13.89789L41.375219,16.767812 21.460039,5.3381228 23.10964,2.4582005C23.979116,0.941679,25.437378,0.034730911,26.812517,0.0009765625z" }; editCallout.Clicked += (e, f) => callOut.StartEditing(); callOut.Actions.Add(editCallout); } // Lock the PoI var canMoveCallout = new CallOutAction { IconBrush = new SolidColorBrush(effStyle.CallOutForeground.Value), Title = "Lock", Path = effStyle.CanMove.Value ? "F1M648.2778,1043.3809L648.2778,1047.4329 645.6158,1047.4329 645.6158,1043.3839C644.5488,1042.9079 643.7998,1041.9019 643.7998,1040.7169 643.7998,1039.0759 645.2068,1037.7479 646.9428,1037.7479 648.6858,1037.7479 650.0938,1039.0759 650.0938,1040.7169 650.0938,1041.8989 649.3458,1042.9079 648.2778,1043.3809 M654.3988,1031.2069C654.3988,1031.2009,654.3998,1031.1959,654.4008,1031.1899L651.2988,1031.1529 641.3268,1031.1529 640.3338,1028.5859C639.1988,1025.6569 640.6488,1022.3669 643.5788,1021.2339 646.5088,1020.0989 649.7988,1021.5549 650.9328,1024.4789L652.0168,1027.2809C652.2178,1027.8009,652.3348,1028.3359,652.3778,1028.8669L654.4728,1028.8909C654.3998,1028.2769,654.2548,1027.6609,654.0208,1027.0559L652.5638,1023.2979C651.0408,1019.3659 646.6198,1017.4139 642.6888,1018.9379 638.7598,1020.4589 636.8068,1024.8789 638.3278,1028.8109L639.3428,1031.4309C637.3868,1032.1059,635.9778,1033.9609,635.9778,1036.1469L635.9778,1046.2999C635.9778,1049.0579,638.2148,1051.2949,640.9708,1051.2949L653.7078,1051.2949C656.4668,1051.2949,658.7008,1049.0579,658.7008,1046.2999L658.7008,1036.1469C658.7008,1033.6249,656.8298,1031.5439,654.3988,1031.2069" : "F1M339.3071,1185.249L339.3071,1188.437 337.2111,1188.437 337.2111,1185.251C336.3721,1184.876 335.7831,1184.085 335.7831,1183.151 335.7831,1181.861 336.8901,1180.815 338.2561,1180.815 339.6281,1180.815 340.7371,1181.861 340.7371,1183.151 340.7371,1184.082 340.1471,1184.876 339.3071,1185.249 M331.6851,1168.456C331.6851,1165.017 334.4711,1162.228 337.9101,1162.228 341.3491,1162.228 344.1411,1165.017 344.1411,1168.456L344.1411,1171.745C344.1411,1172.16,344.0991,1172.565,344.0211,1172.959L331.8051,1172.959C331.7281,1172.565,331.6851,1172.16,331.6851,1171.745z M346.2351,1173.133C346.2611,1172.861,346.2761,1172.586,346.2761,1172.308L346.2761,1167.893C346.2761,1163.274 342.5291,1159.528 337.9101,1159.528 333.2921,1159.528 329.5511,1163.274 329.5511,1167.893L329.5511,1172.308C329.5511,1172.586 329.5661,1172.861 329.5921,1173.132 327.2211,1173.733 325.4651,1175.875 325.4651,1178.432L325.4651,1189.558C325.4651,1192.578,327.9121,1195.028,330.9361,1195.028L344.8901,1195.028C347.9091,1195.028,350.3601,1192.578,350.3601,1189.558L350.3601,1178.432C350.3601,1175.876,348.6031,1173.733,346.2351,1173.133" }; canMoveCallout.Clicked += (e, f) => { if (Poi.Style == null) { Poi.Style = new PoIStyle { CanMove = !effStyle.CanMove }; } else Poi.Style.CanMove = !effStyle.CanMove; if (Poi.Style.CanMove == true && (effStyle.DrawingMode == DrawingModes.Polygon || effStyle.DrawingMode == DrawingModes.Polyline)) (Poi.Data["graphic"] as Graphic).MakeDraggable(); Poi.TriggerLabelChanged("", "", ""); Poi.UpdateEffectiveStyle(); callOut.Close(); }; callOut.Actions.Add(canMoveCallout); if (effStyle.CanRotate.Value && (Poi.NEffectiveStyle.DrawingMode.Value == DrawingModes.Point || Poi.NEffectiveStyle.DrawingMode.Value == DrawingModes.Image)) { var rotateCallOutAction = new CallOutAction { IconBrush = new SolidColorBrush(Poi.NEffectiveStyle.CallOutForeground.Value), Title = "Rotate", Path = "F1M225.713,1773.49L232.795,1776.66 231.995,1768.94 231.192,1761.23 226.002,1764.99C221.113,1758.99 213.677,1755.15 205.337,1755.15 190.61,1755.15 178.672,1767.1 178.672,1781.82 178.672,1796.55 190.61,1808.49 205.337,1808.49 211.902,1808.49 217.903,1806.11 222.543,1802.17 222.573,1802.11 222.593,1802.06 222.627,1801.99 224.257,1798.82 220.791,1798.99 220.781,1798.99 216.686,1802.68 211.271,1804.93 205.337,1804.93 192.595,1804.93 182.228,1794.56 182.228,1781.82 182.228,1769.08 192.595,1758.71 205.337,1758.71 212.481,1758.71 218.867,1761.98 223.106,1767.09L218.631,1770.33 225.713,1773.49z" }; rotateCallOutAction.Clicked += (e, f) => { callOut.Close(); Poi.StartRotation(); }; callOut.Actions.Add(rotateCallOutAction); } if (effStyle.CanDelete.Value) { var deleteCalloutAction = new CallOutAction { IconBrush = new SolidColorBrush(Poi.NEffectiveStyle.CallOutForeground.Value), Title = "Delete", Path = "M33.977998,27.684L33.977998,58.102997 41.373998,58.102997 41.373998,27.684z M14.841999,27.684L14.841999,58.102997 22.237998,58.102997 22.237998,27.684z M4.0319996,22.433001L52.183,22.433001 52.183,63.999001 4.0319996,63.999001z M15.974,0L40.195001,0 40.195001,7.7260003 56.167001,7.7260003 56.167001,16.000999 0,16.000999 0,7.7260003 15.974,7.7260003z" }; deleteCalloutAction.Clicked += (e, f) => { callOut.Close(); var nea = new NotificationEventArgs { Text = "Are you sure?", Header = "Delete " + Poi.Name, Duration = new TimeSpan(0, 0, 30), Background = Brushes.Red, Image = new BitmapImage(new Uri(@"pack://application:,,,/csCommon;component/Resources/Icons/Delete.png")), Foreground = Brushes.White, Options = new List<string> { "Yes", "No" } }; nea.OptionClicked += (s, n) => { if (n.Option != "Yes") return; //AppState.TriggerNotification(Poi.Name + " was deleted", pathData: MenuHelpers.DeleteIcon); Service.RemovePoi(Poi as PoI); AppState.Popups.Remove(callOut); }; AppState.TriggerNotification(nea); }; callOut.Actions.Add(deleteCalloutAction); } foreach (var action in Poi.CalloutActions) { callOut.Actions.Add(action); } }
public void RemoveVisitedLocation(VisitedLocation visitedLocation) { var notificationEventArgs = new NotificationEventArgs { Id = Guid.NewGuid(), Background = Brushes.Red, Foreground = Brushes.Black, Header = "Delete location?", Text = string.Format("Do you want to delete {0}?", visitedLocation.Title), Duration = TimeSpan.FromDays(1), Options = new List<string> { "YES", "NO" } }; notificationEventArgs.OptionClicked += (sender, args) => { switch (args.Option) { case "NO": return; case "YES": VisitedLocations.Remove(visitedLocation); SaveVisitedLocationsLabel(); UpdateVisitedPath(); break; } }; AppState.TriggerNotification(notificationEventArgs); }
void AppStateNewNotification(NotificationEventArgs e) { Notification = e; e.OnStarting(); if (e.AutoClickInSeconds > 0) { e.Duration = TimeSpan.FromSeconds(e.AutoClickInSeconds + 1); var _timer = new DispatcherTimer(TimeSpan.FromSeconds(1), DispatcherPriority.Normal, (sender, args) => { e.AutoClickInSeconds--; e.AutoClickUpdate(); if (e.AutoClickInSeconds > 0) return; var timer = sender as DispatcherTimer; timer.Stop(); if (e.AutoClickInSeconds > int.MinValue) e.TriggerOptionClicked(e.AutoClickText, false); }, Application.Current.Dispatcher); _timer.Start(); } switch (e.Style) { case NotificationStyle.Popup: AddPopup(e); break; case NotificationStyle.FreeText: Execute.OnUIThread(() => { var tb = new TextBlock { Tag = e.Id, Text = e.Text, HorizontalAlignment = e.HorizontalAlignment, VerticalAlignment = e.VerticalAlignment, Background = e.Background, Foreground = e.Foreground, FontSize = e.FontSize, Padding = e.Padding, Margin = e.Margin, FontFamily = e.FontFamily, TextAlignment = e.TextAlignment }; tb.MouseDown += (es, s) => e.TriggerClick(); tb.TextWrapping = TextWrapping.Wrap; if (e.Size != null) { tb.Width = e.Size.Width; tb.Height = e.Size.Height; } _view.bFreeText.Children.Add(tb); var dt = new DispatcherTimer {Interval = e.Duration}; dt.Tick += (es, s) => { if (_view.bFreeText.Children.Contains(tb)) { _view.bFreeText.Children.Remove(tb); } dt.Stop(); dt = null; }; dt.Start(); }); break; } }
private void CreateInitialPath() { removeLastPoint = false; editRouteNotification = new NotificationEventArgs { Id = Guid.NewGuid(), Background = AppState.AccentBrush, Foreground = Brushes.White, Header = "Edit route", Text = "Click the route, including way points.", Duration = TimeSpan.FromDays(1), Options = new List<string> { "DONE" } }; editRouteNotification.OptionClicked += (sender, args) => { removeLastPoint = !args.UsesTouch; // Only remove the last point when the mouse was used. draw.CompleteDraw(); }; AppState.TriggerNotification(editRouteNotification); draw = new Draw(AppState.ViewDef.MapControl) { DrawMode = DrawMode.Polyline, LineSymbol = new LineSymbol { Width = Poi.NEffectiveStyle.StrokeWidth.HasValue ? Poi.NEffectiveStyle.StrokeWidth.Value : 2, Color = new SolidColorBrush(Poi.NEffectiveStyle.StrokeColor.HasValue ? Poi.NEffectiveStyle.StrokeColor.Value : Colors.Black) }, IsEnabled = true, }; // Add the first point (drop point) draw.AddVertex(webMercator.FromGeographic(new MapPoint(Poi.Position.Longitude, Poi.Position.Latitude)) as MapPoint); draw.DrawComplete += OnDrawingCompleted; }
/// <summary> /// Add a notification popup (title, text and options) /// </summary> /// <param name="e"></param> private void AddPopup(NotificationEventArgs e) { Notifications.Add(e); //if (e.SoundUri!=null) PlaySound(e.SoundUri); if (e.Duration.Ticks <= 0) return; e.Timer = new DispatcherTimer(); if (e.Image == null) { e.Image = new BitmapImage(new Uri("pack://application:,,,/csCommon;component/Resources/Icons/Message.png")); } e.Timer.Interval = e.Duration; e.Timer.Tick += (s, ea) => Remove(e); e.Timer.Start(); if (!e.Options.Any()) return; e.WorkingOptions = new BindableCollection<NotificationOption>(); foreach (var a in e.Options) e.WorkingOptions.Add(new NotificationOption { Notification = e, Option = a }); }
private void ShowRouteInformation(int distanceInMeters, TimeSpan travelTime) { AppState.TriggerDeleteNotification(notification); var mode = string.Empty; switch (selectedPathType) { case PathType.GoogleDrivingDirections: mode = "driving"; break; case PathType.GoogleWalkingDirections: mode = "walking"; break; } var distance = Distance(distanceInMeters); notification = new NotificationEventArgs { Id = Guid.NewGuid(), Background = AppState.AccentBrush, Foreground = Brushes.White, Header = "Route info", Text = string.Format("The {0} distance is {1} and takes {2}.", mode, distance, travelTime.Humanize(2)), Duration = TimeSpan.FromDays(1), }; AppState.TriggerNotification(notification); }
public void NotificationClick(NotificationEventArgs s) { Remove(s); }
private void AddWayPoint(Point tapPoint) { lastTapPoint = tapPoint; if (addingWayPoint) return; addingWayPoint = true; var notificationEventArgs = new NotificationEventArgs { Id = Guid.NewGuid(), Background = AppState.AccentBrush, Foreground = Brushes.White, Header = "Add way point", Text = "At the current location?", Duration = TimeSpan.FromSeconds(5), Options = new List<string> { "YES", "NO" } }; notificationEventArgs.Closing += (sender, args) => addingWayPoint = false; notificationEventArgs.OptionClicked += (sender, args) => { addingWayPoint = false; switch (args.Option) { case "NO": return; case "YES": CreatePoiAndSubscribeToPositionChanged(lastTapPoint, TrackPoiType.WayPoint); return; } }; AppState.TriggerNotification(notificationEventArgs); }
public void AutoClick(NotificationEventArgs o, object eventArgs) { if (o == null) return; var usesTouch = false; var touchEvent = eventArgs as TouchEventArgs; if (touchEvent != null) { usesTouch = true; touchEvent.Handled = true; } else { var routedEvent = eventArgs as RoutedEventArgs; if (routedEvent != null) routedEvent.Handled = true; } o.TriggerOptionClicked(o.AutoClickText, usesTouch); Remove(o); }
public void ServiceMenu(ActionExecutionContext context) { var sb = context.Source as SurfaceButton; if (sb == null) return; var a = sb.DataContext as PoiService; if (a == null) return; var menu = new MenuPopupViewModel { RelativeElement = sb, RelativePosition = new Point(-35, -5), TimeOut = new TimeSpan(0, 0, 0, 5), VerticalAlignment = VerticalAlignment.Bottom, DisplayProperty = "", AutoClose = true }; //menu.Point = _view.CreateLayer.TranslatePoint(new Point(0,0),Application.Current.MainWindow); if (a.IsSubscribed) menu.Objects.Add((a.IsLocal && a.Mode == Mode.client) ? "Share online" : "Make local"); if (a.IsLocal && a.IsSubscribed && a.Settings != null && a.Settings.CanEdit) { menu.Objects.Add("Rename"); } menu.Objects.Add("Delete"); //menu.Objects.Add("Duplicate"); menu.Selected += (e, s) => { switch (s.Object.ToString()) { case "Make local": a.MakeLocal(); break; case "Share online": a.MakeOnline(); break; case "Remove": //Plugin.Functions.Remove(a); break; case "Duplicate": //Plugin.Functions.Add(a.Clone()); break; case "Delete": var nea = new NotificationEventArgs() { Text = "Are you sure?", Header = "Delete " + a.Name }; nea.Duration = new TimeSpan(0, 0, 45); nea.Background = Brushes.Red; nea.Image = new BitmapImage(new Uri(@"pack://application:,,,/csCommon;component/Resources/Icons/Delete.png")); nea.Foreground = Brushes.White; nea.Options = new List<string>() { "Yes", "No" }; nea.OptionClicked += (ts, n) => { if (n.Option == "Yes") { if (a.IsSubscribed && a.Mode == Mode.server) a.MakeLocal(); Plugin.Dsb.DeleteService(a); } }; AppStateSettings.Instance.TriggerNotification(nea); break; case "Rename": var input = new InputPopupViewModel { RelativeElement = sb, RelativePosition = new Point(-20, -15), TimeOut = new TimeSpan(0, 0, 2, 5), VerticalAlignment = VerticalAlignment.Bottom, Title = "Function Name", Width = 250.0, DefaultValue = a.Name }; input.Saved += (st, ea) => { var oldName = a.FileName; var old = a.Name; a.Name = ea.Result; if (oldName == a.FileName) return; if (File.Exists(oldName) && (!File.Exists(a.FileName))) { if (a.SaveXml()) { File.Delete(oldName); AppStateSettings.Instance.RenameStartPanelTabItem(old, a.Name); } else a.Name = old; } else a.Name = old; }; AppStateSettings.Instance.Popups.Add(input); break; } }; AppStateSettings.Instance.Popups.Add(menu); }