private void _insertFilterButton_Click(object sender, EventArgs e) { DSFilterTreeViewNode node = dsFilterTreeView1.SelectedNode as DSFilterTreeViewNode; if (node != null) { _associatedGraphPanel.AddFilter(node); } }
/// <summary> /// Overide the default DaggerUIGraph OnDragDrop to handle TreeNodes from a DSFilterTreeView /// instead of TreeNodes from DaggerNodeTreeView /// </summary> /// <param name="drgevent"></param> protected override void OnDragDrop(System.Windows.Forms.DragEventArgs drgevent) { DSFilterTreeViewNode tn = (DSFilterTreeViewNode)drgevent.Data.GetData(typeof(DSFilterTreeViewNode)); if (tn != null) { // store the drop location so the node can be repositioned in SyncGraph _dropLocation = PointToClient(new Point(drgevent.X, drgevent.Y)); AddFilter(tn); } }
void dsFilterTreeView1_DoubleClick(object sender, EventArgs e) { if (_associatedGraphPanel != null) { DSFilterTreeViewNode tn = dsFilterTreeView1.SelectedNode as DSFilterTreeViewNode; if (tn != null) { _associatedGraphPanel.AddFilter(tn); } } }
/// <summary> /// Create and add a filter from a DSFilterTreeViewNode /// </summary> /// <param name="tn"></param> public IBaseFilter AddFilter(DSFilterTreeViewNode tn) { int hr = 0; IBaseFilter filter = null; if (tn.DSFilterType == FilterType.DMO) { // create a DMO wrapper and init it with the ClassGuid filter = (IBaseFilter) new DMOWrapperFilter(); IDMOWrapperFilter wrapper = (IDMOWrapperFilter)filter; hr = wrapper.Init(tn.ClassGuid, tn.DMOCategory); if (hr != 0) { MessageBox.Show(DsError.GetErrorText(hr), "Error wrapping DMO"); Marshal.ReleaseComObject(filter); return(null); } hr = _Graph.AddFilter(filter, tn.Text); if (hr != 0) { MessageBox.Show(DsError.GetErrorText(hr), "Error Adding DMO"); Marshal.ReleaseComObject(filter); return(null); } SyncGraphs(filter); return(filter); } else { // try adding it as a source filter first (this usually works for non-source filters anyway) hr = (_Graph as IFilterGraph2).AddSourceFilterForMoniker(tn.Moniker, null, tn.Text, out filter); // that didn't work. Try AddFilterByDevicePath if (filter == null) { DirectShowLib.Utils.FilterGraphTools.AddFilterByDevicePath(_Graph as IGraphBuilder, tn.DevicePath, tn.Name); } // force the DaggerGraph to reflect changes in the DS graph List <DSFilterNode> addedNodes = SyncGraphs(filter); // get the DSFilterNode that was added and give it the information if (addedNodes.Count == 1) { addedNodes[0]._devicePath = tn.DevicePath; addedNodes[0]._moniker = tn.Moniker; } return(filter); } }
public DSFilterTreeViewNode FindFilter(string searchText) { // store the search text in the Singleton SearchItemsSingleton sitems = SearchItemsSingleton.Instance; if (!sitems.Items.Contains(searchText)) { sitems.Items.Add(searchText); } searchText = searchText.ToLower(); int startparent = 0; int startchild = 0; if (dsFilterTreeView1.SelectedNode != null) { if (dsFilterTreeView1.SelectedNode is DSFilterTreeViewNode) { startparent = dsFilterTreeView1.SelectedNode.Parent.Index; startchild = dsFilterTreeView1.SelectedNode.Index; } else { startparent = dsFilterTreeView1.SelectedNode.Index; startchild = 0; } } // search from selected to end DSFilterTreeViewNode found = FindFilterRange(searchText, startparent, startchild + 1, dsFilterTreeView1.Nodes.Count - 1, dsFilterTreeView1.Nodes[dsFilterTreeView1.Nodes.Count - 1].Nodes.Count - 1); if (found == null) { if (startparent != 0 && startchild != 0) { // search from top to selected found = FindFilterRange(searchText, 0, 0, startparent, startchild); } } // if a node was found, select it and expand it if (found != null) { dsFilterTreeView1.Select(); found.Parent.Expand(); dsFilterTreeView1.SelectedNode = found; } return(found); }
/// <summary> /// Updates the filter's property panel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dsFilterTreeView1_AfterSelect(object sender, TreeViewEventArgs e) { splitContainer1.Panel2.Controls.Clear(); // do wee need to create a new properties panel? DSFilterTreeViewNode node = dsFilterTreeView1.SelectedNode as DSFilterTreeViewNode; if (node != null) { FilterPropertiesPanel p = new FilterPropertiesPanel(node); p.Dock = DockStyle.Fill; splitContainer1.Panel2.Controls.Add(p); _insertFilterButton.Enabled = true; } else { _insertFilterButton.Enabled = false; } }
/// <summary> /// Adds or removes DSFilterTreeViewNodes to/from a TreeNodeCollection based on Filters /// that are available on the system. /// </summary> /// <param name="collection"></param> public virtual void SyncTreeNodes(TreeNodeCollection collection) { // get a list of all standard Direct Show Filters List <DsDevice> devices = new List <DsDevice>(DirectShowLib.DsDevice.GetDevicesOfCat(Category)); // GC will release the monikers when the devices list goes out of scope // go in reverse order and remove any nodes that no longer have registered filters for (int i = collection.Count - 1; i > -1; i--) { DSFilterTreeViewNode tn = collection[i] as DSFilterTreeViewNode; if (tn != null) { if (GetDeviceFromMoniker(devices, tn.Moniker) == null) { collection.Remove(tn); } } } // add new TreeNodes for filters that are not yet in the collection foreach (DsDevice device in devices) { if (DSFilterTreeView.GetTreeNodeByDevicePath(device.DevicePath, collection) == null) { // we don't have this one yet try { DSFilterTreeViewNode tn = new DSFilterTreeViewNode(device, this.DMOCategory); if (tn.Text != "") { collection.Add(tn); } } catch { // some filters just don't play nice } } } }
public FilterPropertiesPanel(DSFilterTreeViewNode node) { InitializeComponent(); _nameLabel.Text = node.Text; _meritLabel.Text = "0x" + node.FilterInformation.Merit.ToString("X"); _monikerTextBox.Text = node.DevicePath; _filenameLabel.Text = node.FilePath; _filenameLabel.SelectAll(); foreach (FilterDataPin pin in node.FilterInformation.Pins) { TreeNode tn = new TreeNode("pin " + pin.PinNumber.ToString() + ":"); tn.Nodes.Add(new TreeNode("Many: " + pin.PinFlagMany.ToString())); tn.Nodes.Add(new TreeNode("Output: " + pin.PinFlagOutput.ToString())); tn.Nodes.Add(new TreeNode("Rendered: " + pin.PinFlagRenderer.ToString())); tn.Nodes.Add(new TreeNode("Zero: " + pin.PinFlagZero.ToString())); tn.Nodes.Add(new TreeNode("ClsPinCategory: " + pin.Category.ToString())); foreach (FilterDataPinType pt in pin.Mediums) { TreeNode mtn = new TreeNode("Medium " + pt.TypeNumber.ToString()); mtn.Nodes.Add(new TreeNode("medium clsid: " + pt.MajorType.ToString())); tn.Nodes.Add(mtn); } foreach (FilterDataPinType pt in pin.Types) { TreeNode mtn = new TreeNode("type " + pt.TypeNumber.ToString()); mtn.Nodes.Add(new TreeNode("major type: " + DsToString.MediaTypeToString(pt.MajorType) + " {" + pt.MajorType.ToString() + "}")); mtn.Nodes.Add(new TreeNode("subtype: " + DsToString.MediaSubTypeToString(pt.SubType) + " {" + pt.SubType.ToString() + "}")); tn.Nodes.Add(mtn); } _pinsTreeView.Nodes.Add(tn); } }
/// <summary> /// Create and add a filter from a DSFilterTreeViewNode /// </summary> /// <param name="tn"></param> public IBaseFilter AddFilter(DSFilterTreeViewNode tn) { return(dsDaggerUIGraph1.AddFilter(tn)); }
public StandardFilterCategory(DsDevice category) { _category = category; _clsid = DSFilterTreeViewNode.GetMonikerGuid(category.Mon); }