예제 #1
0
        static async Task Main()
        {
            List <QuoteResponse> quoteList = await QuoteGenerate.QuoteListGenerator();

            DateTime start    = new DateTime();
            string   apiQuote = QuoteShow.showQuote(quoteList);

            start = DateTime.Now;
            TypeChallenge.RecordTry(apiQuote);
            ResultStats totalTime = new ResultStats();

            totalTime.GetTotalTime(start);
        }
예제 #2
0
        /// <summary>Calculate profit stats on a collection of records</summary>
        private ResultStats CalcStats(IEnumerable <Record> records)
        {
            var wins = records.Where(x => x.NetProfit >= 0).ToArray();
            var loss = records.Where(x => x.NetProfit < 0).ToArray();

            var stats = new ResultStats();

            stats.Wins       = wins.Length;
            stats.Losses     = loss.Length;
            stats.WinAmount  = wins.Sum(x => (double)x.NetProfit);
            stats.LossAmount = loss.Sum(x => (double)x.NetProfit);
            return(stats);
        }
예제 #3
0
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
        #endregion
        public MainViewModel(IOptionService optionService, IDirectoryService directoryService,
                             IAppService infoService, IThemeService themeService)
        {
            // Initialize services
            _docLib           = DocLib.Instance;
            _optionService    = optionService;
            _directoryService = directoryService;
            _themeService     = themeService;
            _infoService      = infoService;

            // Initialize commands
            GetDirectory = ReactiveCommand.Create(BrowseDirectory);
            ReadPDF      = ReactiveCommand.Create(() => {
                _th = new Thread(() => StartReading());
                _th.IsBackground = true;
                _th.Start();
            }, this.IsValid());
            ChangeTheme = ReactiveCommand.Create(() =>
            {
                themeService.ChangeTheme();
                CurrentThemeName = themeService.GetCurrentThemeName();
            });
            ChangeLanguage = ReactiveCommand.Create(() =>
            {
                infoService.ChangeLanguage();
                CurrentLanguageName = infoService.GetCurrentLanguage();
                UpdateStringResources();
            });

            // Initialize variables
            PrecisionOCR = new ObservableCollection <RecognitionPrecision>(Enum.GetValues(typeof(RecognitionPrecision)).Cast <RecognitionPrecision>());
            LanguageOCR  = new ObservableCollection <RecognitionLanguage>(Enum.GetValues(typeof(RecognitionLanguage)).Cast <RecognitionLanguage>());
            Options      = new SearchOptions("", "", PrecisionOCR.FirstOrDefault(), LanguageOCR.FirstOrDefault(),
                                             false, true, false, true, false, false);
            Results             = new ObservableCollection <QueryResult>();
            Stats               = new ResultStats("0/0", true, 0, "0");
            ResultInfo          = infoService.GetSearchInfo(SearchInfo.Init);
            StatusName          = infoService.GetSearchStatus(SearchStatus.Ready);
            CurrentThemeName    = themeService.GetCurrentThemeName();
            CurrentLanguageName = infoService.GetCurrentLanguage();
            ItemsReady          = false;

            // Subscribe for events and set validation rules
            ErrorsChanged += OnValidationErrorsChanged;
            this.ValidationRule(x => x.Options.Keyword, key => !string.IsNullOrEmpty(key), "Keyword cannot be empty!");
            this.ValidationRule(x => x.Options.Path, key => !string.IsNullOrEmpty(key) && Directory.Exists(key), "Path has to be valid!");

            // Get assembly version
            AppVersion = infoService.GetVersion();
        }
예제 #4
0
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
        public MainViewModel()
        {
            // Initialize variables
            PrecisionOCR = new ObservableCollection <RecognitionPrecision>(Enum.GetValues(typeof(RecognitionPrecision)).Cast <RecognitionPrecision>());
            LanguageOCR  = new ObservableCollection <RecognitionLanguage>(Enum.GetValues(typeof(RecognitionLanguage)).Cast <RecognitionLanguage>());
            Options      = new SearchOptions("", "", PrecisionOCR.FirstOrDefault(), LanguageOCR.FirstOrDefault(),
                                             false, true, false, true, false, false);
            Results             = new ObservableCollection <QueryResult>();
            Stats               = new ResultStats("0/0", true, 0, "0");
            StatusName          = SearchStatus.Ready.ToString();
            ResultInfo          = "Click search button to start";
            CurrentThemeName    = Theme.Default.ToString().ToUpper();
            CurrentLanguageName = AppLanguage.English.ToString().ToUpper();
            ItemsReady          = false;

            // Subscribe for events and set validation rules
            ErrorsChanged += OnValidationErrorsChanged;
            this.ValidationRule(x => x.Options.Keyword, key => !string.IsNullOrEmpty(key), "Keyword cannot be empty!");
            this.ValidationRule(x => x.Options.Path, key => !string.IsNullOrEmpty(key) && Directory.Exists(key), "Path has to be valid!");

            AppVersion = "x.x.x";
        }