Пример #1
0
        public MainWindow(string[] args)
        {
            Glade.XML gxml = new Glade.XML("MainWindow.glade", "EithneWindow");
            gxml.BindFields(this);

            if (EithneWindow.Screen.RgbaColormap != null)
            {
                AlphaChannel          = true;
                EithneWindow.Colormap = EithneWindow.Screen.RgbaColormap;
            }

            EithneWindow.IconList = new Gdk.Pixbuf[2] {
                new Gdk.Pixbuf(null, "icon-48.png"), new Gdk.Pixbuf(null, "icon-16.png")
            };

            EithneWindow.DeleteEvent += OnWindowDelete;

            EithneWindow.Title = About.Name;

            StatusBar.Push(1, String.Format(Catalog.GetString("Welcome to {0}!"), About.Name));

            MenuFileNew.Image              = new Image(null, "document-new.png");
            MenuFileNew.Activated         += OnNew;
            MenuFileOpen.Image             = new Image(null, "document-open.png");
            MenuFileOpen.Activated        += OnLoad;
            MenuFileSave.Image             = new Image(null, "document-save.png");
            MenuFileSave.Activated        += OnSave;
            MenuFileSaveAs.Image           = new Image(null, "document-save-as.png");
            MenuFileSaveAs.Activated      += OnSaveAs;
            MenuFilePrint.Activated       += OnPrint;
            MenuFilePreferences.Image      = new Image(null, "preferences-desktop.png");
            MenuFilePreferences.Activated += delegate(object o, EventArgs eargs) { new Preferences(); };
            MenuFileQuit.Image             = new Image(null, "system-log-out.png");
            MenuFileQuit.Activated        += OnWindowDelete;
            MenuSystemRun.Image            = new Image(null, "media-playback-start.png");
            MenuSystemRun.Activated       += OnRun;
            MenuSystemStop.Image           = new Image(null, "media-playback-stop.png");
            MenuSystemStop.Activated      += OnRun;
            MenuHelpPluginList.Image       = new Image(null, "plugin-16.png");
            MenuHelpPluginList.Activated  += delegate(object o, EventArgs eargs) { new PluginList(); };
            MenuHelpAbout.Image            = new Image(null, "help-browser.png");
            MenuHelpAbout.Activated       += delegate(object o, EventArgs eargs) { new About(); };

            ToolbarNew.IconWidget  = new Image(null, "document-new-22.png");
            ToolbarNew.Clicked    += OnNew;
            ToolbarOpen.IconWidget = new Image(null, "document-open-22.png");
            ToolbarOpen.Clicked   += OnLoad;
            ToolbarSave.IconWidget = new Image(null, "document-save-22.png");
            ToolbarSave.Clicked   += OnSave;
            ToolbarRun.IconWidget  = new Image(null, "media-playback-start-22.png");
            ToolbarRun.Clicked    += OnRun;

            schematic = new Schematic(StatusBar);
            PluginToolboxSocket.AddWithViewport(new PluginToolbox(StatusBar, schematic));
            SchematicSocket.AddWithViewport(schematic);

            engine = new Engine2(schematic, SetRunToStart, progress.Pulse);

            progress.PulseStep = 0.05;
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
        public static ArrayList Load(string fn, Schematic s)
        {
            ArrayList errors = new ArrayList();
            ArrayList blocks = new ArrayList();
            Hashtable h      = new Hashtable();

            XmlDocument  x  = new XmlDocument();
            StreamReader sr = new StreamReader(fn);

            x.Load(sr);
            sr.Close();
            XmlNode root = x.DocumentElement;

            if (root.Name != "eithne")
            {
                new DialogMessage(String.Format(Catalog.GetString("File <i>{0}</i> is not an eithne system schematic!"), fn));

                return(null);
            }

            XmlNodeList nl = root.SelectNodes("schematic/block");

            Context c = Gdk.Context.CreateDrawable(s.GdkWindow);

            foreach (XmlNode n in nl)
            {
                blocks.Add(LoadBlock(n, c, h, errors, s));
            }

            ((IDisposable)c.Target).Dispose();
            ((IDisposable)c).Dispose();

            if (errors.Count == 0)
            {
                int i = 0;
                foreach (XmlNode n in nl)
                {
                    MakeConnections(n, h, (Block)blocks[i++]);
                }

                return(blocks);
            }
            else
            {
                new LoadError(fn, errors);

                return(null);
            }
        }
Пример #4
0
        private static XmlNode GenSchematic(XmlDocument x, Schematic s)
        {
            XmlNode   root = x.CreateNode(XmlNodeType.Element, "schematic", "");
            ArrayList l    = s.Blocks;
            Hashtable h    = new Hashtable();

            for (int i = 0; i < l.Count; i++)
            {
                h.Add(l[i], i);
            }

            foreach (Block b in l)
            {
                root.AppendChild(GenBlock(x, b, h));
            }

            return(root);
        }
Пример #5
0
        public static void Save(string fn, Schematic s)
        {
            XmlDocument x = new XmlDocument();
            XmlNode     n;

            n = x.CreateNode(XmlNodeType.XmlDeclaration, "", "");
            (n as XmlDeclaration).Encoding = "utf-8";
            x.AppendChild(n);

            n           = x.CreateNode(XmlNodeType.Comment, "", "");
            n.InnerText = String.Format(" {0} schematic. Do not hand modify. ", About.Name);
            x.AppendChild(n);

            n = x.CreateNode(XmlNodeType.Element, "eithne", "");
            x.AppendChild(n);

            n.AppendChild(GenInfo(x, fn));
            n.AppendChild(GenSchematic(x, s));

            x.Save(fn);
        }
Пример #6
0
        public PluginToolbox(Statusbar status, Schematic schematic) : base()
        {
            this.status    = status;
            this.schematic = schematic;

            TreeStore store = new TreeStore(typeof(string), typeof(IFactory));

            TreeIter iter = store.AppendValues(Catalog.GetString("Input"));

            Populate(store, iter, PluginDB.In);

            iter = store.AppendValues(Catalog.GetString("Image processing"));
            Populate(store, iter, PluginDB.ImgProc);

            iter = store.AppendValues(Catalog.GetString("Comparator"));
            Populate(store, iter, PluginDB.Comparator);

            iter = store.AppendValues(Catalog.GetString("Result processing"));
            Populate(store, iter, PluginDB.ResProc);

            iter = store.AppendValues(Catalog.GetString("Output"));
            Populate(store, iter, PluginDB.Out);

            iter = store.AppendValues(Catalog.GetString("Other"));
            Populate(store, iter, PluginDB.Other);

            Model          = store;
            HeadersVisible = false;

            CellRendererText cr = new CellRendererText();

            AppendColumn("Name", cr, "text", 0);
            Columns[0].SetCellDataFunc(cr, new Gtk.TreeCellDataFunc(RenderCell));

            ExpandAll();
        }
Пример #7
0
 private static void UpdateHandler()
 {
     Block.CheckGConf();
     Schematic.CheckGConf();
     Engine2.CheckGConf();
 }
Пример #8
0
        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);
        }
Пример #9
0
 public Engine2(Schematic s, FinishCallback finish, Progress progress)
 {
     this.s        = s;
     this.finish   = finish;
     this.progress = progress;
 }
Пример #10
0
        protected override bool OnButtonPressEvent(Gdk.EventButton args)
        {
            status.Pop(1);

            Schematic _t       = this;
            object    selected = _t.selected;

            object tmp = CheckSelection((int)args.X, (int)args.Y);

            if (selected != null && selected == tmp)
            {
                if (selected is Block)
                {
                    Block b = selected as Block;

                    if (args.Button == 1)
                    {
                        if (args.Type == Gdk.EventType.ButtonPress)
                        {
                            status.Push(1, Catalog.GetString("Move block to desired location"));

                            // move clicked block to the top
                            if (blocks[blocks.Count - 1] != selected)
                            {
                                blocks.Remove(selected);
                                blocks.Add(selected);
                                QueueDraw();
                            }

                            Action.m = Action.Mode.Move;
                            tmpx     = (int)args.X;
                            tmpy     = (int)args.Y;
                        }
                        else if (args.Type == Gdk.EventType.TwoButtonPress)
                        {
                            Action.m = Action.Mode.Normal;

                            if (b.Plugin is Plugin.Out && b.Plugin.WorkDone)
                            {
                                try
                                {
                                    (b.Plugin as Plugin.Out).DisplayResults();
                                }
                                catch (Exception e)
                                {
                                    b.ShowError = true;
                                    QueueDraw();
                                    new PluginError(e, b, true);
                                }
                            }
                            else if (b.Plugin.HasSetup)
                            {
                                try
                                {
                                    b.Plugin.Setup();
                                }
                                catch (Exception e)
                                {
                                    b.ShowError = true;
                                    QueueDraw();
                                    new PluginError(e, b, true);
                                }
                            }
                        }
                    }
                    else if (args.Button == 3)
                    {
                        ImageMenuItem mi;

                        status.Push(1, String.Format(Catalog.GetString("{0} menu"), b.Plugin.Info.Name));

                        Action.m = Action.Mode.Normal;

                        Menu m = new Menu();

                        if (b.Plugin is Plugin.Out)
                        {
                            mi            = new ImageMenuItem(Catalog.GetString("Display _results"));
                            mi.Image      = new Image(null, "system-search.png");
                            mi.Activated += PluginResults;
                            if (!b.Plugin.WorkDone)
                            {
                                mi.Sensitive = false;
                            }
                            m.Append(mi);
                        }

                        if (b.Plugin.HasSetup)
                        {
                            mi            = new ImageMenuItem(Catalog.GetString("_Setup"));
                            mi.Image      = new Image(null, "preferences-desktop.png");
                            mi.Activated += PluginSetup;
                            m.Append(mi);
                        }

                        if (b.Plugin.HasSetup || b.Plugin is Plugin.Out)
                        {
                            m.Append(new SeparatorMenuItem());
                        }

                        mi            = new ImageMenuItem(Catalog.GetString("D_isconnect all"));
                        mi.Image      = new Image(null, "edit-cut.png");
                        mi.Activated += delegate(object sender, EventArgs eargs)
                        {
                            b.Disconnect();
                            QueueDraw();
                            status.Pop(1);
                            status.Push(1, Catalog.GetString("Removed all block's connections"));
                        };
                        m.Append(mi);

                        mi       = new ImageMenuItem(Catalog.GetString("In_validate"));
                        mi.Image = new Image(null, "user-trash-full.png");
                        if (b.CheckState() != Block.State.Good)
                        {
                            mi.Sensitive = false;
                        }
                        mi.Activated += delegate(object sender, EventArgs eargs)
                        {
                            b.Invalidate();

                            status.Pop(1);
                            status.Push(1, Catalog.GetString("Invalidated results"));
                        };
                        m.Append(mi);

                        mi            = new ImageMenuItem(Catalog.GetString("_Delete"));
                        mi.Image      = new Image(null, "edit-delete.png");
                        mi.Activated += delegate(object sender, EventArgs eargs)
                        {
                            b.Disconnect();
                            blocks.Remove(selected);
                            QueueDraw();

                            status.Pop(1);
                            status.Push(1, String.Format(Catalog.GetString("Deleted {0} block"), b.Plugin.Info.Name));
                        };
                        m.Append(mi);

                        m.Append(new SeparatorMenuItem());

                        mi            = new ImageMenuItem(Catalog.GetString("_About"));
                        mi.Image      = new Image(null, "help-browser.png");
                        mi.Activated += delegate(object sender, EventArgs eargs) { new PluginAbout(b.Plugin); };
                        m.Append(mi);

                        m.ShowAll();
                        m.Popup();
                    }
                }
                else if (selected is Socket)
                {
                    Socket s = selected as Socket;

                    if (s.Other == null)
                    {
                        if (s.Type == Socket.T.Out)
                        {
                            if (args.Button == 1)
                            {
                                status.Push(1, Catalog.GetString("Connect block with another"));
                                Action.m    = Action.Mode.Connect;
                                Action.data = Connection.None;
                                tmpx        = (int)args.X;
                                tmpy        = (int)args.Y;
                                QueueDraw();
                            }
                        }
                    }
                    else
                    {
                        if (args.Button == 1 && args.Type == Gdk.EventType.TwoButtonPress)
                        {
                            status.Push(1, Catalog.GetString("Removed connection"));
                            s.Disconnect();
                            QueueDraw();
                        }
                        else if (args.Button == 3)
                        {
                            Menu          m  = new Menu();
                            ImageMenuItem mi = new ImageMenuItem(Catalog.GetString("_Disconnect"));
                            mi.Image      = new Image(null, "edit-cut.png");
                            mi.Activated += delegate(object sender, EventArgs eargs)
                            {
                                s.Disconnect();
                                _t.QueueDraw();

                                _t.status.Pop(1);
                                _t.status.Push(1, Catalog.GetString("Removed connection"));
                            };
                            m.Append(mi);

                            m.ShowAll();
                            m.Popup();
                        }
                    }
                }
            }
            else
            {
                Action.m = Action.Mode.Normal;
                selected = tmp;
                QueueDraw();
            }

            return(true);
        }