Add missed changes from query/DataStorage update

This commit is contained in:
John Lewin 2016-02-24 07:57:15 -08:00
parent bb7f69eea4
commit feb0c30b51
2 changed files with 12 additions and 10 deletions

View file

@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.DataStorage;
using MatterHackers.MatterControl.PrinterCommunication;
using MatterHackers.MatterControl.SlicerConfiguration;
using System;
@ -139,13 +140,12 @@ namespace MatterHackers.MatterControl.PrinterControls
macroButtonContainer.Margin = new BorderDouble(3, 0);
macroButtonContainer.Padding = new BorderDouble(3);
IEnumerable<DataStorage.CustomCommands> macroList = GetMacros();
int buttonCount = 0;
foreach (DataStorage.CustomCommands m in macroList)
foreach (CustomCommands macro in GetMacros())
{
buttonCount++;
Button macroButton = textImageButtonFactory.Generate(m.Name);
macroButton.Text = m.Value;
Button macroButton = textImageButtonFactory.Generate(macro.Name);
macroButton.Text = macro.Value;
macroButton.Margin = new BorderDouble(right: 5);
macroButton.Click += (sender, e) =>
{
@ -153,26 +153,28 @@ namespace MatterHackers.MatterControl.PrinterControls
};
macroButtonContainer.AddChild(macroButton);
}
if (buttonCount == 0)
{
TextWidget noMacrosFound = new TextWidget(LocalizedString.Get("No macros are currently set up for this printer."), pointSize: 10);
noMacrosFound.TextColor = ActiveTheme.Instance.PrimaryTextColor;
macroButtonContainer.AddChild(noMacrosFound);
}
return macroButtonContainer;
}
internal static IEnumerable<DataStorage.CustomCommands> GetMacros()
internal static IEnumerable<CustomCommands> GetMacros()
{
if (ActivePrinterProfile.Instance.ActivePrinter != null)
{
//Retrieve a list of macros from the database
string query = string.Format("SELECT * FROM CustomCommands WHERE PrinterId = {0};", ActivePrinterProfile.Instance.ActivePrinter.Id);
return DataStorage.Datastore.Instance.dbSQLite.Query<DataStorage.CustomCommands>(query);
return Datastore.Instance.dbSQLite.Query<CustomCommands>(query);
}
return Enumerable.Empty<DataStorage.CustomCommands>();
return Enumerable.Empty<CustomCommands>();
}
protected void SendCommandToPrinter(string command)

View file

@ -287,7 +287,7 @@ namespace MatterHackers.MatterControl
topToBottom.AddChild(presetsFormContainer);
foreach (DataStorage.CustomCommands currentCommand in MacroControlsWidget.GetMacros())
foreach (CustomCommands currentCommand in MacroControlsWidget.GetMacros())
{
FlowLayoutWidget macroRow = new FlowLayoutWidget();
macroRow.Margin = new BorderDouble(3, 0, 3, 3);
@ -306,7 +306,7 @@ namespace MatterHackers.MatterControl
editLink.Margin = new BorderDouble(right: 5);
// You can't pass a foreach variable into a link function or it wall always be the last item.
// So we make a local variable copy of it and pass that. This will get the right one.
DataStorage.CustomCommands currentCommandForLinkFunction = currentCommand;
CustomCommands currentCommandForLinkFunction = currentCommand;
editLink.Click += (sender, e) =>
{
windowController.ChangeToMacroDetail(currentCommandForLinkFunction);
@ -364,7 +364,7 @@ namespace MatterHackers.MatterControl
{
public EventHandler functionToCallOnSave;
public DataStorage.CustomCommands ActiveMacro;
public CustomCommands ActiveMacro;
public EditMacrosWindow(EventHandler functionToCallOnSave)
: base(360, 420)