Beispiel #1
0
        protected void SelectElementTableClicked(object sender, EventArgs e)
        {
            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Open xstage file.", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
            fc.SetCurrentFolder(settings.GetSettingsFileLocationUri().AbsolutePath);
            FileFilter ff = new FileFilter();

            ff.AddPattern("*.xstage");
            fc.Filter = ff;

            if (fc.Run() == (int)ResponseType.Accept)
            {
                XStageProject        xsp          = XStageProject.Load(fc.Filename);
                List <XStageElement> elementTable = xsp.elements;

                elementTableUrl = fc.Filename;

                nodestore.Clear();
                foreach (XStageElement element in elementTable)
                {
                    Uri elementTableUri       = new Uri(elementTableUrl);
                    Uri elementTableDirectory = new Uri(elementTableUri, ".");

                    foreach (XStageDrawing d in element.drawings)
                    {
                        VectorFilePath vfp = new VectorFilePath();
                        vfp.Path = elementTableDirectory.OriginalString + element.rootFolder + "/" + element.elementFolder + "/" + element.elementName + "-" + d.name + ".tvg";
                        vfp.Name = element.elementName + "-" + d.name;
                        nodestore.AddNode(vfp);
                    }
                }

                Console.WriteLine(xsp.GetXmlString());
            }
            fc.Destroy();
        }
Beispiel #2
0
        public static XStageProject Load(String filePath)
        {
            XmlSerializer serialiser = new XmlSerializer(typeof(XStageProject));
            FileStream    stream     = File.OpenRead(filePath);
            XStageProject tbe        = (XStageProject)serialiser.Deserialize(stream);

            stream.Close();
            return(tbe);
        }
Beispiel #3
0
        public XStageListTab(XStageProject xstage, Uri fileUri, ExportListController exportListController)
        {
            this.Build();
            _xstage = xstage;
            this.exportListController = exportListController;


            nodestore = new NodeStore(typeof(ElementExportSettings));

            FileTree.RulesHint      = true;
            FileTree.Selection.Mode = SelectionMode.Multiple;
            FileTree.AppendColumn("Name", new Gtk.CellRendererText(), "text", 1);
            FileTree.AppendColumn("Path", new Gtk.CellRendererText(), "text", 0);

            FileTree.NodeStore = nodestore;
            AddButton.Clicked += (sender, e) => {
                NodeSelection selection = FileTree.NodeSelection;
                foreach (ITreeNode node in selection.SelectedNodes)
                {
                    //Add selected VectorFilePath to the active export list
                    ElementExportSettings current = (ElementExportSettings)node;
                    ElementExportSettings tvg     = new ElementExportSettings();
                    tvg.Name     = current.Name;
                    tvg.FilePath = current.FilePath;
                    exportListController.AddTvg(tvg);
                }
            };



            foreach (XStageElement element in xstage.elements)
            {
                Uri xstageDirectory = new Uri(fileUri, "./");

                foreach (XStageDrawing d in element.drawings)
                {
                    ElementExportSettings vfp = new ElementExportSettings();
                    vfp.FilePath = new Uri(xstageDirectory.LocalPath + element.rootFolder + "/" + element.elementFolder + "/" + element.elementName + "-" + d.name + ".tvg");
                    vfp.Name     = element.elementName + "-" + d.name;
                    nodestore.AddNode(vfp);
                }
            }
        }
Beispiel #4
0
        void RefreshXStageProjectList()
        {
            //Remove all pages
            while (Notebook.NPages > 0)
            {
                Notebook.RemovePage(0);
            }

            //Recreate pages for all xstage files

            foreach (Uri uri in controller.GetXStageProjects())
            {
                Uri           absoluteUri = new Uri(controller.FileDirectory, uri);
                XStageProject xstageProj  = XStageProject.Load(absoluteUri.AbsolutePath);
                if (xstageProj != null)
                {
                    XStageListTab tab = new XStageListTab(xstageProj, absoluteUri, exportListController);
                    Label         lbl = new Label(System.IO.Path.GetFileName(absoluteUri.AbsolutePath));

                    Notebook.AppendPage(tab, lbl);
                }
            }
            Notebook.ShowAll();
        }
Beispiel #5
0
        public ProjectWindow(ProjectController controller) :
            base(Gtk.WindowType.Toplevel)
        {
            this.Build();

            DeleteEvent += OnDeleteEvent;

            Notebook.RemovePage(0);
            NotebookExport.RemovePage(0);

            this.controller      = controller;
            exportListController = controller.ExportController;

            this.Maximize();


            controller.ExportListsChanged += RefreshExportLists;

            controller.XStageProjectListChanged += RefreshXStageProjectList;


            NotebookExport.SwitchPage += (o, args) => {
                Widget w = NotebookExport.GetNthPage((int)args.PageNum);
                exportListController.SetActiveExportList(notebookMap [w]);
                Console.WriteLine(notebookMap [w].Name);
            };

            AddXStageButton.Clicked += (sender, e) => {
                Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Open xstage file.", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
                fc.SetCurrentFolder(new Uri(controller.FileLocation, "./").AbsolutePath);
                FileFilter ff = new FileFilter();
                ff.AddPattern("*.xstage");
                fc.Filter = ff;

                if (fc.Run() == (int)ResponseType.Accept)
                {
                    XStageProject        xsp          = XStageProject.Load(fc.Filename);
                    List <XStageElement> elementTable = xsp.elements;

                    controller.AddXStageProject(new Uri(fc.Uri));
                }
                fc.Destroy();
            };

            NewExportListButton.Clicked += (sender, e) => {
                Dialog d         = new Dialog("Enter Name", this, DialogFlags.Modal, "Cancel", ResponseType.Cancel, "Ok", ResponseType.Ok);
                Entry  nameEntry = new Entry();
                d.VBox.Add(nameEntry);
                d.ShowAll();
                nameEntry.Activated += (sender1, e1) => {
                    d.Respond(ResponseType.Ok);
                };
                int response = d.Run();
                if ((ResponseType)response == ResponseType.Ok)
                {
                    controller.AddExportList(nameEntry.Text);
                }
                d.Destroy();
            };

            _SetupMenu();
            _SetupExport();

            Reinit();
        }