// --- #region Extraction protected void ExtractDataFiles(DataRep g, string tmpPath) { string fileExt = Path.GetExtension(g.CurrentPath).TrimStart('.'); // Détection du mode if (fileExt.Equals("zip", StringComparison.OrdinalIgnoreCase)) { // Extraction des fichiers ZipDecompression zippy = new ZipDecompression() { TokenSource = this.TokenSource, IsPaused = this.IsPaused, }; zippy.ExtractSpecificFiles(g.CurrentPath, tmpPath, "DPGame.json", "NBGame.xml", "TBGame.xml", "EBGame.xml"); } else if (fileExt.Equals("7zip", StringComparison.OrdinalIgnoreCase) || fileExt.Equals("7z", StringComparison.OrdinalIgnoreCase)) { // Extraction des fichiers SevenZipDecompression sevZipp = new SevenZipDecompression() { TokenSource = this.TokenSource, IsPaused = this.IsPaused, }; sevZipp.ExtractSpecificFiles(g.CurrentPath, tmpPath, "DPGame.json", "NBGame.xml", "TBGame.xml", "EBGame.xml"); } else { throw new Exception("File format not managed"); } }
public static void SaveDataRepLinqXML(string FileName, DataRep obj) { try { if (FileName.Length == 0) { FileName = "Log.xml"; } if (File.Exists(FileName)) { XDocument doc = XDocument.Load(FileName); XElement track = new XElement("DataRep", new XElement("Event", obj.Event), new XElement("Date", obj.Date)); doc.Root.Add(track); doc.Save(FileName); } else { FileName = "Log.xml"; List <DataRep> objS = new List <DataRep>(); objS.Add(new DataRep { Date = obj.Date, Event = obj.Event }); SaveDataRepSerializXML(FileName, objS); } } catch (Exception x) { Console.Write("SaveDataRepLinqXML: " + x.Message); } }
private void UnsetDefault(object tag, Func <DataRep, object> SetChosen) { DataRep dr = (DataRep)tag; dr.IsSelected = false; SetChosen(null); }
private string AssignDefaultPath(string destPath, DataRep defaultPath) { if (defaultPath == null) { return(null); } return(DxPath.To_Relative(destPath, defaultPath.DestPath));; }
internal void ThemeVideo_Handler(DataRep selected, bool isChecked) { if (isChecked) { SetDefault(selected, VideosCollection, ChosenVideo, (x) => ChosenThemeVideo = x); } else { UnsetDefault(selected, (x) => ChosenThemeVideo = x); } }
/// <summary> /// Initialize une collection avec une copie modifiée des datareps pour montrer l'arborescence dans le nom /// </summary> /// <param name="srcCollected"></param> /// <param name="targetedCollec"></param> /// <param name="mediatype"></param> protected void MakeCollection(IEnumerable <DataRep> srcCollected, ObservableCollection <DataRep> targetedCollec, string link) { // string pRoot = Path.Combine(Root, link); targetedCollec.Clear(); foreach (DataRep elem in srcCollected) { DataRep dr = DataRep.DataRepFactory(elem); dr.Name = dr.DestPath.Replace(link, "."); targetedCollec.Add(dr); } }
public void Write(BinaryWriter writer) { writer.Write(MajorVersion); writer.Write(MinorVersion); writer.Write((byte)Type); writer.Write((byte)Flags); writer.Write(DataRep.ToArray()); writer.Write(FragmentLength); writer.Write(AuthLength); writer.Write(CallId); }
private void AddWVerif(string fichier, List <DataRep> liste) { foreach (var fr in liste) { if (fr.CurrentPath.Equals(fichier)) { return; } } liste.Add(DataRep.MakeNormal(fichier)); }
internal void SetDefault(DataRep dr, ObservableCollection <DataRep> collection, DataRep other, Action <DataRep> SetChosen) { foreach (var elem in collection) { if (elem != other && elem != dr) { elem.IsSelected = false; } } dr.IsSelected = true; SetChosen(dr); }
void DPG7ZipCore(DataRep zF, string gamePath) { // Extraction des fichiers xml SevenZipDecompression zippy = new SevenZipDecompression() { TokenSource = this.TokenSource, IsPaused = this.IsPaused, }; SafeBoxes.LaunchDouble(zippy, () => zippy.ExtractSpecificFiles(zF.CurrentPath, gamePath, "NBGame.xml", "TBGame.xml", "EBGame.xml", "DPGame.json"), "SevenZip Extraction"); }
void DPGZipCore(DataRep archive, string gamePath) { // Extraction des fichiers xml ZipDecompression zippy = new ZipDecompression() { TokenSource = this.TokenSource, IsPaused = this.IsPaused, }; SafeBoxes.LaunchDouble(zippy, () => zippy.ExtractSpecificFiles(archive.CurrentPath, gamePath, "NBGame.xml", "TBGame.xml", "EBGame.xml", "DPGame.json"), "Zip Extraction"); /*var res = PackMe_IHM.ZipCompressFolder(zippy, () => zippy.CompressFolder( * gamePath, title, PS.Default.cZipCompLvl), "Compression Zip");*/ }
private void LoadFiles2(string path, ObservableCollection <DataRep> collection) { if (!Directory.Exists(path)) { return; } foreach (string f in Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories)) { // on ajoute que si non présent var test = collection.FirstOrDefault((x) => x.DestPath.Equals(f)); if (test == null) { DataRep dr = new DataRep(f); dr.DestPath = f; dr.Name = dr.DestPath.Replace(path, "."); collection.Add(dr); } } }
protected bool Depacking(DataRep g, string tmpPath) { string fileExt = Path.GetExtension(g.CurrentPath).TrimStart('.'); // Décompression // Détection du mode if (fileExt.Equals("zip", StringComparison.OrdinalIgnoreCase)) { DepackZip(g.CurrentPath, tmpPath); } else if (fileExt.Equals("7zip", StringComparison.OrdinalIgnoreCase) || fileExt.Equals("7z", StringComparison.OrdinalIgnoreCase)) { Depack7Zip(g.CurrentPath, tmpPath); } else { throw new Exception("File format not managed"); } return(true); }
//Запись логов в файл public static void SaveLog(string info = "") { try { if (info.Length != 0) { string StrDate = String.Format("{0:H:mm:ss}", DateTime.Now); string PatchGate = ""; PatchGate = "Log.xml"; DataRep obj = new DataRep(); obj.Date = DateTime.Parse(StrDate); obj.Event = info; SaveDataRepLinqXML(PatchGate, obj); } } catch (Exception x) { Console.Write(x.Message); } }
internal static void Alter_EBPaths(DataRep g, string destPath) { string tmpFile = Path.Combine(destPath, $"tmp.xml"); // Backup de l'EBGame File.Copy(Path.Combine(destPath, "EBGame.xml"), tmpFile, true); // Altération de la copie XDocument xelBack = XDocument.Load(tmpFile); /* * Liste des paths à altérer * GamePath * Addapplication path * manual * music * videopath */ // Effacement de la backup File.Delete(tmpFile); }
private void CreateEdges (DataRep.CADComponent component, CyPhy.ComponentAssembly topassembly, bool size2fit = false) { foreach (KeyValuePair<string, DataRep.StructuralInterfaceConstraint> item in component.StructuralInterfaceNodes) { // [1] find matching structural interface // [2] CreateEdge(a, b) var found = structuralInfProcessed.Find(x => x == item.Key); if (found == null) { CommonTraversal traverser = new CommonTraversal(item.Value.CyPhyImpl, topassembly); if (traverser.FoundConnectedNodes.Count() > 1) { Logger.Instance.AddLogMessage("StructuralInterface connected to >1 StructuralInterface [" + item.Value.CyPhyImpl.Path + "]", Severity.Error); continue; } else if (traverser.FoundConnectedNodes.Count() < 1) { if (traverser.GetVisitedConnectionCount() > 0) Logger.Instance.AddLogMessage("StructuralInterface not connected to another StructuralInterface [" + item.Value.CyPhyImpl.Path + "]", Severity.Warning); continue; } string dstparentid = traverser.FoundConnectedNodes.First().ParentContainer.ID; string dstsiid = traverser.FoundConnectedNodes.First().ID; if (!size2fitComponents.ContainsKey(dstparentid)) { if (regularComponents.ContainsKey(dstparentid)) { if (regularComponents[dstparentid].StructuralInterfaceNodes.ContainsKey(dstsiid)) { // META-3124 if (item.Value.Joint != null && regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid].Joint != null) { if (item.Value.Joint.Name == regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid].Joint.Name) CreateEdge(component, item.Value, regularComponents[dstparentid], regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid]); else { Logger.Instance.AddLogMessage("Mismatched joints in connected Connectors: " + component.CyPhyModelPath + item.Value.CyPhyImpl.Name + "(" + item.Value.Joint + "), " + regularComponents[dstparentid].CyPhyModelPath + regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid].CyPhyImpl.Name + "(" + regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid].Joint + ")", Severity.Error); } } else { CreateEdge(component, item.Value, regularComponents[dstparentid], regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid]); } } } } } } }
private bool CreateEdge(DataRep.CADComponent aparent, DataRep.StructuralInterfaceConstraint a, DataRep.CADComponent bparent, DataRep.StructuralInterfaceConstraint b, bool size2fit = false) { structuralInfProcessed.Add(a.PortID); structuralInfProcessed.Add(b.PortID); // Create Edge DataRep.CADEdge edge = new DataRep.CADEdge(aparent, bparent) { SrcPortID = a.PortID, DstPortID = b.PortID, SrcPortName = a.Name, DstPortName = b.Name, DegreeFreedom = a.DegreeFreedom, SrcIntf = a, DstIntf = b }; List<Tuple<DataRep.Datum, DataRep.Datum>> constraintPairs = new List<Tuple<DataRep.Datum,DataRep.Datum>>(); bool result = DataRep.StructuralInterfaceConstraint.MatchStructuralInterfaceDatums(a, b, constraintPairs); edge.ConstraintPairs.AddRange(constraintPairs); // TODO: Add more checking for this if (a.Joint != null && b.Joint != null) { var aJointType = a.Joint.JointType; var bJointType = b.Joint.JointType; if (aJointType != bJointType) { Logger.Instance.AddLogMessage("Mismatched joint type in connected Connectors.", Severity.Error); } else { edge.KinematicJointPair = new DataRep.KinematicJointPair(a.Joint, b.Joint); GMEIDJointIDMap.Add(a.Joint.CyPhyID, edge.KinematicJointPair.XmlID); GMEIDJointIDMap.Add(b.Joint.CyPhyID, edge.KinematicJointPair.XmlID); } } if (size2fit) size2fitEdges.Add(edge); else regularEdges.Add(edge); // TODO: !!!!!!!!!!!!!! NEED TO IMPLEMENT !!!!!!!!!!!!!! // Check for coordinatesystem datum should be the only 1 return !result; }
public void ToDAG(DataRep.CADAssembly assembly, List<string> RefCoordComponents) { string start_component_id = "-1"; List<string> openComponents = new List<string>(); List<string> closedComponents = new List<string>(); // [1] Create openEdges List<DataRep.CADEdge> openEdges = new List<DataRep.CADEdge>(); openEdges.AddRange(assembly.ChildEdges); // [2] Find starting component and create openComponents set /* // META-2885 start_component_id = FindStartingComponent(assembly.ChildComponents.Keys.ToList(), RefCoordComponents, openEdges, openComponents); */ start_component_id = FindStartingComponent(assembly.ChildComponents.OrderBy(x => x.Value.Name).ToDictionary(x => x.Key, x => x.Value).Keys.ToList(), RefCoordComponents, openEdges, openComponents); assembly.RootComponentID = start_component_id; closedComponents.Add(start_component_id); // cassemblyParent_in->SetRootComponentID(start_component_id); int degree = 6, openSize = openComponents.Count(); while (openComponents.Any()) { ConstrainComponents(closedComponents, openEdges, degree, openComponents); //ConstrainComponents(closedComponents, assembly.ChildEdges, degree, openComponents); int tmp_open_size = openComponents.Count(); if (tmp_open_size == openSize) // was not able to find components with edges of dof 6 degree--; else degree = 6; openSize = tmp_open_size; } if (openEdges.Any()) { debugMessages.Add("+++++ Left Over Edges +++++\n"); foreach (var edge in openEdges) debugMessages.Add(" Source: " + edge.Src.Id + "Dst: " + edge.Dst.Id + "\n"); } }
public static bool MatchStructuralInterfaceDatums(DataRep.StructuralInterfaceConstraint a, DataRep.StructuralInterfaceConstraint b, List<Tuple<DataRep.Datum, DataRep.Datum>> constraintPairs) { string apath = a.CyPhyImpl.Path, bpath = b.CyPhyImpl.Path; // Means no error bool result = false; if (!DataRep.StructuralInterfaceConstraint.MatchSIType(a.InterfaceDefinition, b.InterfaceDefinition)) //if (!MatchSIType(a.InterfaceDefinition, b.InterfaceDefinition)) { Logger.Instance.AddLogMessage("Mismatched Type attribute on connected StructuralInterfaces. Interface 1: [" + a.CyPhyImpl.ToHyperLink() + "] (" + a.InterfaceDefinition + "). Interface 2: [" + b.CyPhyImpl.ToHyperLink() + "] (" + b.InterfaceDefinition + ")", Severity.Error); return true; } List<string> adatumnames = a.DatumList.Keys.ToList(); List<string> bdatumnames = b.DatumList.Keys.ToList(); if (adatumnames.Count() != bdatumnames.Count()) { Logger.Instance.AddLogMessage("Connected StructuralInterfaces have different number of datum ports: [" + a.CyPhyImpl.ToHyperLink() + ", " + b.CyPhyImpl.ToHyperLink() + "]", Severity.Error); return true; } if (adatumnames.Count() > 1 && bdatumnames.Count() > 1) { foreach (KeyValuePair<string, DataRep.Datum> adatum in a.DatumList) { if (b.DatumList.ContainsKey(adatum.Key)) { DataRep.DatumType a_type = adatum.Value.Type; DataRep.DatumType b_type = b.DatumList[adatum.Key].Type; if (a_type != b_type) { Logger.Instance.AddLogMessage("Matching datum ports are different type [" + a.CyPhyImpl.ToHyperLink() + "," + b.CyPhyImpl.ToHyperLink() + "]", Severity.Error); result = true; continue; } else { if (a_type == DataRep.DatumType.Surface) { if (adatum.Value.Alignment != b.DatumList[adatum.Key].Alignment) { Logger.Instance.AddLogMessage("Matching Surface datum ports have different Alignment attributes [" + a.CyPhyImpl.ToHyperLink() + "," + b.CyPhyImpl.ToHyperLink() + "]", Severity.Error); result = true; continue; } } var atumple = new Tuple<DataRep.Datum, DataRep.Datum>(adatum.Value, b.DatumList[adatum.Key]); constraintPairs.Add(atumple); } adatumnames.Remove(adatum.Key); bdatumnames.Remove(adatum.Key); } } if (adatumnames.Any() || bdatumnames.Any()) { Logger.Instance.AddLogMessage(String.Format("Connected connectors contain unmatched named feature ports. Port names must match inside connectors. Connectors are: {0} ({1}) and {2} ({3}).", a.CyPhyImpl.ToHyperLink(), String.Join(",", adatumnames.ToArray()), b.CyPhyImpl.ToHyperLink(), String.Join(",", bdatumnames)), Severity.Error); return true; } } else { var atuple = new Tuple<DataRep.Datum, DataRep.Datum>(a.DatumList.Values.First(), b.DatumList.Values.First()); constraintPairs.Add(atuple); } return result; }
public virtual void Remove_Game(DataRep game) { Games.Remove(game); Signal?.Invoke(this); }
public void SetDefault(string propertyName, DataRep value) { this.GetType().GetProperty(propertyName).SetValue(this, value); }
public string GetRepresentation(DataRep.CADComponent component) { string mbp = component.MakeOrBuyParam; if (mbp=="Buy" && !String.IsNullOrEmpty(BuyRep)) { return BuyRep; } else if (mbp == "Make" && !String.IsNullOrEmpty(MakeRep)) { return MakeRep; } else if (!String.IsNullOrEmpty(DefaultRep)) { return DefaultRep; } else { return ""; } }
public virtual void Add_Game(DataRep game) { Games.Add(game); Signal?.Invoke(this); }
private bool Copy2(string srcFolder, string subFolder, string message, Collection <DataRep> collec) { srcFolder = Path.GetFullPath(srcFolder, Config.HLaunchBoxPath); DataRep dr = null; TreeChoose tc = new TreeChoose() { Model = new M_ChooseRaw() { Info = message, Mode = ChooseMode.File, ShowFiles = true, StartingFolder = srcFolder } }; if (tc.ShowDialog() == true) { string folderDest = Path.Combine(_Root, subFolder); dr = DataTrans.MakeSrcnDest <DataRep>(tc.LinkResult, subFolder); dr.Name = dr.DestPath.Replace(subFolder, "."); DateTime oldLW = new DateTime(); DataRep oldDr = collec.FirstOrDefault(x => x.DestPath.Equals(dr.DestPath)); if (oldDr != null) { oldLW = File.GetLastWriteTimeUtc(oldDr.DestPath); } // EphemProgress ephem = new EphemProgress(); HashCopy copyZat = new HashCopy(); copyZat.AskToUser += PackMe_IHM.Ask4_FileConflict2; bool copyres = false; TaskLauncher launcher = new TaskLauncher() { AutoCloseWindow = true, ProgressIHM = new DxProgressB1(ephem), MethodToRun = () => copyres = copyZat.CopyOneNVerif(dr), }; launcher.Launch(copyZat); // if (!copyres) { return(false); } DateTime newLW = File.GetLastWriteTimeUtc(dr.DestPath); if (oldLW == newLW) { return(false); } if (oldDr != null) { collec.Remove(oldDr); } collec.Add(dr); return(true); //return Copy(tc.LinkResult, Path.Combine(Root, subFolder)); } return(false); }