Ejemplo n.º 1
0
        public ConfigurationViewModel()
        {
            // ComboBoxの初期値を設定するにはItemsSourceで利用しているインスタンスの中から指定する必要がある
            SelectedSwatch = new ReactivePropertySlim <Swatch>(Swatches.FirstOrDefault(s => s.Name == ThemeService.CurrentTheme.Name));
            SelectedSwatch.Subscribe(s => ChangeTheme(s)).AddTo(CompositeDisposable);

            var backupPath = UserConfigurationManager.Instance.GetConfiguration <BackupPathConfig>(ConfigKey.BackupPath);

            BackupPath = new ReactivePropertySlim <string>(backupPath?.DirectoryPath);

            var favorites = UserConfigurationManager.Instance.GetConfiguration <FavoriteWorkTasksConfig>(ConfigKey.FavoriteWorkTask);

            FavoriteWorkTasks = new ObservableCollection <FavoriteWorkTask>(favorites?.FavoriteWorkTasks ?? new FavoriteWorkTask[0]);

            var maps = UserConfigurationManager.Instance.GetConfiguration <ScheduleTitleMapConfig>(ConfigKey.ScheduleTitleMap)?.ScheduleTitleMaps;

            if (maps == null || maps.Count() == 0)
            {
                // 新設定が未登録なら旧設定をとる
                var config = JsonFileIO.Deserialize <TimeRecorderConfiguration>("TimeRecorderConfiguration.json") ?? new TimeRecorderConfiguration();
                maps = config.WorkTaskBuilderConfig.TitleMappers?.Select(t => t.ConvertToScheduleTitleMap()).ToArray();
            }
            ScheduleTitleMaps = new ObservableCollection <ScheduleTitleMap>(maps ?? new ScheduleTitleMap[0]);

            ShowFavoriteDescription = new ReactivePropertySlim <bool>(FavoriteWorkTasks.Count == 0);
            ShowScheduleDescription = new ReactivePropertySlim <bool>(ScheduleTitleMaps.Count == 0);

            var url = UserConfigurationManager.Instance.GetConfiguration <WorkingHourImportApiUrlConfig>(ConfigKey.WorkingHourImportApiUrl);

            WorkingHourImportUrl = new ReactivePropertySlim <string>(url?.URL);
        }
Ejemplo n.º 2
0
        private void SortSwatches(ColorSortType sortType, ListSortDirection sortDirection = ListSortDirection.Ascending)
        {
            int sd = sortDirection.Equals(ListSortDirection.Ascending) ? 1 : -1;

            switch (sortType)
            {
            case ColorSortType.Luminocity:
                Swatches.Sort((a, b) =>
                {
                    var aa = a.Color.Luminosity;
                    var bb = b.Color.Luminosity;
                    return(sd * aa.CompareTo(bb));
                });
                break;

            case ColorSortType.Saturation:
                Swatches.Sort((a, b) => sd * a.Color.Saturation.CompareTo(b.Color.Saturation));
                break;

            case ColorSortType.Hue:
                Swatches.Sort((a, b) =>
                {
                    var aa = a.Color.Hue + a.Color.Luminosity;
                    var bb = b.Color.Hue + b.Color.Luminosity;
                    return(sd * aa.CompareTo(bb));
                });
                Swatches.Sort((a, b) => sd * a.Color.Hue.CompareTo(b.Color.Hue));
                break;

            case ColorSortType.Name:
                Swatches.Sort((a, b) => sd * a.Name.CompareTo(b.Name));
                break;
            }
        }
Ejemplo n.º 3
0
        public Hue GetAccent(Theme theme)
        {
            var colour = theme.GetAccentColor();
            var swatch = Swatches.Lookup(colour);

            return(swatch.Convert(s => new Hue(s.Name, s.AccentExemplarHue.Name, s.AccentExemplarHue.Foreground, s.AccentExemplarHue.Color))
                   .ValueOrThrow(() => new ArgumentOutOfRangeException(colour)));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 设置默认样式
        /// </summary>
        /// <param name="swatch"></param>
        public void ApplyDefault(string skinName)
        {
            var Swatch = Swatches.FirstOrDefault(t => t.Name.Equals(skinName));

            if (Swatch != null)
            {
                new PaletteHelper().ReplacePrimaryColor(Swatch);
            }
        }
Ejemplo n.º 5
0
        private void LoadSwatches()
        {
            Logger.Log.Debug("Loading");

            foreach (Swatch s in Library.Swatches)
            {
                Swatches.Add(new SwatchViewModel(MainViewModel, s));
            }

            Logger.Log.DebugFormat("Loaded Swatches[{0}]", Swatches.Count);
        }
 private void RefreshPreview(string primary, string accent)
 {
     if (!string.IsNullOrWhiteSpace(primary))
     {
         var primarySwatch = Swatches.FirstOrDefault(s => s.Name == primary);
         RefreshPrimaryPreview(primarySwatch);
     }
     if (!string.IsNullOrWhiteSpace(accent))
     {
         var accentSwatch = Swatches.FirstOrDefault(s => s.Name == accent);
         RefreshAccentPreview(accentSwatch);
     }
 }
        public void RestoreColors()
        {
            var primary = Swatches.FirstOrDefault(s => s.Name == Configuration.PrimaryColor);
            var accent  = Swatches.FirstOrDefault(s => s.Name == Configuration.AccentColor);

            if (primary != null)
            {
                ChoosePrimaryColor(primary);
            }
            if (accent != null)
            {
                ChooseAccentColor(accent);
            }
            DarkMode = Configuration.DarkMode;
        }
Ejemplo n.º 8
0
        public void Dispose()
        {
            Logger.Log.Debug("Disposing");

            Library = null;

            Swatches.Clear();
            Swatches = null;

            MainViewModel = null;

            Library = null;

            Logger.Log.Debug("Disposed");
        }
Ejemplo n.º 9
0
 private void UpdateAll()
 {
     _projectDirectory = Configuration.ProjectDirectory;
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ProjectDirectory)));
     _modelSystemDirectory = Configuration.ModelSystemDirectory;
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ModelSystemDirectory)));
     _hostPort = Configuration.HostPort;
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(HostPort)));
     if (Configuration.PrimaryColour != null)
     {
         PrimarySwatch = Swatches.First((s) => s.Name == Configuration.PrimaryColour);
         PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PrimarySwatch)));
     }
     if (Configuration.AccentColour != null)
     {
         AccentSwatch = AccentSwatches.First((s) => s.Name == Configuration.AccentColour);
         PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(AccentSwatch)));
     }
     IsDarkTheme = Configuration.IsDarkTheme;
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsDarkTheme)));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LocalHostButtonName)));
 }
Ejemplo n.º 10
0
 private void ScrollSwatchesToTop(object sender, System.EventArgs e)
 {
     // Otherwise it stays in the old position but all the swatches change.
     Swatches.ScrollTo(0);
 }