Example #1
0
        private void ButtonAddSource_Click(object sender, EventArgs e)
        {
            if (!_machineAvailable)
            {
                return;
            }

            _disableStateChangedEvents = true;
            _selectedSource            = new DistributionSource();
            DistributionSources.Add(_selectedSource);
            DistributionSourcesChanged = true;
            DisplayPath(_selectedSource.Path);
            textBoxFilter.Text        = _selectedSource.Filter;
            checkBoxRecursive.Checked = _selectedSource.Recursive;
            checkBoxInclusive.Checked = _selectedSource.Inclusive;
            ListViewItem item = listViewSources.Items.Add(new ListViewItem(new[]
            {
                _selectedSource.Path ?? UNSPECIFIED_PATH,
                _selectedSource.Filter,
                _selectedSource.Recursive.ToString(CultureInfo.InvariantCulture),
                _selectedSource.Inclusive.ToString(CultureInfo.InvariantCulture)
            })
            {
                Tag = _selectedSource
            });

            _disableStateChangedEvents = false;
            item.Selected       = true;
            panelSource.Visible = true;
            EnableControls();
            textBoxPath.Focus();
        }
Example #2
0
        private void ButtonRemoveSource_Click(object sender, EventArgs e)
        {
            if (!_machineAvailable)
            {
                return;
            }

            if (listViewSources.SelectedItems.Count == 0)
            {
                return;
            }

            _selectedSource = (DistributionSource)listViewSources.SelectedItems[0].Tag;
            DistributionSources.Remove(_selectedSource);
            DistributionSourcesChanged = true;
            listViewSources.Items.Remove(listViewSources.SelectedItems[0]);
            _selectedSource = null;
            EnableControls();
        }
Example #3
0
        private bool ValidateSources()
        {
            IDictionary <DistributionSource, List <string> > invalidSources = DistributionSources
                                                                              .Select(source => new
            {
                Source   = source,
                Messages = DistributionSourceIsValid(source).ToList()
            })
                                                                              .Where(x => x.Messages.Count > 0)
                                                                              .ToDictionary(x => x.Source, x => x.Messages);

            if (invalidSources.Count > 0)
            {
                int invalidSourceCount = invalidSources.Keys.Count;
                Messenger.ShowError($"Distribution source{(invalidSourceCount == 1 ? string.Empty : "s")} invalid",
                                    "One or more distribution source property invalid. See details for more information.",
                                    invalidSources.Aggregate(string.Empty, (x, y) => x + Environment.NewLine + Environment.NewLine
                                                             + y.Value.Select(z => new { Source = y.Key, Message = z })
                                                             .Aggregate(string.Empty, (a, b) => a + Environment.NewLine + Machine + " > " + Application + ": " + b.Message).Trim()).Trim());
                return(false);
            }
            return(true);
        }