Skip to content

Commit

Permalink
v 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ncleardev authored Mar 19, 2023
1 parent 54e3183 commit 81e4c5d
Show file tree
Hide file tree
Showing 55 changed files with 2,861 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Apps/Console.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Cosmos.System;

namespace NclearOS2
{
public class ConsoleApp : Window
{
private Input inputInstance;
private CommandExecute commandHandler = new CommandExecute();

public ConsoleApp(int x, int y) : base("Console", x, y, Resources.console) { }
internal override bool Update(int StartX, int StartY, int x, int y)
{
Kernel.canvas.DrawFilledRectangle(Kernel.DarkPen, StartX, StartY, x, y);
Kernel.canvas.DrawChar('>', Kernel.font, Kernel.WhitePen, StartX+10, StartY + 10);
Graphic.EditText(inputInstance, StartX + 25, StartY + 10, Kernel.WhitePen, true);
if (inputInstance.ready)
{
commandHandler.Main(inputInstance.input);
inputInstance.ready = false;
inputInstance.input = null;
}
Graphic.TextView(commandHandler.result, StartX + 10, StartY + 34, Kernel.WhitePen);
return true;
}
internal override bool Start()
{
inputInstance = new Input("Console", true);
ProcessManager.Run(inputInstance);
inputInstance.input = null;
return true;
}
internal override int Stop() { ProcessManager.RemoveAtService(inputInstance.id); return 0; }
internal override void Key(ConsoleKeyEx keyEx) { }
}
}
29 changes: 29 additions & 0 deletions Apps/ExampleApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Cosmos.System;
using System;
using System.Collections.Generic;

namespace NclearOS2
{
public class AppExample : Window
{
public static List<string> RAWlistresult = new();
private int click;
private int selY;
private int dclick = -1;
public AppExample() : base("App Example", 300, 100, Resources.program) { }
internal override bool Start()
{
RAWlistresult.Add("wow");
RAWlistresult.Add("wow2");
RAWlistresult.Add("wow3");
return true;
}
internal override bool Update(int StartX, int StartY, int x, int y)
{
(click, dclick, selY) = Graphic.Listview(RAWlistresult, StartX + 10, StartY + 10, 280, 80, click, dclick, selY);
return true;
}
internal override int Stop() { return 0; }
internal override void Key(ConsoleKeyEx key) { }
}
}
419 changes: 419 additions & 0 deletions Apps/Files.cs

Large diffs are not rendered by default.

96 changes: 96 additions & 0 deletions Apps/Notepad.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using Cosmos.System;
using System;
using System.Collections.Generic;
using F = NclearOS2.FileManager;

namespace NclearOS2
{
public class Notepad : Window
{
public Notepad(int x, int y, string path = null) : base("Notepad", x, y, Resources.notepad)
{ this.filePath = path; }
string filePath;
bool exit;
public Input inputInstance;
static List<string> buttons = new()
{
"Yes",
"No"
};
internal override bool Start()
{
inputInstance = new Input("Notepad", false);
ProcessManager.Run(inputInstance);
if (filePath != null) { inputInstance.input = F.Open(filePath); name = "Notepad - " + filePath; }
return true;
}
internal override bool Update(int StartX, int StartY, int x, int y)
{
Kernel.canvas.DrawFilledRectangle(Kernel.DarkGrayPen, StartX, StartY + 20, x, y);
Kernel.canvas.DrawFilledRectangle(Kernel.SystemPen, StartX, StartY, x, 20);
Graphic.EditText(inputInstance, StartX + 10, StartY + 30, Kernel.WhitePen, true);
Kernel.canvas.DrawString("New Open Save Save as", Kernel.font, Kernel.WhitePen, StartX + 10, StartY + 1);
if (MouseManager.Y < StartY + 20 && MouseManager.Y > StartY && MouseManager.X > StartX + 10 && MouseManager.X < StartX + x)
{
if (MouseManager.X < StartX + 33)
{
Kernel.canvas.DrawString("New ", Kernel.font, Kernel.GrayPen, StartX + 10, StartY + 1);
if (Kernel.Pressed) { inputInstance.input = null; }
}
else if (MouseManager.X < StartX + 80)
{
Kernel.canvas.DrawString(" Open ", Kernel.font, Kernel.GrayPen, StartX + 10, StartY + 1);
if (Kernel.Pressed) { ProcessManager.Add(new Files(630, 400)); return false; }
}
else if (MouseManager.X < StartX + 130)
{
Kernel.canvas.DrawString(" Save ", Kernel.font, Kernel.GrayPen, StartX + 10, StartY + 1);
if (Kernel.Pressed)
{
if (String.IsNullOrWhiteSpace(filePath))
{
F.Save(F.NewFile("0:\\New Text Document"), inputInstance.input);
//Files.SaveContent = Input.input;
//Process.Run(Process.Apps.files);
//Input.Register(false);
}
else
{
F.Save(filePath, inputInstance.input);
}
}
}
else if (MouseManager.X < StartX + 200)
{
Kernel.canvas.DrawString(" Save as", Kernel.font, Kernel.GrayPen, StartX + 10, StartY + 1);
if (Kernel.Pressed)
{
Toast.msg = "Not implemented yet";
//Files.SaveContent = Input.input;
//Process.Run(Process.Apps.files);
//Input.Register(false);
}
}
}
if (exit) { if (!Exit(id)) { inputInstance.input = null; return false; }; }
return true;
}
internal override int Stop()
{
if (inputInstance.input != null) { exit = true; return 1; } else { ProcessManager.RemoveAtService(inputInstance.id); return 0; }
}
bool Exit(int id)
{
switch(MsgBox.Main(StartWindowX + x / 4, StartWindowY + y / 4, "Are you sure you want to exit?", buttons))
{
case 1:
return false;
case 2:
exit = false;
return true;
}
return true;
}
internal override void Key(ConsoleKeyEx key) { }
}
}
148 changes: 148 additions & 0 deletions Apps/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
using Cosmos.System;
using Cosmos.System.Graphics;
using System.Drawing;

namespace NclearOS2
{
public class Settings : Window
{
public static int wallpapernum = 1;
public static int cursortype = 0;
static Bitmap cursor1 = new(Resources.CursorIcon);
static Bitmap cursor2 = new(Resources.CursorWhiteIcon);
Bitmap setttingsUI = new Bitmap(Resources.SettingsUI);
public Settings() : base("Settings", 300, 300, Resources.settings) { }
public static string Change(string option)
{
switch (option)
{
case "wallpaper":
Kernel.WallpaperOn = true;
if (wallpapernum == 1)
{
Resources.wallpaper = Resources.wallpaperlock;
wallpapernum = 2;
}
else if (wallpapernum == 2)
{
Resources.wallpaper = Resources.wallpaperold;
wallpapernum = 3;
}
else if (wallpapernum == 3)
{
Kernel.WallpaperOn = false;
wallpapernum = 0;
}
else
{
Resources.wallpaper = Resources.wallpapernew;
wallpapernum = 1;
}
break;
case "cursorwhite":
Resources.cursor = new Bitmap(Resources.CursorWhiteIcon);
Resources.cursorload = new Bitmap(Resources.CursorWhiteLoad);
cursortype = 1;
break;
case "cursordark":
Resources.cursor = new Bitmap(Resources.CursorIcon);
Resources.cursorload = new Bitmap(Resources.CursorLoad);
cursortype = 0;
break;
case "default":
Kernel.SystemPen = Color.SteelBlue;

break;
case "red":
Kernel.SystemPen = Color.DarkRed;

break;
case "green":
Kernel.SystemPen = Color.Green;

break;
case "yellow":
Kernel.SystemPen = Color.Goldenrod;

break;
case "darkblue":
Kernel.SystemPen = Color.MidnightBlue;

break;
case "gray":
Kernel.SystemPen = Color.FromArgb(40, 40, 40);

break;
case "black":
Kernel.SystemPen = Color.Black;

break;
case "res":
string result = "Usage: set res WidthxHeight Optional: set res WidthxHeight@ColorDepth\nExamples: set res 1920x1080 set res 1920x1080@32\nAvailable resolutions: ";
foreach (var i in Kernel.canvas.AvailableModes)
{
result += "\n" + i;
}
return result;
case { } when option.StartsWith("res "):
return Kernel.SetRes(option[4..]);
default:
return "Unknown command; Type 'set' for help";
}
return "Set successfully";
}
internal override bool Update(int StartX, int StartY, int x, int y)
{
Kernel.canvas.DrawFilledRectangle(Kernel.GrayPen, StartX, StartY, x, y);
Kernel.canvas.DrawImage(setttingsUI, StartX, StartY + 7); //because of many memory leaks and performance problems I decided to use screeenshot of UI instead of drawing UI
if (MouseManager.X > StartX + 5 && MouseManager.X < StartX + 128 && MouseManager.Y > StartY + 70 && MouseManager.Y < StartY + 90)
{
if (Kernel.Pressed)
{ Change("wallpaper"); }
}
if (Kernel.Pressed && MouseManager.Y > StartY + 105 && MouseManager.Y < StartY + 135)
{
if (MouseManager.X > StartX + 5 && MouseManager.X < StartX + 35) { Change("default"); }
if (MouseManager.X > StartX + 45 && MouseManager.X < StartX + 75) { Change("red"); }
if (MouseManager.X > StartX + 85 && MouseManager.X < StartX + 115) { Change("green"); }
if (MouseManager.X > StartX + 125 && MouseManager.X < StartX + 155) { Change("yellow"); }
if (MouseManager.X > StartX + 165 && MouseManager.X < StartX + 195) { Change("darkblue"); }
if (MouseManager.X > StartX + 205 && MouseManager.X < StartX + 235) { Change("gray"); }
if (MouseManager.X > StartX + 245 && MouseManager.X < StartX + 275) { Change("black"); }
}
if (Kernel.Pressed && MouseManager.Y > StartY + 25 && MouseManager.Y < StartY + 40)
{
if (MouseManager.X > StartX + 15 && MouseManager.X < StartX + 35)
{
Change("cursordark");
}
else if (MouseManager.X > StartX + 50 && MouseManager.X < StartX + 70)
{
Change("cursorwhite");
}
}
return true;
}
internal override bool Start() { return true; }
internal override int Stop() { return 0; }
public static void UI(int StartX, int StartY, int x, int y)
{
Kernel.canvas.DrawString("Cursor", Kernel.font, Kernel.WhitePen, StartX + 5, StartY + 5);
Kernel.canvas.DrawLine(Kernel.WhitePen, StartX + 60, StartY + 11, StartX + x, StartY + 11);
Kernel.canvas.DrawString("Wallpaper", Kernel.font, Kernel.WhitePen, StartX + 5, StartY + 50);
Kernel.canvas.DrawLine(Kernel.WhitePen, StartX + 85, StartY + 56, StartX + x, StartY + 56);
Kernel.canvas.DrawString("Colours", Kernel.font, Kernel.WhitePen, StartX + 5, StartY + 85);
Kernel.canvas.DrawLine(Kernel.WhitePen, StartX + 68, StartY + 91, StartX + x, StartY + 91);
Kernel.canvas.DrawImageAlpha(cursor1, StartX + 15, StartY + 25);
Kernel.canvas.DrawImageAlpha(cursor2, StartX + 50, StartY + 25);
Kernel.canvas.DrawString("Change background", Kernel.font, Kernel.WhitePen, StartX + 5, StartY + 70);
Kernel.canvas.DrawString("Change background", Kernel.font, Kernel.SystemPen, StartX + 5, StartY + 70);
Kernel.canvas.DrawFilledCircle(Kernel.DefaultPen, StartX + 20, StartY + 120, 15);
Kernel.canvas.DrawFilledCircle(Kernel.RedPen, StartX + 60, StartY + 120, 15);
Kernel.canvas.DrawFilledCircle(Kernel.GreenPen, StartX + 100, StartY + 120, 15);
Kernel.canvas.DrawFilledCircle(Kernel.DarkBluePen, StartX + 180, StartY + 120, 15);
Kernel.canvas.DrawFilledCircle(Kernel.DarkGrayPen, StartX + 220, StartY + 120, 15);
}
internal override void Key(ConsoleKeyEx key) { }
}
}
29 changes: 29 additions & 0 deletions Apps/SysInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Cosmos.Core;
using Cosmos.System;

namespace NclearOS2
{
public class Sysinfo : Window
{
public Sysinfo() : base("System Info", 500, 100, Resources.sysinfo) { }
internal override bool Start()
{
return true;
}
internal override bool Update(int StartX, int StartY, int x, int y)
{
Kernel.canvas.DrawFilledRectangle(Kernel.DarkGrayPen, StartX, StartY, x, y);
Graphic.TextView(Main(), StartX + 5, StartY + 5, Kernel.WhitePen);
return true;
}
public static string Main()
{
return Kernel.CurrentVersion
+ "\nDisplay: " + Kernel.canvas.Mode
+ "\nCPU: " + CPU.GetCPUBrandString()
+ "\nRAM: " + GCImplementation.GetUsedRAM() / 1048576 + " MB / " + CPU.GetAmountOfRAM() + " MB";
}
internal override int Stop() { return 0; }
internal override void Key(ConsoleKeyEx key) { }
}
}
Loading

0 comments on commit 81e4c5d

Please sign in to comment.