diff --git a/Sunfish/Sunfish/Form1.Designer.cs b/Sunfish/Sunfish/Form1.Designer.cs
index 18be0fa..2cc8edd 100644
--- a/Sunfish/Sunfish/Form1.Designer.cs
+++ b/Sunfish/Sunfish/Form1.Designer.cs
@@ -230,7 +230,10 @@
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Sunfish";
+ this.Activated += new System.EventHandler(this.Form1_Activated);
+ this.Deactivate += new System.EventHandler(this.Form1_Activated);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
+ this.LocationChanged += new System.EventHandler(this.Form1_Activated);
((System.ComponentModel.ISupportInitialize)(this.nudPort)).EndInit();
this.cmsItem.ResumeLayout(false);
this.cmsGOptions.ResumeLayout(false);
diff --git a/Sunfish/Sunfish/Form1.cs b/Sunfish/Sunfish/Form1.cs
index ebdaa54..325716a 100644
--- a/Sunfish/Sunfish/Form1.cs
+++ b/Sunfish/Sunfish/Form1.cs
@@ -17,6 +17,7 @@
public const string conffile = "sunfish";
public Font smallfont;
public Brush itembrushgray;
+ private Screen myscreen;
public Form1()
{
InitializeComponent();
@@ -29,6 +30,7 @@
}
PopulateData();
Text += " "+Program.VERSION;
+ myscreen = Screen.FromControl(this);
}
private void PopulateData()
@@ -55,6 +57,8 @@
return result;
}
+ public Screen MyScreen { get { lock (this) return myscreen; } }
+
private void button1_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Minimized;
@@ -205,5 +209,11 @@
{
e.KeyChar = char.ToLower(e.KeyChar);
}
+
+ private void Form1_Activated(object sender, EventArgs e)
+ {
+ lock (this)
+ myscreen = Screen.FromControl(this);
+ }
}
}
diff --git a/Sunfish/Sunfish/Form1.resx b/Sunfish/Sunfish/Form1.resx
index 9a298c8..97ae20d 100644
--- a/Sunfish/Sunfish/Form1.resx
+++ b/Sunfish/Sunfish/Form1.resx
@@ -128,7 +128,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAq
- AQAAAk1TRnQBSQFMAgEBAgEAASABAAEgAQABEAEAARABAAT/AQUBAAj/AUIBTQF2BwABdgMAASgDAAFA
+ AQAAAk1TRnQBSQFMAgEBAgEAAUABAAFAAQABEAEAARABAAT/AQUBAAj/AUIBTQF2BwABdgMAASgDAAFA
AwABEAMAAQEBAAEEBgABAhgAAYACAAGAAwACgAEAAYADAAGAAQABgAEAAoACAAPAAQADgAMAAf8CAAH/
AwAC/wEAAf8DAAH/AQAB/wEAAv8CAAP//wD/AAMAAUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEB
BQABgBcAA/8BAAT/BAAE/wQABP8EAAH8AT8C/wQAAfwBPwL/BAAB/AE/Av8EAAHgAQcB4AEHBAAB4AEH
@@ -136,9 +136,6 @@
BAAL
-
- 17, 17
-
185, 17
diff --git a/Sunfish/Sunfish/Program.cs b/Sunfish/Sunfish/Program.cs
index 6c8f675..e4eaa11 100644
--- a/Sunfish/Sunfish/Program.cs
+++ b/Sunfish/Sunfish/Program.cs
@@ -8,7 +8,8 @@
{
static class Program
{
- public static string VERSION = "0.8";
+ public static string VERSION = "0.9";
+ private static Form1 mainform;
///
/// Punto de entrada principal para la aplicación.
///
@@ -19,12 +20,14 @@
Application.SetCompatibleTextRenderingDefault(false);
try
{
- Application.Run(new Form1());
+ Application.Run(mainform=new Form1());
}
finally
{
WebXplorer.Stop();
}
}
+
+ public static Form1 MAINFORM { get { return mainform; } }
}
}
diff --git a/Sunfish/Sunfish/Resources/ShScreen.js b/Sunfish/Sunfish/Resources/ShScreen.js
index 9e8e7a0..6bd4db3 100644
--- a/Sunfish/Sunfish/Resources/ShScreen.js
+++ b/Sunfish/Sunfish/Resources/ShScreen.js
@@ -1,15 +1,57 @@
var shs = new (function () {
+ var xmlhttp = new XMLHttpRequest();
var byId = function (name) {
return document.getElementById(name);
}
- var frm;
- var scr;
- var code;
+ var sending = false;
+ var send = function (code, cmd) {
+ if (sending) return;
+ sending = true;
+ xmlhttp.open("GET", "$screencmd?code=" + code + "&cmd=" + cmd, true);
+ xmlhttp.onreadystatechange = function (evt) {
+ if (xmlhttp.readyState == 4) {
+ sending = false;
+ }
+ }
+ xmlhttp.onerror = function () {
+ sending = false;
+ }
+ xmlhttp.send();
+ }
this.start = function () {
- frm = byId("frm");
- scr = byId("scr");
- code = byId("scpwd").value;
+ var frm = byId("frm");
+ var code = byId("scpwd").value;
+ var img = byId("scr");
frm.style.display = "none";
- scr.src = "/$screencap?code=" + code;
+ img.onload = function () {
+ img.onload = function () {
+ img.src = "/$screencap?code=" + code + "&time=" + new Date().getTime();
+ }
+ img.onerror = function () {
+ location.href = "/";
+ }
+ img.onload();
+ }
+ img.onerror = function () {
+ img.style.display = "none";
+ frm.style.display = "";
+ }
+ img.onmousemove = function (evt) {
+ send(code, "M"+evt.offsetX+";"+evt.offsetY);
+ }
+ img.onmousedown = function (evt) {
+ send(code, "D" + evt.offsetX + ";" + evt.offsetY);
+ return false;
+ }
+ img.onmouseup = function (evt) {
+ send(code, "U" + evt.offsetX + ";" + evt.offsetY);
+ }
+ img.onmousewheel = function (evt) {
+ send(code, "W" + evt.offsetX + ";" + evt.offsetY + ";" + evt.wheelDelta);
+ }
+ img.onclick = function (evt) {
+ evt.preventDefault();
+ }
+ img.src = "/$screencap?code=" + code;
}
})();
\ No newline at end of file
diff --git a/Sunfish/Sunfish/Resources/site1.css b/Sunfish/Sunfish/Resources/site1.css
index 51c5a9e..9aac741 100644
--- a/Sunfish/Sunfish/Resources/site1.css
+++ b/Sunfish/Sunfish/Resources/site1.css
@@ -17,7 +17,7 @@
div#main {
background: #FFF;
- box-shadow: 0 2px 5px #777;
+ box-shadow: 0 2px 7px #999;
border: 0px;
border-radius:4px;
font-family:verdana;
@@ -30,6 +30,8 @@
}
img#scr {
+/*
max-width:100%;
max-height:100%;
+*/
}
\ No newline at end of file
diff --git a/Sunfish/Sunfish/wx/WebXplorer.cs b/Sunfish/Sunfish/wx/WebXplorer.cs
index 9f5441b..d46384b 100644
--- a/Sunfish/Sunfish/wx/WebXplorer.cs
+++ b/Sunfish/Sunfish/wx/WebXplorer.cs
@@ -11,6 +11,8 @@
using System.Drawing.Imaging;
using DolphinWebXplorer2.Properties;
using System.Reflection;
+using System.Threading;
+using System.Runtime.InteropServices;
namespace DolphinWebXplorer2.wx
{
@@ -324,12 +326,88 @@
private void Special(string path)
{
- if (path=="screen"){
+ if (path == "screen")
+ {
BlackHeader("Shared Screen", global::DolphinWebXplorer2.Properties.Resources.ShScreen);
- Out.Write("
Password:
");
- Out.Write("
");
+ Out.Write("Password:
");
+ Out.Write("");
BlackFooter();
+ return;
}
+ if (path == "screencap")
+ {
+ 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, 35L);
+ myEncoderParameters.Param[0] = myEncoderParameter;
+ bmp.Save(ms, jgpEncoder, myEncoderParameters);
+ ms.Close();
+ }
+ BinaryOut(ms.ToArray(), "image/jpeg");
+ return;
+ }
+ if (path == "screencmd")
+ {
+ if (GET["code"] != WebXplorer.SharedScreenPassword)
+ return;
+ string cmd = GET["cmd"];
+ if (cmd.Length == 0)
+ return;
+ string par = cmd.Substring(1);
+ 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 (cmd[0])
+ {
+ case 'D':
+ Thread.Sleep(100);
+ mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
+ break;
+ case 'U':
+ Thread.Sleep(100);
+ mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
+ break;
+ case 'W':
+
+ break;
+ }
+ Out.Write("Ok");
+ return;
+ }
+ }
+
+ #region WINAPI
+ private const int MOUSEEVENTF_LEFTDOWN = 0x0002; /* left button down */
+ private const int MOUSEEVENTF_LEFTUP = 0x0004; /* left button up */
+ [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);
+ #endregion
+
+ 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 void GetIcon(WShared sh, string path)