Beispiel #1
0
        public override void Initialize(IConfig config)
        {
            // Prepare disposables
            _disposables?.Dispose();
            _disposables = new CompositeDisposable();

            // Place this under the Ui parent
            ParentId = nameof(ConfigIds.Destinations);

            // Make sure Commit/Rollback is called on the IUiConfiguration
            config.Register(CoreConfiguration);

            // automatically update the DisplayName
            var greenshotLanguageBinding = GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsDestinationPicker));

            // Make sure the greenshotLanguageBinding is disposed when this is no longer active
            _disposables.Add(greenshotLanguageBinding);

            UsedDestinations.Clear();
            if (CoreConfiguration.PickerDestinations.Any())
            {
                foreach (var outputDestination in CoreConfiguration.PickerDestinations)
                {
                    var pickerDestination = AllDestinations
                                            .Where(destination => !"Picker".Equals(destination.Metadata.Designation))
                                            .Where(destination => destination.Value.IsActive)
                                            .Where(destination => outputDestination == destination.Value.Designation)
                                            .Select(d => d.Value).FirstOrDefault();

                    if (pickerDestination != null)
                    {
                        UsedDestinations.Add(pickerDestination);
                    }
                }
            }
            else
            {
                foreach (var pickerDestination in AllDestinations
                         .Where(destination => !"Picker".Equals(destination.Metadata.Designation))
                         .Where(destination => destination.Value.IsActive)
                         .OrderBy(destination => destination.Metadata.Priority)
                         .ThenBy(destination => destination.Value.Description)
                         .Select(d => d.Value))
                {
                    UsedDestinations.Add(pickerDestination);
                }
            }
            AvailableDestinations.Clear();
            foreach (var destination in AllDestinations
                     .Where(destination => !"Picker".Equals(destination.Metadata.Designation))
                     .Where(destination => destination.Value.IsActive)
                     .Where(destination => UsedDestinations.All(pickerDestination => pickerDestination.Designation != destination.Value.Designation))
                     .OrderBy(destination => destination.Metadata.Priority).ThenBy(destination => destination.Value.Description)
                     .Select(d => d.Value))
            {
                AvailableDestinations.Add(destination);
            }
            base.Initialize(config);
        }
Beispiel #2
0
        public override void Initialize(IConfig config)
        {
            // Prepare disposables
            _disposables?.Dispose();

            // Place this under the Ui parent
            ParentId = nameof(ConfigIds.InternalDestinations);

            // Make sure Commit/Rollback is called on the IUiConfiguration
            config.Register(CoreConfiguration);

            // automatically update the DisplayName
            _disposables = new CompositeDisposable
            {
                GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsDestinationPicker))
            };

            UsedDestinations.Clear();
            if (CoreConfiguration.PickerDestinations.Any())
            {
                foreach (var outputDestination in CoreConfiguration.PickerDestinations)
                {
                    var pickerDestination = _destinationHolder.SortedActiveDestinations
                                            .Where(destination => !"Picker".Equals(destination.Designation))
                                            .FirstOrDefault(destination => outputDestination == destination.Designation);

                    if (pickerDestination != null)
                    {
                        UsedDestinations.Add(pickerDestination);
                    }
                }
            }
            else
            {
                foreach (var pickerDestination in _destinationHolder.SortedActiveDestinations
                         .Where(destination => !"Picker".Equals(destination.Designation)))
                {
                    UsedDestinations.Add(pickerDestination);
                }
            }
            AvailableDestinations.Clear();
            foreach (var destination in _destinationHolder.SortedActiveDestinations
                     .Where(destination => !"Picker".Equals(destination.Designation))
                     .Where(destination => UsedDestinations.All(pickerDestination => pickerDestination.Designation != destination.Designation)))
            {
                AvailableDestinations.Add(destination);
            }
            base.Initialize(config);
        }
        public override void Initialize(IConfig config)
        {
            // Prepare disposables
            _disposables?.Dispose();

            // Place this under the Ui parent
            ParentId = nameof(ConfigIds.InternalDestinations);

            // Make sure Commit/Rollback is called on the IUiConfiguration
            config.Register(CoreConfiguration);

            // automatically update the DisplayName
            _disposables = new CompositeDisposable
            {
                GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsDestinationClipboard))
            };
            DisplayName = typeof(ClipboardDestination).GetDesignation();

            UsedDestinations.Clear();

            if (CoreConfiguration.ClipboardFormats.Any())
            {
                foreach (var clipboardFormat in CoreConfiguration.ClipboardFormats)
                {
                    UsedDestinations.Add(clipboardFormat.ToString());
                }
            }

            AvailableDestinations.Clear();
            foreach (var clipboardFormat in Enum.GetNames(typeof(ClipboardFormats)))
            {
                if (clipboardFormat == ClipboardFormats.NONE.ToString())
                {
                    continue;
                }
                AvailableDestinations.Add(clipboardFormat);
            }
            base.Initialize(config);
        }