Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Leden selecteren, sla leden op in XML bestand.

  • Loading branch information...
commit d8def459d42e90ffe0f046b8d9871dc253e0c6fa 1 parent 98d080f
@Sjord authored
View
77 ScoutsOffline/Form1.Designer.cs
@@ -28,15 +28,23 @@ protected override void Dispose(bool disposing)
/// </summary>
private void InitializeComponent()
{
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.SearchBox = new System.Windows.Forms.TextBox();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
+ this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
+ this.toolStrip1 = new System.Windows.Forms.ToolStrip();
+ this.MarkeerLid = new System.Windows.Forms.ToolStripButton();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
+ this.toolStripContainer1.ContentPanel.SuspendLayout();
+ this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
+ this.toolStripContainer1.SuspendLayout();
+ this.toolStrip1.SuspendLayout();
this.SuspendLayout();
//
// SearchBox
//
- this.SearchBox.Location = new System.Drawing.Point(13, 13);
+ this.SearchBox.Location = new System.Drawing.Point(12, 3);
this.SearchBox.Name = "SearchBox";
this.SearchBox.Size = new System.Drawing.Size(245, 20);
this.SearchBox.TabIndex = 0;
@@ -52,33 +60,81 @@ private void InitializeComponent()
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView1.Location = new System.Drawing.Point(12, 39);
+ this.dataGridView1.Location = new System.Drawing.Point(12, 32);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true;
- this.dataGridView1.Size = new System.Drawing.Size(453, 368);
+ this.dataGridView1.Size = new System.Drawing.Size(625, 424);
this.dataGridView1.TabIndex = 1;
this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);
+ this.dataGridView1.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dataGridView1_CellFormatting);
//
// progressBar1
//
- this.progressBar1.Location = new System.Drawing.Point(265, 13);
+ this.progressBar1.Location = new System.Drawing.Point(263, 3);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(200, 23);
this.progressBar1.TabIndex = 2;
//
+ // toolStripContainer1
+ //
+ this.toolStripContainer1.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)));
+ //
+ // toolStripContainer1.ContentPanel
+ //
+ this.toolStripContainer1.ContentPanel.Controls.Add(this.SearchBox);
+ this.toolStripContainer1.ContentPanel.Controls.Add(this.progressBar1);
+ this.toolStripContainer1.ContentPanel.Controls.Add(this.dataGridView1);
+ this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(649, 469);
+ this.toolStripContainer1.Location = new System.Drawing.Point(0, 0);
+ this.toolStripContainer1.Name = "toolStripContainer1";
+ this.toolStripContainer1.Size = new System.Drawing.Size(649, 494);
+ this.toolStripContainer1.TabIndex = 3;
+ this.toolStripContainer1.Text = "toolStripContainer1";
+ //
+ // toolStripContainer1.TopToolStripPanel
+ //
+ this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.toolStrip1);
+ //
+ // toolStrip1
+ //
+ this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None;
+ this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.MarkeerLid});
+ this.toolStrip1.Location = new System.Drawing.Point(3, 0);
+ this.toolStrip1.Name = "toolStrip1";
+ this.toolStrip1.Size = new System.Drawing.Size(33, 25);
+ this.toolStrip1.TabIndex = 0;
+ //
+ // MarkeerLid
+ //
+ this.MarkeerLid.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
+ this.MarkeerLid.Image = ((System.Drawing.Image)(resources.GetObject("MarkeerLid.Image")));
+ this.MarkeerLid.ImageTransparentColor = System.Drawing.Color.Magenta;
+ this.MarkeerLid.Name = "MarkeerLid";
+ this.MarkeerLid.Size = new System.Drawing.Size(23, 22);
+ this.MarkeerLid.Text = "Markeer geselecteerd lid";
+ this.MarkeerLid.Click += new System.EventHandler(this.MarkeerLid_Click);
+ //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(477, 419);
- this.Controls.Add(this.progressBar1);
- this.Controls.Add(this.dataGridView1);
- this.Controls.Add(this.SearchBox);
+ this.ClientSize = new System.Drawing.Size(649, 493);
+ this.Controls.Add(this.toolStripContainer1);
this.Name = "Form1";
this.Text = "ScoutsOffLine";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
+ this.toolStripContainer1.ContentPanel.ResumeLayout(false);
+ this.toolStripContainer1.ContentPanel.PerformLayout();
+ this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false);
+ this.toolStripContainer1.TopToolStripPanel.PerformLayout();
+ this.toolStripContainer1.ResumeLayout(false);
+ this.toolStripContainer1.PerformLayout();
+ this.toolStrip1.ResumeLayout(false);
+ this.toolStrip1.PerformLayout();
this.ResumeLayout(false);
- this.PerformLayout();
}
@@ -87,6 +143,9 @@ private void InitializeComponent()
private System.Windows.Forms.TextBox SearchBox;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.ProgressBar progressBar1;
+ private System.Windows.Forms.ToolStripContainer toolStripContainer1;
+ private System.Windows.Forms.ToolStrip toolStrip1;
+ private System.Windows.Forms.ToolStripButton MarkeerLid;
}
}
View
56 ScoutsOffline/Form1.cs
@@ -8,12 +8,13 @@
using System.Windows.Forms;
using ScoutsOffline.Sol;
using System.Diagnostics;
+using ScoutsOffline.Model;
namespace ScoutsOffline
{
public partial class Form1 : Form
{
- List<Member> members = new List<Member>();
+ Repository repository;
public Form1()
{
@@ -24,6 +25,13 @@ protected override void OnShown(EventArgs e)
{
base.OnShown(e);
+ /*
+ var username = "Sjoerder";
+ repository = new Repository(username);
+ FilterDataSource();
+ return;
+ */
+
var login = new Login();
login.LoginClick += OnLoginClick;
login.Show(this);
@@ -37,6 +45,10 @@ protected void OnLoginClick(object sender, LoginClickEventArgs eArgs)
var sol = new ScoutsOnLine();
if (sol.Authenticate(eArgs.username, eArgs.password))
{
+ var username = eArgs.username;
+ repository = new Repository(username);
+ FilterDataSource();
+
progressBar1.Style = ProgressBarStyle.Marquee;
var getAllMembers = new GetAllMembersDelegate(GetAllMembers);
getAllMembers.BeginInvoke(sol, null, null);
@@ -56,9 +68,8 @@ private void GetAllMembers(ScoutsOnLine sol)
private void AddMembers(List<Member> newMembers, int step, int count)
{
- var allMembers = new HashSet<Member>(this.members);
- allMembers.UnionWith(newMembers);
- this.members = allMembers.OrderBy(m => m.Lidachternaam).ThenBy(m => m.Lidvoornaam).ToList();
+ repository.Model.MemberList.UpdateWith(newMembers);
+ repository.Store();
if (dataGridView1.InvokeRequired)
{
@@ -103,7 +114,7 @@ private void SearchBox_TextChanged(object sender, EventArgs e)
var searchtext = SearchBox.Text;
if (searchtext == string.Empty)
{
- dataGridView1.DataSource = this.members;
+ dataGridView1.DataSource = this.repository.Model.MemberList.Members;
}
else
{
@@ -114,12 +125,45 @@ private void SearchBox_TextChanged(object sender, EventArgs e)
}
else
{
- source = this.members;
+ source = this.repository.Model.MemberList.Members;
}
var keywords = searchtext.Split(new [] {' '}, StringSplitOptions.RemoveEmptyEntries);
dataGridView1.DataSource = source.Where(m => m.Matches(keywords)).ToList();
_previousSearchValue = searchtext;
}
}
+
+ private void MarkeerLid_Click(object sender, EventArgs e)
+ {
+ List<int> rowIndices = new List<int>();
+ foreach (DataGridViewCell cell in dataGridView1.SelectedCells)
+ {
+ var row = cell.RowIndex;
+ if (!rowIndices.Contains(row))
+ rowIndices.Add(row);
+ }
+
+ var members = (List<Member>)dataGridView1.DataSource;
+ foreach (var index in rowIndices)
+ {
+ var member = members[index];
+ repository.Model.MemberList.ToggleSelect(member);
+ }
+ dataGridView1.Refresh();
+ }
+
+ private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
+ {
+ var members = (List<Member>)dataGridView1.DataSource;
+ var member = members[e.RowIndex];
+ if (member.Selected)
+ {
+ e.CellStyle.BackColor = Color.LightYellow;
+ }
+ else
+ {
+ e.CellStyle.BackColor = Color.White;
+ }
+ }
}
}
View
26 ScoutsOffline/Form1.resx
@@ -112,9 +112,31 @@
<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>
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.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>
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <data name="MarkeerLid.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0K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S/P7ZgNOu3+O/
+ DeFrfK+bS5LjDM7uENw7hQTzkrwvXWBt9dbLzT298BrO4Ox2/Q/5zGXSMq+6YQAAAABJRU5ErkJggg==
+</value>
+ </data>
</root>
View
BIN  ScoutsOffline/Images/bookmark-4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
32 ScoutsOffline/Model/MemberList.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ScoutsOffline.Sol;
+using System.Collections;
+
+namespace ScoutsOffline.Model
+{
+ public class MemberList
+ {
+ public List<Member> Members { get; set; }
+
+ public MemberList()
+ {
+ this.Members = new List<Member>();
+ }
+
+ public void UpdateWith(List<Member> newMembers)
+ {
+ // TODO oude leden moeten ook verwijderd worden
+ var allMembers = new HashSet<Member>(this.Members);
+ allMembers.UnionWith(newMembers);
+ this.Members = allMembers.OrderBy(m => m.Lidachternaam).ThenBy(m => m.Lidvoornaam).ToList();
+ }
+
+ internal void ToggleSelect(Member member)
+ {
+ member.Selected = !member.Selected;
+ }
+ }
+}
View
80 ScoutsOffline/Model/Repository.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Xml.Serialization;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+using System.Reflection;
+
+
+namespace ScoutsOffline.Model
+{
+ public class Repository
+ {
+ private string BaseDirectory;
+ private DataContractSerializer serializer;
+ private string file;
+
+ private StoredModel _model;
+ public StoredModel Model
+ {
+ get
+ {
+ if (_model == null)
+ {
+ _model = Get();
+ }
+ return _model;
+ }
+ }
+
+ public Repository(string username)
+ {
+ this.BaseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+ this.serializer = new DataContractSerializer(typeof(StoredModel));
+ this.file = Path.Combine(BaseDirectory, username + ".xml");
+ }
+
+ public StoredModel Get()
+ {
+ if (!File.Exists(file))
+ {
+ return new StoredModel();
+ }
+ using (var stream = File.OpenRead(file))
+ {
+ return (StoredModel)serializer.ReadObject(stream);
+ }
+ }
+
+ public void Store()
+ {
+ Store(Model);
+ }
+
+ public void Store(StoredModel model)
+ {
+ if (File.Exists(file))
+ {
+ var tmpFile = file + "~";
+ StoreToFile(model, tmpFile);
+ File.Replace(tmpFile, file, file + ".bkp");
+ }
+ else
+ {
+ StoreToFile(model, file);
+ }
+ }
+
+ private void StoreToFile(StoredModel model, string filename)
+ {
+ XmlWriterSettings settings = new XmlWriterSettings();
+ settings.Indent = true;
+ using (var xmlWriter = XmlWriter.Create(filename, settings))
+ {
+ serializer.WriteObject(xmlWriter, model);
+ }
+ }
+ }
+}
View
17 ScoutsOffline/Model/StoredModel.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ScoutsOffline.Model
+{
+ public class StoredModel
+ {
+ public StoredModel()
+ {
+ this.MemberList = new MemberList();
+ }
+
+ public MemberList MemberList { get; set; }
+ }
+}
View
4 ScoutsOffline/ScoutsOffline.csproj
@@ -40,6 +40,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
+ <Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@@ -64,6 +65,9 @@
<DependentUpon>Login.cs</DependentUpon>
</Compile>
<Compile Include="LoginClickEventArgs.cs" />
+ <Compile Include="Model\MemberList.cs" />
+ <Compile Include="Model\Repository.cs" />
+ <Compile Include="Model\StoredModel.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PwdHashSharp\DomainExtractor.cs" />
View
2  ScoutsOffline/Sol/Member.cs
@@ -39,6 +39,8 @@ public class Member
public string Organisatie { get; set; }
public string Organisatieplaats { get; set; }
+ public bool Selected { get; set; }
+
private IEnumerable<PropertyInfo> GetSearchProperties()
{
return this.GetType().GetProperties().Where(p => p.Name.StartsWith("Lid"));
Please sign in to comment.
Something went wrong with that request. Please try again.