public override CriterionResult Validate(string path) { //setup the full path by safely adding the extra path. string fullPath = Path.Combine(path, SubPath?.Trim('\\') ?? ""); //check the base type which sees if the directory in the sub path exists first. CriterionResult baseResult = base.Validate(path); if (!baseResult.IsValid) { return(baseResult); } //grab the directories in the path var directories = Directory.GetDirectories(fullPath); if (directories != null && directories.Length == Count) { return(new CriterionResult() { IsValid = true, Description = Description, Message = $"You have {Count} directories in your {SubPath} folder, good job!" }); } else { return(new CriterionResult() { IsValid = false, Description = Description, Message = $"You have {directories?.Length ?? 0} directories in your {SubPath} folder, but you should have {Count}." }); } }
private void Configure(Route path) { FilePath = path; if (!path.IsValid || path.RouteType == RouteType.FILE) { // initial, make the outlinepath // be the relative file path // DebugHelper.Prime.ListRoute(path); SubPath = path.SubPath(rootPath); OutlinePath = SubPath.Clone(); } else { // all but FILE - just save the path for later // review SubPath = path.Clone(); OutlinePath = path.Clone(); } if (SubPath.RouteType != RouteType.FILE) { NonFileCount++; } }
/// <summary> /// Gets the simple git version <see cref="RepositoryInfo"/> from a branch. /// Returns null if an error occurred or if RepositoryInfo.xml has not been successfully read. /// </summary> /// <param name="m">The monitor to use.</param> /// <param name="branchName">Defaults to <see cref="CurrentBranchName"/>.</param> /// <returns>The RepositoryInfo or null if it it cannot be obtained.</returns> public RepositoryInfo ReadRepositoryVersionInfo(IActivityMonitor m, string branchName = null) { if (branchName == null) { branchName = CurrentBranchName; } try { Branch b = Git.Branches[branchName]; if (b == null) { m.Error($"Unknown branch {branchName}."); return(null); } var pathOpt = b.IsRemote ? SubPath.AppendPart("remotes").Combine(b.FriendlyName) : SubPath.AppendPart("branches").AppendPart(branchName); pathOpt = pathOpt.AppendPart("RepositoryInfo.xml"); var fOpt = FileSystem.GetFileInfo(pathOpt); if (!fOpt.Exists) { m.Error($"Missing required {pathOpt} file."); return(null); } var opt = RepositoryInfoOptions.Read(fOpt.ReadAsXDocument().Root); opt.StartingBranchName = branchName; var result = new RepositoryInfo(Git, opt); if (result.RepositoryError != null) { m.Error($"Unable to read RepositoryInfo. RepositoryError: {result.RepositoryError}."); return(null); } if (result.Error != null) { m.Error(result.ReleaseTagError); return(null); } return(result); } catch (Exception ex) { m.Fatal($"While reading version info for branch '{branchName}'.", ex); return(null); } }
string _getFilePathName(Movie movie, string sourceFile) { if (SubPath != null) { var a = SubPath.Replace("演员", movie.Actor.Count == 0 ? "无名氏" : Tools.ListToString(movie.Actor)); a = a.Replace("番号", movie.AVCode); a = a.Replace("厂商", movie.Maker == "" ? "未知厂商" : movie.Maker); a = a.Replace("制造商", movie.Producer == "" ? "未知制造商" : movie.Producer); a = a.Replace("标题", movie.Title == "" ? "未知标题" : movie.Title); a = a.Replace("标签", movie.Lable == "" ? "无标签" : movie.Lable); return(Path.Combine(DestPath, a, movie.AVCode + Path.GetExtension(sourceFile))); } else { return(Path.Combine(DestPath, movie.AVCode, Path.GetFileName(movie.AVCode))); } }
private void btnCrSemiLine_Click(object sender, RoutedEventArgs e) { if (checkActive()) { MessageBox.Show(err, "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { Size s = new Size(app.ActiveSelection.SizeWidth, app.ActiveSelection.SizeHeight); ShapeRange orSh = app.ActiveSelectionRange; Shape sh = app.ActiveLayer.CreateRectangle(orSh.LeftX, orSh.TopY, orSh.RightX, orSh.BottomY); sh.ConvertToCurves(); Curve c = app.ActiveDocument.CreateCurve(); SubPath ss = c.CreateSubPath(orSh.RightX, orSh.BottomY); ss.AppendCurveSegment(orSh.LeftX, orSh.BottomY); ss.AppendCurveSegment(orSh.LeftX, orSh.TopY); sh.Curve.CopyAssign(c); orSh.Delete(); sh.CreateSelection(); orSh = app.ActiveSelectionRange; double space = 0; for (int i = 1; i < numRow.Value; i++) { space += s.y; orSh.AddRange(app.ActiveSelectionRange.Duplicate(0, -space)); } orSh.CreateSelection(); space = 0; for (int j = 1; j < numCol.Value; j++) { space += s.x; orSh.AddRange(app.ActiveSelectionRange.Duplicate(space, 0)); } orSh.Add(app.ActiveLayer.CreateLineSegment(orSh.PositionX, orSh.PositionY, orSh.PositionX + orSh.SizeWidth, orSh.PositionY)); orSh.Add(app.ActiveLayer.CreateLineSegment(orSh.PositionX + orSh.SizeWidth, orSh.PositionY, orSh.PositionX + orSh.SizeWidth, orSh.PositionY - orSh.SizeHeight)); orSh.Group(); app.ActiveLayer.CreateRectangle(orSh.LeftX, orSh.TopY, orSh.RightX, orSh.BottomY).CreateSelection(); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.Source, "Lỗi"); } }
public override CriterionResult Validate(string path) { CriterionResult baseResult = base.Validate(path); if (!baseResult.IsValid) { return(baseResult); } //setup the full path by safely adding the extra path. string fullPath = Path.Combine(path, SubPath?.Trim('\\') ?? ""); //next step down directories based on the depth specified var directories = fullPath.GetDirectoriesAtDepth(Depth); var patterns = FileNamePattern.Split(','); if (directories != null && directories.Any()) { //check the file pattern foreach (var dir in directories) { foreach (var pattern in patterns) { if (Directory.GetFiles(dir, pattern).Any()) { return(new CriterionResult() { Description = Description, IsValid = true, Message = $"You have a '{FileNamePattern}' file {Depth} folders deep in your in your '{SubPath}' folder." }); } } } } //if we end up here the file is not found return(new CriterionResult() { Description = Description, IsValid = false, Message = $"Could not find a file like '{FileNamePattern}' {Depth} folders down from the '{SubPath}' folder." }); }
private void createMark() { double mSize = 1.6; double mWid = 0.06; app.ActiveDocument.Unit = cdrUnit.cdrCentimeter; ShapeRange orSh = app.ActiveSelectionRange; Shape botRight = app.ActiveLayer.CreateRectangle(0, 0, mSize, mSize); botRight.ConvertToCurves(); Curve c = app.ActiveDocument.CreateCurve(); SubPath ss = c.CreateSubPath(mSize, mSize); ss.AppendCurveSegment(0, mSize); ss.AppendCurveSegment(0, 0); botRight.Curve.CopyAssign(c); botRight.Outline.Width = mWid; botRight.Outline.Color.CMYKAssign(30, 30, 30, 100); Shape topRight = botRight.Duplicate(0, 0); topRight.Flip(cdrFlipAxes.cdrFlipVertical); topRight.AddToSelection(); Shape topLeft = botRight.Duplicate(0, 0); topLeft.Flip(cdrFlipAxes.cdrFlipBoth); topLeft.AddToSelection(); Shape botLeft = botRight.Duplicate(0, 0); botLeft.Flip(cdrFlipAxes.cdrFlipHorizontal); botLeft.AddToSelection(); botRight.Move(orSh.PositionX + orSh.SizeWidth, orSh.PositionY - orSh.SizeHeight - mSize); topRight.Move(orSh.PositionX + orSh.SizeWidth, orSh.PositionY); topLeft.Move(orSh.PositionX - mSize, orSh.PositionY); botLeft.Move(orSh.PositionX - mSize, orSh.PositionY - orSh.SizeHeight - mSize); Shape mark = app.ActiveSelectionRange.Combine(); mark.Name = "FineCut_TomboGroup"; orSh.Delete(); }
private void AddNewSubPath(SubPath subpath) { StartNewPathIfNull(); _currentPath.SubPaths.Add(subpath); }
public override int GetHashCode() => SubPath.GetHashCode();