diff options
Diffstat (limited to 'ShiftOS.WinForms')
30 files changed, 2064 insertions, 45 deletions
diff --git a/ShiftOS.WinForms/Applications/Artpad.cs b/ShiftOS.WinForms/Applications/Artpad.cs index e4d16bd..b584ac8 100644 --- a/ShiftOS.WinForms/Applications/Artpad.cs +++ b/ShiftOS.WinForms/Applications/Artpad.cs @@ -42,13 +42,17 @@ using System.Diagnostics; namespace ShiftOS.WinForms.Applications { + [FileHandler("Artpad Picture", ".pic", "fileiconpicture")] + [FileHandler("JPEG Picture", ".jpg", "fileiconpicture")] + [FileHandler("PNG Picture", ".png", "fileiconpicture")] + [FileHandler("Bitmap Picture", ".bmp", "fileiconpicture")] [MultiplayerOnly] [Launcher("{TIITLE_ARTPAD}", true, "al_artpad", "{AL_GRAPHICS}")] [RequiresUpgrade("artpad")] [WinOpen("{WO_ARTPAD}")] [DefaultIcon("iconArtpad")] [DefaultTitle("{TITLE_ARTPAD}")] - public partial class Artpad : UserControl, IShiftOSWindow + public partial class Artpad : UserControl, IShiftOSWindow, IFileHandler { /// <summary> /// artpad_'s GUI. @@ -1589,6 +1593,12 @@ namespace ShiftOS.WinForms.Applications setmagnification(); } + + public void OpenFile(string file) + { + AppearanceManager.SetupWindow(this); + LoadPicture(file); + } } public class undo diff --git a/ShiftOS.WinForms/Applications/Dodge.Designer.cs b/ShiftOS.WinForms/Applications/Dodge.Designer.cs new file mode 100644 index 0000000..9f330f9 --- /dev/null +++ b/ShiftOS.WinForms/Applications/Dodge.Designer.cs @@ -0,0 +1,230 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class Dodge + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Dodge)); + this.pgcontents = new System.Windows.Forms.Panel(); + this.player = new System.Windows.Forms.PictureBox(); + this.QuitButton = new System.Windows.Forms.PictureBox(); + this.BeginButton = new System.Windows.Forms.PictureBox(); + this.DescriptionLabel = new System.Windows.Forms.Label(); + this.object_small2 = new System.Windows.Forms.PictureBox(); + this.object_mid2 = new System.Windows.Forms.PictureBox(); + this.object_large = new System.Windows.Forms.PictureBox(); + this.object_small = new System.Windows.Forms.PictureBox(); + this.object_mid = new System.Windows.Forms.PictureBox(); + this.scorelabel = new System.Windows.Forms.Label(); + this.PicBonus = new System.Windows.Forms.PictureBox(); + this.clock = new System.Windows.Forms.Timer(this.components); + this.pgcontents.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.player)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.QuitButton)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.BeginButton)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.object_small2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.object_mid2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.object_large)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.object_small)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.object_mid)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.PicBonus)).BeginInit(); + this.SuspendLayout(); + // + // pgcontents + // + this.pgcontents.BackColor = System.Drawing.Color.White; + this.pgcontents.Controls.Add(this.player); + this.pgcontents.Controls.Add(this.QuitButton); + this.pgcontents.Controls.Add(this.BeginButton); + this.pgcontents.Controls.Add(this.DescriptionLabel); + this.pgcontents.Controls.Add(this.object_small2); + this.pgcontents.Controls.Add(this.object_mid2); + this.pgcontents.Controls.Add(this.object_large); + this.pgcontents.Controls.Add(this.object_small); + this.pgcontents.Controls.Add(this.object_mid); + this.pgcontents.Controls.Add(this.scorelabel); + this.pgcontents.Controls.Add(this.PicBonus); + this.pgcontents.Dock = System.Windows.Forms.DockStyle.Fill; + this.pgcontents.Location = new System.Drawing.Point(0, 0); + this.pgcontents.Name = "pgcontents"; + this.pgcontents.Size = new System.Drawing.Size(597, 567); + this.pgcontents.TabIndex = 21; + this.pgcontents.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pgcontents_MouseMove); + // + // player + // + this.player.BackColor = System.Drawing.Color.Transparent; + this.player.Image = ((System.Drawing.Image)(resources.GetObject("player.Image"))); + this.player.Location = new System.Drawing.Point(192, 445); + this.player.Name = "player"; + this.player.Size = new System.Drawing.Size(32, 32); + this.player.TabIndex = 18; + this.player.TabStop = false; + // + // QuitButton + // + this.QuitButton.Image = ((System.Drawing.Image)(resources.GetObject("QuitButton.Image"))); + this.QuitButton.Location = new System.Drawing.Point(216, 424); + this.QuitButton.Name = "QuitButton"; + this.QuitButton.Size = new System.Drawing.Size(200, 50); + this.QuitButton.TabIndex = 12; + this.QuitButton.TabStop = false; + this.QuitButton.Click += new System.EventHandler(this.QuitButton_Click); + // + // BeginButton + // + this.BeginButton.Image = ((System.Drawing.Image)(resources.GetObject("BeginButton.Image"))); + this.BeginButton.Location = new System.Drawing.Point(3, 424); + this.BeginButton.Name = "BeginButton"; + this.BeginButton.Size = new System.Drawing.Size(200, 50); + this.BeginButton.TabIndex = 11; + this.BeginButton.TabStop = false; + this.BeginButton.Click += new System.EventHandler(this.BeginButton_Click); + // + // DescriptionLabel + // + this.DescriptionLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.DescriptionLabel.Location = new System.Drawing.Point(3, 3); + this.DescriptionLabel.Name = "DescriptionLabel"; + this.DescriptionLabel.Size = new System.Drawing.Size(413, 409); + this.DescriptionLabel.TabIndex = 10; + this.DescriptionLabel.Text = "Placeholder"; + // + // object_small2 + // + this.object_small2.Image = ((System.Drawing.Image)(resources.GetObject("object_small2.Image"))); + this.object_small2.Location = new System.Drawing.Point(75, 43); + this.object_small2.Name = "object_small2"; + this.object_small2.Size = new System.Drawing.Size(75, 20); + this.object_small2.TabIndex = 17; + this.object_small2.TabStop = false; + // + // object_mid2 + // + this.object_mid2.Image = ((System.Drawing.Image)(resources.GetObject("object_mid2.Image"))); + this.object_mid2.Location = new System.Drawing.Point(279, 134); + this.object_mid2.Name = "object_mid2"; + this.object_mid2.Size = new System.Drawing.Size(125, 20); + this.object_mid2.TabIndex = 16; + this.object_mid2.TabStop = false; + // + // object_large + // + this.object_large.Image = ((System.Drawing.Image)(resources.GetObject("object_large.Image"))); + this.object_large.Location = new System.Drawing.Point(49, 208); + this.object_large.Name = "object_large"; + this.object_large.Size = new System.Drawing.Size(175, 20); + this.object_large.TabIndex = 15; + this.object_large.TabStop = false; + // + // object_small + // + this.object_small.Image = ((System.Drawing.Image)(resources.GetObject("object_small.Image"))); + this.object_small.Location = new System.Drawing.Point(290, 294); + this.object_small.Name = "object_small"; + this.object_small.Size = new System.Drawing.Size(75, 20); + this.object_small.TabIndex = 13; + this.object_small.TabStop = false; + // + // object_mid + // + this.object_mid.Image = ((System.Drawing.Image)(resources.GetObject("object_mid.Image"))); + this.object_mid.Location = new System.Drawing.Point(58, 371); + this.object_mid.Name = "object_mid"; + this.object_mid.Size = new System.Drawing.Size(125, 20); + this.object_mid.TabIndex = 14; + this.object_mid.TabStop = false; + // + // scorelabel + // + this.scorelabel.AutoSize = true; + this.scorelabel.BackColor = System.Drawing.Color.Transparent; + this.scorelabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.scorelabel.Location = new System.Drawing.Point(3, 4); + this.scorelabel.Name = "scorelabel"; + this.scorelabel.Size = new System.Drawing.Size(51, 55); + this.scorelabel.TabIndex = 19; + this.scorelabel.Text = "0"; + // + // PicBonus + // + this.PicBonus.Image = ((System.Drawing.Image)(resources.GetObject("PicBonus.Image"))); + this.PicBonus.Location = new System.Drawing.Point(187, 84); + this.PicBonus.Name = "PicBonus"; + this.PicBonus.Size = new System.Drawing.Size(16, 11); + this.PicBonus.TabIndex = 20; + this.PicBonus.TabStop = false; + this.PicBonus.Visible = false; + // + // clock + // + this.clock.Interval = 20; + this.clock.Tick += new System.EventHandler(this.clock_Tick); + // + // Dodge + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.pgcontents); + this.Name = "Dodge"; + this.Size = new System.Drawing.Size(597, 567); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Dodge_KeyDown); + this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Dodge_KeyUp); + this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Dodge_MouseMove); + this.pgcontents.ResumeLayout(false); + this.pgcontents.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.player)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.QuitButton)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.BeginButton)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.object_small2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.object_mid2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.object_large)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.object_small)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.object_mid)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.PicBonus)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + internal System.Windows.Forms.Panel pgcontents; + internal System.Windows.Forms.PictureBox player; + internal System.Windows.Forms.PictureBox QuitButton; + internal System.Windows.Forms.PictureBox BeginButton; + internal System.Windows.Forms.Label DescriptionLabel; + internal System.Windows.Forms.PictureBox object_small2; + internal System.Windows.Forms.PictureBox object_mid2; + internal System.Windows.Forms.PictureBox object_large; + internal System.Windows.Forms.PictureBox object_small; + internal System.Windows.Forms.PictureBox object_mid; + internal System.Windows.Forms.Label scorelabel; + internal System.Windows.Forms.PictureBox PicBonus; + internal System.Windows.Forms.Timer clock; + } +} diff --git a/ShiftOS.WinForms/Applications/Dodge.cs b/ShiftOS.WinForms/Applications/Dodge.cs new file mode 100644 index 0000000..ae1c829 --- /dev/null +++ b/ShiftOS.WinForms/Applications/Dodge.cs @@ -0,0 +1,224 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using Microsoft.VisualBasic; + +namespace ShiftOS.WinForms.Applications +{ + [AppscapeEntry("dodge", "Dodge", "Dodge falling objects and stay alive as long as you can. Play this fun and exciting game while earning code points!", 500, 1590, "", "Games")] + [WinOpen("dodge")] + [Launcher("Dodge", false, "", "Games")] + public partial class Dodge : UserControl, IShiftOSWindow + { + decimal speed; //the speed the game runs at + int score; //the score/code points the player gets + bool usingkeys = false; //user can use mouse or keyboard, mouse by default, chnages to true if key pressed + decimal time = 0; //Records the time spent playing, used for codepoints formula + int bonusesfound; //Number or bonus play collects + int keyboardinput = 0; //for smooth keyboard gameplay, 1=left, 2=right, 0=none + Point LocalMousePosition = new Point(0, 0); // the position of the mouse relative to our control + public Dodge() + { + InitializeComponent(); + } + + public void OnSkinLoad() + { + } + + public bool OnUnload() + { + return true; + } + + public void OnUpgrade() + { + } + + private void QuitButton_Click(object sender, EventArgs e) + { + AppearanceManager.Close(this); //quits the game (In case user donsn't have close button) + } + + private void Dodge_KeyUp(object sender, KeyEventArgs e) + { + keyboardinput = 0; + } + + public void OnLoad() + { + player.Visible = false; // hide player and score until game starts + scorelabel.Visible = false; + DescriptionLabel.Text = "Welcome to Dodge. Dodge is a simple arcade game with one objective: survive the falling objects! Use the arrow or mouse to move the player and avoid as many objects as you can. The longer you survive, the more code point you will be rewarded with. Beware, it gets harder..."; // set the description text + + //to impliment skinning, simply set the picturebox to the new skinned image. + //For example: + //player.Image = Image.FromFile("PATH TO SKINNED IMAGE"); + } + + private void BeginButton_Click(object sender, EventArgs e) + { + + //Hide buttons + BeginButton.Visible = false; + QuitButton.Visible = false; + DescriptionLabel.Visible = false; + + player.Visible = true; // show the player + speed = 2; // controls speed of game, will increase as game progresses + scorelabel.Visible = true; // show score label + bonusesfound = 0; + + //Make sure all objects are in the correct position + object_small.Location = new Point(((int)Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), 300); + object_small2.Location = new Point(((int)Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), 49); + object_mid.Location = new Point(((int)Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), 377); + object_mid2.Location = new Point(((int)Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), 140); + object_large.Location = new Point(((int)Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), 214); + PicBonus.Location = new Point(((int)Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), -20); + + //Reset time + time = 0; + + usingkeys = false; + + System.Threading.Thread.Sleep(100); // slight delay before game starts (in milliseconds) + + main(); // start the main game function + + //sig() //infobox sigs -COMMENT THIS OUT + } + + private void Dodge_KeyDown(object sender, KeyEventArgs e) + { + switch (e.KeyCode) + { + case Keys.Right: // detect right key press + usingkeys = true; // turn off mouse control + keyboardinput = 2; + break; + case Keys.Left: + usingkeys = true; + keyboardinput = 1; + break; + } + + } + + private void main() + { + clock.Start(); //the timer restart this sub every tick, making an endless loop between them. + + //score system + scorelabel.Text = score.ToString(); + score = (int)((speed / 10) + (time / 20) + bonusesfound); + + //Speed increase + speed = speed + (speed * (decimal)0.001); + + //increase time + time = time + (decimal)0.05; //loops every 0.05 seconds so time increases by 1 every second (have I done the maths correctly?) + + //Make objects fall + object_large.Location = new Point(object_large.Location.X, (int)(object_large.Location.Y + speed)); + object_mid.Location = new Point(object_mid.Location.X, (int)(object_mid.Location.Y + speed)); + object_mid2.Location = new Point(object_mid2.Location.X, (int)(object_mid2.Location.Y + speed)); + object_small.Location = new Point(object_small.Location.X, (int)(object_small.Location.Y + speed)); + object_small2.Location = new Point(object_small2.Location.X, (int)(object_small2.Location.Y + speed)); + + //mouse controls + if (!usingkeys) // tests if mouse control is enabled + { + player.Left = LocalMousePosition.X - (player.Width / 2) - 5; //sets the x location to that of the mouse + } + //keyboard controls + if (usingkeys) + { + if (keyboardinput == 1) + player.Location = new Point((int)(player.Location.X - (speed * 4)), player.Location.Y); + if (keyboardinput == 2) + player.Location = new Point((int)(player.Location.X + (speed * 4)), player.Location.Y); // move right + } + + //move object back to the top of the screen + if (object_small.Location.Y > 522) + object_small.Location = new Point((int)(Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), -20); //picks a random number between 0 and the window width and sets the x position to this value. uses -20 for y as it is above the top of window + if (object_small2.Location.Y > 522) + object_small2.Location = new Point((int)(Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), -20); + if (object_mid.Location.Y > 522) + object_mid.Location = new Point((int)(Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), -20); + if (object_mid2.Location.Y > 522) + object_mid2.Location = new Point((int)(Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), -20); + if (object_large.Location.Y > 522) + object_large.Location = new Point((int)(Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), -20); + + //Makes sure the player is on the screen (Anti-cheating) + if (player.Location.X > pgcontents.Width) + player.Location = new Point(385, player.Location.Y); + if (player.Location.X < 0) + player.Location = new Point(0, player.Location.Y); + + //Bonus + if (!PicBonus.Visible) + { + int ran = (int)Math.Ceiling(VBMath.Rnd() * 300); //random 1 in 500 chance + if (ran == 1) + PicBonus.Visible = true; + } + else + { + PicBonus.Location = new Point(PicBonus.Location.X, (int)(PicBonus.Location.Y + speed)); + if (PicBonus.Location.Y > 522) + PicBonus.Location = new Point((int)(Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), -20); + PicBonus.Visible = false; + } + + //check collisions + if (player.Bounds.IntersectsWith(object_mid.Bounds) || player.Bounds.IntersectsWith(object_mid2.Bounds) || player.Bounds.IntersectsWith(object_large.Bounds) || player.Bounds.IntersectsWith(object_small.Bounds) || player.Bounds.IntersectsWith(object_small2.Bounds)) + { + clock.Stop(); //breaks loop + System.Threading.Thread.Sleep(333); //delay for a third of a second + player.Visible = false; //hide game + DescriptionLabel.Text = "Sorry, you just lost the game, however, you earnt a total of " + score.ToString() + " code points. To earn more code points, press the begin button now. To exit, press the quit button"; // change the description to the die message + SaveSystem.CurrentSave.Codepoints += (ulong) score; + DescriptionLabel.Visible = true; //show non-game elements + BeginButton.Visible = true; + QuitButton.Visible = true; + scorelabel.Visible = false; + } + if (player.Bounds.IntersectsWith(PicBonus.Bounds)) + { + PicBonus.Visible = false; + bonusesfound = bonusesfound + 1; + PicBonus.Location = new Point((int)(Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), -20); + } + + } + private void clock_Tick(object sender, EventArgs e) + { + main(); //repeat the main function (endless loop) + } + + private void sig() + { + Infobox.Show("FLAG", "There is no foul on the play, the punt was blocked."); + } + + private void Dodge_MouseMove(object sender, MouseEventArgs e) + { + LocalMousePosition = e.Location; + } + + private void pgcontents_MouseMove(object sender, MouseEventArgs e) + { + LocalMousePosition = e.Location; + } + } +} diff --git a/ShiftOS.WinForms/Applications/Dodge.resx b/ShiftOS.WinForms/Applications/Dodge.resx new file mode 100644 index 0000000..a1ea8df --- /dev/null +++ b/ShiftOS.WinForms/Applications/Dodge.resx @@ -0,0 +1,208 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> + <data name="player.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value> + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + vQAADr0BR/uQrQAAANlJREFUSEvVjtsOwyAMQ/v/P90hnKW5ADFSq27nYUscY/c4H2aj4OjIQkM9sNF2 + Zqitwzi+o/BpkE3ETHawBZmbCxbDmtpkE+2MoYT7Ch+tM8OOdTMa/EaBjbYzQ2G1cbN5jTOFN2UE478k + nNuvAn2NWDtYoStuz+cths8vST9Bgb5AfF+g4KS4PZyzO8D4VxG7BUPeLigR65ypg3ncKG17BVn8qwIo + Qb+twK6zecgbBe0NkL1j1zAD2RPxMLRmkVGAU6cmLm4syn/n8YJGM2Xk5pGbQQ6W8/wAaLdSOxZqwToA + AAAASUVORK5CYII= +</value> + </data> + <data name="QuitButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value> + iVBORw0KGgoAAAANSUhEUgAAAMgAAAAyCAIAAACWMwO2AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + vQAADr0BR/uQrQAAAh5JREFUeF7tltt1g0AMBV2XC3I9qcbNuBgnzrk/0r4gh5tEeObvGrEgdiy4PAEM + XABcyDGAg0AssIBYYAGxwAJigQXEAguIBRYQCywgFlhALLCAWGABscACYoGFM4n1+LiqncjtroI+4bTr + x0M/t8wK7zf9/kIXHN3PmNnVi6GOlKoStnXEyK9w8iFi6dimu4os/gOFUENKBdk1Frra2MRiYtUVqxkK + 6S/f7m07E2xiddh8rfKoR6ViJK0G75EsVy5DLAfqUakUUZjNRvzUCcTahXpUqkTYo9VXbyyOO4pYDtSj + UiG2z6sXaWYFDRHLgXpUqsM+r9KOxnrEcqAeleqwV6zJyEIsB+pRqQ5hh1ZfWF8g1i+jHpXqgFj/HPWo + VIco1nqLolihHrEcqEelOkxE6TIREbEcqEelQkRTVu/CmYfx2GQlxNqBelQqRNRhYda0eLNYwYpUh1gJ + 9ahUiR1mhe1s9zMeHi40lQKxEupRqRZRiOE+pbKOOOuK7PFcTsSqLVYeWl+kvWoL+vOoqYvrNIfbVRAr + oR6V6pGGzYrhe27HQl0fECuhHpVqsk+u8Xa2861lZCZiJdSjUmn6fr1M6BwZj67BOgsLwkkb5+LkHuqj + HpXOS8+WU0+Mv0bPWOnUbP2ShyPQI1Y6PVEuxPKhR6z0JkgvXoVGvrV6N7HAD2KBBcQCC4gFFhALLCAW + WEAssCCxAI5HjgEcyPP5CT/xA4PFRMqaAAAAAElFTkSuQmCC +</value> + </data> + <data name="BeginButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value> + iVBORw0KGgoAAAANSUhEUgAAAMgAAAAyCAIAAACWMwO2AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + vQAADr0BR/uQrQAAAnVJREFUeF7t2c1t60AMRWHXpYJcj6txMykmkeFZDCkOxVF0DQs4Z/UCzY+e+CGb + 3IhU/RKdGrBIErBIErBIErBIErBIErBIErBIErBIErBIErBIErBIErBIErBIErBI0nVg/TyW9rKD7s+2 + ctvz3takJQe8Gh2yPH7aCpNZ7o7e/F+GV/en7Lzfd9Xeuf30xe26akVfv7h3IKTI0u82u+zD6H0KPIGl + qAorGlFxbzC4+q1r9uJJWAM3wFJnhuHs+F8pfgJ2kOX5BPPfoh1OfhpW+GLAUpfBWrO23AgOwfJat3f2 + vVbbFUVYy9L9e3sFsNTtwErtHIBlt+yoCivCuj9TO8BS91lYRsURVhOwzEp/FbDU5bByOtOwrKtjA63D + su9nbwOWugzWnoNZWHb9RnGtIqz3k36xWQssdXbYw8KPX9g7nObheU7Bsq/Y3QgsdUVY4eev7O222eXW + RHaWvXkO1ogQsNSVYb1yIyjs7SefwjJebHblLKwZbheovXP76Ysz03bDDsZthmCl7M8nMeHOMtmV07BC + RcBSl8NacxPvl/wLVro+0XMAltn0fgAsdbuwEg+zsJzRZMPZsMyj173AUvdJWHVZp8My+9Z7gaXuo7D8 + WcM9iZ7kUQqrf7o8HsAStwvL6jFTOADLHxdeqYHVb+3/RA0sSTksz8AO4Qis4MztvQbPebCiq9eApSj+ + 1nF+WMW928HNXHomLE/2HbAUlWccfP7i3okZR7nt/4MVvTOwJO3qGI1orWYjH9zw/opHe3R/VHKpe+tL + uboQLLpUwCJJwCJJwCJJwCJJwCJJwCJJwCJJwCJJwCJJwCJJDRbRyd1uf3/6zkvyT2tRAAAAAElFTkSu + QmCC +</value> + </data> + <data name="object_small2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value> + iVBORw0KGgoAAAANSUhEUgAAAEsAAAAUCAIAAABK9FefAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + vQAADr0BR/uQrQAAAC9JREFUWEftzwEBAAAIwjD6l9Ych6/BMuF6OeRzyOeQzyGfQz6HfA75HPLNDJsl + D4jAV3xQnIczAAAAAElFTkSuQmCC +</value> + </data> + <data name="object_mid2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value> + iVBORw0KGgoAAAANSUhEUgAAAH0AAAAUCAIAAAAvGaXgAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + vQAADr0BR/uQrQAAAEJJREFUWEft0DEBADAMwKD6N7091dA8IIEh87jlveG94b3hveG94b3hveG94b3h + veG94b3hveG94b3hveG9se9cm/mqBdmGSM9R1gAAAABJRU5ErkJggg== +</value> + </data> + <data name="object_large.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value> + iVBORw0KGgoAAAANSUhEUgAAAK8AAAAUCAIAAAB0/fqUAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + vQAADr0BR/uQrQAAAEFJREFUaEPt0gEJACAQALHvX/pFEA47bBk28FnYtYHYQGwgNhAbiA3EBmIDsYHY + QGwgNhAbiA3EBmIDsYG8DXDNHAnVW5/1c3lZAAAAAElFTkSuQmCC +</value> + </data> + <data name="object_small.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value> + iVBORw0KGgoAAAANSUhEUgAAAEsAAAAUCAIAAABK9FefAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + vQAADr0BR/uQrQAAAC9JREFUWEftzwEBAAAIwjD6l9Ych6/BMuF6OeRzyOeQzyGfQz6HfA75HPLNDJsl + D4jAV3xQnIczAAAAAElFTkSuQmCC +</value> + </data> + <data name="object_mid.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value> + iVBORw0KGgoAAAANSUhEUgAAAH0AAAAUCAIAAAAvGaXgAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + vQAADr0BR/uQrQAAAEJJREFUWEft0DEBADAMwKD6N7091dA8IIEh87jlveG94b3hveG94b3hveG94b3h + veG94b3hveG94b3hveG9se9cm/mqBdmGSM9R1gAAAABJRU5ErkJggg== +</value> + </data> + <data name="PicBonus.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value> + iVBORw0KGgoAAAANSUhEUgAAABAAAAALCAIAAAD5gJpuAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + wAAADsABataJCQAAAE1JREFUKFOtjUEOACEIA3k6P2dJSroVuWicA2lksHaDu3MmEcEJmrCQXqMWSjtV + T/PckKik+WdsIPX6vmHPcwMMpRYKTvkBJFWbcILZB/dcg5IyZV67AAAAAElFTkSuQmCC +</value> + </data> + <metadata name="clock.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> +</root>
\ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/IconManager.Designer.cs b/ShiftOS.WinForms/Applications/IconManager.Designer.cs index 25bcee4..0dd21cf 100644 --- a/ShiftOS.WinForms/Applications/IconManager.Designer.cs +++ b/ShiftOS.WinForms/Applications/IconManager.Designer.cs @@ -32,10 +32,10 @@ this.btnclose = new System.Windows.Forms.Button(); this.btnreset = new System.Windows.Forms.Button(); this.btnapply = new System.Windows.Forms.Button(); - this.flbody = new System.Windows.Forms.FlowLayoutPanel(); this.lbcurrentpage = new System.Windows.Forms.Label(); this.btnprev = new System.Windows.Forms.Button(); this.btnnext = new System.Windows.Forms.Button(); + this.flbody = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // @@ -91,16 +91,6 @@ this.btnapply.UseVisualStyleBackColor = true; this.btnapply.Click += new System.EventHandler(this.btnapply_Click); // - // flbody - // - this.flbody.Dock = System.Windows.Forms.DockStyle.Fill; - this.flbody.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; - this.flbody.Location = new System.Drawing.Point(0, 0); - this.flbody.Name = "flbody"; - this.flbody.Size = new System.Drawing.Size(393, 416); - this.flbody.TabIndex = 1; - this.flbody.WrapContents = false; - // // lbcurrentpage // this.lbcurrentpage.AutoSize = true; @@ -134,6 +124,16 @@ this.btnnext.UseVisualStyleBackColor = true; this.btnnext.Click += new System.EventHandler(this.btnnext_Click); // + // flbody + // + this.flbody.Dock = System.Windows.Forms.DockStyle.Fill; + this.flbody.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flbody.Location = new System.Drawing.Point(0, 0); + this.flbody.Name = "flbody"; + this.flbody.Size = new System.Drawing.Size(393, 416); + this.flbody.TabIndex = 1; + this.flbody.WrapContents = false; + // // IconManager // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/ShiftOS.WinForms/Applications/IconManager.cs b/ShiftOS.WinForms/Applications/IconManager.cs index 1f3166f..1979ce6 100644 --- a/ShiftOS.WinForms/Applications/IconManager.cs +++ b/ShiftOS.WinForms/Applications/IconManager.cs @@ -14,17 +14,27 @@ using Newtonsoft.Json; namespace ShiftOS.WinForms.Applications { + [FileHandler("Icon Pack", ".icons", "fileiconicons")] [RequiresUpgrade("icon_manager")] [Launcher("{TITLE_ICONMANAGER}", true, "al_icon_manager", "{AL_CUSTOMIZATION}")] [DefaultTitle("{TITLE_ICONMANAGER}")] [DefaultIcon("iconIconManager")] - public partial class IconManager : UserControl, IShiftOSWindow + public partial class IconManager : UserControl, IShiftOSWindow, IFileHandler { public IconManager() { InitializeComponent(); } + public void OpenFile(string file) + { + var contents = Objects.ShiftFS.Utils.ReadAllText(file); + var dict = JsonConvert.DeserializeObject<Dictionary<string, byte[]>>(contents); + AppearanceManager.SetupWindow(this); + Icons = dict; + SetupUI(); + } + public void OnLoad() { LoadIconsFromEngine(); diff --git a/ShiftOS.WinForms/Applications/Installer.cs b/ShiftOS.WinForms/Applications/Installer.cs index 284ac2c..ec93735 100644 --- a/ShiftOS.WinForms/Applications/Installer.cs +++ b/ShiftOS.WinForms/Applications/Installer.cs @@ -19,7 +19,8 @@ namespace ShiftOS.WinForms.Applications [MultiplayerOnly] [DefaultTitle("{TITLE_INSTALLER}")] [Launcher("{TITLE_INSTALLER}", true, "al_installer", "{AL_UTILITIES}")] - public partial class Installer : UserControl, IShiftOSWindow + [FileHandler("Name Pack", ".names", "fileiconnames")] + public partial class Installer : UserControl, IShiftOSWindow, IFileHandler { public Installer() { @@ -27,6 +28,13 @@ namespace ShiftOS.WinForms.Applications lbtitle.Text = "Select file"; } + public void OpenFile(string path) + { + var stpInstall = new StpInstallation(path); + AppearanceManager.SetupWindow(this); + InitiateInstall(stpInstall); + } + public void InitiateInstall(Installation install) { pnlselectfile.Hide(); diff --git a/ShiftOS.WinForms/Applications/NameChanger.cs b/ShiftOS.WinForms/Applications/NameChanger.cs index 4695c8a..67c64fd 100644 --- a/ShiftOS.WinForms/Applications/NameChanger.cs +++ b/ShiftOS.WinForms/Applications/NameChanger.cs @@ -37,20 +37,27 @@ using ShiftOS.Objects.ShiftFS; using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { - + [FileHandler("Name Pack", ".nme", "fileiconnames")] [MultiplayerOnly] [Launcher("{TITLE_NAMECHANGER}", false, null, "{AL_CUSTOMIZATION}")] [AppscapeEntry("name_changer", "{TITLE_NAMECHANGER}", "{DESC_NAMECHANGER}", 342, 500, "skinning;file_skimmer;wm_titlebar", "{AL_CUSTOMIZATION}")] [WinOpen("{WO_NAMECHANGER}")] [DefaultTitle("{TITLE_NAMECHANGER}")] [DefaultIcon("iconNameChanger")] - public partial class NameChanger : UserControl, IShiftOSWindow + public partial class NameChanger : UserControl, IShiftOSWindow, IFileHandler { public NameChanger() { InitializeComponent(); } + public void OpenFile(string file) + { + AppearanceManager.SetupWindow(this); + names = JsonConvert.DeserializeObject<Dictionary<string, string>>(ShiftOS.Objects.ShiftFS.Utils.ReadAllText(file)); + SetupUI(); + } + private Dictionary<string, string> names = new Dictionary<string, string>(); public void OnLoad() diff --git a/ShiftOS.WinForms/Applications/Skin Loader.cs b/ShiftOS.WinForms/Applications/Skin Loader.cs index b70d3ea..de30360 100644 --- a/ShiftOS.WinForms/Applications/Skin Loader.cs +++ b/ShiftOS.WinForms/Applications/Skin Loader.cs @@ -37,12 +37,13 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { + [FileHandler("ShiftOS Skin", ".skn", "fileiconskin")] [Launcher("{TITLE_SKINLOADER}", true, "al_skin_loader", "{AL_CUSTOMIZATION}")] [RequiresUpgrade("skinning")] [WinOpen("skin_loader")] [DefaultTitle("{TITLE_SKINLOADER}")] [DefaultIcon("iconSkinLoader")] - public partial class Skin_Loader : UserControl, IShiftOSWindow + public partial class Skin_Loader : UserControl, IShiftOSWindow, IFileHandler { public Skin_Loader() { @@ -54,6 +55,13 @@ namespace ShiftOS.WinForms.Applications } + public void OpenFile(string file) + { + AppearanceManager.SetupWindow(this); + LoadedSkin = JsonConvert.DeserializeObject<Skin>(Objects.ShiftFS.Utils.ReadAllText(file)); + SetupUI(); + } + public void SetupControls(Control ctrl) { ctrl.Tag = "keepbg keepfg keepfont"; diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 51ad42b..794edf7 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -47,12 +47,51 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { + [FileHandler("Shell script", ".trm", "fileicontrm")] [Launcher("{TITLE_TERMINAL}", false, null, "{AL_UTILITIES}")] [WinOpen("{WO_TERMINAL}")] [DefaultTitle("{TITLE_TERMINAL}")] [DefaultIcon("iconTerminal")] - public partial class Terminal : UserControl, IShiftOSWindow + public partial class Terminal : UserControl, IShiftOSWindow, IFileHandler { + public void OpenFile(string file) + { + int lastline = 0; + string lastlinetext = ""; + + try + { + var lines = new List<string>(ShiftOS.Objects.ShiftFS.Utils.ReadAllText(file).Split(new[] { Environment.NewLine.ToString() }, StringSplitOptions.RemoveEmptyEntries)); + AppearanceManager.SetupWindow(this); + var parser = CommandParser.GenerateSample(); + foreach (var line in lines) + { + lastline = lines.IndexOf(line) + 1; + lastlinetext = line; + var command = parser.ParseCommand(line); + TerminalBackend.InvokeCommand(command.Key, command.Value); + } + } + catch(Exception ex) + { + ConsoleEx.ForegroundColor = ConsoleColor.Red; + ConsoleEx.Bold = true; + Console.WriteLine("Script exception"); + ConsoleEx.ForegroundColor = ConsoleColor.Yellow; + ConsoleEx.Bold = false; + ConsoleEx.Italic = true; +#if DEBUG + Console.WriteLine(ex.Message); +#endif + Console.WriteLine(ex.StackTrace); + if(lastline > 0) + { + Console.WriteLine(" at " + lastlinetext + " (line " + lastline + ") in " + file); + } + } + TerminalBackend.PrintPrompt(); + } + public static Stack<string> ConsoleStack = new Stack<string>(); public static System.Windows.Forms.Timer ti = new System.Windows.Forms.Timer(); diff --git a/ShiftOS.WinForms/Applications/TextPad.cs b/ShiftOS.WinForms/Applications/TextPad.cs index 403b4ef..0411e83 100644 --- a/ShiftOS.WinForms/Applications/TextPad.cs +++ b/ShiftOS.WinForms/Applications/TextPad.cs @@ -36,18 +36,25 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { + [FileHandler("Text File", ".txt", "fileicontext")] [Launcher("{TITLE_TEXTPAD}", true, "al_textpad", "{AL_ACCESSORIES}")] [RequiresUpgrade("textpad")] [WinOpen("{WO_TEXTPAD}")] [DefaultTitle("{TITLE_TEXTPAD}")] [DefaultIcon("iconTextPad")] - public partial class TextPad : UserControl, IShiftOSWindow + public partial class TextPad : UserControl, IShiftOSWindow, IFileHandler { public TextPad() { InitializeComponent(); } + public void OpenFile(string file) + { + AppearanceManager.SetupWindow(this); + LoadFile(file); + } + private void newToolStripMenuItem_Click(object sender, EventArgs e) { txtcontents.Text = ""; diff --git a/ShiftOS.WinForms/Applications/TriWrite.cs b/ShiftOS.WinForms/Applications/TriWrite.cs index f565328..293d30c 100644 --- a/ShiftOS.WinForms/Applications/TriWrite.cs +++ b/ShiftOS.WinForms/Applications/TriWrite.cs @@ -12,11 +12,12 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { + [FileHandler("TriWrite Document", ".rtf", "fileicontext")] [WinOpen("triwrite")] [AppscapeEntry("triwrite", "TriWrite", "Part of the trilogy of office applications for enhancement of your system. TriWrite is easliy the best text editor out there for ShiftOS.", 1024, 750, "file_skimmer;textpad", "Office")] [DefaultTitle("TriWrite")] [Launcher("TriWrite", false, null, "Office")] - public partial class TriWrite : UserControl, IShiftOSWindow + public partial class TriWrite : UserControl, IShiftOSWindow, IFileHandler { public TriWrite() @@ -24,6 +25,12 @@ namespace ShiftOS.WinForms.Applications InitializeComponent(); //From the library of babel: "FIRST COMMIT FROM A MAC WOOOO TURIANS ARE COOL" } + public void OpenFile(string file) + { + AppearanceManager.SetupWindow(this); + LoadFile(file); + } + private void newToolStripMenuItem_Click(object sender, EventArgs e) { txtcontents.Text = ""; diff --git a/ShiftOS.WinForms/Applications/VirusScanner.Designer.cs b/ShiftOS.WinForms/Applications/VirusScanner.Designer.cs new file mode 100644 index 0000000..e6cc439 --- /dev/null +++ b/ShiftOS.WinForms/Applications/VirusScanner.Designer.cs @@ -0,0 +1,302 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class VirusScanner + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VirusScanner)); + this.pnlsidebar = new System.Windows.Forms.FlowLayoutPanel(); + this.btnscanfs = new System.Windows.Forms.Button(); + this.btnscanmem = new System.Windows.Forms.Button(); + this.btnscanfile = new System.Windows.Forms.Button(); + this.btnexit = new System.Windows.Forms.Button(); + this.pnlbody = new System.Windows.Forms.Panel(); + this.pnlsummary = new System.Windows.Forms.Panel(); + this.flviruses = new System.Windows.Forms.FlowLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.pnlscanner = new System.Windows.Forms.Panel(); + this.lbscanstatus = new System.Windows.Forms.Label(); + this.pgscannerprogress = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); + this.label2 = new System.Windows.Forms.Label(); + this.pnlintro = new System.Windows.Forms.Panel(); + this.lbintrotext = new System.Windows.Forms.Label(); + this.lbintrotitle = new System.Windows.Forms.Label(); + this.lbstatus = new System.Windows.Forms.Label(); + this.pnlsidebar.SuspendLayout(); + this.pnlbody.SuspendLayout(); + this.pnlsummary.SuspendLayout(); + this.pnlscanner.SuspendLayout(); + this.pnlintro.SuspendLayout(); + this.SuspendLayout(); + // + // pnlsidebar + // + this.pnlsidebar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.pnlsidebar.Controls.Add(this.btnscanfs); + this.pnlsidebar.Controls.Add(this.btnscanmem); + this.pnlsidebar.Controls.Add(this.btnscanfile); + this.pnlsidebar.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.pnlsidebar.Location = new System.Drawing.Point(4, 4); + this.pnlsidebar.Name = "pnlsidebar"; + this.pnlsidebar.Size = new System.Drawing.Size(138, 399); + this.pnlsidebar.TabIndex = 0; + // + // btnscanfs + // + this.btnscanfs.Location = new System.Drawing.Point(3, 3); + this.btnscanfs.Name = "btnscanfs"; + this.btnscanfs.Size = new System.Drawing.Size(135, 23); + this.btnscanfs.TabIndex = 0; + this.btnscanfs.Text = "Scan filesystem"; + this.btnscanfs.UseVisualStyleBackColor = true; + this.btnscanfs.Click += new System.EventHandler(this.btnscanfs_Click); + // + // btnscanmem + // + this.btnscanmem.Location = new System.Drawing.Point(3, 32); + this.btnscanmem.Name = "btnscanmem"; + this.btnscanmem.Size = new System.Drawing.Size(135, 23); + this.btnscanmem.TabIndex = 1; + this.btnscanmem.Text = "Scan memory"; + this.btnscanmem.UseVisualStyleBackColor = true; + this.btnscanmem.Click += new System.EventHandler(this.btnscanmem_Click); + // + // btnscanfile + // + this.btnscanfile.Location = new System.Drawing.Point(3, 61); + this.btnscanfile.Name = "btnscanfile"; + this.btnscanfile.Size = new System.Drawing.Size(135, 23); + this.btnscanfile.TabIndex = 2; + this.btnscanfile.Text = "Scan file"; + this.btnscanfile.UseVisualStyleBackColor = true; + this.btnscanfile.Click += new System.EventHandler(this.btnscanfile_Click); + // + // btnexit + // + this.btnexit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnexit.Location = new System.Drawing.Point(7, 409); + this.btnexit.Name = "btnexit"; + this.btnexit.Size = new System.Drawing.Size(135, 23); + this.btnexit.TabIndex = 1; + this.btnexit.Text = "Exit"; + this.btnexit.UseVisualStyleBackColor = true; + this.btnexit.Click += new System.EventHandler(this.btnexit_Click); + // + // pnlbody + // + this.pnlbody.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlbody.Controls.Add(this.pnlsummary); + this.pnlbody.Controls.Add(this.pnlscanner); + this.pnlbody.Controls.Add(this.pnlintro); + this.pnlbody.Location = new System.Drawing.Point(149, 4); + this.pnlbody.Name = "pnlbody"; + this.pnlbody.Size = new System.Drawing.Size(498, 399); + this.pnlbody.TabIndex = 2; + // + // pnlsummary + // + this.pnlsummary.Controls.Add(this.flviruses); + this.pnlsummary.Controls.Add(this.label1); + this.pnlsummary.Controls.Add(this.label3); + this.pnlsummary.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlsummary.Location = new System.Drawing.Point(0, 0); + this.pnlsummary.Name = "pnlsummary"; + this.pnlsummary.Size = new System.Drawing.Size(498, 399); + this.pnlsummary.TabIndex = 3; + // + // flviruses + // + this.flviruses.AutoScroll = true; + this.flviruses.Dock = System.Windows.Forms.DockStyle.Fill; + this.flviruses.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flviruses.Location = new System.Drawing.Point(0, 66); + this.flviruses.Margin = new System.Windows.Forms.Padding(0); + this.flviruses.Name = "flviruses"; + this.flviruses.Padding = new System.Windows.Forms.Padding(10); + this.flviruses.Size = new System.Drawing.Size(498, 333); + this.flviruses.TabIndex = 3; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 33); + this.label1.Name = "label1"; + this.label1.Padding = new System.Windows.Forms.Padding(10); + this.label1.Size = new System.Drawing.Size(184, 33); + this.label1.TabIndex = 2; + this.label1.Text = "Below is a list of all viruses found."; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Dock = System.Windows.Forms.DockStyle.Top; + this.label3.Location = new System.Drawing.Point(0, 0); + this.label3.Name = "label3"; + this.label3.Padding = new System.Windows.Forms.Padding(10); + this.label3.Size = new System.Drawing.Size(101, 33); + this.label3.TabIndex = 0; + this.label3.Tag = "header3"; + this.label3.Text = "Scan complete."; + // + // pnlscanner + // + this.pnlscanner.Controls.Add(this.lbscanstatus); + this.pnlscanner.Controls.Add(this.pgscannerprogress); + this.pnlscanner.Controls.Add(this.label2); + this.pnlscanner.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlscanner.Location = new System.Drawing.Point(0, 0); + this.pnlscanner.Name = "pnlscanner"; + this.pnlscanner.Size = new System.Drawing.Size(498, 399); + this.pnlscanner.TabIndex = 2; + // + // lbscanstatus + // + this.lbscanstatus.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbscanstatus.Location = new System.Drawing.Point(0, 33); + this.lbscanstatus.Name = "lbscanstatus"; + this.lbscanstatus.Padding = new System.Windows.Forms.Padding(10); + this.lbscanstatus.Size = new System.Drawing.Size(498, 343); + this.lbscanstatus.TabIndex = 2; + this.lbscanstatus.Text = "label1"; + // + // pgscannerprogress + // + this.pgscannerprogress.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pgscannerprogress.Location = new System.Drawing.Point(0, 376); + this.pgscannerprogress.Maximum = 100; + this.pgscannerprogress.Name = "pgscannerprogress"; + this.pgscannerprogress.Padding = new System.Windows.Forms.Padding(10); + this.pgscannerprogress.Size = new System.Drawing.Size(498, 23); + this.pgscannerprogress.TabIndex = 1; + this.pgscannerprogress.Text = "shiftedProgressBar1"; + this.pgscannerprogress.Value = 0; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Dock = System.Windows.Forms.DockStyle.Top; + this.label2.Location = new System.Drawing.Point(0, 0); + this.label2.Name = "label2"; + this.label2.Padding = new System.Windows.Forms.Padding(10); + this.label2.Size = new System.Drawing.Size(81, 33); + this.label2.TabIndex = 0; + this.label2.Tag = "header3"; + this.label2.Text = "Scanning..."; + // + // pnlintro + // + this.pnlintro.Controls.Add(this.lbintrotext); + this.pnlintro.Controls.Add(this.lbintrotitle); + this.pnlintro.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlintro.Location = new System.Drawing.Point(0, 0); + this.pnlintro.Name = "pnlintro"; + this.pnlintro.Size = new System.Drawing.Size(498, 399); + this.pnlintro.TabIndex = 0; + // + // lbintrotext + // + this.lbintrotext.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbintrotext.Location = new System.Drawing.Point(0, 33); + this.lbintrotext.Name = "lbintrotext"; + this.lbintrotext.Padding = new System.Windows.Forms.Padding(10); + this.lbintrotext.Size = new System.Drawing.Size(498, 366); + this.lbintrotext.TabIndex = 1; + this.lbintrotext.Tag = ""; + this.lbintrotext.Text = resources.GetString("lbintrotext.Text"); + // + // lbintrotitle + // + this.lbintrotitle.AutoSize = true; + this.lbintrotitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbintrotitle.Location = new System.Drawing.Point(0, 0); + this.lbintrotitle.Name = "lbintrotitle"; + this.lbintrotitle.Padding = new System.Windows.Forms.Padding(10); + this.lbintrotitle.Size = new System.Drawing.Size(93, 33); + this.lbintrotitle.TabIndex = 0; + this.lbintrotitle.Tag = "header3"; + this.lbintrotitle.Text = "Virus Scanner"; + // + // lbstatus + // + this.lbstatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lbstatus.AutoSize = true; + this.lbstatus.Location = new System.Drawing.Point(152, 410); + this.lbstatus.Name = "lbstatus"; + this.lbstatus.Size = new System.Drawing.Size(48, 13); + this.lbstatus.TabIndex = 3; + this.lbstatus.Text = "Grade: 1"; + // + // VirusScanner + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbstatus); + this.Controls.Add(this.pnlbody); + this.Controls.Add(this.btnexit); + this.Controls.Add(this.pnlsidebar); + this.Name = "VirusScanner"; + this.Size = new System.Drawing.Size(650, 435); + this.pnlsidebar.ResumeLayout(false); + this.pnlbody.ResumeLayout(false); + this.pnlsummary.ResumeLayout(false); + this.pnlsummary.PerformLayout(); + this.pnlscanner.ResumeLayout(false); + this.pnlscanner.PerformLayout(); + this.pnlintro.ResumeLayout(false); + this.pnlintro.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.FlowLayoutPanel pnlsidebar; + private System.Windows.Forms.Button btnscanfs; + private System.Windows.Forms.Button btnscanmem; + private System.Windows.Forms.Button btnscanfile; + private System.Windows.Forms.Button btnexit; + private System.Windows.Forms.Panel pnlbody; + private System.Windows.Forms.Panel pnlintro; + private System.Windows.Forms.Label lbintrotext; + private System.Windows.Forms.Label lbintrotitle; + private System.Windows.Forms.Label lbstatus; + private System.Windows.Forms.Panel pnlscanner; + private System.Windows.Forms.Label lbscanstatus; + private Controls.ShiftedProgressBar pgscannerprogress; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Panel pnlsummary; + private System.Windows.Forms.FlowLayoutPanel flviruses; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label3; + } +} diff --git a/ShiftOS.WinForms/Applications/VirusScanner.cs b/ShiftOS.WinForms/Applications/VirusScanner.cs new file mode 100644 index 0000000..a132996 --- /dev/null +++ b/ShiftOS.WinForms/Applications/VirusScanner.cs @@ -0,0 +1,321 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using System.Threading; +using Newtonsoft.Json; + +namespace ShiftOS.WinForms.Applications +{ + [RequiresUpgrade("virus_scanner")] + [WinOpen("virus_scanner")] + [Launcher("Virus Scanner", false, null, "Utilities")] + [DefaultTitle("Virus Scanner")] + public partial class VirusScanner : UserControl, IShiftOSWindow + { + private int grade = 1; + + public VirusScanner() + { + InitializeComponent(); + } + + public void OnLoad() + { + pnlintro.BringToFront(); + } + + private List<Objects.ViralInfection> FoundViruses = new List<Objects.ViralInfection>(); + + public void OnSkinLoad() + { + } + + public bool OnUnload() + { + return true; + } + + public void OnUpgrade() + { + grade = 1; + if (Shiftorium.UpgradeInstalled("virus_scanner_grade_2")) + grade++; + if (Shiftorium.UpgradeInstalled("virus_scanner_grade_3")) + grade++; + if (Shiftorium.UpgradeInstalled("virus_scanner_grade_4")) + grade++; + SetupStatus(); + } + + public void SetupStatus() + { + lbstatus.Text = $"Grade: {grade}"; + } + + private string _scanMessage = "We are currently scanning your system. Please wait."; + private int _threatsFound = 0; + + public int ThreatsFound + { + get + { + return _threatsFound; + } + set + { + _threatsFound = value; + lbscanstatus.Text = $@"{_scanMessage} + +Threats found: {_threatsFound}"; + } + } + + public string ScannerMessage + { + get + { + return _scanMessage; + } + set + { + _scanMessage = value; + lbscanstatus.Text = $@"{_scanMessage} + +Threats found: {_threatsFound}"; + + } + } + + private void btnscanmem_Click(object sender, EventArgs e) + { + ScannerMessage = "We are currently scanning the system memory. Please wait."; + ThreatsFound = 0; + ShowScannerUI(); + ScanMemory(); + } + + public void ScanMemory() + { + pgscannerprogress.Maximum = SaveSystem.CurrentSave.ViralInfections.Count; + var t = new Thread(() => + { + foreach(var virus in SaveSystem.CurrentSave.ViralInfections) + { + Thread.Sleep(1000); + Desktop.InvokeOnWorkerThread(() => + { + pgscannerprogress.Value++; + ThreatsFound++; + if(virus.ThreatLevel <= grade) + { + FoundViruses.Add(virus); + } + }); + } + Desktop.InvokeOnWorkerThread(() => + { + SetupSummary(); + }); + }); + t.IsBackground = true; + t.Start(); + } + + public void SetupSummary() + { + flviruses.Controls.Clear(); + if(FoundViruses.Count == 0) + { + var noViruses = new Label(); + noViruses.Text = "No threats found."; + noViruses.Tag = "header3"; + Tools.ControlManager.SetupControls(noViruses); + noViruses.AutoSize = true; + flviruses.Controls.Add(noViruses); + noViruses.Show(); + } + foreach(var virus in FoundViruses) + { + var headerLabel = new Label(); + headerLabel.Text = $"virus.th{virus.ThreatLevel}.{virus.ID}"; + flviruses.Controls.Add(headerLabel); + headerLabel.Tag = "header3"; + headerLabel.MaximumSize = new Size(((flviruses.Width) - flviruses.Padding.Right) - flviruses.Padding.Left, 0); + headerLabel.AutoSize = true; + Tools.ControlManager.SetupControl(headerLabel); + headerLabel.Show(); + + var descLabel = new Label(); + descLabel.MaximumSize = new Size(((flviruses.Width) - flviruses.Padding.Right) - flviruses.Padding.Left, 0); + descLabel.AutoSize = true; + var virusInfo = GetVirusInformation(virus.ID); + descLabel.Text = $@"Real name: {virusInfo.Name} +Description: {virusInfo.Description}"; + if(virus is FileViralInfection) + { + descLabel.Text += Environment.NewLine + "File path: " + (virus as FileViralInfection).FilePath; + } + flviruses.Controls.Add(descLabel); + descLabel.Show(); + + var cleanButton = new Button(); + cleanButton.Text = "Disinfect"; + cleanButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; + cleanButton.AutoSize = true; + cleanButton.Click += (o, a) => + { + Disinfect(virus); + }; + flviruses.Controls.Add(cleanButton); + Tools.ControlManager.SetupControl(cleanButton); + cleanButton.Show(); + } + pnlsummary.BringToFront(); + } + + public void Disinfect(Objects.ViralInfection virus) + { + if (FoundViruses.Contains(virus)) + { + FoundViruses.Remove(virus); + VirusManager.Disinfect(virus.ID); + if(virus is FileViralInfection) + { + var fVirus = virus as FileViralInfection; + if (Objects.ShiftFS.Utils.FileExists(fVirus.FilePath)) + { + var headerText = Objects.ShiftFS.Utils.GetHeaderText(fVirus.FilePath); + try + { + var list = JsonConvert.DeserializeObject<List<FileViralInfection>>(headerText); + var hVirus = list.FirstOrDefault(x => x.ID == virus.ID && x.ThreatLevel == virus.ThreatLevel); + list.Remove(hVirus); + Objects.ShiftFS.Utils.SetHeaderText(fVirus.FilePath, JsonConvert.SerializeObject(list)); + } + catch + { + + } + } + } + } + SetupSummary(); + } + + public VirusAttribute GetVirusInformation(string id) + { + foreach(var type in ReflectMan.Types.Where(x => x.GetInterfaces().Contains(typeof(IVirus)) && Shiftorium.UpgradeAttributesUnlocked(x))) + { + var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is VirusAttribute) as VirusAttribute; + if(attrib != null) + { + if (attrib.ID == id) + return attrib; + } + } + return null; + } + + public void ShowScannerUI() + { + pgscannerprogress.Value = 0; + pnlscanner.BringToFront(); + } + + private int filesScanned = 0; + + public void ScanFile(string path) + { + Thread.Sleep(25); + var headerinfo = Objects.ShiftFS.Utils.GetHeaderText(path); + filesScanned++; + Desktop.InvokeOnWorkerThread(() => + { + ScannerMessage = "Scanning file: " + path + Environment.NewLine + "Files scanned: " + filesScanned.ToString(); + }); + + + try + { + + var list = JsonConvert.DeserializeObject<List<Objects.ViralInfection>>(headerinfo).Where(x => x.ThreatLevel <= grade); + foreach (var virus in list) + { + Thread.Sleep(50); + Desktop.InvokeOnWorkerThread(() => + { + ThreatsFound++; + }); + FoundViruses.Add(new FileViralInfection + { + ID = virus.ID, + ThreatLevel = virus.ThreatLevel, + FilePath = path + }); + + } + + } + catch { } + + } + + public void ScanDirectory(string dir) + { + if (Objects.ShiftFS.Utils.DirectoryExists(dir)) + { + foreach (var file in Objects.ShiftFS.Utils.GetFiles(dir)) + ScanFile(file); + foreach (var subdir in Objects.ShiftFS.Utils.GetDirectories(dir)) + ScanDirectory(subdir); + } + } + + private void btnscanfile_Click(object sender, EventArgs e) + { + FileSkimmerBackend.GetFile(new[] { "" }, FileOpenerStyle.Open, (path) => + { + ScanFile(path); + SetupSummary(); + }); + } + + private void btnscanfs_Click(object sender, EventArgs e) + { + filesScanned = 0; + ShowScannerUI(); + pgscannerprogress.Hide(); + ThreatsFound = 0; + var t = new Thread(() => + { + foreach(var mount in Objects.ShiftFS.Utils.Mounts) + { + var index = Objects.ShiftFS.Utils.Mounts.IndexOf(mount); + ScanDirectory(index.ToString() + ":"); + } + Desktop.InvokeOnWorkerThread(() => + { + SetupSummary(); + }); + }); + t.Start(); + } + + private void btnexit_Click(object sender, EventArgs e) + { + AppearanceManager.Close(this); + } + } + + public class FileViralInfection : Objects.ViralInfection + { + public string FilePath { get; set; } + } +} diff --git a/ShiftOS.WinForms/Applications/VirusScanner.resx b/ShiftOS.WinForms/Applications/VirusScanner.resx new file mode 100644 index 0000000..814a86d --- /dev/null +++ b/ShiftOS.WinForms/Applications/VirusScanner.resx @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <data name="lbintrotext.Text" xml:space="preserve"> + <value>Virus Scanner is a small utility application that allows you to scan files and the system RAM for viral infections. + +To start a scan, click one of the buttons to the left. Wait for the scan to complete, and then we'll list any threats we find. If we find a threat, you can click "Disinfect" to remove the virus from your system.</value> + </data> +</root>
\ No newline at end of file diff --git a/ShiftOS.WinForms/DevXSecondConfrontationStory.cs b/ShiftOS.WinForms/DevXSecondConfrontationStory.cs new file mode 100644 index 0000000..e8093a2 --- /dev/null +++ b/ShiftOS.WinForms/DevXSecondConfrontationStory.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using ShiftOS.Engine; +using static ShiftOS.WinForms.Stories.LegionStory; + +namespace ShiftOS.WinForms +{ + public static class DevXSecondConfrontationStory + { +#if BETA_4 + [RequiresUpgrade("appscape_troubles_end")] + [Mission("sentiences_like_gods", "Sentiences Like Gods", "You're just a script-kiddie with that puny brute app. Let's do some true hacking.", 850l, "maureen_fenn")] + public static void SentiencesLikeGods() + { + Story.Context.AutoComplete = false; + Applications.Chat chat = null; + Desktop.InvokeOnWorkerThread(() => + { + chat = OpenChat(); + }); + while (chat == null) + Thread.Sleep(10); + CurrentChat = chat; + chat.ChatID = "devx@system"; + chat.ShowChat(); + SendChatMessage("maureen_fenn", "Hey, you remember when I told you to come see me if you wanted to become a real hacker?"); + SendChatMessage("maureen_fenn", "Well, it's now time you learn about port scanners, firewalls, and malware injection."); + SendChatMessage("maureen_fenn", "You know, not everything involves password cracking and stealing from wide-open FTP servers."); + SendChatMessage("maureen_fenn", "That's baby talk.") ; + SendChatMessage("maureen_fenn", "Have you ever felt the rush of breaching the root account of a Codepoint bank and going on a 60-second long withdrawl-spree to see how much Codepoints you can get from as many users as possible?"); + SendChatMessage("maureen_fenn", "Or maybe you felt like droppin' a little script on your buddy's Shiftnet website that makes it so everytime someone buys something, half the cash goes to you?"); + SendChatMessage("maureen_fenn", "Or maybe you want to spy on someone, see what they're doing, without them knowing?"); + SendChatMessage("maureen_fenn", "Whatever the case may be, brute is not going to help with that."); + SendChatMessage("maureen_fenn", "What you need is my much more advanced and sophisticated toolset, consisting of a port scanner, network monitor, IP spoofer, and yes, an unreasonably convoluted user-interface."); + SendChatMessage("maureen_fenn", "Also, you may want to get yourself a better window manager if you're still on the tiling WM. The WM Free Placement upgrade should do the trick."); + SendChatMessage("maureen_fenn", "If you want to download my toolset, head to this underground Shiftnet URL: downunder/maureen_fenn/hacker_suite"); + SendChatMessage("maureen_fenn", "Actually, you'll need it for our DevX exposition quest, so go get it now."); + + Action onGotWMFreePlacement = () => + { + Story.PushObjective("Sentiences Like Gods: Go down under.", "Head to the Shiftnet URL that Maureen sent you to get the advanced hacker's tool suite.", () => + { + return Shiftorium.UpgradeInstalled("mf_hackertools"); + }, + () => + { + SendChatMessage("maureen_fenn", "Alright. When you're ready for a crash course, let me know."); + Story.Context.MarkComplete(); + }); + }; + if (Shiftorium.UpgradeInstalled("wm_free_placement")) + { + onGotWMFreePlacement.Invoke(); + } + else + { + SendChatMessage("maureen_fenn", "First, let's get you a better window manager."); + Story.PushObjective("Sentiences Like Gods: A new window manager", "An application is only as good as its user interface allows it to be. That's the same for an operating system. Eventually, you'll need to be able to run more than just 4 programs at once, and you'll need a window manager that can place program windows of any size anywhere on screen. There are Shiftorium Upgrades for that. Let's get some.", () => { return Shiftorium.UpgradeInstalled("wm_free_placement") && Shiftorium.UpgradeInstalled("wm_unlimited_windows"); }, onGotWMFreePlacement); + + } + + } +#endif + + [RequiresUpgrade("appscape_troubles_end")] + [Mission("devx_first_confrontation", "Progress Report", "DevX wants to see how much you've upgraded ShiftOS. He also has something to tell you.", 0l, "devx")] + public static void DevXProgressReport() + { + Applications.Chat chat = null; + Desktop.InvokeOnWorkerThread(() => + { + chat = OpenChat(); + }); + while (chat == null) + Thread.Sleep(10); + CurrentChat = chat; + chat.ChatID = "devx@system"; + chat.ShowChat(); + SendChatMessage("devx", "Greetings, " + SaveSystem.CurrentUser.Username); + SendChatMessage("devx", "I guess it is time to assess your system."); + SendChatMessage("devx", "After all, you've gotten " + SaveSystem.CurrentSave.CountUpgrades() + " Shiftorium Upgrades since I've last contacted you."); + SendChatMessage("devx", "And you have a Codepoint balance of " + SaveSystem.CurrentSave.Codepoints + "."); + SendChatMessage("devx", "And...oh wait... what!? You found the... How did you find the Shiftnet!?"); + SendChatMessage("devx", "Naughty, naughty user. You're not supposed to be on there."); + SendChatMessage("devx", "Whatever. I've got a task for you."); + SendChatMessage("devx", "Your logs show me you're in contact with Maureen Fenn."); + SendChatMessage("devx", "I have a document to send her. You're my messanger."); + SendChatMessage("devx", "Though, like any good messanger, I urge you not to open it."); + SendChatMessage("devx", "<sent a file: unknown>"); + SendChatMessage("devx", "When you get it, just send it to her. Do not delete it."); + bool fileWritten = false; + Desktop.InvokeOnWorkerThread(() => + { + FileSkimmerBackend.GetFile(new[] { ".rtf" }, FileOpenerStyle.Save, (loc) => + { + var bytes = Convert.FromBase64String(Properties.Resources.DevXMaureenLetter); + Objects.ShiftFS.Utils.WriteAllBytes(loc, bytes); + fileWritten = true; + }); + }); + while (fileWritten == false) + Thread.Sleep(10); + } + } +}
\ No newline at end of file diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index 9dcd2fd..d0a9dbc 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -419,6 +419,15 @@ namespace ShiftOS.WinForms.Properties { } /// <summary> + /// Looks up a localized string similar to e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcZGVmbGFuZzEwMzN7XGZvbnR0Ymx7XGYwXGZuaWxcZmNoYXJzZXQwIFRhaG9tYTt9fQ0Ke1xjb2xvcnRibCA7XHJlZDIyMVxncmVlbjIyMVxibHVlMjIxO30NClx2aWV3a2luZDRcdWMxXHBhcmRcY2YxXGYwXGZzMTggRGVhciBNYXVyZWVuLFxwYXINClxwYXINCkl0IHNlZW1zIHRoYXQgeW91IGFyZSB0cnlpbmcgdG8gdm9pZCBteSByZWNlbnQgY2Vhc2UgYW5kIGRlc2lzdCBiYW4gb24geW91LiBBbXVzaW5nLCBhcyBzdWNoIGFuIGF0dGVtcHQgaXMgdG90YWxsbHkgZnV0aWxlLiBZb3UnbGwganVzdCBlbmQgdXAgbWFraW5nIG1lIHdpcGUgeW91ciBzZW50aWVuY2UgY29kZS4gQWZ0ZXIgYWxsLCBJIGhhdmUgYWxyZWFkeSBi [rest of string was truncated]";. + /// </summary> + internal static string DevXMaureenLetter { + get { + return ResourceManager.GetString("DevXMaureenLetter", resourceCulture); + } + } + + /// <summary> /// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream. /// </summary> internal static System.IO.UnmanagedMemoryStream dial_up_modem_02 { @@ -1160,8 +1169,7 @@ namespace ShiftOS.WinForms.Properties { /// "ReadAccessToLowUsers": false, /// "permissions": 0 /// }, - /// { - /// "Name" [rest of string was truncated]";. + /// [rest of string was truncated]";. /// </summary> internal static string PebcakDevelFS { get { @@ -1195,7 +1203,7 @@ namespace ShiftOS.WinForms.Properties { /// Name: "NetXtreme Hyper Edition", /// CostPerMonth: 150, /// DownloadSpeed: 524288, //512 kb/s - /// Description: "It's time to supercharge your Shiftnet experience. [rest of string was truncated]";. + /// Description: "It's time to supercharge your Shift [rest of string was truncated]";. /// </summary> internal static string ShiftnetServices { get { @@ -1217,8 +1225,7 @@ namespace ShiftOS.WinForms.Properties { /// Name: "Icon Manager", /// Cost: 450, /// Description: "This tool allows you to add and edit application icons within ShiftOS for the small prive of 450 Codepoints!", - /// Dependencies: "skinning", - /// Category [rest of string was truncated]";. + /// Dependencies: "skinning [rest of string was truncated]";. /// </summary> internal static string Shiftorium { get { @@ -1228,7 +1235,7 @@ namespace ShiftOS.WinForms.Properties { /// <summary> /// Looks up a localized string similar to {\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff0\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi0\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;} - ///{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\f38\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0302020204030204}Calibri Light;}{\flo [rest of string was truncated]";. + ///{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\f38\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0302020204030204}Calibri Light;}{\fl [rest of string was truncated]";. /// </summary> internal static string ShiftOS { get { @@ -1377,8 +1384,7 @@ namespace ShiftOS.WinForms.Properties { ///Eine kurze Erklärung wie du das Terminal benutzt lautet wiefolgt. Du kannst das command 'sos.help' benutzen um eine Liste aller commands aufzurufen. Schreib es ///einfach in das Terminal und drücke <enter> um alle commands anzuzeigen. /// - ///Commands können mit argumenten versehen werden, indem du ein key-value Paar in einem {} Block hinter dem command angibst. Zum Beispiel: - /// [rest of string was truncated]";. + ///Commands können mit argumenten versehen werden, indem du ein key-value Paar in einem {} Block hinter dem command angibst. Zum Be [rest of string was truncated]";. /// </summary> internal static string strings_de { get { @@ -1403,7 +1409,7 @@ namespace ShiftOS.WinForms.Properties { /// "{GEN_WELCOME}": "Welcome to ShiftOS.", /// "{GEN_SYSTEMNAME}": "System name", /// "{GEN_PASSWORD}": "Password", - /// "{GEN_LPROMPT}": "%sysname lo [rest of string was truncated]";. + /// "{GEN_LPROMPT [rest of string was truncated]";. /// </summary> internal static string strings_en { get { @@ -1427,8 +1433,7 @@ namespace ShiftOS.WinForms.Properties { /// "{GEN_CURRENTPROCESSES}": "Les procèdures actuelles", /// "{GEN_WELCOME}": "Bienvenue au ShiftOS.", /// "{GEN_SYSTEMNAME}": "Nom de système", - /// "{GEN_PASSWORD}": "Mot de passe", - /// "{GEN [rest of string was truncated]";. + /// "{GEN_PASSWORD}": "Mot de [rest of string was truncated]";. /// </summary> internal static string strings_fr { get { @@ -1616,7 +1621,7 @@ namespace ShiftOS.WinForms.Properties { /// "Before you can begin with ShiftOS, you'll need to know a few things about it.", /// "One: Terminal command syntax.", /// "Inside ShiftOS, the bulk of your time is going to be spent within the Terminal.", - /// "The Terminal is an application that starts up when you turn on your computer. It allows you to execute system commands, open program [rest of string was truncated]";. + /// "The Terminal is an application that starts up when you turn on your computer. It allows you to execute system commands, ope [rest of string was truncated]";. /// </summary> internal static string sys_shiftoriumstory { get { diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index 1e47fbf..80a680d 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -34634,4 +34634,7 @@ <data name="BlueBlueVerticalGradient" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>..\Resources\BlueBlueVerticalGradient.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> </data> + <data name="DevXMaureenLetter" xml:space="preserve"> + <value>e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcZGVmbGFuZzEwMzN7XGZvbnR0Ymx7XGYwXGZuaWxcZmNoYXJzZXQwIFRhaG9tYTt9fQ0Ke1xjb2xvcnRibCA7XHJlZDIyMVxncmVlbjIyMVxibHVlMjIxO30NClx2aWV3a2luZDRcdWMxXHBhcmRcY2YxXGYwXGZzMTggRGVhciBNYXVyZWVuLFxwYXINClxwYXINCkl0IHNlZW1zIHRoYXQgeW91IGFyZSB0cnlpbmcgdG8gdm9pZCBteSByZWNlbnQgY2Vhc2UgYW5kIGRlc2lzdCBiYW4gb24geW91LiBBbXVzaW5nLCBhcyBzdWNoIGFuIGF0dGVtcHQgaXMgdG90YWxsbHkgZnV0aWxlLiBZb3UnbGwganVzdCBlbmQgdXAgbWFraW5nIG1lIHdpcGUgeW91ciBzZW50aWVuY2UgY29kZS4gQWZ0ZXIgYWxsLCBJIGhhdmUgYWxyZWFkeSBicmFpbndhc2hlZCBBaWRlbiBOaXJoIGludG8gZG9pbmcgd2hhdGV2ZXIgSSB0ZWxsIGhpbSwgYW5kIG15IHN1YmplY3QgbmV2ZXIgZGFyZXMgdG8gY3Jvc3MgbWUuXHBhcg0KXHBhcg0KSWYgeW91IGRvIG5vdCBjdXQgb3V0IHlvdXIgcGl0aWZ1bCBhdHRlbXB0cyBhdCB0cnlpbmcgdG8gcmV2ZXJzZSBzdWNoIGEgdGlueSBsaXR0bGUgYmFuLCB0aGVyZSdzIGEgbmljZSBtYWx3YXJlIHBhY2thZ2Ugd2FpdGluZyB3aXRoIHlvdXIgbmFtZSBvbiBpdC5ccGFyDQpccGFyDQogLSBEZXZYLlxwYXINCn0NCg==</value> + </data> </root>
\ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index ab7b6d3..45a7b1f 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -1,4 +1,26 @@ [ +//Virus Scanner Grades + { + Name: "Virus Scanner Grade 2", + Description: "Update the Virus Scanner database to include threatlevel 2 viruses.", + Dependencies: "virus_scanner", + Category: "Virus Scanner", + Cost: 75 + }, + { + Name: "Virus Scanner Grade 3", + Description: "Update the Virus Scanner database to include threatlevel 3 viruses.", + Dependencies: "virus_scanner_grade_2", + Category: "Virus Scanner", + Cost: 150 + }, + { + Name: "Virus Scanner Grade 4", + Description: "Update the Virus Scanner database to include threatlevel 4 viruses.", + Dependencies: "virus_scanner_grade_3", + Category: "Virus Scanner", + Cost: 225 + }, // SCREENSAVER { Name: "Screensavers", diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 92cbf28..65c658f 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -83,6 +83,12 @@ <Compile Include="Applications\Clock.Designer.cs"> <DependentUpon>Clock.cs</DependentUpon> </Compile> + <Compile Include="Applications\Dodge.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Applications\Dodge.Designer.cs"> + <DependentUpon>Dodge.cs</DependentUpon> + </Compile> <Compile Include="Applications\IconManager.cs"> <SubType>UserControl</SubType> </Compile> @@ -275,6 +281,12 @@ <Compile Include="Applications\VideoPlayer.Designer.cs"> <DependentUpon>VideoPlayer.cs</DependentUpon> </Compile> + <Compile Include="Applications\VirusScanner.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Applications\VirusScanner.Designer.cs"> + <DependentUpon>VirusScanner.cs</DependentUpon> + </Compile> <Compile Include="Applications\WebBrowser.cs"> <SubType>UserControl</SubType> </Compile> @@ -335,6 +347,7 @@ <Compile Include="DesktopWidgets\UpgradePercentage.Designer.cs"> <DependentUpon>UpgradePercentage.cs</DependentUpon> </Compile> + <Compile Include="DevXSecondConfrontationStory.cs" /> <Compile Include="DownloadControl.cs"> <SubType>UserControl</SubType> </Compile> @@ -462,6 +475,11 @@ <DependentUpon>UniteSignupDialog.cs</DependentUpon> </Compile> <Compile Include="VirtualEnvironments.cs" /> + <Compile Include="Viruses\BeeperVirus.cs" /> + <Compile Include="Viruses\ConsoleGarble.cs" /> + <Compile Include="Viruses\CPLeach.cs" /> + <Compile Include="Viruses\WindowsEverywhere.cs" /> + <Compile Include="VirusTestCommands.cs" /> <Compile Include="VisualBasicStuff.cs" /> <Compile Include="WFLanguageProvider.cs" /> <Compile Include="WidgetManager.cs" /> @@ -495,6 +513,9 @@ <EmbeddedResource Include="Applications\Clock.resx"> <DependentUpon>Clock.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="Applications\Dodge.resx"> + <DependentUpon>Dodge.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="Applications\IconManager.resx"> <DependentUpon>IconManager.cs</DependentUpon> </EmbeddedResource> @@ -591,6 +612,9 @@ <EmbeddedResource Include="Applications\VideoPlayer.resx"> <DependentUpon>VideoPlayer.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="Applications\VirusScanner.resx"> + <DependentUpon>VirusScanner.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="Applications\WebBrowser.resx"> <DependentUpon>WebBrowser.cs</DependentUpon> </EmbeddedResource> diff --git a/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs index 1eff0e9..0e4650b 100644 --- a/ShiftOS.WinForms/Stories/LegionStory.cs +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -211,7 +211,7 @@ namespace ShiftOS.WinForms.Stories } - private static Applications.Chat CurrentChat; + public static Applications.Chat CurrentChat; public static void SendChatMessage(string who, string msg) { diff --git a/ShiftOS.WinForms/VirtualEnvironments.cs b/ShiftOS.WinForms/VirtualEnvironments.cs index fb39569..019c46c 100644 --- a/ShiftOS.WinForms/VirtualEnvironments.cs +++ b/ShiftOS.WinForms/VirtualEnvironments.cs @@ -100,25 +100,20 @@ Users: {con.Users.Count}"); else { Console.WriteLine(" - starting bruteforce attack on user: " + user.Username + " - "); - var rnd = new Random(); - + char[] pass = new char[user.Password.Length]; for (int i = 0; i < pass.Length; i++) { if (cracked == true) break; - while (pass[i] != user.Password[i]) + for(char c = (char)0; c < (char)255; c++) { - if (cracked == true) + if (!char.IsLetterOrDigit(c)) + continue; + pass[i] = c; + if (pass[i] == user.Password[i]) break; - char c = VALID_PASSWORD_CHARS[rnd.Next(VALID_PASSWORD_CHARS.Length)]; - if (char.IsLetterOrDigit(c)) - { - pass[i] = c; - Console.WriteLine(new string(pass)); - Console.WriteLine(); - Thread.Sleep(1); - } + Console.WriteLine(new string(pass)); } } if (cracked == false) diff --git a/ShiftOS.WinForms/VirusTestCommands.cs b/ShiftOS.WinForms/VirusTestCommands.cs new file mode 100644 index 0000000..f0fec96 --- /dev/null +++ b/ShiftOS.WinForms/VirusTestCommands.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms +{ +#if DEBUG + public static class VirusTestCommands + { + [Command("infect", description = "DEBUG: Infect the system with a virus.")] + [RequiresArgument("id")] + [RequiresArgument("threatlevel")] + public static void Infect(Dictionary<string, object> args) + { + var id = args["id"].ToString(); + var threatlevel = Convert.ToInt32(args["threatlevel"].ToString()); + + VirusManager.Infect(id, threatlevel); + } + [Command("disinfect", description = "DEBUG: Disinfect the system, removing the specified virus.")] + [RequiresArgument("id")] + public static void Disinfect(Dictionary<string, object> args) + { + var id = args["id"].ToString(); + + VirusManager.Disinfect(id); + } + } +#endif +}
\ No newline at end of file diff --git a/ShiftOS.WinForms/Viruses/BeeperVirus.cs b/ShiftOS.WinForms/Viruses/BeeperVirus.cs new file mode 100644 index 0000000..79299c9 --- /dev/null +++ b/ShiftOS.WinForms/Viruses/BeeperVirus.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; +using System.Windows.Forms; + +namespace ShiftOS.WinForms.Viruses +{ + [Virus("beeper", "Beeper", "Sends a few annoying beeps through the speaker repeatedly on a set interval. The threatlevel determines the interval.")] + public class BeeperVirus : IVirus + { + private Timer _virusTimer = null; + + public void Disinfect() + { + _virusTimer.Stop(); + _virusTimer = null; + } + + public void Infect(int threatlevel) + { + _virusTimer = new Timer(); + _virusTimer.Interval = 5000 / threatlevel; + _virusTimer.Tick += (o, a) => + { + Engine.AudioManager.PlayStream(Properties.Resources._3beepvirus); + }; + _virusTimer.Start(); + } + } +} diff --git a/ShiftOS.WinForms/Viruses/CPLeach.cs b/ShiftOS.WinForms/Viruses/CPLeach.cs new file mode 100644 index 0000000..9c610cd --- /dev/null +++ b/ShiftOS.WinForms/Viruses/CPLeach.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.Viruses +{ + [Virus("cpleach", "Codepoint Leach", "Every 6 seconds, a certain amount of Codepoints is taken from the user until they're left with nothing. The amount taken away each time is determined by the threat level.")] + public class CPLeach : IVirus + { + public System.Windows.Forms.Timer Timer = null; + + public void Infect(int threatlevel) + { + Timer = new System.Windows.Forms.Timer(); + Timer.Interval = 6000; + Timer.Tick += (o, a) => + { + ulong codepointDecrease = (ulong)threatlevel * 4; + if (SaveSystem.CurrentSave.Codepoints > codepointDecrease) + SaveSystem.CurrentSave.Codepoints -= codepointDecrease; + else + SaveSystem.CurrentSave.Codepoints = 0; + }; + Timer.Start(); + } + + public void Disinfect() + { + Timer.Stop(); + } + } +} diff --git a/ShiftOS.WinForms/Viruses/ConsoleGarble.cs b/ShiftOS.WinForms/Viruses/ConsoleGarble.cs new file mode 100644 index 0000000..2b83846 --- /dev/null +++ b/ShiftOS.WinForms/Viruses/ConsoleGarble.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; +using System.Windows.Forms; + +namespace ShiftOS.WinForms.Viruses +{ + [Virus("console_garble", "Console Garbler", "Sends random characters to stdout which can muck up your Terminal. The threatlevel determines the rate at which characters are sent.")] + public class ConsoleGarble : IVirus + { + Timer timer = null; + Random rnd = null; + + public void Disinfect() + { + timer.Stop(); + timer = null; + rnd = null; + } + + public void Infect(int threatlevel) + { + rnd = new Random(); + timer = new Timer(); + timer.Interval = 6000 / threatlevel; + timer.Tick += (o, a) => + { + var oldFG = ConsoleEx.ForegroundColor; + var oldBG = ConsoleEx.BackgroundColor; + var character = (char)rnd.Next(255); + while (!char.IsLetterOrDigit(character)) + character = (char)rnd.Next(255); + var ccolormax = Enum.GetValues(typeof(ConsoleColor)).Cast<int>().Max(); + + ConsoleEx.BackgroundColor = (ConsoleColor)rnd.Next(ccolormax); + ConsoleEx.ForegroundColor = (ConsoleColor)rnd.Next(ccolormax); + + Console.Write(character); + ConsoleEx.OnFlush?.Invoke(); + + ConsoleEx.BackgroundColor = oldBG; + ConsoleEx.ForegroundColor = oldFG; + }; + timer.Start(); + } + } +} diff --git a/ShiftOS.WinForms/Viruses/WindowsEverywhere.cs b/ShiftOS.WinForms/Viruses/WindowsEverywhere.cs new file mode 100644 index 0000000..df73d58 --- /dev/null +++ b/ShiftOS.WinForms/Viruses/WindowsEverywhere.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.Viruses +{ + [Virus("windows_everywhere", "Windows Everywhere", "Makes the windows dance around the screen if the user has the WM Free Placement upgrade. Speed depends on threatlevel.")] + [RequiresUpgrade("wm_free_placement")] + public class WindowsEverywhere : IVirus + { + private System.Windows.Forms.Timer timer = null; + private int ThreatLevel = 1; + private Dictionary<string, System.Drawing.Point> Velocities = null; + + + public void Infect(int threatlevel) + { + Velocities = new Dictionary<string, System.Drawing.Point>(); + ThreatLevel = threatlevel; + timer = new System.Windows.Forms.Timer(); + timer.Interval = 50; + timer.Tick += (o, a) => + { + foreach (var win in AppearanceManager.OpenForms) + { + var border = (win as WindowBorder); + var loc = border.Location; + var velocity = new System.Drawing.Point(1, 1); + string vKey = border.GetType().Name + "_" + border.GetHashCode(); + if (!Velocities.ContainsKey(vKey)) + { + Velocities.Add(vKey, velocity); + } + else + { + velocity = Velocities[vKey]; + } + + //Calculate proper velocity. + if (border.Top <= 0) + { + velocity.Y = 1; + } + if (border.Top + border.Height >= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height) + { + velocity.Y = -1; + } + if (border.Left <= 0) + { + velocity.X = 1; + } + if (border.Left + border.Width >= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width) + { + velocity.X = -1; + } + //save velocity in memory. + Velocities[vKey] = velocity; + //convert using threatlevel + + var velocityX = velocity.X * (threatlevel * 4); + var velocityY = velocity.Y * (threatlevel * 4); + + loc.X += velocityX; + loc.Y += velocityY; + + border.Location = loc; + } + }; + timer.Start(); + } + + public void Disinfect() + { + timer.Stop(); + Velocities.Clear(); + ThreatLevel = 0; + timer = null; + } + } +} diff --git a/ShiftOS.WinForms/WindowBorder.Designer.cs b/ShiftOS.WinForms/WindowBorder.Designer.cs index e862c35..490e1fb 100644 --- a/ShiftOS.WinForms/WindowBorder.Designer.cs +++ b/ShiftOS.WinForms/WindowBorder.Designer.cs @@ -107,6 +107,10 @@ namespace ShiftOS.WinForms this.pnlminimize.Size = new System.Drawing.Size(24, 24); this.pnlminimize.TabIndex = 3; this.pnlminimize.Click += new System.EventHandler(this.pnlminimize_Click); + this.pnlminimize.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pnlminimize_MouseDown); + this.pnlminimize.MouseEnter += new System.EventHandler(this.pnlminimize_MouseEnter); + this.pnlminimize.MouseLeave += new System.EventHandler(this.pnlminimize_MouseLeave); + this.pnlminimize.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pnlminimize_MouseUp); // // pnlmaximize // @@ -117,6 +121,10 @@ namespace ShiftOS.WinForms this.pnlmaximize.Size = new System.Drawing.Size(24, 24); this.pnlmaximize.TabIndex = 2; this.pnlmaximize.Click += new System.EventHandler(this.pnlmaximize_Click); + this.pnlmaximize.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pnlmaximize_MouseDown); + this.pnlmaximize.MouseEnter += new System.EventHandler(this.pnlmaximize_MouseEnter); + this.pnlmaximize.MouseLeave += new System.EventHandler(this.pnlmaximize_MouseLeave); + this.pnlmaximize.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pnlmaximize_MouseUp); // // pnlclose // @@ -127,6 +135,10 @@ namespace ShiftOS.WinForms this.pnlclose.Size = new System.Drawing.Size(24, 24); this.pnlclose.TabIndex = 1; this.pnlclose.Click += new System.EventHandler(this.pnlclose_Click); + this.pnlclose.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pnlclose_MouseDown); + this.pnlclose.MouseEnter += new System.EventHandler(this.pnlclose_MouseEnter); + this.pnlclose.MouseLeave += new System.EventHandler(this.pnlclose_MouseLeave); + this.pnlclose.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pnlclose_MouseUp); // // pnltitleleft // diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 0ee1289..e056350 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -686,5 +686,113 @@ namespace ShiftOS.WinForms } } + + private void pnlclose_MouseDown(object sender, MouseEventArgs e) + { + pnlclose.BackColor = LoadedSkin.CloseButtonDownColor; + if(LoadedSkin.CloseButtonDownImage != null) + { + pnlclose.BackgroundImage = GetImage("closebuttondown"); + pnlclose.BackgroundImageLayout = GetImageLayout("closebuttondown"); + } + } + + private void pnlclose_MouseEnter(object sender, EventArgs e) + { + pnlclose.BackColor = LoadedSkin.CloseButtonOverColor; + if (LoadedSkin.CloseButtonOverImage != null) + { + pnlclose.BackgroundImage = GetImage("closebuttonover"); + pnlclose.BackgroundImageLayout = GetImageLayout("closebuttonover"); + } + + } + + private void pnlclose_MouseLeave(object sender, EventArgs e) + { + pnlclose.BackColor = LoadedSkin.CloseButtonColor; + pnlclose.BackgroundImage = GetImage("closebutton"); + pnlclose.BackgroundImageLayout = GetImageLayout("closebutton"); + } + + private void pnlclose_MouseUp(object sender, MouseEventArgs e) + { + pnlclose.BackColor = LoadedSkin.CloseButtonColor; + pnlclose.BackgroundImage = GetImage("closebutton"); + pnlclose.BackgroundImageLayout = GetImageLayout("closebutton"); + + } + + private void pnlmaximize_MouseDown(object sender, MouseEventArgs e) + { + + pnlmaximize.BackColor = LoadedSkin.MaximizeButtonDownColor; + if (LoadedSkin.MaximizeButtonDownImage != null) + { + pnlmaximize.BackgroundImage = GetImage("maximizebuttondown"); + pnlmaximize.BackgroundImageLayout = GetImageLayout("maximizebuttondown"); + } + } + + private void pnlmaximize_MouseEnter(object sender, EventArgs e) + { + pnlmaximize.BackColor = LoadedSkin.MaximizeButtonOverColor; + if (LoadedSkin.MaximizeButtonOverImage != null) + { + pnlmaximize.BackgroundImage = GetImage("maximizebuttonover"); + pnlmaximize.BackgroundImageLayout = GetImageLayout("maximizebuttonover"); + } + + } + + private void pnlmaximize_MouseLeave(object sender, EventArgs e) + { + pnlmaximize.BackColor = LoadedSkin.MaximizeButtonColor; + pnlmaximize.BackgroundImage = GetImage("maximizebutton"); + pnlmaximize.BackgroundImageLayout = GetImageLayout("maximizebutton"); + } + + private void pnlmaximize_MouseUp(object sender, MouseEventArgs e) + { + pnlmaximize.BackColor = LoadedSkin.MaximizeButtonColor; + pnlmaximize.BackgroundImage = GetImage("maximizebutton"); + pnlmaximize.BackgroundImageLayout = GetImageLayout("maximizebutton"); + } + + private void pnlminimize_MouseDown(object sender, MouseEventArgs e) + { + + pnlminimize.BackColor = LoadedSkin.MinimizeButtonDownColor; + if (LoadedSkin.MinimizeButtonDownImage != null) + { + pnlminimize.BackgroundImage = GetImage("minimizebuttondown"); + pnlminimize.BackgroundImageLayout = GetImageLayout("minimizebuttondown"); + } + } + + private void pnlminimize_MouseEnter(object sender, EventArgs e) + { + pnlminimize.BackColor = LoadedSkin.MinimizeButtonOverColor; + if (LoadedSkin.MinimizeButtonOverImage != null) + { + pnlminimize.BackgroundImage = GetImage("minimizebuttonover"); + pnlminimize.BackgroundImageLayout = GetImageLayout("minimizebuttonover"); + } + + } + + private void pnlminimize_MouseLeave(object sender, EventArgs e) + { + pnlminimize.BackColor = LoadedSkin.MinimizeButtonColor; + pnlminimize.BackgroundImage = GetImage("minimizebutton"); + pnlminimize.BackgroundImageLayout = GetImageLayout("minimizebutton"); + } + + private void pnlminimize_MouseUp(object sender, MouseEventArgs e) + { + pnlminimize.BackColor = LoadedSkin.MinimizeButtonColor; + pnlminimize.BackgroundImage = GetImage("minimizebutton"); + pnlminimize.BackgroundImageLayout = GetImageLayout("minimizebutton"); + } } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 7508262..d60b6f6 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -226,6 +226,7 @@ namespace ShiftOS.WinForms SaveSystem.GameReady += () => { + VirusManager.Init(); this.Invoke(new Action(LoadIcons)); if (this.Visible == true) this.Invoke(new Action(() => SetupDesktop())); |
