Click here to Skip to main content
15,884,176 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 295.8K   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;
using DaggerLib.DSGraphEdit;

namespace DaggerLib.DSGraphEdit
{
    public partial class ROTEntriesDialog : Form
    {
        private IFilterGraph _filterGraph;

        public ROTEntriesDialog()
        {
            InitializeComponent();
            _okButton.DialogResult = DialogResult.OK;
            _cancelButton.DialogResult = DialogResult.Cancel;
            RefreshEntries();
            listBox1.SelectedIndex = listBox1.Items.Count - 1;
        }

        public string SelectedROTEntry
        {
            get
            {
                if (listBox1.SelectedIndex != -1)
                {
                    return listBox1.SelectedItem.ToString();
                }
                else
                {
                    return string.Empty;
                }
            }
        }

        public IFilterGraph FilterGraph
        {
            get
            {
                if (_filterGraph != null)
                {
                    return _filterGraph;
                }
                else
                {
                    if (listBox1.SelectedIndex != -1)
                    {
                        _filterGraph = (listBox1.SelectedItem as DSGrapheditROTEntry).ConnectToROTEntry();
                        return _filterGraph;
                    }
                    else
                    {
                        return null;
                    }
                }
            }
        }

        private void PurgeEntries()
        {
            foreach (DSGrapheditROTEntry rote in listBox1.Items)
            {
                rote.Dispose();
            }
            listBox1.Items.Clear();
        }

        private void RefreshEntries()
        {
            PurgeEntries();
            listBox1.Items.AddRange(DaggerDSUtils.GetFilterGraphsFromROT().ToArray());
        }
    }
}

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