public void RightSideUrl() { XmlSerializer serializer = new XmlSerializer(typeof(PathMap)); PathMap mapping = (PathMap)serializer.Deserialize( new System.IO.StreamReader( @"MappingTest\Mapping.xml")); Directory dir1 = mapping.GetDirectory("/zmrsoap"); Assert.IsNotNull(dir1, "dir1 not found."); Assert.AreEqual("zmrsoap", dir1.Name); Assert.AreEqual( "https://portals-test.bmi.gv.at/bmi.gv.at/soapv2/soaphttpengine/soapv2%23pvp1?dest=ZMR&opzone=test", dir1.GetFullTargetPath("/zmrsoap/")); ApplicationDirectory appStatistik = mapping.GetApplication("/statistik.at/vis.test.extern/"); Assert.IsNotNull(appStatistik, "appStatistik not found."); Assert.AreEqual("vis.test.extern", appStatistik.Name); Assert.AreEqual("https://awp.statistik.at/statistik.at/vis.test.extern/", appStatistik.RootUrl); Assert.AreEqual("https://awp.statistik.at/statistik.at/vis.test.extern/einFile.txt", appStatistik.GetFullTargetPath("/statistik.at/vis.test.extern/einFile.txt")); ApplicationDirectory withPort = mapping.GetApplication("/withport/"); Assert.IsNotNull(withPort, "withport not found."); Assert.AreEqual("https://egora:8443/test", withPort.FullTargetPath); Assert.AreEqual("https://egora:8443/test/hello.htm", withPort.GetFullTargetPath("/withport/hello.htm")); ApplicationDirectory defaultApp = mapping.GetApplication("/someunknownurl/"); Assert.IsNotNull(defaultApp, "defaultApp not found."); Assert.AreEqual(string.Empty, defaultApp.Name); }
public void PDFAssistent_ausführen() { Eplan.EplApi.Base.Settings oSettings = new Eplan.EplApi.Base.Settings(); if (oSettings.ExistSetting("USER.SCRIPTS.PDF_Assistent.OhneNachfrage")) { bool bChecked = oSettings.GetBoolSetting("USER.SCRIPTS.PDF_Assistent.OhneNachfrage", 1); if (bChecked) { string scriptName = @"$(MD_SCRIPTS)\Ausgabe\PDF\PDF Assistent.cs"; scriptName = PathMap.SubstitutePath(scriptName); ExcecuteScripts(scriptName, "0"); // cboAusgabeNach.SelectedIndex = 0; // ReadSettings(); // PDFexport(txtSpeicherort.Text + txtDateiname.Text + @".pdf"); // Close(); } else { //PDFAssistent_Start(); string scriptName = @"$(MD_SCRIPTS)\Ausgabe\PDF\PDF Assistent.cs"; scriptName = PathMap.SubstitutePath(scriptName); ExcecuteScripts(scriptName, "1"); } } }
public void ExcecutePDF_Assistent() { string scriptName = @"$(MD_SCRIPTS)\Ausgabe\PDF\PDF Assistent.cs"; scriptName = PathMap.SubstitutePath(scriptName); ExcecuteScripts(scriptName, "1"); }
public void ExcecuteMacroNavigator() { string scriptName = @"$(MD_SCRIPTS)\MakroNavigator\MacroNaviForm.cs"; scriptName = PathMap.SubstitutePath(scriptName); ExcecuteScripts(scriptName); }
public void Function() { string projectsPath = PathMap.SubstitutePath("$(MD_PROJECTS)"); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "ProjectInfo.xml|ProjectInfo.xml"; ofd.InitialDirectory = projectsPath; ofd.Title = "Projekteigenschaften auswählen:"; ofd.ValidateNames = false; if (ofd.ShowDialog() == DialogResult.OK) { Progress progress = new Progress("SimpleProgress"); progress.SetAllowCancel(false); progress.BeginPart(100, ""); progress.SetTitle("Projekteigenschaften importieren"); progress.ShowImmediately(); CommandLineInterpreter cli = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); acc.AddParameter("TYPE", "READPROJECTINFO"); acc.AddParameter("FILENAME", ofd.FileName); cli.Execute("projectmanagement", acc); progress.EndPart(true); cli.Execute("XPrjActionPropertiesEdit"); } return; }
public void RemoteApplication_PostRequest() { PathMap map = PathMap.CreateFromFile( @"MappingTest\Mapping.xml"); RemoteApplication.Initialize(map); HttpContext context = HttpContextHelper.CreateHttpContext("POST", "/localtest1/", null); HttpRequest leftSideRequest = context.Request; RemoteApplication remoteApplication = RemoteApplication.GetRemoteApplication(context.Request); TrafficLogger logger = new TrafficLogger(remoteApplication.RemoteApplicationProxyPath, "UnitTest", new TraceScope(null), context.Request.Url); string rightSideUrl = remoteApplication.GetRightSideUrl(context.Request); Assert.AreEqual("http://egoratest/PvpTestApplication/1/", rightSideUrl, "RightSideUrl"); using (Stream inputBuffer = CopyFilter.GetInputStream(context.Request)) { HttpWebRequest rightSideRequest = remoteApplication.CreateRightSideRequest(context.Request, inputBuffer, logger); Assert.IsNotNull(rightSideRequest, "Request is null."); Assert.AreEqual("POST", rightSideRequest.Method); // currently empty collection foreach (HttpHeader header in leftSideRequest.Headers) { Assert.IsNotNull(rightSideRequest.Headers[header.Name], "header"); Assert.AreEqual(header.Value, rightSideRequest.Headers[header.Name]); } } }
public void Function() { string strProjectpath = PathMap.SubstitutePath("$(PROJECTPATH)") + @"\"; string strFilename = "Testdatei"; OpenFileDialog ofd = new OpenFileDialog(); ofd.DefaultExt = "txt"; ofd.FileName = strFilename; ofd.Filter = "Testdatei (*Testdatei*.txt)" + "|*Testdatei*.txt|Alle Dateien (*.*)|*.*"; ofd.InitialDirectory = strProjectpath; ofd.Title = "Testdatei auswählen:"; ofd.ValidateNames = true; if (ofd.ShowDialog() == DialogResult.OK) { strFilename = ofd.FileName; MessageBox.Show( "Der Speicherort wurde erfolgreich übergeben:\n" + strFilename, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information ); } return; }
public void Action(string id, string index, out string value) { string pathTemplate = Path.Combine(PathMap.SubstitutePath("$(MD_SCRIPTS)"), "ScriptSettings", "Library", "GetProjectProperty", "GetProjectProperty_Template.xml"); string pathScheme = Path.Combine(PathMap.SubstitutePath("$(MD_SCRIPTS)"), "ScriptSettings", "Library", "GetProjectProperty", "GetProjectProperty_Scheme.xml"); string pathOutput = Path.Combine(PathMap.SubstitutePath("$(MD_SCRIPTS)"), "ScriptSettings", "Library", "GetProjectProperty", "GetProjectProperty_Output.txt"); try { // Set scheme string content = File.ReadAllText(pathTemplate); content = content.Replace("GetProjectProperty_ID", id); content = content.Replace("GetProjectProperty_INDEX", index); File.WriteAllText(pathScheme, content); new Settings().ReadSettings(pathScheme); // Export ActionCallingContext actionCallingContext = new ActionCallingContext(); actionCallingContext.AddParameter("configscheme", "GetProjectProperty"); actionCallingContext.AddParameter("destinationfile", pathOutput); actionCallingContext.AddParameter("language", "de_DE"); new CommandLineInterpreter().Execute("label", actionCallingContext); // Read value = File.ReadAllLines(pathOutput)[0]; } catch (Exception exception) { MessageBox.Show(exception.Message, "GetProjectProperty", MessageBoxButtons.OK, MessageBoxIcon.Error); value = "[Error]"; } }
private void panel_Symbol_Paint(object sender, PaintEventArgs e) { if (this.MvProject.Project == null) { return; } if (dataGridView2.CurrentRow == null || dataGridView2.CurrentRow.Cells["PartNr"].Value == null) { return; } string partNr = dataGridView2.CurrentRow.Cells["PartNr"].Value.ToString(); MDPartsDatabase mdb = Util.eplan.GetPartMaster(); MDPart part = mdb.GetPart(partNr); if (part == null) { return; } string filePath = PathMap.SubstitutePath(part.Properties.ARTICLE_GROUPSYMBOLMACRO.ToString()); if (!File.Exists(filePath)) { return; } int variant = 0; if (panel_Symbol.Tag != null) { variant = (int)panel_Symbol.Tag; } try { WindowMacro wm = new WindowMacro(); wm.Open(filePath, this.MvProject.Project); wm.RepresentationType = WindowMacro.Enums.RepresentationType.SingleLine; if (wm.ExistVariant(WindowMacro.Enums.RepresentationType.SingleLine, variant)) { wm.Variant = variant; } else { panel_Symbol.Tag = wm.Variant = 0; } DrawingService ds = new DrawingService(); ds.MacroPreview = false; ds.CenterView = true; ds.CreateDisplayList(wm); ds.DrawDisplayList(e); } catch { //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
protected virtual void ApplyPathMapOverrides(PathMap pathMap) { foreach (var kvp in this.PathMapOverrides) { pathMap.Set(kvp.Key, kvp.Value); } }
//Prüfen ob Assistent gestartet werden soll public void PDFAssistent_SollStarten() { Eplan.EplApi.Base.Settings oSettings = new Eplan.EplApi.Base.Settings(); //Ist Project in Project-Folder //Wenn angekreuzt dann muß Project im Folder sein für Assistent, sonst kein Assistent //Wenn nicht angekreuzt dann Assistent if (oSettings.ExistSetting("USER.SCRIPTS.PDF_Assistant.OhneNachfrage")) { bool bChecked = oSettings.GetBoolSetting("USER.SCRIPTS.PDF_Assistant.ProjectInFolder", 1); string sProjectInFolder = oSettings.GetStringSetting("USER.SCRIPTS.PDF_Assistant.ProjectInFolderName", 0); if (bChecked) { string sProjectFolder = PathMap.SubstitutePath("$(PROJECTPATH)"); sProjectFolder = sProjectFolder.Substring(0, sProjectFolder.LastIndexOf(@"\")); if (!sProjectFolder.EndsWith(@"\")) { sProjectFolder += @"\"; } if (sProjectInFolder == sProjectFolder) //hier vielleicht noch erweitern auf alle UnterFolder (InString?) { PDFAssistent_To Run(); } else { Close(); } } else { PDFAssistent_To Run(); } } }
public void Function() { string filename = PathMap.SubstitutePath(@"$(PROJECTPATH)\Test_dates.txt"); string strContent = "Example text\n"; StreamWriter swTextfile = new StreamWriter( filename, true, Encoding.Unicode ); swTextfile.Write(strContent); swTextfile.Close(); MessageBox.Show( "Text file successfully exported.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information ); Process.Start(filename); return; }
//Check if Assistant should be started public void PDFAssistant_SollStarten() { Eplan.EplApi.Base.Settings oSettings = new Eplan.EplApi.Base.Settings(); // is project in project folder // If ticked then Project has to be in Folder for Assistant, otherwise no Assistant // If not ticked then Assistant if (oSettings.ExistSetting("USER.SCRIPTS.PDF_Assistant.WithoutDemand")) { bool bChecked = oSettings.GetBoolSetting("USER.SCRIPTS.PDF_Assistant.ProjectInFolder", 1); string sProjectInFolder = oSettings.GetStringSetting("USER.SCRIPTS.PDF_Assistant.ProjectInFolderName", 0); if (bChecked) { string sProjectFolder = PathMap.SubstitutePath("$(PROJECTPATH)"); sProjectFolder = sProjectFolder.Substring(0, sProjectFolder.LastIndexOf(@"\")); if (!sProjectFolder.EndsWith(@"\")) { sProjectFolder += @"\"; } if (sProjectInFolder == sProjectFolder) //here maybe even expand on all subfolders(InString ?) { PDFAssistant_ausführen(); } else { Close(); } } else { PDFAssistant_ausführen(); } } }
public void RemoteApplication_ByPass() { PathMap map = PathMap.CreateFromFile( @"MappingTest\Mapping.xml"); RemoteApplication.Initialize(map); HttpContext context = HttpContextHelper.CreateHttpContext("GET", "/zmrres/images/somepicture.png", "name1=value1"); RemoteApplication remoteApplication = RemoteApplication.GetRemoteApplication(context.Request); TrafficLogger logger = new TrafficLogger(remoteApplication.RemoteApplicationProxyPath, "UnitTest", new TraceScope(null), context.Request.Url); string rightSideUrl = remoteApplication.GetRightSideUrl(context.Request); Assert.AreEqual("https://portal.bmi.gv.at/images/somepicture.png?name1=value1", rightSideUrl, "RightSideUrl"); Assert.IsTrue(remoteApplication.ByPass(context.Request.Url.AbsolutePath)); using (Stream inputBuffer = CopyFilter.GetInputStream(context.Request)) { HttpWebRequest request = remoteApplication.CreateRightSideRequest(context.Request, inputBuffer, logger); Assert.IsNotNull(request, "Request is null."); Assert.AreEqual("GET", request.Method); } }
public void Function() { string strProjectName = GetProject(); string strLabelName = PathMap.SubstitutePath("$(PROJECTNAME)"); string myDate = System.DateTime.Now.ToString("yyyyMMdd"); string myTime = System.DateTime.Now.ToString("HHmm"); // Dokumentenordner auswählen string sProjectDocPath = PathMap.SubstitutePath("$(DOC)"); string sfilenameEinbauort = sProjectDocPath + @"\Einbauorte_" + myDate + "_" + myTime + ".txt"; // Ausgabe der TXT mit Einbauorten LabellingEinbauort(sfilenameEinbauort, strProjectName); // Textdatei lesen List <string> sEinbauort = ReadFile(sfilenameEinbauort); // Zeilenweise zerlegen foreach (var item in sEinbauort) { // MessageBox.Show(item); ExportPartlist(sProjectDocPath, strLabelName, strProjectName, item, myDate, myTime); } string sExportierteOrte = string.Join(",\r\n+", sEinbauort.ToArray()); MessageBox.Show("Artikeldaten exportiert für:\r\n" + sExportierteOrte); }
public void RemoteApplication_GetRequest() { PathMap map = PathMap.CreateFromFile( @"MappingTest\Mapping.xml"); RemoteApplication.Initialize(map); HttpContext context = HttpContextHelper.CreateHttpContext("GET", "/localtest1/TestPage.aspx/someinfo", "name1=value1"); using (new TraceScope(context)) { RemoteApplication remoteApplication = RemoteApplication.GetRemoteApplication(context.Request); TrafficLogger logger = new TrafficLogger(remoteApplication.RemoteApplicationProxyPath, "UnitTest", new TraceScope(null), context.Request.Url); string rightSideUrl = remoteApplication.GetRightSideUrl(context.Request); Assert.AreEqual("http://egoratest/PvpTestApplication/1/TestPage.aspx/someinfo?name1=value1", rightSideUrl, "RightSideUrl"); using (Stream inputBuffer = CopyFilter.GetInputStream(context.Request)) { HttpWebRequest request = remoteApplication.CreateRightSideRequest(context.Request, inputBuffer, logger); Assert.IsNotNull(request, "Request is null."); Assert.AreEqual("GET", request.Method); } } }
public void ExcecuteSummaryPartList() { string scriptName = @"$(MD_SCRIPTS)\Ausgabe\AusgabeListen.cs"; scriptName = PathMap.SubstitutePath(scriptName); ExcecuteScripts(scriptName); }
public static string GetPathFile(string name, string parameter) { string value = GetText(name, parameter); try { if (value.Contains("$(PROJECTPATH_SUB)")) { string directory = Path.GetDirectoryName(PathMap.SubstitutePath("$(PROJECTPATH)")); var path2 = value.Substring(value.IndexOf("$(PROJECTPATH_SUB)") + 18, value.Length - 18); if (directory != null) { return(directory + path2); } } else { value = PathMap.SubstitutePath(value); return(value); } } catch { return(null); } return(null); }
//Kontextmenü 'Komplette Projekt-Verzeichnisstruktur hinzufügen' private void toolStripMenuItemProjektVerzeichnisstruktur_Click(object sender, EventArgs e) { string sSelectedProjectPath = string.Empty; #if DEBUG sSelectedProjectPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\Test\Test.edb"; #else sSelectedProjectPath = PathMap.SubstitutePath(@"$(P)"); #endif if (sSelectedProjectPath != string.Empty) { string sTemp = string.Empty; string sRootPath = Path.GetPathRoot(sSelectedProjectPath); //Root-Verzeichnis ermitteln sTemp = sSelectedProjectPath.Replace(sRootPath, string.Empty); //Root-Verzeichnis aus Projekt-Verzeichnis entfernen sTemp = Path.ChangeExtension(sTemp, null); //Erweiterung entfernen //Überprüfen ob mit "\" beginnt, dann entfernen if (Path.IsPathRooted(sTemp)) { sTemp = sTemp.TrimStart(Path.DirectorySeparatorChar); sTemp = sTemp.TrimStart(Path.AltDirectorySeparatorChar); } if (!txtZielverzeichnis.Text.EndsWith(@"\")) { txtZielverzeichnis.Text += @"\"; } //neues Zielverzeichnis eintragen txtZielverzeichnis.Text = Path.Combine(txtZielverzeichnis.Text, sTemp); txtZielverzeichnis.Select(); // to Set Focus txtZielverzeichnis.Select(txtZielverzeichnis.Text.Length, 0); //to set cursor at the end of textbox } }
public void Action(string id, string index, out string value) { string pathTemplate = Path.Combine(PathMap.SubstitutePath("$(MD_SCRIPTS)"), "GetProjectProperty", "GetProjectProperty_Template.xml"); string pathScheme = Path.Combine(PathMap.SubstitutePath("$(MD_SCRIPTS)"), "GetProjectProperty", "GetProjectProperty_Scheme.xml"); bool isUserDefinied = string.IsNullOrEmpty(index) || index.ToUpper().Equals("NULL"); try { // Set scheme const string QUOTE = "\""; string content = File.ReadAllText(pathTemplate); if (isUserDefinied) { string isSelectedPropertyUserDef = @"<Setting name=" + QUOTE + "SelectedPropertyIdUserDef" + QUOTE + " type=" + QUOTE + "string" + QUOTE + ">" + "<Val>" + id + "</Val>" + "</Setting>"; content = content.Replace("GetProjectProperty_ID_SelectedPropertyId", "0"); content = content.Replace("IsSelectedPropertyIdUserDef", isSelectedPropertyUserDef); content = content.Replace("GetProjectProperty_INDEX", "0"); content = content.Replace("GetProjectProperty_ID", id); } else { content = content.Replace("GetProjectProperty_ID_SelectedPropertyId", id); content = content.Replace("IsSelectedPropertyIdUserDef", ""); content = content.Replace("GetProjectProperty_INDEX", index); content = content.Replace("GetProjectProperty_ID", id); } File.WriteAllText(pathScheme, content); new Settings().ReadSettings(pathScheme); string pathOutput = Path.Combine( PathMap.SubstitutePath("$(MD_SCRIPTS)"), "GetProjectProperty", "GetProjectProperty_Output.txt"); // Export ActionCallingContext actionCallingContext = new ActionCallingContext(); actionCallingContext.AddParameter("configscheme", "GetProjectProperty"); actionCallingContext.AddParameter("destinationfile", pathOutput); actionCallingContext.AddParameter("language", "de_DE"); new CommandLineInterpreter().Execute("label", actionCallingContext); // Read value = File.ReadAllLines(pathOutput)[0]; } catch (Exception exception) { MessageBox.Show(exception.Message, "GetProjectProperty", MessageBoxButtons.OK, MessageBoxIcon.Error); value = "[Error]"; } }
public void Function() { CommandLineInterpreter oCLI = new CommandLineInterpreter(); ActionCallingContext acc = new ActionCallingContext(); string strPages = string.Empty; acc.AddParameter("TYPE", "PAGES"); oCLI.Execute("selectionset", acc); acc.GetParameter("PAGES", ref strPages); string[] strPagesCount = strPages.Split(';'); int intPagesCount = strPagesCount.Length; string strProjectname = PathMap.SubstitutePath("$(PROJECTNAME)"); MessageBox.Show("Anzahl markierter Seiten:\n" + "►►► " + intPagesCount.ToString() + " ◄◄◄", "Markierte Seiten [" + strProjectname + "]", MessageBoxButtons.OK, MessageBoxIcon.Information); return; }
public void Function() { string strProjectpath = PathMap.SubstitutePath("$(PROJECTPATH)") + @"\"; string strFilename = "Test dates"; OpenFileDialog ofd = new OpenFileDialog(); ofd.DefaultExt = "txt"; ofd.FileName = strFilename; ofd.Filter = "Test dates (*Test dates*.txt)" + "|*Test dates*.txt|All files (*.*)|*.*"; ofd.InitialDirectory = strProjectpath; ofd.Title = "Test dates choose:"; ofd.ValidateNames = true; if (ofd.ShowDialog() == DialogResult.OK) { strFilename = ofd.FileName; MessageBox.Show( "The location was successfully submitted:\n" + strFilename, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information ); } return; }
public NavCache() { PathMap pathMap = PathMap.Instance; PathNode root = new PathNode { Name = "" }; }
public void Function() { string fileName = PathMap.SubstitutePath("$(PROJECTPATH)" + @"\" + "Projectinfo.xml"); int id = 10043; string lastVersion = ReadProjectProperty(fileName, id); if (lastVersion != null) { MessageBox.Show( "Zuletzt verwendete EPLAN-Version:" + Environment.NewLine + lastVersion, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information ); } else { MessageBox.Show( "Eigenschaft " + id + " nicht gefunden.", "Warnung", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } return; }
private void Apply(PathMap pathMap) { foreach (var action in PathMapActions) { action(pathMap); } }
public Entry CreateEntry(string dir, string name) { ExceptionContext.Check(!Disposed); Flush(); string pathEnt; string pathTemp; GetPath(out pathEnt, out pathTemp, dir, name, true); if (!PathMap.TryAdd(pathEnt, pathTemp)) { throw ExceptionContext.ExceptParam(nameof(name), "Duplicate entry: '{0}'", pathEnt); } Stream stream; if (pathTemp != null) { stream = new FileStream(pathTemp, FileMode.CreateNew); } else { stream = new MemoryStream(); } return(AddEntry(pathEnt, stream)); }
private void Projektsuche_Load(object sender, System.EventArgs e) { ProjectPath = PathMap.SubstitutePath("$(MD_PROJECTS)"); TextBoxSearch.Select(); return; }
private static void MapResBundleFiles(DirectoryInfo a_dir, PathMap a_bundlePathMap, PathMap a_globalPathMap, string a_extension) { referenceList.AddLast(a_dir.Name); FileInfo[] info = a_dir.GetFiles("*" + a_extension); LinkedListNode <string> node = null; for (int i = 0; i < info.Length; ++i) { node = referenceList.First; string fullName = info[i].Name; int extensionIndex = fullName.IndexOf(".", System.StringComparison.Ordinal); string name = fullName.Substring(0, extensionIndex); string extension = fullName.Substring(extensionIndex, fullName.Length - extensionIndex); string fullPath = ""; while (node != referenceList.Last) { fullPath += node.Value; fullPath += "/"; node = node.Next; } fullPath += node.Value; fullPath += "/"; fullPath += name; int pathHash = fullPath.GetHashCode(); fullPath += extension; a_bundlePathMap.Add(pathHash, fullPath); a_globalPathMap.Add(pathHash, fullPath); } }
[Ignore] // test no longer works since Framwork 3.0 installed public void RightSideHeader_FromCustomLeftSideHeader() { PathMap map = PathMap.CreateFromFile( @"MappingTest\Mapping.xml"); RemoteApplication.Initialize(map); HttpContext context = HttpContextHelper.CreateHttpContext("GET", "/localtest1/TestPage.aspx/someinfo", "name1=value1"); RemoteApplication remoteApplication = RemoteApplication.GetRemoteApplication(context.Request); Assert.IsNotNull(remoteApplication, "remoteApplication"); TrafficLogger logger = new TrafficLogger(remoteApplication.RemoteApplicationProxyPath, "UnitTest", new TraceScope(null), context.Request.Url); NameValueCollection headers = new NameValueCollection(); headers.Add("X-Custom", "CustomValue"); headers.Add("Range", "messages=1-20,25-30"); HttpRequestHelper.AddHeaders(context.Request, headers); using (Stream inputBuffer = CopyFilter.GetInputStream(context.Request)) { HttpWebRequest webRequest = remoteApplication.CreateRightSideRequest(context.Request, inputBuffer, logger); Assert.IsNotNull(webRequest, "Request is null."); Assert.AreEqual("GET", webRequest.Method); Assert.IsNotNull(webRequest.Headers["X-Custom"], "CustomHeader"); Assert.AreEqual("CustomValue", webRequest.Headers["X-Custom"]); Assert.IsNotNull(webRequest.Headers["Range"], "Range"); Assert.AreEqual("messages=1-20,25-30", webRequest.Headers["Range"]); } }
//"..." Button private void ButtonOpenSaveDialog_Click(object sender, System.EventArgs e) { string projectName = PathMap.SubstitutePath("$(PROJECTNAME)"); string date = DateTime.Now.ToString("yyyy.MM.dd"); string fileName = projectName + "_" + date + ".zw1"; SaveFileDialog sfd = new SaveFileDialog(); sfd.DefaultExt = "zw1"; sfd.FileName = fileName; sfd.Filter = "Datensicherung: Projekt (*.zw1)|*.zw1"; sfd.InitialDirectory = userDefinedDirectory; sfd.Title = "Speicherort für Datensicherung wählen:"; sfd.ValidateNames = true; if (sfd.ShowDialog() == DialogResult.OK) { //FileStream fileStream = File.Create(sfd.FileName); //fileStream.Dispose(); string backupFullFileName = sfd.FileName; this.TextBoxLocationPath.Text = backupFullFileName; } return; }
public void SpawnLevel(string filename) { Filename = filename; Load(); Dimensions = new Vector2(tiles.GetLength(0), tiles.GetLength(1)); Distance = new PathMap(tiles.GetLength(0), tiles.GetLength(1)); InfectedDistance = new PathMap(tiles.GetLength(0), tiles.GetLength(1)); CreatePlanes(); CreatePlaces(); UpdateVisual(); UpdatePaths(Distance); UpdatePaths(InfectedDistance, true); SpawnHumans(); Spawned = true; }
private void UpdatePaths(PathMap distanceMap, bool infected = false) { distanceMap.Init(); for (int y = 0; y < tiles.GetLength(1); ++y) for (int x = 0; x < tiles.GetLength(0); ++x) { Vector2 pos = new Vector2(x, y); switch (tiles[x, y]) { case Tile.Street: distanceMap[pos, new Vector2(pos.x + 1, pos.y)] = 1.0f; distanceMap[pos, new Vector2(pos.x, pos.y - 1)] = 1.0f; distanceMap[pos, new Vector2(pos.x - 1, pos.y)] = 1.0f; distanceMap[pos, new Vector2(pos.x, pos.y + 1)] = 1.0f; break; case Tile.Checkpoint: if (!infected) { distanceMap[pos, new Vector2(pos.x + 1, pos.y)] = 1.0f; distanceMap[pos, new Vector2(pos.x, pos.y - 1)] = 1.0f; distanceMap[pos, new Vector2(pos.x - 1, pos.y)] = 1.0f; distanceMap[pos, new Vector2(pos.x, pos.y + 1)] = 1.0f; } break; case Tile.Hospital: case Tile.Home: case Tile.Office: case Tile.Bar: case Tile.Mall: distanceMap[pos, new Vector2(pos.x, pos.y + 1)] = 1.0f; break; } } // Floyd for (int k = 0; k < distanceMap.DimX * distanceMap.DimY; ++k) for (int i = 0; i < distanceMap.DimX * distanceMap.DimY; ++ i) for (int j = 0; j < distanceMap.DimX * distanceMap.DimY; ++j) { if (distanceMap.Distance[i, k] + distanceMap.Distance[k, j] < distanceMap.Distance[i, j]) { distanceMap.Distance[i, j] = distanceMap.Distance[i, k] + distanceMap.Distance[k, j]; distanceMap.ShortestPath[i, j] = distanceMap.ShortestPath[i, k]; } } }
// Constructor to create the path map public PRMNavigationPlanner(List<PRMAlgorithm> prms, string cf) { allPRMs = new Dictionary<string, PRMAlgorithm>(); currentPath = new List<Vector2>(); pathDictionary = new Dictionary<Vector2,Node>(); currentField = cf; //Add all the fields and their prms. foreach (PRMAlgorithm p in prms) { string name = p.PRMmap.name; allPRMs.Add(name, p); } pathMapNodes = new List<PathMapNode>(); List<string> visitedRooms = new List<string>(); //find connection pair for each room pair. foreach (string f1 in allPRMs.Keys) { PRMAlgorithm prm1 = allPRMs[f1]; foreach (string f2 in allPRMs.Keys) { if (!visitedRooms.Contains(f2) && f1 != f2) { PRMAlgorithm prm2 = allPRMs[f2]; Tuple<Node, Node> connection = PRMAlgorithm.mergePRM(prm1, prm2); if (connection != null) { PathMapNode pmn = new PathMapNode(connection.Item1.coord, connection.Item1.fieldLocation, connection.Item2.coord, connection.Item2.fieldLocation); pathMapNodes.Add(pmn); } } } visitedRooms.Add(f1); } //check list of conenctions foreach (PathMapNode pnode1 in pathMapNodes) { foreach(PathMapNode pnode2 in pathMapNodes) { if (pnode1 != pnode2) { if (pnode1.v1.Item2 == pnode2.v1.Item2) { pnode1.addConnection(pnode2, 1, pnode2.v1.Item1); } else if (pnode1.v2.Item2 == pnode2.v1.Item2) { pnode1.addConnection(pnode2, 2, pnode2.v1.Item1); } else if (pnode1.v1.Item2 == pnode2.v2.Item2) { pnode1.addConnection(pnode2, 1, pnode2.v2.Item1); ; } else if (pnode1.v2.Item2 == pnode2.v2.Item2) { pnode1.addConnection(pnode2, 2, pnode2.v2.Item1); } } } } pathMap = new PathMap(pathMapNodes); }
/// <summary> /// Click to confirm position of the free point. If more fields, call to /// load next field. If no more, render the path map. Then close. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OK_Click(object sender, EventArgs e) { if (complete) { this.Hide(); return; } f.DefineFreePoint(point); PRMs.Add(new PRMAlgorithm(f, 0.35, (int)(f.AreaDifference() / 0.2))); if (++count <= fields.Count) { f = fields[count - 1]; LoadNext(); } else //if all points found render all lines { reset(); Number_Label.Text = "Path Map and PRM"; OK.Text = "Save"; Vector2 center = new Vector2(0, 0); List<Polygon> fieldsComp = new List<Polygon>(); List<Polygon> wallsComp = new List<Polygon>(); List<Polygon> objectsComp = new List<Polygon>(); List<Polygon> regionsComp = new List<Polygon>(); foreach (Field ff in fields) { fieldsComp.Add(ff.shape); TextRenderable name = new TextRenderable(ff.name, new PointF((float)ff.shape.Center.X, (float)ff.shape.Center.Y), Color.Black); rend.AddRenderable(name); center += ff.shape.Center; foreach (List<Polygon> p in ff.walls.Values) { wallsComp.AddRange(p); } foreach (List<Polygon> p in ff.objects.Values) { objectsComp.AddRange(p); } foreach (List<Polygon> p in ff.regions.Values) { regionsComp.AddRange(p); } } fieldsRend.Polygons = fieldsComp; wallsRend.Polygons = wallsComp; objectsRend.Polygons = objectsComp; regionsRend.Polygons = regionsComp; center /= fields.Count; rend.CamOrtho.CameraPosition = new PoseYPR(center.X, center.Y, rend.CamOrtho.CameraPosition.z, rend.CamOrtho.CameraPosition.yaw, rend.CamOrtho.CameraPosition.pitch, rend.CamOrtho.CameraPosition.roll); OK.Enabled = true; complete = true; pm = new PRMNavigationPlanner(PRMs, "").getPathMap(); foreach (PRMAlgorithm prm in PRMs) { foreach (Vector2 v in prm.getNodeVector2()) { PointRenderable pointr = new PointRenderable(v); rend.AddRenderable(pointr); } } foreach (PathMapNode pmn in pm.map) { PathRenderable line = new PathRenderable(new List<Vector2>() { pmn.v1.Item1, pmn.v2.Item1 }); line.DisplayColor = Color.Blue; lines.Add(line); rend.AddRenderable(line); } } }
//Constructor for when path map is already made public PRMNavigationPlanner(List<PRMAlgorithm> prms, PathMap pm, string cf) { allPRMs = new Dictionary<string, PRMAlgorithm>(); pathDictionary = new Dictionary<Vector2, Node>(); pathMap = pm; pathMapNodes = pm.getNodes(); currentField = cf; //Add all the fields and their prms. foreach (PRMAlgorithm p in prms) { string name = p.PRMmap.name; allPRMs.Add(name, p); } }
/// <summary> /// Saves the metric map, pathMap and PRM. If one only wants to save the Metric Map, saveP is false. /// </summary> /// <param name="fields">The list of split fields to save</param> /// <param name="PRMs">The list of PRMs to save</param> /// <param name="PM">The PathMap to save</param> /// <param name="saveP">Whether or not to save the PRM and PathMap</param> private void save(List<Field> fields, List<PRMAlgorithm> PRMs, PathMap PM, bool saveP) { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { System.Xml.Serialization.XmlSerializer writeField = new System.Xml.Serialization.XmlSerializer(typeof(Field)); System.Xml.Serialization.XmlSerializer writePRM = new System.Xml.Serialization.XmlSerializer(typeof(PRMAlgorithm)); System.Xml.Serialization.XmlSerializer writePM = new System.Xml.Serialization.XmlSerializer(typeof(PathMap)); string filePath = this.saveFileDialog1.FileName; System.IO.Directory.CreateDirectory(filePath); if (saveP) { StreamWriter files = new StreamWriter(filePath + "\\" + "PathMap.xml"); writePM.Serialize(files, PM); files.Close(); } for (int i = 0; i < fields.Count; i++) { StreamWriter file = new StreamWriter(filePath + "\\" + fields[i].name + ".xml"); writeField.Serialize(file, fields[i]); if (saveP) { file = new StreamWriter(filePath + "\\" + fields[i].name + "PRM.xml"); writePRM.Serialize(file, PRMs[i]); } file.Close(); } } }
/// <summary> /// This occurs when the renderer's tool is set to clickTool. It gets the /// location of the mouseclick relative to the rederer. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FieldViewClick(object sender, ClickedEventArgs e) { if (!complete) { bool outside = !f.shape.IsInside(e.Location); if (outside) { reset(); Error_OutsideField.Show(); } bool inside = false; foreach (Polygon p in f.blocks()) { if (p.IsInside(e.Location)) { inside = true; break; } } if (!outside && inside) { reset(); Error_InsideItem.Show(); } if (!outside && !inside) { reset(); point = e.Location; pointRend.Coordinates2D = e.Location; pointRend.Show = true; OK.Enabled = true; } } else { bool outside = true; bool inside = false; foreach (Field s in fields) { if (s.shape.IsInside(e.Location)) { outside = false; f = s; } foreach (Polygon p in s.blocks()) { if (p.IsInside(e.Location)) { inside = true; break; } } } if (outside) { reset(); OK.Enabled = true; Error_OutsideField.Show(); } else if (inside) { reset(); OK.Enabled = true; Error_InsideItem.Show(); } else { PRMs[fields.IndexOf(f)].addPoint(e.Location.X, e.Location.Y); PointRenderable p = new PointRenderable(e.Location); rend.AddRenderable(p); pm = new PRMNavigationPlanner(PRMs, "").getPathMap(); foreach (PathRenderable pr in lines) { rend.RemoveRenderable(pr); } foreach (PathMapNode pmn in pm.map) { PathRenderable line = new PathRenderable(new List<Vector2>() { pmn.v1.Item1, pmn.v2.Item1 }); line.DisplayColor = Color.Blue; lines.Add(line); rend.AddRenderable(line); } } } }