private void GraphForm_KeyDown(object sender, KeyEventArgs e) { int k = e.KeyValue; //MessageBox.Show(k.ToString()); if (k == 46) //Del button { graph.Stop(); if (graph.SelectedFilters.Count > 0) { foreach (Filter f in graph.SelectedFilters) graph.RemoveFilter(f, false); graph.ClearFiltersSelection(); graph.RecalcPaths(); Invalidate(); } PinConnection con = graph.SelectedConnection; if (con != null) { graph.SelectedConnection = null; graph.RemoveConnection(con, true); Invalidate(); } e.Handled = true; } }
public void CompleteConnect(PinConnection con, bool really) { connection = con; if (con == null && really) { Filter.Graph.Disconnect(ipin); } }
protected void Connect(Pin outpin, Pin inpin) //ipins must be already connected { PinConnection con = new PinConnection(outpin, inpin); List <ConStep> path = CalcPath(outpin, inpin, con.ID); con.path = path; connections.Add(con); history.ConnectIfNew(outpin, inpin, con); }
void DescribeActions() { StringBuilder sb = new StringBuilder(); DateTime t = DateTime.Now; if (movingFilter == null && connectingPin == null) //no action yet { sb.Append("Right click for menu. "); Filter filter = graph.FilterInPoint(mousepos); if (filter != null) { Pin pin = filter.PinInPoint(mousepos); if (pin != null) { if (pin.Connection == null) sb.Append("Drag with left button down for intelligent connect, with right button for direct connect, left click to see media types. "); AddToAnimated(pin, t); } else sb.Append("Drag with left button down to move filter, left click to select and see properties. Shift+click to add to selection. "); AddToAnimated(filter, t); } else { int con_id = HoveredConnectionID(); if (con_id > 0) { sb.Append("Left click to see connection mediatype. "); if (graph.SelectedConnection != null && graph.SelectedConnection.ID == con_id) sb.Append("Press Del to remove connection. "); PinConnection con = graph.ConnectionWithID(con_id); if (con != null) AddToAnimated(con, t); } else if (selecting) sb.Append("Release mouse button to select filters in rectangle. "); else if (graph.HasFilters) sb.Append("Drag mouse with left button down to select several filters. "); } } if (movingFilter != null) sb.Append("Release mouse button to stop moving filters. "); if (graph.SelectedFilters.Count > 0) sb.Append("Press Del to remove selected filters. "); if (connectingPin != null) if (otherPin != null) sb.Append("Release mouse button to attempt connection. "); else sb.Append("Move mouse to the pin you want to connect to. "); if (RegistryChecker.R[1]==0 && RegistryChecker.R[0] != 0) sb.AppendFormat("{0} days to evaluate. ", RegistryChecker.R[93]); //sb.AppendFormat("R {0} {1}", RegistryChecker.R[0], RegistryChecker.R[1]); //sb.AppendFormat(" {0} animated", animated_objects.Count); Program.mainform.SetHint(sb.ToString()); }
public void SelectConnection(int con_id) { foreach (PinConnection con in connections) { if (con.ID == con_id) { SelectedConnection = con; AMMediaType mt = new AMMediaType(); con.pins[0].IPin.ConnectionMediaType(mt); MediaTypeProps mtp = MediaTypeProps.CreateMTProps(mt); //new MediaTypeProps(mt); Program.mainform.propform.SetObject(mtp); break; } } }
public void RemoveConnection(PinConnection con, bool recalcPaths) { if (con == null) { return; } Form.StopAnimation(con); history.RemoveConnection(con.pins[0], con.pins[1]); con.Disconnect(true); connections.Remove(con); if (recalcPaths) { RecalcPaths(); } }
public void SelectFilter(Filter f, bool select) { if (select) { if (!selectedFilters.Contains(f)) { selectedFilters.Add(f); } selectedConnection = null; } else { selectedFilters.Remove(f); } }
public THIConnect(HIConnect _hi, PinConnection _con) { hi = _hi; con = _con; }
public void ReloadFilters() { log("reload filters.."); IEnumFilters ef; ClearFiltersSelection(); ClearConnections(); filter_positions.Clear(); foreach (Filter f in filters) { filter_positions.Add(f.Name, f.Coords); } filters.Clear(); log("reload_filters 1"); try { int hr = graphBuilder.EnumFilters(out ef); DsError.ThrowExceptionForHR(hr); IBaseFilter[] fs = new IBaseFilter[1]; IntPtr fetched = Marshal.AllocHGlobal(4); while ((hr = ef.Next(1, fs, fetched)) == 0) { log("reload_filters 2"); FilterInfo fi; fs[0].QueryFilterInfo(out fi); log("reload_filters: " + fi.achName); Filter ff = FindFilterByName(fi.achName); if (ff == null) //not found { ff = new Filter(fs[0]); AddFilterHere(ff, false, null); history.AddFilterIfNew(ff.filterProps, ff.Name, ff.srcFileName, ff.dstFileName, ff); } else { ff.ReloadPins(); } log("reload_filters 3"); foreach (Pin pin in ff.Pins) { log("reload_filters 4: " + pin.Name); IPin ip = pin.IPin, connected_ipin; hr = ip.ConnectedTo(out connected_ipin); if (hr != 0) { continue; } PinInfo cpi; connected_ipin.QueryPinInfo(out cpi); FilterInfo cfi; cpi.filter.QueryFilterInfo(out cfi); Filter connected_filter = FindFilterByName(cfi.achName); if (connected_filter != null) { Pin cp = connected_filter.FindPinByName(connected_filter.Name + "." + cpi.name); if (cp != null) { string con_uniqname = (pin.Direction == PinDirection.Input) ? cp.UniqName + "-" + pin.UniqName : pin.UniqName + "-" + cp.UniqName; PinConnection con = FindConnectionByName(con_uniqname); if (con == null) { if (pin.Direction == PinDirection.Input) { Connect(cp, pin); } else { Connect(pin, cp); } } } } DsUtils.FreePinInfo(cpi); } } Marshal.FreeHGlobal(fetched); if (hr < 0) { DsError.ThrowExceptionForHR(hr); } } catch (COMException e) { ShowCOMException(e, "Error while enumerating filters in the graph"); return; } /*catch (Exception e) * { * MessageBox.Show(e.Message, "Error while enumerating filters in the graph"); * return; * }*/ log("reload_filters: almost done"); history.CommitAdded(); log("reload_filters: done"); }
public void ClearFiltersSelection() { selectedFilters.Clear(); selectedConnection = null; }