Esempio n. 1
0
        public MainWindow(IGUIToolkit guiToolkit) :
            base(Constants.SOFTWARE_NAME)
        {
            this.Build();
            this.guiToolKit = guiToolkit;
            Title           = Constants.SOFTWARE_NAME;

            ConnectMenuSignals();

            // Default screen
            Screen screen = Display.Default.DefaultScreen;
            // Which monitor is our window on
            int monitor = screen.GetMonitorAtWindow(this.GdkWindow);
            // Monitor size
            Rectangle monitor_geometry = screen.GetMonitorGeometry(monitor);

            // Resize to a convenient size
            this.Resize(monitor_geometry.Width * 80 / 100, monitor_geometry.Height * 80 / 100);
            if (Utils.OS == OperatingSystemID.OSX)
            {
                this.Move(monitor_geometry.Width * 10 / 100, monitor_geometry.Height * 10 / 100);
            }
            DatabaseManagerCommand = new LimitationCommand(LongoMatchFeature.DatabaseManager.ToString(), () => {
                App.Current.StateController.MoveToModal(DatabasesManagerState.NAME, null, true);
            });
        }
Esempio n. 2
0
        public MediaFileChooser(String name, int index)
        {
            this.Build();

            nameentry.NoShowAll = true;

            // The name entry is only visible when not empty
            nameentry.Visible = !String.IsNullOrEmpty(name);
            nameentry.Text    = name ?? "";

            addbuttonimage.Image   = App.Current.ResourcesLocator.LoadIcon("vas-browse", Sizes.ButtonDialogIconSize);
            clearbuttonimage.Image = App.Current.ResourcesLocator.LoadIcon("vas-delete", Sizes.ButtonDialogIconSize);

            FilterName       = "MP4";
            FilterExtensions = new string [] { "*.mp4" };
            FileChooserMode  = FileChooserMode.MediaFile;

            UpdateFile();

            // FIXME: Use a viewmodel and the proper bindings
            // Warning: Note also that if the index is incremented from another part than the new panel the limitation will be also
            // applied there.
            addLimitationCommand = new LimitationCommand(VASFeature.CreateMultiCamera.ToString(), () => HandleAddClicked(null, null));
            addLimitationCommand.LimitationCondition = () => index > 1;
            entrybutton_addbutton.BindManually(addLimitationCommand);

            clearbutton.Clicked += HandleClearClicked;
            nameentry.Changed   += HandleNameChanged;

            nameentry.TooltipText = Catalog.GetString("Edit to change camera name");

            ProposedFileName      = String.Format("{0}-{1}.mp4", App.Current.SoftwareName, DateTime.Now.ToShortDateString());
            ProposedDirectoryName = String.Format("{0}-{1}", App.Current.SoftwareName, DateTime.Now.ToShortDateString());
        }
Esempio n. 3
0
        public void HScale_LimitationEnabled_ReturnsToDefaultValue()
        {
            LimitationCommand <double> command = new LimitationCommand <double> ("Test", (obj) => {});
            HScale scale = new HScale(1, 4, 1);
            HScaleCommandBinding binding = new HScaleCommandBinding(scale, (vm) => command, 1);

            binding.ViewModel = new DummyViewModel();
            mockLimitationService.Setup(s => s.CanExecute("Test")).Returns(false);

            scale.Value = 2;

            Assert.AreEqual(1, scale.Value);
        }
Esempio n. 4
0
        public void HScale_LimitationEnabled_ExecuteCalledOnce()
        {
            LimitationCommand <double> command = new LimitationCommand <double> ("Test", (obj) => { });
            HScale scale = new HScale(1, 4, 1);
            HScaleCommandBinding binding = new HScaleCommandBinding(scale, (vm) => command, 1);

            binding.ViewModel = new DummyViewModel();
            mockLimitationService.Setup(s => s.CanExecute("Test")).Returns(false);

            scale.Value = 2;

            mockLimitationService.Verify((s) => s.MoveToUpgradeDialog("Test"), Times.Once);
        }
Esempio n. 5
0
        public void HScale_LimitationEnabled_CommandNotExecuted()
        {
            double val = -1;
            LimitationCommand <double> command = new LimitationCommand <double> ("Test", (obj) => val = obj);
            HScale scale = new HScale(1, 4, 1);
            HScaleCommandBinding binding = new HScaleCommandBinding(scale, (vm) => command, 1);

            binding.ViewModel = new DummyViewModel();
            mockLimitationService.Setup(s => s.CanExecute("Test")).Returns(false);

            scale.Value = 2;

            Assert.AreEqual(-1, val);
        }
Esempio n. 6
0
        public void Execute_LimitationCanExecute_Executed()
        {
            // Arrange
            bool executed = false;

            mockLimitationService.Setup(lim => lim.CanExecute(limitationName)).Returns(true);
            var command = new LimitationCommand(limitationName, () => { executed = true; });

            // Act
            command.Execute();

            // Assert
            Assert.IsTrue(executed);
            mockLimitationService.Verify(lim => lim.MoveToUpgradeDialog(limitationName), Times.Never);
        }
Esempio n. 7
0
        public void Execute_LimitationNotInitialized_Executed()
        {
            // Arrange
            bool executed = false;

            App.Current.LicenseLimitationsService = new LicenseLimitationsService();
            var command = new LimitationCommand(limitationName, () => { executed = true; });

            // Act
            command.Execute();

            // Assert
            Assert.IsTrue(executed);
            Assert.AreEqual(executed, command.Executed);
        }
Esempio n. 8
0
 public Blackboard(IWidget widget) : base(widget)
 {
     Accuracy      = 5;
     SelectionMode = MultiSelectionMode.MultipleWithModifier;
     LineWidth     = 2;
     Color         = Color.Red1;
     LineStyle     = LineStyle.Normal;
     LineType      = LineType.Arrow;
     FontSize      = 12;
     tool          = DrawTool.Selection;
     currentZoom   = 1;
     MinZoom       = App.Current.ZoomLevels.Min();
     MaxZoom       = App.Current.ZoomLevels.Max();
     ZoomCommand   = new LimitationCommand <double> (VASFeature.Zoom.ToString(), Zoom);
 }
Esempio n. 9
0
        public void Execute_LimitationCanNotExecute_MoveToUpgradeDialog()
        {
            // Arrange
            bool executed = false;

            mockLimitationService.Setup(lim => lim.CanExecute(limitationName)).Returns(false);
            var command = new LimitationCommand(limitationName, () => { executed = true; });

            // Act
            command.Execute();

            // assert
            Assert.IsFalse(executed);
            Assert.AreEqual(executed, command.Executed);
            mockLimitationService.Verify(lim => lim.MoveToUpgradeDialog(limitationName), Times.Once);
        }
Esempio n. 10
0
        public void Execute_FeatureCanExecuteButConditionSetToNotApplyLimit_ExecuteOk()
        {
            // Arrange
            bool executed = false;

            mockLimitationService.Setup(lim => lim.CanExecute(limitationName)).Returns(false);
            var command = new LimitationCommand(limitationName, () => { executed = true; });

            command.LimitationCondition = () => false;

            // Act
            command.Execute();

            // assert
            Assert.IsTrue(executed);
            mockLimitationService.Verify(lim => lim.MoveToUpgradeDialog(limitationName), Times.Never);
        }
Esempio n. 11
0
        void HandleToggled(object sender, EventArgs args)
        {
            if (!silenceToggledEvent)
            {
                Command.Execute(button.Active ? Parameter : parameterInactive);

                LimitationCommand limitedCommand = Command as LimitationCommand;
                if (limitedCommand != null && !limitedCommand.Executed)
                {
                    silenceToggledEvent = true;
                    button.Toggle();
                    button.Active       = false;
                    silenceToggledEvent = false;
                }

                UpdateView();
            }
        }
 public LMProjectAnalysisVM()
 {
     TeamTagger                  = new LMTeamTaggerVM();
     TeamTagger.Compact          = true;
     TeamTagger.SelectionMode    = MultiSelectionMode.Multiple;
     TeamTagger.ShowTeamsButtons = true;
     Project     = new LMProjectVM();
     SaveCommand = new Command(
         () => App.Current.EventsBroker.Publish(new SaveEvent <LMProjectVM> {
         Object = Project
     }),
         () => Project.Edited);
     ShowStatsCommand = new Command(
         () => App.Current.EventsBroker.Publish(new ShowProjectStatsEvent {
         Project = Project.Model
     }));
     CloseCommand          = new AsyncCommand(Close);
     ShowWarningLimitation = new LimitationCommand(VASFeature.OpenMultiCamera.ToString(), () => { });
     ShowWarningLimitation.LimitationCondition = () => Project.FileSet.Count() > 1;
 }
Esempio n. 13
0
 public ProjectsManagerVM()
 {
     LoadedProject = new TViewModel();
     NewCommand    = new LimitationCommand(VASCountLimitedObjects.Projects.ToString(), New)
     {
         IconName = "vas-plus"
     };
     OpenCommand   = new AsyncCommand <TViewModel> (Open, (arg) => Selection.Count == 1);
     DeleteCommand = new AsyncCommand <TViewModel> (Delete, (arg) => Selection.Any() || arg != null)
     {
         IconName = "vas-delete"
     };
     SaveCommand   = new AsyncCommand(Save, () => LoadedProject?.Model != null && LoadedProject.IsChanged);
     ExportCommand = new AsyncCommand(Export, () => Selection.Count == 1);
     EmptyCard     = new EmptyCardVM {
         HeaderText      = ProjectsNoneCreated,
         DescriptionText = ProjectsCreateHelper,
         TipText         = ProjectsCreateTip,
     };
     VisibleViewModels = new VisibleRangeObservableProxy <TViewModel> (ViewModels);
 }
Esempio n. 14
0
        public void BindView_LimitationNotEnabledCommandExecuted_ButtonActive()
        {
            // Arrange
            bool limitedCommandExecuted = false;
            LimitationCommand   command = new LimitationCommand("Test", (obj) => limitedCommandExecuted = true);
            ToggleButton        button  = new ToggleButton();
            ToggleButtonBinding binding = new ToggleButtonBinding(button, (vm) => command, true, false);

            binding.ViewModel = new DummyViewModel();

            int toggled = 0;

            button.Toggled += (sender, e) => toggled++;

            mockLimitationService.Setup(s => s.CanExecute("Test")).Returns(true);

            // Act
            button.Toggle();

            // Assert
            Assert.AreEqual(limitedCommandExecuted, command.Executed);
            Assert.AreEqual(1, toggled);
        }
Esempio n. 15
0
        public NewProjectPanel()
        {
            this.Build();
            this.mtoolkit = App.Current.MultimediaToolkit;
            dialogs       = App.Current.Dialogs;
            capturemediafilechooser.FileChooserMode  = FileChooserMode.File;
            capturemediafilechooser.ProposedFileName = String.Format("Live-LongoMatch-{0}.mp4",
                                                                     DateTime.Now.ToShortDateString());
            notebook1.ShowTabs   = false;
            notebook1.ShowBorder = false;

            ipCameraCommand = new LimitationCommand(LongoMatchFeature.IpCameras.ToString(), () => HandleNextClicked(this, null));

            LoadIcons();
            GroupLabels();
            ConnectSignals();
            FillFormats();
            Gdk.Color.Parse("red", ref red);
            outputfilelabel.ModifyFg(StateType.Normal, red);
            urilabel.ModifyFg(StateType.Normal, red);

            ApplyStyle();
        }
 public VideoConversionTool()
 {
     this.Build();
     buttonOk.Sensitive = false;
     Files = new List <MediaFile> ();
     supportedVideoStandards = VideoStandards.Transcode;
     maxHeight = supportedVideoStandards [0].Height;
     mediafilechooser1.FileChooserMode  = FileChooserMode.File;
     mediafilechooser1.ChangedEvent    += HandleFileChanges;
     mediafilechooser1.ProposedFileName = String.Format("{0}-Video-{1}.mp4", Constants.SOFTWARE_NAME,
                                                        DateTime.Now.ToShortDateString().Replace('/', '-'));
     FillStandards();
     FillBitrates();
     addbutton1.Clicked += OnAddbuttonClicked;
     convertimage.Image  = App.Current.ResourcesLocator.LoadIcon("lm-video-converter-big", 64);
     addimage.Image      = App.Current.ResourcesLocator.LoadIcon("vas-add", StyleConf.ButtonNormalSize);
     eventbox1.ModifyBg(StateType.Normal, Misc.ToGdkColor(App.Current.Style.PaletteBackgroundDark));
     addbutton1.CanFocus     = false;
     scrolledwindow1.Visible = false;
     conversionCommand       = new LimitationCommand(LongoMatchFeature.VideoConverter.ToString(), ExecuteConversion);
     // FIXME: port to viewmodel this view and do the proper bindings
     buttonOk.BindManually(conversionCommand);
 }
Esempio n. 17
0
        public VideoPlayerVM()
        {
            ViewPortsSwitchActive = true;
            CamerasConfig         = new RangeObservableCollection <CameraConfig> ();
            AbsoluteCurrentTime   = new Time(0);
            CurrentTime           = new Time(0);
            Step = new Time {
                TotalSeconds = 10
            };
            ShowDetachButton         = true;
            ShowCenterPlayHeadButton = true;

            ShowZoomCommand = new LimitationCommand(VASFeature.Zoom.ToString(),
                                                    () => {
                ShowZoom = true;
            })
            {
                Icon        = App.Current.ResourcesLocator.LoadIcon("vas-control-zoom", 15),
                ToolTipText = Catalog.GetString("Zoom"),
            };

            SetZoomCommand = new LimitationCommand <float> (VASFeature.Zoom.ToString(), zoomLevel => Player.SetZoom(zoomLevel));

            EditEventDurationCommand = new Command <bool> (b => Player.SetEditEventDurationMode(b))
            {
                Icon        = App.Current.ResourcesLocator.LoadIcon(Icons.PlayerControlTrim, Sizes.PlayerCapturerIconSize),
                Text        = Catalog.GetString("Edit event duration"),
                ToolTipText = Catalog.GetString("Edit event duration"),
                Executable  = false,
            };

            InitializeCommands();
            Duration    = new Time(0);
            CurrentTime = new Time(0);
            EditEventDurationTimeNode = new TimeNodeVM();
        }
Esempio n. 18
0
        public DashboardVM()
        {
            AddButton = new Command <string> (
                (s) => App.Current.EventsBroker.Publish(new CreateDashboardButtonEvent {
                Name = s
            }))
            {
                Icon = App.Current.ResourcesLocator.LoadIcon("vas-add", App.Current.Style.ButtonNormalWidth),
                Text = Catalog.GetString("Add"),
            };

            DeleteButton = new Command <DashboardButtonVM> (
                (s) => App.Current.EventsBroker.Publish(new DeleteEvent <DashboardButtonVM> {
                Object = s
            }))
            {
                Icon = App.Current.ResourcesLocator.LoadIcon("vas-delete", App.Current.Style.ButtonNormalWidth),
                Text = Catalog.GetString("Delete"),
            };

            DuplicateButton = new Command <DashboardButtonVM> (
                (s) => App.Current.EventsBroker.Publish(new DuplicateEvent <DashboardButtonVM> {
                Object = s
            }))
            {
                Text = Catalog.GetString("Duplicate"),
            };

            DeleteLink = new Command <ActionLinkVM> (
                (s) => App.Current.EventsBroker.Publish(new DeleteEvent <ActionLinkVM> {
                Object = s
            }))
            {
                Icon = App.Current.ResourcesLocator.LoadIcon("vas-delete", App.Current.Style.ButtonNormalWidth),
                Text = Catalog.GetString("Delete"),
            };

            ResetField = new Command <FieldPositionType> (
                (p) => App.Current.EventsBroker.Publish(new ResetDashboardFieldEvent {
                Field = p
            }))
            {
                Text = Catalog.GetString("Reset"),
            };

            ChangeField = new Command <FieldPositionType> (
                (p) => App.Current.EventsBroker.Publish(new ReplaceDashboardFieldEvent {
                Field = p
            }))
            {
                Text = Catalog.GetString("Change"),
            };

            ToggleActionLinks = new LimitationCommand <bool> (VASFeature.LinkingButtons.ToString(), (p) => ShowLinks = p)
            {
                Icon         = App.Current.ResourcesLocator.LoadIcon("vas-link-active", App.Current.Style.IconSmallWidth),
                IconInactive = App.Current.ResourcesLocator.LoadIcon("vas-link-disabled", App.Current.Style.IconSmallWidth),
                ToolTipText  = Catalog.GetString("Edit action links"),
            };

            ChangeDashboardMode = new Command <DashboardMode> ((p) => Mode = p)
            {
                Icon         = App.Current.ResourcesLocator.LoadIcon("vas-dash-edit-active", App.Current.Style.IconSmallWidth),
                IconInactive = App.Current.ResourcesLocator.LoadIcon("vas-dash-edit", App.Current.Style.IconSmallWidth),
                ToolTipText  = Catalog.GetString("Edit dashboard"),
            };

            TogglePopupWindow = new Command <bool> ((p) => DisablePopupWindow = !p)
            {
                Icon        = App.Current.ResourcesLocator.LoadIcon("vas-popup", App.Current.Style.IconSmallWidth),
                ToolTipText = Catalog.GetString("Disable popup window"),
            };

            ChangeFitMode = new Command <FitMode> ((p) => FitMode = p);

            ViewModels.CollectionChanged += HandleCollectionChanged;
            CurrentTime = new Time();
        }
Esempio n. 19
0
 public DrawingToolVM()
 {
     SetZoomCommand = new LimitationCommand <double> (VASFeature.Zoom.ToString(), SetZoom);
     ZoomLevel      = 1;
 }
Esempio n. 20
0
        public void CanExecute_InitExecutable_Ok()
        {
            var command = new LimitationCommand(limitationName, (obj) => { });

            Assert.IsTrue(command.CanExecute());
        }
Esempio n. 21
0
        public void CanExecute_Command_OK()
        {
            var command = new LimitationCommand(limitationName, () => { }, () => true);

            Assert.IsTrue(command.CanExecute(true));
        }
Esempio n. 22
0
        public void CanExecute_GenricCommand_OK()
        {
            var command = new LimitationCommand <bool> (limitationName, (o) => { }, () => true);

            Assert.IsTrue(command.CanExecute());
        }
Esempio n. 23
0
        public void CanExecute_GenericCommandParametrized_CanExecuteOK()
        {
            var command = new LimitationCommand <bool> (limitationName, o => { }, o => o);

            Assert.IsTrue(command.CanExecute(true));
        }
Esempio n. 24
0
        void InitializeCommands()
        {
            ShowZoomCommand = new LimitationCommand(VASFeature.Zoom.ToString(), () => { ShowZoom = true; });
            ConfigureCommand(ShowZoomCommand, Icons.PlayerControlZoom, Sizes.PlayerCapturerSmallIconSize, StyleConf.PlayerTooltipZoom);

            SetZoomCommand = new LimitationCommand <float> (VASFeature.Zoom.ToString(), zoomLevel => Player.SetZoom(zoomLevel));

            ChangeVolumeCommand = new Command <double> (level => {
                Player.Volume = level / 100;
            });
            ConfigureCommand(ChangeVolumeCommand, Icons.PlayerControlHigh, Sizes.PlayerCapturerIconSize, StyleConf.PlayerTooltipVolume);

            ChangeStepCommand = new Command <double> (val => {
                Player.SetStep(new Time {
                    TotalSeconds = App.Current.StepList [(int)val]
                });
            });
            ConfigureCommand(ChangeStepCommand, Icons.PlayerControlJumps, Sizes.PlayerCapturerSmallIconSize, StyleConf.PlayerTooltipJumps);

            ChangeRateCommand = new Command <double> (val => {
                double rateLevel = App.Current.RateList [(int)val];
                // Mute for rate != 1
                if (rateLevel != 1 && Volume != 0)
                {
                    previousVolumeLevel = Volume;
                    Player.Volume       = 0;
                }
                else if (rateLevel == 1)
                {
                    Player.Volume = previousVolumeLevel;
                }

                Player.Rate = rateLevel;
            });
            ConfigureCommand(ChangeRateCommand, Icons.PlayerControlSpeedRate, Sizes.PlayerCapturerSmallIconSize, StyleConf.PlayerTooltipRate);

            CloseCommand = new Command(() => { LoadEvent(null, Playing); });
            ConfigureCommand(CloseCommand, Icons.PlayerControlCancelRec, Sizes.PlayerCapturerIconSize, StyleConf.PlayerTooltipClose);

            PreviousCommand = new Command(() => { Player.Previous(); });
            ConfigureCommand(PreviousCommand, Icons.PlayerControlRewind, Sizes.PlayerCapturerIconSize, StyleConf.PlayerTooltipPrevious);

            NextCommand = new Command(() => { Player.Next(); });
            ConfigureCommand(NextCommand, Icons.PlayerControlFastForward, Sizes.PlayerCapturerIconSize, StyleConf.PlayerTooltipNext);

            PlayCommand = new Command(() => { Player.Play(); });
            ConfigureCommand(PlayCommand, Icons.PlayerControlPlay, Sizes.PlayerCapturerIconSize, StyleConf.PlayerTooltipPlay);

            PauseCommand = new Command <bool> (sync => Player.Pause(sync));
            ConfigureCommand(PauseCommand, Icons.PlayerControlPause, Sizes.PlayerCapturerIconSize, StyleConf.PlayerTooltipPause);

            DrawCommand = new Command(() => Player.DrawFrame());
            ConfigureCommand(DrawCommand, Icons.PlayerControlDraw, Sizes.PlayerCapturerIconSize, StyleConf.PlayerTooltipDraw);

            DetachCommand = new LimitationCommand(VASFeature.VideoDetach.ToString(), () => { App.Current.EventsBroker.Publish(new DetachEvent()); });
            ConfigureCommand(DetachCommand, Icons.PlayerControlDetach, Sizes.PlayerCapturerIconSize, StyleConf.PlayerTooltipDetach);

            ViewPortsSwitchToggleCommand = new Command(() => {
                ViewPortsSwitchActive = !ViewPortsSwitchActive;
            });
            ConfigureCommand(ViewPortsSwitchToggleCommand, Icons.PlayerControlMulticam, Sizes.PlayerCapturerIconSize);

            SeekCommand = new Command <VideoPlayerSeekOptions> (seekOptions => {
                Player.Seek(seekOptions.Time, seekOptions.Accurate, seekOptions.Synchronous, seekOptions.Throttled);
            });

            ExposeCommand = new Command(() => Player.Expose());

            ReadyCommand = new Command <bool> (ready => Player.Ready(ready));

            StopCommand = new Command(() => Player.Stop());

            TogglePlayCommand = new Command(() => Player.TogglePlay());

            SeekToPreviousFrameCommand = new Command(() => Player.SeekToPreviousFrame());

            SeekToNextFrameCommand = new Command(() => Player.SeekToNextFrame());

            StepBackwardCommand = new Command(() => Player.StepBackward());

            StepForwardCommand = new Command(() => Player.StepForward());
        }