Ejemplo n.º 1
6
        /// <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();
            };
        }
Ejemplo n.º 2
0
        public PropertyControl(PropertiesView view, ObsProperty property, ObsData setting)
        {
            SuspendLayout();
            AutoSize = true;
            Margin   = new Padding(0, 1, 0, 1);
            Size     = new Size(600, 25);
            ResumeLayout(false);

            this.view = view;

            DoubleBuffered = true;
            Padding        = new Padding(2);

            ObsPropertyType type     = property.Type;
            bool            addLabel = true;
            List <Control>  controls = new List <Control>();

            switch (type)
            {
            case ObsPropertyType.Bool:
            {
                addLabel = false;
                AddBool(property, setting, controls);
                break;
            }

            case ObsPropertyType.Int:
            case ObsPropertyType.Float:
            {
                AddNumeric(property, setting, controls);
                break;
            }

            case ObsPropertyType.Text:
            {
                AddText(property, setting, controls);
                break;
            }

            case ObsPropertyType.Path:
            {
                AddPath(property, setting, controls);
                break;
            }

            case ObsPropertyType.List:
            {
                AddList(property, setting, controls);
                break;
            }

            case ObsPropertyType.Color:
            {
                AddColor(property, setting, controls);
                break;
            }

            case ObsPropertyType.Button:
            {
                addLabel = false;
                AddButton(property, setting, controls);
                break;
            }

            case ObsPropertyType.Font:
            {
                AddFont(property, setting, controls);
                break;
            }

            case ObsPropertyType.EditableList:
            {
                addLabel = false;
                AddEditableList(property, setting, controls);
                break;
            }

            default:
            {
                throw new Exception(String.Format("Error, unimplemented property type {0} for property {1}", type, property.Description));
            }
            }

            Label nameLabel = new Label
            {
                Text        = addLabel ? property.Description : "",
                TextAlign   = ContentAlignment.MiddleRight,
                MinimumSize = new Size(170, 0),
                AutoSize    = true,
                Dock        = DockStyle.Left
            };

            controls.Insert(0, nameLabel);

            foreach (Control control in controls)
            {
                WinFormsHelper.DoubleBufferControl(control);

                int     margin    = 0;
                Padding oldmargin = control.Margin;
                oldmargin.Top    = margin;
                oldmargin.Bottom = margin;
                control.Margin   = oldmargin;
            }

            SuspendLayout();
            Controls.AddRange(controls.ToArray());
            ResumeLayout();
        }
Ejemplo n.º 3
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;
                }
            };
        }
Ejemplo n.º 4
0
        private void PopulateControls(Filter filter)
        {
            if (propertyPanel.Controls.Contains(view))
                propertyPanel.Controls.Remove(view);

            view = new PropertiesView(filter.GetSettings(), filter, filter.GetProperties, filter.GetDefaults, filter.Update);
            propertyPanel.Controls.Add(view);
        }
Ejemplo n.º 5
0
        private void FilterListBox_MouseUp(object sender, MouseEventArgs e)
        {
            var index = FilterListBox.IndexFromPoint(e.Location);
            Select(index);

            if (e.Button != MouseButtons.Right)
                return;

            var contextmenu = new ContextMenuStrip { Renderer = new AccessKeyMenuStripRenderer() };
            var add = new ToolStripMenuItem("Add...") { DropDown = FilterMenu() };

            var remove = new ToolStripMenuItem("Remove");
            remove.Click += (o, args) =>
            {
                FilterSource.RemoveFilter(SelectedFilter);
                propertyPanel.Controls.Clear();
                view = null;
            };

            var top = new ToolStripMenuItem("Move to &Top");
            top.Click += (o, args) =>
            {
                Select(FilterSource.MoveItem(SelectedFilter, obs_order_movement.OBS_ORDER_MOVE_TOP));
            };

            var up = new ToolStripMenuItem("Move &Up");
            up.Click += (o, args) =>
            {
                Select(FilterSource.MoveItem(SelectedFilter, obs_order_movement.OBS_ORDER_MOVE_UP));
            };

            var down = new ToolStripMenuItem("Move &Down");
            down.Click += (o, args) =>
            {
                Select(FilterSource.MoveItem(SelectedFilter, obs_order_movement.OBS_ORDER_MOVE_DOWN));
            };

            var bottom = new ToolStripMenuItem("Move to &Bottom");
            bottom.Click += (o, args) =>
            {
                Select(FilterSource.MoveItem(SelectedFilter, obs_order_movement.OBS_ORDER_MOVE_BOTTOM));
            };

            if (SelectedFilter == null)
            {
                remove.Enabled = false;
                top.Enabled = false;
                up.Enabled = false;
                down.Enabled = false;
                bottom.Enabled = false;
            }

            if (index == 0)
            {
                top.Enabled = false;
                up.Enabled = false;
            }
            if (index == FilterSource.Filters.Count - 1)
            {
                down.Enabled = false;
                bottom.Enabled = false;
            }

            contextmenu.Items.AddRange(new ToolStripItem[]
                                       {
                                           add,
                                           remove,
                                           new ToolStripSeparator(),
                                           top,
                                           up,
                                           down,
                                           bottom
                                       });

            contextmenu.Show(this, PointToClient(Cursor.Position));
        }
Ejemplo n.º 6
0
        public PropertyControl(PropertiesView view, ObsProperty property, ObsData setting)
        {
            SuspendLayout();
            AutoSize = true;
            Margin = new Padding(0, 1, 0, 1);
            Size = new Size(600, 25);
            ResumeLayout(false);

            this.view = view;

            DoubleBuffered = true;
            Padding = new Padding(2);

            ObsPropertyType type = property.Type;
            bool addLabel = true;
            List<Control> controls = new List<Control>();

            switch (type)
            {
                case ObsPropertyType.Bool:
                    {
                        addLabel = false;
                        AddBool(property, setting, controls);
                        break;
                    }
                case ObsPropertyType.Int:
                case ObsPropertyType.Float:
                    {
                        AddNumeric(property, setting, controls);
                        break;
                    }
                case ObsPropertyType.Text:
                    {
                        AddText(property, setting, controls);
                        break;
                    }
                case ObsPropertyType.Path:
                    {
                        AddPath(property, setting, controls);
                        break;
                    }
                case ObsPropertyType.List:
                    {
                        AddList(property, setting, controls);
                        break;
                    }
                case ObsPropertyType.Color:
                    {
                        AddColor(property, setting, controls);
                        break;
                    }
                case ObsPropertyType.Button:
                    {
                        addLabel = false;
                        AddButton(property, setting, controls);
                        break;
                    }
                case ObsPropertyType.Font:
                    {
                        AddFont(property, setting, controls);
                        break;
                    }
                case ObsPropertyType.EditableList:
                    {
                        addLabel = false;
                        AddEditableList(property, setting, controls);
                        break;
                    }
                default:
                    {
                        throw new Exception(String.Format("Error, unimplemented property type {0} for property {1}", type, property.Description));
                    }
            }

            Label nameLabel = new Label
            {
                Text = addLabel ? property.Description : "",
                TextAlign = ContentAlignment.MiddleRight,
                MinimumSize = new Size(170, 0),
                AutoSize = true,
                Dock = DockStyle.Left
            };
            controls.Insert(0, nameLabel);

            foreach (Control control in controls)
            {
                WinFormsHelper.DoubleBufferControl(control);

                int margin = 0;
                Padding oldmargin = control.Margin;
                oldmargin.Top = margin;
                oldmargin.Bottom = margin;
                control.Margin = oldmargin;
            }

            SuspendLayout();
            Controls.AddRange(controls.ToArray());
            ResumeLayout();
        }