Skip to content

Commit

Permalink
Add control bindings to settings model (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
gyk4j authored Mar 7, 2024
1 parent e31839f commit 8ece2a7
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 141 deletions.
12 changes: 6 additions & 6 deletions WreckGui/Controller/GuiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ protected override void Init()
string member = Model.GetBindingDataMember(c);
View.GetMain().Bind(Model, c, member);
}

string m = Model.GetBindingDataMember();
View.GetMain().Bind(Model, m);
}

public override void Error()
Expand Down Expand Up @@ -149,19 +152,16 @@ public override void Run(CorrectionMode mode, string[] paths)
Dictionary<SourceEnum, bool> sources = new Dictionary<SourceEnum, bool>();
foreach(SourceEnum s in SourceEnum.Values)
{
// FIXME: To check GUI control checkbox
sources.Add(s, true);
sources.Add(s, Model.SourceModel[s]);
}

Dictionary<CorrectionEnum, bool> corrections = new Dictionary<CorrectionEnum, bool>();
foreach(CorrectionEnum c in CorrectionEnum.Values)
{
// FIXME: To check GUI control checkbox
corrections.Add(c, true);
corrections.Add(c, Model.CorrectionModel[c]);
}

// FIXME: To check GUI control checkbox and textbox
DateTime customDateTime = DateTime.Now;
DateTime customDateTime = Model.CustomDateTimeModel;

List<ITask> tasks = Service.Run(paths, mode, sources, corrections, customDateTime);

Expand Down
20 changes: 10 additions & 10 deletions WreckGui/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions WreckGui/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ public void Bind(object source, CorrectionEnum type, string member)
control.DataBindings.Add(binding);
}

public void Bind(object source, string member)
{
// HACK: must be true if not subsequent correction enum checkboxes would not be bound properly.
// Maybe date time string parsing between DateTimePicker
// (string) and model DateTime crashes?
Binding binding = new Binding(
"Value",
source,
member,
true,
DataSourceUpdateMode.OnPropertyChanged);
dtpCustom.DataBindings.Add(binding);
}

void BtnRunClick(object sender, EventArgs e)
{
Program.Controller.Repair();
Expand Down
Loading

0 comments on commit 8ece2a7

Please sign in to comment.