Пример #1
0
        private async void Verbosity_Click(object sender, RoutedEventArgs e)
        {
            var level = SettingsService.Current.VerbosityLevel;

            var dialog = new TLContentDialog();
            var stack  = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 0, Content = "Assert", IsChecked = level == 0
            });
            stack.Children.Add(new RadioButton {
                Tag = 1, Content = "Error", IsChecked = level == 1
            });
            stack.Children.Add(new RadioButton {
                Tag = 2, Content = "Warning", IsChecked = level == 2
            });
            stack.Children.Add(new RadioButton {
                Tag = 3, Content = "Info", IsChecked = level == 3
            });
            stack.Children.Add(new RadioButton {
                Tag = 4, Content = "Debug", IsChecked = level == 4
            });
            stack.Children.Add(new RadioButton {
                Tag = 5, Content = "Verbose", IsChecked = level == 5
            });

            dialog.Title               = "Verbosity Level";
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var newLevel = 1;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        newLevel = (int)current.Tag;
                        break;
                    }
                }

                SettingsService.Current.VerbosityLevel = newLevel;
                TLContainer.Current.Resolve <IProtoService>().Send(new SetLogVerbosityLevel(newLevel));

                Verbosity.Badge = Enum.GetName(typeof(VerbosityLevel), (VerbosityLevel)SettingsService.Current.VerbosityLevel);
            }
        }
Пример #2
0
        private async void AutolockExecute()
        {
            var timeout = AutolockTimeout + 0;

            var dialog = new TLContentDialog();
            var stack  = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 0, Content = Locale.FormatAutoLock(0), IsChecked = timeout == 0
            });
            stack.Children.Add(new RadioButton {
                Tag = 1 * 60, Content = Locale.FormatAutoLock(1 * 60), IsChecked = timeout == 1 * 60
            });
            stack.Children.Add(new RadioButton {
                Tag = 5 * 60, Content = Locale.FormatAutoLock(5 * 60), IsChecked = timeout == 5 * 60
            });
            stack.Children.Add(new RadioButton {
                Tag = 1 * 60 * 60, Content = Locale.FormatAutoLock(1 * 60 * 60), IsChecked = timeout == 1 * 60 * 60
            });
            stack.Children.Add(new RadioButton {
                Tag = 5 * 60 * 60, Content = Locale.FormatAutoLock(5 * 60 * 60), IsChecked = timeout == 5 * 60 * 60
            });

            dialog.Title               = Strings.Resources.AutoLock;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = 1;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (int)current.Tag;
                        break;
                    }
                }

                AutolockTimeout = mode;
                InactivityHelper.Initialize(mode);
            }
        }
        private async void ChangeTtlExecute()
        {
            var enabled = CacheService.Options.UseStorageOptimizer;
            var ttl     = CacheService.Options.StorageMaxTimeFromLastAccess;

            var dialog = new TLContentDialog();
            var stack  = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 3, Content = Locale.Declension("Days", 3), IsChecked = enabled && ttl == 3 * 60 * 60 * 24
            });
            stack.Children.Add(new RadioButton {
                Tag = 7, Content = Locale.Declension("Weeks", 1), IsChecked = enabled && ttl == 7 * 60 * 60 * 24
            });
            stack.Children.Add(new RadioButton {
                Tag = 30, Content = Locale.Declension("Months", 1), IsChecked = enabled && ttl == 30 * 60 * 60 * 24
            });
            stack.Children.Add(new RadioButton {
                Tag = 0, Content = Strings.Resources.KeepMediaForever, IsChecked = !enabled
            });

            dialog.Title               = Strings.Resources.KeepMedia;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = 0;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (int)current.Tag;
                        break;
                    }
                }

                CacheService.Options.StorageMaxTimeFromLastAccess = mode * 60 * 60 * 24;
                CacheService.Options.UseStorageOptimizer          = mode > 0;

                RaisePropertyChanged(() => FilesTtl);
            }
        }
Пример #4
0
        private async void AddExecute()
        {
            var types = new List <PassportElementType>();

            types.Add(new PassportElementTypePhoneNumber());
            types.Add(new PassportElementTypeEmailAddress());
            types.Add(new PassportElementTypePersonalDetails());
            types.Add(new PassportElementTypePassport());
            types.Add(new PassportElementTypeInternalPassport());
            types.Add(new PassportElementTypePassportRegistration());
            types.Add(new PassportElementTypeTemporaryRegistration());
            types.Add(new PassportElementTypeIdentityCard());
            types.Add(new PassportElementTypeDriverLicense());
            types.Add(new PassportElementTypeAddress());
            types.Add(new PassportElementTypeUtilityBill());
            types.Add(new PassportElementTypeBankStatement());
            types.Add(new PassportElementTypeRentalAgreement());

            foreach (var element in Items)
            {
                var type    = element.ToElementType();
                var already = types.FirstOrDefault(x => x.TypeEquals(type));

                if (already != null)
                {
                    types.Remove(already);
                }
            }

            var combo = new ComboBox();

            combo.ItemsSource = types;
            //combo.DisplayMemberPath = "Name";

            var dialog = new TLContentDialog();

            dialog.Content = combo;

            await dialog.ShowQueuedAsync();
        }
Пример #5
0
        private async void SuggestExecute()
        {
            var dialog = new TLContentDialog();
            var stack  = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = StickersSuggestionMode.All, Content = Strings.Resources.SuggestStickersAll, IsChecked = SuggestStickers == StickersSuggestionMode.All
            });
            stack.Children.Add(new RadioButton {
                Tag = StickersSuggestionMode.Installed, Content = Strings.Resources.SuggestStickersInstalled, IsChecked = SuggestStickers == StickersSuggestionMode.Installed
            });
            stack.Children.Add(new RadioButton {
                Tag = StickersSuggestionMode.None, Content = Strings.Resources.SuggestStickersNone, IsChecked = SuggestStickers == StickersSuggestionMode.None
            });

            dialog.Title               = Strings.Resources.SuggestStickers;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = StickersSuggestionMode.All;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (StickersSuggestionMode)current.Tag;
                        break;
                    }
                }

                SuggestStickers = mode;
            }
        }
Пример #6
0
        private async void UseLessDataExecute()
        {
            var dialog = new TLContentDialog();
            var stack  = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 0, Content = Strings.Resources.UseLessDataNever, IsChecked = UseLessData == libtgvoip.DataSavingMode.Never
            });
            stack.Children.Add(new RadioButton {
                Tag = 1, Content = Strings.Resources.UseLessDataOnMobile, IsChecked = UseLessData == libtgvoip.DataSavingMode.MobileOnly
            });
            stack.Children.Add(new RadioButton {
                Tag = 2, Content = Strings.Resources.UseLessDataAlways, IsChecked = UseLessData == libtgvoip.DataSavingMode.Always
            });

            dialog.Title               = Strings.Resources.VoipUseLessData;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = 1;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (int)current.Tag;
                        break;
                    }
                }

                UseLessData = (libtgvoip.DataSavingMode)mode;
            }
        }
        private async void DistanceUnitsExecute()
        {
            var dialog = new TLContentDialog();
            var stack  = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = DistanceUnits.Automatic, Content = Strings.Resources.DistanceUnitsAutomatic, IsChecked = DistanceUnits == DistanceUnits.Automatic
            });
            stack.Children.Add(new RadioButton {
                Tag = DistanceUnits.Kilometers, Content = Strings.Resources.DistanceUnitsKilometers, IsChecked = DistanceUnits == DistanceUnits.Kilometers
            });
            stack.Children.Add(new RadioButton {
                Tag = DistanceUnits.Miles, Content = Strings.Resources.DistanceUnitsMiles, IsChecked = DistanceUnits == DistanceUnits.Miles
            });

            dialog.Title               = Strings.Resources.DistanceUnitsTitle;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = DistanceUnits.Automatic;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (DistanceUnits)current.Tag;
                        break;
                    }
                }

                DistanceUnits = mode;
            }
        }
Пример #8
0
        private async void DownloadLocationExecute()
        {
            var dialog = new TLContentDialog();
            var stack  = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 1, Content = "Temp folder, cleared on logout or uninstall", IsChecked = FilesDirectory == null
            });
            stack.Children.Add(new RadioButton {
                Tag = 2, Content = "Custom folder, cleared only manually", IsChecked = FilesDirectory != null
            });

            dialog.Title               = "Choose download location";
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = 1;
                var path = FilesDirectory + string.Empty;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (int)current.Tag;
                        break;
                    }
                }

                switch (mode)
                {
                case 0:
                    break;

                case 1:
                    FilesDirectory = null;
                    break;

                case 2:
                    var picker = new FolderPicker();
                    picker.SuggestedStartLocation = PickerLocationId.Downloads;
                    picker.FileTypeFilter.Add("*");

                    var folder = await picker.PickSingleFolderAsync();

                    if (folder != null)
                    {
                        StorageApplicationPermissions.FutureAccessList.AddOrReplace("FilesDirectory", folder);
                        FilesDirectory = folder.Path;
                    }

                    break;
                }

                if (string.Equals(path, FilesDirectory, StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }

                ProtoService.Send(new Close());
            }
        }