Click here to Skip to main content
15,891,136 members
Articles / Programming Languages / C#

DSGraphEdit: A Reasonable Facsimile of Microsoft's GraphEdit in .NET

Rate me:
Please Sign up or sign in to vote.
4.93/5 (79 votes)
28 Jan 2018MIT7 min read 299.6K   10K   142  
A library for adding DirectShow GraphEdit-like abilities to .NET applications
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using DirectShowLib;

namespace DaggerLib.DSGraphEdit
{
    [ToolboxItem(false)]
    public partial class PropertiesDialog : Form
    {
        private TextBox _textBox;
        private PinPropertiesTextBox _pinTextBox;
        private PropertyPagePanel _properties;

        public PropertiesDialog(string caption, IBaseFilter filter)
        {
            InitializeComponent();

            // remove the default panels
            this.Controls.Remove(panel1);
            this.Controls.Remove(panel2);

            // create the PropertyPagePanel
            _properties = new PropertyPagePanel(true,filter);
            _properties.Dock = DockStyle.Fill;
            
            // make sure it's wide enough to show all the buttons
            int newwidth = Math.Max(350, _properties.PageSize.Width);
            int newheight = _properties.PageSize.Height;
            this.ClientSize = new Size(newwidth + 10, newheight + 23);

            this.Controls.Add(_properties);
            _properties.OkButton.DialogResult = DialogResult.OK;
            _properties.CloseButton.DialogResult = DialogResult.Cancel;
            this.CancelButton = _properties.CloseButton;
            this.AcceptButton = _properties.OkButton;
            Text = caption;
        }

        public PropertiesDialog(string caption,IPin pin)
        {
            InitializeComponent();
            _pinTextBox = new PinPropertiesTextBox(pin);
            panel2.Controls.Add(_pinTextBox);
            button1.DialogResult = DialogResult.OK;
            this.CancelButton = button1;
            Text = caption + " Properties";
        }

        public PropertiesDialog(string caption)
        {
            InitializeComponent();
            _textBox = new TextBox();
            _textBox.ReadOnly = true;
            _textBox.Multiline = true;
            _textBox.Dock = DockStyle.Fill;
            _textBox.ScrollBars = ScrollBars.Both;
            _textBox.WordWrap = false;
            _textBox.BorderStyle = BorderStyle.FixedSingle;
            panel2.Controls.Add(_textBox);
            button1.DialogResult = DialogResult.OK;
            this.CancelButton = button1;
            Text = caption;
        }

        public TextBox TextBox
        {
            get
            {
                return (TextBox)(_pinTextBox != null ? _pinTextBox : _textBox);
            }
        }

        public PropertyPagePanel PropertyPagePanel
        {
            get
            {
                return _properties;
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer (Senior)
United States United States
AKA Rich Insley.

I have over 25 years experience in programming, and I'm completely self taught. (Except for one year at California State University Fresno where I had to learn the God awful language Miranda (http://miranda.org.uk/). I've spent 10 years as a Paratrooper in the US Army during the Clinton Administration.

Comments and Discussions