예제 #1
0
        /// <summary>
        /// Creates a new empty project
        /// </summary>
        private ProjectController(ProjectFile file, Uri fileLocation)
        {
            pf = file;
            this.FileLocation = fileLocation;
            ExportController  = new ExportListController(this);
            ExportController.UpdateExportLists(file.ExportList);

            UTransformController = new UTransformController(ConfigController);
        }
예제 #2
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);
                }
            }
        }
예제 #3
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();
        }
예제 #4
0
        public ExportListTab(ExportList list, ProjectController projectController, ExportListController controller)
        {
            this.Build();
            this.exportList        = list;
            this.controller        = controller;
            this.projectController = projectController;

            _initNodeStore();
            _setupExportDestinationButton();

            ExportLocationEntry.Text = ((Uri)list.ExportDirectory).OriginalString;

            ExportListNameEntry.Text     = list.Name;
            ExportListNameEntry.Changed += (sender, e) => {
                list.Name = ExportListNameEntry.Text;
            };

            SuffixEntry.Text     = list.Suffix;
            SuffixEntry.Changed += (sender, e) => {
                list.Suffix = SuffixEntry.Text;
            };

            PrefixEntry.Text     = list.Prefix;
            PrefixEntry.Changed += (sender, e) => {
                list.Prefix = PrefixEntry.Text;
            };

            GlobalArgsTxt.Text     = list.Options;
            GlobalArgsTxt.Changed += (sender, e) => {
                list.Options = GlobalArgsTxt.Text;
            };

            ResXEntry.Text     = "" + list.ResolutionX;
            ResXEntry.Changed += (sender, e) => {
                int  parseResult;
                bool parsable = int.TryParse(ResXEntry.Text, out parseResult);
                if (parsable)
                {
                    list.ResolutionX = parseResult;
                }
            };
            ResXEntry.FocusOutEvent += (o, args) => {
                ResXEntry.Text = "" + list.ResolutionX;
            };

            ResYEntry.Text     = "" + list.ResolutionY;
            ResYEntry.Changed += (sender, e) => {
                int  parseResult;
                bool parsable = int.TryParse(ResYEntry.Text, out parseResult);
                if (parsable)
                {
                    list.ResolutionY = parseResult;
                }
            };
            ResYEntry.FocusOutEvent += (o, args) => {
                ResYEntry.Text = "" + list.ResolutionY;
            };

            ListStore formatModel = new ListStore(typeof(string), typeof(ElementExportSettings.CropSetting));

            foreach (object enumVal in Enum.GetValues(typeof(ExportType)))
            {
                formatModel.AppendValues(enumVal.ToString(), enumVal);
            }
            FormatCombo.Model    = formatModel;
            FormatCombo.Active   = (int)list.DefaultExportType;
            FormatCombo.Changed += (sender, e) => {
                list.DefaultExportType = (ExportType)FormatCombo.Active;
            };

            ListStore cropModeModel = new ListStore(typeof(string));

            foreach (object enumVal in Enum.GetValues(typeof(ElementExportSettings.CropSetting)))
            {
                if ((ElementExportSettings.CropSetting)enumVal == ElementExportSettings.CropSetting.Default)
                {
                    continue;
                }
                cropModeModel.AppendValues(enumVal.ToString());
            }

            CropModeCombo.Model    = cropModeModel;
            CropModeCombo.Changed += (sender, e) => {
                TreeIter selected;
                CropModeCombo.GetActiveIter(out selected);
                string selectedValue = (string)cropModeModel.GetValue(selected, 0);
                list.CropSetting = selectedValue;
            };

            //Set combo to current value
            string   initialValue = exportList.CropSetting;
            TreeIter pos;

            //Sets to first entry if next function fails due to invalid value.
            CropModeCombo.Model.GetIterFirst(out pos);
            //Iterates until we find a entry which matches the inital value.
            CropModeCombo.Model.Foreach((model, path, iter) => {
                if (((string)model.GetValue(iter, 0)).Equals(initialValue))
                {
                    pos = iter;
                    return(true);
                }
                else
                {
                    return(false);
                }
            });
            CropModeCombo.SetActiveIter(pos);

            System.Action UpdateAllArtButton = () => {
                LineArtButton.Active   = list.ExportLineArt;
                ColorArtButton.Active  = list.ExportColorArt;
                AllArtButton.Sensitive = !(LineArtButton.Active && ColorArtButton.Active);
                AllArtButton.Active    = (LineArtButton.Active && ColorArtButton.Active);
            };
            UpdateAllArtButton();

            AllArtButton.Clicked += (sender, e) => {
                if (AllArtButton.Active)
                {
                    LineArtButton.Active  = true;
                    ColorArtButton.Active = true;
                    UpdateAllArtButton();
                }
            };

            LineArtButton.Clicked += (sender, e) => {
                list.ExportLineArt = LineArtButton.Active;
                UpdateAllArtButton();
            };

            ColorArtButton.Clicked += (sender, e) => {
                list.ExportColorArt = ColorArtButton.Active;
                UpdateAllArtButton();
            };


            foreach (ElementExportSettings file in list.Elements)
            {
                nodestore.AddNode(file);
            }

            controller.TvgAdded += (activeList) => {
                if (activeList == list)
                {
                    nodestore.Clear();
                    foreach (ElementExportSettings file in list.Elements)
                    {
                        nodestore.AddNode(file);
                    }
                }
            };

            ExportSelectedButton.Clicked += (sender, e) => {
                ITreeNode[] selected = NodeFileList.NodeSelection.SelectedNodes;
                List <ElementExportSettings> tvgs = new List <ElementExportSettings> ();
                foreach (ITreeNode node in selected)
                {
                    tvgs.Add((ElementExportSettings)node);
                }
                if (tvgs.Count > 0)
                {
                    projectController.Export(list, tvgs);
                }
            };

            DeleteExportListButton.Clicked += (sender, e) => {
                projectController.RemoveExportList(exportList);
            };


            RemoveButton.Clicked += (sender, e) => {
                ITreeNode [] selected             = NodeFileList.NodeSelection.SelectedNodes;
                List <ElementExportSettings> tvgs = new List <ElementExportSettings> ();
                foreach (ITreeNode node in selected)
                {
                    tvgs.Add((ElementExportSettings)node);
                }
                foreach (ElementExportSettings tvg in tvgs)
                {
                    controller.RemoveTvg(tvg, exportList);
                }

                //Refresh node store
                nodestore.Clear();
                foreach (ElementExportSettings file in list.Elements)
                {
                    nodestore.AddNode(file);
                }
            };
        }