Наследование: Caliburn.Micro.Screen, IPopupScreen
        public void SecondScreenMenuOptions(FrameworkElement pSource)
        {
            try
            {



                var menu = new MenuPopupViewModel
                {
                    RelativeElement = pSource,
                    RelativePosition = new System.Windows.Point(35, -5),
                    TimeOut = new System.TimeSpan(0, 0, 0, 5),
                    VerticalAlignment = System.Windows.VerticalAlignment.Bottom,
                    DisplayProperty = string.Empty,
                    AutoClose = true
                };
                var menuItemString = AppStateSettings.Instance.Config.Get("SecondScreens", "");
                if (String.IsNullOrEmpty(menuItemString))
                {
                    (Owner as CsVideoStreamViewModel).AvaliableVideoStreamsVM.OpenInSecondScreen(this, 1);
                }
                else
                {
                    var items = menuItemString.Split('|');
                    if (items.Count() > 1) // Show popup menu so user can select an second screen
                    {
                        foreach (var menuItem in items.Select(x => new SecondScreenMenuItem(x)))
                        {
                            menu.Objects.Add(menuItem);
                        }

                        menu.Selected += (o, args) =>
                        {
                            if (Owner is CsVideoStreamViewModel)
                                (Owner as CsVideoStreamViewModel).AvaliableVideoStreamsVM.OpenInSecondScreen(this,
                                    (args.Object as SecondScreenMenuItem).SecondScreenId);
                        };
                        AppStateSettings.Instance.Popups.Add(menu);
                        // Memory leak?! Should dispose popup menu?
                    }
                    else
                    {
                        if (items.Count() == 1)
                        {
                            var menuitem = new SecondScreenMenuItem(items[0]);
                            if (Owner is CsVideoStreamViewModel)
                                (Owner as CsVideoStreamViewModel).AvaliableVideoStreamsVM.OpenInSecondScreen(this,
                                    menuitem.SecondScreenId);
                        }
                    }
                }
            }
            catch (Exception)
            {


            }
        }
Пример #2
0
 private MenuPopupViewModel GetMenu(FrameworkElement fe)
 {
     var menu = new MenuPopupViewModel
     {
         RelativeElement = fe,
         RelativePosition = new Point(35, -5),
         TimeOut = new TimeSpan(0, 0, 0, 15),
         VerticalAlignment = VerticalAlignment.Top,
         DisplayProperty = string.Empty,
         AutoClose = true
     };
     return menu;
 }
Пример #3
0
        public void ItemMenu(ActionExecutionContext context)
        {
            var sb = context.Source as SurfaceButton;
            if (sb == null) return;
            var a = sb.DataContext as NotebookItem;
            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 = string.Empty,
                AutoClose = true
            };
            //menu.Point = _view.CreateLayer.TranslatePoint(new Point(0,0),Application.Current.MainWindow);

            menu.Objects.Add("Remove");

            menu.Selected += (e, s) =>
            {
                switch (s.Object.ToString())
                {
                    case "Remove":
                        try
                        {
                            if (ActiveNotebook.Items.Contains(a)) ActiveNotebook.Items.Remove(a);
                            if (File.Exists(a.FileName))
                            {
                                File.Delete(a.FileName);
                                //ThreadPool.QueueUserWorkItem(delegate {
                                //    Thread.Sleep(1000); File.Delete(a.FileName);                                    
                                //});
                            }
                        }
                        catch (Exception ex)
                        {
                            // Added ex.Message to logger.
                            Logger.Log("Notes", "Try to delete it next time (after restarting).", "Error deleting notebook item from disk!\n" + ex.Message, Logger.Level.Error, true);
                        }

                        NotifyOfPropertyChange(() => CanCreatePowerPoint);
                        break;
                }
            };

            AppStateSettings.Instance.Popups.Add(menu);
        }
Пример #4
0
        public void GroupMenu(FrameworkElement element) {
            if (!CanDeleteGroup) return;
            var menu = new MenuPopupViewModel
            {
                RelativeElement   = element,
                RelativePosition  = new Point(25, 0),
                TimeOut           = new TimeSpan(0, 0, 0, 5),
                VerticalAlignment = VerticalAlignment.Top,
                DisplayProperty   = string.Empty
            };
            var miDelete = MenuHelpers.CreateMenuItem("Delete Group", MenuHelpers.DeleteIcon);
            miDelete.Click += (e, f) => AppState.Imb.DeleteGroup(Group);
            menu.Items.Add(miDelete);
            //menu.Items.AddRange(GetMenuItems(layer));

            if (menu.Items.Any()) AppState.Popups.Add(menu);
        }
Пример #5
0
        private MenuPopupViewModel GetMenu(FrameworkElement fe)
        {
            var menu = new MenuPopupViewModel
            {
                RelativeElement   = fe,
                RelativePosition  = new Point(35, -5),
                TimeOut           = new TimeSpan(0, 0, 0, 15),
                VerticalAlignment = VerticalAlignment.Top,
                DisplayProperty   = string.Empty,
                AutoClose         = true
            };

            menu.AddMenuItem("<none>");
            foreach (var wtl in AppState.ViewDef.BaseLayerProviders)
            {
                menu.AddMenuItem(wtl.Title);
            }

            return menu;
        }
        public void CreateLayer(object sender, RoutedEventArgs e) {
            var sb = sender as SurfaceToggleButton;
            if (sb == null) return;

            var menu = new MenuPopupViewModel
            {
                RelativeElement = sb,
                RelativePosition = new Point(35, -5),
                TimeOut = new TimeSpan(0, 0, 0, 5),
                VerticalAlignment = VerticalAlignment.Bottom,
                DisplayProperty = string.Empty,
                AutoClose = true
            };
            menu.Objects.Add(CreateNewLayerString);
            foreach (var service in Plugin.Dsb.Templates)
                menu.Objects.Add(string.Format("* {0}", service.Name));
            menu.Selected += (o, args) => CreateNewService(args);
            AppStateSettings.Instance.Popups.Add(menu);
        }
Пример #7
0
        private void _partStream_Click(object sender, RoutedEventArgs e) {
            var menu = new MenuPopupViewModel {
                RelativeElement = _partStream,
                RelativePosition = new Point(0, 0),
                TimeOut = new TimeSpan(0, 0, 0, 5),
                VerticalAlignment = VerticalAlignment.Top,
                AutoClose = true
            };
            //menu.Point = _view.CreateLayer.TranslatePoint(new Point(0,0),Application.Current.MainWindow);
            //menu.DisplayProperty = "ServiceName";
            menu.Selected += MenuSelected;
            foreach (var ep in endPoints) {
                var mi = menu.AddMenuItem(ep.Title);
                mi.Tag = ep;
            }
            //foreach (ImbClientStatus a in AppStateSettings.Instance.Imb.Clients.Values.Where(k => k.Client))
            //{
            //  System.Windows.Controls.MenuItem mi = menu.AddMenuItem(a.Name);
            //  mi.Tag = a;
            //}
            //var config = menu.AddMenuItem("Configuration");

            AppStateSettings.Instance.Popups.Add(menu);
        }
Пример #8
0
        public void OpenFunctionOperationMenu(DataSet ds, SurfaceButton b)
        {
            var menu = new MenuPopupViewModel();
            menu.RelativeElement = b;
            menu.RelativePosition = new Point(0, 0);
            menu.TimeOut = new TimeSpan(0, 0, 0, 5);
            //menu.Point = _view.CreateLayer.TranslatePoint(new Point(0,0),Application.Current.MainWindow);
            menu.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            //menu.DisplayProperty = "ServiceName";
            menu.AutoClose = true;

            foreach (var a in Enum.GetValues(typeof(FunctionOperations)))
            {
                var mi = menu.AddMenuItem(a.ToString());
                mi.Click += (e, s) =>
                {
                    SelectedDataSet.FunctionOperation = (FunctionOperations)a;
                    UpdateDataSet(SelectedDataSet);
                    menu.Close();
                };
            }
            AppState.Popups.Add(menu);
        }
Пример #9
0
 private MenuPopupViewModel GetMenu(FrameworkElement fe)
 {
     var menu = new MenuPopupViewModel();
     menu.RelativeElement = fe;
     menu.RelativePosition = new Point(0, 0);
     menu.TimeOut = new TimeSpan(0, 0, 0, 5);
     //menu.Point = _view.CreateLayer.TranslatePoint(new Point(0,0),Application.Current.MainWindow);
     menu.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
     //menu.DisplayProperty = "ServiceName";
     menu.AutoClose = true;
     return menu;
 }
Пример #10
0
        public void OpenDataSetMenu(DataSet ds, SurfaceButton b)
        {
            var menu = new MenuPopupViewModel();
            menu.RelativeElement = b;
            menu.RelativePosition = new Point(0, 0);
            menu.TimeOut = new TimeSpan(0, 0, 0, 5);
            //menu.Point = _view.CreateLayer.TranslatePoint(new Point(0,0),Application.Current.MainWindow);
            menu.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            //menu.DisplayProperty = "ServiceName";
            menu.AutoClose = true;
            var miRemove = menu.AddMenuItem("Remove");
            miRemove.Click += (e, s) =>
                {
                    DataSets.Remove(ds);
                    menu.Close();
                };

            var miFit = menu.AddMenuItem("Fit");
            miFit.Click += (e, s) =>
            {
                FitDataSet(ds);
                menu.Close();
            };

            var miDuplicate = menu.AddMenuItem("Duplicate");
            miDuplicate.Click += (e, s) =>
                {
                    DataSet d = ds.Clone() as DataSet;
                    DataSets.Add(d);
                    menu.Close();
                };

            var miEdit = menu.AddMenuItem("Edit");
            miEdit.Click += (e, s) =>
                {
                    SelectedDataSet = ds;
                    menu.Close();
                    EditDataSet = true;
                };


            var miDraw = menu.AddMenuItem("Draw");
            miDraw.Click += (e, s) =>
            {
                SelectedDataSet = ds;
                menu.Close();
                if (DrawDataSet == false)
                {
                    DrawDataSet = true;
                    // Subscribe to the mouse down event on the line series
                    _view.PreviewMouseLeftButtonDown += _view_PreviewMouseLeftButtonDown;
                    _view.PreviewMouseMove += _view_PreviewMouseMove;
                    _view.PreviewMouseLeftButtonUp += _view_PreviewMouseLeftButtonUp;
                    

                }
                else
                {
                    DrawDataSet = false;
                }
            };
            AppState.Popups.Add(menu);
        }
Пример #11
0
        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);
        }
Пример #12
0
        private void BFocusTimeMouseUp(object sender, MouseButtonEventArgs e)
        {
            isMouseDownBm = false;
            isMouseDown = false;
            e.MouseDevice.Capture(null);
            e.Handled = true;

            if (bFocusMouseStart.AddMilliseconds(200) > AppState.TimelineManager.CurrentTime)
            {
                var menu = new MenuPopupViewModel
                {
                    RelativeElement = bFocusTime,
                    RelativePosition = new Point(-50, -15),
                    TimeOut = new TimeSpan(0, 0, 0, 5),
                    VerticalAlignment = VerticalAlignment.Bottom,
                };
                //menu.Point = _view.CreateLayer.TranslatePoint(new Point(0,0),Application.Current.MainWindow);

                menu.AddMenuItem("Go to now").Click += (s, es) =>
                {
                    Timeline.Start = AppState.TimelineManager.CurrentTime.AddDays(-1);
                    Timeline.End = AppState.TimelineManager.CurrentTime.AddDays(1);
                    Timeline.ForceTimeChanged();
                    Timeline.SetFocusTime(AppState.TimelineManager.CurrentTime);
                    Timeline.ForceTimeChanged();
                };

                AppState.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);
        }
Пример #14
0
        private void SelectColor()
        {
            var menu = new MenuPopupViewModel
            {
                RelativeElement   = Application.Current.MainWindow,
                RelativePosition  = new Point(200, 300),
                TimeOut           = new TimeSpan(0, 0, 0, 10),
                VerticalAlignment = VerticalAlignment.Bottom,
                DisplayProperty   = string.Empty
            };

            menu.AddMenuItems(availableColors.ToArray());

            menu.Selected += (e, f) => SetShapeColor(f.Object.ToString());

            AppState.Popups.Add(menu);
        }
Пример #15
0
        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);
        }
Пример #16
0
        public void ChangeVisualType(FrameworkElement button)
        {
            var menu = new MenuPopupViewModel
            {
                RelativeElement = button,
                RelativePosition = new Point(35, -5),
                TimeOut = new TimeSpan(0, 0, 0, 5),
                VerticalAlignment = VerticalAlignment.Bottom,
                DisplayProperty = string.Empty,
                AutoClose = true
            };
            var types = Enum.GetValues(typeof(VisualTypes));
            foreach (VisualTypes t in types)
            {
                var mi = menu.AddMenuItem(t.ToString());
                var t1 = t;
                mi.Click += (o, e) =>
                {
                    Highlighter.VisualType = t1;
                    Service.ResetFilters();
                };
            }

            AppStateSettings.Instance.Popups.Add(menu);
        }
Пример #17
0
        public void ChangeStringValue(FrameworkElement button)
        {
            var menu = new MenuPopupViewModel
            {
                RelativeElement = button,
                RelativePosition = new Point(35, -5),
                TimeOut = new TimeSpan(0, 0, 0, 5),
                VerticalAlignment = VerticalAlignment.Bottom,
                DisplayProperty = string.Empty,
                AutoClose = true
            };
            var options = new List<string>();
            foreach (var p in Service.PoIs.Where(k => ((PoI) k).PoiTypeId == Highlighter.PoiType))
            {
                if (p.Labels.ContainsKey(Highlighter.SelectionCriteria) &&
                    !options.Contains(p.Labels[Highlighter.SelectionCriteria]))
                {
                    options.Add(p.Labels[Highlighter.SelectionCriteria]);
                }
            }

            //var types = Enum.GetValues(typeof(VisualTypes));
            foreach (var t in options)
            {
                var mi = menu.AddMenuItem(t);
                var t1 = t;
                mi.Click += (o, e) =>
                {
                    Highlighter.StringValue = t1;
                    Refresh();
                };
            }

            AppStateSettings.Instance.Popups.Add(menu);
        }
Пример #18
0
        public void LayerMenu(sLayer layer, FrameworkElement element)
        {
            if (layer == null) return;

            var menu = new MenuPopupViewModel
            {
                RelativeElement = element,
                RelativePosition = new Point(25, 0),
                TimeOut = new TimeSpan(0, 0, 0, 5),
                VerticalAlignment = VerticalAlignment.Bottom,
                DisplayProperty = string.Empty
            };

            menu.Items.AddRange(GetMenuItems(layer));

            if (menu.Items.Any()) AppState.Popups.Add(menu);
        }