static void Main(string[] args) { string dir = "C:\\Documents and Settings\\eric\\My Documents\\Trunk\\Data\\Gate Study Data\\LabeledPartsSketches\\COPY_and_EQN sketches\\"; string searchPattern = "*.labeled.xml"; string[] files = Directory.GetFiles(dir, searchPattern); foreach (string filename in files) { //string filename = dir + "01_EQ1_UCR_T.labeled.xml"; Sketch.Sketch sketch = new ReadXML(filename).Sketch; MakeXML make2 = new MakeXML(sketch); make2.WriteXML(filename); sketch = General.ReOrderParentShapes(sketch); foreach (Substroke stroke in sketch.SubstrokesL) { for (int i = 0; i < stroke.ParentShapes.Count - 1; i++) { stroke.ParentShapes[i].AddShape(stroke.ParentShapes[i + 1]); } } MakeXML make = new MakeXML(sketch); make.WriteXML(filename); } }
/// <summary> /// Method for saving sketch as xml file /// </summary> /// <param name="filename">String containing xml filename</param> /// <param name="sketch">Sketch.Sketch object</param> public void XMLWrite(String filename, Sketch.Sketch sketch) { //create a new xml object and write the xml file MakeXML xmlFile = new MakeXML(sketch); xmlFile.WriteXML(filename); }
/// <summary> /// This method saves the user-generated sketch in the MIT xml format /// </summary> /// <param name="sketch">Sketch.Sketch object to be written to xml</param> /// <returns>String containing the generated xml's filepath</returns> String XMLWrite(Sketch.Sketch sketch) { inkCol.AutoRedraw = true; SaveFileDialog saveDialog = new SaveFileDialog(); String filename; saveDialog.Filter = "XML files (*.xml)|*.xml"; if (saveDialog.ShowDialog() == DialogResult.OK) { try { filename = saveDialog.FileName.ToLower(); MakeXML xmlFile = new MakeXML(sketch); xmlFile.WriteXML(filename); return(filename); } catch (IOException /*ioe*/) { MessageBox.Show("File error"); } } return(null); }
private void miBackupXMLGame_Click(object sender, EventArgs e) { ShortGame sGame = (ShortGame)lvGames.SelectedItems[0].Tag; string gameWPath = Path.Combine(_OutPPath, PlatformName, sGame.FileName.Split('.')[0]); var backupGame = _xfGames.ScrapBackupGame(sGame.ID); MakeXML.Backup_Game(gameWPath, backupGame, "TBGame"); }
/// <summary> /// Make Info Xml /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void miInfoXml_Click(object sender, EventArgs e) { ShortGame sGame = (ShortGame)lvGames.SelectedItems[0].Tag; string gameWPath = Path.Combine(_OutPPath, PlatformName, sGame.FileName.Split('.')[0]); var fGame = _xfGames.ScrapGame(sGame.ID); MakeXML.InfoGame(gameWPath, fGame); }
static void Main(string[] args) { if (args.Length != 2) { return; } string[] files = Directory.GetFiles(args[0], args[1]); string dirOut = args[0] + "\\Flipped\\"; if (!Directory.Exists(dirOut)) { Directory.CreateDirectory(dirOut); } float minT = 3000.0f; foreach (string file in files) { Sketch.Sketch sketch = new ReadXML(file).Sketch; if (file.Contains("_P.labeled")) { float max = 0f; foreach (Point pt in sketch.Points) { max = Math.Max(max, pt.Y); } max += minT; foreach (Point pt in sketch.Points) { pt.Y = max - pt.Y; } } MakeXML make = new MakeXML(sketch); make.WriteXML(dirOut + Path.GetFileName(file)); } }
/// <summary> /// Sends the sketch to the networked Wizard Labeler. /// </summary> /// <param name="sketch">The sketch to send</param> /// <param name="selectedStrokes">Selection of strokes to recognize (ignored for now)</param> /// <param name="userTriggered">True iff the user triggered recognition</param> void Recognizer.recognize(Sketch.Sketch sketch, Sketch.Stroke[] selectedStrokes, bool userTriggered) { // For fast sketchers, XML (un)marshalling causes a bottleneck. // Here we limit the frequency with which the Wizard is updated // in order to avoid crashes due to this bottleneck. if (!userTriggered && (DateTime.Now.Ticks - lastSketchSent.Ticks) <= WizardMaxUpdateThreshold) { Console.WriteLine("Fast sketcher! Skipping Wizard Labeler Update. Duration: " + (DateTime.Now.Ticks - lastSketchSent.Ticks)); return; } Console.WriteLine("Firing send. Duration: " + (DateTime.Now.Ticks - lastSketchSent.Ticks)); // Create XML from the sketch MakeXML makeXml = new MakeXML(sketch); // If the user triggered recognition, then // internally remember this event so that // the recognizer will fire a recognition // event as soon as a result is received. this.waitingOnWizard = userTriggered; // Give XML to the SocketClient for transmittal string xmlStr = makeXml.getXMLstr(); DefaultNamespace.SocketClient.SocketClientSendXml sendDelegate = new DefaultNamespace.SocketClient.SocketClientSendXml(socketClient.SendXml); sendDelegate.BeginInvoke(xmlStr, userTriggered, null, null); //TextWriter errorWriter = new StreamWriter("errorSketch.xml"); //errorWriter.Write(xmlStr); // Record when sketch was sent lastSketchSent = DateTime.Now; }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("BatchDRSConverter: Convert DRS formatted files to MIT XML formatted files"); Console.WriteLine("usage: BatchDRSConverter.exe [-d input_directory] [-o output_directory] [files]"); Console.WriteLine("if an input directory is given, extra files on the command line are ignored"); Environment.Exit(1); } string indir = "", outdir = ""; for (int i = 0; i < args.Length; i++) { if (args[i] == "-d") { indir = args[++i]; } else if (args[i] == "-o") { outdir = args[++i]; } } List <string> files = new List <string>(); if (indir == "") { for (int i = 0; i < args.Length; i++) { if (args[i] == "-o") { i++; } else { files.Add(args[i]); } } } else { if (!Directory.Exists(indir)) { Console.WriteLine("Input directory '{0}' does not exist. Exiting.", indir); Environment.Exit(1); } files.AddRange(Directory.GetFiles(indir, ".drs")); files.AddRange(Directory.GetFiles(indir, ".DRS")); } foreach (string file in files) { if (!File.Exists(file)) { Console.WriteLine("File '{0}' does not exist. Continuing.", file); } Sketch.Sketch sketch = ReadDRS.load(file); MakeXML mxml = new MakeXML(sketch); string outfile = ""; if (outdir == "") { outfile = file.Substring(0, file.LastIndexOf('.')) + ".xml"; } else { outfile = outdir + file.Substring(file.LastIndexOf(Path.DirectorySeparatorChar), file.LastIndexOf('.') - file.LastIndexOf(Path.DirectorySeparatorChar)) + ".xml"; } mxml.WriteXML(outfile); } }
/// <summary> /// Returns the XML representation of this sketch. /// </summary> /// <returns>The XML for this sketch</returns> public string GetSketchXML() { MakeXML xmlHolder = new MakeXML(Sketch); return(xmlHolder.getXMLstr()); }
/// <summary> /// Saves this Sketch to the specified file path. /// </summary> /// <param name="filename">The path of the file to write</param> public void SaveSketch(string filename) { MakeXML xmlHolder = new MakeXML(Sketch); xmlHolder.WriteXML(filename); }
/// <summary> /// /// </summary> internal bool Run() { ITrace.WriteLine(prefix: false); #region // Verifications // Todo Verifications with zip and 7z //if (Directory.Exists(_GamePath)) //{ //} #endregion /* Déplacé 2020 * // Creation of System folder and working assign * ITrace.WriteLine($"[Run] {Lang.CreationFolder}: '{_SystemName}'"); * Directory.CreateDirectory(_SystemName); * Directory.SetCurrentDirectory(_SystemPath); * * // Creation of Game folder * ITrace.WriteLine($"[Run] {Lang.CreationFolder}: '{_GamePath}'"); * Directory.CreateDirectory(_GamePath); */ //2020 Directory.SetCurrentDirectory(_GamePath); #region Creation of the Infos.xml if (Settings.Default.opInfos) { MakeXML.InfoGame(_GamePath, _ZeGame); } else { ITrace.WriteLine("[Run] Make info disabled"); } #endregion // Tree root + lvl1 MakeStructure(); // Copy Roms #region 22/08/2020 new rom management vApps = CopyRoms(_zBackGame.ApplicationPath, _Tree.Children[nameof(SubFolder.Roms)].Path); //vApps = CopySpecific(_zBackGame.ApplicationPath, _Tree.Children["Roms"].Path, "Roms", x => _zBackGame.ApplicationPath = x); #endregion // Video, Music, Manual vManual = CopySpecific(_zBackGame.ManualPath, _Tree.Children[nameof(SubFolder.Manuals)].Path, "Manual", x => _zBackGame.ManualPath = x); vMusic = CopySpecific(_zBackGame.MusicPath, _Tree.Children[nameof(SubFolder.Musics)].Path, "Music", x => _zBackGame.MusicPath = x); vVideo = CopySpecific(_zBackGame.VideoPath, _Tree.Children[nameof(SubFolder.Videos)].Path, "Video", x => _zBackGame.VideoPath = x); // CopySpecificFiles() old way; // Copy images CopyImages(); #region Copy CheatCodes if (Settings.Default.opCheatCodes && !string.IsNullOrEmpty(Settings.Default.CCodesPath)) { CopyCheatCodes(); } else { ITrace.WriteLine("[Run] Copy Cheat Codes disabled"); } #endregion #region Copy Clones if (Settings.Default.opClones) { CopyClones(); } else { ITrace.WriteLine($"[Run] Clone copy disabled"); } #endregion #region Serialization / backup ameliorated of launchbox datas (with found medias missing) if (Settings.Default.opEBGame) { MakeXML.Backup_Game(_GamePath, _zBackGame, "EBGame"); } else { ITrace.WriteLine($"[Run] Enhanced Backup Game disabled"); } #endregion #region Save Struct if (Settings.Default.opTreeV) { GetStruc(); } else { ITrace.WriteLine($"[Run] Save Struct disabled"); } #endregion #region 2020 Résultats // au lieu de mettre à true le bool au moment de la copie, //on fait un recheck au cas où l'utilisateur a modifié le contenu) //PackMeRes.ShowDialog(vGame, vManual, vMusic, vVideo, vApps); PackMeRes2 pmr2 = new PackMeRes2(_Tree.Path) { GameName = _zBackGame.Title, // Destinations /*CheatPath = _Tree.Children[nameof(SubFolder.CheatCodes)].Path, * ManualPath = _Tree.Children[nameof(SubFolder.Manuals)].Path, * MusicPath = _Tree.Children[nameof(SubFolder.Musics)].Path, * RomPath = _Tree.Children[nameof(SubFolder.Roms)].Path, * VideoPath = _Tree.Children[nameof(SubFolder.Videos)].Path,*/ // Sources SourceRomPath = _ZePlatform.FolderPath, SourceManuelPath = _ZePlatform.PlatformFolders.FirstOrDefault(x => x.MediaType == "Manual"), SourceMusicPath = _ZePlatform.PlatformFolders.FirstOrDefault(x => x.MediaType == "Music"), SourceVideoPath = _ZePlatform.PlatformFolders.FirstOrDefault(x => x.MediaType == "Video"), }; // Liste des manuels //pmr2.Musics = Directory.GetFiles(_Tree.Children["Musics"].Path, "*.*", System.IO.SearchOption.TopDirectoryOnly); pmr2.LoadDatas(); pmr2.ShowDialog(); //pmr2.AddManual(); #endregion #region 2020 choix du nom // Fenêtre pour le choix du nom GameName gnWindows = new GameName(); gnWindows.SuggestedGameName = _ZeGame.ExploitableFileName; gnWindows.ShowDialog(); // Changement de nom du dossier ushort i = 0; string destFolder = Path.Combine(_SystemPath, gnWindows.ChoosenGameName); if (!_GamePath.Equals(destFolder)) { while (i < 10) { try { Directory.Move(_GamePath, destFolder); ITrace.WriteLine("Folder successfully renamed"); // Attribution du résultat _GamePath = destFolder; // Sortie break; } catch (IOException ioe) { ITrace.WriteLine($"Try {i}: {ioe}"); Thread.Sleep(10); i++; } } } //string destArchLink = Path.Combine(path, $"{destArchive}"); //string destArchLink = Path.Combine(path, gnWindows.ChoosenGameName); // On verra si on dissocie un jour _ZeGame.ExploitableFileName = gnWindows.ChoosenGameName; #endregion // Archive //string destArchive = Path.Combine(_SystemPath, _ZeGame.ExploitableFileName); #region Compression // Zip if (Properties.Settings.Default.opZip) { // MessageBox.Show("test "+ destArchive); // Make_Zip(destArchive); // ZipCompression.Make_Folder(_GamePath, _SystemPath, destArchive); ZipCompression.Make_Folder(_GamePath, _SystemPath, _ZeGame.ExploitableFileName); } else { ITrace.WriteLine($"[Run] Zip Compression disabled"); } // 7-Zip if (Properties.Settings.Default.op7_Zip) { //MessageBox.Show("test " + destArchive); // SevenZipCompression.Make_Folder(_GamePath, _SystemPath, destArchive); SevenZipCompression.Make_Folder(_GamePath, _SystemPath, _ZeGame.ExploitableFileName); } else { ITrace.WriteLine($"[Run] 7z Compression disabled"); } #endregion // Erase the temp folder if (MessageBox.Show($"{Lang.EraseTmpFolder} '{_ZeGame.ExploitableFileName}' ?", Lang.Erase, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { Directory.SetCurrentDirectory(_WFolder); Directory.Delete(_GamePath, true); Console.WriteLine($"[Run] folder {_GamePath} erased"); } catch (Exception exc) { Console.WriteLine($"[Run] Error when Erasing temp folder {_GamePath}\n{exc.Message }"); } } // Stop loggers if (_IScreen != null) { _IScreen.KillAfter(10); } ITrace.RemoveListerners(_Loggers); return(true); }
/// <summary> /// ... /// Créer un fichier xml après collection des données dans le fichier xml de launchbox si activé /// </summary> /// <param name="xFile">believe... xml file </param> /// <param name="GameFile">Game file (exploitable)</param> internal int Initialize(string xFile, ShortGame sGame) { // Verif if (string.IsNullOrEmpty(ID)) { throw new Exception("Id property: null"); } if (string.IsNullOrEmpty(_SystemName)) { throw new Exception(); } _WFolder = Properties.Settings.Default.OutPPath; // Chemin du dossier temporaire du system _SystemPath = Path.Combine(_WFolder, _SystemName); _GamePath = Path.Combine(_SystemPath, $"{sGame.ExploitableFileName}"); // New Working Folder string logFile = Path.Combine(_WFolder, $"{_SystemName} - {sGame.ExploitableFileName}.log"); // Todo peut être déclencher un event sur le stop pour couper net ? var folderRes = OPFolders.SVerif(_GamePath, "Initialize", Dcs_Buttons.NoPass | Dcs_Buttons.NoRename, (string message) => ITrace.WriteLine(message, true)); if (folderRes == EDestDecision.Stop) { // ITrace.WriteLine("[Initialize] GoodBye !"); if (_IScreen != null) { _IScreen.Close(); } ITrace.RemoveListener(_IScreen); return(200); } #region System d'affichage string prefix = "PackMe"; //window if (Settings.Default.opLogWindow) { _IScreen = new InfoScreen(); _IScreen.Prefix = prefix; _IScreen.Show(); _Loggers.Add(_IScreen); } // file if (Settings.Default.opLogFile) { InfoToFile iLog = new InfoToFile(logFile, true); iLog.Prefix = prefix; _Loggers.Add(iLog); } // debug if (Debugger.IsAttached) { InfoToConsole iConsole = new InfoToConsole(); iConsole.Prefix = prefix; _Loggers.Add(iConsole); } ITrace.AddListeners(_Loggers); ITrace.WriteLine("===== Report of errors: ====="); ITrace.WriteLine($"[Initialize] ID:\t'{ID}'"); ITrace.WriteLine($"[Initialize] {Lang.SystemSelected}: '{_SystemName}'"); ITrace.WriteLine($"[Initialize] {Lang.GameSelected}: '{sGame.Title}' - Rom: '{sGame.ExploitableFileName}'"); #endregion /* * BackgroundWorker bw = new BackgroundWorker(); * bw.DoWork += new DoWorkEventHandler(BwWork); // PackMe.Initialize(_XmlFPlatform); * bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BWRunWorkerCompleted); * bw.RunWorkerAsync(); */ // Lecture du fichier platform XML_Functions xmlPlatform = new XML_Functions(); xmlPlatform.ReadFile(Path.Combine(Properties.Settings.Default.LBPath, Properties.Settings.Default.fPlatforms)); _ZePlatform = xmlPlatform.ScrapPlatform(_SystemName); // Reconstruct PlatformFolder Path foreach (PlatformFolder plfmFolder in _ZePlatform.PlatformFolders) { plfmFolder.FolderPath = ReconstructPath(plfmFolder.FolderPath); } // Lecture du fichier des jeux _XFunctions = new XML_Functions(); _XFunctions.ReadFile(xFile); // Get Main infos _zBackGame = _XFunctions.ScrapBackupGame(ID); _ZeGame = (GameInfo)_zBackGame; #region 2020 // Creation of System folder and working assign ITrace.WriteLine($"[Run] {Lang.CreationFolder}: '{_SystemName}'"); Directory.CreateDirectory(_SystemName); Directory.SetCurrentDirectory(_SystemPath); // Creation of Game folder ITrace.WriteLine($"[Run] {Lang.CreationFolder}: '{_GamePath}'"); Directory.CreateDirectory(_GamePath); #endregion #region Original Backup Game if (Settings.Default.opOBGame) { MakeXML.Backup_Game(_GamePath, _zBackGame, "TBGame"); } else { ITrace.WriteLine("[Run] Original Backup Game disabled"); } #endregion _LBoxDI = new DirectoryInfo(Settings.Default.LBPath); // Set active Directory to Root Directory.SetCurrentDirectory(_WFolder); #region Paths reconstruction _zBackGame.ApplicationPath = ReconstructPath(_zBackGame.ApplicationPath); _zBackGame.ManualPath = ReconstructPath(_zBackGame.ManualPath); _zBackGame.MusicPath = ReconstructPath(_zBackGame.MusicPath); _zBackGame.VideoPath = ReconstructPath(_zBackGame.VideoPath); #endregion return(0); }