Inheritance: System.Windows.Forms.Form
        private void BtnAddNewFileClick(object sender, System.EventArgs e)
        {
            if (!ProjectTypeIsValid())
            {
                return;
            }

            NewFileWindow nfw = new NewFileWindow();

            foreach (var ati in AvailableAssetTypes.Self.AllAssetTypes)
            {
                if (!string.IsNullOrEmpty(ati.Extension) && !string.IsNullOrEmpty(ati.QualifiedSaveTypeName))
                {
                    nfw.AddOption(ati);
                }

                // special case .txt
                if (ati.Extension == "txt")
                {
                    nfw.AddOption(ati);
                }
            }

            // Also add CSV files
            //nfw.AddOption(new AssetTypeInfo("csv", "", null, "Spreadsheet (.csv)", "", ""));
            nfw.AddOption(AvailableAssetTypes.Self.AllAssetTypes.First(item => item.FriendlyName == "Spreadsheet (.csv)"));

            if (nfw.ShowDialog() == DialogResult.OK)
            {
                AssetTypeInfo resultAssetTypeInfo = nfw.ResultAssetTypeInfo;
                bool          make2D = nfw.GetOptionFor(resultAssetTypeInfo) == "2D";

                string name = nfw.ResultName;

                string createdFile = PluginManager.CreateNewFile(resultAssetTypeInfo, make2D, FileManager.GetDirectoryKeepRelative(Rfs.Name), name);

                //var createdFile = resultAssetTypeInfo.CreateNewFile(FileManager.GetDirectoryKeepRelative(Rfs.Name) + name, "", make2D);
                createdFile = ProjectManager.MakeRelativeContent(createdFile);

                var psf = new ProjectSpecificFile
                {
                    ProjectName = cboProjectType.Text,
                    FilePath    = createdFile
                };

                Value.Add(psf);
                Rfs.ProjectSpecificFiles = Value;
                GlueCommands.Self.ProjectCommands.UpdateFileMembershipInProject(Rfs);
                ProjectManager.SaveProjects();
                GlueCommands.Self.RefreshCommands.RefreshPropertyGrid();

                RefreshList();
            }
        }
Esempio n. 2
0
        private static NewFileWindow CreateNewFileWindow()
        {
            NewFileWindow nfw = new NewFileWindow();

            PluginManager.AddNewFileOptions(nfw);

            if (GlueState.Self.CurrentElement != null)
            {
                foreach (ReferencedFileSave fileInElement in GlueState.Self.CurrentElement.ReferencedFiles)
                {
                    nfw.NamedAlreadyUsed.Add(FileManager.RemovePath(FileManager.RemoveExtension(fileInElement.Name)));
                }
            }

            // Also add CSV files
            nfw.AddOption(new AssetTypeInfo("csv", "", null, "Spreadsheet (.csv)", "", ""));
            return nfw;
        }
Esempio n. 3
0
        internal static void AddNewFileOptions(NewFileWindow newFileWindow)
        {
            foreach (PluginManager pluginManager in mInstances)
            {
                foreach (INewFile plugin in pluginManager.NewFilePlugins)
                {
                    PluginContainer container = pluginManager.mPluginContainers[plugin];

                    if (container.IsEnabled)
                    {
                        INewFile plugin1 = plugin;
                        PluginCommand(() =>
                                          {
                                              plugin1.AddNewFileOptions(newFileWindow);
                                          }, container, "Failed in AddNewFileOptions");
                    }
                }

                // Execute the new style plugins
                var plugins = pluginManager.ImportedPlugins.Where(x => x.AddNewFileOptionsHandler != null);
                foreach (var plugin in plugins)
                {
                    var container = pluginManager.mPluginContainers[plugin];
                    if (container.IsEnabled)
                    {
                        PluginBase plugin1 = plugin;
                        PluginCommand(() =>
                            {
                                plugin1.AddNewFileOptionsHandler(newFileWindow);
                            }, container, "Failed in AddNewFileOptions");
                    }
                }
            }
        }
        private void BtnAddNewFileClick(object sender, System.EventArgs e)
        {
            if (!ProjectTypeIsValid()) return;

            NewFileWindow nfw = new NewFileWindow();

            foreach(var ati in AvailableAssetTypes.Self.AllAssetTypes)
            {
                if (!string.IsNullOrEmpty(ati.Extension) && !string.IsNullOrEmpty(ati.QualifiedSaveTypeName))
                {
                    nfw.AddOption(ati);
                }

                // special case .txt
                if (ati.Extension == "txt")
                {
                    nfw.AddOption(ati);
                }

            }

            // Also add CSV files
            //nfw.AddOption(new AssetTypeInfo("csv", "", null, "Spreadsheet (.csv)", "", ""));
            nfw.AddOption(AvailableAssetTypes.Self.AllAssetTypes.First(item => item.FriendlyName == "Spreadsheet (.csv)"));

            if (nfw.ShowDialog() == DialogResult.OK)
            {
                AssetTypeInfo resultAssetTypeInfo = nfw.ResultAssetTypeInfo;
                bool make2D = nfw.GetOptionFor(resultAssetTypeInfo) == "2D";

                string name = nfw.ResultName;

                string createdFile = PluginManager.CreateNewFile(resultAssetTypeInfo, make2D, FileManager.GetDirectoryKeepRelative(Rfs.Name), name);

                //var createdFile = resultAssetTypeInfo.CreateNewFile(FileManager.GetDirectoryKeepRelative(Rfs.Name) + name, "", make2D);
                createdFile = ProjectManager.MakeRelativeContent(createdFile);

                var psf = new ProjectSpecificFile
                {
                    ProjectId = cboProjectType.Text,
                    FilePath = createdFile
                };

                Value.Add(psf);
                Rfs.ProjectSpecificFiles = Value;
                ProjectManager.UpdateFileMembershipInProject(Rfs);
                ProjectManager.SaveProjects();
                GlueCommands.Self.RefreshCommands.RefreshPropertyGrid();

                RefreshList();
            }
        }
        public BuildToolAssociation GetBuildToolAssocationAndNameFor(string fileName, out bool userCancelled, out string rfsName, out string extraCommandLineArguments)
        {
            userCancelled = false;
            rfsName = null;

            BuildToolAssociation buildToolAssociation = null;

            string sourceExtension = FileManager.GetExtension(fileName);

            List<BuildToolAssociation> btaList = new List<BuildToolAssociation>();
            foreach (BuildToolAssociation bta in BuildToolAssociationManager.Self.ProjectSpecificBuildTools.BuildToolList)
            {
                if (bta.SourceFileType != null && bta.SourceFileType.ToLower() == sourceExtension.ToLower())
                {
                    btaList.Add(bta);
                }
            }



            NewFileWindow nfw = new NewFileWindow();
            nfw.ComboBoxMessage = "Which builder would you like to use for this file?";

            int commandLineArgumentsId = nfw.AddTextBox("Enter extra command line arguments:");

            foreach (BuildToolAssociation bta in btaList)
            {
                nfw.AddOption(bta);
            }

            if (btaList.Count != 0)
            {
                nfw.SelectedItem = btaList[0];
            }

            nfw.ResultName = FileManager.RemoveExtension(FileManager.RemovePath(fileName));
            //DialogResult result = cbmb.ShowDialog();
            DialogResult result = nfw.ShowDialog();
            extraCommandLineArguments = "";

            if (result == DialogResult.OK)
            {
                buildToolAssociation = nfw.SelectedItem as BuildToolAssociation;
                rfsName = nfw.ResultName;
                extraCommandLineArguments = nfw.GetValueFromId(commandLineArgumentsId);
            }
            else
            {
                userCancelled = true;
            }




            return buildToolAssociation;
        }