예제 #1
0
        /// <summary>
        /// Create a property dialog for an existing source
        /// </summary>
        /// <param name="source">Source of type ObsSource</param>
        public TestProperties(ObsSource source)
            : this()
        {
            this.source = source;
            ObsData sourceSettings = source.GetSettings();

            view = new PropertiesView(sourceSettings, source, source.GetProperties, source.GetDefaults, source.Update);
            propertyPanel.Controls.Add(view);

            undoButton.Click += (sender, args) =>
            {
                view.ResetChanges();
            };

            defaultButton.Click += (sender, args) =>
            {
                view.ResetToDefaults();
            };

            okButton.Click += (o, args) =>
            {
                view.UpdateSettings();
                DialogResult = DialogResult.OK;
                Close();
            };

            cancelButton.Click += (o, args) =>
            {
                view.ResetChanges();
                DialogResult = DialogResult.Cancel;
                Close();
            };
        }
예제 #2
0
        /// <summary>
        /// Create a property dialog for an existing source
        /// </summary>
        /// <param name="source">Source of type ObsSource</param>
        public TestFilter(Source source)
            : this()
        {
            FilterSource   = source;
            sourceSettings = FilterSource.GetSettings();

            FilterListBox.DisplayMember = "Name";
            FilterListBox.DataSource    = FilterSource.Filters;

            oldfilters = FilterSource.Filters;

            undoButton.Enabled    = false;
            defaultButton.Enabled = false;

            if (FilterSource.Filters.Any())
            {
                Select(FilterSource.Filters.First());
                undoButton.Enabled    = true;
                defaultButton.Enabled = true;
            }

            defaultButton.Click += (sender, args) =>
            {
                view.ResetToDefaults();
            };

            okButton.Click += (o, args) =>
            {
                if (view != null)
                {
                    view.UpdateSettings();
                }
                DialogResult = DialogResult.OK;
                Close();
            };

            cancelButton.Click += (o, args) =>
            {
                FilterSource.ClearFilters();

                foreach (Filter oldfilter in oldfilters)
                {
                    FilterSource.AddFilter(oldfilter);
                }

                DialogResult = DialogResult.Cancel;
                Close();
            };

            undoButton.Click += (sender, args) =>
            {
                view.ResetChanges();
            };

            AddFilterButton.Click += (sender, args) =>
            {
                FilterMenu().Show(this, PointToClient(Cursor.Position));
            };

            RemoveFilterButton.Click += (sender, args) =>
            {
                if (SelectedFilter != null)
                {
                    FilterSource.RemoveFilter(SelectedFilter);
                    propertyPanel.Controls.Clear();
                    view = null;
                }
            };
        }