コード例 #1
0
        public SyncObservableCollection <Language> GetAllLanguages(SyncObservableCollection <Language> languages)
        {
            var languagesLn = LineSr.Instance.GetTerminalLanguages();

            List <Language> languagesToRemove = new List <Language>();

            foreach (var languageLn in languagesLn)
            {
                if (languages.Count(x => x.Id == languageLn.LanguageId) < 1 && StationRepository.SystemLanguages != null && StationRepository.SystemLanguages.Contains(languageLn.ShortName.ToUpperInvariant()))
                {
                    languages.Add(new Language(languageLn.ShortName.ToUpperInvariant())
                    {
                        Id = languageLn.LanguageId
                    });
                }
                else if (languages.Count(x => x.Id == languageLn.LanguageId) >= 1 && StationRepository.SystemLanguages != null && !StationRepository.SystemLanguages.Contains(languageLn.ShortName.ToUpperInvariant()))
                {
                    languagesToRemove.Add(languages.Where(x => x.Id == languageLn.LanguageId).FirstOrDefault());
                }
            }

            if (languagesToRemove.Count > 0)
            {
                foreach (Language lan in languagesToRemove)
                {
                    languages.Remove(lan);
                }
            }

            return(languages);
        }
コード例 #2
0
        private void LoadImagesCore(string DirectoryPath, CancellationToken CancellationToken)
        {
            this.IsLoadingFiles = true;
            try
            {
                CancellationToken.ThrowIfCancellationRequested();

                _ActiveFiles.Clear();
                this.ActiveImage = null;

                this.ZoomFit();

                System.IO.DirectoryInfo SelectedDirectory;
                try
                {
                    SelectedDirectory = new System.IO.DirectoryInfo(DirectoryPath);
                }
                catch (System.IO.IOException)
                {
                    //System.Windows.MessageBox.Show("Could not open directory: " + ex.Message);
                    return;
                }

                var NaturalStringComparer = new NaturalStringComparer();
                foreach (var FileInfo in SelectedDirectory.EnumerateFiles().OrderBy((o) => o.Name, NaturalStringComparer))
                {
                    CancellationToken.ThrowIfCancellationRequested();

                    var Decoder = ImageFileUtils.CreateDecoder(FileInfo);
                    if (Decoder == null || Decoder.Frames == null || Decoder.Frames.Count == 0 || Decoder.Frames[0].Width == 0 || Decoder.Frames[0].Height == 0)
                    {
                        continue;
                    }

                    lock (ActiveFilesLock)
                    {
                        _ActiveFiles.Add(FileInfo);
                    }
                    if (_ActiveFiles.Count == 1)
                    {
                        this.MoveToFirst();
                    }
                }
            }
            catch (OperationCanceledException)
            {
                //Ignore task cancel
                throw;
            }
            catch (Exception)
            {
                //TODO: Error handling
            }
            finally
            {
                this.IsLoadingFiles = false;
            }
        }
コード例 #3
0
ファイル: LogViewModel.cs プロジェクト: w1r2p1/Algoloop-1
        public LogViewModel()
        {
            Logs = new SyncObservableCollection <LogItem>();
            Log.DebuggingEnabled = Config.GetBool("debug-mode");
            Log.LogHandler       = Composer.Instance.GetExportedValueByTypeName <ILogHandler>(Config.Get("log-handler", "CompositeLogHandler"));
            ILogItemHandler logService = Log.LogHandler as ILogItemHandler;

            if (logService != null)
            {
                logService.Connect((item) => Logs.Add(item));
            }
        }
コード例 #4
0
        private void OnLoadData()
        {
            decimal paymentBalance       = 0;
            decimal locationCashPosition = 0;
            decimal totalLocationBalance = 0;

            PaymentFlowData[] list;

            if (itemsAmountPerPage > 0)
            {
                ChangeTracker.ItemsAmmountPerPage = itemsAmountPerPage;
            }

            //download data from hub
            Saldo = WsdlRepository.GetStationPaymentFlowData(StationRepository.StationNumber, currentPosition, ChangeTracker.ItemsAmmountPerPage, out paymentBalance, out locationCashPosition, out totalLocationBalance, out list, out itemsTotal);

            CashPosition   = locationCashPosition;
            CashBalance    = totalLocationBalance;
            PaymentBalance = paymentBalance;

            Dispatcher.Invoke(() =>
            {
                Payments.Clear();

                SyncObservableCollection <PaymentFlowData> temp = new SyncObservableCollection <PaymentFlowData>();
                if (list != null)
                {
                    foreach (var paymentFlowData in list)
                    {
                        if (paymentFlowData.type == "OWED_PAYMENT")
                        {
                            paymentFlowData.type = TranslationProvider.Translate(MultistringTags.OWED_PAYMENT) as string;
                        }
                        else if (paymentFlowData.type == "CREDIT")
                        {
                            paymentFlowData.type = TranslationProvider.Translate(MultistringTags.CREDIT) as string;
                        }
                        else if (paymentFlowData.type == "PAYMENT")
                        {
                            paymentFlowData.type = TranslationProvider.Translate(MultistringTags.PAYMENT) as string;
                        }
                        temp.Add(paymentFlowData);
                    }

                    Payments = new SyncObservableCollection <PaymentFlowData>(temp);
                    OnPropertyChanged("Payments");
                }
            });
        }
コード例 #5
0
        private void FillTournaments()
        {
            Tournaments.Clear();
            if (flag1)
            {
                lock (_itemsLock)
                {
                    flag1 = false;
                    SortableObservableCollection <IMatchVw> matches = new SortableObservableCollection <IMatchVw>();
                    int tournamentsAmount = ChangeTracker.IsLandscapeMode ? 10 : 8;
                    SyncObservableCollection <SportCategory> tempCategories = new SyncObservableCollection <SportCategory>();

                    matches = Repository.FindMatches(matches, "", SelectedLanguage, MatchFilter, Sort);

                    //lets see if we can start from categories, not tournaments
                    var groups = matches.Where(x => !x.IsOutright && x.CategoryView != null).Select(x => x.CategoryView).Distinct().ToList();

                    foreach (var group in groups)
                    {
                        SportCategory temp = new SportCategory(group.DisplayName, new SyncObservableCollection <TournamentVw>(), group.LineObject.GroupId);
                        temp.Sort = group.LineObject.Sort.Value;
                        tempCategories.Add(temp);
                    }
                    tempCategories = new SyncObservableCollection <SportCategory>(tempCategories.OrderBy(x => x.Sort).ToList());

                    foreach (SportCategory category in tempCategories)
                    {
                        //fill tournaments - not outrights

                        List <TournamentVw> Tournaments = new List <TournamentVw>();
                        var tours = matches.Where(x => !x.IsOutright && x.TournamentView != null && x.CategoryView != null && x.CategoryView.LineObject.GroupId == category.CategoryID).Select(x => x.TournamentView).Distinct().ToList();
                        int allTournamentsCount = tours.Count;

                        for (int i = 0; i < tours.Count; i++)
                        {
                            long   id             = tours[i].LineObject.GroupId;
                            long   svrId          = tours[i].LineObject.SvrGroupId;
                            string tournamentName = tours[i].DisplayName;
                            long   countryId      = 0;
                            string country        = "";

                            int    sort           = tours[i].LineObject.Sort.Value;
                            string minCombination = null;

                            if (tours[i].LineObject.GroupTournament != null && tours[i].LineObject.GroupTournament.MinCombination.Value > 0)
                            {
                                minCombination = TranslationProvider.Translate(MultistringTags.TERMINAL_X_COMB, tours[i].LineObject.GroupTournament.MinCombination.Value);
                            }

                            if (tours[i].TournamentCountryView != null)
                            {
                                countryId = tours[i].TournamentCountryView.LineObject.SvrGroupId;
                                country   = tours[i].TournamentCountryView.DisplayName;
                            }

                            long   sportId   = 0;
                            string sportName = "";

                            if (tours[i].TournamentSportView != null)
                            {
                                sportId   = tours[i].TournamentSportView.LineObject.SvrGroupId;
                                sportName = tours[i].TournamentSportView.DisplayName;
                            }

                            bool isOutright = false;
                            long categoryId = 0;

                            TournamentVw tour = new TournamentVw(id, svrId, tournamentName, countryId, sort, minCombination, country, sportId, isOutright, sportName, categoryId);
                            tour.TemporaryMatchesCount = matches.Where(x => !x.IsOutright && x.TournamentView != null && x.TournamentView.LineObject.GroupId == tour.Id).Count();
                            tour.ApplayTemporaryMatchesCount();

                            if (ChangeTracker.SelectedTournaments.Contains(tour.Id.ToString() + "*0"))
                            {
                                tour.IsSelected = true;
                            }

                            Tournaments.Add(tour);
                        }

                        Tournaments = new List <TournamentVw>(Tournaments.OrderBy(x => x.Sort));
                        Tournaments.Sort(Comparison);
                        //now i have all category tournaments

                        for (int i = 0; i < tournamentsAmount; i++)
                        {
                            if (i >= Tournaments.Count)
                            {
                                break;
                            }

                            category.Tournaments.Add(Tournaments[i]);
                        }

                        Tournaments.Clear();
                        //if there is only outrights, add them to category
                        int outrightCount = matches.Where(x => x.IsOutright && x.CategoryView != null && x.CategoryView.LineObject.GroupId == category.CategoryID).Count();
                        if (outrightCount > 0)
                        {
                            allTournamentsCount++;
                        }

                        if (category.Tournaments.Count == 0 || category.Tournaments.Count < tournamentsAmount)
                        {
                            if (outrightCount > 0)
                            {
                                TournamentVw outright = new TournamentVw(int.MinValue, 0, TranslationProvider.Translate(MultistringTags.OUTRIGHTS).ToString(), 0, int.MinValue, null, "", category.CategoryID, true, category.SportName);
                                outright.MatchesCount = outrightCount;
                                category.Tournaments.Add(outright);
                            }
                        }

                        //add all tournaments button
                        if (allTournamentsCount > category.Tournaments.Count)
                        {
                            category.Tournaments.RemoveAt(category.Tournaments.Count - 1);

                            TournamentVw allTournaments = new TournamentVw(int.MinValue, -999, "All tournaments", 0, int.MinValue, null, "", category.CategoryID, true, category.SportName);
                            allTournaments.MatchesCount = allTournamentsCount;
                            category.Tournaments.Add(allTournaments);
                        }
                    }


                    SetImageCategories(tempCategories);
                    Dispatcher.BeginInvoke((Action)(() =>
                    {
                        Categories.ApplyChanges(tempCategories);
                    }));
                }
            }
        }