Commit 4ff65cec by Liv Haapala

Updates to various apps

1 parent 5bd9c821
Showing with 2096 additions and 445 deletions
......@@ -24,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
......@@ -33,6 +34,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="AutoUpdateLib, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
......@@ -56,6 +58,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataClasses\ApiCredential.cs" />
<Compile Include="DataClasses\RestClient.cs" />
<Compile Include="Forms\ApiSettings.cs">
<SubType>Form</SubType>
</Compile>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CardDisplay
{
public class ApiCredential
{
public string authname;
public DateTime created;
public bool enabled;
public string secret;
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
namespace CardDisplay
{
public enum HttpVerb
{
GET,
POST,
PUT,
DELETE
}
public class RestClient
{
public string EndPoint { get; set; }
public HttpVerb Method { get; set; }
public string ContentType { get; set; }
public string PostData { get; set; }
public static string ApiApplicationKey;
public static string ApiUser;
public static string ApiPass;
public static string ApiURL;
public RestClient()
{
EndPoint = ApiURL;
Method = HttpVerb.GET;
ContentType = "application/json";
PostData = "";
}
public RestClient(string endpoint)
{
EndPoint = endpoint;
Method = HttpVerb.GET;
ContentType = "application/json";
PostData = "";
}
public RestClient(string endpoint, HttpVerb method)
{
EndPoint = endpoint;
Method = method;
ContentType = "application/json";
PostData = "";
}
public RestClient(string endpoint, HttpVerb method, string postData)
{
EndPoint = endpoint;
Method = method;
ContentType = "application/json";
PostData = postData;
}
public static string CalculateSHA1(string text)
{
// Convert the input string to a byte array
byte[] buffer = Encoding.GetEncoding("iso-8859-1").GetBytes(text);
// In doing your test, you won't want to re-initialize like this every time you test a
// string.
SHA1CryptoServiceProvider cryptoTransformSHA1 =
new SHA1CryptoServiceProvider();
// The replace won't be necessary for your tests so long as you are consistent in what
// you compare.
string hash = BitConverter.ToString(cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", "").ToLower();
return hash;
}
private static int ConvertToTimestamp(DateTime value)
{
//create Timespan by subtracting the value provided from
//the Unix Epoch
TimeSpan span = (value - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime());
//return the total seconds (which is a UNIX timestamp)
return (int)span.TotalSeconds;
}
public static string GetRequestURL(string server, string queryPath)
{
return GetRequestURL(server, queryPath,null);
}
public static string GetRequestURL(string server, string queryPath, string getparms)
{
int timestamp = ConvertToTimestamp(DateTime.Now);
string hash = CalculateSHA1("/" + queryPath + "+" + ApiApplicationKey + "+" + ApiUser + "+" + timestamp + "+" + ApiPass);
if (getparms != null && getparms.Length > 0)
getparms = getparms + "&";
string url = server + "/rest/" + queryPath + "?";
if (getparms != null)
url += getparms;
url += "appkey=" + ApiApplicationKey + "&appuser=" + ApiUser + "&appstamp=" + timestamp + "&appmac=" + hash;
Console.WriteLine(url);
return url;
}
public string MakeRequest(string queryPath)
{
return MakeRequest(queryPath, null);
}
public string MakeRequest(string queryPath, string getparms)
{
///placeadmin/places/30+abcdefg+testuser-asdf+1393735570144+acdcabbacd
///
var request = (HttpWebRequest)WebRequest.Create(GetRequestURL(EndPoint,queryPath,getparms));
request.Method = Method.ToString();
request.ContentLength = 0;
request.ContentType = ContentType;
if (!string.IsNullOrEmpty(PostData) && (Method == HttpVerb.POST || Method == HttpVerb.PUT ))
{
var encoding = new UTF8Encoding();
var bytes = Encoding.GetEncoding("iso-8859-1").GetBytes(PostData);
request.ContentLength = bytes.Length;
using (var writeStream = request.GetRequestStream())
{
writeStream.Write(bytes, 0, bytes.Length);
}
}
try
{
using (var response = (HttpWebResponse)request.GetResponse())
{
var responseValue = string.Empty;
if ((int)response.StatusCode < 200 && (int)response.StatusCode >= 300)
{
var message = String.Format("Request failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
}
// grab the response
//if (response.ContentLength > 0)
//{
using (var responseStream = response.GetResponseStream())
{
if (responseStream != null)
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
//}
return responseValue;
}
}
catch (WebException e)
{
if (e.Status == WebExceptionStatus.ConnectFailure)
throw e;
Stream responseStream = ((WebException)e).Response.GetResponseStream();
if (responseStream != null)
{
string responseValue = StreamToString(responseStream);
Console.WriteLine("Response was " + responseValue);
throw new Exception(responseValue);
}
throw e;
}
}
/// <summary>
/// Convert streams from web to string
/// </summary>
/// <param name="responseStream">Webresponse stream</param>
/// <returns>string</returns>
private string StreamToString(Stream responseStream)
{
StreamReader reader = new StreamReader(responseStream);
string responseString = reader.ReadToEnd();
responseStream.Close();
reader.Close();
return responseString;
}
public static ApiCredential GetApiCredential(string username, string pw, string apiKey, string url)
{
var request = (HttpWebRequest)WebRequest.Create(url+"/rest/apiapp/v1/createInstance/"+apiKey);
/*
NetworkCredential credentials = new NetworkCredential();
credentials.UserName = username;
credentials.Password = pw;
CredentialCache credentialCache = new CredentialCache();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
credentialCache.Add(new System.Uri(url), "Basic", credentials);
request.Credentials = credentialCache;
request.PreAuthenticate = true;
*/
string encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + pw));
request.Headers.Add("Authorization", "Basic " + encoded);
request.Method = "POST";
try
{
using (var response = (HttpWebResponse)request.GetResponse())
{
var responseValue = string.Empty;
if ((int)response.StatusCode < 200 && (int)response.StatusCode >= 300)
{
var message = String.Format("Request failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
}
// grab the response
//if (response.ContentLength > 0)
//{
using (var responseStream = response.GetResponseStream())
{
if (responseStream != null)
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
//}
JavaScriptSerializer ser = new JavaScriptSerializer();
try
{
ApiCredential credential = ser.Deserialize<ApiCredential>(responseValue);
return credential;
} catch(Exception ex)
{
throw ex;
}
}
}
catch (WebException e)
{
throw e;
}
}
} // class
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CardDisplay.Forms
namespace CardDisplay
{
public partial class ApiSettings : Form
{
......@@ -18,21 +12,62 @@ namespace CardDisplay.Forms
private void SaveButton_Click(object sender, EventArgs e)
{
Properties.Settings.Default.ApiURL = apiURLTextBox.Text;
Properties.Settings.Default.ApiKey = ApiKeyTextBox.Text;
Properties.Settings.Default.ApiUser = ApiUserTextBox.Text;
Properties.Settings.Default.ApiPass = ApiPassTextBox.Text;
Properties.Settings.Default.Save();
ApiCredential apiCredential = null;
if (resetApiTokenCheckBox.Checked)
{
try
{
apiCredential = RestClient.GetApiCredential(usernameTextBox.Text, pwTextBox.Text, Properties.Settings.Default.ApiApplicationKey, apiURLTextBox.Text);
}
catch (Exception ex)
{
MessageBox.Show("Failed to get api credentials: " + ex.Message);
}
if (apiCredential != null)
{
Properties.Settings.Default.ApiURL = apiURLTextBox.Text;
Properties.Settings.Default.ApiUser = apiCredential.authname;
Properties.Settings.Default.ApiPass = apiCredential.secret;
Properties.Settings.Default.ApiTokenSet = true;
Properties.Settings.Default.Save();
}
}
RestClient.ApiApplicationKey = Properties.Settings.Default.ApiApplicationKey;
RestClient.ApiPass = Properties.Settings.Default.ApiPass;
RestClient.ApiUser = Properties.Settings.Default.ApiUser;
RestClient.ApiURL = Properties.Settings.Default.ApiURL;
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
private void ApiSettings_Load(object sender, EventArgs e)
{
resetApiTokenCheckBox.Checked = !Properties.Settings.Default.ApiTokenSet;
apiURLTextBox.Text = Properties.Settings.Default.ApiURL;
ApiKeyTextBox.Text = Properties.Settings.Default.ApiKey;
ApiUserTextBox.Text = Properties.Settings.Default.ApiUser;
ApiPassTextBox.Text = Properties.Settings.Default.ApiPass;
//usernameTextBox.Text = Properties.Settings.Default.ApiUser;
//pwTextBox.Text = Properties.Settings.Default.ApiPass;
}
private void resetApiTokenCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (!resetApiTokenCheckBox.Checked)
{
apiURLTextBox.ReadOnly = true;
usernameTextBox.ReadOnly = true;
pwTextBox.ReadOnly = true;
}
else
{
apiURLTextBox.ReadOnly = false;
usernameTextBox.ReadOnly = false;
pwTextBox.ReadOnly = false;
}
}
}
}
......@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
......@@ -19,7 +20,7 @@ namespace CardDisplay
InitializeComponent();
RestClient.ApiURL = Properties.Settings.Default.ApiURL;
RestClient.ApiApplicationKey = Properties.Settings.Default.ApiKey;
RestClient.ApiApplicationKey = Properties.Settings.Default.ApiApplicationKey;
RestClient.ApiUser = Properties.Settings.Default.ApiUser;
RestClient.ApiPass = Properties.Settings.Default.ApiPass;
}
......@@ -159,6 +160,10 @@ namespace CardDisplay
{
ret = client.MakeRequest("reader/readerevents/" + reader.readerId + "/" + slot1ReaderEventId);
ret = ret.Replace("\"printedCardId\":null,", "");
Debug.WriteLine("Ret: " + ret);
var ser = new JavaScriptSerializer();
ReaderEventList events = ser.Deserialize<ReaderEventList>(ret);
events.readerEvents = events.readerEvents.OrderByDescending(r => r.readerEventTime).ToList();
......@@ -218,7 +223,7 @@ namespace CardDisplay
try
{
ret = client.MakeRequest("reader/readerevents/" + reader.readerId + "/" + slot2ReaderEventId);
ret = ret.Replace("\"printedCardId\":null,", "");
var ser = new JavaScriptSerializer();
ReaderEventList events = ser.Deserialize<ReaderEventList>(ret);
events.readerEvents = events.readerEvents.OrderByDescending(r => r.readerEventTime).ToList();
......@@ -278,7 +283,7 @@ namespace CardDisplay
try
{
ret = client.MakeRequest("reader/readerevents/" + reader.readerId + "/" + slot3ReaderEventId);
ret = ret.Replace("\"printedCardId\":null,", "");
var ser = new JavaScriptSerializer();
ReaderEventList events = ser.Deserialize<ReaderEventList>(ret);
events.readerEvents = events.readerEvents.OrderByDescending(r => r.readerEventTime).ToList();
......
......@@ -106,7 +106,7 @@ namespace CardDisplay.Forms
try
{
ret = client.MakeRequest("reader/readerevents/" + reader.readerId + "/" + slot1ReaderEventId);
ret = ret.Replace("\"printedCardId\":null,", "");
var ser = new JavaScriptSerializer();
ReaderEventList events = ser.Deserialize<ReaderEventList>(ret);
events.readerEvents = events.readerEvents.OrderByDescending(r => r.readerEventTime).ToList();
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;
......@@ -11,10 +12,22 @@ namespace CardDisplay
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (!Debugger.IsAttached)
{
if (args.Length == 0 || args[0] != "-noautoupdate")
{
if (AutoUpdateLib.AutoUpdateCore.CheckForUpdates(null))
return; //program is required to close by autoupdate (probably updated)
}
}
Application.Run(new Form1());
}
}
......
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.6.0")]
[assembly: AssemblyFileVersion("1.0.6.0")]
[assembly: AssemblyVersion("1.0.7.0")]
[assembly: AssemblyFileVersion("1.0.7.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18449
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
......
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18449
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
......@@ -12,7 +12,7 @@ namespace CardDisplay.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
......@@ -25,13 +25,13 @@ namespace CardDisplay.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ApiKey {
[global::System.Configuration.DefaultSettingValueAttribute("Nie4xu9eedu8Shaey1bu")]
public string ApiApplicationKey {
get {
return ((string)(this["ApiKey"]));
return ((string)(this["ApiApplicationKey"]));
}
set {
this["ApiKey"] = value;
this["ApiApplicationKey"] = value;
}
}
......@@ -70,5 +70,17 @@ namespace CardDisplay.Properties {
this["ApiPass"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool ApiTokenSet {
get {
return ((bool)(this["ApiTokenSet"]));
}
set {
this["ApiTokenSet"] = value;
}
}
}
}
......@@ -2,8 +2,8 @@
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="CardDisplay.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ApiKey" Type="System.String" Scope="User">
<Value Profile="(Default)" />
<Setting Name="ApiApplicationKey" Type="System.String" Scope="User">
<Value Profile="(Default)">Nie4xu9eedu8Shaey1bu</Value>
</Setting>
<Setting Name="ApiURL" Type="System.String" Scope="User">
<Value Profile="(Default)" />
......@@ -14,5 +14,8 @@
<Setting Name="ApiPass" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ApiTokenSet" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
\ No newline at end of file
......@@ -7,8 +7,8 @@
</configSections>
<userSettings>
<CardDisplay.Properties.Settings>
<setting name="ApiKey" serializeAs="String">
<value />
<setting name="ApiApplicationKey" serializeAs="String">
<value>Nie4xu9eedu8Shaey1bu</value>
</setting>
<setting name="ApiURL" serializeAs="String">
<value />
......@@ -19,6 +19,9 @@
<setting name="ApiPass" serializeAs="String">
<value />
</setting>
<setting name="ApiTokenSet" serializeAs="String">
<value>False</value>
</setting>
</CardDisplay.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
......@@ -2,7 +2,7 @@
<AutoPublishSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UploadUser>f-solu-06</UploadUser>
<UploadPath>/home/f-solu-06/software.f-solutions.fi</UploadPath>
<UploadHost>software.f-solutions.fi</UploadHost>
<UploadHost>www4.f-solutions.fi</UploadHost>
<ProjectName>CardDisplay</ProjectName>
<Customers>
<Customer>
......
......@@ -22,7 +22,7 @@
Name "CardDisplay moya v1_00_06"
Name "CardDisplay moya v1_00_07"
; DO NOT CHANGE OutFile "installer_temp.exe" !!! AutoPublish requires this.
......@@ -198,7 +198,7 @@ FunctionEnd
Section "!CardDisplay moya stable v1_00_06" SecMain
Section "!CardDisplay moya stable v1_00_07" SecMain
SetShellVarContext current
......@@ -225,8 +225,10 @@ Section "!CardDisplay moya stable v1_00_06" SecMain
; that is referenced to the main project.
File "C:\devel\proj\moya-info-tools\CardDisplay\CardDisplay\CardDisplay\bin\Release\MoyaAdminLib.dll"
File "C:\devel\proj\moya-info-tools\CardDisplay\CardDisplay\CardDisplay\bin\Release\AutoUpdateLib.dll"
File "C:\devel\proj\moya-info-tools\CardDisplay\CardDisplay\CardDisplay\bin\Release\CardDisplay.pdb"
File "C:\devel\proj\moya-info-tools\CardDisplay\CardDisplay\CardDisplay\bin\Release\AutoUpdateLib.pdb"
......@@ -315,8 +317,10 @@ Section "Uninstall"
; that is referenced to the main project.
Delete "$INSTDIR\C:\devel\proj\moya-info-tools\CardDisplay\CardDisplay\CardDisplay\bin\Release\MoyaAdminLib.dll"
Delete "$INSTDIR\C:\devel\proj\moya-info-tools\CardDisplay\CardDisplay\CardDisplay\bin\Release\AutoUpdateLib.dll"
Delete "$INSTDIR\C:\devel\proj\moya-info-tools\CardDisplay\CardDisplay\CardDisplay\bin\Release\CardDisplay.pdb"
Delete "$INSTDIR\C:\devel\proj\moya-info-tools\CardDisplay\CardDisplay\CardDisplay\bin\Release\AutoUpdateLib.pdb"
......
......@@ -9,6 +9,10 @@ using System.Windows.Forms;
using System.Web.Script.Serialization;
using System.Net;
using System.Collections.Specialized;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;
using System.Diagnostics;
namespace ImageResizer
{
......@@ -216,6 +220,8 @@ namespace ImageResizer
}
private bool _suspendRefresh = false;
HaarCascade face;
#endregion
#region Constructors
......@@ -227,6 +233,8 @@ namespace ImageResizer
// Save in full quality
_encoderParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
// Find the codecs for the supported formats, set the open and save dialog filters
string displayFilters = string.Empty;
int codecCount = 0;
......@@ -315,6 +323,8 @@ namespace ImageResizer
if (!SuspendRefresh && DrawnImage != null)
{
// if( the image is too large, draw only visible portion as dictated by the scrollbars, otherwise draw the whole image.
if (DrawnImage.Width > grpImage.Width || DrawnImage.Height > grpImage.Height)
{
......@@ -338,8 +348,11 @@ namespace ImageResizer
// Draw the crop rectangle with both yellow and black so it is easily visible no matter the image.
if (chkCrop.Checked)
{
e.Graphics.DrawRectangle(Pens.Yellow, CropBoxX, CropBoxY, (float)nudCropWidth.Value, (float)nudCropHeight.Value);
e.Graphics.DrawRectangle(Pens.Black, CropBoxX - 1, CropBoxY - 1, (float)nudCropWidth.Value + 2, (float)nudCropHeight.Value + 2);
if (!RecognizeFaceAndDrawCropBox(DrawnImage, e.Graphics))
{
e.Graphics.DrawRectangle(Pens.Yellow, CropBoxX, CropBoxY, (float)nudCropWidth.Value, (float)nudCropHeight.Value);
e.Graphics.DrawRectangle(Pens.Black, CropBoxX - 1, CropBoxY - 1, (float)nudCropWidth.Value + 2, (float)nudCropHeight.Value + 2);
}
}
}
}
......@@ -830,10 +843,21 @@ namespace ImageResizer
private void ImageResizer_Load(object sender, EventArgs e)
{
if(selectedUser != null)
try
{
face = new HaarCascade("haarcascade_frontalface_default.xml");
} catch (Exception ex)
{
Console.WriteLine("Failed to setup face recognizion: " + ex.Message);
}
if (selectedUser != null)
{
SelectUser(selectedUser);
}
}
......@@ -857,8 +881,7 @@ namespace ImageResizer
Card card = ser.Deserialize<Card>(json);
//string url = RestClient.GetRequestURL(defaultApiUrl, "card/GetImage/" + card.id);
if (card.state == "PENDING_VALIDATION" ||
card.state == "REJECTED")
if (card.state == "PENDING_VALIDATION")
{
selectedUser = user;
string url = RestClient.GetRequestURL(defaultApiUrl, "v2/user/" + user.UserId + "/image");
......@@ -904,8 +927,7 @@ namespace ImageResizer
Card card = ser.Deserialize<Card>(json);
//string url = RestClient.GetRequestURL(defaultApiUrl, "card/GetImage/" + card.id);
if (card.state == "PENDING_VALIDATION" ||
card.state == "REJECTED")
if (card != null && card.state == "PENDING_VALIDATION")
{
selectedUser = user;
string url = RestClient.GetRequestURL(defaultApiUrl, "v2/user/" + user.UserId + "/image");
......@@ -944,6 +966,92 @@ namespace ImageResizer
selectNextUser();
}
private bool RecognizeFaceAndDrawCropBox(Bitmap faceImage, Graphics g)
{
if (face != null)
{
Image<Bgr, Byte> currentFrame = new Image<Bgr, byte>(faceImage);
Image<Gray, byte> gray = null;
gray = currentFrame.Convert<Gray, Byte>();
MCvAvgComp[][] facesDetected = null;
if (gray != null)
{
//Face Detector
facesDetected = gray.DetectHaarCascade(
face,
1.1,
10,
Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
new Size(50, 50));
}
//Action for each element detected
if (facesDetected != null && facesDetected[0].Length > 0)
{
Debug.WriteLine("[imageresizer] Face dedected!");
MCvAvgComp f = facesDetected[0][0];
//decimal width = ((decimal)f.rect.Width) * 3.1M;
//decimal width = ((decimal)f.rect.Width) * 2.8M;
decimal scale = 1.4M; // use this to define size for crop box
int width = (int)(f.rect.Width * scale);
//decimal height = ((decimal)f.rect.Height);
int height = (int)(f.rect.Width * scale * 1.36774193548M);
if (height > faceImage.Height) height = faceImage.Height;
if (width > faceImage.Width) width = faceImage.Width;
int y = f.rect.Y - (int)((height - f.rect.Height) / 2); // calculate new horisontal centerline
int x = f.rect.X - (int)((width - f.rect.Width) / 2); // calculate new vertical center line (not needed if scale is 1)
//g.DrawRectangle(Pens.Blue, f.rect.X, f.rect.Y, f.rect.Width, f.rect.Height);
//g.DrawLine(Pens.Red, f.rect.X, f.rect.Y + (f.rect.Height /2), f.rect.X + f.rect.Width , f.rect.Y + (f.rect.Height / 2));
// allow offset, do not allow thing go outside of picture
if (y < 0) y = 0;
if (y + (int)height > faceImage.Height) y = faceImage.Height - (int)height;
if (x < 0) x = 0;
if (x + (int)width > faceImage.Width) x = faceImage.Width - (int)width;
Debug.WriteLine("[imageresizer] Crop: x: " + x.ToString() + ", y: " + y.ToString() + ", width: " + width.ToString() + ", height: " + height + ", faceImage.Width: " + faceImage.Width.ToString() + ", faceImage.Height: " + faceImage.Height);
if (x + (int)width <= faceImage.Width && y + (int)height <= faceImage.Height && x >= 0 && y >= 0)
{
//Debug.WriteLine("[imageresizer] Crop: x: " + x.ToString() + ", y: " + y.ToString() + ", width: " + width.ToString() + ", height: " + height);
Rectangle cropRect = new Rectangle(x, y, (int)width, (int)height);
Image<Bgr, byte> croppedImage = currentFrame.Copy(cropRect);
croppedImage = croppedImage.Resize(310, 424, INTER.CV_INTER_CUBIC);
//Debug.WriteLine("[takepictureform] Adding score '" + score + "' to croppedImageDictionary.");
g.DrawRectangle(Pens.Yellow, x, y, (float) width, (float)height);
g.DrawRectangle(Pens.Black, x - 1, y - 1, (float)width + 2, (float)height + 2);
return true;
} else
{
Debug.WriteLine("[imageresizer] Failed to draw crop box!");
}
}
} else
{
Debug.WriteLine("[imageresizer] Couldn't dedect faces, something wrong with initializon!");
}
return false;
}
private void cropButton_Click(object sender, EventArgs e)
{
_editedImage = new Bitmap((int)nudCropWidth.Value, (int)nudCropHeight.Value);
......
......@@ -40,6 +40,21 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Emgu.CV">
<HintPath>Resources\Emgu.CV.dll</HintPath>
</Reference>
<Reference Include="Emgu.CV.GPU">
<HintPath>Resources\Emgu.CV.GPU.dll</HintPath>
</Reference>
<Reference Include="Emgu.CV.ML">
<HintPath>Resources\Emgu.CV.ML.dll</HintPath>
</Reference>
<Reference Include="Emgu.CV.UI">
<HintPath>Resources\Emgu.CV.UI.dll</HintPath>
</Reference>
<Reference Include="Emgu.Util">
<HintPath>Resources\Emgu.Util.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
......@@ -95,6 +110,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="photo_portrait.ico" />
<Content Include="Resources\haarcascade_frontalface_default.xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\MoyaAdminLib\MoyaAdminLib.csproj">
......
......@@ -36,6 +36,7 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
namespace MoyaAdminLib
......@@ -11,7 +12,7 @@ namespace MoyaAdminLib
public DateTime readerEventTime = DateTime.MinValue;
public int readerId = 0;
public Eventuser eventuser;
public int printedCardId = 0;
public int? printedCardId = 0;
public string printedCardState = "";
}
}
......@@ -28,7 +28,6 @@
/// </summary>
private void InitializeComponent()
{
this.moyaCsvOpenFileDialog = new System.Windows.Forms.OpenFileDialog();
this.GoogleCsvOpenFileDialog = new System.Windows.Forms.OpenFileDialog();
this.moyaCsvTextBox = new System.Windows.Forms.TextBox();
this.googleCsvTextBox = new System.Windows.Forms.TextBox();
......@@ -38,12 +37,9 @@
this.label3 = new System.Windows.Forms.Label();
this.resultTextBox = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.moyaCsvOpenFileDialog = new System.Windows.Forms.OpenFileDialog();
this.SuspendLayout();
//
// moyaCsvOpenFileDialog
//
this.moyaCsvOpenFileDialog.FileName = "openFileDialog1";
//
// GoogleCsvOpenFileDialog
//
this.GoogleCsvOpenFileDialog.FileName = "openFileDialog2";
......@@ -111,6 +107,10 @@
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// moyaCsvOpenFileDialog
//
this.moyaCsvOpenFileDialog.FileName = "openFileDialog1";
//
// CSVGeneratorForItemCollectionForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
......@@ -132,8 +132,6 @@
}
#endregion
private System.Windows.Forms.OpenFileDialog moyaCsvOpenFileDialog;
private System.Windows.Forms.OpenFileDialog GoogleCsvOpenFileDialog;
private System.Windows.Forms.TextBox moyaCsvTextBox;
private System.Windows.Forms.TextBox googleCsvTextBox;
......@@ -143,5 +141,6 @@
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox resultTextBox;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.OpenFileDialog moyaCsvOpenFileDialog;
}
}
\ No newline at end of file
......@@ -25,7 +25,7 @@ namespace MoyaAdminUI
string resultCSV;
StringWriter writer = new StringWriter();
string[] headers = new string[3];
string[] headers = new string[4];
......@@ -48,6 +48,7 @@ namespace MoyaAdminUI
headers[0] = "Nimi";
headers[1] = "Sähköposti";
headers[2] = "Tuotteet";
headers[3] = "Ei tulossa";
//CsvWriter.Write(writer, )
}
}
......@@ -61,16 +62,19 @@ namespace MoyaAdminUI
string name = null;
string email = null;
string items = null;
bool notComing = false;
string[] newLine = new string[3];
string[] newLine = new string[4];
Dictionary<string, string> nameToNameDict = new Dictionary<string, string>();
List<string> namesAddedToLines = new List<string>();
List<string> emailsAddedToLines = new List<string>();
CultureInfo provider = new CultureInfo("en-US");
foreach (ICsvLine line in CsvReader.ReadFromText(strMoyaCsv))
{
notComing = false;
string kpl = line["Kpl"];
decimal amount = decimal.Parse(kpl, NumberStyles.AllowDecimalPoint, provider);
......@@ -91,6 +95,7 @@ namespace MoyaAdminUI
foreach (ICsvLine line2 in CsvReader.ReadFromText(strGoogleCsv))
{
if (line2["Nimi"].ToLower() == name.ToLower() ||
line2["Nimi"].ToLower().Contains(name.ToLower()) ||
line2["Email Address"].ToLower() == email.ToLower())
{
found = true;
......@@ -102,6 +107,12 @@ namespace MoyaAdminUI
else
items += "Miesten malli, ";
items += line2["Järkkäpaidan koko"];
if (line2["Ei tulossa/Perunut"] == "X")
notComing = true;
if (!nameToNameDict.Keys.Contains(name))
nameToNameDict.Add(name, line2["Nimi"]);
else
Debug.WriteLine("Name " + name + " already added to dict.");
}
}
......@@ -131,13 +142,21 @@ namespace MoyaAdminUI
newLine[2] = "";
Debug.WriteLine("Items is null!");
}
if (notComing)
newLine[3] = "X";
else
newLine[3] = "";
if(newLine != null)
lines.Add(newLine);
if(!namesAddedToLines.Contains(name))
namesAddedToLines.Add(name);
if (!emailsAddedToLines.Contains(email))
emailsAddedToLines.Add(email);
newLine = new string[3];
newLine = new string[4];
name = line["Nimi"];
email = line["Sähköposti"];
......@@ -147,9 +166,11 @@ namespace MoyaAdminUI
foreach (ICsvLine line2 in CsvReader.ReadFromText(strGoogleCsv))
{
if(!namesAddedToLines.Contains(line2["Nimi"]) )
if(!namesAddedToLines.Contains(line2["Nimi"]) &&
!emailsAddedToLines.Contains(line2["Email Address"]) &&
!nameToNameDict.Values.Contains(line2["Nimi"]))
{
newLine = new string[3];
newLine = new string[4];
if (line2["Nimi"] != null)
newLine[0] = line2["Nimi"];
else
......@@ -171,8 +192,13 @@ namespace MoyaAdminUI
newLine[2] = item;
else
newLine[2] = "";
if(newLine != null)
if (line2["Ei tulossa/Perunut"] == "X")
newLine[3] = "X";
else
newLine[3] = "";
if (newLine != null)
lines.Add(newLine);
}
}
writer = new StringWriter();
......
......@@ -117,13 +117,13 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="moyaCsvOpenFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="GoogleCsvOpenFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>201, 17</value>
</metadata>
<metadata name="selectFileToSaveOpenFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>395, 17</value>
</metadata>
<metadata name="moyaCsvOpenFileDialog.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
......@@ -53,6 +53,10 @@
this.previewTextBox = new System.Windows.Forms.TextBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.messageToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.label10 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.booksNumberNumericUpDown)).BeginInit();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.lastAddedBookNumericUpDown)).BeginInit();
......@@ -299,9 +303,9 @@
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.messageToolStripStatusLabel});
this.statusStrip1.Location = new System.Drawing.Point(0, 267);
this.statusStrip1.Location = new System.Drawing.Point(0, 272);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(280, 22);
this.statusStrip1.Size = new System.Drawing.Size(595, 22);
this.statusStrip1.TabIndex = 29;
this.statusStrip1.Text = "Status";
//
......@@ -311,11 +315,47 @@
this.messageToolStripStatusLabel.Size = new System.Drawing.Size(39, 17);
this.messageToolStripStatusLabel.Text = "Status";
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.listView1.FullRowSelect = true;
this.listView1.Location = new System.Drawing.Point(280, 27);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(303, 225);
this.listView1.TabIndex = 30;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.listView1_KeyUp);
//
// columnHeader1
//
this.columnHeader1.Text = "Nimi";
this.columnHeader1.Width = 99;
//
// columnHeader2
//
this.columnHeader2.Text = "Nick";
this.columnHeader2.Width = 106;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(280, 8);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(69, 13);
this.label10.TabIndex = 31;
this.label10.Text = "Printed cards";
//
// CardLocationInput
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(280, 289);
this.ClientSize = new System.Drawing.Size(595, 294);
this.Controls.Add(this.label10);
this.Controls.Add(this.listView1);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.label6);
......@@ -372,5 +412,9 @@
private System.Windows.Forms.TextBox previewTextBox;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel messageToolStripStatusLabel;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.Label label10;
}
}
\ No newline at end of file
......@@ -30,6 +30,42 @@ namespace MoyaAdminUI
private void CardLocationInput_Load(object sender, EventArgs e)
{
updatePreviewTextBox();
loadPrintedCards();
}
private void loadPrintedCards()
{
List<Card> cards = new List<Card>();
foreach (User user in User.Cache)
{
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
string ret = "";
try
{
ret = client.MakeRequest("user/card/" + user.EventUserId);
var ser = new JavaScriptSerializer();
Card card = ser.Deserialize<Card>(ret);
if (card != null && card.state == "PRINTED")
{
cards.Add(card);
continue;
}
}
catch (Exception ex)
{
continue;
}
}
cards = cards.OrderBy(c => c.wholeName).ToList();
foreach(Card card in cards)
{
ListViewItem lvi = new ListViewItem(card.wholeName);
lvi.SubItems.Add(card.username);
lvi.Tag = card;
listView1.Items.Add(lvi);
}
}
private void barcodeTextBox_TextChanged(object sender, EventArgs e)
......@@ -53,48 +89,21 @@ namespace MoyaAdminUI
if (id != 0)
{
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
string ret = client.MakeRequest("card/Get/" + id);
var ser = new JavaScriptSerializer();
Card card = ser.Deserialize<Card>(ret);
int lastAddedBook = (int)booksNumberNumericUpDown.Value;
int lastAddedPage = (int)pageNumberNumericUpDown.Value;
int lastAddedSlot = (int)slotsNumberNumericUpDown.Value;
string value = "";
if (prefixTextBox.Text != "")
value = prefixTextBox.Text + ".";
value += booksNumberNumericUpDown.Value.ToString() + "." + pageNumberNumericUpDown.Value.ToString() + "." + slotsNumberNumericUpDown.Value.ToString();
if ((slotsNumberNumericUpDown.Value + 1) > numberOfCardSlotsnumericUpDown.Value)
{
slotsNumberNumericUpDown.Value = 1;
pageNumberNumericUpDown.Value++;
}
else
slotsNumberNumericUpDown.Value++;
string json = "{\"" + key + "\":\"" + value + "\"}";
RestClient client2 = new RestClient(Properties.Settings.Default.ApiURL, HttpVerb.PUT, json);
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
string ret = null;
try
{
client2.MakeRequest("meta/v1/printedcard/" + card.id + "/card-filing");
}
catch (ApplicationException ex)
ret = client.MakeRequest("card/Get/" + id);
}catch (Exception ex)
{
if (!ex.Message.Contains("HTTP NoContent"))
return;
messageToolStripStatusLabel.Text = "Viivakoodin lukeminen ei onnistunut!";
return;
}
var ser = new JavaScriptSerializer();
Card card = ser.Deserialize<Card>(ret);
lastAddedMeta = card;
lastAddedBookNumericUpDown.Value = lastAddedBook;
lastAddedPageNumericUpDown.Value = lastAddedPage;
lastAddedSlotsNumericUpDown.Value = lastAddedSlot;
messageToolStripStatusLabel.Text = "Viimeisin lisätty value: " + value + " kortille: " + card.Label();
addMetaToCard(card);
}
else
messageToolStripStatusLabel.Text = "Viivakoodin lukeminen ei onnistunut!";
......@@ -132,5 +141,61 @@ namespace MoyaAdminUI
barcodeTextBox.Focus();
}
private void listView1_KeyUp(object sender, KeyEventArgs e)
{
if(e.KeyData == Keys.Enter && listView1.SelectedItems != null && listView1.SelectedItems.Count == 1)
{
if(listView1.SelectedItems[0].Tag is Card)
{
Card card = (Card)listView1.SelectedItems[0].Tag;
addMetaToCard(card);
int index = listView1.SelectedIndices[0];
index = index + 1;
if(index < listView1.Items.Count)
this.listView1.Items[index].Selected = true;
}
}
}
private void addMetaToCard(Card card)
{
int lastAddedBook = (int)booksNumberNumericUpDown.Value;
int lastAddedPage = (int)pageNumberNumericUpDown.Value;
int lastAddedSlot = (int)slotsNumberNumericUpDown.Value;
string value = "";
if (prefixTextBox.Text != "")
value = prefixTextBox.Text + ".";
value += booksNumberNumericUpDown.Value.ToString() + "." + pageNumberNumericUpDown.Value.ToString() + "." + slotsNumberNumericUpDown.Value.ToString();
if ((slotsNumberNumericUpDown.Value + 1) > numberOfCardSlotsnumericUpDown.Value)
{
slotsNumberNumericUpDown.Value = 1;
pageNumberNumericUpDown.Value++;
}
else
slotsNumberNumericUpDown.Value++;
string json = "{\"" + key + "\":\"" + value + "\"}";
RestClient client2 = new RestClient(Properties.Settings.Default.ApiURL, HttpVerb.PUT, json);
try
{
client2.MakeRequest("meta/v1/printedcard/" + card.id + "/card-filing");
}
catch (ApplicationException ex)
{
if (!ex.Message.Contains("HTTP NoContent"))
return;
}
lastAddedMeta = card;
lastAddedBookNumericUpDown.Value = lastAddedBook;
lastAddedPageNumericUpDown.Value = lastAddedPage;
lastAddedSlotsNumericUpDown.Value = lastAddedSlot;
messageToolStripStatusLabel.Text = "Viimeisin lisätty value: " + value + " kortille: " + card.Label();
}
}
}
namespace MoyaAdminUI
{
partial class GetListOfUsersWithUnlinkedPlacesForm
{
/// <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.label1 = new System.Windows.Forms.Label();
this.moyaCsvTextBox = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.resultTextBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.moyaCsvOpenFileDialog = new System.Windows.Forms.OpenFileDialog();
this.selectFileToSaveOpenFileDialog = new System.Windows.Forms.OpenFileDialog();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(38, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(57, 13);
this.label1.TabIndex = 8;
this.label1.Text = "Moya CSV";
//
// moyaCsvTextBox
//
this.moyaCsvTextBox.Location = new System.Drawing.Point(101, 6);
this.moyaCsvTextBox.Name = "moyaCsvTextBox";
this.moyaCsvTextBox.Size = new System.Drawing.Size(176, 20);
this.moyaCsvTextBox.TabIndex = 6;
//
// button1
//
this.button1.Location = new System.Drawing.Point(202, 58);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 12;
this.button1.Text = "Get CSV";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// resultTextBox
//
this.resultTextBox.Location = new System.Drawing.Point(101, 32);
this.resultTextBox.Name = "resultTextBox";
this.resultTextBox.Size = new System.Drawing.Size(176, 20);
this.resultTextBox.TabIndex = 10;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(58, 35);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(37, 13);
this.label3.TabIndex = 11;
this.label3.Text = "Result";
//
// moyaCsvOpenFileDialog
//
this.moyaCsvOpenFileDialog.FileName = "openFileDialog1";
//
// selectFileToSaveOpenFileDialog
//
this.selectFileToSaveOpenFileDialog.FileName = "openFileDialog2";
//
// GetListOfUsersWithUnlinkedPlacesForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(288, 98);
this.Controls.Add(this.button1);
this.Controls.Add(this.label3);
this.Controls.Add(this.resultTextBox);
this.Controls.Add(this.label1);
this.Controls.Add(this.moyaCsvTextBox);
this.Name = "GetListOfUsersWithUnlinkedPlacesForm";
this.Text = "GetListOfUsersWithUnlinkedPlacesForm";
this.Load += new System.EventHandler(this.GetListOfUsersWithUnlinkedPlacesForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox moyaCsvTextBox;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox resultTextBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.OpenFileDialog moyaCsvOpenFileDialog;
private System.Windows.Forms.OpenFileDialog selectFileToSaveOpenFileDialog;
}
}
\ No newline at end of file
using Csv;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MoyaAdminUI
{
public partial class GetListOfUsersWithUnlinkedPlacesForm : Form
{
public GetListOfUsersWithUnlinkedPlacesForm()
{
InitializeComponent();
}
List<string> logins;
string moyaCSV;
string resultCSV;
StringWriter writer = new StringWriter();
string[] headers = new string[1];
public List<string> SetLoginsList
{
set { logins = value; }
}
private void GetListOfUsersWithUnlinkedPlacesForm_Load(object sender, EventArgs e)
{
if (moyaCsvOpenFileDialog.ShowDialog() == DialogResult.OK)
{
moyaCSV = moyaCsvOpenFileDialog.FileName;
moyaCsvTextBox.Text = moyaCSV;
}
if (selectFileToSaveOpenFileDialog.ShowDialog() == DialogResult.OK)
{
resultCSV = selectFileToSaveOpenFileDialog.FileName;
resultTextBox.Text = resultCSV;
headers[0] = "Sähköposti";
//CsvWriter.Write(writer, )
}
}
private void button1_Click(object sender, EventArgs e)
{
List<string[]> lines = new List<string[]>();
string strMoyaCsv = File.ReadAllText(moyaCSV);
string[] newLine = new string[1];
List<string> emails = new List<string>();
foreach(string login in logins)
{
foreach (ICsvLine line in CsvReader.ReadFromText(strMoyaCsv))
{
if(line["Login"] == login)
{
emails.Add(line["Email"]);
break;
}
}
}
foreach(string email in emails)
{
lines.Add(new string[] { email });
}
writer = new StringWriter();
CsvWriter.Write(writer, headers, lines.ToArray(), ':');
string result = writer.ToString();
File.WriteAllText(resultCSV, result);
if(lines.Count > 0)
{
MessageBox.Show("Wrote " + lines.Count.ToString() + " lines to file " + resultCSV);
this.DialogResult = DialogResult.OK;
this.Close();
} else
{
MessageBox.Show("No lines to write");
}
}
}
}
<?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>
<metadata name="moyaCsvOpenFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="selectFileToSaveOpenFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>619, 17</value>
</metadata>
</root>
\ No newline at end of file
......@@ -47,6 +47,7 @@
this.imageResizer1.RequiredWidth = 0;
this.imageResizer1.Size = new System.Drawing.Size(958, 936);
this.imageResizer1.TabIndex = 0;
this.imageResizer1.Load += new System.EventHandler(this.imageResizer1_Load);
//
// ImageCropForm
//
......
......@@ -50,5 +50,10 @@ namespace MoyaAdminUI
imageResizer1.SelectUser(selectedUser);
}
}
private void imageResizer1_Load(object sender, EventArgs e)
{
}
}
}
......@@ -54,8 +54,9 @@
this.orgMealToolStripButton = new System.Windows.Forms.ToolStripButton();
this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
this.cropImageToolStripButton = new System.Windows.Forms.ToolStripButton();
this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
this.getListOfUnlinkedComputerPlacesToolStripButton = new System.Windows.Forms.ToolStripButton();
this.generateBacksidesToolStripButton = new System.Windows.Forms.ToolStripButton();
this.toolStripButton4 = new System.Windows.Forms.ToolStripButton();
this.TopPanel = new System.Windows.Forms.Panel();
this.allPlacesCountTextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
......@@ -71,7 +72,7 @@
this.ImageRefreshTimer = new System.Windows.Forms.Timer(this.components);
this.panel2 = new System.Windows.Forms.Panel();
this.placesCountTimer = new System.Windows.Forms.Timer(this.components);
this.toolStripButton4 = new System.Windows.Forms.ToolStripButton();
this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
this.placesContextMenuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.MapPictureBox)).BeginInit();
this.toolStrip1.SuspendLayout();
......@@ -189,9 +190,10 @@
this.orgMealToolStripButton,
this.toolStripButton2,
this.cropImageToolStripButton,
this.toolStripButton3,
this.getListOfUnlinkedComputerPlacesToolStripButton,
this.generateBacksidesToolStripButton,
this.toolStripButton4});
this.toolStripButton4,
this.toolStripButton3});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(1078, 25);
......@@ -328,16 +330,15 @@
this.cropImageToolStripButton.Text = "Crop Image tool";
this.cropImageToolStripButton.Click += new System.EventHandler(this.cropImageToolStripButton_Click);
//
// toolStripButton3
// getListOfUnlinkedComputerPlacesToolStripButton
//
this.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image")));
this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton3.Name = "toolStripButton3";
this.toolStripButton3.Size = new System.Drawing.Size(23, 22);
this.toolStripButton3.Text = "Get list of computer places that are not linked to user";
this.toolStripButton3.Visible = false;
this.toolStripButton3.Click += new System.EventHandler(this.toolStripButton3_Click_1);
this.getListOfUnlinkedComputerPlacesToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.getListOfUnlinkedComputerPlacesToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("getListOfUnlinkedComputerPlacesToolStripButton.Image")));
this.getListOfUnlinkedComputerPlacesToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.getListOfUnlinkedComputerPlacesToolStripButton.Name = "getListOfUnlinkedComputerPlacesToolStripButton";
this.getListOfUnlinkedComputerPlacesToolStripButton.Size = new System.Drawing.Size(23, 22);
this.getListOfUnlinkedComputerPlacesToolStripButton.Text = "Get list of computer places that are not linked to user";
this.getListOfUnlinkedComputerPlacesToolStripButton.Click += new System.EventHandler(this.getListOfUnlinkedComputerPlacesToolStripButton_Click);
//
// generateBacksidesToolStripButton
//
......@@ -350,6 +351,16 @@
this.generateBacksidesToolStripButton.Visible = false;
this.generateBacksidesToolStripButton.Click += new System.EventHandler(this.generateBacksidesToolStripButton_Click);
//
// toolStripButton4
//
this.toolStripButton4.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton4.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton4.Image")));
this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton4.Name = "toolStripButton4";
this.toolStripButton4.Size = new System.Drawing.Size(23, 22);
this.toolStripButton4.Text = "Generate CSV for item collection";
this.toolStripButton4.Click += new System.EventHandler(this.toolStripButton4_Click);
//
// TopPanel
//
this.TopPanel.Controls.Add(this.allPlacesCountTextBox);
......@@ -481,15 +492,15 @@
this.placesCountTimer.Interval = 600000000;
this.placesCountTimer.Tick += new System.EventHandler(this.placesCountTimer_Tick);
//
// toolStripButton4
// toolStripButton3
//
this.toolStripButton4.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton4.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton4.Image")));
this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton4.Name = "toolStripButton4";
this.toolStripButton4.Size = new System.Drawing.Size(23, 22);
this.toolStripButton4.Text = "Generate CSV for item collection";
this.toolStripButton4.Click += new System.EventHandler(this.toolStripButton4_Click);
this.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image")));
this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton3.Name = "toolStripButton3";
this.toolStripButton3.Size = new System.Drawing.Size(23, 22);
this.toolStripButton3.Text = "Get Printed Cards CSV";
this.toolStripButton3.Click += new System.EventHandler(this.toolStripButton3_Click_2);
//
// MainForm
//
......@@ -561,10 +572,11 @@
private System.Windows.Forms.ToolStripButton toolStripButton2;
private System.Windows.Forms.ToolStripMenuItem printPlaceStickersForSelectedPlacesToolStripMenuItem;
private System.Windows.Forms.ToolStripButton cropImageToolStripButton;
private System.Windows.Forms.ToolStripButton toolStripButton3;
private System.Windows.Forms.ToolStripButton getListOfUnlinkedComputerPlacesToolStripButton;
private System.Windows.Forms.ToolStripMenuItem doAReplaceForComputerPlaceNameToolStripMenuItem;
private System.Windows.Forms.ToolStripButton generateBacksidesToolStripButton;
private System.Windows.Forms.ToolStripButton toolStripButton4;
private System.Windows.Forms.ToolStripButton toolStripButton3;
}
}
......@@ -12,6 +12,7 @@ using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
namespace MoyaAdminUI
......@@ -1537,25 +1538,7 @@ namespace MoyaAdminUI
private void toolStripButton3_Click_1(object sender, EventArgs e)
{
List<User> unmappedUsers = new List<User>();
foreach(ComputerPlace place in ComputerPlace.Cache)
{
if (place.APIReference != null && place.APIReference.eventuserId <= 0)
{
foreach (User user in User.Cache)
{
if (!unmappedUsers.Contains(user) && user.EventUserId == place.ReserverId)
{
unmappedUsers.Add(user);
break;
}
}
}
}
ListUsersForm frm = new ListUsersForm();
frm.Users = unmappedUsers;
frm.Show();
}
private void doAReplaceForComputerPlaceNameToolStripMenuItem_Click(object sender, EventArgs e)
......@@ -1591,5 +1574,34 @@ namespace MoyaAdminUI
CSVGeneratorForItemCollectionForm frm = new CSVGeneratorForItemCollectionForm();
frm.Show();
}
private void getListOfUnlinkedComputerPlacesToolStripButton_Click(object sender, EventArgs e)
{
List<string> logins = new List<string>();
foreach(ListViewItem lvi in PlacesListView.Items)
{
if(lvi.Tag is ComputerPlace)
{
ComputerPlace place = (ComputerPlace)lvi.Tag;
if(place.APIReference != null && place.APIReference.eventuserId <= 0)
{
if (place.User != null)
{
if (!logins.Contains(place.User.Login))
logins.Add(place.User.Login);
}
}
}
}
GetListOfUsersWithUnlinkedPlacesForm frm = new GetListOfUsersWithUnlinkedPlacesForm();
frm.SetLoginsList = logins;
frm.Show();
}
private void toolStripButton3_Click_2(object sender, EventArgs e)
{
}
}
}
......@@ -115,6 +115,12 @@
<Compile Include="CSVGeneratorForItemCollectionForm.Designer.cs">
<DependentUpon>CSVGeneratorForItemCollectionForm.cs</DependentUpon>
</Compile>
<Compile Include="GetListOfUsersWithUnlinkedPlacesForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GetListOfUsersWithUnlinkedPlacesForm.Designer.cs">
<DependentUpon>GetListOfUsersWithUnlinkedPlacesForm.cs</DependentUpon>
</Compile>
<Compile Include="ImageCropForm.cs">
<SubType>Form</SubType>
</Compile>
......@@ -209,6 +215,9 @@
<EmbeddedResource Include="CSVGeneratorForItemCollectionForm.resx">
<DependentUpon>CSVGeneratorForItemCollectionForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GetListOfUsersWithUnlinkedPlacesForm.resx">
<DependentUpon>GetListOfUsersWithUnlinkedPlacesForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ImageCropForm.resx">
<DependentUpon>ImageCropForm.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.28")]
[assembly: AssemblyFileVersion("1.0.28")]
[assembly: AssemblyVersion("1.0.29")]
[assembly: AssemblyFileVersion("1.0.29")]
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
This diff could not be displayed because it is too large.
<?xml version="1.0" encoding="utf-8"?>
<AutoPublishSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AutoPublishSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UploadUser>f-solu-06</UploadUser>
<PrivateKeyPath />
<UploadPath>/home/f-solu-06/software.f-solutions.fi</UploadPath>
<UploadHost>www4.f-solutions.fi</UploadHost>
<ProjectName>MoyaAdminUI</ProjectName>
......
namespace MoyaSignup
{
partial class AdvancedMessageBox
{
/// <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.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(191, 186);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 1;
this.label1.Text = "label1";
this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// AdvancedMessageBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(469, 221);
this.ControlBox = false;
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "AdvancedMessageBox";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "AdvancedMessageBox";
this.TopMost = true;
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MoyaSignup
{
public partial class AdvancedMessageBox : Form
{
public AdvancedMessageBox(string text)
{
label1.Text = text;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
<?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
......@@ -31,8 +31,6 @@
this.apiURLTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.SaveButton = new System.Windows.Forms.Button();
this.ApiKeyTextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.usernameTextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
......@@ -79,7 +77,7 @@
// SaveButton
//
this.SaveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.SaveButton.Location = new System.Drawing.Point(257, 655);
this.SaveButton.Location = new System.Drawing.Point(257, 595);
this.SaveButton.Name = "SaveButton";
this.SaveButton.Size = new System.Drawing.Size(75, 23);
this.SaveButton.TabIndex = 2;
......@@ -87,23 +85,6 @@
this.SaveButton.UseVisualStyleBackColor = true;
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
//
// ApiKeyTextBox
//
this.ApiKeyTextBox.Location = new System.Drawing.Point(6, 157);
this.ApiKeyTextBox.Name = "ApiKeyTextBox";
this.ApiKeyTextBox.ReadOnly = true;
this.ApiKeyTextBox.Size = new System.Drawing.Size(260, 20);
this.ApiKeyTextBox.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 141);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(79, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Application key";
//
// label3
//
this.label3.AutoSize = true;
......@@ -160,7 +141,7 @@
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(15, 449);
this.label6.Location = new System.Drawing.Point(18, 380);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(58, 13);
this.label6.TabIndex = 11;
......@@ -186,7 +167,7 @@
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(15, 603);
this.textBox1.Location = new System.Drawing.Point(18, 534);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
......@@ -199,7 +180,7 @@
//
this.groupBox1.Controls.Add(this.groupBox3);
this.groupBox1.Controls.Add(this.groupBox2);
this.groupBox1.Location = new System.Drawing.Point(15, 232);
this.groupBox1.Location = new System.Drawing.Point(16, 163);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(316, 214);
this.groupBox1.TabIndex = 16;
......@@ -290,20 +271,18 @@
this.groupBox4.Controls.Add(this.usernameTextBox);
this.groupBox4.Controls.Add(this.pwTextBox);
this.groupBox4.Controls.Add(this.label4);
this.groupBox4.Controls.Add(this.label2);
this.groupBox4.Controls.Add(this.label1);
this.groupBox4.Controls.Add(this.ApiKeyTextBox);
this.groupBox4.Controls.Add(this.apiURLTextBox);
this.groupBox4.Location = new System.Drawing.Point(15, 12);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(282, 211);
this.groupBox4.Size = new System.Drawing.Size(282, 145);
this.groupBox4.TabIndex = 18;
this.groupBox4.TabStop = false;
//
// webcamsCheckedListBox
//
this.webcamsCheckedListBox.FormattingEnabled = true;
this.webcamsCheckedListBox.Location = new System.Drawing.Point(15, 466);
this.webcamsCheckedListBox.Location = new System.Drawing.Point(18, 397);
this.webcamsCheckedListBox.Name = "webcamsCheckedListBox";
this.webcamsCheckedListBox.Size = new System.Drawing.Size(316, 124);
this.webcamsCheckedListBox.TabIndex = 19;
......@@ -312,7 +291,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(344, 690);
this.ClientSize = new System.Drawing.Size(344, 630);
this.Controls.Add(this.webcamsCheckedListBox);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox1);
......@@ -339,8 +318,6 @@
private System.Windows.Forms.TextBox apiURLTextBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button SaveButton;
private System.Windows.Forms.TextBox ApiKeyTextBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox usernameTextBox;
private System.Windows.Forms.Label label4;
......
......@@ -41,7 +41,7 @@ namespace MoyaSignup
{
try
{
apiCredential = RestClient.GetApiCredential(usernameTextBox.Text, pwTextBox.Text, ApiKeyTextBox.Text, apiURLTextBox.Text);
apiCredential = RestClient.GetApiCredential(usernameTextBox.Text, pwTextBox.Text, Properties.Settings.Default.ApiApplicationKey, apiURLTextBox.Text);
}
catch (Exception ex)
{
......@@ -51,7 +51,6 @@ namespace MoyaSignup
if (apiCredential != null)
{
Properties.Settings.Default.ApiURL = apiURLTextBox.Text;
Properties.Settings.Default.ApiApplicationKey = ApiKeyTextBox.Text;
Properties.Settings.Default.ApiUser = apiCredential.authname;
Properties.Settings.Default.ApiPass = apiCredential.secret;
Properties.Settings.Default.ApiTokenSet = true;
......@@ -117,7 +116,6 @@ namespace MoyaSignup
}
apiURLTextBox.Text = Properties.Settings.Default.ApiURL;
ApiKeyTextBox.Text = Properties.Settings.Default.ApiApplicationKey;
//usernameTextBox.Text = Properties.Settings.Default.ApiUser;
//pwTextBox.Text = Properties.Settings.Default.ApiPass;
......@@ -202,13 +200,11 @@ namespace MoyaSignup
apiURLTextBox.ReadOnly = true;
usernameTextBox.ReadOnly = true;
pwTextBox.ReadOnly = true;
ApiKeyTextBox.ReadOnly = true;
} else
{
apiURLTextBox.ReadOnly = false;
usernameTextBox.ReadOnly = false;
pwTextBox.ReadOnly = false;
ApiKeyTextBox.ReadOnly = false;
}
}
......
......@@ -331,6 +331,7 @@ namespace MoyaSignup
{
userDetailsEditor1.SetUsersImage(image);
userDetailsEditor1.LatestFrame = image;
userDetailsEditor1.ShowSaveButton();
}
private void btnFinnish_Click_1(object sender, EventArgs e)
......
......@@ -148,6 +148,12 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AdvancedMessageBox.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="AdvancedMessageBox.Designer.cs">
<DependentUpon>AdvancedMessageBox.cs</DependentUpon>
</Compile>
<Compile Include="API32.cs" />
<Compile Include="ApiSettings.cs">
<SubType>Form</SubType>
......@@ -202,6 +208,9 @@
<Compile Include="WebCamViewForm.Designer.cs">
<DependentUpon>WebCamViewForm.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="AdvancedMessageBox.resx">
<DependentUpon>AdvancedMessageBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ApiSettings.resx">
<DependentUpon>ApiSettings.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.45.0")]
[assembly: AssemblyFileVersion("1.0.45.0")]
[assembly: AssemblyVersion("1.0.56.0")]
[assembly: AssemblyFileVersion("1.0.56.0")]
......@@ -25,7 +25,7 @@ namespace MoyaSignup.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("myapiclientid")]
[global::System.Configuration.DefaultSettingValueAttribute("8krAyTEpzP6QnwzkxGek")]
public string ApiApplicationKey {
get {
return ((string)(this["ApiApplicationKey"]));
......
......@@ -3,7 +3,7 @@
<Profiles />
<Settings>
<Setting Name="ApiApplicationKey" Type="System.String" Scope="User">
<Value Profile="(Default)">myapiclientid</Value>
<Value Profile="(Default)">8krAyTEpzP6QnwzkxGek</Value>
</Setting>
<Setting Name="ApiUser" Type="System.String" Scope="User">
<Value Profile="(Default)">myapiuser</Value>
......
......@@ -91,7 +91,7 @@
//
// selectCamTimer
//
this.selectCamTimer.Interval = 10000;
this.selectCamTimer.Interval = 5000;
this.selectCamTimer.Tick += new System.EventHandler(this.selectCamTimer_Tick);
//
// TakePictureForm
......@@ -103,8 +103,13 @@
this.Controls.Add(this.pictureTakenLabel);
this.Controls.Add(this.btnTakePic);
this.Controls.Add(this.pictureBox);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "TakePictureForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Ota kuva";
this.TopMost = true;
this.Load += new System.EventHandler(this.TakePictureForm_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false);
......
......@@ -25,6 +25,8 @@ namespace MoyaSignup
int DefaultCropWidth = 263;
int DefaultCropHeight = 360;
int camHeight = 720;
//bool freeze;
// bool pictureTaken = false;
//bool cameraOpen = false;
......@@ -40,6 +42,8 @@ namespace MoyaSignup
HaarCascade face;
Image<Gray, byte> gray = null;
Rectangle cropRectangle = new Rectangle();
List<Capture> webCams;
......@@ -58,6 +62,10 @@ namespace MoyaSignup
private void TakePictureForm_Load(object sender, EventArgs e)
{
startCapturing();
cropRectangle.X = 189;
cropRectangle.Y = 0;
cropRectangle.Width = DefaultCropWidth;
cropRectangle.Height = DefaultCropHeight;
}
private void startCapturing()
......@@ -173,6 +181,7 @@ namespace MoyaSignup
{
//Debug.WriteLine("[takepictureform] Trying to find a face in the frames from the webcams");
Dictionary<Image<Bgr, byte>, decimal> croppedImages = new Dictionary<Image<Bgr, byte>, decimal>();
Dictionary<Image<Bgr, byte>, Rectangle> cropRectangles = new Dictionary<Image<Bgr, byte>, Rectangle>();
List<Image<Bgr, byte>> fullFrames = new List<Image<Bgr, byte>>();
lock(camScores)
......@@ -185,9 +194,15 @@ namespace MoyaSignup
decimal score = 0;
Capture grabber = webCams[i];
currentFullFrame = grabber.QueryFrame();
currentFrame = currentFullFrame.Resize(640, 360, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); //640x360
try
{
currentFullFrame = grabber.QueryFrame();
currentFrame = currentFullFrame.Resize(640, 360, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); //640x360
}catch(Exception ex)
{
Debug.WriteLine("[takepictureform] Could not get frame from camera. Ex: " + ex.Message);
return;
}
gray = currentFrame.Convert<Gray, Byte>();
MCvAvgComp[][] facesDetected = null;
......@@ -197,17 +212,18 @@ namespace MoyaSignup
//Face Detector
facesDetected = gray.DetectHaarCascade(
face,
1.2,
1.1,
10,
Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
new Size(100, 100));
new Size(50, 50));
}
//Action for each element detected
if (facesDetected != null && facesDetected[0].Length > 0)
{
MCvAvgComp f = facesDetected[0][0];
decimal width = ((decimal)f.rect.Width) * 3.1M;
//decimal width = ((decimal)f.rect.Width) * 3.1M;
decimal width = ((decimal)f.rect.Width) * 2.8M;
decimal height = width * 1.36774193548M;
int x = (f.rect.X + f.rect.Width / 2) * 2;
......@@ -227,29 +243,37 @@ namespace MoyaSignup
score += distance;
if (x + width <= 1280 && y + height <= 720 && x >= 0 && y >= 0)
// allow offset
if (y < 0 && y > -50)
y = 0;
if (y + height > camHeight && y + height < camHeight + 150)
y = camHeight - (int)height - 1;
if (x + width <= 1280 && y + height <= camHeight && x >= 0 && y >= 0)
{
Rectangle cropRectangle = new Rectangle(x, y, (int)width, (int)height);
Rectangle cropRect = new Rectangle(x, y, (int)width, (int)height);
Image<Bgr, byte> croppedImage = currentFullFrame.Copy(cropRectangle);
Image<Bgr, byte> croppedImage = currentFullFrame.Copy(cropRect);
croppedImage = croppedImage.Resize(310, 424, INTER.CV_INTER_CUBIC);
Debug.WriteLine("[takepictureform] Adding score '" + score + "' to croppedImageDictionary.");
//Debug.WriteLine("[takepictureform] Adding score '" + score + "' to croppedImageDictionary.");
croppedImages.Add(croppedImage, score);
cropRectangles.Add(croppedImage, cropRect);
lock (camScores)
{
camScores.Add(score, webCams[i]);
}
currentFullFrame.Draw(cropRectangle, new Bgr(Color.Red), 2);
currentFullFrame.Draw(cropRect, new Bgr(Color.Green), 2);
fullFrames.Add(currentFullFrame.Resize(640, 360, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC));
}
}
}
decimal bestScore = 1000;
decimal bestScore = 300;
Image<Bgr, byte> bestImage = null;
int bestImageIdx = 0;
int j = 0;
......@@ -294,7 +318,12 @@ namespace MoyaSignup
selectedCam = camScores[score];
}
}
Rectangle rect = cropRectangles[bestImage];
int x = (int) rect.X / 2;
int y = (int)rect.Y / 2;
int width = (int)rect.Width / 2;
int height = (int)rect.Height / 2;
cropRectangle = new Rectangle( x, y, width, height);
latestFrame = BitmapFilter.Crop(bestImage.Bitmap, RetangleWidth, RetangleHeight, ImageFilters.BitmapFilter.AnchorPosition.Free);
if (fullFrames.Count > bestImageIdx)
pictureBox.Image = fullFrames[bestImageIdx].Bitmap;
......@@ -308,10 +337,11 @@ namespace MoyaSignup
fullFrame = selectedCam.QueryFrame().Resize(640, 360, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
else
fullFrame = webCams[0].QueryFrame().Resize(640, 360, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
latestFrame = BitmapFilter.Crop(fullFrame.Bitmap, DefaultCropWidth, DefaultCropHeight, ImageFilters.BitmapFilter.AnchorPosition.Free);
int x = (640 - DefaultCropWidth) / 2;
int y = (360 - DefaultCropHeight) / 2;
Rectangle cropRectangle = new Rectangle(x, y, DefaultCropWidth, DefaultCropHeight);
latestFrame = BitmapFilter.Crop(fullFrame.Bitmap, cropRectangle.Width, cropRectangle.Height, ImageFilters.BitmapFilter.AnchorPosition.Free);
//int x = (640 - DefaultCropWidth) / 2;
//int y = (360 - DefaultCropHeight) / 2;
//cropRectangle = new Rectangle(x, y, DefaultCropWidth, DefaultCropHeight);
fullFrame.Draw(cropRectangle, new Bgr(Color.Red), 2);
//pbIncoming.Image = latestFrame;
......
......@@ -126,4 +126,7 @@
<metadata name="selectCamTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>284, 17</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
\ No newline at end of file
......@@ -360,7 +360,7 @@
this.btnStartCapture.Name = "btnStartCapture";
this.btnStartCapture.Size = new System.Drawing.Size(271, 30);
this.btnStartCapture.TabIndex = 26;
this.btnStartCapture.Text = "Aloita kuvanotto";
this.btnStartCapture.Text = "Ota uusi kuva";
this.btnStartCapture.UseVisualStyleBackColor = true;
this.btnStartCapture.Click += new System.EventHandler(this.btnStartCapture_Click);
//
......@@ -395,7 +395,7 @@
this.Controls.Add(this.label1);
this.Controls.Add(this.txtFirstName);
this.Name = "UserDetailsEditor";
this.Size = new System.Drawing.Size(875, 524);
this.Size = new System.Drawing.Size(875, 491);
this.Load += new System.EventHandler(this.UserDetailsEditor_Load);
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UserDetailsEditor_KeyUp);
((System.ComponentModel.ISupportInitialize)(this.usersPictureBox)).EndInit();
......
......@@ -124,6 +124,7 @@ namespace MoyaSignup
txtZip.ReadOnly = false;
txtCity.ReadOnly = false;
txtPhone.ReadOnly = false;
this.usersPictureBox.Image = null;
if (txtEmail.Text.Length > 0)
{
......@@ -172,6 +173,7 @@ namespace MoyaSignup
txtZip.Text = "";
txtAge.Text = "";
//this.takePictureControl1.Clear();
this.usersPictureBox.Image = null;
currentUser = null;
latestFrame = null;
PictureTaken = false;
......@@ -327,6 +329,8 @@ namespace MoyaSignup
userId = euser.eventuserId;
currentUser = new User(euser);
//takePictureControl1.SaveUserImage(currentUser);
if(PictureTaken)
SaveUserImage(currentUser);
name = euser.firstname + " " + euser.lastname;
}
else
......@@ -690,7 +694,10 @@ namespace MoyaSignup
frm.StartPosition = FormStartPosition.CenterScreen;
frm.ShowDialog();
}
public void ShowSaveButton()
{
btnSaveData.Visible = true;
}
public void SetUsersImage(Bitmap image)
{
usersPictureBox.Image = image;
......
......@@ -93,9 +93,10 @@
//
// loginButton
//
this.loginButton.Location = new System.Drawing.Point(148, 86);
this.loginButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.loginButton.Location = new System.Drawing.Point(195, 86);
this.loginButton.Name = "loginButton";
this.loginButton.Size = new System.Drawing.Size(118, 26);
this.loginButton.Size = new System.Drawing.Size(212, 26);
this.loginButton.TabIndex = 94;
this.loginButton.Text = "Kirjaudu tapahtumaan";
this.loginButton.UseVisualStyleBackColor = true;
......@@ -104,9 +105,10 @@
//
// forgottenPasswordButton
//
this.forgottenPasswordButton.Location = new System.Drawing.Point(272, 86);
this.forgottenPasswordButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.forgottenPasswordButton.Location = new System.Drawing.Point(413, 86);
this.forgottenPasswordButton.Name = "forgottenPasswordButton";
this.forgottenPasswordButton.Size = new System.Drawing.Size(139, 26);
this.forgottenPasswordButton.Size = new System.Drawing.Size(214, 26);
this.forgottenPasswordButton.TabIndex = 95;
this.forgottenPasswordButton.Text = "En muista salasanaani";
this.forgottenPasswordButton.UseVisualStyleBackColor = true;
......@@ -114,9 +116,10 @@
//
// btnNewProfile
//
this.btnNewProfile.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnNewProfile.Location = new System.Drawing.Point(16, 86);
this.btnNewProfile.Name = "btnNewProfile";
this.btnNewProfile.Size = new System.Drawing.Size(126, 26);
this.btnNewProfile.Size = new System.Drawing.Size(173, 26);
this.btnNewProfile.TabIndex = 96;
this.btnNewProfile.Text = "Lisää omat tiedot";
this.btnNewProfile.UseVisualStyleBackColor = true;
......@@ -135,7 +138,7 @@
this.Controls.Add(this.label4);
this.Controls.Add(this.txtEmail);
this.Name = "UserLoginControl";
this.Size = new System.Drawing.Size(420, 126);
this.Size = new System.Drawing.Size(632, 126);
this.Load += new System.EventHandler(this.UserLoginControl_Load);
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UserLoginControl_KeyUp);
this.ResumeLayout(false);
......
......@@ -60,6 +60,7 @@ namespace MoyaSignup
timer1.Stop();
CurrentUser = null;
btnNewProfile.Visible = false;
showLogin(false);
infoLabel.Text = "Hei! Kirjoita sähköpostiosoitteesi";
}
}
......@@ -109,6 +110,10 @@ namespace MoyaSignup
CurrentUser = new User(euser);
infoLabel.Text = "Hei! " + CurrentUser.ToString() + " Kirjoita salasanasi ja kirjaudu";
showLogin(true);
} else
{
showLogin(false);
ClearText();
}
}
catch (Exception ex)
......@@ -194,9 +199,13 @@ namespace MoyaSignup
passwordTextBox.Text = "";
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent;
ClearText();
Debug.WriteLine("[userlogincontrol] Cleared login info");
}
internal void ClearText()
{
infoLabel.Text = "Hei! Kirjoita sähköpostiosoitteesi";
loginButton.Visible = false;
Debug.WriteLine("[userlogincontrol] Cleared login info");
}
private void UserLoginControl_KeyUp(object sender, KeyEventArgs e)
......
......@@ -40,7 +40,7 @@
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(640, 480);
this.flowLayoutPanel1.Size = new System.Drawing.Size(640, 869);
this.flowLayoutPanel1.TabIndex = 0;
//
// timer1
......@@ -53,14 +53,14 @@
this.flowLayoutPanel2.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel2.Location = new System.Drawing.Point(640, 0);
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
this.flowLayoutPanel2.Size = new System.Drawing.Size(424, 480);
this.flowLayoutPanel2.Size = new System.Drawing.Size(424, 869);
this.flowLayoutPanel2.TabIndex = 1;
//
// WebCamViewForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1064, 480);
this.ClientSize = new System.Drawing.Size(1064, 869);
this.Controls.Add(this.flowLayoutPanel2);
this.Controls.Add(this.flowLayoutPanel1);
this.Name = "WebCamViewForm";
......
......@@ -21,6 +21,8 @@ namespace MoyaSignup
int RetangleHeight = 410;
int RetangleWidth = 280;
int camHeight = 720;
List<Capture> webCams;
Dictionary<Capture, Image<Bgr, byte>> currentFrames = new Dictionary<Emgu.CV.Capture, Image<Bgr, byte>>();
......@@ -94,7 +96,7 @@ namespace MoyaSignup
currentFrame = currentFullFrame.Resize(640, 360, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); //640x360
ImageBox box = (ImageBox)flowLayoutPanel1.Controls[i];
box.Image = currentFrame;
//Dictionary<Image<Bgr, byte>, decimal> croppedImages = new Dictionary<Image<Bgr, byte>, decimal>();
......@@ -109,45 +111,80 @@ namespace MoyaSignup
//Face Detector
facesDetected = gray.DetectHaarCascade(
face,
1.2,
1.1,
10,
Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
new Size(100, 100));
new Size(50, 50));
}
//Action for each element detected
if (facesDetected != null && facesDetected[0].Length > 0)
{
MCvAvgComp f = facesDetected[0][0];
decimal width = ((decimal)f.rect.Width) * 2.9M;
//decimal width = ((decimal)f.rect.Width) * 2.9M;
//decimal height = width * 1.464285M;
decimal width = ((decimal)f.rect.Width) * 2.8M;
decimal height = width * 1.464285M;
int x = (f.rect.X + f.rect.Width / 2) * 2;
x = (int)(x - width / 2);
int y = (f.rect.Y + f.rect.Height / 2) * 2;
y = (int)(y - height / 2);
int x1 = (int)(x + width / 2);
if (x1 >= 1280)
x1 = 1279;
int y1 = (int)(y + height / 2);
if (y1 >= 720)
if (y1 >= camHeight)
y1 = 719;
decimal distance = (decimal)Math.Sqrt(Math.Pow((double)(x1 - 640), 2) + Math.Pow((double)(y1 - 360), 2));
score += distance;
if (x + width <= 1280 && y + height <= 720 && x >= 0 && y >= 0)
/*
Rectangle cropRectangle2 = new Rectangle(x, y, (int)width, (int)height);
currentFullFrame.Draw(cropRectangle, new Bgr(Color.Red), 2);
currentFrame = currentFullFrame.Resize(640, 360, INTER.CV_INTER_CUBIC);
Image<Bgr, byte> croppedImage = currentFullFrame.Copy(cropRectangle);
croppedImage = croppedImage.Resize(280, 410, INTER.CV_INTER_CUBIC);
*/
currentFullFrame.Draw(new Rectangle(x, y, (int)width, (int)height), new Bgr(Color.Blue), 2);
// allow offset
if (y < 0 && y > -50)
y = 0;
if (y + height > camHeight && y + height < camHeight + 150)
y = camHeight - (int)height -1 ;
if (x + width <= 1280 && y + height <= camHeight && x >= 0 && y >= 0)
{
Debug.WriteLine("[webcamviewform] Found a face in frame");
Rectangle cropRectangle = new Rectangle(x, y, (int)width, (int)height);
currentFullFrame.Draw(cropRectangle, new Bgr(Color.Red), 2);
currentFrame = currentFullFrame.Resize(640, 360, INTER.CV_INTER_CUBIC);
Image<Bgr, byte> croppedImage = currentFullFrame.Copy(cropRectangle);
croppedImage = croppedImage.Resize(280, 410, INTER.CV_INTER_CUBIC);
//Bitmap latestFrame = BitmapFilter.Crop(croppedImage.Bitmap, RetangleWidth, RetangleHeight, ImageFilters.BitmapFilter.AnchorPosition.Free);
if(flowLayoutPanel2.Controls != null && flowLayoutPanel2.Controls.Count > i && flowLayoutPanel2.Controls[i] is CroppedImageControl)
{
......@@ -157,8 +194,13 @@ namespace MoyaSignup
}
}
//draw face box to image
currentFrame.Draw(f.rect, new Bgr(Color.Green), 2);
}
box.Image = currentFrame;
}
}
......
......@@ -20,7 +20,7 @@
<userSettings>
<MoyaSignup.Properties.Settings>
<setting name="ApiApplicationKey" serializeAs="String">
<value>myapiclientid</value>
<value>8krAyTEpzP6QnwzkxGek</value>
</setting>
<setting name="ApiUser" serializeAs="String">
<value>myapiuser</value>
......
......@@ -22,7 +22,7 @@
Name "MoyaSignup moya v1_00_45"
Name "MoyaSignup moya v1_00_56"
; DO NOT CHANGE OutFile "installer_temp.exe" !!! AutoPublish requires this.
......@@ -198,7 +198,7 @@ FunctionEnd
Section "!MoyaSignup moya stable v1_00_45" SecMain
Section "!MoyaSignup moya stable v1_00_56" SecMain
SetShellVarContext current
......
......@@ -2,7 +2,7 @@
<AutoPublishSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UploadUser>f-solu-06</UploadUser>
<UploadPath>/home/f-solu-06/software.f-solutions.fi</UploadPath>
<UploadHost>software.f-solutions.fi</UploadHost>
<UploadHost>www4.f-solutions.fi</UploadHost>
<ProjectName>MoyaPrintServer</ProjectName>
<Customers>
<Customer>
......
......@@ -107,7 +107,7 @@ Section "!<$PROJECTNAME$> <$CUSTOMER$> <$VERSIONGROUP$> v<$VERSION$>" SecMain
SetOverwrite On
File /oname=autoupdate.xml "<$BINARYDIR$>\autoupdate.<$CUSTOMER$>.xml"
File /oname=<$BINARYNAMEORIG$> "<$BINARYDIR$>\<$BINARYNAMEOBF$>"
File autoupdate.crt
; File autoupdate.crt
; this line will be replicated for every non-default existing assembly
; that is referenced to the main project.
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MoyaAdminLib
{
public class ApiCredential
{
public string authname;
public DateTime created;
public bool enabled;
public string secret;
}
}
......@@ -28,124 +28,132 @@
/// </summary>
private void InitializeComponent()
{
this.label4 = new System.Windows.Forms.Label();
this.ApiPassTextBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.ApiUserTextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.ApiKeyTextBox = new System.Windows.Forms.TextBox();
this.SaveButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.apiURLTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.SaveButton = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.usernameTextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.pwTextBox = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.resetApiTokenCheckBox = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 148);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(48, 13);
this.label4.TabIndex = 35;
this.label4.Text = "Api Pass";
//
// ApiPassTextBox
//
this.ApiPassTextBox.Location = new System.Drawing.Point(12, 164);
this.ApiPassTextBox.Name = "ApiPassTextBox";
this.ApiPassTextBox.PasswordChar = 'ῷ';
this.ApiPassTextBox.Size = new System.Drawing.Size(260, 20);
this.ApiPassTextBox.TabIndex = 34;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 109);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(47, 13);
this.label3.TabIndex = 33;
this.label3.Text = "Api User";
//
// ApiUserTextBox
//
this.ApiUserTextBox.Location = new System.Drawing.Point(12, 125);
this.ApiUserTextBox.Name = "ApiUserTextBox";
this.ApiUserTextBox.Size = new System.Drawing.Size(260, 20);
this.ApiUserTextBox.TabIndex = 32;
//
// label2
// apiURLTextBox
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 70);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(79, 13);
this.label2.TabIndex = 31;
this.label2.Text = "Application key";
this.apiURLTextBox.Location = new System.Drawing.Point(6, 113);
this.apiURLTextBox.Name = "apiURLTextBox";
this.apiURLTextBox.ReadOnly = true;
this.apiURLTextBox.Size = new System.Drawing.Size(260, 20);
this.apiURLTextBox.TabIndex = 0;
//
// ApiKeyTextBox
// label1
//
this.ApiKeyTextBox.Location = new System.Drawing.Point(12, 86);
this.ApiKeyTextBox.Name = "ApiKeyTextBox";
this.ApiKeyTextBox.Size = new System.Drawing.Size(260, 20);
this.ApiKeyTextBox.TabIndex = 30;
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 97);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(47, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Moya url";
//
// SaveButton
//
this.SaveButton.Location = new System.Drawing.Point(197, 210);
this.SaveButton.Location = new System.Drawing.Point(226, 163);
this.SaveButton.Name = "SaveButton";
this.SaveButton.Size = new System.Drawing.Size(75, 23);
this.SaveButton.TabIndex = 29;
this.SaveButton.TabIndex = 2;
this.SaveButton.Text = "Save";
this.SaveButton.UseVisualStyleBackColor = true;
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
//
// label1
// label3
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 27);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(47, 13);
this.label1.TabIndex = 28;
this.label1.Text = "Moya url";
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 19);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(55, 13);
this.label3.TabIndex = 6;
this.label3.Text = "Username";
//
// apiURLTextBox
// usernameTextBox
//
this.apiURLTextBox.Location = new System.Drawing.Point(12, 43);
this.apiURLTextBox.Name = "apiURLTextBox";
this.apiURLTextBox.Size = new System.Drawing.Size(260, 20);
this.apiURLTextBox.TabIndex = 27;
this.usernameTextBox.Location = new System.Drawing.Point(6, 35);
this.usernameTextBox.Name = "usernameTextBox";
this.usernameTextBox.ReadOnly = true;
this.usernameTextBox.Size = new System.Drawing.Size(260, 20);
this.usernameTextBox.TabIndex = 5;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(6, 58);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(53, 13);
this.label4.TabIndex = 8;
this.label4.Text = "Password";
//
// pwTextBox
//
this.pwTextBox.Location = new System.Drawing.Point(6, 74);
this.pwTextBox.Name = "pwTextBox";
this.pwTextBox.PasswordChar = 'ῷ';
this.pwTextBox.ReadOnly = true;
this.pwTextBox.Size = new System.Drawing.Size(260, 20);
this.pwTextBox.TabIndex = 7;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.pwTextBox);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.usernameTextBox);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.apiURLTextBox);
this.groupBox1.Controls.Add(this.resetApiTokenCheckBox);
this.groupBox1.Location = new System.Drawing.Point(13, 13);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(288, 144);
this.groupBox1.TabIndex = 9;
this.groupBox1.TabStop = false;
//
// resetApiTokenCheckBox
//
this.resetApiTokenCheckBox.AutoSize = true;
this.resetApiTokenCheckBox.Location = new System.Drawing.Point(6, -1);
this.resetApiTokenCheckBox.Name = "resetApiTokenCheckBox";
this.resetApiTokenCheckBox.Size = new System.Drawing.Size(101, 17);
this.resetApiTokenCheckBox.TabIndex = 0;
this.resetApiTokenCheckBox.Text = "Reset api token";
this.resetApiTokenCheckBox.UseVisualStyleBackColor = true;
this.resetApiTokenCheckBox.CheckedChanged += new System.EventHandler(this.resetApiTokenCheckBox_CheckedChanged);
//
// ApiSettings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 261);
this.Controls.Add(this.label4);
this.Controls.Add(this.ApiPassTextBox);
this.Controls.Add(this.label3);
this.Controls.Add(this.ApiUserTextBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.ApiKeyTextBox);
this.ClientSize = new System.Drawing.Size(310, 197);
this.Controls.Add(this.SaveButton);
this.Controls.Add(this.label1);
this.Controls.Add(this.apiURLTextBox);
this.Controls.Add(this.groupBox1);
this.Name = "ApiSettings";
this.Text = "ApiSettings";
this.Load += new System.EventHandler(this.ApiSettings_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox ApiPassTextBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox ApiUserTextBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox ApiKeyTextBox;
private System.Windows.Forms.Button SaveButton;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox apiURLTextBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button SaveButton;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox usernameTextBox;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox pwTextBox;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.CheckBox resetApiTokenCheckBox;
}
}
\ No newline at end of file
using System;
using MoyaAdminLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace moyaPrintServer
......@@ -18,21 +20,67 @@ namespace moyaPrintServer
private void SaveButton_Click(object sender, EventArgs e)
{
Properties.Settings.Default.ApiURL = apiURLTextBox.Text;
Properties.Settings.Default.ApiKey = ApiKeyTextBox.Text;
Properties.Settings.Default.ApiUser = ApiUserTextBox.Text;
Properties.Settings.Default.ApiPass = ApiPassTextBox.Text;
Properties.Settings.Default.Save();
ApiCredential apiCredential = null;
if (resetApiTokenCheckBox.Checked)
{
try
{
apiCredential = RestClient.GetApiCredential(usernameTextBox.Text, pwTextBox.Text, Properties.Settings.Default.ApiApplicationKey, apiURLTextBox.Text);
}
catch (Exception ex)
{
MessageBox.Show("Failed to get api credentials: " + ex.Message);
}
if (apiCredential != null)
{
Properties.Settings.Default.ApiURL = apiURLTextBox.Text;
Properties.Settings.Default.ApiApplicationKey = Properties.Settings.Default.ApiApplicationKey;
Properties.Settings.Default.ApiUser = apiCredential.authname;
Properties.Settings.Default.ApiPass = apiCredential.secret;
Properties.Settings.Default.ApiTokenSet = true;
Properties.Settings.Default.Save();
}
}
RestClient.ApiApplicationKey = Properties.Settings.Default.ApiApplicationKey;
RestClient.ApiPass = Properties.Settings.Default.ApiPass;
RestClient.ApiUser = Properties.Settings.Default.ApiUser;
RestClient.ApiURL = Properties.Settings.Default.ApiURL;
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
private void ApiSettings_Load(object sender, EventArgs e)
{
resetApiTokenCheckBox.Checked = !Properties.Settings.Default.ApiTokenSet;
apiURLTextBox.Text = Properties.Settings.Default.ApiURL;
ApiKeyTextBox.Text = Properties.Settings.Default.ApiKey;
ApiUserTextBox.Text = Properties.Settings.Default.ApiUser;
ApiPassTextBox.Text = Properties.Settings.Default.ApiPass;
//ApiKeyTextBox.Text = Properties.Settings.Default.ApiApplicationKey;
//textBox1.Text =Properties.Settings.Default.ApiApplicationKey;
//usernameTextBox.Text = Properties.Settings.Default.ApiUser;
//pwTextBox.Text = Properties.Settings.Default.ApiPass;
}
private void resetApiTokenCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (!resetApiTokenCheckBox.Checked)
{
apiURLTextBox.ReadOnly = true;
usernameTextBox.ReadOnly = true;
pwTextBox.ReadOnly = true;
//ApiKeyTextBox.ReadOnly = true;
}
else
{
apiURLTextBox.ReadOnly = false;
usernameTextBox.ReadOnly = false;
pwTextBox.ReadOnly = false;
//ApiKeyTextBox.ReadOnly = false;
}
}
}
}
......@@ -9,7 +9,6 @@ using System.Windows.Forms;
using System.Net;
using System.Text;
using System.IO;
using HttpUtils;
using System.Drawing.Printing;
using System.Web.Script.Serialization;
using System.Printing;
......@@ -18,6 +17,7 @@ namespace moyaPrintServer
{
public partial class Form1 : Form
{
Random rnd = new Random();
public Form1()
{
InitializeComponent();
......@@ -37,6 +37,8 @@ namespace moyaPrintServer
if (apiUrlTextBox.Text == "")
apiUrlTextBox.Text = "https://event.domain.ltd/MoyaWeb/rest";
*/
}
......@@ -60,6 +62,24 @@ namespace moyaPrintServer
refreshList();
}
private void tryPrintCardFromList(Card card, ListViewItem lvi, bool showDialog)
{
try
{
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
client.MakeRequest("card/Reserve/" + card.id);
PrintCard(card);
listView.Items.Remove(lvi);
}
catch (Exception ex)
{
//varattu kortti. Skipataan
listView.Items.Remove(lvi);
MessageBox.Show("Kortti on jo tulostettu");
return;
}
}
private void printButton_Click(object sender, EventArgs e)
{
if (listView.SelectedItems.Count > 0)
......@@ -74,6 +94,7 @@ namespace moyaPrintServer
{
cards.Add( (Card)lvi.Tag);
}
cards = cards.OrderBy(c=>c.username).ToList();
foreach (Card card in cards)
{
......@@ -81,18 +102,18 @@ namespace moyaPrintServer
{
if ((Card)lvi.Tag == card)
{
PrintCard(card);
listView.Items.Remove(lvi);
tryPrintCardFromList(card, lvi, true);
break;
}
}
}
}
else
{
foreach (ListViewItem lvi in items)
{
PrintCard((Card)lvi.Tag);
tryPrintCardFromList((Card)lvi.Tag, lvi, true);
listView.Items.Remove(lvi);
}
}
......@@ -189,9 +210,15 @@ namespace moyaPrintServer
}
if (listView.Items.Count > 0 && GetNumberOfPrintJobs() < 1)
{
Card card = (Card)listView.Items[0].Tag;
// Idiot fix for double click users & some random race conditions.
System.Threading.Thread.Sleep(rnd.Next(500, 1500));
refreshList();
if (listView.Items.Count == 0)
return;
Card card = (Card)listView.Items[0].Tag;
try
{
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
client.MakeRequest("card/Reserve/" + card.id);
}
......@@ -219,7 +246,7 @@ namespace moyaPrintServer
var ser = new JavaScriptSerializer();
PrintQueueList queuelist = ser.Deserialize<PrintQueueList>(json);
if (queuelist == null)
if (queuelist == null || queuelist.cards.Count == 0)
{
toolStripStatusLabel1.Text = "No new cards";
return;
......@@ -229,10 +256,12 @@ namespace moyaPrintServer
listView.Items.Clear();
if (sortByNameCheckBox.Checked)
queuelist.cards = queuelist.cards.OrderBy(c => c.username).ToList();
if (sortByFirstnameCheckBox.Checked)
queuelist.cards = queuelist.cards.OrderBy(c => c.wholeName).ToList();
foreach (Card card in queuelist.cards)
{
// jos ei ole filtteriä niin tulosta kaikki validoidut kortit. Jos on filtteri niin tulosta vain ne joihin se osuu
if (card.state == "VALIDATED" && (CardFilterTextBox.Text.Length == 0 || CardFilterTextBox.Text == card.template))
if (card.state == "VALIDATED" && (CardFilterTextBox.Text.Length == 0 || CardFilterTextBox.Text.ToLower().Contains(card.template.ToLower())))
{
ListViewItem lvi = listView.Items.Add(card.id.ToString());
......@@ -255,17 +284,14 @@ namespace moyaPrintServer
LocalPrintServer server = new LocalPrintServer();
PrintQueueCollection queueCollection = server.GetPrintQueues();
PrintQueue printQueue = null;
foreach (PrintQueue pq in queueCollection)
{
if (PrintersComboBox.SelectedItem != null && pq.FullName == PrintersComboBox.SelectedItem.ToString())
printQueue = pq;
}
int numberOfJobs = 0;
if (printQueue != null)
numberOfJobs = printQueue.NumberOfJobs;
return numberOfJobs;
}
......@@ -317,6 +343,16 @@ namespace moyaPrintServer
}
}
private void sortByFirstnameCheckBox_CheckedChanged(object sender, EventArgs e)
{
if(sortByFirstnameCheckBox.Checked)
sortByNameCheckBox.Checked = !sortByFirstnameCheckBox.Checked;
}
private void sortByNameCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (sortByNameCheckBox.Checked)
sortByNameCheckBox.Checked = !sortByFirstnameCheckBox.Checked;
}
}
}
......@@ -142,6 +142,9 @@
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>346, 17</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>346, 17</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAgAICAQAAAAAADoAgAAhgAAABAQEAAAAAAAKAEAAG4DAAAwMAAAAQAIAKgOAACWBAAAICAAAAEA
......
......@@ -6,7 +6,6 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HttpUtils;
using System.Net;
using System.IO;
......
......@@ -39,7 +39,20 @@ namespace moyaPrintServer
Properties.Settings.Default.ApplicationVersion = appVersionString;
}
//Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
//Application.ThreadException += Application_ThreadException;
Application.Run(new Form1());
}
private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
if (e.Exception.Message.Contains("Could not load file or assembly") && e.Exception.Message.Contains("System.Web.Extensions") && e.Exception.Message.Contains("4.0.0.0"))
{
MessageBox.Show("Cannot find .Net Framework version 4.0 installed on your system. Please install the missing framework. You can download and install it from: http://www.microsoft.com/en-us/download/details.aspx?id=17851");
}
else
throw new Exception(e.Exception.Message, e.Exception);
}
}
}
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.29.0")]
[assembly: AssemblyFileVersion("1.0.29.0")]
[assembly: AssemblyVersion("1.0.36.0")]
[assembly: AssemblyFileVersion("1.0.36.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18408
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
......@@ -12,7 +12,7 @@ namespace moyaPrintServer.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
......@@ -61,13 +61,13 @@ namespace moyaPrintServer.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ApiKey {
[global::System.Configuration.DefaultSettingValueAttribute("8krAyTEpzP6QnwzkxGek")]
public string ApiApplicationKey {
get {
return ((string)(this["ApiKey"]));
return ((string)(this["ApiApplicationKey"]));
}
set {
this["ApiKey"] = value;
this["ApiApplicationKey"] = value;
}
}
......@@ -106,5 +106,17 @@ namespace moyaPrintServer.Properties {
this["ApplicationVersion"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool ApiTokenSet {
get {
return ((bool)(this["ApiTokenSet"]));
}
set {
this["ApiTokenSet"] = value;
}
}
}
}
......@@ -11,8 +11,8 @@
<Setting Name="ApiURL" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ApiKey" Type="System.String" Scope="User">
<Value Profile="(Default)" />
<Setting Name="ApiApplicationKey" Type="System.String" Scope="User">
<Value Profile="(Default)">8krAyTEpzP6QnwzkxGek</Value>
</Setting>
<Setting Name="ApiUser" Type="System.String" Scope="User">
<Value Profile="(Default)" />
......@@ -23,5 +23,8 @@
<Setting Name="ApplicationVersion" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ApiTokenSet" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
\ No newline at end of file
using System;
using MoyaAdminLib;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
public enum HttpVerb
namespace moyaPrintServer
{
GET,
POST,
PUT,
DELETE
}
namespace HttpUtils
{
public enum HttpVerb
{
GET,
POST,
PUT,
DELETE
}
public class RestClient
{
public string EndPoint { get; set; }
......@@ -22,10 +28,16 @@ namespace HttpUtils
public string ContentType { get; set; }
public string PostData { get; set; }
public static string ApiApplicationKey;
public static string ApiUser;
public static string ApiPass;
public static string ApiURL;
public RestClient()
{
EndPoint = "";
EndPoint = ApiURL;
Method = HttpVerb.GET;
ContentType = "application/json";
PostData = "";
}
......@@ -53,20 +65,6 @@ namespace HttpUtils
}
public string MakeRequest()
{
return MakeRequest("");
}
public static string GetRequestURL(string server, string parameters)
{
int timestamp = ConvertToTimestamp(DateTime.Now);
string hash = CalculateSHA1("/" + parameters + "+" + moyaPrintServer.Properties.Settings.Default.ApiKey + "+" + moyaPrintServer.Properties.Settings.Default.ApiUser + "+" + timestamp + "+" + moyaPrintServer.Properties.Settings.Default.ApiPass);
string url = server + "/rest/" + parameters + "?appkey=" + moyaPrintServer.Properties.Settings.Default.ApiKey + "&appuser=" + moyaPrintServer.Properties.Settings.Default.ApiUser + "&appstamp=" + timestamp + "&appmac=" + hash;
Debug.WriteLine(url);
return url;
}
public static string CalculateSHA1(string text)
{
// Convert the input string to a byte array
......@@ -83,7 +81,6 @@ namespace HttpUtils
return hash;
}
private static int ConvertToTimestamp(DateTime value)
{
//create Timespan by subtracting the value provided from
......@@ -94,15 +91,48 @@ namespace HttpUtils
return (int)span.TotalSeconds;
}
public string MakeRequest(string parameters)
public static string GetRequestURL(string server, string queryPath)
{
var request = (HttpWebRequest)WebRequest.Create(GetRequestURL( EndPoint, parameters));
return GetRequestURL(server, queryPath,null);
}
public static string GetRequestURL(string server, string queryPath, string getparms)
{
int timestamp = ConvertToTimestamp(DateTime.Now);
string hash = CalculateSHA1("/" + queryPath + "+" + Properties.Settings.Default.ApiApplicationKey + "+" + Properties.Settings.Default.ApiUser + "+" + timestamp + "+" + Properties.Settings.Default.ApiPass);
if (getparms != null && getparms.Length > 0)
getparms = getparms + "&";
string url = server + "/rest/" + queryPath + "?";
if (getparms != null)
url += getparms;
url += "appkey=" + Properties.Settings.Default.ApiApplicationKey + "&appuser=" + Properties.Settings.Default.ApiUser + "&appstamp=" + timestamp + "&appmac=" + hash;
Console.WriteLine(url);
return url;
}
public string MakeRequest(string queryPath)
{
return MakeRequest(queryPath, null);
}
public string MakeRequest(string queryPath, string getparms)
{
///placeadmin/places/30+abcdefg+testuser-asdf+1393735570144+acdcabbacd
///
var request = (HttpWebRequest)WebRequest.Create(GetRequestURL(EndPoint,queryPath,getparms));
request.Method = Method.ToString();
request.ContentLength = 0;
request.ContentType = ContentType;
if (!string.IsNullOrEmpty(PostData) && Method == HttpVerb.POST)
if (!string.IsNullOrEmpty(PostData) && (Method == HttpVerb.POST || Method == HttpVerb.PUT ))
{
var encoding = new UTF8Encoding();
var bytes = Encoding.GetEncoding("iso-8859-1").GetBytes(PostData);
......@@ -113,31 +143,131 @@ namespace HttpUtils
writeStream.Write(bytes, 0, bytes.Length);
}
}
using (var response = (HttpWebResponse)request.GetResponse())
{
var responseValue = string.Empty;
if (response.StatusCode != HttpStatusCode.OK)
try
{
using (var response = (HttpWebResponse)request.GetResponse())
{
var message = String.Format("Request failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
var responseValue = string.Empty;
if ((int)response.StatusCode < 200 && (int)response.StatusCode >= 300)
{
var message = String.Format("Request failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
}
// grab the response
//if (response.ContentLength > 0)
//{
using (var responseStream = response.GetResponseStream())
{
if (responseStream != null)
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
//}
return responseValue;
}
}
catch (WebException e)
{
if (e.Status == WebExceptionStatus.ConnectFailure)
throw e;
Stream responseStream = ((WebException)e).Response.GetResponseStream();
// grab the response
using (var responseStream = response.GetResponseStream())
if (responseStream != null)
{
if (responseStream != null)
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
string responseValue = StreamToString(responseStream);
Console.WriteLine("Response was " + responseValue);
throw new Exception(responseValue);
}
return responseValue;
throw e;
}
}
/// <summary>
/// Convert streams from web to string
/// </summary>
/// <param name="responseStream">Webresponse stream</param>
/// <returns>string</returns>
private string StreamToString(Stream responseStream)
{
StreamReader reader = new StreamReader(responseStream);
string responseString = reader.ReadToEnd();
responseStream.Close();
reader.Close();
return responseString;
}
public static ApiCredential GetApiCredential(string username, string pw, string apiKey, string url)
{
var request = (HttpWebRequest)WebRequest.Create(url+"/rest/apiapp/v1/createInstance/"+apiKey);
/*
NetworkCredential credentials = new NetworkCredential();
credentials.UserName = username;
credentials.Password = pw;
CredentialCache credentialCache = new CredentialCache();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
credentialCache.Add(new System.Uri(url), "Basic", credentials);
request.Credentials = credentialCache;
request.PreAuthenticate = true;
*/
string encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + pw));
request.Headers.Add("Authorization", "Basic " + encoded);
request.Method = "POST";
try
{
using (var response = (HttpWebResponse)request.GetResponse())
{
var responseValue = string.Empty;
if ((int)response.StatusCode < 200 && (int)response.StatusCode >= 300)
{
var message = String.Format("Request failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
}
// grab the response
//if (response.ContentLength > 0)
//{
using (var responseStream = response.GetResponseStream())
{
if (responseStream != null)
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
//}
JavaScriptSerializer ser = new JavaScriptSerializer();
try
{
ApiCredential credential = ser.Deserialize<ApiCredential>(responseValue);
return credential;
} catch(Exception ex)
{
throw ex;
}
}
}
catch (WebException e)
{
throw e;
}
}
} // class
}
\ No newline at end of file
}
......@@ -16,8 +16,8 @@
<setting name="ApiURL" serializeAs="String">
<value />
</setting>
<setting name="ApiKey" serializeAs="String">
<value />
<setting name="ApiApplicationKey" serializeAs="String">
<value>8krAyTEpzP6QnwzkxGek</value>
</setting>
<setting name="ApiUser" serializeAs="String">
<value />
......@@ -28,6 +28,9 @@
<setting name="ApplicationVersion" serializeAs="String">
<value />
</setting>
<setting name="ApiTokenSet" serializeAs="String">
<value>False</value>
</setting>
</moyaPrintServer.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
......@@ -37,7 +37,7 @@
<ItemGroup>
<Reference Include="AutoUpdateLib, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\AutoUpdate\src\AutoUpdateLib\bin\Debug\AutoUpdateLib.dll</HintPath>
<HintPath>..\res\AutoUpdateLib.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
......@@ -57,6 +57,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ApiCredential.cs" />
<Compile Include="ApiSettings.cs">
<SubType>Form</SubType>
</Compile>
......
......@@ -22,7 +22,7 @@
Name "MoyaPrintServer moya v1_00_29"
Name "MoyaPrintServer moya v1_00_36"
; DO NOT CHANGE OutFile "installer_temp.exe" !!! AutoPublish requires this.
......@@ -198,7 +198,7 @@ FunctionEnd
Section "!MoyaPrintServer moya stable v1_00_29" SecMain
Section "!MoyaPrintServer moya stable v1_00_36" SecMain
SetShellVarContext current
......@@ -212,11 +212,11 @@ Section "!MoyaPrintServer moya stable v1_00_29" SecMain
SetOverwrite On
File /oname=autoupdate.xml "I:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\autoupdate.moya.xml"
File /oname=autoupdate.xml "C:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\autoupdate.moya.xml"
File /oname=moyaPrintServer.exe "I:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\moyaPrintServer.exe"
File /oname=moyaPrintServer.exe "C:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\moyaPrintServer.exe"
File autoupdate.crt
; File autoupdate.crt
......@@ -224,10 +224,10 @@ Section "!MoyaPrintServer moya stable v1_00_29" SecMain
; that is referenced to the main project.
File "I:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\AutoUpdateLib.dll"
File "C:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\AutoUpdateLib.dll"
File "I:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\moyaPrintServer.pdb"
File "I:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\AutoUpdateLib.pdb"
File "C:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\moyaPrintServer.pdb"
File "C:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\AutoUpdateLib.pdb"
......@@ -315,10 +315,10 @@ Section "Uninstall"
; that is referenced to the main project.
Delete "$INSTDIR\I:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\AutoUpdateLib.dll"
Delete "$INSTDIR\C:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\AutoUpdateLib.dll"
Delete "$INSTDIR\I:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\moyaPrintServer.pdb"
Delete "$INSTDIR\I:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\AutoUpdateLib.pdb"
Delete "$INSTDIR\C:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\moyaPrintServer.pdb"
Delete "$INSTDIR\C:\devel\proj\moya-info-tools\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\AutoUpdateLib.pdb"
......
......@@ -34,12 +34,22 @@ namespace QrCodeScannerFrm
private void Form1_Load(object sender, EventArgs e)
{
DsDevice[] _SystemCamereas = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
foreach(DsDevice device in _SystemCamereas)
if (TrayForm.CaptureDevice != null)
{
webcamsComboBox.Items.Add(device.Name);
//if (Properties.Settings.Default.WebCam != "" && Properties.Settings.Default.WebCam == device.Name)
// webcamsComboBox.SelectedItem = device.Name;
webcamsComboBox.Enabled = false;
capture = TrayForm.CaptureDevice;
}
else
{
DsDevice[] _SystemCamereas = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
foreach (DsDevice device in _SystemCamereas)
{
webcamsComboBox.Items.Add(device.Name);
//if (Properties.Settings.Default.WebCam != "" && Properties.Settings.Default.WebCam == device.Name)
// webcamsComboBox.SelectedItem = device.Name;
}
}
hostTextBox.Text = Properties.Settings.Default.Host;
......@@ -48,7 +58,14 @@ namespace QrCodeScannerFrm
barcodereader = new BarcodeReader();
qrCodeReader = new ZXing.QrCode.QRCodeReader();
timer1.Enabled = false;
if (TrayForm.CaptureDevice == null)
{
timer1.Enabled = false;
} else
{
timer1.Enabled = true;
timer1.Start();
}
}
private void setRet()
......@@ -89,18 +106,32 @@ namespace QrCodeScannerFrm
else
{
Debug.WriteLine("Couldn't dedect qr code, trying to dedect barcode.");
result = barcodereader.Decode(image);
if (result != null)
for (int i = 0; i < 3; i++)
{
Debug.WriteLine(result.BarcodeFormat.ToString());
Debug.WriteLine(result.Text);
if (codeTextBox.Text != result.Text || timeCodeSent.AddSeconds(30) < DateTime.Now)
if (i > 0)
{
Debug.WriteLine("Couldn't dedect barcode, trying to rotate picture 90 degrees.");
image.RotateFlip(RotateFlipType.Rotate90FlipNone);
}
pictureBox1.Image = image;
source = new BitmapLuminanceSource(image);
bimage = new BinaryBitmap(new HybridBinarizer(source));
result = new MultiFormatReader().decode(bimage);
result = barcodereader.Decode(image);
if (result != null)
{
codeTextBox.Text = result.Text;
sendCode(result.Text);
Debug.WriteLine(result.BarcodeFormat.ToString());
Debug.WriteLine(result.Text);
if (codeTextBox.Text != result.Text || timeCodeSent.AddSeconds(30) < DateTime.Now)
{
codeTextBox.Text = result.Text;
sendCode(result.Text);
}
if (codeTypeTextBox.Text != result.BarcodeFormat.ToString())
codeTypeTextBox.Text = result.BarcodeFormat.ToString();
break;
}
if (codeTypeTextBox.Text != result.BarcodeFormat.ToString())
codeTypeTextBox.Text = result.BarcodeFormat.ToString();
}
}
}
......
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.14.0")]
[assembly: AssemblyFileVersion("1.0.14.0")]
[assembly: AssemblyVersion("1.0.16.0")]
[assembly: AssemblyFileVersion("1.0.16.0")]
......@@ -32,9 +32,10 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TrayForm));
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.scanCodeTimer = new System.Windows.Forms.Timer(this.components);
this.apiSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.scanCodeTimer = new System.Windows.Forms.Timer(this.components);
this.videoFormToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
......@@ -48,30 +49,38 @@
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.videoFormToolStripMenuItem,
this.apiSettingsToolStripMenuItem,
this.exitToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(153, 70);
this.contextMenuStrip1.Size = new System.Drawing.Size(154, 92);
this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening);
//
// scanCodeTimer
//
this.scanCodeTimer.Tick += new System.EventHandler(this.scanCodeTimer_Tick);
//
// apiSettingsToolStripMenuItem
//
this.apiSettingsToolStripMenuItem.Name = "apiSettingsToolStripMenuItem";
this.apiSettingsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.apiSettingsToolStripMenuItem.Size = new System.Drawing.Size(153, 22);
this.apiSettingsToolStripMenuItem.Text = "Settings";
this.apiSettingsToolStripMenuItem.Click += new System.EventHandler(this.apiSettingsToolStripMenuItem_Click);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.exitToolStripMenuItem.Size = new System.Drawing.Size(153, 22);
this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
// scanCodeTimer
//
this.scanCodeTimer.Tick += new System.EventHandler(this.scanCodeTimer_Tick);
//
// videoFormToolStripMenuItem
//
this.videoFormToolStripMenuItem.Name = "videoFormToolStripMenuItem";
this.videoFormToolStripMenuItem.Size = new System.Drawing.Size(153, 22);
this.videoFormToolStripMenuItem.Text = "Live video feed";
this.videoFormToolStripMenuItem.Click += new System.EventHandler(this.videoFormToolStripMenuItem_Click);
//
// TrayForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
......@@ -93,5 +102,6 @@
private System.Windows.Forms.Timer scanCodeTimer;
private System.Windows.Forms.ToolStripMenuItem apiSettingsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem videoFormToolStripMenuItem;
}
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ namespace QrCodeScannerFrm
{
public partial class TrayForm : Form
{
Capture capture = null;
public static Capture CaptureDevice = null;
IBarcodeReader barcodereader = null;
ZXing.QrCode.QRCodeReader qrCodeReader = null;
......@@ -76,7 +76,7 @@ namespace QrCodeScannerFrm
{
try
{
capture = new Emgu.CV.Capture(Properties.Settings.Default.WebCam);
CaptureDevice = new Emgu.CV.Capture(Properties.Settings.Default.WebCam);
scanCodeTimer.Enabled = true;
scanCodeTimer.Start();
}
......@@ -94,11 +94,11 @@ namespace QrCodeScannerFrm
{
try
{
Image<Bgr, byte> frame = capture.QueryFrame();
Image<Gray, byte> gray = frame.Convert<Gray, Byte>();
Image<Bgr, byte> frame = CaptureDevice.QueryFrame();
//Image<Gray, byte> gray = frame.Convert<Gray, byte>();
if (frame != null)
{
Bitmap image = gray.Bitmap;
Bitmap image = frame.Bitmap;
//pictureBox1.Image = image;
LuminanceSource source = new BitmapLuminanceSource(image);
BinaryBitmap bimage = new BinaryBitmap(new HybridBinarizer(source));
......@@ -120,21 +120,34 @@ namespace QrCodeScannerFrm
else
{
Debug.WriteLine("Couldn't dedect qr code, trying to dedect barcode.");
result = barcodereader.Decode(image);
if (result != null)
Debug.WriteLine("Couldn't dedect qr code, trying to dedect barcode.");
for (int i = 0; i < 3; i++)
{
Debug.WriteLine(result.BarcodeFormat.ToString());
Debug.WriteLine(result.Text);
if (lastCode != result.Text || timeCodeSent.AddSeconds(30) < DateTime.Now)
if (i > 0)
{
Debug.WriteLine("Couldn't dedect barcode, trying to rotate picture 90 degrees.");
image.RotateFlip(RotateFlipType.Rotate90FlipNone);
}
source = new BitmapLuminanceSource(image);
bimage = new BinaryBitmap(new HybridBinarizer(source));
result = new MultiFormatReader().decode(bimage);
result = barcodereader.Decode(image);
if (result != null && !result.BarcodeFormat.ToString().Contains("UPC"))
{
lastCode = result.Text;
lastCodeType = result.BarcodeFormat.ToString();
sendCode(lastCode, lastCodeType);
Debug.WriteLine(result.BarcodeFormat.ToString());
Debug.WriteLine(result.Text);
if (lastCode != result.Text || timeCodeSent.AddSeconds(30) < DateTime.Now)
{
lastCode = result.Text;
lastCodeType = result.BarcodeFormat.ToString();
sendCode(lastCode, lastCodeType);
}
break;
/*
if (codeTypeTextBox.Text != result.BarcodeFormat.ToString())
codeTypeTextBox.Text = result.BarcodeFormat.ToString();
*/
}
/*
if (codeTypeTextBox.Text != result.BarcodeFormat.ToString())
codeTypeTextBox.Text = result.BarcodeFormat.ToString();
*/
}
}
}
......@@ -190,7 +203,7 @@ namespace QrCodeScannerFrm
if(form.ShowDialog() == DialogResult.OK)
{ try
{
capture = new Emgu.CV.Capture(Properties.Settings.Default.WebCam);
CaptureDevice = new Emgu.CV.Capture(Properties.Settings.Default.WebCam);
scanCodeTimer.Enabled = true;
scanCodeTimer.Start();
} catch(Exception ex)
......@@ -214,5 +227,11 @@ namespace QrCodeScannerFrm
{
notifyIcon1.Dispose();
}
private void videoFormToolStripMenuItem_Click(object sender, EventArgs e)
{
Form1 frm = new Form1();
frm.Show();
}
}
}
......@@ -22,7 +22,7 @@
Name "QrCodeScannerFrm moya v1_00_14"
Name "QrCodeScannerFrm moya v1_00_16"
; DO NOT CHANGE OutFile "installer_temp.exe" !!! AutoPublish requires this.
......@@ -198,7 +198,7 @@ FunctionEnd
Section "!QrCodeScannerFrm moya stable v1_00_14" SecMain
Section "!QrCodeScannerFrm moya stable v1_00_16" SecMain
SetShellVarContext current
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!