check point
This commit is contained in:
77
VisionBuilder.UI.Windows/Dialogs/RecipeSelectionDialog.cs
Normal file
77
VisionBuilder.UI.Windows/Dialogs/RecipeSelectionDialog.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using MaterialSkin.Controls;
|
||||
using OpenCvSharp.XImgProc;
|
||||
using System.Text.RegularExpressions;
|
||||
using OpenCvSharp.Extensions;
|
||||
using VisionBuilder.UI.Common.ViewModel;
|
||||
using VisionBuilder.UI.Common.ViewModel.Classes;
|
||||
|
||||
namespace VisionBuilder.UI.Windows.Dialogs
|
||||
{
|
||||
public partial class RecipeSelectionDialog : MaterialForm
|
||||
{
|
||||
private readonly RecipeSelectionVM _recipeSelectionVm;
|
||||
|
||||
public RecipeSelectionDialog(RecipeSelectionVM recipeSelectionVm)
|
||||
{
|
||||
_recipeSelectionVm = recipeSelectionVm;
|
||||
|
||||
InitializeComponent();
|
||||
ReloadRecipes();
|
||||
}
|
||||
|
||||
public void ReloadRecipes()
|
||||
{
|
||||
|
||||
var recipes = _recipeSelectionVm.Recipes.ToList();
|
||||
listView1.Items.Clear();
|
||||
|
||||
recipes = recipes.OrderBy(x => x.RecipeName).ToList();
|
||||
listView1.LargeImageList = new ImageList() { ColorDepth = ColorDepth.Depth24Bit };
|
||||
listView1.LargeImageList.ImageSize = new Size(128, 128);
|
||||
|
||||
var plug = new Bitmap(128, 128);
|
||||
using (Graphics g = Graphics.FromImage(plug))
|
||||
{
|
||||
g.Clear(Color.Gray);
|
||||
}
|
||||
|
||||
listView1.LargeImageList.Images.Add("plug", plug);
|
||||
|
||||
|
||||
|
||||
|
||||
recipes.ForEach(x =>
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (x.Image != null)
|
||||
{
|
||||
var image = x.Image.Resize(new OpenCvSharp.Size(128, 128)).ToBitmap();
|
||||
listView1.LargeImageList.Images.Add(x.RecipeName, image);
|
||||
listView1.Items.Add(x.RecipeName, x.RecipeName, x.RecipeName).Tag = x;
|
||||
}
|
||||
else
|
||||
{
|
||||
listView1.Items.Add(x.RecipeName, x.RecipeName, "plug").Tag=x;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
private void listView1_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (listView1.SelectedIndices.Count > 0)
|
||||
{
|
||||
_recipeSelectionVm.SelectedRecipe = (RecipeData)listView1.SelectedItems[0].Tag!;
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user