Example #1
0
        /// <summary>
        ///     Exports a file of a given type.
        ///     Formats available to export will depend on the type of the data.
        /// </summary>
        /// <param name="type">Type of the data to be exported</param>
        /// <param name="data">The data</param>
        /// <param name="arguments">Optional arguments to be used by the exporter</param>
        public static void export(fileType type, object data, params object[] arguments)
        {
            using (SaveFileDialog saveDlg = new SaveFileDialog())
            {
                switch (type)
                {
                case fileType.model:
                    OModelExportForm exportMdl = new OModelExportForm((RenderBase.OModelGroup)data, (int)arguments[0]);
                    exportMdl.Show();
                    break;

                case fileType.texture:
                    OTextureExportForm exportTex = new OTextureExportForm((RenderBase.OModelGroup)data, (int)arguments[0]);
                    exportTex.Show();
                    break;

                case fileType.skeletalAnimation:
                    saveDlg.Title  = "Export Skeletal Animation";
                    saveDlg.Filter = "Source Model|*.smd";
                    if (saveDlg.ShowDialog() == DialogResult.OK)
                    {
                        switch (saveDlg.FilterIndex)
                        {
                        case 1:
                            SMD.export((RenderBase.OModelGroup)data, saveDlg.FileName, (int)arguments[0], (int)arguments[1]);
                            break;
                        }
                    }
                    break;
                }
            }
        }
Example #2
0
        public Handler(int FileId, fileType FileType, fileVersion file)
        {
            switch (FileType)
            {
            case fileType.Csv:
                processer = new CSVHandler(FileId);
                processer.ImportData();
                break;

            case fileType.Excel:
                switch (file)
                {
                case fileVersion.Version1:
                    processer = new ExcelHandler(FileId);
                    processer.ImportData();
                    break;

                case fileVersion.Version2:
                    processer = new ExcelHandler(FileId);
                    processer.ImportData2();
                    break;
                }
                break;
            }
        }
Example #3
0
 DirFile(string name, string p, DirFile par, fileType t)
 {
     fileName = name;
     path     = p;
     parent   = par;
     type     = t;
 }
Example #4
0
        public bool Import(string filepath, fileType ft)
        {
            bool importSucessful = false;


            switch (ft)
            {
            case fileType.OFFERS:
                if (importSucessful = ImportOffer(filepath))
                {
                    _filePathOffers = filepath;
                }
                break;

            case fileType.CONTRACTORS:
                if (importSucessful = ImportContractor(filepath))
                {
                    _filePathContractors = filepath;
                }
                break;

            case fileType.ROUTES:
                if (importSucessful = ImportRoute(filepath))
                {
                    _filePathRoutes = filepath;
                }
                break;

            default: throw new Exception("File Type doesn't exist!");
            }
            return(importSucessful);
        }
Example #5
0
        /// <summary>
        /// Get object and save to Json file
        /// </summary>
        public static void Savejson(fileType type)
        {
            if (!fileLocked)
            {
                string file = "";

                if (type == fileType.trackedList)
                {
                    file = trackedListFile;
                }
                else if (type == fileType.Configuration)
                {
                    file = configfile;
                }

                using (StreamWriter sw = new StreamWriter(file, false))
                {
                    if (type == fileType.trackedList)
                    {
                        sw.Write(JsonConvert.SerializeObject(trackedApps));
                    }
                    else if (type == fileType.Configuration)
                    {
                        sw.Write(JsonConvert.SerializeObject(config));
                    }
                }
            }
        }
Example #6
0
        public fileType datatypeSelect(string _datatype)
        {
            fileType ft = new fileType();
            fileSpec fs = new fileSpec();

            switch (_datatype)
            {
            case "v":
                ft.fields = fs.vendor;
                ft.len    = fs.vendorLen;
                ft.path   = fs.vendata;
                return(ft);

            case "pr":
                ft.fields = fs.product;
                ft.len    = fs.prodLen;
                ft.path   = fs.prodata;
                return(ft);

            case "pt":
                ft.fields = fs.part;
                ft.len    = fs.partLen;
                ft.path   = fs.partdata;
                return(ft);

            default:
                return(ft);
            }
        }
Example #7
0
        protected override void Execute(CodeActivityContext context)
        {
            string File_Path = FilePath.Get(context);

            //DataTable dt = new DataTable();
            //dt.Columns.Add(new DataColumn("Name", typeof(String)));
            //dt.Columns.Add(new DataColumn("Value", typeof(String)));

            Dictionary <String, String> dt = new Dictionary <String, String>();

            fileType file_Type = TypeOfFile;

            if (file_Type == fileType.Xml)
            {
                XDocument  xDoc         = XDocument.Load(File_Path);
                XContainer xContainer   = xDoc;
                String     fullNodeName = String.Empty;
                readXMLNodes(xContainer, ref dt, fullNodeName);
                ResultDictionary.Set(context, dt);
            }
            else
            {
                JToken objJToken;
                using (StreamReader file = File.OpenText(File_Path))
                    using (JsonTextReader reader = new JsonTextReader(file))
                    {
                        objJToken = JToken.ReadFrom(reader);
                    }
                readJsonNodes(objJToken, ref dt, String.Empty);
                ResultDictionary.Set(context, dt);
            }
        }
Example #8
0
 public netFile(string Name, string Url, bool Isdir = false)
 {
     this.Name  = Name;
     this.Url   = Url;
     this.Isdir = Isdir;
     if (!Isdir)
     {
         if (re_video.IsMatch(this.Url))
         {
             this.Type = fileType.Video;
         }
         else if (re_audio.IsMatch(this.Url))
         {
             this.Type = fileType.Audio;
         }
         else if (re_pic.IsMatch(this.Url))
         {
             this.Type = fileType.Pciture;
         }
         else if (this.Url.EndsWith(".ass"))
         {
             this.Type = fileType.Subtitle;
         }
         else
         {
             this.Type = fileType.None;
         }
     }
     else
     {
         this.Type = fileType.None;
     }
 }
Example #9
0
        static void Main(string[] args)
        {
            const string cppFile = "#include \"iostream\"\n" +
                                   "using namespace std;\n\n" +
                                   "int main(int argc, char const *argv[])\n" +
                                   "{\n" +
                                   "   cout << \"Hello world!\\n\";\n" +
                                   "   return 0;\n" +
                                   "}\n";



            Console.WriteLine("Problem number");
            int number = Int32.Parse(Console.ReadLine());

            Console.WriteLine("Folder output");
            string folder = Console.ReadLine();

            folder += "\\" + number.ToString();
            Directory.CreateDirectory(folder);
            string url = "https://www.aceptaelreto.com/pub/problems/v00" + number / 100 + "/" + (number % 100).ToString("00") + "/st/problem.pdf";

            using (var client = new WebClient())
            {
                client.DownloadFile(url, folder + "\\problem.pdf");
            }

            Console.WriteLine("Downloaded File");


            Console.WriteLine("Choose file type: \n  1) c++ \n  2) java");
            fileType choosenFile = (fileType)(Console.ReadKey(true).KeyChar - '0');
            string   file        = "";

            switch (choosenFile)
            {
            case fileType.cpp:
                file = cppFile;
                break;

            case fileType.java:
                file = javaFile(number);
                break;

            default:
                throw new Exception("Wrong file format");
            }

            Console.WriteLine("Creating file");

            StreamWriter sw = File.CreateText(folder + "\\problem" + number.ToString() + "." + choosenFile.ToString());

            sw.Write(file);
            sw.Close();
            Console.WriteLine("Written problem" + number.ToString() + "." + choosenFile.ToString());

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey(true);
        }
Example #10
0
        /// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// Writing data - TODO wip
        /// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Writes the data files.
        /// </summary>
        /// <returns>The data files.</returns>
        /// <param name="suite">Suite.</param>
        /// <param name="testType">Test type.</param>
        /// <param name="resultIOdata">Result I odata.</param>
        /// <param name="data">Data.</param>
        /// <param name="filetype">Filetype.</param>
        public IEnumerator WriteDataFiles(ResultsIOData resultIOdata, fileType filetype)
        {
            if (resultIOdata.resultsRow.Count != 0)
            {
                string            suite    = resultIOdata.suite;
                string            testType = resultIOdata.testType;
                ResultsDataCommon common   = ResultsIO.Instance.GenerateRDC(resultIOdata.resultsRow[0].resultsColumn.ToArray());
                string[]          fields   = resultIOdata.fieldNames.ToArray();
                Console.Instance.Write(DebugLevel.File, MessageLevel.Log, "Beginning to write data for suite " + suite + " of the testType " + testType + " which contains " + resultIOdata.resultsRow.Count + " files to write"); // Write to console
                string platformAPI            = common.Platform + "_" + common.API;
                string filePath               = CreateDataDirectory(suite, platformAPI, common.RenderPipe, testType);
                string prefix                 = "";
                int    suiteBaselineDataIndex = -1;
                if (filetype == fileType.Baseline)
                { //if it's a baseline file we need to update latest baseline timesstamp
                    prefix = baselinePrefix;
                    ResultsIO.Instance.UpdateBaselineDictionary(suite, common.Platform, common.API, common.RenderPipe, out suiteBaselineDataIndex);
                }
                else
                {
                    prefix = resultsCurrentPrefix;
                }
                List <string> data = new List <string>(); //list to create string for local file
                                                          //iterate through all the results in the current ResultsIOData
                for (int i = 0; i < resultIOdata.resultsRow.Count; i++)
                {
                    common = ResultsIO.Instance.GenerateRDC(resultIOdata.resultsRow[i].resultsColumn.ToArray());
                    data.Clear();                                              //clear data for new file
                    for (int f = 0; f < fields.Length; f++)
                    {                                                          //adding the data(values) and fields together
                        data.Add(fields[f]);                                   //add the field name
                        data.Add(resultIOdata.resultsRow[i].resultsColumn[f]); //add the value
                    }
                    if (!Directory.Exists(filePath))                           // check to see ig folder exists if not create it
                    {
                        Directory.CreateDirectory(filePath);
                    }
                    string fileName = prefix + "_" + common.GroupName + "_" + common.TestName + ".txt"; //name the file
                    File.WriteAllLines(filePath + "/" + fileName, data.ToArray());                      //write the contents of data line by line
                    while (!File.Exists(filePath + "/" + fileName))
                    {
                        Console.Instance.Write(DebugLevel.File, MessageLevel.Log, "Writing..."); // Write to console
                        yield return(new WaitForEndOfFrame());
                    }
                    //update baseline dictionary(not a dictionary) if baseline
                    if (filetype == fileType.Baseline)
                    {
                        ResultsIO.Instance.BaselineDictionaryEntry(suiteBaselineDataIndex, testType, common.GroupName, common.TestName, common.DateTime);
                    }
                }
                Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Wrote " + resultIOdata.resultsRow.Count + " files to disk"); // Write to console
                                                                                                                                        //Write baseline dictionary for suite and update timestamp TODO might need work/tweaking
                if (filetype == fileType.Baseline)
                {
                    yield return(StartCoroutine(UpdateSuiteDataFiles()));
                }
                yield return(null);
            }
        }
Example #11
0
 public additionalMap(string FileName, string Location, fileType type, string mapType, string displayName, T map)
 {
     this.FileName    = FileName;
     this.Location    = Location;
     this.type        = type;
     this.mapType     = mapType;
     this.displayName = displayName;
     this.map         = map;
 }
Example #12
0
 public DFile(string name, string p, DirFile par, fileType t, DateTime date, double s)
 {
     fileName  = name;
     path      = p;
     parent    = par;
     type      = t;
     creatTime = date;
     size      = s;
 }
Example #13
0
        /******************************************************************************/
        // Form creation

        public Form1()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Normal;
            this.Show();
            this.BringToFront();

            exit_path = "";
            file_type = fileType.OTHER;
            label_status.ForeColor = System.Drawing.Color.Black;
            label_status.Text      = "Status: Please, insert a BIN or FEX file, then press Convert button";
        }
Example #14
0
        private fileType LoadFile(System.IO.FileInfo fi, string requestedName, out string varname, out Bitmap output)
        {
            fileType returnType = fileType.ImageMdl;

            varname = "";
            output  = null;
            if (fi.Name.EndsWith(".mdl"))
            {
                MDL.MDLFile test  = new MDL.MDLFile();
                bool        valid = test.ReadFromFile(fi.FullName);
                if (valid)
                {
                    currentBinaryMDL = test;
                    returnType       = fileType.ModelMdl;
                    if (test.RootObject.Where(x => x.type == MDLType.mdl_image).Count() > 0)
                    {
                        output     = test.RootObject.First(x => x.type == MDLType.mdl_image).image.myBitmap;
                        returnType = fileType.ImageMdl;
                    }
                }
                else
                {
                    currentBinaryMDL = null;
                    System.IO.FileStream fs;
                    try
                    {
                        fs = fi.OpenRead();
                        using (System.IO.BinaryReader br = new System.IO.BinaryReader(fs))
                        {
                            br.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
                            output     = LoadTextBmpMDL(fi, out currentReferencedFiles, requestedName, out varname);
                            returnType = fileType.TextMdl;
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            else
            {
                returnType       = fileType.Image;
                currentBinaryMDL = null;
                output           = (Bitmap)Bitmap.FromFile(fi.FullName);
            }

            return(returnType);
        }
Example #15
0
 /// <summary>
 ///     Exports a file of a given type.
 ///     Formats available to export will depend on the type of the data.
 /// </summary>
 /// <param name="type">Type of the data to be exported</param>
 /// <param name="data">The data</param>
 /// <param name="arguments">Optional arguments to be used by the exporter</param>
 public static void export(fileType type, object data, params object[] arguments)
 {
     if (arguments.Length < 3)
     {
         using (SaveFileDialog saveDlg = new SaveFileDialog())
         {
             switch (type)
             {
                 case fileType.model:
                     OModelExportForm exportMdl = new OModelExportForm((RenderBase.OModelGroup)data, (int)arguments[0]);
                     exportMdl.Show();
                     break;
                 case fileType.texture:
                     OTextureExportForm exportTex = new OTextureExportForm((RenderBase.OModelGroup)data, (int)arguments[0]);
                     exportTex.Show();
                     break;
                 case fileType.skeletalAnimation:
                     saveDlg.Title = "Export Skeletal Animation";
                     saveDlg.Filter = "Source Model|*.smd|Autodesk DAE|*.dae";
                     if (saveDlg.ShowDialog() == DialogResult.OK)
                     {
                         switch (saveDlg.FilterIndex)
                         {
                             case 1:
                                 for (int i = 0; i < ((RenderBase.OModelGroup)data).skeletalAnimation.list.Count; i++)
                                 {
                                     SMD.export((RenderBase.OModelGroup)data, saveDlg.FileName, (int)arguments[0], i);
                                 }
                                 break;
                             case 2:
                                 for (int i = 0; i < ((RenderBase.OModelGroup)data).skeletalAnimation.list.Count; i++)
                                 {
                                     DAE.export((RenderBase.OModelGroup)data, saveDlg.FileName, (int)arguments[0], i);
                                 }
                                 break;
                         }
                     }
                     break;
             }
         }
     }
     else
     {
         DAE.export((RenderBase.OModelGroup)data, Path.GetFullPath(arguments[2].ToString() + ".bch"), (int)arguments[0]);
     }
 }
Example #16
0
        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="path">文件路径</param>
        public void DeleteFile(string filename, fileType type = fileType.ImageType)
        {
            string path = "";

            if (type == fileType.ImageType)
            {
                path = "/Data/Images/" + filename;
            }
            else if (type == fileType.CertificateType)
            {
                path = "/Data/Certificates/" + filename;
            }

            if (File.Exists(HttpContext.Current.Server.MapPath(path)))
            {
                File.Delete(HttpContext.Current.Server.MapPath(path));
            }
        }
Example #17
0
        /// <summary>
        /// Load Json File and convert to object
        /// </summary>
        public static object LoadFile(fileType type)
        {
            string file = "";

            if (type == fileType.trackedList)
            {
                file = trackedListFile;
            }
            else if (type == fileType.Configuration)
            {
                file = configfile;
            }

            if (file != "")
            {
                using (StreamReader sr = new StreamReader(file))
                {
                    fileLocked = true;
                    string json = sr.ReadToEnd();

                    if (type == fileType.trackedList)
                    {
                        trackedApps = JsonConvert.DeserializeObject <List <TrackedApp> >(json);
                        fileLocked  = false;
                        return(trackedApps);
                    }
                    else if (type == fileType.Configuration)
                    {
                        config     = JsonConvert.DeserializeObject <Config>(json);
                        fileLocked = false;
                        return(config);
                    }
                    else
                    {
                        fileLocked = false;
                        return(null);
                    }
                }
            }
            else
            {
                return(null);
            }
        }
Example #18
0
        /// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// Processing fresh test data
        /// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Processes the results, saving local txt files and pushing to cloud.
        /// </summary>
        /// <param name="suiteName">Suite name.</param>
        /// <param name="testType">Test type.</param>
        /// <param name="inputData">Input data.</param>
        /// <param name="baseline">Baseline data?</param>
        public IEnumerator ProcessResults(string suiteName, string testType, ResultsIOData inputData, int baseline)
        {
            ProgressScreen.Instance.SetState(true, ProgressType.CloudSave, "Saving cloud data");

            inputData.suite    = suiteName;
            inputData.testType = testType;
            int uploaded = -1;

            if (writeCloud)
            {
                string sheetName;
                if (baseline == 1) //Cloud upload for baseline
                {
                    sheetName = suiteName + "_" + testType + "_Baseline";
                }
                else                 //cloud upload for results
                {
                    sheetName = suiteName + "_" + testType + "_Results";
                }
                StartCoroutine(SQL.SQLIO.AddEntry(inputData, sheetName, baseline, (value) => { uploaded = value; }));                 // SQLCHECK
                while (uploaded == -1)
                {
                    yield return(null);
                }
            }
            else
            {
                uploaded = 1;
            }

            ProgressScreen.Instance.SetState(true, ProgressType.LocalSave, "Saving local data");

            if (writeLocal)
            {
                fileType ft = baseline == 1 ? fileType.Baseline : fileType.Result;
                if (uploaded == 1)                 // if the entry uploaded fine
                {
                    StartCoroutine(LocalIO.Instance.WriteDataFiles(inputData, ft));
                }
            }

            BroadcastEndResultsSave();
        }
Example #19
0
        private bool is_FEX_file(string file)
        {
            char[] extension = new char[4];

            extension[0] = file[file.Length - 4];
            extension[1] = file[file.Length - 3];
            extension[2] = file[file.Length - 2];
            extension[3] = file[file.Length - 1];

            if ((extension[0] == '.') && (extension[1] == 'f' || extension[1] == 'F') && (extension[2] == 'e' || extension[2] == 'E') && (extension[3] == 'x' || extension[3] == 'X'))
            {
                file_type = fileType.FEX;
                return(true);
            }
            else
            {
                file_type = fileType.OTHER;
                return(false);
            }
        }
Example #20
0
        private bool is_BIN_file(string file)
        {
            char[] extension = new char[4];

            extension[0] = file[file.Length - 4];
            extension[1] = file[file.Length - 3];
            extension[2] = file[file.Length - 2];
            extension[3] = file[file.Length - 1];

            if ((extension[0] == '.') && (extension[1] == 'b' || extension[1] == 'B') && (extension[2] == 'i' || extension[2] == 'I') && (extension[3] == 'n' || extension[3] == 'N'))
            {
                file_type = fileType.BIN;
                return(true);
            }
            else
            {
                file_type = fileType.OTHER;
                return(false);
            }
        }
        private void setFileContentType(fileType pFileType)
        {
            switch (pFileType)
            {
            case fileType.xml:
                this.fileContentType = "application/xml";
                break;

            case fileType.pdf:
                this.fileContentType = "application/pdf";
                break;

            case fileType.xls:
                this.fileContentType = "application/vnd.ms-excel";
                break;

            default:
                break;
            }
        }
Example #22
0
        private void btnSaveAs_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItems.Count > 1)
            {
                List <System.IO.FileInfo> files = new List <System.IO.FileInfo>();
                foreach (object item in listBox1.SelectedItems)
                {
                    if (item.GetType() == typeof(System.IO.FileInfo))
                    {
                        files.Add((System.IO.FileInfo)item);
                    }
                }

                // save all the images here.
                string      fileNamePattern = "";
                ImageFormat resType         = GetBatchNameAndType("png", out fileNamePattern, currentDirectory.FullName);

                if (resType != null)
                {
                    foreach (System.IO.FileInfo fi in files)
                    {
                        string curName = fi.Name.Replace(fi.Extension, "");
                        string newName = fileNamePattern.Replace("[currentname]", curName);
                        //newName += "."+resType.ToString();
                        string   tmp;
                        Bitmap   curBitmap;
                        fileType ft = LoadFile(fi, "", out tmp, out curBitmap);
                        curBitmap.Save(newName, resType);
                    }
                }
            }
            else if (listBox1.SelectedItem != null && listBox1.SelectedItem.GetType() == typeof(System.IO.FileInfo))
            {
                string ext   = ((System.IO.FileInfo)listBox1.SelectedItem).Extension.ToLower();
                string fname = ((System.IO.FileInfo)listBox1.SelectedItem).Name;
                string cDir  = currentDirectory.FullName;
                Bitmap btmap = currentBitmap;

                SaveImageAs(ext, fname, cDir, btmap);
            }
        }
Example #23
0
        /// <summary>
        /// 上传图片
        /// </summary>
        /// <returns></returns>
        public string UploadFile(HttpPostedFileBase File, fileType type = fileType.ImageType)
        {
            string FileName = null;

            if (File != null)
            {
                FileName = File.FileName; //获取文件名
            }

            string path = "";


            if (type == fileType.ImageType)
            {
                path = "/Data/Images/";
            }
            else if (type == fileType.CertificateType)
            {
                path = "/Data/Certificates/";
            }

            string sPath = Server.MapPath(path); //构造绝对路径

            Directory.CreateDirectory(sPath);    //创建目录

            string guid = "";

            if (FileName != null && FileName != "")
            {
                string FileType = FileName.Substring(FileName.LastIndexOf(".") + 1); //得到文件的后缀名
                guid = System.Guid.NewGuid().ToString() + "." + FileType;            //得到重命名的文件名
                File.SaveAs(Server.MapPath(path) + guid);                            //保存操作
                return(guid);
            }
            else
            {
                return("");
            }
        }
Example #24
0
        public static void printCode(string inFileName, fileType fType, string schemaNameSpace, string outFileName, bool showFile)
        {
            XmlReader appReader = null;

            // convert type
            if (fType == fileType.GmlProfile)
            {
                appReader = new GmlProfileReader(inFileName, schemaNameSpace);
            }
            else
            {
                //create fileReader
                appReader = new XmlReader(inFileName, schemaNameSpace);
            }

            //create CS- code of application schema
            appReader.printCsCode(outFileName);

            //show outfile in default application
            if (showFile)
            {
                Process.Start(outFileName);
            }
        }
Example #25
0
        private List <Bitmap> GetReferencedImages(MDLFile currentBinaryMDL)
        {
            List <Bitmap> retunvalue = new List <Bitmap>();
            List <string> possibleNS = currentBinaryMDL.header.NameSpaces.Where(x => x != "model" && x != "effect").ToList();

            // lets loop over our possible NS
            foreach (var imageNameSpace in possibleNS)
            {
                IEnumerable <FileInfo> myFiles = listBox1.Items.OfType <FileInfo>();
                foreach (var fileInfo in myFiles.Where(x => x.Name.ToLower() == imageNameSpace.ToLower() + ".mdl"))
                {
                    // lets try to load an image out of this file.
                    string fName = "";  // The namespace we got out of the file.
                    Bitmap resultImage; // The image that we loaded from the file.

                    fileType ft = LoadImage(fileInfo, imageNameSpace, out fName, out resultImage);
                    if (resultImage != null)
                    {// if we loaded an image lets add it to our list.
                        retunvalue.Add(resultImage);
                    }
                }
            }
            return(retunvalue);
        }
Example #26
0
        public static Extraction extraction(string filename, string path, String delimiter, bool lineWithHeaders, int selectedFolder, fileType fileType = fileType.CSV)
        {
            string totalPath = path + "\\" + filename;

            switch (fileType)
            {
            case fileType.CSV:

                return(GetExtractionCSV(totalPath, delimiter, lineWithHeaders, selectedFolder));

            case fileType.JSON:
                string folderAppPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);

                return(GetExtractionJSON(Path.Combine(folderAppPath, "JSONtoCSV.py"), totalPath, delimiter, lineWithHeaders, selectedFolder));

            case fileType.XML:

                return(GetExtractionXML(totalPath, delimiter, lineWithHeaders));

            default:
                break;
            }


            return(new Extraction());
        }
Example #27
0
        public void loadFile()
        {
            System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
            openFileDialog.InitialDirectory = "C:/Samples";
            openFileDialog.Filter = "DMC Files (*.DMC)|*.DMC;*.dmc|STL Files (*.stl, *.STL)|*.stl;*.STL";
            openFileDialog.FilterIndex = 2;
            openFileDialog.RestoreDirectory = false;
            openFileDialog.Title = "Select File";

            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    fileName = openFileDialog.FileName;
                    path = Path.GetDirectoryName(fileName);
                    string extension = new FileInfo(fileName).Extension;
                    switch (extension)
                    {
                        case ".dmc":
                        case ".DMC":
                            LoadedType = fileType.DMC;
                            if (stlLoaded)
                            {
                                tph.SwitchType.Visible = true;
                                tph.SwitchType.Text = "Switch To STL";
                            }
                            break;
                        case ".stl":
                        case ".STL":
                            LoadedType = fileType.STL;
                            if (stlLoaded)
                            {
                                tph.SwitchType.Visible = true;
                                tph.SwitchType.Text = "Switch To DMC";
                            }
                            break;
                        default:
                            LoadedType = fileType.None;
                            break;
                    }

                    if (fileName != null)
                    {
                        var reader = new StreamReader(fileName);
                        string partTemplate = iSwApp.GetUserPreferenceStringValue((int)swUserPreferenceStringValue_e.swDefaultTemplatePart);
                        if (modDoc == null)
                        {
                            modDoc = (IModelDoc2)iSwApp.NewDocument(partTemplate, (int)swDwgPaperSizes_e.swDwgPaperA2size, 0.0, 0.0);
                            modDoc.ShowNamedView2("*Isometric", -1);
                            swSelectionMgr = modDoc.SelectionManager;
                            vis = new Vis(iSwApp, modDoc);
                        }

                        while (!reader.EndOfStream)
                        {
                            string line = reader.ReadLine();
                            switch (LoadedType)
                            {
                                case fileType.DMC:
                                    scanDMC(line);
                                    break;
                                case fileType.STL:
                                    scanSTL(line);
                                    break;
                                default:
                                    break;
                            }
                        }
                        switch (LoadedType)
                        {
                            case fileType.DMC:
                                StartSwLines();
                                break;
                            case fileType.STL:
                                MakeTriangles();
                                break;
                            default:
                                break;
                        }
                    }
                }
                catch { }
            }
        }
Example #28
0
        public void loadFile()
        {
            System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
            openFileDialog.InitialDirectory = "C:/Samples";
            openFileDialog.Filter           = "DMC Files (*.DMC)|*.DMC;*.dmc|STL Files (*.stl, *.STL)|*.stl;*.STL";
            openFileDialog.FilterIndex      = 2;
            openFileDialog.RestoreDirectory = false;
            openFileDialog.Title            = "Select File";

            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    fileName = openFileDialog.FileName;
                    path     = Path.GetDirectoryName(fileName);
                    string extension = new FileInfo(fileName).Extension;
                    switch (extension)
                    {
                    case ".dmc":
                    case ".DMC":
                        LoadedType = fileType.DMC;
                        if (stlLoaded)
                        {
                            tph.SwitchType.Visible = true;
                            tph.SwitchType.Text    = "Switch To STL";
                        }
                        break;

                    case ".stl":
                    case ".STL":
                        LoadedType = fileType.STL;
                        if (stlLoaded)
                        {
                            tph.SwitchType.Visible = true;
                            tph.SwitchType.Text    = "Switch To DMC";
                        }
                        break;

                    default:
                        LoadedType = fileType.None;
                        break;
                    }

                    if (fileName != null)
                    {
                        var    reader       = new StreamReader(fileName);
                        string partTemplate = iSwApp.GetUserPreferenceStringValue((int)swUserPreferenceStringValue_e.swDefaultTemplatePart);
                        if (modDoc == null)
                        {
                            modDoc = (IModelDoc2)iSwApp.NewDocument(partTemplate, (int)swDwgPaperSizes_e.swDwgPaperA2size, 0.0, 0.0);
                            modDoc.ShowNamedView2("*Isometric", -1);
                            swSelectionMgr = modDoc.SelectionManager;
                            vis            = new Vis(iSwApp, modDoc);
                        }

                        while (!reader.EndOfStream)
                        {
                            string line = reader.ReadLine();
                            switch (LoadedType)
                            {
                            case fileType.DMC:
                                scanDMC(line);
                                break;

                            case fileType.STL:
                                scanSTL(line);
                                break;

                            default:
                                break;
                            }
                        }
                        switch (LoadedType)
                        {
                        case fileType.DMC:
                            StartSwLines();
                            break;

                        case fileType.STL:
                            MakeTriangles();
                            break;

                        default:
                            break;
                        }
                    }
                }
                catch { }
            }
        }
Example #29
0
        /// <summary>
        ///     Exports a file of a given type.
        ///     Formats available to export will depend on the type of the data.
        /// </summary>
        /// <param name="type">Type of the data to be exported</param>
        /// <param name="data">The data</param>
        /// <param name="arguments">Optional arguments to be used by the exporter</param>
        public static void export(fileType type, object data, params int[] arguments)
        {
            string fileName = null;

            switch (type)
            {
            case fileType.container:
                foreach (OContainer.fileEntry file in ((OContainer)data).content)
                {
                    Directory.CreateDirectory(System.Environment.CurrentDirectory + "\\" + ((OContainer)data).name);

                    fileName = Path.Combine(System.Environment.CurrentDirectory + "\\" + ((OContainer)data).name, file.name);
                    string dir = Path.GetDirectoryName(fileName);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    byte[] buffer;

                    if (file.loadFromDisk)
                    {
                        buffer = new byte[file.fileLength];
                        ((OContainer)data).data.Seek(file.fileOffset, SeekOrigin.Begin);
                        ((OContainer)data).data.Read(buffer, 0, buffer.Length);
                    }
                    else
                    {
                        buffer = file.data;
                    }

                    if (file.doDecompression)
                    {
                        buffer = LZSS_Ninty.decompress(buffer);
                    }

                    File.WriteAllBytes(fileName, buffer);
                    Console.WriteLine("Extracted file: " + fileName);
                }
                break;

            case fileType.model:
                for (int i = 0; i < ((RenderBase.OModelGroup)data).model.Count; i++)
                {
                    fileName = Path.Combine(System.Environment.CurrentDirectory, ((RenderBase.OModelGroup)data).model[i].name);

                    switch (arguments[0])
                    {
                    case 0: DAE.export(((RenderBase.OModelGroup)data), fileName + ".dae", i); break;

                    case 1: SMD.export(((RenderBase.OModelGroup)data), fileName + ".smd", i); break;

                    case 2: OBJ.export(((RenderBase.OModelGroup)data), fileName + ".obj", i); break;

                    case 3: CMDL.export(((RenderBase.OModelGroup)data), fileName + ".cmdl", i); break;
                    }

                    Console.WriteLine("Extracted file: " + fileName);
                }
                break;

            case fileType.texture:
                if (data.GetType().Equals(typeof(RenderBase.OModelGroup)))       //if extracting textures from a model
                {
                    Directory.CreateDirectory(System.Environment.CurrentDirectory + "\\" + ((RenderBase.OModelGroup)data).model[0].name + "_tex");

                    foreach (RenderBase.OTexture tex in ((RenderBase.OModelGroup)data).texture)
                    {
                        fileName = Path.Combine(System.Environment.CurrentDirectory + "\\" + ((RenderBase.OModelGroup)data).model[0].name + "_tex", tex.name + ".png");
                        tex.texture.Save(fileName);
                        Console.WriteLine("Extracted file: " + fileName);
                    }
                }
                else     // not a model
                {
                    fileName = Path.Combine(System.Environment.CurrentDirectory, ((RenderBase.OTexture)data).name + ".png");
                    ((RenderBase.OTexture)data).texture.Save(fileName);
                    Console.WriteLine("Extracted file: " + fileName);
                }
                break;

            case fileType.skeletalAnimation:
                fileName = Path.Combine(System.Environment.CurrentDirectory, ((RenderBase.OModelGroup)data).model[0].name);
                SMD.export((RenderBase.OModelGroup)data, fileName, arguments[0], arguments[1]);
                Console.WriteLine("Extracted file: " + fileName);
                break;
            }
            Console.WriteLine("Extracting files completed!");
        }
Example #30
0
 public void Add(String InternalName, String FileName, fileType FileType)
 {
     LoadObject temp;
     temp.FileName = FileName;
     temp.FileType = FileType;
     temp.InternalName = InternalName;
     Objects.Add(temp);
 }
Example #31
0
        /// <summary>
        ///     Imports a file of the given type.
        ///     Returns data relative to the chosen type.
        /// </summary>
        /// <param name="type">The type of the data</param>
        /// <returns></returns>
        public static object import(fileType type)
        {
            using (OpenFileDialog openDlg = new OpenFileDialog())
            {
                openDlg.Multiselect = true;

                switch (type)
                {
                case fileType.model:
                    openDlg.Title  = "Import models";
                    openDlg.Filter = "All files|*.*";

                    if (openDlg.ShowDialog() == DialogResult.OK)
                    {
                        List <RenderBase.OModel> output = new List <RenderBase.OModel>();
                        foreach (string fileName in openDlg.FileNames)
                        {
                            output.AddRange(((RenderBase.OModelGroup)load(fileName).data).model);
                        }
                        return(output);
                    }
                    break;

                case fileType.texture:
                    openDlg.Title  = "Import textures";
                    openDlg.Filter = "All files|*.*";

                    if (openDlg.ShowDialog() == DialogResult.OK)
                    {
                        List <RenderBase.OTexture> output = new List <RenderBase.OTexture>();
                        foreach (string fileName in openDlg.FileNames)
                        {
                            file file = load(fileName);
                            switch (file.type)
                            {
                            case formatType.model: output.AddRange(((RenderBase.OModelGroup)file.data).texture); break;

                            case formatType.texture: output.AddRange((List <RenderBase.OTexture>)file.data); break;

                            case formatType.image: output.Add((RenderBase.OTexture)file.data); break;
                            }
                        }
                        return(output);
                    }
                    break;

                case fileType.skeletalAnimation:
                    openDlg.Title  = "Import skeletal animations";
                    openDlg.Filter = "All files|*.*";

                    if (openDlg.ShowDialog() == DialogResult.OK)
                    {
                        RenderBase.OAnimationListBase output = new RenderBase.OAnimationListBase();
                        foreach (string fileName in openDlg.FileNames)
                        {
                            output.list.AddRange(((RenderBase.OModelGroup)load(fileName).data).skeletalAnimation.list);
                        }
                        return(output);
                    }
                    break;

                case fileType.materialAnimation:
                    openDlg.Title  = "Import material animations";
                    openDlg.Filter = "All files|*.*";

                    if (openDlg.ShowDialog() == DialogResult.OK)
                    {
                        RenderBase.OAnimationListBase output = new RenderBase.OAnimationListBase();
                        foreach (string fileName in openDlg.FileNames)
                        {
                            output.list.AddRange(((RenderBase.OModelGroup)load(fileName).data).materialAnimation.list);
                        }
                        return(output);
                    }
                    break;

                case fileType.visibilityAnimation:
                    openDlg.Title  = "Import visibility animations";
                    openDlg.Filter = "All files|*.*";

                    if (openDlg.ShowDialog() == DialogResult.OK)
                    {
                        RenderBase.OAnimationListBase output = new RenderBase.OAnimationListBase();
                        foreach (string fileName in openDlg.FileNames)
                        {
                            output.list.AddRange(((RenderBase.OModelGroup)load(fileName).data).visibilityAnimation.list);
                        }
                        return(output);
                    }
                    break;
                }
            }

            return(null);
        }
Example #32
0
        /// <summary>
        ///     Imports a file of the given type.
        ///     Returns data relative to the chosen type.
        /// </summary>
        /// <param name="type">The type of the data</param>
        /// <returns></returns>
        public static Object import(fileType type)
        {
            using (OpenFileDialog openDlg = new OpenFileDialog())
            {
                openDlg.Multiselect = true;

                switch (type)
                {
                    case fileType.model:
                        openDlg.Title = "Import Model";
                        openDlg.Filter = "All supported files|*.bch;*.bcmdl;*.bcres;*.cx;*.lz;*.cmp;*.zmdl;*.smes;*.smd";
                        openDlg.Filter += "|Binary CTR H3D|*.bch";
                        openDlg.Filter += "|Binary CTR Model|*.bcmdl";
                        openDlg.Filter += "|Binary CTR Resource|*.bcres";
                        openDlg.Filter += "|Compressed file|*.cx;*.lz;*.cmp";
                        openDlg.Filter += "|Fantasy Life Model|*.zmdl";
                        openDlg.Filter += "|New Love Plus Mesh|*.smes";
                        openDlg.Filter += "|StudioMdl Model|*.smd";
                        openDlg.Filter += "|All files|*.*";

                        if (openDlg.ShowDialog() == DialogResult.OK)
                        {
                            List<RenderBase.OModel> output = new List<RenderBase.OModel>();
                            foreach (string fileName in openDlg.FileNames)
                            {
                                try
                                {
                                    switch (Path.GetExtension(fileName).ToLower())
                                    {
                                        case ".smd": output.AddRange(SMD.import(fileName).model); break;
                                        default:
                                            byte[] buffer = File.ReadAllBytes(fileName);
                                            Stream data = new MemoryStream(buffer);
                                            fileFormat format = identify(fileName);
                                            if (isCompressed(format)) decompress(ref data, ref format);
                                            switch (format)
                                            {
                                                case fileFormat.flZMdl: output.AddRange(ZMDL.load(data).model); break;
                                                case fileFormat.nlpSMes: output.AddRange(NLP.loadMesh(data).model); break;
                                                case fileFormat.nw4cCGfx: output.AddRange(CGFX.load(data).model); break;
                                                case fileFormat.nw4cH3D: output.AddRange(BCH.load((MemoryStream)data).model); break;
                                                case fileFormat.pkmnContainer: 
                                                    GenericContainer.OContainer container = PkmnContainer.load(data);
                                                    switch (container.fileIdentifier)
                                                    {
                                                        case "PC": //Pokémon model
                                                            output.AddRange(BCH.load(new MemoryStream(container.content[0].data)).model);
                                                            break;
                                                        case "MM": //Pokémon Overworld model
                                                            output.AddRange(BCH.load(new MemoryStream(container.content[0].data)).model);
                                                            break;
                                                        case "GR": //Pokémon Map model
                                                            output.AddRange(BCH.load(new MemoryStream(container.content[1].data)).model);
                                                            break;
                                                        case "PT": //Pokémon texture
                                                            output.AddRange(BCH.load(new MemoryStream(container.content[0].data)).model);
                                                            break;
                                                        case "PK": //Pokemon Visibility/Skeletal animations
                                                            output.AddRange(BCH.load(new MemoryStream(container.content[0].data)).model);
                                                            break;
                                                        case "PB": //Pokémon material animations
                                                            output.AddRange(BCH.load(new MemoryStream(container.content[0].data)).model);
                                                            break;
                                                        case "AD": //???
                                                            output.AddRange(BCH.load(new MemoryStream(container.content[0].data)).model);
                                                            break;
                                                    }
                                                    break;
                                                default: data.Close(); break;
                                            }
                                            break;
                                    }
                                }
                                catch
                                {
                                    Debug.WriteLine("FileIO: Unable to import model file \"" + fileName + "\"!");
                                }
                            }
                            return output;
                        }
                        break;
                    case fileType.texture:
                        openDlg.Title = "Import Texture";
                        openDlg.Filter = "All supported files|*.bch;*.bcmdl;*.bcres;*.bctex;*.cx;*.lz;*.cmp;*.ztex";
                        openDlg.Filter += "|Binary CTR H3D|*.bch";
                        openDlg.Filter += "|Binary CTR Model|*.bcmdl";
                        openDlg.Filter += "|Binary CTR Resource|*.bcres";
                        openDlg.Filter += "|Binary CTR Texture|*.bctex";
                        openDlg.Filter += "|Compressed file|*.cx;*.lz;*.cmp";
                        openDlg.Filter += "|Fantasy Life Texture|*.ztex";
                        openDlg.Filter += "|All files|*.*";

                        if (openDlg.ShowDialog() == DialogResult.OK)
                        {
                            List<RenderBase.OTexture> output = new List<RenderBase.OTexture>();
                            foreach (string fileName in openDlg.FileNames)
                            {
                                byte[] buffer = File.ReadAllBytes(fileName);
                                Stream data = new MemoryStream(buffer);
                                fileFormat format = identify(fileName);
                                if (isCompressed(format)) decompress(ref data, ref format);
                                switch (format)
                                {
                                    case fileFormat.flZTex: output.AddRange(ZTEX.load(data)); break;
                                    case fileFormat.nw4cCGfx: output.AddRange(CGFX.load(data).texture); break;
                                    case fileFormat.nw4cH3D: output.AddRange(BCH.load((MemoryStream)data).texture); break;
                                    case fileFormat.pkmnContainer: 
                                        GenericContainer.OContainer container = PkmnContainer.load(data);
                                        switch (container.fileIdentifier)
                                        {
                                            case "PC": //Pokémon model
                                                output.AddRange(BCH.load(new MemoryStream(container.content[0].data)).texture);
                                                break;
                                            case "MM": //Pokémon Overworld model
                                                output.AddRange(BCH.load(new MemoryStream(container.content[0].data)).texture);
                                                break;
                                            case "GR": //Pokémon Map model
                                                output.AddRange(BCH.load(new MemoryStream(container.content[1].data)).texture);
                                                break;
                                            case "PT": //Pokémon texture
                                                output.AddRange(BCH.load(new MemoryStream(container.content[0].data)).texture);
                                                break;
                                            case "PK": //Pokemon Visibility/Skeletal animations
                                                output.AddRange(BCH.load(new MemoryStream(container.content[0].data)).texture);
                                                break;
                                            case "PB": //Pokémon material animations
                                                output.AddRange(BCH.load(new MemoryStream(container.content[0].data)).texture);
                                                break;
                                            case "AD": //???
                                                output.AddRange(BCH.load(new MemoryStream(container.content[0].data)).texture);
                                                break;
                                        }
                                        break;
                                    default: data.Close(); break;
                                }
                            }
                            return output;
                        }
                        break;
                    case fileType.skeletalAnimation:
                        openDlg.Title = "Import Skeletal Animation";
                        openDlg.Filter = "All supported files|*.bch;*.bcres;*.bcskla;*.smd";
                        openDlg.Filter += "|Binary CTR H3D|*.bch";
                        openDlg.Filter += "|Binary CTR Resource|*.bcres";
                        openDlg.Filter += "|Binary CTR Skeletal Animation|*.bcskla";
                        openDlg.Filter += "|StudioMdl Model|*.smd";
                        openDlg.Filter += "|All files|*.*";

                        if (openDlg.ShowDialog() == DialogResult.OK)
                        {
                            RenderBase.OAnimationListBase output = new RenderBase.OAnimationListBase();
                            foreach (string fileName in openDlg.FileNames)
                            {
                                switch (Path.GetExtension(fileName).ToLower())
                                {
                                    case ".smd": output.list.AddRange(SMD.import(fileName).skeletalAnimation.list); break;
                                    default:
                                        byte[] buffer = File.ReadAllBytes(fileName);
                                        Stream data = new MemoryStream(buffer);
                                        fileFormat format = identify(fileName);
                                        if (isCompressed(format)) decompress(ref data, ref format);
                                        switch (format)
                                        {
                                            case fileFormat.nw4cCGfx: output.list.AddRange(CGFX.load(data).skeletalAnimation.list); break;
                                            case fileFormat.nw4cH3D: output.list.AddRange(BCH.load((MemoryStream)data).skeletalAnimation.list); break;
                                            default: data.Close(); break;
                                        }
                                        break;
                                }
                            }
                            return output;
                        }
                        break;
                    case fileType.materialAnimation:
                        openDlg.Title = "Import Material Animation";
                        openDlg.Filter = "All supported files|*.bch;";
                        openDlg.Filter += "|Binary CTR H3D|*.bch";
                        openDlg.Filter += "|All files|*.*";

                        if (openDlg.ShowDialog() == DialogResult.OK)
                        {
                            RenderBase.OAnimationListBase output = new RenderBase.OAnimationListBase();
                            foreach (string fileName in openDlg.FileNames)
                            {

                                byte[] buffer = File.ReadAllBytes(fileName);
                                Stream data = new MemoryStream(buffer);
                                fileFormat format = identify(fileName);
                                if (isCompressed(format)) decompress(ref data, ref format);
                                switch (format)
                                {
                                    case fileFormat.nw4cCGfx: output.list.AddRange(CGFX.load(data).materialAnimation.list); break;
                                    case fileFormat.nw4cH3D: output.list.AddRange(BCH.load((MemoryStream)data).materialAnimation.list); break;
                                    default: data.Close(); break;
                                }
                            }
                            return output;
                        }
                        break;
                    case fileType.visibilityAnimation:
                        openDlg.Title = "Import Visibility Animation";
                        openDlg.Filter = "All supported files|*.bch;";
                        openDlg.Filter += "|Binary CTR H3D|*.bch";
                        openDlg.Filter += "|All files|*.*";

                        if (openDlg.ShowDialog() == DialogResult.OK)
                        {
                            RenderBase.OAnimationListBase output = new RenderBase.OAnimationListBase();
                            foreach (string fileName in openDlg.FileNames)
                            {

                                byte[] buffer = File.ReadAllBytes(fileName);
                                Stream data = new MemoryStream(buffer);
                                fileFormat format = identify(fileName);
                                if (isCompressed(format)) decompress(ref data, ref format);
                                switch (format)
                                {
                                    case fileFormat.nw4cCGfx: output.list.AddRange(CGFX.load(data).visibilityAnimation.list); break;
                                    case fileFormat.nw4cH3D: output.list.AddRange(BCH.load((MemoryStream)data).visibilityAnimation.list); break;
                                    default: data.Close(); break;
                                }
                            }
                            return output;
                        }
                        break;
                }
            }

            return null;
        }
Example #33
0
        /// <summary>
        ///     Imports a file of the given type.
        ///     Returns data relative to the chosen type.
        /// </summary>
        /// <param name="type">The type of the data</param>
        /// <returns></returns>
        public static object import(fileType type)
        {
            using (OpenFileDialog openDlg = new OpenFileDialog())
            {
                openDlg.Multiselect = true;

                switch (type)
                {
                    case fileType.model:
                        openDlg.Title = "Import models";
                        openDlg.Filter = "All files|*.*";

                        if (openDlg.ShowDialog() == DialogResult.OK)
                        {
                            omodelOutput = new List<RenderBase.OModel>();
                            foreach (string fileName in openDlg.FileNames)
                            {
                                omodelOutput.AddRange(((RenderBase.OModelGroup)load(fileName).data).model);
                            }
                            return omodelOutput;
                        }
                        break;
                    case fileType.texture:
                        openDlg.Title = "Import textures";
                        openDlg.Filter = "All files|*.*";

                        if (openDlg.ShowDialog() == DialogResult.OK)
                        {
                            otexOutput = new List<RenderBase.OTexture>();
                            foreach (string fileName in openDlg.FileNames)
                            {
                                file file = load(fileName);
                                switch (file.type)
                                {
                                    case formatType.model: otexOutput.AddRange(((RenderBase.OModelGroup)file.data).texture); break;
                                    case formatType.texture: otexOutput.AddRange((List<RenderBase.OTexture>)file.data); break;
                                }
                            }
                            return otexOutput;
                        }
                        break;
                    case fileType.skeletalAnimation:
                        openDlg.Title = "Import skeletal animations";
                        openDlg.Filter = "All files|*.*";

                        if (openDlg.ShowDialog() == DialogResult.OK)
                        {
                            output = new RenderBase.OAnimationListBase();
                            foreach (string fileName in openDlg.FileNames)
                            {
                                try
                                {
                                    output.list.AddRange(((RenderBase.OModelGroup)load(fileName).data).skeletalAnimation.list);
                                }
                                catch
                                {
                                }
                            }
                            return output;
                        }
                        break;
                    case fileType.materialAnimation:
                        openDlg.Title = "Import material animations";
                        openDlg.Filter = "All files|*.*";

                        if (openDlg.ShowDialog() == DialogResult.OK)
                        {
                            output = new RenderBase.OAnimationListBase();
                            foreach (string fileName in openDlg.FileNames)
                            {
                                try
                                {
                                    output.list.AddRange(((RenderBase.OModelGroup)load(fileName).data).materialAnimation.list);
                                }
                                catch
                                {
                                }
                            }
                            return output;
                        }
                        break;
                    case fileType.visibilityAnimation:
                        openDlg.Title = "Import visibility animations";
                        openDlg.Filter = "All files|*.*";

                        if (openDlg.ShowDialog() == DialogResult.OK)
                        {
                            output = new RenderBase.OAnimationListBase();
                            foreach (string fileName in openDlg.FileNames)
                            {
                                try
                                {
                                    output.list.AddRange(((RenderBase.OModelGroup)load(fileName).data).visibilityAnimation.list);
                                }
                                catch
                                {
                                }
                            }
                            return output;
                        }
                        break;
                }
            }

            return null;
        }
Example #34
0
 public overrideMap(string Location, string FileName, fileType type)
 {
     this.Location = Location;
     this.FileName = FileName;
     this.type     = type;
 }
Example #35
0
 /// <summary>
 ///     Exports a file of a given type.
 ///     Formats available to export will depend on the type of the data.
 /// </summary>
 /// <param name="type">Type of the data to be exported</param>
 /// <param name="data">The data</param>
 /// <param name="arguments">Optional arguments to be used by the exporter</param>
 public static void export(fileType type, Object data, List<int> arguments = null)
 {
     using (SaveFileDialog saveDlg = new SaveFileDialog())
     {
         switch (type)
         {
             case fileType.model:
                 OModelExportForm exportMdl = new OModelExportForm((RenderBase.OModelGroup)data, arguments[0]);
                 exportMdl.Show();
                 break;
             case fileType.texture:
                 OTextureExportForm exportTex = new OTextureExportForm((RenderBase.OModelGroup)data, arguments[0]);
                 exportTex.Show();
                 break;
             case fileType.skeletalAnimation:
                 saveDlg.Title = "Export Skeletal Animation";
                 saveDlg.Filter = "Source Model|*.smd";
                 if (saveDlg.ShowDialog() == DialogResult.OK)
                 {
                     switch (saveDlg.FilterIndex)
                     {
                         case 1:
                             SMD.export((RenderBase.OModelGroup)data, saveDlg.FileName, arguments[0], arguments[1]);
                             break;
                     }
                 }
                 break;
         }
     }
 }
Example #36
0
 public ImportSetting GetImportSetting(fileType fileType)
 {
     return(marketREntities.ImportSettings.Where(d => d.FileType == (int)fileType).FirstOrDefault());
 }