public static string CombinePaths(string rootPath, string filePath, PathTypes type = PathTypes.WebPath) { string fullPath = rootPath ?? string.Empty; char find = '\\', replaceWith = '/'; if (type == PathTypes.DiskPath) { find = '/'; replaceWith = '\\'; } fullPath = fullPath.Replace(find, replaceWith); if (!string.IsNullOrEmpty(fullPath) && !fullPath.EndsWith(replaceWith.ToString())) { fullPath += replaceWith; } if (!string.IsNullOrWhiteSpace(filePath)) { filePath = filePath.Replace(find, replaceWith); if (filePath.StartsWith(replaceWith.ToString())) { filePath = filePath.Substring(1, filePath.Length - 1); } fullPath += filePath; } return(fullPath); }
internal IPath Create(string path, PlatformPathTypes platformPathType, PathTypes pathType, string[] components) { switch (platformPathType) { case PlatformPathTypes.Infer: return Create(path, InferPlatformPathType(path), pathType, components); case PlatformPathTypes.Windows: switch (pathType) { case PathTypes.Root: return new WinRootPath(this, platformPathType, pathType, path, components); case PathTypes.Directory: return new WinDirectoryPath(this, platformPathType, pathType, path, components); case PathTypes.File: return new WinFilePath(this, platformPathType, pathType, path, components); default: throw new ArgumentOutOfRangeException("pathType", pathType, null); } case PlatformPathTypes.Unix: switch (pathType) { case PathTypes.Root: return new UnixRootPath(this, platformPathType, pathType, path, components); case PathTypes.Directory: return new UnixDirectoryPath(this, platformPathType, pathType, path, components); case PathTypes.File: return new UnixFilePath(this, platformPathType, pathType, path, components); default: throw new ArgumentOutOfRangeException("pathType", pathType, null); } ; default: throw new ArgumentOutOfRangeException("platformPathType", platformPathType, null); } }
private Color GetPathColor(PathTypes p) { if (p == PathTypes.BICYCLE) { return(Color.magenta); } if (p == PathTypes.BOAT) { return(Color.green); } if (p == PathTypes.CAR) { return(Color.blue); } if (p == PathTypes.FEET) { return(Color.red); } if (p == PathTypes.TRAIN) { return(Color.yellow); } return(Color.black); }
/// <summary> /// Returns the location where Templates are stored for the current app /// </summary> public string AppPathRoot(bool useSharedFileSystem, PathTypes pathType) { var wrapLog = Log.Call <string>($"{useSharedFileSystem}, {pathType}"); string basePath; //var useSharedFileSystem = locationId == Settings.TemplateLocations.HostFileSystem; switch (pathType) { case PathTypes.Link: basePath = useSharedFileSystem ? _linkPaths.ToAbsolute(Settings.PortalHostDirectory, Settings.AppsRootFolder) : App.Site.AppsRootLink; break; case PathTypes.PhysRelative: basePath = useSharedFileSystem ? _linkPaths.ToAbsolute(Settings.PortalHostDirectory, Settings.AppsRootFolder) : App.Site.AppsRootPhysical; break; case PathTypes.PhysFull: basePath = useSharedFileSystem ? ServerPaths.FullAppPath(Path.Combine(Settings.PortalHostDirectory, Settings.AppsRootFolder)) : App.Site.AppsRootPhysicalFull; break; default: throw new ArgumentOutOfRangeException(nameof(pathType), pathType, null); } var finalPath = Path.Combine(basePath, App.Folder); return(wrapLog(finalPath, finalPath)); }
public Connection(Connectable starrRect, Connectable endRect, PathTypes connectType, Action <Connection> OnClickRemoveConnection) { inPoint = starrRect; outPoint = endRect; connectionType = connectType; this.OnClickRemoveConnection = OnClickRemoveConnection; }
public string ReadPath(PathTypes pathType) { switch (pathType) { case PathTypes.Source: Console.WriteLine("Bitte geben Sie den Pfad des Ordners an, in dem die .tiff-Dateien liegen"); break; case PathTypes.Destination: Console.WriteLine("Bitte geben Sie den Pfad des Ordners an, in dem die bearbeiteten Dateien erzeugt weren sollen"); break; default: throw new NotImplementedException("Der benutzete PathType ist nicht definiert"); } string path = Console.ReadLine(); if (!CheckPath(path)) { ReadPath(pathType); } return(path); }
private void ClearConnectionSelection() { selectedInPoint = null; selectedOutPoint = null; selectedType = PathTypes.NONE; connecting = false; }
protected BasePath(PathFactory factory, PlatformPathTypes platformPathType, PathTypes pathType, string path, string[] components) { Factory = factory; PlatformPathType = platformPathType; PathType = pathType; Components = components; Path = path; }
public string IconPathOrNull(IView view, PathTypes type) { // 1. Check if the file actually exists //var iconFile = ViewPath(view); var iconFile = IconPath(view, PathTypes.PhysFull); var exists = File.Exists(iconFile); // 2. Return as needed return(exists ? IconPath(view, type) : null); }
public static string MapPath(long?pathRootId, string filePath, PathTypes type = PathTypes.WebPath) { string rootPath = string.Empty; if (pathRootId.HasValue && pathRootId.Value != 0) { rootPath = GetPathRoot(pathRootId.Value); } return(CombinePaths(rootPath, filePath, type)); }
public IDirectory Directory(string path, PathTypes pathType = PathTypes.Relative) { if (pathType == PathTypes.Absolute) { return(new Directory(path, this)); } else { return(new Directory(this.path + Path.AltDirectorySeparatorChar + path.Trim(Path.AltDirectorySeparatorChar), this)); } }
/// <summary> /// ValidatePath file or diretory path /// </summary> /// <param name = "path"></param> /// <param name = "type">path type</param> /// <returns></returns> public static bool ValidatePath(string path, PathTypes type) { bool _result = false; if ((type & PathTypes.Absolute) == PathTypes.Absolute) { _result |= ms_checkValidAbsolutePathRegEx.IsMatch(path); } if ((type & PathTypes.Relative) == PathTypes.Relative) { _result |= ms_checkValidRelativePathRegEx.IsMatch(path); } return(_result); }
private static string GetPath(this XElement element, PathTypes pathType = PathTypes.FullPath) { if (element == null) { return(string.Empty); } var ancestors = element.Ancestors().ToList(); if (!ancestors.Any()) { return(element.Name.ToString()); } var p = ancestors.Select(x => x.Name.LocalName).Aggregate((path, next) => next + "\\" + path); p += "\\" + element.Name.LocalName; if (pathType == PathTypes.ShortPath) { return(p); } if (element.NodeType == XmlNodeType.Element) { var index = element.Parent.Elements().ToList().IndexOf(element); p = p + '[' + index + ']'; // Add name attribute (if any) if (element.Attribute("Name") != null) { p = string.Format("{0}[Name=='{1}']", p, element.Attribute("Name").Value); } else if (element.Attribute("ID") != null) { p = string.Format("{0}[ID=='{1}']", p, element.Attribute("ID").Value); } if (element.HasElements) { return(p); } var textValue = element.DescendantNodes().OfType <XText>().Select(x => x.Value).FirstOrDefault(); if (!string.IsNullOrEmpty(textValue)) { p = String.Format("{0}\\{{\"{1}\"}}", p, textValue); } } return(p); }
public static void MoveFile(PathTypes oldType, PathTypes newType, string filePath, ILogger logger = null) { var newPath = ChangePathType( oldType, newType, filePath); logger.LogDebug($"{filePath} -> {newPath}"); // ensure newPath exists Directory.CreateDirectory(Path.GetDirectoryName(newPath)); File.Move(filePath, newPath); if (logger != null) { logger.LogInformation($"moved to: {newPath}"); } }
public void SaveTriggerData(Rect _rect, int _ID, string _desc, List <bool> _showOptions, List <AudioClip> _audio, List <int> _delays, List <Vector2> _cons, PathTypes _type, Vector2 _svVec, Vector3 _worldPos) { rect = _rect; ID = _ID; stepDescription = _desc; showAudio = _showOptions; playedAudioClips = _audio; delays = _delays; nodeConnections = _cons; pathType = _type; scrollViewVector = _svVec; if (_worldPos != transform.position) { worldPosition = _worldPos; transform.position = _worldPos; } }
public void OnClickInPoint(Connectable inPoint, PathTypes type) { connecting = true; selectedInPoint = inPoint; selectedType = type; if (selectedOutPoint != null) { if (selectedOutPoint.ID != selectedInPoint.ID) { CreateConnection(); ClearConnectionSelection(); } else { ClearConnectionSelection(); } } }
public static string GetPath(this XObject node, PathTypes pathType = PathTypes.FullPath) { if (node == null) { return(string.Empty); } if (node.NodeType == XmlNodeType.Attribute) { var attribute = (XAttribute)node; var attrName = attribute.Name.ToString(); return(string.Format("{0}[{1}]", GetPath(attribute.Parent), attrName)); } if (node.NodeType == XmlNodeType.Element) { return(GetPath((XElement)node, pathType)); } return(string.Empty); }
private void StartConnection(object obj) { switch (obj.ToString()) { case "GOOD": editorInstance.OnClickInPoint(this, PathTypes.GOOD); pathType = PathTypes.GOOD; break; case "BAD": editorInstance.OnClickInPoint(this, PathTypes.BAD); pathType = PathTypes.BAD; break; default: editorInstance.OnClickInPoint(this, PathTypes.NONE); pathType = PathTypes.NONE; break; } }
protected WinPath(PathFactory factory, PlatformPathTypes platformPathType, PathTypes pathType, string path, string[] components) : base(factory, platformPathType, pathType, path, components) { var firstComponent = components.FirstOrDefault(); Drive = PathUtility.GetDrive(firstComponent); }
public ConnectionInfo(int _inPoint, int _outPoint, PathTypes _connectionType) { inPointID = _inPoint; outPointID = _outPoint; connectionType = _connectionType; }
public UnixRootPath(PathFactory factory, PlatformPathTypes platformPathType, PathTypes pathType, string path, string[] components) { throw new NotImplementedException(); }
public static string ChangePathType(PathTypes oldType, PathTypes newType, string path) => ChangePathType(oldType.ToString(), newType.ToString(), path);
public string ViewPath(IView view, PathTypes type) => AppPathRoot(view.IsShared, type) + "/" + view.Path;
public WinFilePath(PathFactory factory, PlatformPathTypes platformPathType, PathTypes pathType, string path, string[] components) : base(factory, platformPathType, pathType, path, components) { }
/// <summary> /// ValidatePath file or diretory path /// </summary> /// <param name = "path"></param> /// <param name = "type">path type</param> /// <returns></returns> public static bool ValidatePath(string path, PathTypes type) { bool _result = false; if ((type & PathTypes.Absolute) == PathTypes.Absolute) { _result |= ms_checkValidAbsolutePathRegEx.IsMatch(path); } if ((type & PathTypes.Relative) == PathTypes.Relative) { _result |= ms_checkValidRelativePathRegEx.IsMatch(path); } return _result; }
private string IconPath(IView view, PathTypes type) { var viewPath1 = ViewPath(view, type); return(viewPath1.Substring(0, viewPath1.LastIndexOf(".", StringComparison.Ordinal)) + ".png"); }
public UnixDirectoryPath(PathFactory factory, PlatformPathTypes platformPathType, PathTypes pathType, string path, string[] components) { }
public PathTypes GetPathTypeOnSection(Vector2Int one, Vector2Int two, bool end, Vector2Int dir) { PathTypes ret = PathTypes.UpLeft; if (end) { if (one.x != two.x) { if (one.x > two.x) { ret = PathTypes.ArrowHorizontalLeft; } if (one.x < two.x) { ret = PathTypes.ArrowHorizontalRight; //ret = PathTypes.ArrowVerticalDown; } } else { if (one.y > two.y) { ret = PathTypes.ArrowVerticalDown; //ret = PathTypes.ArrowHorizontalRight; } if (one.y < two.y) { ret = PathTypes.ArrowVerticaUp; } } } else { if (dir != Vector2Int.zero && dir != two - one) { dir = two - one; Debug.Log(dir); if (dir.x == 1) { ret = PathTypes.UpLeft; } else if (dir.x == -1) { ret = PathTypes.UpRight; //ret = PathTypes.DownRight; } if (two.x < Path[0].x) { if (dir.y == -1) { ret = PathTypes.UpRight; //ret = PathTypes.UpRight; } else { ret = PathTypes.DownRight; } } else { if (dir.y == -1) { ret = PathTypes.UpLeft; //ret = PathTypes.UpRight; } else { ret = PathTypes.DownLeft; } } } else { if (one.x == two.x) { ret = PathTypes.Vertical; } else if (one.y == two.y) { ret = PathTypes.Horrizontal; } } } return(ret); }
private void DisplayColumnFromList() { GameObject prefabToPlace = prefabOpenPath[0]; for (int index = 0; index < path.Count; index++) { PathTypes p = path[index]; // we want a background tile every time. prefabToPlace = prefabOpenPath[Random.Range(0, prefabOpenPath.Length)]; Vector3 blankTilePos = transform.position + Vector3.up * index; Instantiate(prefabToPlace, blankTilePos, Quaternion.identity, transform); // we want to add random tiles when/where needed if (p == PathTypes.Open) { if (openColumn) { continue; } if (Random.Range(0, 101) < 2) { prefabToPlace = prefabStore; } if (Random.Range(0, 201) < 5) { prefabToPlace = prefabCoin; } if (Random.Range(0, 201) < 2) { prefabToPlace = prefabHealing; } } if (p == PathTypes.Blocker) { prefabToPlace = prefabBlockedPath[Random.Range(1, prefabBlockedPath.Length)]; if (Random.Range(0, 101) < 40) { prefabToPlace = prefabBlockedPath[0]; } } if (p == PathTypes.Enemy) { prefabToPlace = prefabEnemy; } if (p == PathTypes.Barrier) { prefabToPlace = prefabBarrierPath[Random.Range(0, prefabBarrierPath.Length)]; } Vector3 pos = transform.position + Vector3.up * index; Instantiate(prefabToPlace, pos, Quaternion.identity, transform); } }
public static string BuildPath(PathTypes type = PathTypes.Base) => BuildPath(type.ToString());
public PathAttribute(PathTypes pathType, string[] extensions) { PathType = pathType; Extensions = extensions; }