Example #1
0
        private void ReceiveFileCommand(FileCommandMessage fileCommand)
        {
            switch (fileCommand.Command)
            {
            case "NEW":
                _content = new Project();
                ApplicationCommands.SaveJsonObject(fileCommand.Path, _content);
                TreeData = ConvertFromProjectToGroups();
                break;

            case "OPEN":
                _content = (Project)ApplicationCommands.ReadJsonObject(fileCommand.Path, typeof(Project));
                if (_content != null)
                {
                    TreeData = ConvertFromProjectToGroups();
                }
                break;

            case "SAVE":
                ApplicationCommands.SaveJsonObject(fileCommand.Path, _content);
                break;

            default:
                throw new Exception($"Unknnown File Menu command {fileCommand.Command}");
            }
        }
Example #2
0
        static int Main(string[] args)
        {
            try
            {
                var app = new CommandLineApplication
                {
                    Name = "SFTools",
                };
                app.HelpOption("-?|-h|--help");

                ImageStoreCommand.Configure(app);
                ApplicationTypeCommands.Configure(app);
                ApplicationCommands.Configure(app);

                var errCode = app.Execute(args);
                if (errCode != 0)
                {
                    //Console.WriteLine("Error parsing options...");
                    //Console.WriteLine();

                    //app.ShowHelp();
                    Console.WriteLine($"Something went wrong - exited with status code {errCode}");
                    return(errCode);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(-1);
            }

            return(0);
        }
Example #3
0
        private void AddExcel(string _)
        {
            var t = ApplicationCommands.RunOpenFileDialog(".xlsx", System.IO.Directory.GetCurrentDirectory());

            if (!t.Item1)
            {
                // Send message back to TreeView
                GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new ExcelFileCommandMessage(_treeNode.Key, TreeNodeCommand.Add, t.Item2));
            }
        }
Example #4
0
        public async Task RunAsync()
        {
            var json = string.Empty;

            using (var fs = File.OpenRead("config.json"))
            {
                using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
                {
                    json = await sr.ReadToEndAsync().ConfigureAwait(false);
                }
            }

            var configJson = JsonConvert.DeserializeObject <ConfigJson>(json);

            var config = new DiscordConfiguration
            {
                Token                 = configJson.Token,
                TokenType             = TokenType.Bot,
                AutoReconnect         = true,
                LogLevel              = LogLevel.Debug,
                UseInternalLogHandler = true
            };

            Client = new DiscordClient(config);

            Client.Ready += OnClientReady;

            Client.UseInteractivity(new InteractivityConfiguration
            {
                Timeout = TimeSpan.FromMinutes(2)
            });

            var commandsConfig = new CommandsNextConfiguration
            {
                StringPrefix         = configJson.Prefix,
                EnableDms            = true,
                EnableMentionPrefix  = true,
                CaseSensitive        = false,
                IgnoreExtraArguments = true
            };

            Commands = Client.UseCommandsNext(commandsConfig);
            Commands.RegisterCommands <ApplicationCommands>();
            Commands.RegisterCommands <TeamCommands>();
            Commands.RegisterCommands <FunCommands>();

            await ApplicationCommands.Init().ConfigureAwait(false);

            await Client.ConnectAsync();

            await Task.Delay(-1);
        }
Example #5
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            if (CmdSite == null)
            {
                return;
            }
            ;
            WriteVerbose(string.Format("restart-application on {0}", CmdSite.Url));
            var response = ApplicationCommands.RestartApplication(CmdSite);

            WriteObject(response);
        }
Example #6
0
        public MaskingVideoOverlayViewModelTests()
        {
            _scriptVideoContextMock = new Mock <IScriptVideoContext>();
            _scriptVideoContextMock.Setup(svc => svc.HasVideo).Returns(true);
            _scriptVideoContextMock.Setup(svc => svc.FrameNumber).Returns(0);
            _scriptVideoContextMock.Setup(svc => svc.IsVideoPlaying).Returns(false);
            _scriptVideoContextMock.Setup(svc => svc.VideoFrameCount).Returns(241);
            _scriptVideoContextMock.Setup(svc => svc.SeekableVideoFrameCount).Returns(240);
            _scriptVideoContextMock.Setup(svc => svc.VideoFrameSize).Returns(new SizeI(628, 472));

            _scriptVideoServiceMock = new Mock <IScriptVideoService>();
            _scriptVideoServiceMock.Setup(svs => svs.GetContextReference()).Returns(_scriptVideoContextMock.Object);

            _mockMaskingProject = MockProjectFactory.CreateMockMaskingProject();
            _projectServiceMock = new Mock <IProjectService>();
            _projectServiceMock.Setup(ps => ps.Project).Returns(_mockMaskingProject);

            _undoServiceMock = new Mock <IUndoService>();
            _undoServiceMock.Setup(us => us[It.IsAny <object>()]).Returns((object root) =>
            {
                if (_undoRoot?.Root != root)
                {
                    _undoRoot = new UndoRoot(root);
                }
                return(_undoRoot);
            });

            _undoChangeFactoryMock = new Mock <IChangeFactory>();

            _systemDialogServiceMock = new Mock <ISystemDialogService>();
            _systemDialogServiceMock.Setup(sds => sds.ShowErrorDialog(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Exception>()))
            .Callback <string, string, Exception>((dialogTextParam, dialogCaptionParam, exceptionParam) =>
            {
                throw exceptionParam ?? new Exception(dialogTextParam);
            });

            _clipboardServiceMock = new Mock <IClipboardService>();

            _applicationCommands = new ApplicationCommands();

            _viewModel = new MaskingVideoOverlayViewModel(_scriptVideoServiceMock.Object, _undoServiceMock.Object, _undoChangeFactoryMock.Object, _applicationCommands, _projectServiceMock.Object, _systemDialogServiceMock.Object, _clipboardServiceMock.Object);
        }
Example #7
0
 private void ReceiveExcelFileCommand(ExcelFileCommandMessage fileCommand)
 {
     switch (fileCommand.Command)
     {
     case TreeNodeCommand.Add:
         var sheets = ApplicationCommands.RetreiveSheets(fileCommand.FullPath);
         // Add to Project
         _content.ExcelFiles.Add(new ExcelFileData()
         {
             ExcelFileFullPath = fileCommand.FullPath,
             Sheets            = sheets.Select(s => new SheetData()
             {
                 SheetName = s, ClassName = string.Empty
             }).ToList()
         });
         // Update TreeView
         TreeData = ConvertFromProjectToGroups();
         break;
     }
 }
Example #8
0
        public void HorizonViewModelInitialize()
        {
            // Arrangements
            var topHorizon = new int[, ]
            {
                { 1, 2 },
                { 2, 3 }
            };

            var _applicationCommands = new ApplicationCommands();

            _mockHorizonDataService.Setup(s => s.GetTopHorizonDepthInFeet()).Returns(topHorizon);
            _mockVolumeCalculationService.Setup(s => s.CalculateOilAndGasVolumeFromTopHorizonInCubicMeter(topHorizon)).Returns(12.0);

            // Actions
            var horizonViewModel = new HorizonViewModel(_applicationCommands, _mockHorizonDataService.Object, _mockVolumeCalculationService.Object);

            // Assertions
            Assert.IsNotNull(horizonViewModel);
            Assert.IsNotNull(horizonViewModel.ShowVolumeCommand);
            _mockHorizonDataService.Verify(c => c.GetTopHorizonDepthInFeet(), Times.Once());
            _mockVolumeCalculationService.Verify(c => c.CalculateOilAndGasVolumeFromTopHorizonInCubicMeter(topHorizon), Times.Once());
            Assert.AreEqual(12.0, horizonViewModel.VolumeOfOilAndGasInCubicMeter);
        }
        private void RaiseApplicationCommand(ApplicationCommands command)
        {
            if (OnApplicationCommand == null)
            {
                return;
            }

            OnApplicationCommand(this, new ApplicationCommandEventArgs(command));
        }
		public ApplicationCommandEventArgs(ApplicationCommands command)
		{
			Command = command;
		}
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            InitializeContext();

            ApplicationCommands.ResizeWindow(1400, 900);
        }
 private void OnPreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
 {
     ApplicationCommands.Scroll(e.Delta);
 }
        private void SetupViewModel(bool useRealUndoService = false)
        {
            _currentScriptVideoFrameNumber = 0;

            _scriptVideoServiceMock = new Mock <IScriptVideoService>();
            _scriptVideoServiceMock.SetupAdd(svs => svs.FrameChanged    += It.IsAny <EventHandler <FrameChangedEventArgs> >());
            _scriptVideoServiceMock.SetupRemove(svs => svs.FrameChanged -= It.IsAny <EventHandler <FrameChangedEventArgs> >());

            _scriptVideoContextMock = new Mock <IScriptVideoContext>();
            _scriptVideoContextMock.Setup(svc => svc.HasVideo).Returns(true);

            _scriptVideoContextMock.SetupGet(svc => svc.FrameNumber).Returns(() => _currentScriptVideoFrameNumber);
            _scriptVideoContextMock.SetupSet(svc => svc.FrameNumber = It.IsAny <int>()).Callback <int>(value =>
            {
                int previousFrameNumber        = _currentScriptVideoFrameNumber;
                _currentScriptVideoFrameNumber = value;
                _scriptVideoServiceMock.Raise(svs => svs.FrameChanged += null, new FrameChangedEventArgs(previousFrameNumber, _currentScriptVideoFrameNumber));
            });

            _scriptVideoContextMock.Setup(svc => svc.IsVideoPlaying).Returns(false);
            _scriptVideoContextMock.Setup(svc => svc.VideoFrameCount).Returns(400);
            _scriptVideoContextMock.Setup(svc => svc.SeekableVideoFrameCount).Returns(399);
            _scriptVideoContextMock.Setup(svc => svc.VideoFrameSize).Returns(new SizeI(640, 480));

            _scriptVideoServiceMock.Setup(svs => svs.GetContextReference()).Returns(_scriptVideoContextMock.Object);

            _timelineCommands    = new TimelineCommands();
            _applicationCommands = new ApplicationCommands();

            if (useRealUndoService)
            {
                _undoService = UndoService.Current;
                _undoService.Clear();
                _undoChangeFactory = new ChangeFactory();
            }
            else
            {
                Mock <IUndoService>   undoServiceMock;
                Mock <IChangeFactory> undoChangeFactoryMock;

                undoServiceMock = new Mock <IUndoService>();
                undoServiceMock.Setup(us => us[It.IsAny <object>()]).Returns((object root) =>
                {
                    if (_undoRoot?.Root != root)
                    {
                        _undoRoot = new UndoRoot(root);
                    }
                    return(_undoRoot);
                });
                _undoService = undoServiceMock.Object;

                undoChangeFactoryMock = new Mock <IChangeFactory>();
                _undoChangeFactory    = undoChangeFactoryMock.Object;
            }

            _clipboardServiceMock = new Mock <IClipboardService>();
            _dialogServiceMock    = new Mock <IDialogService>();

            _timelineSegmentProvidingViewModel = new MockTimelineSegmentProvidingViewModel(GenerateTestSegmentModels(), _scriptVideoServiceMock.Object, _undoService, _undoChangeFactory, _clipboardServiceMock.Object, _applicationCommands);

            if (useRealUndoService)
            {
                _undoRoot = _undoService[_timelineSegmentProvidingViewModel];
            }

            _viewModel = new VideoTimelineViewModel(_scriptVideoServiceMock.Object, _undoService, _undoChangeFactory, _clipboardServiceMock.Object, _dialogServiceMock.Object, _timelineCommands)
            {
                TimelineSegmentProvidingViewModel = _timelineSegmentProvidingViewModel
            };
            _scriptVideoContextMock.Object.FrameNumber = 0;
        }