private static SettingSection BuildGallerySection()
        {
            var section = new SettingSection(SystemUtil.GetStringResource("SettingSection_ContentsSync"));

            section.Add(new ToggleSetting(
                            new AppSettingData <bool>(SystemUtil.GetStringResource("Setting_PrioritizeOriginalSize"), SystemUtil.GetStringResource("Guide_PrioritizeOriginalSize"),
                                                      () => { return(ApplicationSettings.GetInstance().PrioritizeOriginalSizeContents); },
                                                      enabled => { ApplicationSettings.GetInstance().PrioritizeOriginalSizeContents = enabled; })));

            section.Add(new ComboBoxSetting(
                            new AppSettingData <int>(SystemUtil.GetStringResource("ContentTypes"), SystemUtil.GetStringResource("ContentTypesGuide"),
                                                     () => { return((int)ApplicationSettings.GetInstance().RemoteContentsSet); },
                                                     newValue =>
            {
                if (newValue != -1)
                {
                    ApplicationSettings.GetInstance().RemoteContentsSet = (ContentsSet)newValue;
                }
            },
                                                     SettingValueConverter.FromContentsSet(EnumUtil <ContentsSet> .GetValueEnumerable()))));

            section.Add(new ToggleSetting(
                            new AppSettingData <bool>(SystemUtil.GetStringResource("Setting_EnableSaveToOneDrive"), SystemUtil.GetStringResource("Guide_EnableSaveToOneDrive"),
                                                      () => { return(ApplicationSettings.GetInstance().SaveToOneDriveEnabled); },
                                                      enabled => { ApplicationSettings.GetInstance().SaveToOneDriveEnabled = enabled; })));

            return(section);
        }
Beispiel #2
0
        private static SettingSection BuildGallerySection()
        {
            var section = new SettingSection(SystemUtil.GetStringResource("SettingSection_ContentsSync"));

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("Setting_PrioritizeOriginalSize"),
                    Guide         = SystemUtil.GetStringResource("Guide_PrioritizeOriginalSize"),
                    StateProvider = () => ApplicationSettings.GetInstance().PrioritizeOriginalSizeContents,
                    StateObserver = enabled => ApplicationSettings.GetInstance().PrioritizeOriginalSizeContents = enabled
                }
            });

            section.Add(new ComboBoxSetting(new AppSettingData <int>()
            {
                Title         = SystemUtil.GetStringResource("ContentTypes"),
                Guide         = SystemUtil.GetStringResource("ContentTypesGuide"),
                StateProvider = () => (int)ApplicationSettings.GetInstance().RemoteContentsSet,
                StateObserver = newValue =>
                {
                    if (newValue != -1)
                    {
                        ApplicationSettings.GetInstance().RemoteContentsSet = (ContentsSet)newValue;
                    }
                },
                Candidates = SettingValueConverter.FromContentsSet(EnumUtil <ContentsSet> .GetValueEnumerable())
            }));

            return(section);
        }
Beispiel #3
0
        public void DoYourThing()
        {
            if (_typeProvider == null)
            {
                throw new ConfigurationException("You must specify a type provider used to scan for configuration settings.");
            }
            if (_registerAsSingleton == null)
            {
                throw new ConfigurationException("You must provide a registration action.");
            }

            var settingsReader        = _settingsReader ?? new AppSettingsReader(_excludedKeys.ToArray());
            var settingsOverrider     = _settingsOverrider ?? new NoOpSettingsOverrider();
            var settingValueConverter = new SettingValueConverter(_customValueParsers.ToArray());

            var settingsRegistrationService = new SettingsRegistrationService(_logger,
                                                                              _typeProvider,
                                                                              _settingKeyConventions.ToArray(),
                                                                              settingsReader,
                                                                              settingsOverrider,
                                                                              settingValueConverter,
                                                                              _allowConfigurationEntriesThatDoNotHaveSettingsClasses,
                                                                              _registerAsSingleton);

            settingsRegistrationService.RegisterConfigurationSettings();
        }
        public void DoYourThing()
        {
            if (_assemblies == null) throw new ConfigurationException("You must specify the assemblies to scan for configuration settings.");
            if (_registerAsSingleton == null) throw new ConfigurationException("You must provide a registration action.");

            var settingsReader = _settingsReader ?? new AppSettingsReader(_excludedKeys.ToArray());
            var settingValueConverter = new SettingValueConverter(_customValueParsers.ToArray());

            var appConfigConfigurationProvider = new SettingsRegistrationService(_assemblies,
                                                                                 _registerAsSingleton,
                                                                                 _allowConfigurationEntriesThatDoNotHaveSettingsClasses,
                                                                                 settingValueConverter,
                                                                                 settingsReader,
                                                                                 _settingKeyConventions.ToArray());
            appConfigConfigurationProvider.RegisterConfigurationSettings();
        }
        private async Task OnComboBoxChanged <T>(object sender, Capability <T> param, AsyncAction <T> action)
        {
            if (param == null || param.Candidates == null || param.Candidates.Count == 0)
            {
                return;
            }

            var selected       = (sender as ComboBox).SelectedIndex;
            var currentSetting = SettingValueConverter.GetSelectedIndex(param);

            if (selected != currentSetting)
            {
                return;
            }

            if (selected < 0 || param.Candidates.Count <= selected)
            {
                DebugUtil.Log("ignore out of range");
                return;
            }

            try
            {
                await action.Invoke(param.Candidates[selected]);

                return;
            }
            catch (RemoteApiException e)
            {
                DebugUtil.Log(() => "Failed to set parameter: " + e.StatusCode);
            }
            catch (NullReferenceException e)
            {
                DebugUtil.Log(() => "Failed to set parameter: " + e.Message);
            }
            await DataSource.Device.Observer.Refresh();
        }
Beispiel #6
0
        private static SettingSection BuildDisplaySection()
        {
            var section = new SettingSection(SystemUtil.GetStringResource("SettingSection_Display"));

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("DisplayTakeImageButtonSetting"),
                    Guide         = SystemUtil.GetStringResource("Guide_DisplayTakeImageButtonSetting"),
                    StateProvider = () => ApplicationSettings.GetInstance().IsShootButtonDisplayed,
                    StateObserver = enabled => ApplicationSettings.GetInstance().IsShootButtonDisplayed = enabled
                }
            });

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("DisplayHistogram"),
                    Guide         = SystemUtil.GetStringResource("Guide_Histogram"),
                    StateProvider = () => ApplicationSettings.GetInstance().IsHistogramDisplayed,
                    StateObserver = enabled => ApplicationSettings.GetInstance().IsHistogramDisplayed = enabled
                }
            });

            var FocusFrameSetting = new AppSettingData <bool>()
            {
                Title         = SystemUtil.GetStringResource("FocusFrameDisplay"),
                Guide         = SystemUtil.GetStringResource("Guide_FocusFrameDisplay"),
                StateProvider = () => ApplicationSettings.GetInstance().RequestFocusFrameInfo,
                StateObserver = enabled =>
                {
                    ApplicationSettings.GetInstance().RequestFocusFrameInfo = enabled;
                    // todo: support to show focus frames
                    //await SetupFocusFrame(enabled);
                    //if (!enabled) { _FocusFrameSurface.ClearFrames(); }
                }
            };

            section.Add(new ToggleSetting {
                SettingData = FocusFrameSetting
            });

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("LiveviewRotation"),
                    Guide         = SystemUtil.GetStringResource("LiveviewRotation_guide"),
                    StateProvider = () => ApplicationSettings.GetInstance().LiveviewRotationEnabled,
                    StateObserver = enabled =>
                    {
                        ApplicationSettings.GetInstance().LiveviewRotationEnabled = enabled;
                        // todo: support to rotate liveview image
                        //if (enabled && target != null && target.Status != null)
                        //{
                        //    RotateLiveviewImage(target.Status.LiveviewOrientationAsDouble);
                        //}
                        //else
                        //{
                        //    RotateLiveviewImage(0);
                        //}
                    }
                }
            });

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("FramingGrids"),
                    Guide         = SystemUtil.GetStringResource("Guide_FramingGrids"),
                    StateProvider = () => ApplicationSettings.GetInstance().FramingGridEnabled,
                    StateObserver = enabled =>
                    {
                        ApplicationSettings.GetInstance().FramingGridEnabled = enabled;
                        // screen_view_data.FramingGridDisplayed = enabled;
                    }
                }
            });

            var gridTypePanel = new ComboBoxSetting(new AppSettingData <int>()
            {
                Title         = SystemUtil.GetStringResource("AssistPattern"),
                StateProvider = () => (int)ApplicationSettings.GetInstance().GridType - 1,
                StateObserver = setting =>
                {
                    if (setting < 0)
                    {
                        return;
                    }
                    ApplicationSettings.GetInstance().GridType = (FramingGridTypes)(setting + 1);
                },
                Candidates = SettingValueConverter.FromFramingGrid(EnumUtil <FramingGridTypes> .GetValueEnumerable())
            });

            gridTypePanel.SetBinding(VisibilityProperty, new Binding
            {
                Source    = ApplicationSettings.GetInstance(),
                Path      = new PropertyPath(nameof(ApplicationSettings.FramingGridEnabled)),
                Mode      = BindingMode.OneWay,
                Converter = new BoolToVisibilityConverter(),
            });
            section.Add(gridTypePanel);

            var gridColorPanel = new ComboBoxSetting(new AppSettingData <int>()
            {
                Title         = SystemUtil.GetStringResource("FramingGridColor"),
                StateProvider = () => (int)ApplicationSettings.GetInstance().GridColor,
                StateObserver = setting =>
                {
                    if (setting < 0)
                    {
                        return;
                    }
                    ApplicationSettings.GetInstance().GridColor = (FramingGridColors)setting;
                },
                Candidates = SettingValueConverter.FromFramingGridColor(EnumUtil <FramingGridColors> .GetValueEnumerable())
            });

            gridColorPanel.SetBinding(VisibilityProperty, new Binding
            {
                Source    = ApplicationSettings.GetInstance(),
                Path      = new PropertyPath(nameof(ApplicationSettings.FramingGridEnabled)),
                Mode      = BindingMode.OneWay,
                Converter = new BoolToVisibilityConverter(),
            });
            section.Add(gridColorPanel);

            var fibonacciOriginPanel = new ComboBoxSetting(new AppSettingData <int>()
            {
                Title         = SystemUtil.GetStringResource("FibonacciSpiralOrigin"),
                StateProvider = () => (int)ApplicationSettings.GetInstance().FibonacciLineOrigin,
                StateObserver = setting =>
                {
                    if (setting < 0)
                    {
                        return;
                    }
                    ApplicationSettings.GetInstance().FibonacciLineOrigin = (FibonacciLineOrigins)setting;
                },
                Candidates = SettingValueConverter.FromFibonacciLineOrigin(EnumUtil <FibonacciLineOrigins> .GetValueEnumerable())
            });

            fibonacciOriginPanel.SetBinding(VisibilityProperty, new Binding
            {
                Source    = ApplicationSettings.GetInstance(),
                Path      = new PropertyPath(nameof(ApplicationSettings.IsFibonacciSpiralEnabled)),
                Mode      = BindingMode.OneWay,
                Converter = new BoolToVisibilityConverter(),
            });
            section.Add(fibonacciOriginPanel);

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("ForcePhoneView"),
                    Guide         = SystemUtil.GetStringResource("ForcePhoneView_Guide"),
                    StateProvider = () => ApplicationSettings.GetInstance().ForcePhoneView,
                    StateObserver = enabled => ApplicationSettings.GetInstance().ForcePhoneView = enabled
                }
            });

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("ShowKeyCheatSheet"),
                    Guide         = SystemUtil.GetStringResource("ShowKeyCheatSheet_Guide"),
                    StateProvider = () => ApplicationSettings.GetInstance().ShowKeyCheatSheet,
                    StateObserver = enabled => ApplicationSettings.GetInstance().ShowKeyCheatSheet = enabled
                }
            });

            return(section);
        }
        public void WeShouldThrowAnException(Type settingValueType, string settingValue)
        {
            var converter = new SettingValueConverter();

            Should.Throw <SettingParsingException>(() => converter.ParseSettingValue(settingValueType, settingValue));
        }
        public void TheCorrectValuesAndTypesShouldBeReturned(string stringValue, object expectedValue, Type settingValueType)
        {
            var settingValue = new SettingValueConverter().ParseSettingValue(settingValueType, stringValue);

            settingValue.ShouldBe(expectedValue);
        }
        public void WeShouldThrowAnException(Type settingValueType, string settingValue)
        {
            var converter = new SettingValueConverter();

            converter.ParseSettingValue(settingValueType, settingValue);
        }