
Bulk file renamer windows full#
When adding new elements, they are always added after the current index (active element) – if the list is full and the element is added to the end of the list, then the first element of the list is removed. GetPreviousElement will take elements as long as it does not reach the beginning of the list, while the same applies to GetNextElement, only in the opposite direction. The structure always remembers the current index – from which point we can go backwards (undo – GetPreviousElement) or forward (redo – GetNextElement). The class is initialized with a generic variable type T, and it takes as parameter the desired capacity of the Deque – meaning how many undo objects will it be able to remember.Įlements can be added (pushed), and taken (pulled) from the structure. The backbone of a Deque object is a LinkedList. While (_list.Count - 1 > _index & _list.Count != 0) _index = Math.Min(_index + 1, _list.Count - 1) if index is somewhere in between, delete all the values on higher indexes else if(_index (_index) if capacity is full and index is at the last element, remove first if (_list.Count = Capacity & _index = Capacity - 1)

NET Framework, so I needed to build one myself for this purpose. Such a structure is called a „deque“ and it does not (still) exist as a built-in class in. (The undo / redo refers to all the „apply changes“ actions.)įor the undo / redo functionality to work, we need a sort-of double-sided stack structure (something where we can push and pull elements from each side of the list). The app also supports undo / redo functionality. MessageBoxButtons.OK, MessageBoxIcon.Error) MessageBox.Show( " Expected number of filenames is " +į(), " Invalid number of filenames", Private void checkBox1_CheckedChanged( object sender, EventArgs e) To achieve this, I introduced a Dictionary type variable called selections:
Bulk file renamer windows code#
Highlighted text gets edited, but in order to programatically loop through these highlighted selections, the code must be able to recognize which text exactly is highlighted. If ( this.DialogResult = DialogResult.OK)įorm.StartPosition = FormStartPosition.Manual Private void Tbx_KeyUp( object sender, KeyEventArgs e) This.FormBorderStyle = FormBorderStyle.None The entered string is confirmed ( OK) by pressing ENTER, and it is rejected ( Cancel) by pressing ESCAPE.

It is always shown on current mouse position. The MyInputBox is shown by calling the static method ShowDialog, similar to MessageBox. Selections.Add( new Tuple(startIndex, 0)) įor( int i = 0 i (selections.Item1 +įor the purpose of entering the replacement/insertion string, I have designed a special input box (separate class), which basically consists of only an empty textbox (no surrounding form). If (selections.Where(x => x.Value.Count > 0).Count() = 0) check if selections are clear - allowed for insert int startIndex Private void ReplaceInsert( string newString, bool replace)
