Rebuild connecting, recreated active sessions, bugfixes
This commit is contained in:
+4
-2
@@ -15,10 +15,12 @@ namespace ErgometerDoctorApplication
|
||||
private MetingType type;
|
||||
private ChartArea chartArea;
|
||||
private Series series;
|
||||
private SeriesChartType ChartType;
|
||||
|
||||
public ChartPanel(MetingType type) : base()
|
||||
public ChartPanel(MetingType type, SeriesChartType charttype) : base()
|
||||
{
|
||||
this.type = type;
|
||||
this.ChartType = charttype;
|
||||
|
||||
this.chart = new Chart();
|
||||
this.chartArea = new ChartArea();
|
||||
@@ -57,7 +59,7 @@ namespace ErgometerDoctorApplication
|
||||
{
|
||||
Series serie = new Series();
|
||||
serie.Name = "series";
|
||||
serie.ChartType = SeriesChartType.Line;
|
||||
serie.ChartType = ChartType;
|
||||
serie.ChartArea = "chartArea";
|
||||
serie.BorderWidth = 3;
|
||||
return serie;
|
||||
+8
-16
@@ -8,7 +8,7 @@ using System.Windows.Forms;
|
||||
|
||||
namespace ErgometerDoctorApplication
|
||||
{
|
||||
class ClientThread
|
||||
public class ClientThread
|
||||
{
|
||||
public int Session { get; }
|
||||
public string Name { get; }
|
||||
@@ -23,7 +23,7 @@ namespace ErgometerDoctorApplication
|
||||
Name = name;
|
||||
Session = session;
|
||||
|
||||
window = new SessionWindow(Name, true, Session);
|
||||
window = new SessionWindow(Name, true, Session, this);
|
||||
window.FormClosed += Window_FormClosed;
|
||||
|
||||
Metingen = new List<Meting>();
|
||||
@@ -40,7 +40,11 @@ namespace ErgometerDoctorApplication
|
||||
switch (command.Type)
|
||||
{
|
||||
case NetCommand.CommandType.DATA:
|
||||
SaveMeting(command.Meting);
|
||||
lock(Metingen)
|
||||
{
|
||||
Metingen.Add(command.Meting);
|
||||
}
|
||||
window.Invoke(window.updateMetingen, new Object[] { command.Meting });
|
||||
break;
|
||||
case NetCommand.CommandType.CHAT:
|
||||
ChatMessage chat = new ChatMessage(command.DisplayName, command.ChatMessage, false);
|
||||
@@ -65,18 +69,6 @@ namespace ErgometerDoctorApplication
|
||||
{
|
||||
MainClient.SendNetCommand(command);
|
||||
}
|
||||
|
||||
public void SaveMeting(Meting m)
|
||||
{
|
||||
Metingen.Add(m);
|
||||
|
||||
window.heartBeat.updateValue(m.HeartBeat);
|
||||
window.RPM.updateValue(m.RPM);
|
||||
window.speed.updateValue(m.Speed);
|
||||
window.distance.updateValue(m.Distance);
|
||||
window.power.updateValue(m.Power);
|
||||
window.energy.updateValue(m.Energy);
|
||||
window.actualpower.updateValue(m.ActualPower);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+9
-18
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.DataVisualization.Charting;
|
||||
|
||||
namespace ErgometerDoctorApplication
|
||||
{
|
||||
@@ -32,16 +33,7 @@ namespace ErgometerDoctorApplication
|
||||
}
|
||||
|
||||
List<Meting> metingen = new List<Meting>();
|
||||
metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32));
|
||||
metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32));
|
||||
metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32));
|
||||
metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32));
|
||||
metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32));
|
||||
metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32));
|
||||
metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32));
|
||||
metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32));
|
||||
metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32));
|
||||
metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32));
|
||||
metingen.Add(new Meting(0, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||
|
||||
updateAllCharts(metingen);
|
||||
//
|
||||
@@ -59,14 +51,13 @@ namespace ErgometerDoctorApplication
|
||||
public void createCharts()
|
||||
{
|
||||
charts = new List<ChartPanel>();
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.HEARTBEAT));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.RPM));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.SPEED));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.DISTANCE));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.ENERGY));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.SECONDS));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.POWER));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.ACTUALPOWER));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.HEARTBEAT, SeriesChartType.Line));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.RPM, SeriesChartType.Line));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.SPEED, SeriesChartType.Line));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.DISTANCE, SeriesChartType.Line));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.ENERGY, SeriesChartType.Line));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.POWER, SeriesChartType.Line));
|
||||
charts.Add(new ChartPanel(ChartPanel.MetingType.ACTUALPOWER, SeriesChartType.Line));
|
||||
}
|
||||
|
||||
public void updateAllCharts(List<Meting> metingen)
|
||||
+1
-1
@@ -146,7 +146,7 @@ namespace ErgometerDoctorApplication
|
||||
#endregion
|
||||
private System.Windows.Forms.Panel panelClientContainer;
|
||||
public PanelClientChat panelClientChat;
|
||||
private PanelGraphView panelGraphView;
|
||||
public PanelGraphView panelGraphView;
|
||||
private System.Windows.Forms.Panel panelDataViewLeft;
|
||||
private System.Windows.Forms.Panel panelTopBar;
|
||||
private System.Windows.Forms.Label labelUsername;
|
||||
+36
-2
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ErgometerLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@@ -17,11 +18,24 @@ namespace ErgometerDoctorApplication
|
||||
private string ClientName { get; set; }
|
||||
public int Session { get; }
|
||||
|
||||
public SessionWindow(string ClientName, bool ActiveSessionm, int session)
|
||||
private ClientThread client;
|
||||
|
||||
private int count;
|
||||
|
||||
public delegate void UpdateMetingen(Meting m);
|
||||
public UpdateMetingen updateMetingen;
|
||||
|
||||
public SessionWindow(string ClientName, bool ActiveSessionm, int session, ClientThread parentthread)
|
||||
{
|
||||
this.ActiveSession = ActiveSession;
|
||||
this.ClientName = ClientName;
|
||||
this.client = parentthread;
|
||||
Session = session;
|
||||
|
||||
count = 0;
|
||||
|
||||
updateMetingen = new UpdateMetingen(this.SaveMeting);
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
Form.CheckForIllegalCrossThreadCalls = false;
|
||||
@@ -50,5 +64,25 @@ namespace ErgometerDoctorApplication
|
||||
panelDataViewLeft.Dock = DockStyle.Left;
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveMeting(Meting m)
|
||||
{
|
||||
|
||||
heartBeat.updateValue(m.HeartBeat);
|
||||
RPM.updateValue(m.RPM);
|
||||
speed.updateValue(m.Speed);
|
||||
distance.updateValue(m.Distance);
|
||||
power.updateValue(m.Power);
|
||||
energy.updateValue(m.Energy);
|
||||
actualpower.updateValue(m.ActualPower);
|
||||
|
||||
if (count >= 10)
|
||||
{
|
||||
count = 0;
|
||||
panelGraphView.updateAllCharts(client.Metingen);
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,31 +10,13 @@ namespace ErgometerDoctorApplication
|
||||
{
|
||||
public class ConActiveSessions : Panel
|
||||
{
|
||||
public DataGridView data;
|
||||
|
||||
private FlowLayoutPanel flowlayout;
|
||||
|
||||
public ConActiveSessions() : base()
|
||||
{
|
||||
this.data = new DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)(this.data)).BeginInit();
|
||||
this.labelActiveSessions = new System.Windows.Forms.Label();
|
||||
//
|
||||
// SongsTableView
|
||||
//
|
||||
this.data.AllowUserToAddRows = false;
|
||||
this.data.AllowUserToDeleteRows = false;
|
||||
this.data.AllowUserToResizeRows = false;
|
||||
this.data.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.data.Location = new System.Drawing.Point(0, 0);
|
||||
this.data.MultiSelect = false;
|
||||
this.data.Name = "Active Sessions";
|
||||
this.data.ReadOnly = true;
|
||||
this.data.RowHeadersVisible = false;
|
||||
this.data.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.data.Size = new System.Drawing.Size(760, 172);
|
||||
this.data.TabIndex = 0;
|
||||
labelActiveSessions = new Label();
|
||||
|
||||
//
|
||||
// ConActiveSessions
|
||||
//
|
||||
@@ -53,11 +35,33 @@ namespace ErgometerDoctorApplication
|
||||
this.labelActiveSessions.Name = "labelActiveSessions";
|
||||
this.labelActiveSessions.Size = new System.Drawing.Size(103, 21);
|
||||
this.labelActiveSessions.TabIndex = 3;
|
||||
this.labelActiveSessions.Text = "Geen actieve sessies.";
|
||||
this.labelActiveSessions.Text = "Er zijn geen actieve sessies.";
|
||||
|
||||
flowlayout = new FlowLayoutPanel();
|
||||
|
||||
flowlayout.Dock = DockStyle.Fill;
|
||||
flowlayout.BackColor = System.Drawing.Color.DarkGray;
|
||||
flowlayout.Location = new System.Drawing.Point(0, 0);
|
||||
flowlayout.Name = "flowlayout";
|
||||
flowlayout.Padding = new Padding(15);
|
||||
flowlayout.AutoScroll = true;
|
||||
|
||||
this.Controls.Add(labelActiveSessions);
|
||||
this.Controls.Add(flowlayout);
|
||||
|
||||
}
|
||||
|
||||
public System.Windows.Forms.Label labelActiveSessions;
|
||||
|
||||
public void updateActiveSessions(Dictionary<int, string> actives)
|
||||
{
|
||||
flowlayout.Controls.Clear();
|
||||
|
||||
foreach (KeyValuePair<int, string> pair in actives)
|
||||
{
|
||||
|
||||
flowlayout.Controls.Add(new SessionPanel(pair.Key, pair.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,26 +52,23 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ChartPanel.cs">
|
||||
<Compile Include="Client\ChartPanel.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SessionTable.cs">
|
||||
<Compile Include="Client\ClientThread.cs" />
|
||||
<Compile Include="Client\PanelClientChat.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ClientThread.cs" />
|
||||
<Compile Include="PanelClientChat.cs">
|
||||
<Compile Include="Client\PanelClientData.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="PanelClientData.cs">
|
||||
<Compile Include="Client\PanelGraphView.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="PanelGraphView.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SessionWindow.cs">
|
||||
<Compile Include="Client\SessionWindow.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SessionWindow.Designer.cs">
|
||||
<Compile Include="Client\SessionWindow.Designer.cs">
|
||||
<DependentUpon>SessionWindow.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ConClientData.cs">
|
||||
@@ -98,6 +95,9 @@
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SessionPanel.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="MainWindow.resx">
|
||||
<DependentUpon>MainWindow.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@@ -111,7 +111,7 @@
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="SessionWindow.resx">
|
||||
<EmbeddedResource Include="Client\SessionWindow.resx">
|
||||
<DependentUpon>SessionWindow.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace ErgometerDoctorApplication
|
||||
class MainClient
|
||||
{
|
||||
|
||||
public static TcpClient Server { get; }
|
||||
public static TcpClient Server { get; set; }
|
||||
|
||||
public static bool loggedin;
|
||||
|
||||
@@ -41,8 +41,6 @@ namespace ErgometerDoctorApplication
|
||||
{
|
||||
Server = new TcpClient();
|
||||
|
||||
t = new Thread(run);
|
||||
|
||||
loggedin = false;
|
||||
|
||||
clients = new List<ClientThread>();
|
||||
@@ -55,8 +53,11 @@ namespace ErgometerDoctorApplication
|
||||
{
|
||||
error = "Succes";
|
||||
|
||||
if (!Server.Connected)
|
||||
if (Server == null || !Server.Connected)
|
||||
{
|
||||
if (Server == null)
|
||||
Server = new TcpClient();
|
||||
|
||||
try
|
||||
{
|
||||
Server.Connect(HOST, PORT);
|
||||
@@ -74,6 +75,7 @@ namespace ErgometerDoctorApplication
|
||||
throw new Exception("Session not assigned");
|
||||
|
||||
running = true;
|
||||
t = new Thread(run);
|
||||
t.IsBackground = true;
|
||||
t.Start();
|
||||
}
|
||||
@@ -106,7 +108,9 @@ namespace ErgometerDoctorApplication
|
||||
{
|
||||
NetHelper.SendNetCommand(Server, new NetCommand(NetCommand.CommandType.LOGOUT, Session));
|
||||
loggedin = false;
|
||||
running = false;
|
||||
running = false;
|
||||
Server.Close();
|
||||
Server = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +163,9 @@ namespace ErgometerDoctorApplication
|
||||
throw new FormatException("Error in NetCommand: Length type is not recognised");
|
||||
}
|
||||
break;
|
||||
case NetCommand.CommandType.ERROR:
|
||||
Console.WriteLine("An error occured, ignoring");
|
||||
break;
|
||||
default:
|
||||
HandToClient(command);
|
||||
break;
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ namespace ErgometerDoctorApplication
|
||||
//
|
||||
// updateTimer
|
||||
//
|
||||
this.updateTimer.Interval = 10000;
|
||||
this.updateTimer.Interval = 6000;
|
||||
this.updateTimer.Tick += new EventHandler(this.updateTimer_tick);
|
||||
//
|
||||
// label1
|
||||
|
||||
@@ -25,14 +25,15 @@ namespace ErgometerDoctorApplication
|
||||
this.HeaderLabel.Text = "Actieve Sessies";
|
||||
conActiveSessions.BringToFront();
|
||||
|
||||
string str = "";
|
||||
foreach(KeyValuePair<int, string> client in MainClient.activesessions)
|
||||
if(MainClient.activesessions.Count > 0)
|
||||
{
|
||||
str += client.Value + ", ";
|
||||
MainClient.StartNewCLient(client.Value, client.Key);
|
||||
conActiveSessions.labelActiveSessions.Text = "";
|
||||
conActiveSessions.updateActiveSessions(MainClient.activesessions);
|
||||
}
|
||||
else
|
||||
{
|
||||
conActiveSessions.labelActiveSessions.Text = "Er zijn geen actieve sessies.";
|
||||
}
|
||||
conActiveSessions.labelActiveSessions.Text = str;
|
||||
Console.WriteLine(str);
|
||||
}
|
||||
|
||||
private void BtnSessionLibrary_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ErgometerDoctorApplication
|
||||
{
|
||||
class SessionPanel : Panel
|
||||
{
|
||||
private int Session;
|
||||
private string Name;
|
||||
|
||||
public SessionPanel(int session, string name) : base()
|
||||
{
|
||||
|
||||
Session = session;
|
||||
Name = name;
|
||||
|
||||
this.Location = new System.Drawing.Point(0, 0);
|
||||
this.Size = new System.Drawing.Size(180, 100);
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
|
||||
this.Click += SessionPanel_Click;
|
||||
this.MouseEnter += SessionPanel_MouseEnter;
|
||||
this.MouseLeave += SessionPanel_MouseLeave;
|
||||
this.Cursor = Cursors.Hand;
|
||||
|
||||
this.labelName = new System.Windows.Forms.Label();
|
||||
|
||||
//
|
||||
// labelActiveSessions
|
||||
//
|
||||
this.labelName.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.labelName.AutoSize = true;
|
||||
this.labelName.Font = new System.Drawing.Font("Segoe UI Semibold", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.labelName.Location = new System.Drawing.Point(10, 10);
|
||||
this.labelName.ForeColor = System.Drawing.Color.Gray;
|
||||
this.labelName.Name = "labelActiveSessions";
|
||||
this.labelName.Size = new System.Drawing.Size(103, 21);
|
||||
this.labelName.TabIndex = 3;
|
||||
this.labelName.Text = name;
|
||||
this.labelName.Click += SessionPanel_Click;
|
||||
this.labelName.MouseEnter += SessionPanel_MouseEnter;
|
||||
this.labelName.MouseLeave += SessionPanel_MouseLeave;
|
||||
this.labelName.Cursor = Cursors.Hand;
|
||||
|
||||
this.Controls.Add(labelName);
|
||||
}
|
||||
|
||||
private void SessionPanel_MouseEnter(object sender, System.EventArgs e)
|
||||
{
|
||||
this.BackColor = System.Drawing.Color.LightGray;
|
||||
this.labelName.ForeColor = System.Drawing.Color.DarkGray;
|
||||
}
|
||||
|
||||
private void SessionPanel_MouseLeave(object sender, System.EventArgs e)
|
||||
{
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.labelName.ForeColor = System.Drawing.Color.Gray;
|
||||
}
|
||||
|
||||
private void SessionPanel_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
MainClient.StartNewCLient(Name, Session);
|
||||
}
|
||||
|
||||
public System.Windows.Forms.Label labelName;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ErgometerDoctorApplication
|
||||
{
|
||||
public class SessionTable : DataTable
|
||||
{
|
||||
public SessionTable() : base()
|
||||
{
|
||||
this.Columns.Clear();
|
||||
this.Columns.Add("User", typeof (string));
|
||||
this.Columns.Add("SessionId", typeof (string));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user