Remove duplicate code, reuse GetMacros function

This commit is contained in:
John Lewin 2016-02-23 10:07:36 -08:00
parent 2aef5b2be6
commit ebf66bb849
2 changed files with 3 additions and 16 deletions

View file

@ -162,7 +162,7 @@ namespace MatterHackers.MatterControl.PrinterControls
return macroButtonContainer;
}
private IEnumerable<DataStorage.CustomCommands> GetMacros()
internal static IEnumerable<DataStorage.CustomCommands> GetMacros()
{
if (ActivePrinterProfile.Instance.ActivePrinter != null)
{

View file

@ -32,6 +32,7 @@ using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.DataStorage;
using MatterHackers.MatterControl.FieldValidation;
using MatterHackers.MatterControl.PrinterControls;
using MatterHackers.VectorMath;
using System;
using System.Collections.Generic;
@ -286,8 +287,7 @@ namespace MatterHackers.MatterControl
topToBottom.AddChild(presetsFormContainer);
IEnumerable<DataStorage.CustomCommands> macroList = GetMacros();
foreach (DataStorage.CustomCommands currentCommand in macroList)
foreach (DataStorage.CustomCommands currentCommand in MacroControlsWidget.GetMacros())
{
FlowLayoutWidget macroRow = new FlowLayoutWidget();
macroRow.Margin = new BorderDouble(3, 0, 3, 3);
@ -354,19 +354,6 @@ namespace MatterHackers.MatterControl
this.AnchorAll();
}
private IEnumerable<DataStorage.CustomCommands> GetMacros()
{
IEnumerable<DataStorage.CustomCommands> results = Enumerable.Empty<DataStorage.CustomCommands>();
if (ActivePrinterProfile.Instance.ActivePrinter != null)
{
//Retrieve a list of saved printers from the Datastore
string query = string.Format("SELECT * FROM CustomCommands WHERE PrinterId = {0};", ActivePrinterProfile.Instance.ActivePrinter.Id);
results = (IEnumerable<DataStorage.CustomCommands>)DataStorage.Datastore.Instance.dbSQLite.Query<DataStorage.CustomCommands>(query);
return results;
}
return results;
}
private void addMacro_Click(object sender, EventArgs mouseEvent)
{
windowController.ChangeToMacroDetail();