Commit d68509c4 authored by Gaurav Arora (gaa721)'s avatar Gaurav Arora (gaa721)
Browse files

Added If screen is obsured

parent 3835826b
......@@ -34,6 +34,7 @@
this.lblAtt = new System.Windows.Forms.Label();
this.mouseLabel = new System.Windows.Forms.Label();
this.keyboardLabel = new System.Windows.Forms.Label();
this.actWinVis = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
......@@ -84,17 +85,27 @@
// keyboardLabel
//
this.keyboardLabel.AutoSize = true;
this.keyboardLabel.Location = new System.Drawing.Point(518, 117);
this.keyboardLabel.Location = new System.Drawing.Point(518, 109);
this.keyboardLabel.Name = "keyboardLabel";
this.keyboardLabel.Size = new System.Drawing.Size(35, 13);
this.keyboardLabel.TabIndex = 5;
this.keyboardLabel.Text = "label3";
//
// actWinVis
//
this.actWinVis.AutoSize = true;
this.actWinVis.Location = new System.Drawing.Point(518, 134);
this.actWinVis.Name = "actWinVis";
this.actWinVis.Size = new System.Drawing.Size(35, 13);
this.actWinVis.TabIndex = 6;
this.actWinVis.Text = "label4";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(861, 379);
this.Controls.Add(this.actWinVis);
this.Controls.Add(this.keyboardLabel);
this.Controls.Add(this.mouseLabel);
this.Controls.Add(this.lblAtt);
......@@ -117,5 +128,6 @@
private System.Windows.Forms.Label lblAtt;
private System.Windows.Forms.Label mouseLabel;
private System.Windows.Forms.Label keyboardLabel;
private System.Windows.Forms.Label actWinVis;
}
}
\ No newline at end of file
......@@ -93,9 +93,61 @@ namespace FaceDetectionApp
}
private void F_ActiveWindowChanged(object sender, WindowTitle windowHeader, string Windows, IntPtr hwnd)
public Rectangle getRectangle(WindowTitle windowHeader)
{
textBox1.Text = "CURRENT WINDOW:" + windowHeader.Title + "\r\n\r\nVISIBLE WINDOWS:\r\n" + Windows;
return new Rectangle(windowHeader.coordinates.Left, windowHeader.coordinates.Top, Math.Abs(windowHeader.coordinates.Right - windowHeader.coordinates.Left), Math.Abs(windowHeader.coordinates.Bottom - windowHeader.coordinates.Top));
}
public bool instesects(Rect RectA, Rect RectB)
{
return ((RectA.Left <= RectB.Right && RectA.Right >= RectB.Left &&
RectA.Top <= RectB.Bottom && RectA.Bottom >= RectB.Top));
}
public bool insideH(Rect RectA, Rect RectB)
{
return RectB.Right < RectA.Right && RectB.Left > RectA.Left && RectB.Top < RectA.Top && RectB.Bottom > RectB.Bottom;
}
public bool inside(Rect RectA, Rect RectB)
{
return insideH(RectA, RectB) || insideH(RectB,RectA);
}
private void F_ActiveWindowChanged(object sender, WindowTitle windowHeader, List<WindowTitle> windows, IntPtr hwnd)
{
bool Obscured = false;
String obsText = "";
Rectangle r1 = getRectangle(windowHeader);
foreach (WindowTitle w in windows)
{
if (!getRectangle(w).Contains(r1))
{
Console.WriteLine(w.ToString());
}
if (instesects(w.coordinates, windowHeader.coordinates) && (r1 != getRectangle(w)) && !getRectangle(w).Contains(r1) )
{
Obscured = true;
break;
}
}
actWinVis.Text = "Obscured: " + Obscured;
string text = string.Join("\n", windows);
textBox1.Text = "CURRENT WINDOW:" + windowHeader + "\r\n\r\nVISIBLE WINDOWS:\r\n" + text ;
if (!windowHeader.Title.Equals("Form1"))
{
FaceDetector.Instance.isCurrentWindowTheApp = false;
......
......@@ -71,7 +71,7 @@ namespace FaceDetectionApp
}
}
private static void ActiveWindowChangedCallback(object sender, WindowTitle windowHeader, string Windows, IntPtr hwnd)
private static void ActiveWindowChangedCallback(object sender, WindowTitle windowHeader, List<WindowTitle> Windows, IntPtr hwnd)
{
try
{
......
......@@ -52,6 +52,12 @@
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Form2.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form2.Designer.cs">
<DependentUpon>Form2.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
......@@ -71,6 +77,9 @@
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form2.resx">
<DependentUpon>Form2.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
......
namespace FaceDetectionClientConsole
{
partial class Form2
{
/// <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 Windows Form 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.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.ImageLocation = "C:\\Users\\Admin\\Desktop\\CR210.jpg";
this.pictureBox1.Location = new System.Drawing.Point(39, 174);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(52, 53);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Brown;
this.ClientSize = new System.Drawing.Size(1528, 496);
this.Controls.Add(this.pictureBox1);
this.Name = "Form2";
this.Text = "Form2";
this.Load += new System.EventHandler(this.Form2_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
}
}
\ No newline at end of file
using FaceDetectionMain;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FaceDetectionClientConsole
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
pictureBox1.BackColor = System.Drawing.Color.DarkBlue;
FaceDetectionClientConsoel.Program.changes += changeInJSON;
}
public void changeInJSON()
{
//Console.WriteLine(FaceDetectionClientConsoel.Program.message.CurrentTitle.Title);
FaceDetectionClientConsoel.Program.attention = (FaceDetectionClientConsoel.Program.message.CurrectFaceState == FaceState.Face)&& (FaceDetectionClientConsoel.Program.message.CurrentTitle.Title.Equals(this.Text));
//Thread t = new Thread(new ThreadStart(increaseX));
//if (FaceDetectionClientConsoel.Program.attention)
// {
// t.Start();
// }
// else
// t.Abort();
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
}
}
<?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>
</root>
\ No newline at end of file
......@@ -22,16 +22,16 @@ namespace FaceDetectionClientConsoel
class Program
{
public static JSONMessage message;
public static changesMade changes;
public static changesMade changes;// = attentionUpdate ;
public static bool attention;
[STAThread]
static void Main()
{
Init();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FaceDetectionClientConsole.Form1());
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FaceDetectionClientConsole.Form2());
}
......@@ -87,90 +87,14 @@ namespace FaceDetectionClientConsoel
}
Console.ReadLine();
}
}
}
/**
UdpClient udpc = new UdpClient("127.0.0.1", 2055);
IPEndPoint ep = null;
byte[] sdata = Encoding.ASCII.GetBytes("Enter");
udpc.Send(sdata, sdata.Length);
while (true)
{
byte[] rdata = udpc.Receive(ref ep);
string job = Encoding.ASCII.GetString(rdata);
Console.WriteLine(job);
}**/
/*
*
*
* #region stuff from facedetectionmain
public enum FaceState { NoFace, Face }
[DataContract]
public class JSONMessage
{
[DataMember]
public WindowTitle CurrentTitle;
[DataMember]
public string VisibleWindows; //Change this to List<WindowTitle>
[DataMember]
public FaceState CurrectFaceState;
public JSONMessage(WindowTitle currentTitle, string visibleWindows)
{
CurrentTitle = currentTitle;
VisibleWindows = visibleWindows;
}
public JSONMessage(string JSON)
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(JSONMessage));
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(JSON));
JSONMessage obj = (JSONMessage)ser.ReadObject(ms);
this.CurrentTitle = obj.CurrentTitle;
this.VisibleWindows = obj.VisibleWindows;
this.CurrectFaceState = obj.CurrectFaceState;
}
public string ToJSON()
{
MemoryStream stream1 = new MemoryStream();
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(JSONMessage));
ser.WriteObject(stream1, this);
string jsonString = Encoding.UTF8.GetString(stream1.ToArray());
stream1.Close();
return jsonString;
}
public override string ToString()
{
return ToJSON();
}
}
public static void attentionUpdate()
{
// attention = (message.CurrectFaceState == FaceState.Face) && (message.CurrentTitle.ToString() == "Form2");
public struct WindowTitle
{
public string Title;
public string FilePath;
public bool Visible;
public WindowTitle(string title, string fp, bool visible)
{
Title = title;
FilePath = fp;
Visible = visible;
}
}
public override string ToString()
{
return "Title:" + Title + " FilePath:" + FilePath;
}
}
#endregion
*
* */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment