diff options
Diffstat (limited to 'TimeHACK.Main/GlobalPrograms')
6 files changed, 267 insertions, 31 deletions
diff --git a/TimeHACK.Main/GlobalPrograms/AddressBook/WinClassicAddressBook.cs b/TimeHACK.Main/GlobalPrograms/AddressBook/WinClassicAddressBook.cs index c7c8184..24404bf 100644 --- a/TimeHACK.Main/GlobalPrograms/AddressBook/WinClassicAddressBook.cs +++ b/TimeHACK.Main/GlobalPrograms/AddressBook/WinClassicAddressBook.cs @@ -123,7 +123,7 @@ namespace TimeHACK.OS.Win95.Win95Apps void NewFolder() { FRMWinClassicAddressBookNewFolder abnf = new FRMWinClassicAddressBookNewFolder(); - WinClassic app = wm.startWin95(abnf, "Address Book - New Folder", Properties.Resources.Win95IconWordpad, true, true, true); + WinClassic app = wm.StartWin95(abnf, "Address Book - New Folder", Properties.Resources.Win95IconWordpad, true, true, true); if (treeView1.SelectedNode != null) { @@ -133,7 +133,7 @@ namespace TimeHACK.OS.Win95.Win95Apps } else { - wm.startInfobox95("Address Book - New Folder", "You must enter a folder name!", Properties.Resources.Win95Error); + wm.StartInfobox95("Address Book - New Folder", "You must enter a folder name!", Properties.Resources.Win95Error); } } } @@ -146,7 +146,7 @@ namespace TimeHACK.OS.Win95.Win95Apps void NewContact() { FRMWinClassicAddressBookNewContact abnc = new FRMWinClassicAddressBookNewContact(); - WinClassic app = wm.startWin95(abnc, "Address Book - New Contact", Properties.Resources.Win95IconWordpad, true, true, true); + WinClassic app = wm.StartWin95(abnc, "Address Book - New Contact", Properties.Resources.Win95IconWordpad, true, true, true); if (treeView1.SelectedNode != null) { @@ -189,7 +189,7 @@ namespace TimeHACK.OS.Win95.Win95Apps } } } - WinClassic app = wm.startWin95(abnc, "Address Book - Contact Properties", Properties.Resources.Win95IconWordpad, true, true, true); + WinClassic app = wm.StartWin95(abnc, "Address Book - Contact Properties", Properties.Resources.Win95IconWordpad, true, true, true); if (treeView1.SelectedNode != null) { diff --git a/TimeHACK.Main/GlobalPrograms/WinClassicNotepad.cs b/TimeHACK.Main/GlobalPrograms/WinClassicNotepad.cs index 6dd6ee8..f1920ed 100644 --- a/TimeHACK.Main/GlobalPrograms/WinClassicNotepad.cs +++ b/TimeHACK.Main/GlobalPrograms/WinClassicNotepad.cs @@ -36,7 +36,7 @@ namespace TimeHACK.OS.Win95.Win95Apps private void aboutNotepadToolStripMenuItem_Click(object sender, EventArgs e) { WindowManager wm = new WindowManager(); - wm.startAboutBox95("Notepad", "Microsoft Notepad", Properties.Resources.WinClassicNotepad); + wm.StartAboutBox95("Notepad", "Microsoft Notepad", Properties.Resources.WinClassicNotepad); } private void wordWrapToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/TimeHACK.Main/GlobalPrograms/WinClassicTerminal.Designer.cs b/TimeHACK.Main/GlobalPrograms/WinClassicTerminal.Designer.cs index ddae557..b505208 100644 --- a/TimeHACK.Main/GlobalPrograms/WinClassicTerminal.Designer.cs +++ b/TimeHACK.Main/GlobalPrograms/WinClassicTerminal.Designer.cs @@ -28,35 +28,183 @@ /// </summary> private void InitializeComponent() { - this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.cmdPrompt = new System.Windows.Forms.RichTextBox(); + this.actionPanel = new System.Windows.Forms.Panel(); + this.btnFont = new System.Windows.Forms.Button(); + this.btnCopy = new System.Windows.Forms.Button(); + this.termMax = new System.Windows.Forms.Button(); + this.btnNothing = new System.Windows.Forms.Button(); + this.btnSettings = new System.Windows.Forms.Button(); + this.btnPaste = new System.Windows.Forms.Button(); + this.btnMark = new System.Windows.Forms.Button(); + this.sizeSel = new System.Windows.Forms.ComboBox(); + this.actionPanel.SuspendLayout(); this.SuspendLayout(); // - // richTextBox1 + // cmdPrompt // - this.richTextBox1.BackColor = System.Drawing.Color.Black; - this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.richTextBox1.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.richTextBox1.ForeColor = System.Drawing.Color.White; - this.richTextBox1.Location = new System.Drawing.Point(0, 0); - this.richTextBox1.Name = "richTextBox1"; - this.richTextBox1.ReadOnly = true; - this.richTextBox1.Size = new System.Drawing.Size(459, 262); - this.richTextBox1.TabIndex = 0; - this.richTextBox1.Text = ""; + this.cmdPrompt.BackColor = System.Drawing.Color.Black; + this.cmdPrompt.Dock = System.Windows.Forms.DockStyle.Fill; + this.cmdPrompt.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cmdPrompt.ForeColor = System.Drawing.Color.White; + this.cmdPrompt.Location = new System.Drawing.Point(0, 0); + this.cmdPrompt.Name = "cmdPrompt"; + this.cmdPrompt.ShowSelectionMargin = true; + this.cmdPrompt.Size = new System.Drawing.Size(459, 262); + this.cmdPrompt.TabIndex = 0; + this.cmdPrompt.Text = ""; + this.cmdPrompt.KeyUp += new System.Windows.Forms.KeyEventHandler(this.richTextBox1_KeyUp); + // + // actionPanel + // + this.actionPanel.BackColor = System.Drawing.Color.Silver; + this.actionPanel.Controls.Add(this.btnFont); + this.actionPanel.Controls.Add(this.btnCopy); + this.actionPanel.Controls.Add(this.termMax); + this.actionPanel.Controls.Add(this.btnNothing); + this.actionPanel.Controls.Add(this.btnSettings); + this.actionPanel.Controls.Add(this.btnPaste); + this.actionPanel.Controls.Add(this.btnMark); + this.actionPanel.Controls.Add(this.sizeSel); + this.actionPanel.Dock = System.Windows.Forms.DockStyle.Top; + this.actionPanel.Location = new System.Drawing.Point(0, 0); + this.actionPanel.Name = "actionPanel"; + this.actionPanel.Size = new System.Drawing.Size(459, 28); + this.actionPanel.TabIndex = 1; + // + // btnFont + // + this.btnFont.BackgroundImage = global::TimeHACK.Properties.Resources.termFont; + this.btnFont.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.btnFont.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnFont.Location = new System.Drawing.Point(266, 3); + this.btnFont.Name = "btnFont"; + this.btnFont.Size = new System.Drawing.Size(23, 22); + this.btnFont.TabIndex = 7; + this.btnFont.UseVisualStyleBackColor = true; + this.btnFont.Click += new System.EventHandler(this.btnFont_Click); + // + // btnCopy + // + this.btnCopy.BackgroundImage = global::TimeHACK.Properties.Resources.termCopy; + this.btnCopy.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.btnCopy.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnCopy.Location = new System.Drawing.Point(126, 3); + this.btnCopy.Name = "btnCopy"; + this.btnCopy.Size = new System.Drawing.Size(23, 22); + this.btnCopy.TabIndex = 6; + this.btnCopy.UseVisualStyleBackColor = true; + this.btnCopy.Click += new System.EventHandler(this.btnCopy_Click); + // + // termMax + // + this.termMax.BackgroundImage = global::TimeHACK.Properties.Resources.termMax; + this.termMax.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.termMax.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.termMax.Location = new System.Drawing.Point(180, 3); + this.termMax.Name = "termMax"; + this.termMax.Size = new System.Drawing.Size(23, 22); + this.termMax.TabIndex = 5; + this.termMax.UseVisualStyleBackColor = true; + this.termMax.Click += new System.EventHandler(this.termMax_Click); + // + // btnNothing + // + this.btnNothing.BackgroundImage = global::TimeHACK.Properties.Resources.termNothing; + this.btnNothing.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.btnNothing.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnNothing.Location = new System.Drawing.Point(234, 3); + this.btnNothing.Name = "btnNothing"; + this.btnNothing.Size = new System.Drawing.Size(23, 22); + this.btnNothing.TabIndex = 4; + this.btnNothing.UseVisualStyleBackColor = true; + // + // btnSettings + // + this.btnSettings.BackgroundImage = global::TimeHACK.Properties.Resources.termSettings; + this.btnSettings.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.btnSettings.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnSettings.Location = new System.Drawing.Point(212, 3); + this.btnSettings.Name = "btnSettings"; + this.btnSettings.Size = new System.Drawing.Size(23, 22); + this.btnSettings.TabIndex = 3; + this.btnSettings.UseVisualStyleBackColor = true; + this.btnSettings.Click += new System.EventHandler(this.btnSettings_Click); + // + // btnPaste + // + this.btnPaste.BackgroundImage = global::TimeHACK.Properties.Resources.termPaste; + this.btnPaste.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.btnPaste.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnPaste.Location = new System.Drawing.Point(148, 3); + this.btnPaste.Name = "btnPaste"; + this.btnPaste.Size = new System.Drawing.Size(23, 22); + this.btnPaste.TabIndex = 2; + this.btnPaste.UseVisualStyleBackColor = true; + this.btnPaste.Click += new System.EventHandler(this.btnPaste_Click); + // + // btnMark + // + this.btnMark.BackgroundImage = global::TimeHACK.Properties.Resources.termMark; + this.btnMark.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.btnMark.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnMark.Location = new System.Drawing.Point(104, 3); + this.btnMark.Name = "btnMark"; + this.btnMark.Size = new System.Drawing.Size(23, 22); + this.btnMark.TabIndex = 1; + this.btnMark.UseVisualStyleBackColor = true; + // + // sizeSel + // + this.sizeSel.BackColor = System.Drawing.Color.Silver; + this.sizeSel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.sizeSel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.sizeSel.FormattingEnabled = true; + this.sizeSel.Items.AddRange(new object[] { + "Auto", + "4 x 6", + "5 x 12", + "6 x 8", + "6 x 12", + "7 x 12", + "7 x 14", + "7 x 15", + "8 x 8", + "8 x 12", + "8 x 16", + "10 x 18", + "10 x 20", + "12 x 16", + "12 x 22"}); + this.sizeSel.Location = new System.Drawing.Point(4, 4); + this.sizeSel.Name = "sizeSel"; + this.sizeSel.Size = new System.Drawing.Size(92, 21); + this.sizeSel.TabIndex = 0; // // WinClassicTerminal // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.richTextBox1); + this.Controls.Add(this.actionPanel); + this.Controls.Add(this.cmdPrompt); this.Name = "WinClassicTerminal"; this.Size = new System.Drawing.Size(459, 262); + this.actionPanel.ResumeLayout(false); this.ResumeLayout(false); } #endregion - private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.RichTextBox cmdPrompt; + private System.Windows.Forms.Panel actionPanel; + private System.Windows.Forms.Button btnFont; + private System.Windows.Forms.Button btnCopy; + private System.Windows.Forms.Button termMax; + private System.Windows.Forms.Button btnNothing; + private System.Windows.Forms.Button btnSettings; + private System.Windows.Forms.Button btnPaste; + private System.Windows.Forms.Button btnMark; + private System.Windows.Forms.ComboBox sizeSel; } } diff --git a/TimeHACK.Main/GlobalPrograms/WinClassicTerminal.cs b/TimeHACK.Main/GlobalPrograms/WinClassicTerminal.cs index 86873ff..99f7aed 100644 --- a/TimeHACK.Main/GlobalPrograms/WinClassicTerminal.cs +++ b/TimeHACK.Main/GlobalPrograms/WinClassicTerminal.cs @@ -12,14 +12,39 @@ using System.IO; using System.Threading; using System.Reflection; using System.Linq.Expressions; +using System.Diagnostics; namespace TimeHACK.OS.Win95.Win95Apps { public partial class WinClassicTerminal : UserControl { + public Engine.WindowManager wm = new Engine.WindowManager(); + + public static int currentLine = 0; + public static string prefix = @"C:\>"; + public static string startupDir = $"{Engine.SaveSystem.ProfileMyComputerDirectory}"; + public WinClassicTerminal() { InitializeComponent(); + + // Paint the classic borders + btnCopy.Paint += (sender, args) => Engine.Paintbrush.PaintClassicBorders(sender, args, 2); + btnFont.Paint += (sender, args) => Engine.Paintbrush.PaintClassicBorders(sender, args, 2); + btnMark.Paint += (sender, args) => Engine.Paintbrush.PaintClassicBorders(sender, args, 2); + btnNothing.Paint += (sender, args) => Engine.Paintbrush.PaintClassicBorders(sender, args, 2); + btnPaste.Paint += (sender, args) => Engine.Paintbrush.PaintClassicBorders(sender, args, 2); + btnSettings.Paint += (sender, args) => Engine.Paintbrush.PaintClassicBorders(sender, args, 2); + sizeSel.Paint += (sender, args) => Engine.Paintbrush.PaintClassicBorders(sender, args, 2); + + // Set the default index to "Auto" + sizeSel.SelectedIndex = 0; + + // Set the font and append the prefix text + cmdPrompt.Font = new System.Drawing.Font(TitleScreen.pfc.Families[1], 10F, System.Drawing.FontStyle.Regular); + cmdPrompt.AppendText(prefix); + + cmdPrompt.BringToFront(); } /// <summary> /// Write text to the Terminal and create a new line. Very similar to the Win32 Console.WriteLine Function. @@ -27,7 +52,7 @@ namespace TimeHACK.OS.Win95.Win95Apps /// <param name="Text"></param> public void WriteLine(string Text) { - richTextBox1.AppendText(Text + "\n"); + cmdPrompt.AppendText(Text + "\n"); this.Update(); } @@ -37,8 +62,71 @@ namespace TimeHACK.OS.Win95.Win95Apps /// <param name="Text"></param> public void Write(String Text) { - richTextBox1.AppendText(Text); - richTextBox1.Update(); + cmdPrompt.AppendText(Text); + cmdPrompt.Update(); + } + + private void btnCopy_Click(object sender, EventArgs e) + { + if (cmdPrompt.SelectedText.Length > 0) + Clipboard.SetText(cmdPrompt.SelectedText); // Set the clipboard text to the selection of the RichTextBox + else + wm.StartInfobox95("ERROR", "You need to select something to copy.", Properties.Resources.Win95Error); // Display an error message if the length is 0 + } + + private void btnPaste_Click(object sender, EventArgs e) + { + if (Clipboard.GetText() != "") + Write(Clipboard.GetText()); // Write the contents of the Clipboard text in the RichTextBox + else + wm.StartInfobox95("ERROR", "You need to have something in your clipboard to paste.", Properties.Resources.Win95Error); // Display an error message if the clipboard is null/empty + } + + private void termMax_Click(object sender, EventArgs e) + { + var windowState = ((Engine.Template.WinClassic)this.TopLevelControl).WindowState; + + if (windowState == FormWindowState.Normal) + windowState = FormWindowState.Maximized; + else if (windowState == FormWindowState.Maximized) + windowState = FormWindowState.Normal; + } + + private void btnSettings_Click(object sender, EventArgs e) + { + wm.StartInfobox95("INFO", "This feature has not been implemented yet. Stay tuned! -Jason", Properties.Resources.Win95Info); + //TODO: Well, add the settings... + } + + private void btnFont_Click(object sender, EventArgs e) + { + //TODO: Add font UC(?) + } + + private void richTextBox1_KeyUp(object sender, KeyEventArgs e) + { + if (e.KeyData == Keys.Return) + { + /// Temporary CMD redirect + Process p = new Process(); + + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardOutput = true; + p.StartInfo.CreateNoWindow = true; + p.StartInfo.WorkingDirectory = startupDir; + p.StartInfo.FileName = "cmd.exe"; + p.StartInfo.Arguments = $"/C {cmdPrompt.Lines[cmdPrompt.GetLineFromCharIndex(currentLine)].Substring(prefix.Length)}"; + p.Start(); + + string output = p.StandardOutput.ReadToEnd(); + p.WaitForExit(); + + cmdPrompt.Focus(); + cmdPrompt.AppendText($"\n{output}"); + + currentLine++; + cmdPrompt.AppendText($"\n{prefix}"); + } } } } diff --git a/TimeHACK.Main/GlobalPrograms/WinClassicWindowsExplorer.cs b/TimeHACK.Main/GlobalPrograms/WinClassicWindowsExplorer.cs index 3a263a5..89a6b6f 100644 --- a/TimeHACK.Main/GlobalPrograms/WinClassicWindowsExplorer.cs +++ b/TimeHACK.Main/GlobalPrograms/WinClassicWindowsExplorer.cs @@ -151,7 +151,7 @@ namespace TimeHACK.OS.Win95.Win95Apps dirLbl.Text = currentDirectory; CheckLbl(); } catch (Exception ex) { - wm.startInfobox95("Exploring - C:", "Error with the file explorer \n" + ex.Message, Properties.Resources.Win95Info); + wm.StartInfobox95("Exploring - C:", "Error with the file explorer \n" + ex.Message, Properties.Resources.Win95Info); ((Form)this.TopLevelControl).Close(); } } @@ -548,7 +548,7 @@ namespace TimeHACK.OS.Win95.Win95Apps private void FolderToolStripMenuItem_Click(object sender, EventArgs e) { if (File.Exists(currentDirectory + "\\New Folder")) { - wm.startInfobox95("Windows Explorer", "This directory already exists", Properties.Resources.Win95Info); + wm.StartInfobox95("Windows Explorer", "This directory already exists", Properties.Resources.Win95Info); } else { Directory.CreateDirectory(currentDirectory + "\\New Folder"); SaveDirectoryInfo(currentDirectory + "\\New Folder", false, "New Folder", true); @@ -575,7 +575,7 @@ namespace TimeHACK.OS.Win95.Win95Apps { if (txtSave.Text == "") { - wm.startInfobox95("Windows Explorer", "Please enter a filename", Properties.Resources.Win95Info); + wm.StartInfobox95("Windows Explorer", "Please enter a filename", Properties.Resources.Win95Info); } else { @@ -604,7 +604,7 @@ namespace TimeHACK.OS.Win95.Win95Apps { if (!File.Exists(Path.Combine(currentDirectory, mainView.FocusedItem.Text))) { - wm.startInfobox95("Windows Explorer", "This directory doesn't exist", Properties.Resources.Win95Info); + wm.StartInfobox95("Windows Explorer", "This directory doesn't exist", Properties.Resources.Win95Info); } else { @@ -626,7 +626,7 @@ namespace TimeHACK.OS.Win95.Win95Apps private void AboutWindows95ToolStripMenuItem_Click(object sender, EventArgs e) { WindowManager wm = new WindowManager(); - wm.startAboutBox95("Windows 95", "Microsoft Windows 95 Rev B", Properties.Resources.WinClassicAbout95); + wm.StartAboutBox95("Windows 95", "Microsoft Windows 95 Rev B", Properties.Resources.WinClassicAbout95); } private void RenameToolStripMenuItem_Click(object sender, EventArgs e) @@ -650,13 +650,13 @@ namespace TimeHACK.OS.Win95.Win95Apps setText = mainView.FocusedItem.Text; if (setText == "") { - wm.startInfobox95("Windows Explorer", "Please enter a new directory name", Properties.Resources.Win95Info); + wm.StartInfobox95("Windows Explorer", "Please enter a new directory name", Properties.Resources.Win95Info); } else { if (Directory.Exists(setText)) { - wm.startInfobox95("Windows Explorer", "That directory already exists.", Properties.Resources.Win95Info); + wm.StartInfobox95("Windows Explorer", "That directory already exists.", Properties.Resources.Win95Info); } else { diff --git a/TimeHACK.Main/GlobalPrograms/WinClassicWordPad.cs b/TimeHACK.Main/GlobalPrograms/WinClassicWordPad.cs index 84ef3f6..4d2fbf1 100644 --- a/TimeHACK.Main/GlobalPrograms/WinClassicWordPad.cs +++ b/TimeHACK.Main/GlobalPrograms/WinClassicWordPad.cs @@ -122,7 +122,7 @@ namespace TimeHACK.OS.Win95.Win95Apps private void aboutWordpadToolStripMenuItem_Click(object sender, EventArgs e) { - wm.startAboutBox95("Wordpad", "Microsoft Wordpad", Properties.Resources.Win95IconWordpad); + wm.StartAboutBox95("Wordpad", "Microsoft Wordpad", Properties.Resources.Win95IconWordpad); } private void newToolStripMenuItem_Click(object sender, EventArgs e) @@ -137,7 +137,7 @@ namespace TimeHACK.OS.Win95.Win95Apps private void sendToolStripMenuItem_Click(object sender, EventArgs e) { - wm.startInfobox95("Wordpad", "An error occured opening send option.", null); + wm.StartInfobox95("Wordpad", "An error occured opening send option.", null); } void Cut() |
