private void SetImageCategories(SyncObservableCollection <SportCategory> categories)
        {
            var categoryVM = new CategoriesViewModel();

            categoryVM.OnNavigationCompleted();

            TournamentsViewModel b = new TournamentsViewModel();

            b.OnNavigationCompleted();

            foreach (SportCategory item in categories)
            {
                item.SportImageSource = categoryVM.Categories.Where(a => a.Name == item.SportName).FirstOrDefault().CategoryIconBySport as ImageSource;
                int counter = 0;

                foreach (TournamentVw itemTour in item.Tournaments)
                {
                    if (!itemTour.IsOutrightGroup)
                    {
                        counter++;
                    }
                    else
                    {
                        counter += itemTour.MatchesCount;
                    }
                }

                item.Count    = $"({counter})";
                item.CountAll = item.Tournaments.Count();
                setBorderCategories(item);
            }
            OnPropertyChanged("Categories");
        }
Пример #2
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);
        }
Пример #3
0
        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
        public ActiveImagesViewModel()
        {
            _ActiveFiles                = new SyncObservableCollection <FileInfo>();
            _ActiveFilesView            = new SyncListCollectionView(_ActiveFiles);
            _ActiveFilesView.CustomSort = new NaturalStringComparer();

            _ActiveFiles.CollectionChanged   += ActiveFiles_CollectionChanged;
            _ActiveFilesView.CurrentChanging += ActiveFilesView_CurrentChanging;
            _ActiveFilesView.CurrentChanged  += ActiveFilesView_CurrentChanged;

            this.ZoomType = ImageOrganizer.Common.ZoomType.BestFit;
        }
        public ActiveImagesViewModel()
        {
            _ActiveFiles = new SyncObservableCollection<FileInfo>();
            _ActiveFilesView = new SyncListCollectionView(_ActiveFiles);
            _ActiveFilesView.CustomSort = new NaturalStringComparer();

            _ActiveFiles.CollectionChanged += ActiveFiles_CollectionChanged;
            _ActiveFilesView.CurrentChanging += ActiveFilesView_CurrentChanging;
            _ActiveFilesView.CurrentChanged += ActiveFilesView_CurrentChanged;

            this.ZoomType = ImageOrganizer.Common.ZoomType.BestFit;
        }
Пример #6
0
        public static void SafelyApplyChanges <T>(SyncList <T> lSource, SyncObservableCollection <T> collTarget)
        {
            ExcpHelper.ThrowIf <InvalidOperationException>(ViewObjectBase.Dispatcher == null, "SafelyApplyChanges<{0}> ERROR", typeof(T).Name);

            if (!ViewObjectBase.Dispatcher.CheckAccess())
            {
                ViewObjectBase.Dispatcher.Invoke(new DelegateSafelyApplyChanges <T>(SafelyApplyChanges), lSource, collTarget);
            }
            else
            {
                collTarget.ApplyChanges(lSource);
            }
        }
Пример #7
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");
                }
            });
        }
Пример #8
0
        public LiveMonitorViewModel()
        {
            HidePleaseWait     = false;
            _matchesCollection = new SyncObservableCollection <IMatchVw>();
            //LineSr.DataSqlUpdateSucceeded += DataCopy_DataSqlUpdateSucceeded;

            MainGridCreated = new Command <UIElement>(OnMainGridCreated);
            ItemCreated     = new Command <UIElement>(OnItemCreated);

            Filled        = 0;
            MonitorHeight = 0;
            MonitorWidth  = 0;
            BrowserWidth  = 0;

            ItemHeight       = 0;
            HeaderItemHeight = 0;
        }
Пример #9
0
 public StrategyViewModel()
 {
     Strategies   = new SyncObservableCollection <Strategy>();
     _leanManager = Composer.Instance.GetExportedValueByTypeName <ILeanManager>(Config.Get("lean-manager-type", "LocalLeanManager"));
 }
Пример #10
0
 public SportCategory(string sportName, SyncObservableCollection <TournamentVw> tournaments, long categoryId)
 {
     this.SportName   = sportName;
     this.Tournaments = tournaments;
     this.CategoryID  = categoryId;
 }
Пример #11
0
        private List <global::ViewModels.Registration> InitFields(IEnumerable <formField> fields)
        {
            List <global::ViewModels.Registration> _fields = new List <global::ViewModels.Registration>();

            foreach (formField accountingField in fields)
            {
                if (accountingField.type == null)
                {
                    continue;
                }

                var field = new global::ViewModels.Registration();
                field.isValidatedEvent += field_isValidatedEvent;
                field.ReadOnly          = accountingField.@readonly;
                field.IsEnabled         = false;
                field.EmptyValidation   = field.IsEnabled;

                field.Name  = accountingField.name;
                field.Value = accountingField.value;


                field.Multistring = MultistringTag.Assign("TERMINAL_FORM_" + field.Name.ToUpperInvariant(), field.Name.ToUpperInvariant());
                if (!StationRepository.IsIdCardEnabled && field.Multistring.Value == MultistringTags.TERMINAL_FORM_CARD_PIN_ENABLED.Value)
                {
                    field.Multistring = MultistringTags.TERMINAL_FORM_BARCODECARD_PIN_ENABLED;
                }
                field.Label = TranslationProvider.Translate(field.Multistring);

                field.Rules = new List <fieldValidationRule>();
                field.Type  = AccountingToFormFieldsMap[accountingField.type];
                foreach (fieldValidationRule rule in accountingField.validation_rules)
                {
                    field.Rules.Add(rule);
                }

                if (accountingField.type == "DATE")
                {
                    int minAge = 0;
                    try
                    {
                        int.TryParse(StationRepository.HubSettings["min_play_age"], out minAge);
                    }
                    catch
                    {
                    }

                    var rule = new fieldValidationRule()
                    {
                        name = "MIN", value = minAge.ToString()
                    };

                    field.Rules.Add(rule);
                }

                if (accountingField.field_options != null)
                {
                    foreach (fieldOption option in accountingField.field_options)
                    {
                        field.Options.Add(new SelectorValue(option.value, option.id));
                    }
                }
                field.Options.Add(new SelectorValue(accountingField.value, accountingField.value));
                if (field.Options.All(sv => sv.Name != field.Value))
                {
                    var svTmp = field.Options.FirstOrDefault();
                    if (svTmp != null)
                    {
                        field.Value = svTmp.Name;
                    }
                }

                if (accountingField.type == "CURRENCY")
                {
                    field.Value = StationRepository.Currency;
                }

                if (accountingField.type == "DROPDOWN")
                {
                    if (!String.IsNullOrEmpty(accountingField.value))
                    {
                        field.Value = TranslationProvider.Translate(MultistringTag.Assign(accountingField.value.ToUpperInvariant(), accountingField.value.ToUpperInvariant())).ToString();
                    }
                    else
                    {
                        field.Value = "";
                    }
                    //field.ReadOnly = false;
                }

                if (accountingField.type == "PHONE")
                {
                    field.ValueInt = accountingField.value;
                }

                if (accountingField.type == "LANGUAGE")
                {
                    var languages = new SyncObservableCollection <Language>();
                    LanguageRepository.GetAllLanguages(languages);
                    foreach (var lang in languages)
                    {
                        field.Options.Add(new SelectorValue(lang.ShortName, lang.ShortName));
                    }
                    field.Value = accountingField.value;
                }
                else
                {
                    _fields.Add(field);
                }
                field.Mandatory = accountingField.mandatory;
                if (field.Mandatory)
                {
                    field.Label += "*";
                }

                if (field.Type == FieldType.Date)
                {
                    DateTime selDate = new DateTime();
                    DateTime.TryParse(field.Value, new DateTimeFormatInfo()
                    {
                        DateSeparator = ".", ShortDatePattern = "ddMMyyyy"
                    }, DateTimeStyles.AllowWhiteSpaces, out selDate);
                    field.Value = selDate.ToString("dd.MM.yyyy");
                }

                if (field.Name == "card_pin_enabled")
                {
                    if (field.Value == "1")
                    {
                        if (StationRepository.IsIdCardEnabled)
                        {
                            field.Value = TranslationProvider.Translate(MultistringTags.ENABLED_PIN).ToString();
                        }
                        else
                        {
                            field.Value = TranslationProvider.Translate(MultistringTags.BARCODE_ENABLED_PIN).ToString();
                        }
                    }
                    else
                    {
                        if (StationRepository.IsIdCardEnabled)
                        {
                            field.Value = TranslationProvider.Translate(MultistringTags.DISABLED_PIN).ToString();
                        }
                        else
                        {
                            field.Value = TranslationProvider.Translate(MultistringTags.BARCODE_DISABLED_PIN).ToString();
                        }
                    }
                }
                if (accountingField.name == "tax_number" && !StationRepository.DisplayTaxNumber)
                {
                    field.Visible = false;
                }
                if (accountingField.name == "bet_acceptance_checked")
                {
                    field.Visible = false;
                }
                if (accountingField.name == "terms_and_cond_version")
                {
                    field.Visible = false;
                }
            }
            return(_fields);
        }
Пример #12
0
        private void Initfields()
        {
            var fields = new List <global::ViewModels.Registration>();

            global::ViewModels.Registration fieldUsername = new global::ViewModels.Registration();
            fieldUsername.Mandatory = true;
            fieldUsername.Name      = "username";
            fieldUsername.Type      = FieldType.Text;
            fieldUsername.Rules     = new List <fieldValidationRule> {
                new fieldValidationRule {
                    name = "MAX", value = "255"
                }, new fieldValidationRule {
                    name = "MIN", value = "3"
                }
            };
            fields.Add(fieldUsername);
            Username           = fieldUsername;
            Username.IsFocused = true;

            global::ViewModels.Registration fieldPassword = new global::ViewModels.Registration();
            fieldPassword.Mandatory = true;
            fieldPassword.Name      = "password";
            fieldPassword.Type      = FieldType.Password;
            fieldPassword.Rules     = new List <fieldValidationRule> {
                new fieldValidationRule {
                    name = "MAX", value = "35"
                }, new fieldValidationRule {
                    name = "MIN", value = "3"
                }
            };
            fields.Add(fieldPassword);
            Password = fieldPassword;



            global::ViewModels.Registration fieldConfirmPassword = new global::ViewModels.Registration();
            fieldConfirmPassword.Mandatory = true;
            fieldConfirmPassword.Name      = "confirm_password";
            fieldConfirmPassword.Type      = FieldType.Password2;
            fieldConfirmPassword.Rules     = new List <fieldValidationRule> {
                new fieldValidationRule {
                    name = "MAX", value = "35"
                }, new fieldValidationRule {
                    name = "MIN", value = "3"
                }, new fieldValidationRule()
            };
            fieldConfirmPassword.PasswordConfirmation = fieldPassword;
            fieldPassword.PasswordConfirmation        = fieldConfirmPassword;
            fields.Add(fieldConfirmPassword);
            ConfirmPassword = fieldConfirmPassword;


            global::ViewModels.Registration fieldFirstName = new global::ViewModels.Registration();
            fieldFirstName.Name      = "first_name";
            fieldFirstName.Mandatory = true;
            fieldFirstName.Type      = FieldType.Text;
            fieldFirstName.Rules     = new List <fieldValidationRule> {
                new fieldValidationRule {
                    name = "MAX", value = "35"
                }, new fieldValidationRule {
                    name = "MIN", value = "3"
                }
            };
            fields.Add(fieldFirstName);
            FirstName = fieldFirstName;


            global::ViewModels.Registration fieldLastName = new global::ViewModels.Registration();
            fieldLastName.Name      = "last_name";
            fieldLastName.Mandatory = true;
            fieldLastName.Type      = FieldType.Text;
            fieldLastName.Rules     = new List <fieldValidationRule> {
                new fieldValidationRule {
                    name = "MAX", value = "35"
                }, new fieldValidationRule {
                    name = "MIN", value = "3"
                }
            };
            fields.Add(fieldLastName);
            LastName = fieldLastName;

            global::ViewModels.Registration fieldEmail = new global::ViewModels.Registration();
            fieldEmail.Name = "email";
            fieldEmail.Type = FieldType.EMail;
            fields.Add(fieldEmail);
            Email = fieldEmail;

            global::ViewModels.Registration fieldOperatorType = new global::ViewModels.Registration();
            OperatorType                = fieldOperatorType;
            fieldOperatorType.Name      = "operator_type";
            fieldOperatorType.Mandatory = true;
            fieldOperatorType.Type      = FieldType.Selector;

            bool isEmpty = true;

            if (ChangeTracker.CurrentUser != null && ChangeTracker.CurrentUser.CreateOperator)
            {
                var opList = WsdlRepository.GetAllRoles(ChangeTracker.CurrentUser.AccountId.ToString());

                if (opList == null || opList.Count() <= 0)
                {
                    fieldOperatorType.Visible   = false;
                    fieldOperatorType.IsEnabled = false;
                }

                foreach (UserRole userRole in opList)
                {
                    if (userRole.login_to_terminal == 1)
                    {
                        isEmpty = false;
                        fieldOperatorType.Options.Add(new SelectorValue(userRole.name, userRole.id.ToString()));
                    }
                }
            }

            //if (ChangeTracker.CurrentUser != null && ChangeTracker.CurrentUser.CreateOperator)
            //    fieldOperatorType.Options.Add(new SelectorValue(TranslationProvider.Translate(MultistringTags.Location_owner).ToString(), "3"));
            //if (ChangeTracker.CurrentUser != null && ChangeTracker.CurrentUser.CreateOperator)
            //    fieldOperatorType.Options.Add(new SelectorValue(TranslationProvider.Translate(MultistringTags.OPERATOR).ToString(), "4"));

            if (!isEmpty)
            {
                fields.Add(fieldOperatorType);
            }
            else
            {
                IsWarningVisible = Visibility.Visible;
                AreFieldsVisible = Visibility.Collapsed;
                Mediator.SendMessage(MsgTag.HideKeyboard, MsgTag.HideKeyboard);
            }

            fieldOperatorType.Rules = new List <fieldValidationRule>();
            fieldOperatorType.Rules.Add(new fieldValidationRule()
            {
                name = "MIN", value = "1"
            });
            fieldOperatorType.Value           = fieldOperatorType.Options.Select(x => x.Value).FirstOrDefault();
            fieldOperatorType.EmptyValidation = false;


            global::ViewModels.Registration fieldLanguage = new global::ViewModels.Registration();
            Language = fieldLanguage;
            fieldLanguage.Mandatory = true;
            fieldLanguage.Name      = "language";
            fieldLanguage.Type      = FieldType.DropDown;
            fieldLanguage.Options   = new ObservableCollection <SelectorValue>();
            var languages = new SyncObservableCollection <Language>();

            LanguageRepository.GetAllLanguages(languages);
            foreach (var language in languages)
            {
                fieldLanguage.Options.Add(new SelectorValue(language.ShortName, language.ShortName));
            }
            fieldLanguage.Value           = fieldLanguage.Options.Select(x => x.Value).FirstOrDefault();
            fieldLanguage.EmptyValidation = false;
            fields.Add(fieldLanguage);

            foreach (var registration in fields)
            {
                registration.IsEnabled = true;
                registration.Value     = string.Empty;
                var tag = MultistringTag.Assign("TERMINAL_FORM_" + registration.Name.ToUpperInvariant(), registration.Name.ToUpperInvariant());
                registration.Label = TranslationProvider.Translate(tag) as string;

                registration.isValidatedEvent += field_isValidatedEvent;
                if (registration.Mandatory)
                {
                    registration.Label += "*";
                }
            }
            FormFields = fields;
        }
Пример #13
0
        private List <global::ViewModels.Registration> InitFields(IEnumerable <formField> fields)
        {
            List <global::ViewModels.Registration> _fields    = new List <global::ViewModels.Registration>();
            List <global::ViewModels.Registration> tempFields = new List <global::ViewModels.Registration>();

            foreach (formField accountingField in fields)
            {
                if (accountingField.type == null)
                {
                    continue;
                }

                global::ViewModels.Registration field = new global::ViewModels.Registration();
                field.isValidatedEvent += field_isValidatedEvent;
                field.ReadOnly          = accountingField.@readonly;
                field.IsEnabled         = false;
                field.EmptyValidation   = field.IsEnabled;
                field.Visible           = !accountingField.hidden;
                field.Name              = accountingField.name;
                field.Value             = accountingField.value;

                field.Label = TranslationProvider.Translate(MultistringTag.Assign("TERMINAL_FORM_" + field.Name.ToUpperInvariant(), field.Name.ToUpperInvariant())).ToString().Replace("{0}", "");

                field.Rules = new List <fieldValidationRule>();
                field.Type  = AccountingToFormFieldsMap[accountingField.type];
                if (accountingField.validation_rules != null)
                {
                    foreach (fieldValidationRule rule in accountingField.validation_rules)
                    {
                        field.Rules.Add(rule);
                    }
                }

                if (accountingField.field_options != null)
                {
                    foreach (fieldOption option in accountingField.field_options)
                    {
                        field.Options.Add(new SelectorValue(option.value, option.id));
                    }
                    if (accountingField.field_options.Length == 0)
                    {
                        field.Options.Add(new SelectorValue(accountingField.value, accountingField.value));
                    }

                    if (field.Options.All(sv => sv.Name != field.Value))
                    {
                        var svTmp = field.Options.FirstOrDefault();
                        if (svTmp != null)
                        {
                            field.Value = svTmp.Name;
                        }
                    }
                }
                else
                {
                    field.Options.Add(new SelectorValue(accountingField.value, accountingField.value));
                    if (field.Options.All(sv => sv.Name != field.Value))
                    {
                        var svTmp = field.Options.FirstOrDefault();
                        if (svTmp != null)
                        {
                            field.Value = svTmp.Name;
                        }
                    }
                }

                if (accountingField.type == "DROPDOWN")
                {
                    if (!String.IsNullOrEmpty(accountingField.value))
                    {
                        field.Value = TranslationProvider.Translate(MultistringTag.Assign(accountingField.value.ToUpperInvariant(), accountingField.value.ToUpperInvariant())).ToString();
                    }
                    else
                    {
                        field.Value = "";
                    }
                }
                if (accountingField.type == "PHONE")
                {
                    field.ValueInt = accountingField.value;
                }

                if (accountingField.type == "CURRENCY")
                {
                    field.Value = StationRepository.Currency;
                }

                if (accountingField.type == "LANGUAGE")
                {
                    var languages = new SyncObservableCollection <Language>();
                    LanguageRepository.GetAllLanguages(languages);
                    foreach (var lang in languages)
                    {
                        field.Options.Add(new SelectorValue(lang.ShortName, lang.ShortName));
                    }
                    field.Value = accountingField.value;
                }
                else
                {
                    _fields.Add(field);
                }
                field.Mandatory = accountingField.mandatory;
                if (field.Mandatory)
                {
                    field.Label += "*";
                }
                if (field.Type == FieldType.Date)
                {
                    DateTime selDate = new DateTime();
                    DateTime.TryParse(field.Value, new DateTimeFormatInfo {
                        DateSeparator = ".", ShortDatePattern = "ddMMyyyy"
                    }, DateTimeStyles.AllowWhiteSpaces, out selDate);
                    field.Value = selDate.ToString("dd.MM.yyyy");
                }
                if (accountingField.name == "tax_number" && !StationRepository.DisplayTaxNumber)
                {
                    field.Visible = false;
                }
                if (accountingField.name != "bet_acceptance_checked" && accountingField.name != "terms_and_cond_version")
                {
                    tempFields.Add(field);
                }
            }

            return(tempFields);
        }
Пример #14
0
 public void FindMatches(SyncObservableCollection <IMatchVw> socMatches, string sSearch, string sLanguage, LineSr.DelegateFilterMatches dfm)
 {
     LineSr.Instance.SearchMatches(socMatches, sSearch, sLanguage, dfm);
 }
Пример #15
0
        private void SplitCollection()
        {
            if (ChangeTracker.LiveMonitors.Count <= 0)
            {
                return;
            }

            SyncList <IMatchVw> lMatches = Matches.ToSyncList();
            int iMatchIdx = 0;

            int page = -1;

            for (int i = 0; i < LiveMonitorsCollectionList.Count; i++)
            {
                if (lmViewModels[i].rotating || lmViewModels[i].LiveOddsVisibility == Visibility.Collapsed)
                {
                    continue;
                }

                LiveMonitorViewModel lmvm = null;
                Dispatcher.Invoke(() =>
                {
                    lmvm = ChangeTracker.LiveMonitors[i].Window.DataContext as LiveMonitorViewModel;
                });
                Debug.Assert(lmvm != null);

                double dblItemHeight       = lmvm != null && lmvm.ItemHeight > 0.0d ? lmvm.ItemHeight : ITEM_DEFAULT_HEIGHT;
                double dblHeaderItemHeight = lmvm != null && lmvm.HeaderItemHeight > 0.0d ? lmvm.HeaderItemHeight : ITEM_WITH_HEADER_DEFAULT_HEIGHT;

                Dispatcher.Invoke(() =>
                {
                    SyncObservableCollection <IMatchVw> socMonitor = LiveMonitorsCollectionList[i];
                    double dblCurrentMonitorFilledHeight           = 0;

                    SyncList <IMatchVw> lMatchesTemp = new SyncList <IMatchVw>();

                    IMatchVw matchVw    = lMatches.Count > iMatchIdx ? lMatches[iMatchIdx] : null;
                    string currentSport = "";
                    bool isPreLiveOld   = false;

                    while (matchVw != null)
                    {
                        var isPreLive = matchVw.LiveBetStatus == eMatchStatus.NotStarted || !matchVw.IsLiveBet;

                        if (matchVw.SportDescriptor != currentSport)
                        {
                            matchVw.IsHeaderForLiveMonitor = true;
                            currentSport = matchVw.SportDescriptor;
                        }
                        else if (page != i)
                        {
                            matchVw.IsHeaderForLiveMonitor = true;
                            page = i;
                        }
                        else if (isPreLive && !isPreLiveOld)
                        {
                            matchVw.IsHeaderForLiveMonitor = true;
                            isPreLiveOld = isPreLive;
                        }
                        else
                        {
                            if (dblCurrentMonitorFilledHeight + dblItemHeight <= LiveMonitorHeights[i])
                            {
                                matchVw.IsHeaderForLiveMonitor = false;
                            }
                        }

                        currentSport = matchVw.SportDescriptor;
                        page         = i;
                        isPreLiveOld = isPreLive;

                        dblCurrentMonitorFilledHeight += matchVw.IsHeaderForLiveMonitor ? dblHeaderItemHeight : dblItemHeight;

                        if (dblCurrentMonitorFilledHeight > LiveMonitorHeights[i])
                        {
                            page = i;
                            break;
                        }
                        else
                        {
                            lMatchesTemp.Add(matchVw);
                        }

                        iMatchIdx++;
                        matchVw = lMatches.Count > iMatchIdx ? lMatches[iMatchIdx] : null;
                    }
                    //Debug.Assert(ChangeTracker.LiveMonitors[i].threadId == socMonitor.threadid);

                    //Debug.Assert(Thread.CurrentThread == socMonitor.threadid);

                    socMonitor.ApplyChanges(lMatchesTemp);
                });
            }
        }
        private List <global::ViewModels.Registration> InitFields(formField[] fields)
        {
            List <global::ViewModels.Registration> _fields = new List <global::ViewModels.Registration>();

            foreach (formField accountingField in fields)
            {
                if (!accountingField.searchable)
                {
                    continue;
                }

                global::ViewModels.Registration field = new global::ViewModels.Registration();
                //field.isValidatedEvent += new isValidatedDelegate(field_isValidatedEvent);
                field.ReadOnly  = false;
                field.IsEnabled = true;

                field.Visible = !accountingField.hidden;
                field.Name    = accountingField.name;
                field.Value   = accountingField.value;

                field.Label = TranslationProvider.Translate(MultistringTag.Assign("TERMINAL_FORM_" + field.Name.ToUpperInvariant(), field.Name.ToUpperInvariant())).ToString().Replace("{0}", "");

                if (accountingField.type == null)
                {
                    continue;
                }
                field.Type = AccountingToFormFieldsMap[accountingField.type];

                if (accountingField.field_options != null)
                {
                    foreach (fieldOption option in accountingField.field_options)
                    {
                        field.Options.Add(new SelectorValue(option.value, option.id));
                    }

                    if (!field.Options.Any(sv => sv.Name == field.Value))
                    {
                        var svTmp = field.Options.FirstOrDefault();
                        if (svTmp != null)
                        {
                            field.Value = svTmp.Value;
                        }
                    }
                }
                if (accountingField.type == "DROPDOWN")
                {
                    string[] ids = accountingField.default_value.Split(';');
                    foreach (var id in ids)
                    {
                        string mltStr = TranslationProvider.Translate(MultistringTag.Assign(id.ToUpperInvariant(), id.ToUpperInvariant())).ToString();
                        field.Options.Add(new SelectorValue(mltStr, id));
                    }
                }
                else
                {
                    //field.Value = accountingField.default_value;
                    field.Value = "";
                }

                if (accountingField.type == "CURRENCY")
                {
                    field.IsEnabled       = false;
                    field.EmptyValidation = field.IsEnabled;
                }

                if (accountingField.type == "PHONE")
                {
                    field.ValueInt = accountingField.value;
                }


                if (accountingField.type == "LANGUAGE")
                {
                    var languages = new SyncObservableCollection <Language>();
                    //LanguageRepository.GetAllLanguages(languages);
                    var lr = new LanguageRepository();
                    lr.GetAllLanguages(languages);
                    foreach (var lang in languages)
                    {
                        field.Options.Add(new SelectorValue(lang.ShortName, lang.ShortName));
                    }
                    field.Value = accountingField.default_value;
                }

                if (field.Type == FieldType.Password)
                {
                    _fields.Add(field);
                    global::ViewModels.Registration secondPasswordField = new global::ViewModels.Registration();
                    field.PasswordConfirmation = secondPasswordField;
                    secondPasswordField.PasswordConfirmation = field;
                    //secondPasswordField.isValidatedEvent += new isValidatedDelegate(field_isValidatedEvent);

                    secondPasswordField.Name      = "password2";
                    secondPasswordField.Label     = TranslationProvider.Translate(MultistringTags.TERMINAL_FORM_CONFIRM_PASSWORD) + "*";
                    secondPasswordField.Type      = FieldType.Password2;
                    secondPasswordField.IsEnabled = true;
                    secondPasswordField.Mandatory = true;
                    secondPasswordField.Value     = "";
                    _fields.Add(secondPasswordField);
                }
                else if (field.Type == FieldType.Date)
                {
                    //if (string.IsNullOrWhiteSpace(field.Value))
                    //{
                    //    field.Value = DateTime.Today.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture);
                    //}
                    //DateTime selDate = new DateTime();
                    //DateTime.TryParse(field.Value, new DateTimeFormatInfo() { DateSeparator = ".", ShortDatePattern = "ddMMyyyy" }, DateTimeStyles.AllowWhiteSpaces, out selDate);
                    //field.Value = selDate.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture);
                    field.Value = " ";
                    _fields.Add(field);
                }
                else
                {
                    _fields.Add(field);
                }

                if (accountingField.name == "tax_number" && !StationRepository.DisplayTaxNumber)
                {
                    //field.Visible = false;
                    _fields.Remove(field);
                }
            }
            return(_fields);
        }
Пример #17
0
        public void Rotate()
        {
            if (ChangeTracker.LiveMonitors.Count <= 0)
            {
                return;
            }

            if (this.rotationCounter >= 1000)
            {
                rotationCounter = 0;
            }

            this.rotationCounter++;

            LiveMonitorViewModel lmvm = null;

            SyncList <IMatchVw> lMatches = Matches.ToSyncList();

            for (int i = 0; i < LiveMonitorsCollectionList.Count; i++)
            {
                if (!lmViewModels[i].rotating || lmViewModels[i].LiveOddsVisibility == Visibility.Collapsed)
                {
                    continue;
                }

                //check interval
                if (this.rotationCounter % lmViewModels[i].rotationInterval != 0 && this.rotationCounter != 0)
                {
                    continue;
                }

                lmvm = ChangeTracker.LiveMonitors[i].DataContext as LiveMonitorViewModel;
                Debug.Assert(lmvm != null);

                double dblItemHeight       = lmvm != null && lmvm.ItemHeight > 0.0d ? lmvm.ItemHeight : ITEM_DEFAULT_HEIGHT;
                double dblHeaderItemHeight = lmvm != null && lmvm.HeaderItemHeight > 0.0d ? lmvm.HeaderItemHeight : ITEM_WITH_HEADER_DEFAULT_HEIGHT;

                if (LiveMonitorRotationCounters[i] >= lMatches.Count)
                {
                    LiveMonitorRotationCounters[i] = LiveMonitorRotationCounters[i] - lMatches.Count;
                }

                int iMatchIdx = LiveMonitorRotationCounters[i];

                if (iMatchIdx >= lMatches.Count)
                {
                    iMatchIdx = 0;
                }

                IMatchVw matchVw = lMatches.Count > iMatchIdx ? lMatches[iMatchIdx] : null;



                SyncObservableCollection <IMatchVw> socMonitor = LiveMonitorsCollectionList[i];
                double dblCurrentMonitorFilledHeight           = 0;

                SyncList <IMatchVw> lMatchesTemp = new SyncList <IMatchVw>();

                string oldSport     = "";
                bool   isPreLiveOld = false;

                while (matchVw != null)
                {
                    if (matchVw == null || lMatchesTemp.Contains(matchVw))
                    {
                        break;
                    }

                    string currentSport = matchVw.SportDescriptor;
                    var    isPreLive    = matchVw.LiveBetStatus == eMatchStatus.NotStarted || !matchVw.IsLiveBet;
                    if (!string.IsNullOrEmpty(currentSport))
                    {
                        if (currentSport != oldSport)
                        {
                            matchVw.IsHeaderForRotation = true;
                        }
                        else if (isPreLive && !isPreLiveOld)
                        {
                            matchVw.IsHeaderForRotation = true;
                        }
                        else
                        {
                            matchVw.IsHeaderForRotation = false;
                        }
                        oldSport     = currentSport;
                        isPreLiveOld = isPreLive;
                    }

                    dblCurrentMonitorFilledHeight += matchVw.IsHeaderForRotation ? dblHeaderItemHeight : dblItemHeight;

                    if (dblCurrentMonitorFilledHeight > lmViewModels[i].LiveOddsHeight) //lmViewModels[i].LiveOddsHeight)
                    {
                        break;
                    }
                    else
                    {
                        lMatchesTemp.Add(matchVw);
                    }

                    iMatchIdx++;

                    if (iMatchIdx >= lMatches.Count)
                    {
                        iMatchIdx = 0;
                    }

                    matchVw = lMatches.Count > iMatchIdx ? lMatches[iMatchIdx] : null;

                    LiveMonitorRotationCounters[i]++;
                }

                Dispatcher.Invoke(() =>
                {
                    socMonitor.ApplyChanges(lMatchesTemp);     //damn thing does not applay normally changes for collections with duplicate matches with it...
                });
            }
        }
Пример #18
0
 public void VerifySelectedOdds(SyncObservableCollection <ITipItemVw> syncList)
 {
     LineSr.Instance.VerifySelectedOdds(new SortableObservableCollection <ITipItemVw>(syncList));
 }
        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);
                    }));
                }
            }
        }
 public void Setup()
 {
     _models     = new ObservableCollection <Model>();
     _viewModels = new ExternalizedSyncObservableCollection <ViewModel, Model>(_models, ViewModelBuilder);
 }
 public void Setup()
 {
     _models = new ObservableCollection<Model>();
     _viewModels = new ExternalizedSyncObservableCollection<ViewModel, Model>(_models, ViewModelBuilder);
 }