/// <summary> /// Initializes a new instance of the <see cref="SelfMediaDatabase.Core.Operations.Prune.PruneOperation"/> class. /// </summary> /// <param name="directory">Injection wrapper of <see cref="System.IO.Directory"/>.</param> /// <param name="file">Injection wrapper of <see cref="System.IO.File"/>.</param> /// <param name="path">Injection wrapper of <see cref="System.IO.Path"/>.</param> /// <param name="imageComparer">Image comparer.</param> /// <param name="fileSystemHelper">Helper to access to files.</param> public PruneOperation( IDirectory directory, IFile file, IPath path, IImageComparer imageComparer, IFileSystemHelper fileSystemHelper, IDialog dialog, IRenameOperation renameOperation) { if (directory == null) throw new ArgumentNullException("directory"); if (file == null) throw new ArgumentNullException("file"); if (imageComparer == null) throw new ArgumentNullException("imageComparer"); if (fileSystemHelper == null) throw new ArgumentNullException("fileSystemHelper"); if (path == null) throw new ArgumentNullException("path"); if (dialog == null) throw new ArgumentNullException("dialog"); if (renameOperation == null) throw new ArgumentNullException("renameOperation"); _directory = directory; _file = file; _path = path; _imageComparer = imageComparer; _fileSystemHelper = fileSystemHelper; _dialog = dialog; _renameOperation = renameOperation; }
/// <summary> /// Sets the rename operation to use. /// </summary> /// <param name="operation">Operation to assign.</param> public void SetRenameOperation(IRenameOperation operation) { var operationList = new List <IRenameOperation>(); operationList.Add(operation); this.SetRenameOperations(operationList); }
public PollingRenameOperation( IRenameOperation renameOperation, IPollingManager pollingManager) { _renameOperation = renameOperation; _pollingManager = pollingManager; }
/// <summary> /// Initializes a new instance of the <see cref="SelfMediaDatabase.Console.Bootstrap.BootstrapOperations"/> class. /// </summary> /// <param name="optionUtils">Utils for command line options.</param> public BootstrapOperations( IOptionsUtils optionsUtils, IRenameOperation renameOperation, ITagsOperation tagsOperation, IPruneOperation pruneOperation, IClassifyOperation classifyOperation, ISearchOperation searchOperation) { if (renameOperation == null) throw new ArgumentNullException("renameOperation"); if (optionsUtils == null) throw new ArgumentNullException("optionsUtils"); if (tagsOperation == null) throw new ArgumentNullException("tagsOperation"); if (pruneOperation == null) throw new ArgumentNullException("pruneOperation"); if (classifyOperation == null) throw new ArgumentNullException("classifyOperation"); if (searchOperation == null) throw new ArgumentNullException("searchOperation"); _optionsUtils = optionsUtils; _renameOperation = renameOperation; _tagsOperation = tagsOperation; _pruneOperation = pruneOperation; _classifyOperation = classifyOperation; _searchOperation = searchOperation; }
public void Initialize() { _optionUtils = Substitute.For<IOptionsUtils>(); _renameOperation = Substitute.For<IRenameOperation>(); _tagsOperation = Substitute.For<ITagsOperation>(); _pruneOperation = Substitute.For<IPruneOperation>(); _classifyOperation = Substitute.For<IClassifyOperation>(); _searchOperation = Substitute.For<ISearchOperation>(); _target = new BootstrapOperations(_optionUtils, _renameOperation, _tagsOperation, _pruneOperation, _classifyOperation, _searchOperation); }
public void Initialize() { _directory = Substitute.For<IDirectory>(); _file = Substitute.For<IFile>(); _path = Substitute.For<IPath>(); _imageComparer = Substitute.For<IImageComparer>(); _fileSystemHelper = Substitute.For<IFileSystemHelper>(); _dialog = Substitute.For<IDialog>(); _renameOperation = Substitute.For<IRenameOperation>(); _path.SetPathDefaultBehavior(); _target = new PruneOperation(_directory, _file, _path, _imageComparer, _fileSystemHelper, _dialog, _renameOperation); }
/// <summary> /// Sets the RenameOperation instance represented by the drawer. /// </summary> /// <param name="renameOperationInstance">RenameOperation instance.</param> public void SetModel(IRenameOperation renameOperationInstance) { // This cast is a *bit* of an assumption, that the passed instance can be // downcasted to a more derived type (T : IRenameOperation) than IRenameOperation. this.renameOperation = (T)renameOperationInstance; }
public RenameOperationTester (IFileSystemHelper fileSystemHelper, IFile file, IPath path, IDialog dialog, IRenameOperation self) : base(fileSystemHelper, file, path, dialog) { if (self == null) self = this; _self = self; }
public RenameOperationDrawerBinding(IRenameOperation operation, IRenameOperationDrawer drawer) { this.Operation = operation; this.Drawer = drawer; }
private void FocusRenameOperationDeferred(IRenameOperation renameOperation) { this.OperationToForceFocus = renameOperation; }
private void DrawRenameOperations(Rect operationRect, float spacing) { var headerRect = new Rect(operationRect); headerRect.height = 18.0f; var operationStyle = new GUIStyle("ScriptText"); GUI.Box(headerRect, "", operationStyle); var headerStyle = new GUIStyle(EditorStyles.boldLabel); headerStyle.alignment = TextAnchor.MiddleCenter; EditorGUI.LabelField(headerRect, "Rename Operations", headerStyle); // Store the op before buttons are pressed because buttons change focus var focusedOpBeforeButtonPresses = this.FocusedRenameOp; bool saveOpsToPreferences = false; IRenameOperation operationToFocus = null; var totalHeightDrawn = 0.0f; for (int i = 0; i < this.NumRenameOperations; ++i) { var currentElement = this.RenameOperationsToApplyWithBindings[i]; var rect = new Rect(operationRect); rect.y += totalHeightDrawn + spacing + headerRect.height; rect.height = currentElement.Drawer.GetPreferredHeight(); totalHeightDrawn += rect.height + spacing; var guiOptions = new RenameOperationGUIOptions(); guiOptions.ControlPrefix = i; guiOptions.DisableUpButton = i == 0; guiOptions.DisableDownButton = i == this.NumRenameOperations - 1; var buttonClickEvent = currentElement.Drawer.DrawGUI(rect, guiOptions); switch (buttonClickEvent) { case RenameOperationSortingButtonEvent.MoveUp: { this.RenameOperationsToApplyWithBindings.MoveElementFromIndexToIndex(i, i - 1); saveOpsToPreferences = true; // Move focus with the RenameOp. This techincally changes their focus within the // rename op, but it's better than focus getting swapped to whatever op replaces this one. operationToFocus = focusedOpBeforeButtonPresses; break; } case RenameOperationSortingButtonEvent.MoveDown: { this.RenameOperationsToApplyWithBindings.MoveElementFromIndexToIndex(i, i + 1); saveOpsToPreferences = true; operationToFocus = focusedOpBeforeButtonPresses; break; } case RenameOperationSortingButtonEvent.Delete: { var removingFocusedOperation = focusedOpBeforeButtonPresses == currentElement; this.RenameOperationsToApplyWithBindings.RemoveAt(i); saveOpsToPreferences = true; if (removingFocusedOperation && this.NumRenameOperations > 0) { // Focus the RenameOp that took this one's place, if there is one. var indexToFocus = Mathf.Min(this.NumRenameOperations - 1, i); operationToFocus = this.RenameOperationsToApplyWithBindings[indexToFocus].Operation; } else { operationToFocus = focusedOpBeforeButtonPresses; } break; } case RenameOperationSortingButtonEvent.None: { // Do nothing break; } default: { Debug.LogError(string.Format( "RenamerWindow found Unrecognized ListButtonEvent [{0}] in OnGUI. Add a case to handle this event.", buttonClickEvent)); return; } } if (operationToFocus != null) { this.FocusRenameOperationDeferred(operationToFocus); } if (saveOpsToPreferences) { this.SaveRenameOperationsToPreferences(); } } }
public LoggingPollingRenameOperation(IRenameOperation renameOperation, ILogger logger) { _renameOperation = renameOperation; _logger = logger; }
private static string ConvertOperationToStringEntry(IRenameOperation op) { return(string.Format("[{0}]{1}", op.GetType(), JsonUtility.ToJson(op))); }