-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainForm.cs
More file actions
144 lines (115 loc) · 4.03 KB
/
MainForm.cs
File metadata and controls
144 lines (115 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#region using statements
using DataJuggler.Win.Controls;
using DataJuggler.Win.Controls.Interfaces;
using DataJuggler.Excelerate;
using DataJuggler.UltimateHelper;
using ExcelerateWinApp.Objects;
using DataJuggler.Excelerate.Delegates;
using DataJuggler.Excelerate.Interfaces;
#endregion
namespace ExcelerateWinApp
{
#region class MainForm
/// <summary>
/// This class is the MainForm for this app.
/// </summary>
public partial class MainForm : Form, ITextChanged
{
#region Private Variables
#endregion
#region Constructor
/// <summary>
/// Create a new instance of a 'MainForm' object.
/// </summary>
public MainForm()
{
// Create Controls
InitializeComponent();
// wire up the listener
FileSelector.OnTextChangedListener = this;
}
#endregion
#region Events
#region OnTextChanged(Control sender, string text)
/// <summary>
/// event is fired when On Text Changed
/// </summary>
public void OnTextChanged(Control sender, string text)
{
// enable the control if it exists
UpdateButton.Enabled = TextHelper.Exists(text);
}
#endregion
#region UpdateButton_Click(object sender, EventArgs e)
/// <summary>
/// event is fired when the 'UpdateButton' is clicked.
/// </summary>
private void UpdateButton_Click(object sender, EventArgs e)
{
// load your object(s)
string workbookPath = FileSelector.Text;
// Example WorksheetInfo object
WorksheetInfo info = new WorksheetInfo();
info.LoadColumnOptions = LoadColumnOptionsEnum.LoadAllColumnsExceptExcluded;
info.Path = workbookPath;
// Change to your SheetName
info.SheetName = "";
// Example load Worksheet
Worksheet worksheet = ExcelDataLoader.LoadWorksheet(workbookPath, info);
// If the worksheet object exist
if (NullHelper.Exists(worksheet))
{
// load your objects (example)
// List<Address> addresses = Address.Load(worksheet);
// perform your updates
// to save back to Excel
// you must convert the list before we can pass it in
// List<IExcelerateObject> excelerateObjectList = addresses.Cast<IExcelerateObject>().ToList();
// Save Worksheet Example
// ExcelHelper.SaveWorksheet(excelerateObjectList, worksheet, info, SaveWorksheetCallback, 500);
// show finished
StatusLabel.Text = "Done.";
Graph.Visible = false;
}
}
#endregion
#endregion
#region Methods
#region SaveWorksheetCallback(SaveWorksheetResponse resonse)
/// <summary>
/// Save Worksheet Callback
/// </summary>
public void SaveWorksheetCallback(SaveWorksheetResponse response)
{
// If the response object exists
if (NullHelper.Exists(response))
{
// Update the graph
Graph.Value = response.RowsSaved;
StatusLabel.Text = "Saved " + response.CurrentRowNumber + " of " + response.TotalRows;
// update the UI
Refresh();
Application.DoEvents();
}
}
#endregion
#region SetupGraph()
/// <summary>
/// Setup Graph
/// </summary>
public void SetupGraph(string statusText, int graphMaxium, bool showGraph)
{
// Show or hide
StatusLabel.Text = statusText;
StatusLabel.Visible = showGraph;
Graph.Maximum = graphMaxium;
Graph.Visible = showGraph;
Graph.Value = 0;
}
#endregion
#endregion
#region Properties
#endregion
}
#endregion
}