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
}
}
}
/*
[Description("Binded to user")]
public int ReserverId
{
get { return APIreference.eventuserId; }
set { APIreference.eventuserId = value; }
}*/
public bool Dirty = false;
[Category("Place map")]
......@@ -134,42 +129,70 @@ namespace MoyaAdminUI
get { return APIreference.name; }
set { APIreference.name = value; }
}
[Category("Reservation")]
User reserverUserCache = null;
[Category("Reservation"), DisplayName("Player"), Description("Person who will sit to place")]
public string ReserverUserName
{
get
{
if (APIreference.reserverId > 0)
if (reserverUserCache == null)
{
if (getUser() == null)
if (APIreference.eventuserId > 0)
{
foreach (User u in User.Cache)
{
if (u.EventUserId == APIreference.eventuserId)
{
reserverUserCache = u;
break;
}
}
}
// Still no hit, use buyer
if (reserverUserCache == null)
{
return "ERR";
foreach (User u in User.Cache)
{
if (u.EventUserId == APIreference.reserverId)
{
reserverUserCache = u;
break;
}
}
}
else
return User.ToString();
}
return "free";
if (reserverUserCache == null)
return "free";
else return
reserverUserCache.ToString();
}
}
[Category("Reservation")]
User buyerUserCache = null;
[Category("Reservation"), DisplayName("Buyer"), Description("Person who had payed place")]
public User User
{
get
{
return getUser();
if (buyerUserCache == null)
{
foreach (User u in User.Cache)
{
if (u.EventUserId == APIreference.reserverId)
{
buyerUserCache = u;
break;
}
}
}
return buyerUserCache;
}
//set { }
}
private MoyaAdminUI.User getUser()
{
foreach (User u in User.Cache)
{
if (u.EventUserId == APIreference.reserverId)
return u;
}
return null;
}
public Point GetPoint()
{
return new Point(this.MapX, this.MapY);
......@@ -218,6 +241,8 @@ namespace MoyaAdminUI
}
public void Release()
{
reserverUserCache = null;
buyerUserCache = null;
APIreference.Release();
}
......@@ -227,6 +252,8 @@ namespace MoyaAdminUI
* */
internal void Reserve(User user)
{
reserverUserCache = null;
buyerUserCache = null;
APIreference.Reserve(user.EventUserId);
}
}
......
......@@ -45,6 +45,7 @@ namespace MoyaAdminUI
{
MessageBox.Show(ex.Message + "\r\nCannot connect to Moya.\r\nCheck Api url and key");
}
}
private void loadPlacemap()
......@@ -59,7 +60,7 @@ namespace MoyaAdminUI
loadComputerPlaces();
}
loadImage();
}
ComputerPlace selectedPlace;
......@@ -104,6 +105,7 @@ namespace MoyaAdminUI
Size borderSize = this.Size - this.ClientSize;
this.MapPictureBox.Load(RestClient.GetRequestURL(Properties.Settings.Default.ApiURL, "placeadmin/background/" + SelectedMap.Id));
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;
}
......@@ -609,7 +611,10 @@ namespace MoyaAdminUI
}
else if (place.Taken)
{
brush = Brushes.Red;
if (place.APIReference.eventuserId > 0)
brush = Brushes.Green;
else
brush = Brushes.Red;
}
else if (place.Buyable)
brush = Brushes.White;
......@@ -661,7 +666,8 @@ namespace MoyaAdminUI
placeEditor.SelectedObject = selectedPlace;
}
this.MapPictureBox.Refresh();
ImageRefreshTimer.Start();
}
private void SaveButton_Click(object sender, EventArgs e)
......@@ -839,21 +845,24 @@ namespace MoyaAdminUI
{
mouseDownPoint = e.Location;
mouseDownComputerPlace = findPlace(mouseDownPoint);
if (mouseDownComputerPlace != null)
{
//editComputerPlace(mouseDownComputerPlace);
selectedPlace = mouseDownComputerPlace;
mouseDownOffset = new Size(
e.Location.X - mouseDownComputerPlace.MapX,
e.Location.Y - mouseDownComputerPlace.MapY
);
newPlaceHeight = mouseDownComputerPlace.Height;
newPlaceWidth = mouseDownComputerPlace.Width;
}
else
{
editComputerPlace(null);
}
//if (UnlockToolStripButton.Checked)
//{
if (mouseDownComputerPlace != null)
{
//editComputerPlace(mouseDownComputerPlace);
selectedPlace = mouseDownComputerPlace;
mouseDownOffset = new Size(
e.Location.X - mouseDownComputerPlace.MapX,
e.Location.Y - mouseDownComputerPlace.MapY
);
newPlaceHeight = mouseDownComputerPlace.Height;
newPlaceWidth = mouseDownComputerPlace.Width;
}
else
{
editComputerPlace(null);
}
//}
}
}
......@@ -891,11 +900,12 @@ namespace MoyaAdminUI
private void MapPictureBox_MouseMove(object sender, MouseEventArgs e)
{
unsafe
{
// 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
......@@ -961,13 +971,39 @@ namespace MoyaAdminUI
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)
{
//set multiselect range so we can draw the selectarea rectangle
multiSelectStart = mouseDownPoint;
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
disableEvents = true;
this.PlacesListView.BeginUpdate();
......@@ -1087,10 +1123,55 @@ namespace MoyaAdminUI
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 @@
//
// bookNumericUpDown
//
this.bookNumericUpDown.Enabled = false;
this.bookNumericUpDown.Location = new System.Drawing.Point(363, 159);
this.bookNumericUpDown.Name = "bookNumericUpDown";
this.bookNumericUpDown.ReadOnly = true;
......@@ -172,6 +173,7 @@
//
// pageNumericUpDown
//
this.pageNumericUpDown.Enabled = false;
this.pageNumericUpDown.Location = new System.Drawing.Point(363, 185);
this.pageNumericUpDown.Name = "pageNumericUpDown";
this.pageNumericUpDown.ReadOnly = true;
......@@ -180,6 +182,7 @@
//
// slotNumericUpDown
//
this.slotNumericUpDown.Enabled = false;
this.slotNumericUpDown.Location = new System.Drawing.Point(363, 211);
this.slotNumericUpDown.Name = "slotNumericUpDown";
this.slotNumericUpDown.ReadOnly = true;
......
......@@ -30,14 +30,17 @@
{
this.components = new System.ComponentModel.Container();
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.columnHeader2 = ((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.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.pictureBox1 = new System.Windows.Forms.PictureBox();
this.CardState = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// usersListView
......@@ -53,16 +56,37 @@
this.usersListView.FullRowSelect = true;
this.usersListView.Location = new System.Drawing.Point(12, 58);
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.UseCompatibleStateImageBehavior = false;
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);
//
// 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
//
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.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
......@@ -86,35 +110,35 @@
this.label1.TabIndex = 3;
this.label1.Text = "Search";
//
// columnHeader1
//
this.columnHeader1.Text = "Nick";
this.columnHeader1.Width = 118;
//
// columnHeader2
//
this.columnHeader2.Text = "Firstname";
this.columnHeader2.Width = 112;
// searchTimer
//
// columnHeader3
this.searchTimer.Tick += new System.EventHandler(this.searchTimer_Tick);
//
this.columnHeader3.Text = "Lastname";
this.columnHeader3.Width = 150;
// pictureBox1
//
// 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";
this.columnHeader4.Width = 93;
// CardState
//
// searchTimer
//
this.searchTimer.Tick += new System.EventHandler(this.searchTimer_Tick);
this.CardState.Location = new System.Drawing.Point(535, 412);
this.CardState.Name = "CardState";
this.CardState.ReadOnly = true;
this.CardState.Size = new System.Drawing.Size(260, 20);
this.CardState.TabIndex = 5;
//
// UsersFinderForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
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.searchTextBox);
this.Controls.Add(this.button1);
......@@ -122,6 +146,7 @@
this.Name = "UsersFinderForm";
this.Text = "Users Finder";
this.Load += new System.EventHandler(this.UsersFinderForm_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
......@@ -138,5 +163,7 @@
private System.Windows.Forms.TextBox searchTextBox;
private System.Windows.Forms.Label label1;
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.ComponentModel;
using System.Data;
......@@ -6,6 +8,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
namespace MoyaAdminUI
......@@ -81,5 +84,22 @@ namespace MoyaAdminUI
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!