60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
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 MatrixCalculator
|
|
{
|
|
public partial class ImportWorksheetWindow : Form
|
|
{
|
|
public DataTable Data { get; set; }
|
|
|
|
public ImportWorksheetWindow()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void LoadFile(string filename)
|
|
{
|
|
WorksheetFile file = new WorksheetFile(filename);
|
|
Data = file.Read();
|
|
|
|
listMatrices.Items.Clear();
|
|
|
|
foreach (DataRow i in Data.Rows)
|
|
listMatrices.Items.Add(i["name"].ToString());
|
|
}
|
|
|
|
private void buttonCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
|
|
private void buttonAccept_Click(object sender, EventArgs e)
|
|
{
|
|
List<DataRow> toRemove = new List<DataRow>();
|
|
|
|
foreach (DataRow i in Data.Rows)
|
|
if (!listMatrices.CheckedItems.Contains(i["name"].ToString())) toRemove.Add(i);
|
|
|
|
foreach (var i in toRemove)
|
|
Data.Rows.Remove(i);
|
|
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
|
|
#region Paint
|
|
protected override void OnPaintBackground(PaintEventArgs e)
|
|
{
|
|
DynamicLink.Controls.BackgroundGradient.Paint(e.Graphics, new Rectangle(-1, -1, this.Width, this.Height));
|
|
}
|
|
#endregion
|
|
}
|
|
}
|