using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Diagnostics;
namespace Laj.SWEgenskaper
{
// Last modified: 2002-10-21
// Version: 0.44 ID:LAJGAIS44
// Compiles with Microsoft Visual C# .NET 7.0.9466 on Windows 95.
// The source code is free. It is not under any kind of license.
// If this code works, it was written by Lars Johansson, Göteborg.
// If not, I don't know who wrote it.
// Changes
// Version: 0.43 2002-10-21
// DragDrop implemented
// Version: 0.44 2002-10-21
// comboBoxFileName.Items.AddRange(fileNames); replaced in filesToForm
public class FormMain : System.Windows.Forms.Form
{
private System.Windows.Forms.Button buttonAbout;
private System.Windows.Forms.Button buttonAllFiles;
private System.Windows.Forms.Button buttonDo;
private System.Windows.Forms.Button buttonHelp;
private System.Windows.Forms.Button buttonNow;
private System.Windows.Forms.Button buttonAddFile;
private System.Windows.Forms.Button buttonUndo;
private System.Windows.Forms.CheckBox checkBoxAccessed;
private System.Windows.Forms.CheckBox checkBoxArchiveFile;
private System.Windows.Forms.CheckBox checkBoxCreated;
private System.Windows.Forms.CheckBox checkBoxExtensionChange;
private System.Windows.Forms.CheckBox checkBoxHiddenFile;
private System.Windows.Forms.CheckBox checkBoxModified;
private System.Windows.Forms.CheckBox checkBoxProcessAllFileNames;
private System.Windows.Forms.CheckBox checkBoxProcessFolders;
private System.Windows.Forms.CheckBox checkBoxReadOnly;
private System.Windows.Forms.CheckBox checkBoxSystemFile;
private System.Windows.Forms.CheckBox checkBoxWalkSubfolders;
private System.Windows.Forms.ComboBox comboBoxDay;
private System.Windows.Forms.ComboBox comboBoxFileName;
private System.Windows.Forms.ComboBox comboBoxHour;
private System.Windows.Forms.ComboBox comboBoxMonth;
private System.Windows.Forms.ComboBox comboBoxYear;
private System.Windows.Forms.GroupBox groupBoxAttributes;
private System.Windows.Forms.GroupBox groupBoxExtension;
private System.Windows.Forms.GroupBox groupBoxFile;
private System.Windows.Forms.GroupBox groupBoxTouch;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox textBoxLocation;
private System.Windows.Forms.TextBox textBoxNewExtension;
private System.Windows.Forms.ComboBox comboBoxSecond;
private System.Windows.Forms.ComboBox comboBoxMinute;
private System.Windows.Forms.Button buttonClearAllFiles;
private System.Windows.Forms.CheckBox checkBoxChangeReadOnly;
private System.Windows.Forms.CheckBox checkBoxChangeArchiveFile;
private System.Windows.Forms.CheckBox checkBoxChangeSystemFile;
private System.Windows.Forms.CheckBox checkBoxChangeHiddenFile;
private System.Windows.Forms.CheckBox checkBoxChangeCapitalizationFileName;
private System.Windows.Forms.CheckBox checkBoxChangeCapitalizationExtension;
private System.Windows.Forms.ComboBox comboBoxCapitalizationFileName;
private System.Windows.Forms.ComboBox comboBoxCapitalizationExtension;
private System.Windows.Forms.Button buttonClearCurrentFile;
private System.Windows.Forms.GroupBox groupBoxCapitalization;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public FormMain()
{
InitializeComponent();
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FormMain));
this.groupBoxTouch = new System.Windows.Forms.GroupBox();
this.label7 = new System.Windows.Forms.Label();
this.buttonNow = new System.Windows.Forms.Button();
this.comboBoxSecond = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.comboBoxDay = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.comboBoxMonth = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.comboBoxYear = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.checkBoxAccessed = new System.Windows.Forms.CheckBox();
this.checkBoxModified = new System.Windows.Forms.CheckBox();
this.checkBoxCreated = new System.Windows.Forms.CheckBox();
this.comboBoxHour = new System.Windows.Forms.ComboBox();
this.comboBoxMinute = new System.Windows.Forms.ComboBox();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.groupBoxAttributes = new System.Windows.Forms.GroupBox();
this.checkBoxChangeHiddenFile = new System.Windows.Forms.CheckBox();
this.checkBoxChangeSystemFile = new System.Windows.Forms.CheckBox();
this.checkBoxChangeArchiveFile = new System.Windows.Forms.CheckBox();
this.checkBoxHiddenFile = new System.Windows.Forms.CheckBox();
this.checkBoxSystemFile = new System.Windows.Forms.CheckBox();
this.checkBoxArchiveFile = new System.Windows.Forms.CheckBox();
this.checkBoxReadOnly = new System.Windows.Forms.CheckBox();
this.checkBoxChangeReadOnly = new System.Windows.Forms.CheckBox();
this.groupBoxExtension = new System.Windows.Forms.GroupBox();
this.textBoxNewExtension = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.checkBoxExtensionChange = new System.Windows.Forms.CheckBox();
this.groupBoxFile = new System.Windows.Forms.GroupBox();
this.buttonClearCurrentFile = new System.Windows.Forms.Button();
this.buttonClearAllFiles = new System.Windows.Forms.Button();
this.textBoxLocation = new System.Windows.Forms.TextBox();
this.checkBoxProcessAllFileNames = new System.Windows.Forms.CheckBox();
this.buttonAllFiles = new System.Windows.Forms.Button();
this.checkBoxProcessFolders = new System.Windows.Forms.CheckBox();
this.checkBoxWalkSubfolders = new System.Windows.Forms.CheckBox();
this.label9 = new System.Windows.Forms.Label();
this.buttonAddFile = new System.Windows.Forms.Button();
this.comboBoxFileName = new System.Windows.Forms.ComboBox();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.buttonDo = new System.Windows.Forms.Button();
this.buttonUndo = new System.Windows.Forms.Button();
this.buttonAbout = new System.Windows.Forms.Button();
this.buttonHelp = new System.Windows.Forms.Button();
this.groupBoxCapitalization = new System.Windows.Forms.GroupBox();
this.comboBoxCapitalizationExtension = new System.Windows.Forms.ComboBox();
this.comboBoxCapitalizationFileName = new System.Windows.Forms.ComboBox();
this.checkBoxChangeCapitalizationExtension = new System.Windows.Forms.CheckBox();
this.checkBoxChangeCapitalizationFileName = new System.Windows.Forms.CheckBox();
this.groupBoxTouch.SuspendLayout();
this.groupBoxAttributes.SuspendLayout();
this.groupBoxExtension.SuspendLayout();
this.groupBoxFile.SuspendLayout();
this.groupBoxCapitalization.SuspendLayout();
this.SuspendLayout();
//
// groupBoxTouch
//
this.groupBoxTouch.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label7,
this.buttonNow,
this.comboBoxSecond,
this.label6,
this.comboBoxDay,
this.label3,
this.comboBoxMonth,
this.label2,
this.comboBoxYear,
this.label1,
this.checkBoxAccessed,
this.checkBoxModified,
this.checkBoxCreated,
this.comboBoxHour,
this.comboBoxMinute,
this.label5,
this.label4});
this.groupBoxTouch.Location = new System.Drawing.Point(8, 312);
this.groupBoxTouch.Name = "groupBoxTouch";
this.groupBoxTouch.Size = new System.Drawing.Size(432, 96);
this.groupBoxTouch.TabIndex = 3;
this.groupBoxTouch.TabStop = false;
this.groupBoxTouch.Text = "Touch";
//
// label7
//
this.label7.Location = new System.Drawing.Point(8, 16);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(48, 23);
this.label7.TabIndex = 12;
this.label7.Text = "Change:";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// buttonNow
//
this.buttonNow.Location = new System.Drawing.Point(384, 64);
this.buttonNow.Name = "buttonNow";
this.buttonNow.Size = new System.Drawing.Size(40, 23);
this.buttonNow.TabIndex = 9;
this.buttonNow.Text = "Now";
this.buttonNow.Click += new System.EventHandler(this.buttonNow_Click);
//
// comboBoxSecond
//
this.comboBoxSecond.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSecond.Location = new System.Drawing.Point(320, 64);
this.comboBoxSecond.Name = "comboBoxSecond";
this.comboBoxSecond.Size = new System.Drawing.Size(56, 21);
this.comboBoxSecond.TabIndex = 8;
//
// label6
//
this.label6.Location = new System.Drawing.Point(320, 48);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(36, 23);
this.label6.TabIndex = 10;
this.label6.Text = "Sec";
//
// comboBoxDay
//
this.comboBoxDay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxDay.Location = new System.Drawing.Point(128, 64);
this.comboBoxDay.Name = "comboBoxDay";
this.comboBoxDay.Size = new System.Drawing.Size(56, 21);
this.comboBoxDay.TabIndex = 5;
//
// label3
//
this.label3.Location = new System.Drawing.Point(128, 48);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(36, 23);
this.label3.TabIndex = 8;
this.label3.Text = "Day";
//
// comboBoxMonth
//
this.comboBoxMonth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxMonth.Location = new System.Drawing.Point(72, 64);
this.comboBoxMonth.Name = "comboBoxMonth";
this.comboBoxMonth.Size = new System.Drawing.Size(56, 21);
this.comboBoxMonth.TabIndex = 4;
this.comboBoxMonth.SelectedIndexChanged += new System.EventHandler(this.comboBoxYearOrMonth_SelectedIndexChanged);
//
// label2
//
this.label2.Location = new System.Drawing.Point(72, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(36, 23);
this.label2.TabIndex = 6;
this.label2.Text = "Month";
//
// comboBoxYear
//
this.comboBoxYear.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxYear.Location = new System.Drawing.Point(8, 64);
this.comboBoxYear.Name = "comboBoxYear";
this.comboBoxYear.Size = new System.Drawing.Size(56, 21);
this.comboBoxYear.TabIndex = 3;
this.comboBoxYear.SelectedIndexChanged += new System.EventHandler(this.comboBoxYearOrMonth_SelectedIndexChanged);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 48);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(32, 23);
this.label1.TabIndex = 4;
this.label1.Text = "Year";
//
// checkBoxAccessed
//
this.checkBoxAccessed.Location = new System.Drawing.Point(288, 16);
this.checkBoxAccessed.Name = "checkBoxAccessed";
this.checkBoxAccessed.Size = new System.Drawing.Size(112, 24);
this.checkBoxAccessed.TabIndex = 2;
this.checkBoxAccessed.Text = "Last accessed (L)";
//
// checkBoxModified
//
this.checkBoxModified.Location = new System.Drawing.Point(176, 16);
this.checkBoxModified.Name = "checkBoxModified";
this.checkBoxModified.Size = new System.Drawing.Size(88, 24);
this.checkBoxModified.TabIndex = 1;
this.checkBoxModified.Text = "Modified (M)";
//
// checkBoxCreated
//
this.checkBoxCreated.Location = new System.Drawing.Point(64, 16);
this.checkBoxCreated.Name = "checkBoxCreated";
this.checkBoxCreated.Size = new System.Drawing.Size(88, 24);
this.checkBoxCreated.TabIndex = 0;
this.checkBoxCreated.Text = "Created (C)";
//
// comboBoxHour
//
this.comboBoxHour.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxHour.Location = new System.Drawing.Point(192, 64);
this.comboBoxHour.Name = "comboBoxHour";
this.comboBoxHour.Size = new System.Drawing.Size(56, 21);
this.comboBoxHour.TabIndex = 6;
//
// comboBoxMinute
//
this.comboBoxMinute.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxMinute.Location = new System.Drawing.Point(256, 64);
this.comboBoxMinute.Name = "comboBoxMinute";
this.comboBoxMinute.Size = new System.Drawing.Size(56, 21);
this.comboBoxMinute.TabIndex = 7;
//
// label5
//
this.label5.Location = new System.Drawing.Point(256, 48);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(36, 23);
this.label5.TabIndex = 8;
this.label5.Text = "Min";
//
// label4
//
this.label4.Location = new System.Drawing.Point(192, 48);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(36, 23);
this.label4.TabIndex = 8;
this.label4.Text = "Hour";
//
// groupBoxAttributes
//
this.groupBoxAttributes.Controls.AddRange(new System.Windows.Forms.Control[] {
this.checkBoxChangeHiddenFile,
this.checkBoxChangeSystemFile,
this.checkBoxChangeArchiveFile,
this.checkBoxHiddenFile,
this.checkBoxSystemFile,
this.checkBoxArchiveFile,
this.checkBoxReadOnly,
this.checkBoxChangeReadOnly});
this.groupBoxAttributes.Location = new System.Drawing.Point(8, 416);
this.groupBoxAttributes.Name = "groupBoxAttributes";
this.groupBoxAttributes.Size = new System.Drawing.Size(432, 72);
this.groupBoxAttributes.TabIndex = 4;
this.groupBoxAttributes.TabStop = false;
this.groupBoxAttributes.Text = "Attributes";
//
// checkBoxChangeHiddenFile
//
this.checkBoxChangeHiddenFile.Location = new System.Drawing.Point(304, 16);
this.checkBoxChangeHiddenFile.Name = "checkBoxChangeHiddenFile";
this.checkBoxChangeHiddenFile.Size = new System.Drawing.Size(64, 24);
this.checkBoxChangeHiddenFile.TabIndex = 6;
this.checkBoxChangeHiddenFile.Text = "Change";
//
// checkBoxChangeSystemFile
//
this.checkBoxChangeSystemFile.Location = new System.Drawing.Point(208, 16);
this.checkBoxChangeSystemFile.Name = "checkBoxChangeSystemFile";
this.checkBoxChangeSystemFile.Size = new System.Drawing.Size(64, 24);
this.checkBoxChangeSystemFile.TabIndex = 4;
this.checkBoxChangeSystemFile.Text = "Change";
//
// checkBoxChangeArchiveFile
//
this.checkBoxChangeArchiveFile.Location = new System.Drawing.Point(104, 16);
this.checkBoxChangeArchiveFile.Name = "checkBoxChangeArchiveFile";
this.checkBoxChangeArchiveFile.Size = new System.Drawing.Size(64, 24);
this.checkBoxChangeArchiveFile.TabIndex = 2;
this.checkBoxChangeArchiveFile.Text = "Change";
//
// checkBoxHiddenFile
//
this.checkBoxHiddenFile.Location = new System.Drawing.Point(304, 40);
this.checkBoxHiddenFile.Name = "checkBoxHiddenFile";
this.checkBoxHiddenFile.Size = new System.Drawing.Size(96, 24);
this.checkBoxHiddenFile.TabIndex = 7;
this.checkBoxHiddenFile.Text = "Hidden file (H)";
//
// checkBoxSystemFile
//
this.checkBoxSystemFile.Location = new System.Drawing.Point(208, 40);
this.checkBoxSystemFile.Name = "checkBoxSystemFile";
this.checkBoxSystemFile.Size = new System.Drawing.Size(100, 24);
this.checkBoxSystemFile.TabIndex = 5;
this.checkBoxSystemFile.Text = "System file (S)";
//
// checkBoxArchiveFile
//
this.checkBoxArchiveFile.Location = new System.Drawing.Point(104, 40);
this.checkBoxArchiveFile.Name = "checkBoxArchiveFile";
this.checkBoxArchiveFile.Size = new System.Drawing.Size(100, 24);
this.checkBoxArchiveFile.TabIndex = 3;
this.checkBoxArchiveFile.Text = "Archive file (A)";
//
// checkBoxReadOnly
//
this.checkBoxReadOnly.Location = new System.Drawing.Point(8, 40);
this.checkBoxReadOnly.Name = "checkBoxReadOnly";
this.checkBoxReadOnly.Size = new System.Drawing.Size(96, 24);
this.checkBoxReadOnly.TabIndex = 1;
this.checkBoxReadOnly.Text = "Read-only (R)";
//
// checkBoxChangeReadOnly
//
this.checkBoxChangeReadOnly.Location = new System.Drawing.Point(8, 16);
this.checkBoxChangeReadOnly.Name = "checkBoxChangeReadOnly";
this.checkBoxChangeReadOnly.Size = new System.Drawing.Size(64, 24);
this.checkBoxChangeReadOnly.TabIndex = 0;
this.checkBoxChangeReadOnly.Text = "Change";
//
// groupBoxExtension
//
this.groupBoxExtension.Controls.AddRange(new System.Windows.Forms.Control[] {
this.textBoxNewExtension,
this.label8,
this.checkBoxExtensionChange});
this.groupBoxExtension.Location = new System.Drawing.Point(8, 200);
this.groupBoxExtension.Name = "groupBoxExtension";
this.groupBoxExtension.Size = new System.Drawing.Size(432, 48);
this.groupBoxExtension.TabIndex = 1;
this.groupBoxExtension.TabStop = false;
this.groupBoxExtension.Text = "Extension (E)";
//
// textBoxNewExtension
//
this.textBoxNewExtension.Location = new System.Drawing.Point(168, 16);
this.textBoxNewExtension.Name = "textBoxNewExtension";
this.textBoxNewExtension.Size = new System.Drawing.Size(88, 20);
this.textBoxNewExtension.TabIndex = 1;
this.textBoxNewExtension.Text = "txt";
//
// label8
//
this.label8.Location = new System.Drawing.Point(80, 16);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(88, 23);
this.label8.TabIndex = 2;
this.label8.Text = "New extension:";
this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// checkBoxExtensionChange
//
this.checkBoxExtensionChange.Location = new System.Drawing.Point(8, 16);
this.checkBoxExtensionChange.Name = "checkBoxExtensionChange";
this.checkBoxExtensionChange.Size = new System.Drawing.Size(64, 24);
this.checkBoxExtensionChange.TabIndex = 0;
this.checkBoxExtensionChange.Text = "Change";
//
// groupBoxFile
//
this.groupBoxFile.Controls.AddRange(new System.Windows.Forms.Control[] {
this.buttonClearCurrentFile,
this.buttonClearAllFiles,
this.textBoxLocation,
this.checkBoxProcessAllFileNames,
this.buttonAllFiles,
this.checkBoxProcessFolders,
this.checkBoxWalkSubfolders,
this.label9,
this.buttonAddFile,
this.comboBoxFileName,
this.label10});
this.groupBoxFile.Location = new System.Drawing.Point(8, 8);
this.groupBoxFile.Name = "groupBoxFile";
this.groupBoxFile.Size = new System.Drawing.Size(432, 184);
this.groupBoxFile.TabIndex = 0;
this.groupBoxFile.TabStop = false;
this.groupBoxFile.Text = "File/Files";
//
// buttonClearCurrentFile
//
this.buttonClearCurrentFile.Location = new System.Drawing.Point(128, 16);
this.buttonClearCurrentFile.Name = "buttonClearCurrentFile";
this.buttonClearCurrentFile.Size = new System.Drawing.Size(96, 23);
this.buttonClearCurrentFile.TabIndex = 1;
this.buttonClearCurrentFile.Text = "Clear current file";
this.buttonClearCurrentFile.Click += new System.EventHandler(this.buttonClearCurrentFile_Click);
//
// buttonClearAllFiles
//
this.buttonClearAllFiles.Location = new System.Drawing.Point(232, 16);
this.buttonClearAllFiles.Name = "buttonClearAllFiles";
this.buttonClearAllFiles.Size = new System.Drawing.Size(80, 23);
this.buttonClearAllFiles.TabIndex = 2;
this.buttonClearAllFiles.Text = "Clear all files";
this.buttonClearAllFiles.Click += new System.EventHandler(this.buttonClearAllFiles_Click);
//
// textBoxLocation
//
this.textBoxLocation.Location = new System.Drawing.Point(72, 72);
this.textBoxLocation.Name = "textBoxLocation";
this.textBoxLocation.Size = new System.Drawing.Size(352, 20);
this.textBoxLocation.TabIndex = 5;
this.textBoxLocation.Text = ".";
//
// checkBoxProcessAllFileNames
//
this.checkBoxProcessAllFileNames.Location = new System.Drawing.Point(8, 104);
this.checkBoxProcessAllFileNames.Name = "checkBoxProcessAllFileNames";
this.checkBoxProcessAllFileNames.Size = new System.Drawing.Size(352, 24);
this.checkBoxProcessAllFileNames.TabIndex = 6;
this.checkBoxProcessAllFileNames.Text = "Process all file names";
//
// buttonAllFiles
//
this.buttonAllFiles.Location = new System.Drawing.Point(360, 16);
this.buttonAllFiles.Name = "buttonAllFiles";
this.buttonAllFiles.Size = new System.Drawing.Size(64, 23);
this.buttonAllFiles.TabIndex = 3;
this.buttonAllFiles.Text = "All files *.*";
this.buttonAllFiles.Click += new System.EventHandler(this.buttonAllFiles_Click);
//
// checkBoxProcessFolders
//
this.checkBoxProcessFolders.Location = new System.Drawing.Point(8, 152);
this.checkBoxProcessFolders.Name = "checkBoxProcessFolders";
this.checkBoxProcessFolders.Size = new System.Drawing.Size(352, 24);
this.checkBoxProcessFolders.TabIndex = 8;
this.checkBoxProcessFolders.Text = "Process folders as well (D)";
//
// checkBoxWalkSubfolders
//
this.checkBoxWalkSubfolders.Location = new System.Drawing.Point(8, 128);
this.checkBoxWalkSubfolders.Name = "checkBoxWalkSubfolders";
this.checkBoxWalkSubfolders.Size = new System.Drawing.Size(352, 24);
this.checkBoxWalkSubfolders.TabIndex = 7;
this.checkBoxWalkSubfolders.Text = "Process matching files in the current folder and all subfolders (T)";
//
// label9
//
this.label9.Location = new System.Drawing.Point(8, 72);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(64, 23);
this.label9.TabIndex = 32;
this.label9.Text = "Location";
//
// buttonAddFile
//
this.buttonAddFile.Location = new System.Drawing.Point(8, 16);
this.buttonAddFile.Name = "buttonAddFile";
this.buttonAddFile.Size = new System.Drawing.Size(96, 23);
this.buttonAddFile.TabIndex = 0;
this.buttonAddFile.Text = "Add file(s)...";
this.buttonAddFile.Click += new System.EventHandler(this.buttonAddFile_Click);
//
// comboBoxFileName
//
this.comboBoxFileName.Location = new System.Drawing.Point(72, 48);
this.comboBoxFileName.Name = "comboBoxFileName";
this.comboBoxFileName.Size = new System.Drawing.Size(352, 21);
this.comboBoxFileName.TabIndex = 4;
this.comboBoxFileName.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBoxFileName_KeyPress);
//
// label10
//
this.label10.Location = new System.Drawing.Point(8, 48);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(72, 23);
this.label10.TabIndex = 27;
this.label10.Text = "File name(s)";
//
// label11
//
this.label11.Location = new System.Drawing.Point(16, 80);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(64, 23);
this.label11.TabIndex = 30;
this.label11.Text = "Location";
//
// buttonDo
//
this.buttonDo.Location = new System.Drawing.Point(8, 496);
this.buttonDo.Name = "buttonDo";
this.buttonDo.TabIndex = 5;
this.buttonDo.Text = "Do";
this.buttonDo.Click += new System.EventHandler(this.buttonDo_Click);
//
// buttonUndo
//
this.buttonUndo.Location = new System.Drawing.Point(88, 496);
this.buttonUndo.Name = "buttonUndo";
this.buttonUndo.TabIndex = 6;
this.buttonUndo.Text = "Undo";
this.buttonUndo.Click += new System.EventHandler(this.buttonUndo_Click);
//
// buttonAbout
//
this.buttonAbout.Location = new System.Drawing.Point(360, 496);
this.buttonAbout.Name = "buttonAbout";
this.buttonAbout.TabIndex = 8;
this.buttonAbout.Text = "About";
this.buttonAbout.Click += new System.EventHandler(this.buttonAbout_Click);
//
// buttonHelp
//
this.buttonHelp.Location = new System.Drawing.Point(280, 496);
this.buttonHelp.Name = "buttonHelp";
this.buttonHelp.TabIndex = 7;
this.buttonHelp.Text = "Help";
this.buttonHelp.Click += new System.EventHandler(this.buttonHelp_Click);
//
// groupBoxCapitalization
//
this.groupBoxCapitalization.Controls.AddRange(new System.Windows.Forms.Control[] {
this.comboBoxCapitalizationExtension,
this.comboBoxCapitalizationFileName,
this.checkBoxChangeCapitalizationExtension,
this.checkBoxChangeCapitalizationFileName});
this.groupBoxCapitalization.Location = new System.Drawing.Point(8, 256);
this.groupBoxCapitalization.Name = "groupBoxCapitalization";
this.groupBoxCapitalization.Size = new System.Drawing.Size(432, 48);
this.groupBoxCapitalization.TabIndex = 2;
this.groupBoxCapitalization.TabStop = false;
this.groupBoxCapitalization.Text = "Capitalization (Z)";
//
// comboBoxCapitalizationExtension
//
this.comboBoxCapitalizationExtension.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxCapitalizationExtension.Items.AddRange(new object[] {
"To upper",
"To lower"});
this.comboBoxCapitalizationExtension.Location = new System.Drawing.Point(354, 18);
this.comboBoxCapitalizationExtension.Name = "comboBoxCapitalizationExtension";
this.comboBoxCapitalizationExtension.Size = new System.Drawing.Size(72, 21);
this.comboBoxCapitalizationExtension.TabIndex = 3;
//
// comboBoxCapitalizationFileName
//
this.comboBoxCapitalizationFileName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxCapitalizationFileName.Items.AddRange(new object[] {
"To upper",
"To lower"});
this.comboBoxCapitalizationFileName.Location = new System.Drawing.Point(136, 18);
this.comboBoxCapitalizationFileName.Name = "comboBoxCapitalizationFileName";
this.comboBoxCapitalizationFileName.Size = new System.Drawing.Size(72, 21);
this.comboBoxCapitalizationFileName.TabIndex = 1;
//
// checkBoxChangeCapitalizationExtension
//
this.checkBoxChangeCapitalizationExtension.Location = new System.Drawing.Point(224, 16);
this.checkBoxChangeCapitalizationExtension.Name = "checkBoxChangeCapitalizationExtension";
this.checkBoxChangeCapitalizationExtension.Size = new System.Drawing.Size(144, 24);
this.checkBoxChangeCapitalizationExtension.TabIndex = 2;
this.checkBoxChangeCapitalizationExtension.Text = "Change extension (ZE)";
//
// checkBoxChangeCapitalizationFileName
//
this.checkBoxChangeCapitalizationFileName.Location = new System.Drawing.Point(8, 16);
this.checkBoxChangeCapitalizationFileName.Name = "checkBoxChangeCapitalizationFileName";
this.checkBoxChangeCapitalizationFileName.Size = new System.Drawing.Size(136, 24);
this.checkBoxChangeCapitalizationFileName.TabIndex = 0;
this.checkBoxChangeCapitalizationFileName.Text = "Change file name (ZF)";
//
// FormMain
//
this.AllowDrop = true;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(448, 525);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.groupBoxCapitalization,
this.groupBoxExtension,
this.buttonHelp,
this.buttonAbout,
this.buttonUndo,
this.buttonDo,
this.groupBoxFile,
this.groupBoxAttributes,
this.groupBoxTouch,
this.label11});
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FormMain";
this.Text = "SWEgenskaper";
this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);
this.Load += new System.EventHandler(this.Form1_Load);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.FormMain_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.FormMain_DragEnter);
this.groupBoxTouch.ResumeLayout(false);
this.groupBoxAttributes.ResumeLayout(false);
this.groupBoxExtension.ResumeLayout(false);
this.groupBoxFile.ResumeLayout(false);
this.groupBoxCapitalization.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static int Main(string[] args)
{
if (args.Length == 0)
{
IntPtr hwnd = Laj.WinAPI.GetConsoleWindow();
Laj.WinAPI.ShowWindow(hwnd, Laj.WinAPI.SW_HIDE);
Application.Run(new FormMain());
Laj.WinAPI.ShowWindow(hwnd, Laj.WinAPI.SW_SHOW);
return 0;
}
else if (args[0] == "/?")
return CommandLine.WriteHelp();
else
return CommandLine.Process(args);
}
bool loaded = false;
const string monthFormat = "MMM";
int FormMainWidthOrig;
int groupBoxFileWidthOrig;
int comboBoxFileNameWidthOrig;
void allDataFromForm()
{
Backend.PS.ProcessAllFileNames = checkBoxProcessAllFileNames.Checked;
Backend.PS.WalkSubfolders = checkBoxWalkSubfolders.Checked;
Backend.PS.ProcessFolders = checkBoxProcessFolders.Checked;
Backend.PS.Extension.Change = checkBoxExtensionChange.Checked;
Backend.PS.Extension.NewExtension = textBoxNewExtension.Text;
Backend.PS.Capitalization.FileName.Change = checkBoxChangeCapitalizationFileName.Checked;
Backend.PS.Capitalization.Extension.Change = checkBoxChangeCapitalizationExtension.Checked;
Backend.PS.Capitalization.FileName.ToUpper = (comboBoxCapitalizationFileName.SelectedIndex == 0);
Backend.PS.Capitalization.Extension.ToUpper = (comboBoxCapitalizationExtension.SelectedIndex == 0);
Backend.PS.Touch.ChangeCreated = checkBoxCreated.Checked;
Backend.PS.Touch.ChangeModified = checkBoxModified.Checked;
Backend.PS.Touch.ChangeAccessed = checkBoxAccessed.Checked;
Backend.PS.Touch.NewCreationTime = dateFromForm();
Backend.PS.Touch.NewLastWriteTime = Backend.PS.Touch.NewCreationTime;
Backend.PS.Touch.NewLastAccessTime = Backend.PS.Touch.NewCreationTime;
Backend.PS.Attributes.ChangeReadOnly = checkBoxChangeReadOnly.Checked;
Backend.PS.Attributes.ChangeArchive = checkBoxChangeArchiveFile.Checked;
Backend.PS.Attributes.ChangeSystem = checkBoxChangeSystemFile.Checked;
Backend.PS.Attributes.ChangeHidden = checkBoxChangeHiddenFile.Checked;
Backend.PS.Attributes.ReadOnly = checkBoxReadOnly.Checked;
Backend.PS.Attributes.Archive = checkBoxArchiveFile.Checked;
Backend.PS.Attributes.System = checkBoxSystemFile.Checked;
Backend.PS.Attributes.Hidden = checkBoxHiddenFile.Checked;
}
int yearFromForm()
{
return Convert.ToInt32(comboBoxYear.Text);
}
int monthFromForm()
{
string month = comboBoxMonth.Text;
DateTime m = DateTime.ParseExact(month, monthFormat,
System.Globalization.CultureInfo.CurrentUICulture);
return m.Month;
}
int dayFromForm()
{
return Convert.ToInt32(comboBoxDay.Text);
}
DateTime dateFromForm()
{
int year = yearFromForm();
int month = monthFromForm();
int day = dayFromForm();
int hour = Convert.ToInt32(comboBoxHour.Text);
int minute = Convert.ToInt32(comboBoxMinute.Text);
int second = Convert.ToInt32(comboBoxSecond.Text);
return new DateTime(year, month, day, hour, minute, second);
}
void allDataToForm()
{
checkBoxProcessAllFileNames.Checked = Backend.PS.ProcessAllFileNames;
checkBoxWalkSubfolders.Checked = Backend.PS.WalkSubfolders;
checkBoxProcessFolders.Checked = Backend.PS.ProcessFolders;
checkBoxExtensionChange.Checked = Backend.PS.Extension.Change;
textBoxNewExtension.Text = Backend.PS.Extension.NewExtension;
checkBoxChangeCapitalizationFileName.Checked = Backend.PS.Capitalization.FileName.Change;
checkBoxChangeCapitalizationExtension.Checked = Backend.PS.Capitalization.Extension.Change;
comboBoxCapitalizationFileName.SelectedIndex = (Backend.PS.Capitalization.FileName.ToUpper) ? 0 : 1;
comboBoxCapitalizationExtension.SelectedIndex = (Backend.PS.Capitalization.Extension.ToUpper) ? 0 : 1;
checkBoxCreated.Checked = Backend.PS.Touch.ChangeCreated;
checkBoxModified.Checked = Backend.PS.Touch.ChangeModified;
checkBoxAccessed.Checked = Backend.PS.Touch.ChangeAccessed;
dateToForm(Backend.PS.Touch.NewCreationTime);
checkBoxChangeReadOnly.Checked = Backend.PS.Attributes.ChangeReadOnly;
checkBoxChangeArchiveFile.Checked = Backend.PS.Attributes.ChangeArchive;
checkBoxChangeSystemFile.Checked = Backend.PS.Attributes.ChangeSystem;
checkBoxChangeHiddenFile.Checked = Backend.PS.Attributes.ChangeHidden;
checkBoxReadOnly.Checked = Backend.PS.Attributes.ReadOnly;
checkBoxArchiveFile.Checked = Backend.PS.Attributes.Archive;
checkBoxSystemFile.Checked = Backend.PS.Attributes.System;
checkBoxHiddenFile.Checked = Backend.PS.Attributes.Hidden;
}
void filesToForm(string[] fileNames)
{
foreach (string file in fileNames)
{
if (!comboBoxFileName.Items.Contains(file) )
{
comboBoxFileName.Items.Add(file);
}
}
int index = comboBoxFileName.FindStringExact(fileNames[0]);
comboBoxFileName.SelectedIndex = index;
checkBoxProcessAllFileNames.Checked = (comboBoxFileName.Items.Count > 1);
}
void dateToForm(DateTime currentDate)
{
const int startYear = 2000;
if (comboBoxYear.Items.Count <= 0)
{
for (int k = 0; k <= 10; k++)
{
comboBoxYear.Items.Add(k+startYear);
}
}
comboBoxYear.SelectedIndex = currentDate.Year-startYear;
if (comboBoxMonth.Items.Count <= 0)
{
for (int k = 1; k <= 12; k++)
{
DateTime dt = new DateTime(startYear, k, 1);
comboBoxMonth.Items.Add(dt.ToString(monthFormat) );
}
}
comboBoxMonth.SelectedIndex = comboBoxMonth.FindStringExact(currentDate.ToString(monthFormat) );
dayToForm(currentDate.Year, currentDate.Month, currentDate.Day);
if (comboBoxHour.Items.Count <= 0)
{
for (int k = 0; k <= 23; k++)
{
comboBoxHour.Items.Add(k.ToString("D2") );
}
}
comboBoxHour.SelectedIndex = currentDate.Hour;
if (comboBoxMinute.Items.Count <= 0)
{
for (int k = 0; k <= 59; k++)
{
comboBoxMinute.Items.Add(k.ToString("D2") );
}
}
comboBoxMinute.SelectedIndex = currentDate.Minute;
if (comboBoxSecond.Items.Count <= 0)
{
for (int k = 0; k <= 59; k++)
{
comboBoxSecond.Items.Add(k.ToString("D2") );
}
}
comboBoxSecond.SelectedIndex = currentDate.Second;
}
void dayToForm(int year, int month, int day)
{
int daysInMonth = DateTime.DaysInMonth(year, month);
comboBoxDay.Items.Clear();
for (int k = 1; k <= daysInMonth; k++)
{
comboBoxDay.Items.Add(k.ToString("D2") );
}
if (1 <= day && day <= daysInMonth)
comboBoxDay.SelectedIndex = day - 1;
else
comboBoxDay.SelectedIndex = 0;
}
bool shouldTextBeAddedToItems()
{
string file = comboBoxFileName.Text.Trim();
if (file.Length > 0)
{
if (!comboBoxFileName.Items.Contains(file) ) return true;
}
return false;
}
void addTextToItems()
{
if (shouldTextBeAddedToItems() )
{
comboBoxFileName.Items.Insert(0, comboBoxFileName.Text.Trim() );
}
}
void clearCurrentFile()
{
string file = comboBoxFileName.Text;
comboBoxFileName.Text = "";
int index = comboBoxFileName.FindStringExact(file);
if (index >= 0)
{
comboBoxFileName.Items.RemoveAt(index);
if (comboBoxFileName.Items.Count > 0)
{
comboBoxFileName.SelectedIndex = 0;
comboBoxFileName.Text =
comboBoxFileName.SelectedItem.ToString();
}
}
}
void clearAllFiles()
{
comboBoxFileName.Items.Clear();
comboBoxFileName.Text = "";
}
private void buttonAddFile_Click(object sender, System.EventArgs e)
{
string[] fileNames;
bool ok = Backend.ShowOpenFileDialog(out fileNames);
this.Text = Application.ProductName + " - " + System.IO.Directory.GetCurrentDirectory();
if (!ok) return;
filesToForm(fileNames);
textBoxLocation.Text = Directory.GetParent(fileNames[0]).FullName;
}
private void buttonClearCurrentFile_Click(object sender, System.EventArgs e)
{
clearCurrentFile();
}
private void buttonClearAllFiles_Click(object sender, System.EventArgs e)
{
clearAllFiles();
}
private void buttonAllFiles_Click(object sender, System.EventArgs e)
{
clearAllFiles();
comboBoxFileName.Text = "*.*";
addTextToItems();
}
private void comboBoxFileName_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar == (int)Keys.Enter)
{
addTextToItems();
//TODO2 Varför försvinner musen?
//comboBoxFileName.DroppedDown = true;
e.Handled = true; //TODO3 Varför "låter" det?
}
//TODO0 Varför funkar inte Keys.Delete?
else if (e.KeyChar == (int)Keys.Back)
{
if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
{ //TODO1 Kommer aldrig hit
Debug.WriteLine("Pressed " + Keys.Control);
}
else if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
{ //...men hit
Debug.WriteLine("Pressed " + Keys.Shift);
clearAllFiles();
}
e.Handled = true;
}
else if (e.KeyChar == 127)
{ //...och hit
Debug.WriteLine("Pressed 127 " + Keys.Control);
// char #127 is at the end
comboBoxFileName.Text = comboBoxFileName.Text.Substring(0,
comboBoxFileName.Text.Length-1).Trim();
clearCurrentFile();
e.Handled = true;
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
FormMainWidthOrig = this.Size.Width;
groupBoxFileWidthOrig = groupBoxFile.Width;
comboBoxFileNameWidthOrig = comboBoxFileName.Width;
comboBoxCapitalizationFileName.SelectedIndex = 0;
comboBoxCapitalizationExtension.SelectedIndex = 0;
DateTime currentDate = DateTime.Now;
dateToForm(new DateTime(currentDate.Year, currentDate.Month, currentDate.Day) );
//TODO
//config file
//allDataToForm();
loaded = true;
this.Text = Application.ProductName + " - " + System.IO.Directory.GetCurrentDirectory();
}
private void Form1_SizeChanged(object sender, System.EventArgs e)
{
int delta = this.Size.Width - FormMainWidthOrig;
if (delta >= 0)
{
groupBoxFile.Width = groupBoxFileWidthOrig + delta;
comboBoxFileName.Width = comboBoxFileNameWidthOrig + delta;
textBoxLocation.Width = comboBoxFileNameWidthOrig + delta;
groupBoxExtension.Width = groupBoxFileWidthOrig + delta;
groupBoxCapitalization.Width = groupBoxFileWidthOrig + delta;
groupBoxTouch.Width = groupBoxFileWidthOrig + delta;
groupBoxAttributes.Width = groupBoxFileWidthOrig + delta;
}
}
private void comboBoxYearOrMonth_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (!loaded) return;
int year = yearFromForm();
int month = monthFromForm();
int day = dayFromForm();
dayToForm(year, month, day);
}
private void buttonNow_Click(object sender, System.EventArgs e)
{
dateToForm(DateTime.Now);
}
private void buttonDo_Click(object sender, System.EventArgs e)
{
allDataFromForm();
int c = (Backend.PS.ProcessAllFileNames) ? comboBoxFileName.Items.Count : 0;
int t = (shouldTextBeAddedToItems() ) ? 1 : 0;
if (t== 0 && !Backend.PS.ProcessAllFileNames) t = 1;
string[] files = new String[t+c];
for (int k = 0; k < c; k++)
{
files[k] = (string)comboBoxFileName.Items[k];
}
if (t == 1) files[c] = comboBoxFileName.Text.Trim();
string location = textBoxLocation.Text;
if (location.LastIndexOf(@"\")+1 == location.Length)
{
if (location.Length >= 1)
{
location = location.Substring(0, location.Length-1);
}
}
Backend.ProcessAll(location, files);
if (Backend.PS.Extension.Change) clearAllFiles();
}
private void buttonUndo_Click(object sender, System.EventArgs e)
{
Laj.SWEgenskaper.DlgHelp dlgHelp = new Laj.SWEgenskaper.DlgHelp();
dlgHelp.Text = "Undo";
dlgHelp.ShowDialog();
}
private void buttonHelp_Click(object sender, System.EventArgs e)
{
Laj.SWEgenskaper.DlgHelp dlgHelp = new Laj.SWEgenskaper.DlgHelp();
dlgHelp.ShowDialog();
}
private void buttonAbout_Click(object sender, System.EventArgs e)
{
Laj.DlgArchetype.DlgAbout dlgAbout = new Laj.DlgArchetype.DlgAbout();
dlgAbout.ShowDialog();
}
private void FormMain_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop) )
e.Effect = DragDropEffects.All;
else
e.Effect = DragDropEffects.None;
}
private void FormMain_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
string[] fileNames = (string[])e.Data.GetData("FileDrop", false);
this.Text = Application.ProductName + " - " + System.IO.Directory.GetCurrentDirectory();
filesToForm(fileNames);
textBoxLocation.Text = Directory.GetParent(fileNames[0]).FullName;
}
}
}