public Block(Schematic s, Context c, Plugin.Base plugin, int x, int y) { this.schematic = s; this.plugin = plugin; this.x = x; this.y = y; plugin.Block = this; UpdateCoordinates(c); socketin = new Socket[plugin.NumIn]; socketout = new Socket[plugin.NumOut]; int curpos = 10 + (h - 20 - CalcHeight(plugin.NumIn)) / 2; for (int i = 0; i < plugin.NumIn; i++) { socketin[i] = new Socket(0, curpos, this, Socket.T.In, i); curpos += 15; } curpos = 10 + (h - 20 - CalcHeight(plugin.NumOut)) / 2; for (int i = 0; i < plugin.NumOut; i++) { socketout[i] = new Socket(w - 10, curpos, this, Socket.T.Out, i); curpos += 15; } }
public PluginAbout(Plugin.Base p) { string type; if (p is Plugin.In) { type = Catalog.GetString("Input"); } else if (p is Plugin.Out) { type = Catalog.GetString("Output"); } else if (p is Plugin.ImgProc) { type = Catalog.GetString("Image processing"); } else if (p is Plugin.ResProc) { type = Catalog.GetString("Result processing"); } else if (p is Plugin.Comparator) { type = Catalog.GetString("Comparator"); } else { type = Catalog.GetString("Other"); } CommonTasks(p.Info, type); FillMatchInfo(p); }
protected override void OnRowActivated(TreePath path, TreeViewColumn column) { if (HasParent(path)) { TreeIter iter; Selection.GetSelected(out iter); IFactory f = Model.GetValue(iter, 1) as IFactory; Plugin.Base p = f.Create(); p.Source = PluginDB.Origin[f]; schematic.Add(p); } }
public void Add(Plugin.Base plugin) { Context c = Gdk.Context.CreateDrawable(this.GdkWindow); blocks.Add(new Block(this, c, plugin, 10, offset)); ((IDisposable)c.Target).Dispose(); ((IDisposable)c).Dispose(); offset += 50; if (offset > 400) { offset = 10; } QueueDraw(); }
public EngineThread(Engine2 engine, Block b) { this.b = b; this.engine = engine; b.Working = true; MainWindow.RedrawSchematic(); try { if (b.Plugin.NumIn != 0) { CommSocket cs = new CommSocket(b.Plugin.NumIn); for (int i = 0; i < b.Plugin.NumIn; i++) { Socket other = b.SocketIn[i].Other; if (other.Parent.Plugin.Out == null) { b.Working = false; b = other.Parent; throw new PluginException(Catalog.GetString("Plugin has no data on output sockets.")); } cs[i] = other.Parent.Plugin.Out[other.Num]; } b.Plugin.In = cs; } Plugin = b.Plugin; t = new Thread(ThreadedWork); t.Start(); } catch (Exception e) { engine.Stop(); b.ShowError = true; MainWindow.RedrawSchematic(); new PluginError(e, b, false); } }
protected override bool OnButtonPressEvent(Gdk.EventButton ev) { base.OnButtonPressEvent(ev); status.Pop(1); TreeIter iter; Selection.GetSelected(out iter); if (HasParent(Model, iter)) { IFactory f = Model.GetValue(iter, 1) as IFactory; status.Push(1, String.Format(Catalog.GetString("{0} plugin selected"), f.Info.Name)); if (ev.Button == 3) { Menu m = new Menu(); ImageMenuItem m1 = new ImageMenuItem(Catalog.GetString("A_dd")); m1.Image = new Image(null, "list-add.png"); m1.Activated += delegate(object sender, EventArgs e) { Plugin.Base p = f.Create(); p.Source = PluginDB.Origin[f]; schematic.Add(p); }; m.Append(m1); SeparatorMenuItem s = new SeparatorMenuItem(); m.Append(s); ImageMenuItem m2 = new ImageMenuItem(Catalog.GetString("_About")); m2.Image = new Image(null, "help-browser.png"); m2.Activated += delegate(object sender, EventArgs e) { new PluginAbout(f); }; m.Append(m2); m.ShowAll(); m.Popup(); } } return(true); }
private bool IsGoodConnection(Socket from, Socket to) { // the same block if (from.Parent == to.Parent) { return(false); } // something is already connected to the socket if (to.Other != null) { return(false); } Plugin.Base fp = from.Parent.Plugin; Plugin.Base tp = to.Parent.Plugin; foreach (string mOut in fp.MatchOut) { string tmp = mOut; ArrayList matches = new ArrayList(); matches.Add(tmp); while (tmp.LastIndexOf('/') != -1) { int lastIndex = tmp.LastIndexOf('/'); tmp = tmp.Substring(0, lastIndex); matches.Add(tmp); } matches.Add(""); foreach (string mIn in tp.MatchIn) { if (matches.Contains(mIn)) { return(true); } } } return(false); }
public static Block LoadBlock(XmlNode root, Context c, Hashtable h, ArrayList errors, Schematic schematic) { int x = Int32.Parse(root.SelectSingleNode("x").InnerText); int y = Int32.Parse(root.SelectSingleNode("y").InnerText); string sassembly = root.SelectSingleNode("info/assembly").InnerText; string sclass = root.SelectSingleNode("info/class").InnerText; int n = Int32.Parse(root.Attributes["id"].Value); XmlNode config = root.SelectSingleNode("config"); Block b; Source s = new Source(sassembly, sclass); IFactory f = (IFactory)PluginDB.RevOrigin[s]; if (f == null) { string sname = root.SelectSingleNode("info/name").InnerText; string sversion = root.SelectSingleNode("info/version").InnerText; BlockError e = new BlockError(sname, sversion, sassembly, sclass); if (!errors.Contains(e)) { errors.Add(e); } b = null; } else { Plugin.Base p = f.Create(); p.Source = s; b = new Block(schematic, c, p, x, y); b.Plugin.Config = config; h.Add(n, b); } return(b); }
private void FillMatchInfo(Plugin.Base p) { MatchIn.Model = new ListStore(typeof(string)); MatchOut.Model = new ListStore(typeof(string)); MatchIn.AppendColumn(Catalog.GetString("Input matches"), new CellRendererText(), "text", 0); MatchOut.AppendColumn(Catalog.GetString("Output matches"), new CellRendererText(), "text", 0); if (p.MatchIn != null) { foreach (string s in p.MatchIn) { (MatchIn.Model as ListStore).AppendValues(s); } } if (p.MatchOut != null) { foreach (string s in p.MatchOut) { (MatchOut.Model as ListStore).AppendValues(s); } } }
public PluginAbout(IFactory f) { string type = null; switch (f.Type) { case IType.In: type = Catalog.GetString("Input"); break; case IType.Out: type = Catalog.GetString("Output"); break; case IType.ImgProc: type = Catalog.GetString("Image processing"); break; case IType.ResProc: type = Catalog.GetString("Result processing"); break; case IType.Comparator: type = Catalog.GetString("Comparator"); break; case IType.Other: type = Catalog.GetString("Other"); break; } CommonTasks(f.Info, type); Plugin.Base tmp = f.Create(); FillMatchInfo(tmp); }
protected override bool OnMotionNotifyEvent(Gdk.EventMotion args) { if (Action.m == Action.Mode.Normal) { object oldselected = selected; selected = CheckSelection((int)args.X, (int)args.Y); if (oldselected != selected) { status.Pop(1); if (selected is Block) { status.Push(1, String.Format(Catalog.GetString("{0} block selected"), (selected as Block).Plugin.Info.Name)); } else if (selected is Socket) { Socket s = selected as Socket; Plugin.Base p = s.Parent.Plugin; if (s.Type == Socket.T.In) { status.Push(1, String.Format(Catalog.GetString("{0} block, input socket {1}. {2}"), p.Info.Name, s.Num, p.DescIn(s.Num))); } else { status.Push(1, String.Format(Catalog.GetString("{0} block, output socket {1}. {2}"), p.Info.Name, s.Num, p.DescOut(s.Num))); } } QueueDraw(); } } else if (Action.m == Action.Mode.Move) { int dx = (int)args.X - tmpx; int dy = (int)args.Y - tmpy; (selected as Block).Move(dx, dy); QueueDraw(); tmpx = (int)args.X; tmpy = (int)args.Y; } else if (Action.m == Action.Mode.Connect) { tmpx = (int)args.X; tmpy = (int)args.Y; object tmp = CheckSelection((int)args.X, (int)args.Y); if (tmp is Socket) { Action.data = CheckConnection(selected as Socket, tmp as Socket); } else { Action.data = Connection.None; } QueueDraw(); } return(true); }