public void AppraisalMenu(ActionExecutionContext context) { var sb = context.Source as SurfaceButton; if (sb == null) return; var appraisal = sb.DataContext as Appraisal; if (appraisal == null) return; var menu = new MenuPopupViewModel { RelativeElement = sb, RelativePosition = new Point(-35, -5), TimeOut = new TimeSpan(0, 0, 0, 5), VerticalAlignment = VerticalAlignment.Bottom, DisplayProperty = "" }; //menu.Point = _view.CreateLayer.TranslatePoint(new Point(0,0),Application.Current.MainWindow); menu.Objects.Add((appraisal.IsCompare) ? "Stop Compare" : "Compare"); menu.Objects.Add("Remove"); menu.Objects.Add("Duplicate"); menu.Objects.Add("Rename"); menu.Objects.Add("Select Color"); menu.Selected += (e, s) => { switch (s.Object.ToString()) { case "Stop Compare": appraisal.IsCompare = false; Plugin.TriggerAppraisalsUpdated(); break; case "Compare": appraisal.IsCompare = true; Plugin.TriggerAppraisalsUpdated(); break; case "Remove": Plugin.Appraisals.Remove(appraisal); if (Plugin.SelectedAppraisals.Contains(appraisal)) Plugin.SelectedAppraisals.Remove(appraisal); break; case "Duplicate": Plugin.Appraisals.Add(appraisal.Clone() as Appraisal); break; case "Select Color": var cinput = new ColorInputPopupViewModel { RelativeElement = sb, RelativePosition = new Point(-20, -15), TimeOut = new TimeSpan(0, 0, 2, 5), VerticalAlignment = VerticalAlignment.Bottom, Title = "Appraisal Title", Width = 250.0, DefaultValueB = appraisal.Color.B.ToString(), DefaultValueR = appraisal.Color.R.ToString(), DefaultValueG = appraisal.Color.G.ToString() }; cinput.Saved += (st, ea) => { appraisal.Color = ea.Result.Color; Plugin.TriggerAppraisalsUpdated(); //appraisal.Title = ea.Result; // TODO Should we change the filename too (so the copied screenshot filenames make sense to humans) }; AppStateSettings.Instance.Popups.Add(cinput); 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 = "Appraisal Title", Width = 250.0, DefaultValue = appraisal.Title }; input.Saved += (st, ea) => { appraisal.Title = ea.Result; // TODO Should we change the filename too (so the copied screenshot filenames make sense to humans) }; AppStateSettings.Instance.Popups.Add(input); break; } }; AppStateSettings.Instance.Popups.Add(menu); }
public void RenameService(FrameworkElement sb) { var input = new InputPopupViewModel { RelativePosition = sb.PointToScreen(new Point(0, 0)), TimeOut = new TimeSpan(0, 0, 2, 5), VerticalAlignment = VerticalAlignment.Bottom, Title = "Service Name", Width = 250.0, DefaultValue = service.Name }; input.Saved += (st, ea) => { var oldName = service.FileName; var old = service.Name; service.Name = ea.Result; if (oldName == service.FileName) return; if (File.Exists(oldName) && (!File.Exists(service.FileName))) { if (service.SaveXml()) { File.Delete(oldName); AppStateSettings.Instance.RenameStartPanelTabItem(old, service.Name); } else service.Name = old; } else service.Name = old; plugin.UpdateLayerTabs(service, this); }; AppStateSettings.Instance.Popups.Add(input); }
private void CreateCustomStepMenu(MenuItemEventArgs fe, bool error = false) { var inp = new InputPopupViewModel { Title = error ? "Supply correct format: dd:hh:mm:ss" : "Interval: dd:hh:mm:ss", RelativeElement = fe.Menu.Main, RelativePosition = new Point(10, 10), DefaultValue = DefaultCustomStep.ToString() }; inp.Saved += (o, r) => { var stepMenu = GetMenuItemById("Step"); var custom = stepMenu.Items.FirstOrDefault(k => k.Id == "Size_Custom"); if (custom == null) return; try { var timespan = TimeSpan.Parse(r.Result); PlayStepSize = timespan; custom.Title = "Custom: " + timespan; SetStepSize("Size_Custom"); fe.Menu.Update(); } catch (Exception) { CreateCustomStepMenu(fe, true); } }; AppStateSettings.Popups.Add(inp); }
public void AppraisalMenu(ActionExecutionContext context) { var sb = context.Source as SurfaceButton; if (sb == null) return; var a = sb.DataContext as Function; 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); menu.Objects.Add((a.IsDefault) ? "Remove default" : "Make default"); menu.Objects.Add("Remove"); menu.Objects.Add("Duplicate"); menu.Objects.Add("Rename"); menu.Selected += (e, s) => { switch (s.Object.ToString()) { case "Remove default": a.IsDefault = false; break; case "Make default": a.IsDefault = true; break; case "Remove": Plugin.Functions.Remove(a); break; case "Duplicate": Plugin.Functions.Add(a.Clone()); 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) => { a.Name = ea.Result; }; AppStateSettings.Instance.Popups.Add(input); break; } }; AppStateSettings.Instance.Popups.Add(menu); }
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); }