Commit e8fe2cb7 by Liv Haapala

Merge branch 'master' of gitlab.codecrew.fi:liv/moya-info-tools

Conflicts:
	MoyaAdmin/MoyaAdminUI/MoyaAdminUI/MainForm.Designer.cs
	MoyaAdmin/MoyaAdminUI/MoyaAdminUI/MainForm.cs
	MoyaAdmin/MoyaAdminUI/MoyaAdminUI/MainForm.resx
2 parents 707e01d9 b180fb00
...@@ -54,13 +54,8 @@ namespace MoyaAdminUI ...@@ -54,13 +54,8 @@ namespace MoyaAdminUI
} }
} }
} }
/*
[Description("Binded to user")]
public int ReserverId
{
get { return APIreference.eventuserId; }
set { APIreference.eventuserId = value; }
}*/
public bool Dirty = false; public bool Dirty = false;
[Category("Place map")] [Category("Place map")]
...@@ -134,42 +129,70 @@ namespace MoyaAdminUI ...@@ -134,42 +129,70 @@ namespace MoyaAdminUI
get { return APIreference.name; } get { return APIreference.name; }
set { APIreference.name = value; } set { APIreference.name = value; }
} }
[Category("Reservation")]
User reserverUserCache = null;
[Category("Reservation"), DisplayName("Player"), Description("Person who will sit to place")]
public string ReserverUserName public string ReserverUserName
{ {
get get
{ {
if (APIreference.reserverId > 0) if (reserverUserCache == null)
{ {
if (getUser() == null) if (APIreference.eventuserId > 0)
{
foreach (User u in User.Cache)
{ {
return "ERR"; if (u.EventUserId == APIreference.eventuserId)
{
reserverUserCache = u;
break;
}
} }
else
return User.ToString();
} }
// Still no hit, use buyer
if (reserverUserCache == null)
{
foreach (User u in User.Cache)
{
if (u.EventUserId == APIreference.reserverId)
{
reserverUserCache = u;
break;
}
}
}
}
if (reserverUserCache == null)
return "free"; return "free";
else return
reserverUserCache.ToString();
} }
} }
[Category("Reservation")]
User buyerUserCache = null;
[Category("Reservation"), DisplayName("Buyer"), Description("Person who had payed place")]
public User User public User User
{ {
get get
{ {
return getUser(); if (buyerUserCache == null)
}
//set { }
}
private MoyaAdminUI.User getUser()
{ {
foreach (User u in User.Cache) foreach (User u in User.Cache)
{ {
if (u.EventUserId == APIreference.reserverId) if (u.EventUserId == APIreference.reserverId)
return u; {
buyerUserCache = u;
break;
}
}
} }
return null; return buyerUserCache;
} }
}
public Point GetPoint() public Point GetPoint()
{ {
return new Point(this.MapX, this.MapY); return new Point(this.MapX, this.MapY);
...@@ -218,6 +241,8 @@ namespace MoyaAdminUI ...@@ -218,6 +241,8 @@ namespace MoyaAdminUI
} }
public void Release() public void Release()
{ {
reserverUserCache = null;
buyerUserCache = null;
APIreference.Release(); APIreference.Release();
} }
...@@ -227,6 +252,8 @@ namespace MoyaAdminUI ...@@ -227,6 +252,8 @@ namespace MoyaAdminUI
* */ * */
internal void Reserve(User user) internal void Reserve(User user)
{ {
reserverUserCache = null;
buyerUserCache = null;
APIreference.Reserve(user.EventUserId); APIreference.Reserve(user.EventUserId);
} }
} }
......
...@@ -45,6 +45,7 @@ namespace MoyaAdminUI ...@@ -45,6 +45,7 @@ namespace MoyaAdminUI
{ {
MessageBox.Show(ex.Message + "\r\nCannot connect to Moya.\r\nCheck Api url and key"); MessageBox.Show(ex.Message + "\r\nCannot connect to Moya.\r\nCheck Api url and key");
} }
} }
private void loadPlacemap() private void loadPlacemap()
...@@ -104,6 +105,7 @@ namespace MoyaAdminUI ...@@ -104,6 +105,7 @@ namespace MoyaAdminUI
Size borderSize = this.Size - this.ClientSize; Size borderSize = this.Size - this.ClientSize;
this.MapPictureBox.Load(RestClient.GetRequestURL(Properties.Settings.Default.ApiURL, "placeadmin/background/" + SelectedMap.Id)); this.MapPictureBox.Load(RestClient.GetRequestURL(Properties.Settings.Default.ApiURL, "placeadmin/background/" + SelectedMap.Id));
MapPictureBox.Size = this.MapPictureBox.Image.Size; MapPictureBox.Size = this.MapPictureBox.Image.Size;
panel2.Width = this.MapPictureBox.Image.Size.Width;
this.MinimumSize = this.MapPictureBox.Image.Size + new Size(0, this.TopPanel.Size.Height + 20) + new Size(this.panel1.MinimumSize.Width + 270, 0) + borderSize; this.MinimumSize = this.MapPictureBox.Image.Size + new Size(0, this.TopPanel.Size.Height + 20) + new Size(this.panel1.MinimumSize.Width + 270, 0) + borderSize;
} }
...@@ -609,6 +611,9 @@ namespace MoyaAdminUI ...@@ -609,6 +611,9 @@ namespace MoyaAdminUI
} }
else if (place.Taken) else if (place.Taken)
{ {
if (place.APIReference.eventuserId > 0)
brush = Brushes.Green;
else
brush = Brushes.Red; brush = Brushes.Red;
} }
else if (place.Buyable) else if (place.Buyable)
...@@ -661,7 +666,8 @@ namespace MoyaAdminUI ...@@ -661,7 +666,8 @@ namespace MoyaAdminUI
placeEditor.SelectedObject = selectedPlace; placeEditor.SelectedObject = selectedPlace;
} }
this.MapPictureBox.Refresh(); ImageRefreshTimer.Start();
} }
private void SaveButton_Click(object sender, EventArgs e) private void SaveButton_Click(object sender, EventArgs e)
...@@ -839,6 +845,8 @@ namespace MoyaAdminUI ...@@ -839,6 +845,8 @@ namespace MoyaAdminUI
{ {
mouseDownPoint = e.Location; mouseDownPoint = e.Location;
mouseDownComputerPlace = findPlace(mouseDownPoint); mouseDownComputerPlace = findPlace(mouseDownPoint);
//if (UnlockToolStripButton.Checked)
//{
if (mouseDownComputerPlace != null) if (mouseDownComputerPlace != null)
{ {
//editComputerPlace(mouseDownComputerPlace); //editComputerPlace(mouseDownComputerPlace);
...@@ -854,6 +862,7 @@ namespace MoyaAdminUI ...@@ -854,6 +862,7 @@ namespace MoyaAdminUI
{ {
editComputerPlace(null); editComputerPlace(null);
} }
//}
} }
} }
...@@ -892,10 +901,11 @@ namespace MoyaAdminUI ...@@ -892,10 +901,11 @@ namespace MoyaAdminUI
{ {
unsafe unsafe
{ {
// if drag start top of place then move // if drag start top of place then move
if (e.Button == MouseButtons.Left && mouseDownComputerPlace != null) if (UnlockToolStripButton.Checked && e.Button == MouseButtons.Left && mouseDownComputerPlace != null)
{ {
//drag & drop //drag & drop
...@@ -961,13 +971,39 @@ namespace MoyaAdminUI ...@@ -961,13 +971,39 @@ namespace MoyaAdminUI
MapPictureBox.Refresh(); MapPictureBox.Refresh();
} }
// if drag start from blank area then paint new places // if drag start from blank area then paint selection area
else if (e.Button == MouseButtons.Left && mouseDownComputerPlace == null) else if (e.Button == MouseButtons.Left && mouseDownComputerPlace == null)
{ {
//set multiselect range so we can draw the selectarea rectangle //set multiselect range so we can draw the selectarea rectangle
multiSelectStart = mouseDownPoint; multiSelectStart = mouseDownPoint;
multiSelectEnd = e.Location; multiSelectEnd = e.Location;
int Xleft, Xright, Yup, Ybottom;
if (mouseDownPoint.X > e.Location.X)
{
Xleft = e.Location.X;
Xright = mouseDownPoint.X;
}
else
{
Xleft = mouseDownPoint.X;
Xright = e.Location.X;
}
if (mouseDownPoint.Y > e.Location.Y)
{
Yup = e.Location.Y;
Ybottom = mouseDownPoint.Y;
}
else
{
Yup = mouseDownPoint.Y;
Ybottom = e.Location.Y;
}
multiSelectStart = new Point(Xleft, Yup);
multiSelectEnd = new Point(Xright, Ybottom);
//selecting items //selecting items
disableEvents = true; disableEvents = true;
this.PlacesListView.BeginUpdate(); this.PlacesListView.BeginUpdate();
...@@ -1087,10 +1123,55 @@ namespace MoyaAdminUI ...@@ -1087,10 +1123,55 @@ namespace MoyaAdminUI
frm.Show(); frm.Show();
} }
private void toolStripButton2_Click(object sender, EventArgs e) private void searchTextBox_TextChanged(object sender, EventArgs e)
{ {
searchTimer.Stop();
searchTimer.Start();
}
private void searchTimer_Tick(object sender, EventArgs e)
{
searchTimer.Stop();
ListView.ListViewItemCollection items = PlacesListView.Items;
PlacesListView.BeginUpdate();
if (searchTextBox.Text.Length > 0)
{
foreach (ListViewItem lvi in items)
{
ComputerPlace place = (ComputerPlace)lvi.Tag;
if (
place.Name == searchTextBox.Text
|| place.User != null
&& (
place.ReserverUserName.ToLower().Contains(searchTextBox.Text.ToLower())
|| place.User.ToString().ToLower().Contains(searchTextBox.Text.ToLower())
)
)
{
lvi.Selected = true;
}
else
lvi.Selected = false;
}
}
PlacesListView.EndUpdate();
} }
private void ImageRefreshTimer_Tick(object sender, EventArgs e)
{
ImageRefreshTimer.Stop();
this.MapPictureBox.Refresh();
}
private void MainForm_SizeChanged(object sender, EventArgs e)
{
}
} }
} }
...@@ -164,6 +164,7 @@ ...@@ -164,6 +164,7 @@
// //
// bookNumericUpDown // bookNumericUpDown
// //
this.bookNumericUpDown.Enabled = false;
this.bookNumericUpDown.Location = new System.Drawing.Point(363, 159); this.bookNumericUpDown.Location = new System.Drawing.Point(363, 159);
this.bookNumericUpDown.Name = "bookNumericUpDown"; this.bookNumericUpDown.Name = "bookNumericUpDown";
this.bookNumericUpDown.ReadOnly = true; this.bookNumericUpDown.ReadOnly = true;
...@@ -172,6 +173,7 @@ ...@@ -172,6 +173,7 @@
// //
// pageNumericUpDown // pageNumericUpDown
// //
this.pageNumericUpDown.Enabled = false;
this.pageNumericUpDown.Location = new System.Drawing.Point(363, 185); this.pageNumericUpDown.Location = new System.Drawing.Point(363, 185);
this.pageNumericUpDown.Name = "pageNumericUpDown"; this.pageNumericUpDown.Name = "pageNumericUpDown";
this.pageNumericUpDown.ReadOnly = true; this.pageNumericUpDown.ReadOnly = true;
...@@ -180,6 +182,7 @@ ...@@ -180,6 +182,7 @@
// //
// slotNumericUpDown // slotNumericUpDown
// //
this.slotNumericUpDown.Enabled = false;
this.slotNumericUpDown.Location = new System.Drawing.Point(363, 211); this.slotNumericUpDown.Location = new System.Drawing.Point(363, 211);
this.slotNumericUpDown.Name = "slotNumericUpDown"; this.slotNumericUpDown.Name = "slotNumericUpDown";
this.slotNumericUpDown.ReadOnly = true; this.slotNumericUpDown.ReadOnly = true;
......
...@@ -30,14 +30,17 @@ ...@@ -30,14 +30,17 @@
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.usersListView = new System.Windows.Forms.ListView(); this.usersListView = new System.Windows.Forms.ListView();
this.button1 = new System.Windows.Forms.Button();
this.searchTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.button1 = new System.Windows.Forms.Button();
this.searchTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.searchTimer = new System.Windows.Forms.Timer(this.components); this.searchTimer = new System.Windows.Forms.Timer(this.components);
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.CardState = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// usersListView // usersListView
...@@ -53,16 +56,37 @@ ...@@ -53,16 +56,37 @@
this.usersListView.FullRowSelect = true; this.usersListView.FullRowSelect = true;
this.usersListView.Location = new System.Drawing.Point(12, 58); this.usersListView.Location = new System.Drawing.Point(12, 58);
this.usersListView.Name = "usersListView"; this.usersListView.Name = "usersListView";
this.usersListView.Size = new System.Drawing.Size(570, 241); this.usersListView.Size = new System.Drawing.Size(517, 349);
this.usersListView.TabIndex = 0; this.usersListView.TabIndex = 0;
this.usersListView.UseCompatibleStateImageBehavior = false; this.usersListView.UseCompatibleStateImageBehavior = false;
this.usersListView.View = System.Windows.Forms.View.Details; this.usersListView.View = System.Windows.Forms.View.Details;
this.usersListView.SelectedIndexChanged += new System.EventHandler(this.usersListView_SelectedIndexChanged);
this.usersListView.DoubleClick += new System.EventHandler(this.usersListView_DoubleClick); this.usersListView.DoubleClick += new System.EventHandler(this.usersListView_DoubleClick);
// //
// columnHeader1
//
this.columnHeader1.Text = "Nick";
this.columnHeader1.Width = 118;
//
// columnHeader2
//
this.columnHeader2.Text = "Firstname";
this.columnHeader2.Width = 112;
//
// columnHeader3
//
this.columnHeader3.Text = "Lastname";
this.columnHeader3.Width = 150;
//
// columnHeader4
//
this.columnHeader4.Text = "Login";
this.columnHeader4.Width = 93;
//
// button1 // button1
// //
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(507, 305); this.button1.Location = new System.Drawing.Point(454, 412);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23); this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1; this.button1.TabIndex = 1;
...@@ -86,35 +110,35 @@ ...@@ -86,35 +110,35 @@
this.label1.TabIndex = 3; this.label1.TabIndex = 3;
this.label1.Text = "Search"; this.label1.Text = "Search";
// //
// columnHeader1 // searchTimer
//
this.columnHeader1.Text = "Nick";
this.columnHeader1.Width = 118;
//
// columnHeader2
//
this.columnHeader2.Text = "Firstname";
this.columnHeader2.Width = 112;
// //
// columnHeader3 this.searchTimer.Tick += new System.EventHandler(this.searchTimer_Tick);
// //
this.columnHeader3.Text = "Lastname"; // pictureBox1
this.columnHeader3.Width = 150;
// //
// columnHeader4 this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.pictureBox1.Location = new System.Drawing.Point(535, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(260, 395);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 4;
this.pictureBox1.TabStop = false;
// //
this.columnHeader4.Text = "Login"; // CardState
this.columnHeader4.Width = 93;
// //
// searchTimer this.CardState.Location = new System.Drawing.Point(535, 412);
// this.CardState.Name = "CardState";
this.searchTimer.Tick += new System.EventHandler(this.searchTimer_Tick); this.CardState.ReadOnly = true;
this.CardState.Size = new System.Drawing.Size(260, 20);
this.CardState.TabIndex = 5;
// //
// UsersFinderForm // UsersFinderForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(594, 333); this.ClientSize = new System.Drawing.Size(807, 447);
this.Controls.Add(this.CardState);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.searchTextBox); this.Controls.Add(this.searchTextBox);
this.Controls.Add(this.button1); this.Controls.Add(this.button1);
...@@ -122,6 +146,7 @@ ...@@ -122,6 +146,7 @@
this.Name = "UsersFinderForm"; this.Name = "UsersFinderForm";
this.Text = "Users Finder"; this.Text = "Users Finder";
this.Load += new System.EventHandler(this.UsersFinderForm_Load); this.Load += new System.EventHandler(this.UsersFinderForm_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
...@@ -138,5 +163,7 @@ ...@@ -138,5 +163,7 @@
private System.Windows.Forms.TextBox searchTextBox; private System.Windows.Forms.TextBox searchTextBox;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Timer searchTimer; private System.Windows.Forms.Timer searchTimer;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.TextBox CardState;
} }
} }
\ No newline at end of file
using System; using MoyaAdminLib;
using MoyaAdminUI.MoyaAPI;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
...@@ -6,6 +8,7 @@ using System.Drawing; ...@@ -6,6 +8,7 @@ using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms; using System.Windows.Forms;
namespace MoyaAdminUI namespace MoyaAdminUI
...@@ -81,5 +84,22 @@ namespace MoyaAdminUI ...@@ -81,5 +84,22 @@ namespace MoyaAdminUI
this.DialogResult = DialogResult.OK; this.DialogResult = DialogResult.OK;
} }
private void usersListView_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBox1.Image = null;
if (usersListView.SelectedItems.Count != 1)
{
return;
}
User user = (User)usersListView.SelectedItems[0].Tag;
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
string json = client.MakeRequest("user/card/" + user.EventUserId);
var ser = new JavaScriptSerializer();
Card card = ser.Deserialize<Card>(json);
pictureBox1.ImageLocation = RestClient.GetRequestURL(Properties.Settings.Default.ApiURL, "card/GetImage/" + card.cardId);
CardState.Text = card.state;
}
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!