diff --git a/Sunfish/Sunfish/Sunfish.csproj b/Sunfish/Sunfish/Sunfish.csproj
index 3401ffc..20c91bc 100644
--- a/Sunfish/Sunfish/Sunfish.csproj
+++ b/Sunfish/Sunfish/Sunfish.csproj
@@ -137,6 +137,7 @@
+
diff --git a/Sunfish/Sunfish/wx/RemoteScreen.cs b/Sunfish/Sunfish/wx/RemoteScreen.cs
new file mode 100644
index 0000000..85e0383
--- /dev/null
+++ b/Sunfish/Sunfish/wx/RemoteScreen.cs
@@ -0,0 +1,125 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+using System.Windows.Forms;
+
+namespace DolphinWebXplorer2.wx
+{
+ class RemoteScreen
+ {
+ private static ImageCodecInfo jpegEncoder = null;
+ private static long lastTime;
+
+ static RemoteScreen()
+ {
+ foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageDecoders())
+ if (codec.FormatID == ImageFormat.Jpeg.Guid)
+ {
+ jpegEncoder = codec;
+ break;
+ }
+ }
+
+ #region WINAPI
+ private const int MOUSEEVENTF_LEFTDOWN = 0x0002; /* left button down */
+ private const int MOUSEEVENTF_LEFTUP = 0x0004; /* left button up */
+ private const int MOUSEEVENTF_RIGHTDOWN = 0x0008; /* left button down */
+ private const int MOUSEEVENTF_RIGHTUP = 0x0010; /* left button up */
+ private const int MOUSEEVENTF_WHEEL = 0x0800; /* The wheel has been moved, if the mouse has a wheel. The amount of movement is specified in dwData */
+ [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
+ public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
+ [DllImport("user32.dll")]
+ static extern uint keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
+ public static void KeyDown(System.Windows.Forms.Keys key)
+ {
+ keybd_event((byte)key, 0, 0, 0);
+ }
+
+ public static void KeyUp(System.Windows.Forms.Keys key)
+ {
+ keybd_event((byte)key, 0, 0x7F, 0);
+ }
+ #endregion
+
+ public static byte[] GetScreen()
+ {
+ Screen scr = Program.MAINFORM.MyScreen;
+ MemoryStream ms = new MemoryStream();
+ using (Bitmap bmp = new Bitmap(scr.Bounds.Width, scr.Bounds.Height, PixelFormat.Format16bppRgb565))
+ using (Graphics g = Graphics.FromImage(bmp))
+ {
+ g.CopyFromScreen(scr.Bounds.X, scr.Bounds.Y, 0, 0, scr.Bounds.Size);
+ System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality;
+ EncoderParameters myEncoderParameters = new EncoderParameters(1);
+ EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 17L);
+ myEncoderParameters.Param[0] = myEncoderParameter;
+ bmp.Save(ms, jpegEncoder, myEncoderParameters);
+ ms.Close();
+ }
+ lastTime = DateTime.Now.Ticks;
+ return ms.ToArray();
+ }
+
+ public static void InputCommand(string cmd)
+ {
+ if (cmd.Length == 0)
+ return;
+ string cc = cmd.Substring(0, 2);
+ string par = cmd.Substring(2);
+ if (cc.StartsWith("K"))
+ {
+ byte keyb;
+ byte.TryParse(par, out keyb);
+ Keys key = (Keys)Enum.ToObject(typeof(Keys), keyb);
+ switch (cc)
+ {
+ case "KD":
+ KeyDown(key);
+ break;
+ case "KU":
+ KeyUp(key);
+ break;
+ }
+ return;
+ }
+ int x;
+ int y;
+ string[] pars = par.Split(';');
+ int.TryParse(pars[0], out x);
+ int.TryParse(pars[1], out y);
+ Screen scr = Program.MAINFORM.MyScreen;
+ System.Windows.Forms.Cursor.Position = new Point(x + scr.Bounds.X, y + scr.Bounds.Y);
+ switch (cc)
+ {
+ case "LD":
+ Thread.Sleep(100);
+ mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
+ break;
+ case "LU":
+ Thread.Sleep(100);
+ mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
+ break;
+ case "RD":
+ Thread.Sleep(100);
+ mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
+ break;
+ case "RU":
+ Thread.Sleep(100);
+ mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
+ break;
+ case "WH":
+ Thread.Sleep(100);
+ int wheel;
+ int.TryParse(pars[2], out wheel);
+ mouse_event(MOUSEEVENTF_WHEEL, 0, 0, wheel, 0);
+ break;
+ }
+ }
+ }
+}
diff --git a/Sunfish/Sunfish/wx/WebXplorer.cs b/Sunfish/Sunfish/wx/WebXplorer.cs
index a8a41a3..4b9bb9c 100644
--- a/Sunfish/Sunfish/wx/WebXplorer.cs
+++ b/Sunfish/Sunfish/wx/WebXplorer.cs
@@ -349,124 +349,19 @@
{
if (GET["code"] != WebXplorer.SharedScreenPassword)
return;
- Screen scr = Program.MAINFORM.MyScreen;
- MemoryStream ms = new MemoryStream();
- using (Bitmap bmp = new Bitmap(scr.Bounds.Width, scr.Bounds.Height, PixelFormat.Format16bppRgb565))
- using (Graphics g = Graphics.FromImage(bmp))
- {
- g.CopyFromScreen(scr.Bounds.X, scr.Bounds.Y, 0, 0, scr.Bounds.Size);
- ImageCodecInfo jgpEncoder = GetEncoder();
- System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality;
- EncoderParameters myEncoderParameters = new EncoderParameters(1);
- EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 17L);
- myEncoderParameters.Param[0] = myEncoderParameter;
- bmp.Save(ms, jgpEncoder, myEncoderParameters);
- ms.Close();
- }
- BinaryOut(ms.ToArray(), "image/jpeg");
+ BinaryOut(RemoteScreen.GetScreen(), "image/jpeg");
return;
}
if (path == "screencmd")
{
if (GET["code"] != WebXplorer.SharedScreenPassword)
return;
- string cmd = GET["cmd"];
- if (cmd.Length == 0)
- return;
- string cc = cmd.Substring(0, 2);
- string par = cmd.Substring(2);
- if (cc.StartsWith("K"))
- {
- byte keyb;
- byte.TryParse(par, out keyb);
- Keys key=(Keys) Enum.ToObject(typeof(Keys),keyb);
- switch (cc)
- {
- case "KD":
- KeyDown(key);
- break;
- case "KU":
- KeyUp(key);
- break;
- }
- return;
- }
- int x;
- int y;
- string[] pars = par.Split(';');
- int.TryParse(pars[0], out x);
- int.TryParse(pars[1], out y);
- Screen scr = Program.MAINFORM.MyScreen;
- System.Windows.Forms.Cursor.Position = new Point(x + scr.Bounds.X, y + scr.Bounds.Y);
- switch (cc)
- {
- case "LD":
- Thread.Sleep(100);
- mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
- break;
- case "LU":
- Thread.Sleep(100);
- mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
- break;
- case "RD":
- Thread.Sleep(100);
- mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
- break;
- case "RU":
- Thread.Sleep(100);
- mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
- break;
- case "WH":
- Thread.Sleep(100);
- int wheel;
- int.TryParse(pars[2], out wheel);
- mouse_event(MOUSEEVENTF_WHEEL, 0, 0, wheel, 0);
- break;
- }
+ RemoteScreen.InputCommand(GET["cmd"]);
Out.Write("Ok");
return;
}
}
- #region WINAPI
- private const int MOUSEEVENTF_LEFTDOWN = 0x0002; /* left button down */
- private const int MOUSEEVENTF_LEFTUP = 0x0004; /* left button up */
- private const int MOUSEEVENTF_RIGHTDOWN = 0x0008; /* left button down */
- private const int MOUSEEVENTF_RIGHTUP = 0x0010; /* left button up */
- private const int MOUSEEVENTF_WHEEL = 0x0800; /* The wheel has been moved, if the mouse has a wheel. The amount of movement is specified in dwData */
- [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
- public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
- [DllImport("user32.dll")]
- static extern uint keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
- public static void KeyDown(System.Windows.Forms.Keys key)
- {
- keybd_event((byte)key, 0, 0, 0);
- }
-
- public static void KeyUp(System.Windows.Forms.Keys key)
- {
- keybd_event((byte)key, 0, 0x7F, 0);
- }
- #endregion
-
- #region JPEG SCREEN SHARE
- private ImageCodecInfo jpegEncoder = null;
-
- private ImageCodecInfo GetEncoder()
- {
- if (jpegEncoder == null)
- foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageDecoders())
- if (codec.FormatID == ImageFormat.Jpeg.Guid)
- {
- jpegEncoder = codec;
- break;
- }
- return jpegEncoder;
- }
-
- //private
- #endregion
-
private void GetIcon(WShared sh, string path)
{
path = sh.GetLocalPath(path);
@@ -517,8 +412,7 @@
private void BinaryOut(MemoryStream ms, string mimetype)
{
- Response.Headers[HttpResponseHeader.ContentType] = mimetype;
- Write(ms.ToArray());
+ BinaryOut(ms.ToArray(), mimetype);
}
private void BinaryOut(FileStream fs, string mimetype)
@@ -538,6 +432,7 @@
private void BinaryOut(byte[] data, string mimetype)
{
Response.Headers[HttpResponseHeader.ContentType] = mimetype;
+ Response.ContentLength64 = data.Length;
Write(data);
}
@@ -607,6 +502,7 @@
}
}
+ #region Action Pages
private const string RESETURL="";
private void PageRename(WShared sh, string path)
@@ -828,6 +724,7 @@
}
Footer();
}
+#endregion
private void BlackHeader(string title, string script)
{