using DataEntity;
|
using System;
|
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
using System.ComponentModel;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows;
|
using System.Windows.Controls;
|
using System.Windows.Data;
|
using System.Windows.Documents;
|
using System.Windows.Input;
|
using System.Windows.Media;
|
using System.Windows.Media.Imaging;
|
using System.Windows.Navigation;
|
using System.Windows.Shapes;
|
using XHandler.Class;
|
using XHandler.Class.DataEx;
|
using XHandler.Controls;
|
using XHandler.View.BacteriaProperty;
|
using XHandler.View.MethodProperty;
|
using XImagingXhandler.XDAL;
|
using DataRWDAL;
|
namespace XHandler.View.Tabletop
|
{
|
/// <summary>
|
/// NewTabletopTemplate.xaml 的交互逻辑
|
/// </summary>
|
public partial class NewTabletopTemplate : UserControl
|
{
|
#region custom event
|
public event EventHandler closeEvent;
|
|
/// <summary>
|
/// 确定
|
/// </summary>
|
public static readonly RoutedEvent OKRoutedEvent =
|
EventManager.RegisterRoutedEvent("OKEvent", RoutingStrategy.Bubble, typeof(CustomEvent.CustomRoutedEventHandler<string>), typeof(NewTabletopTemplate));
|
|
[Description("OKEvent")]
|
public event CustomEvent.CustomRoutedEventHandler<string> OKEvent
|
{
|
add
|
{
|
this.AddHandler(OKRoutedEvent, value);
|
}
|
remove
|
{
|
this.RemoveHandler(OKRoutedEvent, value);
|
}
|
}
|
|
private void RaiseOKEvent(string str)
|
{
|
CustomRoutedEventArgs<string> arg = new CustomRoutedEventArgs<string>(OKRoutedEvent, str);
|
this.RaiseEvent(arg);
|
}
|
#endregion
|
public NewTabletopTemplate()
|
{
|
InitializeComponent();
|
}
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
{
|
textboxLabel.Focus();
|
textboxLabel.SelectAll();
|
}
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
{
|
if (EventResponseController.Instance.CanExecute() == false)
|
return;
|
|
closeEvent?.Invoke(this, EventArgs.Empty);
|
}
|
|
private void btnOK_Click(object sender, RoutedEventArgs e)
|
{
|
if (EventResponseController.Instance.CanExecute() == false)
|
return;
|
|
if (string.IsNullOrEmpty(textboxLabel.Text.Trim()))
|
{
|
textboxLabel.BorderThickness = new Thickness(1, 1, 1, 1);
|
tbTips.Text = Properties.Resources.strCannotEmpty;
|
return;
|
}
|
|
ObservableCollection<TabletopTemplate> tabletopTemplates = TabletopTemplateDB.GetTabletopTemplateCollectionFromdb();
|
|
|
TabletopTemplate tabletopTemplate = tabletopTemplates.Where(s => s.tabletopname == textboxLabel.Text).FirstOrDefault();
|
if (tabletopTemplate != null)
|
{
|
textboxLabel.BorderThickness = new Thickness(1, 1, 1, 1);
|
tbTips.Text = Properties.Resources.strBacteriaExist;
|
return;
|
}
|
else
|
{
|
TabletopTemplate tabletopTemplate1 = new TabletopTemplate();
|
tabletopTemplate1.tabletopname = textboxLabel.Text;
|
tabletopTemplate1.tabletopstate = 1;
|
tabletopTemplate1.usestate = 0;
|
tabletopTemplate1.tabletopid = Guid.NewGuid().ToString();
|
//bacterias.Add(bacteria1);
|
}
|
|
RaiseOKEvent(textboxLabel.Text.Trim());
|
}
|
}
|
}
|