예제 #1
0
        public SettingStore(Options option, UserOptions userOption)
        {
            ReadOnlyReactiveProperty <Color> convert(ReactiveProperty <Color?> r, Color d, Func <VSCodeConfigLoader, Color?> func)
            {
                return(r.CombineLatest(UserOptionEnable, UserOptionFindVSCExtConfig, VSCodeConfig, (c, e, ve, vc) => {
                    if (ve && vc?.IsLoaded == true)
                    {
                        var tmp = func(vc);
                        if (tmp.HasValue)
                        {
                            return tmp.Value;
                        }
                    }
                    return (e && c.HasValue) ? c.Value : d;
                }).ToReadOnlyReactiveProperty(d));
            }

            ReactiveProperty <Color?> to_property_as_sync(Expression <Func <UserOptions, string> > func)
            {
                return(UserOption.ToReactivePropertyAsSynchronized <UserOptions, string, Color?>(
                           func,
                           convert: x =>
                           Common.TryConvertColor(x),
                           convertBack: x =>
                           x.HasValue ? Common.ConvertColor(x.Value) : ""
                           ));
            }

            UserOption = userOption;

            SolutionFilePath = new ReactiveProperty <string>();
            SolutionFilePath.Subscribe(x =>
            {
                // VSCodeConfig.Value = VSCodeConfigLoader.FindFromSolutionDir(x);
            });


            VSCodeConfig = SolutionFilePath.Select(x => VSCodeConfigLoader.FindFromSolutionDir(x)).ToReadOnlyReactiveProperty();

            UserActiveBackground   = to_property_as_sync(x => x.ActiveBackground);
            UserActiveForeground   = to_property_as_sync(x => x.ActiveForeground);
            UserInActiveBackground = to_property_as_sync(x => x.InActiveBackground);
            UserInActiveForeground = to_property_as_sync(x => x.InActiveForeground);

            UserOptionEnable           = UserOption.ToReactivePropertyAsSynchronized(x => x.IsEnabled);
            UserOptionFindVSCExtConfig = UserOption.ToReactivePropertyAsSynchronized(x => x.IsFindVSCExtConfig);
            IsPenguin = option.Penguin;

            ActiveBackground   = convert(UserActiveBackground, option.DefaultActiveBackgroundColor, x => x.ActiveBackground);
            ActiveForeground   = convert(UserActiveForeground, option.DefaultActiveForegroundColor, x => x.ActiveForeground);
            InActiveBackground = convert(UserInActiveBackground, option.DefaultInActiveBackgroundColor, x => x.InActiveBackground);
            InActiveForeground = convert(UserInActiveForeground, option.DefaultInActiveForegroundColor, x => x.InActiveForeground);
        }
예제 #2
0
        public static VSCodeConfigLoader FindFromSolutionDir(string sln)
        {
            if (sln == null)
            {
                return(null);
            }
            var d = Directory.GetParent(sln);

            while (d != null)
            {
                var s = new VSCodeConfigLoader(d.FullName);
                if (s.IsLoaded)
                {
                    return(s);
                }
                d = d.Parent;
            }
            return(null);
        }