SettingsPageModel createItem(string icon, string localizedKey)
 {
     return(new SettingsPageModel {
         Icon = icon,
         Title = CrossLocalization.Translate(localizedKey)
     });
 }
示例#2
0
        async Task selectServer(object selectedObject)
        {
            try {
                if (selectedObject == null || !(selectedObject is ServerPageModel))
                {
                    return;
                }

                var server = (ServerPageModel)selectedObject;

                if (!_services.Preferences.IsLoggedIn)
                {
                    changeServer(server);
                    return;
                }

                var result = await _services.Dialogs.ShowConfirmationMessage(
                    CrossLocalization.Translate("base_warning"),
                    CrossLocalization.Translate("settings_server_change_message"));

                if (!result)
                {
                    SelectedItem = null;
                    return;
                }

                changeServer(server);
                _services.Device.MainThread(() => _services.Navigation.OpenLogin());
            } catch (Exception ex) {
                AppLogs.Log(ex);
            }
        }
 ThemePageModel getThemeDetails(string theme)
 {
     return(new ThemePageModel {
         Theme = theme,
         Title = CrossLocalization.Translate(theme?.ToLower()),
         IsChecked = _services.Preferences.Theme == theme
     });
 }
 string getTitle(StatsPageEnum pageType)
 {
     return(pageType switch
     {
         StatsPageEnum.LabsRating => CrossLocalization.Translate("stats_page_labs_rating"),
         StatsPageEnum.LabsVisiting => CrossLocalization.Translate("stats_page_labs_visiting"),
         _ => CrossLocalization.Translate("stats_page_lectures_visiting"),
     });
 Label createContributorLabel(string localizedKey, bool bold = false)
 {
     return(new Label {
         Style = AppStyles.GetLabelStyle(bold: bold),
         HorizontalTextAlignment = TextAlignment.Center,
         Text = CrossLocalization.Translate(localizedKey),
         TextColor = Color.FromHex(Theme.Current.AboutTextColor)
     });
 }
示例#6
0
 ServerPageModel getServerDetails(string serverAddress, string descriptionLocalizedKey)
 {
     return(new ServerPageModel {
         Address = serverAddress,
         Title = Servers.GetServerType(serverAddress),
         Description = CrossLocalization.Translate(descriptionLocalizedKey),
         IsChecked = _services.Preferences.Server == serverAddress
     });
 }
示例#7
0
 /// <summary>
 /// Set downloading.
 /// </summary>
 void setDownloading()
 {
     PlatformServices.Device.MainThread(() => {
         _progressDialog = PlatformServices.Dialogs.ShowProgress(
             CrossLocalization.Translate("files_downloading"),
             CrossLocalization.Translate("base_cancel"),
             () => abortDownload());
     });
 }
 protected async Task openSettings()
 {
     try {
         await _services.Navigation.OpenSettings(
             CrossLocalization.Translate("main_settings"));
     } catch (Exception ex) {
         AppLogs.Log(ex);
     }
 }
        void setInitData()
        {
            Username   = _services.Preferences.UserLogin;
            IsLoggedIn = _services.Preferences.IsLoggedIn;
            Avatar     = _services.Preferences.Avatar;
            var isProfessor = string.IsNullOrEmpty(_services.Preferences.GroupName);

            Group = isProfessor ? null : _services.Preferences.GroupName;
            Role  = CrossLocalization.Translate(isProfessor ? "role_professor" : "role_student");
        }
示例#10
0
 Label createChooseLabel()
 {
     return(new Label {
         Margin = _chooseLabelMargin,
         FontAttributes = FontAttributes.Bold,
         TextColor = Color.FromHex(Theme.Current.BaseSectionTextColor),
         Text = CrossLocalization.Translate("settings_theme_choose"),
         Style = AppStyles.GetLabelStyle(NamedSize.Large, true)
     });
 }
 public TestingResultsPageView(int testId, bool fromComplexLearning, string timePassed = null)
 {
     _timePassed     = timePassed;
     BackgroundColor = Color.FromHex(Theme.Current.AppBackgroundColor);
     Title           = CrossLocalization.Translate("test_results_title");
     BindingContext  = new TestingResultsPageViewModel(
         testId, fromComplexLearning, new PlatformServices());
     createToolbar();
     createViews();
 }
        public NewsDetailsPageView(string title, string body)
        {
            Title = CrossLocalization.Translate("news_details_title");
            var dynSize = FontSizeController.GetDynamicSize(_bodyFontSize);

            _services      = new PlatformServices();
            BindingContext = new NewsDetailsPageViewModel(dynSize, title, body, _services);
            setToolbar();
            createViews();
        }
 Label createRatingTitleLabel()
 {
     return(new Label {
         TextColor = Color.FromHex(Theme.Current.BaseSectionTextColor),
         HorizontalTextAlignment = TextAlignment.Center,
         HorizontalOptions = LayoutOptions.CenterAndExpand,
         Text = CrossLocalization.Translate("test_results_label"),
         Style = AppStyles.GetLabelStyle()
     });
 }
 Label createTimePassedLabel()
 {
     return(new Label {
         HorizontalTextAlignment = TextAlignment.Center,
         HorizontalOptions = LayoutOptions.CenterAndExpand,
         Style = AppStyles.GetLabelStyle(NamedSize.Medium),
         TextColor = Color.FromHex(Theme.Current.TestResultsRatingColor),
         Text = $"{CrossLocalization.Translate("test_results_time")} {_timePassed}"
     });
 }
示例#15
0
 public SaveMarksPageViewModel(IPlatformServices services, int _subjectId, object stat, int groupId, string title)
 {
     _titleOfPage = title;
     _services    = services;
     if (title == CrossLocalization.Translate("stats_page_lectures_visiting"))
     {
         groupData = stat as VisitingLecturesList;
         createLecturesVisitingPage(groupData);
     }
     else if (title == CrossLocalization.Translate("stats_page_labs_visiting"))
     {
         labsVisitingList = stat as LabsVisitingList;
         _takedLabs       = new TakedLabs();
         WebRequest request = WebRequest.Create(Links.GetLabsTest + "subjectId=" + _subjectId + "&groupId=" + groupId);
         request.Headers.Add("Authorization", _services.Preferences.AccessToken);
         WebResponse response = request.GetResponse();
         string      json     = "";
         using (Stream stream = response.GetResponseStream())
         {
             using (StreamReader reader = new StreamReader(stream))
             {
                 string line = "";
                 while ((line = reader.ReadLine()) != null)
                 {
                     json += line;
                 }
             }
         };
         _takedLabs = JsonConvert.DeserializeObject <TakedLabs>(json);
         createLabsVisitingPage(labsVisitingList);
     }
     else if (title == CrossLocalization.Translate("practiсe_visiting"))
     {
         subjectId            = _subjectId;
         practiceVisitingList = stat as LabsVisitingList;
         _takedLabs           = new TakedLabs();
         WebRequest request = WebRequest.Create(Links.GetPracticialsTest + "subjectId=" + _subjectId + "&groupId=" + groupId);
         request.Headers.Add("Authorization", _services.Preferences.AccessToken);
         WebResponse response = request.GetResponse();
         string      json     = "";
         using (Stream stream = response.GetResponseStream())
         {
             using (StreamReader reader = new StreamReader(stream))
             {
                 string line = "";
                 while ((line = reader.ReadLine()) != null)
                 {
                     json += line;
                 }
             }
         };
         _takedLabs = JsonConvert.DeserializeObject <TakedLabs>(json);
         createPracticialsVisitingPage(practiceVisitingList);
     }
 }
示例#16
0
 Label createHeaderLabel()
 {
     return(new Label {
         Padding = _headerPadding,
         FontAttributes = FontAttributes.Bold,
         Text = CrossLocalization.Translate("files_header"),
         TextColor = Color.FromHex(Theme.Current.BaseSectionTextColor),
         BackgroundColor = Color.FromHex(Theme.Current.AppBackgroundColor),
         Style = AppStyles.GetLabelStyle(NamedSize.Large, true)
     });
 }
        async Task logout()
        {
            var result = await _services.Dialogs.ShowConfirmationMessage(
                CrossLocalization.Translate("base_warning"),
                CrossLocalization.Translate("settings_logout_message"));

            if (result)
            {
                resetData();
            }
        }
示例#18
0
        Entry createUsernameEntry(Style style)
        {
            var username = new Entry {
                Style       = style,
                ReturnType  = ReturnType.Next,
                Placeholder = CrossLocalization.Translate("login_username")
            };

            username.SetBinding(Entry.TextProperty, "Username");
            return(username);
        }
示例#19
0
 Label createSubjectsLabel()
 {
     return(new Label {
         BackgroundColor = Color.FromHex(Theme.Current.AppBackgroundColor),
         Padding = _subjectsLabelMargin,
         FontAttributes = FontAttributes.Bold,
         TextColor = Color.FromHex(Theme.Current.BaseSectionTextColor),
         Text = CrossLocalization.Translate("today_subjects"),
         Style = AppStyles.GetLabelStyle(NamedSize.Large, true)
     });
 }
示例#20
0
        async Task showStartTestDialog(int testId, bool forSelfStudy)
        {
            var result = await PlatformServices.Dialogs.ShowConfirmationMessage(
                CrossLocalization.Translate("testing_start_test_title"),
                CrossLocalization.Translate("testing_start_test_description"));

            if (result)
            {
                await PlatformServices.Navigation.OpenTestPassing(testId, forSelfStudy);
            }
        }
        SwitchFrame createSwitchFrame()
        {
            var frame = new SwitchFrame(
                CrossLocalization.Translate("settings_language_system"),
                CrossLocalization.Translate("settings_language_system_description"))
            {
                Margin = _frameMargin
            };

            frame.Switch.SetBinding(Switch.IsToggledProperty, "IsSystemLanguage");
            return(frame);
        }
示例#22
0
        private async Task <KeyValuePair <string, HttpStatusCode> > saveMarks()
        {
            string body = "";
            string link = "";

            if (_title == CrossLocalization.Translate("practice_mark"))
            {
                link = Links.SaveSinglePract;
                SavePractSingle save = new SavePractSingle();
                foreach (var pract in _takedLabs.Practicals.Where(v => v.ShortName == SelectedShortName))
                {
                    save.practicalId = pract.PracticalId;
                    foreach (var practic in fullPractice.Students.Where(v => v.FullName == studentName))
                    {
                        save.studentId      = practic.StudentId;
                        save.showForStudent = ShowForStud;
                        save.mark           = Mark;
                        save.Comment        = Comment;
                        save.date           = DateTime.Today.ToString("dd.MM.yyyy");
                        foreach (var practMark in practic.PracticalsMarks.Where(v => v.PracticalId == save.practicalId))
                        {
                            save.id = practMark.StudentPracticalMarkId;
                        }
                    }
                }
                body = JsonController.ConvertObjectToJson(save);
            }
            else if (_title == CrossLocalization.Translate("stats_page_labs_rating"))
            {
                link = Links.SaveSingleLab;
                SaveLabsSingle save = new SaveLabsSingle();
                foreach (var lab in _takedLabs.Labs.Where(v => v.ShortName == SelectedShortName && v.SubGroup == _subGruop))
                {
                    save.labId = lab.LabId;
                    foreach (var labs in fullMarksLabs.Students.Where(v => v.FullName == studentName))
                    {
                        save.studentId      = labs.StudentId;
                        save.showForStudent = ShowForStud;
                        save.mark           = Mark;
                        save.Comment        = Comment;
                        save.date           = DateTime.Today.ToString("dd.MM.yyyy");
                        foreach (var labMark in labs.LabsMarks.Where(v => v.LabId == save.labId))
                        {
                            save.id = labMark.StudentLabMarkId;
                        }
                    }
                }
                body = JsonController.ConvertObjectToJson(save);
            }
            await _services.Navigation.ClosePage(false);

            return(await AppServicesController.Request(link, body));
        }
        Entry createGroupNumberEntry(Style style)
        {
            var username = new Entry
            {
                Style       = style,
                ReturnType  = ReturnType.Next,
                Placeholder = CrossLocalization.Translate("parental_enter_group_number")
            };

            username.SetBinding(Entry.TextProperty, "GroupNumber");
            return(username);
        }
示例#24
0
        SwitchFrame createSwitchFrame()
        {
            var frame = new SwitchFrame(
                CrossLocalization.Translate("settings_font_large"),
                CrossLocalization.Translate("settings_font_large_description"))
            {
                Margin = _frameMargin
            };

            frame.Switch.SetBinding(Switch.IsToggledProperty, "IsLargeFont");
            return(frame);
        }
示例#25
0
        /// <summary>
        /// Set error details.
        /// </summary>
        /// <param name="message">Error message.</param>
        /// <param name="isConnectionError">Is network connection issue.</param>
        /// <remarks>
        /// Can be <c>null</c> (if no error occurred).
        /// </remarks>
        public static void SetError(string message, bool isConnectionError)
        {
            if (message == null)
            {
                IsError           = false;
                IsConnectionError = false;
                return;
            }

            IsError           = true;
            IsConnectionError = isConnectionError;
            ErrorMessage      = CrossLocalization.Translate(message);
        }
        Entry createPatronymicnameEntry(Style style)
        {
            var username = new Entry
            {
                Style       = style,
                ReturnType  = ReturnType.Next,
                Margin      = _baseSpacing,
                Placeholder = CrossLocalization.Translate("patronymic")
            };

            username.SetBinding(Entry.TextProperty, "Patronymic");
            return(username);
        }
示例#27
0
        Label createCheckInLabel()
        {
            var new_user = new Label
            {
                Text      = CrossLocalization.Translate("new_user_check_in"),
                TextColor = Color.White,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalOptions       = LayoutOptions.StartAndExpand,
                FontSize = 18,
            };

            return(new_user);
        }
示例#28
0
        Entry createPasswordEntry(Style style)
        {
            var password = new Entry {
                Style       = style,
                IsPassword  = true,
                ReturnType  = ReturnType.Done,
                Margin      = _baseSpacing,
                Placeholder = CrossLocalization.Translate("login_password")
            };

            password.SetBinding(Entry.TextProperty, "Password");
            password.SetBinding(Entry.IsPasswordProperty, "IsPasswordHidden");
            return(password);
        }
        Picker createSecretQuestionPicker()
        {
            var questions = new Picker()
            {
                BackgroundColor = Color.White,
                Margin          = _baseSpacing,
                Title           = CrossLocalization.Translate("select_secret_question"),
                HeightRequest   = 50,
                ItemsSource     = SecretQuestions,
            };

            questions.SetBinding(Picker.SelectedItemProperty, "QuestionId");
            return(questions);
        }
        StackLayout createHiddenDetailsView()
        {
            var avgLabsView = createStatisticsView(
                CrossLocalization.Translate("stats_chart_average_labs"),
                Color.FromHex(Theme.Current.StatisticsChartLabsColor),
                "AverageLabs");

            var avgTestsView = createStatisticsView(
                CrossLocalization.Translate("stats_chart_average_tests"),
                Color.FromHex(Theme.Current.StatisticsChartTestsColor),
                "AverageTests");

            var avgPractView = createStatisticsView(
                CrossLocalization.Translate("stats_chart_average_pract"),
                Color.FromHex(Theme.Current.StatisticsChartPractColor),
                "AveragePract");

            var avgRatingView = createStatisticsView(
                CrossLocalization.Translate("stats_chart_rating"),
                Color.FromHex(Theme.Current.StatisticsChartRatingColor),
                "Rating");


            var avgStatsLayout = new StackLayout {
                Children =
                {
                    avgLabsView, avgTestsView, avgPractView, avgRatingView
                }
            };

            avgStatsLayout.SetBinding(IsVisibleProperty, "IsEnoughDetails");

            var notEnoughDataLabel = createStatisticsLabel(
                CrossLocalization.Translate("stats_chart_not_enough_data"), true);

            notEnoughDataLabel.SetBinding(IsVisibleProperty, "IsNotEnoughDetails");

            var hiddenDetailsView = new StackLayout {
                Padding  = _hiddenDetailsPadding,
                Children =
                {
                    avgStatsLayout,
                    notEnoughDataLabel
                }
            };

            hiddenDetailsView.SetBinding(IsVisibleProperty, "IsExpandedStatistics");
            return(hiddenDetailsView);
        }