Inheritance: Livet.NotificationObject, IZoomFactor
        public SettingsViewModel()
        {
            if (Helper.IsInDesignMode) return;

            this.Libraries = App.ProductInfo.Libraries.Aggregate(
                new List<BindableTextViewModel>(),
                (list, lib) =>
                {
                    list.Add(new BindableTextViewModel { Text = list.Count == 0 ? "Build with " : ", " });
                    list.Add(new HyperlinkViewModel { Text = lib.Name.Replace(' ', Convert.ToChar(160)), Uri = lib.Url });
                    // プロダクト名の途中で改行されないように、space を non-break space に置き換えてあげてるんだからねっっ
                    return list;
                });

            this.Cultures = new[] { new CultureViewModel { DisplayName = "(auto)" } }
                .Concat(ResourceService.Current.SupportedCultures
                    .Select(x => new CultureViewModel { DisplayName = x.EnglishName, Name = x.Name })
                    .OrderBy(x => x.DisplayName))
                .ToList();

            this.CompositeDisposable.Add(new PropertyChangedEventListener(Settings.Current)
            {
                (sender, args) => this.RaisePropertyChanged(args.PropertyName),
            });

            this._IsDarkTheme = ThemeService.Current.Theme == Theme.Dark;
            this._IsLightTheme = ThemeService.Current.Theme == Theme.Light;

            var zoomFactor = new BrowserZoomFactor { Current = Settings.Current.BrowserZoomFactor };
            this.CompositeDisposable.Add(new PropertyChangedEventListener(zoomFactor)
            {
                { "Current", (sender, args) => Settings.Current.BrowserZoomFactor = zoomFactor.Current },
            });
            this.BrowserZoomFactor = zoomFactor;
        }
Esempio n. 2
0
		public SettingsViewModel()
		{
			if (Helper.IsInDesignMode) return;

			this.FlashQualityList = this.FlashQualities.ToList();
			this.FlashWindowList = this.FlashWindows.ToList();
            this.BrowserVerticalPositionList = this.BrowserVerticalPositions.ToList();
            this.BrowserHorizontalPositionList = this.BrowserHorizontalPositions.ToList();

			this.Libraries = App.ProductInfo.Libraries.Aggregate(
				new List<BindableTextViewModel>(),
				(list, lib) =>
				{
					list.Add(new BindableTextViewModel { Text = list.Count == 0 ? "Build with " : ", " });
					list.Add(new HyperlinkViewModel { Text = lib.Name.Replace(' ', Convert.ToChar(160)), Uri = lib.Url });
					// プロダクト名の途中で改行されないように、space を non-break space に置き換えてあげてるんだからねっっ
					return list;
				});

			this.Cultures = new[] { new CultureViewModel { DisplayName = "(auto)" } }
				.Concat(ResourceService.Current.SupportedCultures
					.Select(x => new CultureViewModel { DisplayName = x.EnglishName, Name = x.Name })
					.OrderBy(x => x.DisplayName))
				.ToList();

			this.CompositeDisposable.Add(new PropertyChangedEventListener(Settings.Current)
			{
				(sender, args) => this.RaisePropertyChanged(args.PropertyName),
			});

			this._IsDarkTheme = ThemeService.Current.Theme == Theme.Dark;
			this._IsLightTheme = ThemeService.Current.Theme == Theme.Light;

			var zoomFactor = new BrowserZoomFactor { Current = Settings.Current.BrowserZoomFactor };
			this.CompositeDisposable.Add(new PropertyChangedEventListener(zoomFactor)
			{
				{ "Current", (sender, args) => Settings.Current.BrowserZoomFactor = zoomFactor.Current },
			});
			this.BrowserZoomFactor = zoomFactor;

			var orientationMode = new WindowOrientaionMode { CurrentMode = Settings.Current.OrientationMode };
			orientationMode.Refresh();
			this.CompositeDisposable.Add(orientationMode);
			this.CompositeDisposable.Add(new PropertyChangedEventListener(orientationMode)
			{
                { "CurrentMode", (sender, args) => Settings.Current.OrientationMode = orientationMode.CurrentMode },
			});
			Settings.Current.Orientation = orientationMode;

			this.CompositeDisposable.Add(new PropertyChangedEventListener(KanColleClient.Current.Translations)
			{
				(sender, args) => this.RaisePropertyChanged(args.PropertyName),
			});

			if (Settings.Current.EnableUpdateNotification)
			{
				this.CheckForUpdates();
			}

			this.ViewRangeSettingsCollection = ViewRangeCalcLogic.Logics
				.Select(x => new ViewRangeSettingsViewModel(x))
				.ToList();

			this.ReloadPlugins();
		}
		public SettingsViewModel()
		{
			if (Helper.IsInDesignMode) return;

			this.Libraries = AppProductInfo.Libraries.Aggregate(
				new List<BindableTextViewModel>(),
				(list, lib) =>
				{
					list.Add(new BindableTextViewModel { Text = list.Count == 0 ? "Build with " : ", " });
					list.Add(new HyperlinkViewModel { Text = lib.Name.Replace(' ', Convert.ToChar(160)), Uri = lib.Url });
					// プロダクト名の途中で改行されないように、space を non-break space に置き換えてあげてるんだからねっっ
					return list;
				});

			this.Cultures = new[] { new CultureViewModel { DisplayName = "(auto)" } }
				.Concat(ResourceService.Current.SupportedCultures
					.Select(x => new CultureViewModel { DisplayName = x.EnglishName, Name = x.Name })
					.OrderBy(x => x.DisplayName))
				.ToList();

			this.CompositeDisposable.Add(new PropertyChangedEventListener(Settings.Current)
			{
				(sender, args) => this.RaisePropertyChanged(args.PropertyName),
			});

			var zoomFactor = new BrowserZoomFactor { Current = Settings.Current.BrowserZoomFactor };
			this.CompositeDisposable.Add(new PropertyChangedEventListener(zoomFactor)
			{
				{ "Current", (sender, args) => Settings.Current.BrowserZoomFactor = zoomFactor.Current },
			});
			this.BrowserZoomFactor = zoomFactor;

			this.ViewRangeSettingsCollection = ViewRangeCalcLogic.Logics
				.Select(x => new ViewRangeSettingsViewModel(x))
				.ToList();

			this.ReloadPlugins();

            Fiddler.FiddlerApplication.OnReadRequestBuffer += (_, e) => { System.Threading.Interlocked.Add(ref _sentBytes, e.iCountOfBytes);RaisePropertyChanged(nameof(SentBytes)); };
            Fiddler.FiddlerApplication.OnReadResponseBuffer += (_, e) => { System.Threading.Interlocked.Add(ref _receivedBytes, e.iCountOfBytes); RaisePropertyChanged(nameof(ReceivedBytes)); };
            Settings.Current.PropertyChanged += (o, e) => {
                if (e.PropertyName == nameof(Settings.Current.FlashQuality)) RaisePropertyChanged(e.PropertyName);
                if (e.PropertyName == nameof(Settings.Current.FlashRenderMode)) RaisePropertyChanged(e.PropertyName);
            };
		}