sc 2 years ago
parent
commit
f5bf396be5
  1. 2
      MainWindow.xaml
  2. 35
      ViewModel/MainWindowViewModel.cs

2
MainWindow.xaml

@ -50,7 +50,7 @@
</MenuItem> </MenuItem>
</Menu> </Menu>
<TextBox x:Name="USERTIME" Text="{Binding Sys_Time, Source={StaticResource MainWindowViewModel}}" HorizontalAlignment="Right" Height="30" Margin="0,0,5,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="14" <TextBox x:Name="USERTIME" Text="{Binding Sys_Time}" HorizontalAlignment="Right" Height="30" Margin="0,0,5,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="14"
Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}" IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/> Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}" IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/>
<TextBox x:Name="USER" HorizontalAlignment="Right" Height="30" Margin="0,0,155,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="100" FontSize="14" <TextBox x:Name="USER" HorizontalAlignment="Right" Height="30" Margin="0,0,155,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="100" FontSize="14"
Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}" IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/> Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}" IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/>

35
ViewModel/MainWindowViewModel.cs

@ -16,11 +16,24 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Threading; using System.Windows.Threading;
using System.Xml.Linq;
namespace formula_manage.ViewModel namespace formula_manage.ViewModel
{ {
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
///<Summary> ///<Summary>
/// RRODUCTiewModel ///
///
///</Summary> ///</Summary>
/// ///
public class MainWindowViewModel : ViewModelBase public class MainWindowViewModel : ViewModelBase
@ -32,7 +45,12 @@ public class MainWindowViewModel : ViewModelBase
DataTable RecipedataTable = new DataTable(); //建立Recipe缓存 DataTable RecipedataTable = new DataTable(); //建立Recipe缓存
public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "formula.ini"; //配置文件路径 public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "formula.ini"; //配置文件路径
public string Sys_Time; //显示系统时间 public string sys_Time; //显示系统时间
public string Sys_Time //通知UI控件参数改变
{
get { return sys_Time; }
set { sys_Time = value; OnPropertyChanged("Sys_Time"); }
}
string TEXT_SQLIP; string TEXT_SQLIP;
string TEXT_SQLNAME; string TEXT_SQLNAME;
@ -41,7 +59,7 @@ public class MainWindowViewModel : ViewModelBase
string TEXT_SQLPASWOR; string TEXT_SQLPASWOR;
string Connstr_SC; string Connstr_SC;
private async void sql_() private async void Sql_()
{ {
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);//生效配置读取 UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);//生效配置读取
TEXT_SQLIP = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件 TEXT_SQLIP = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件
@ -86,7 +104,8 @@ public class MainWindowViewModel : ViewModelBase
public MainWindowViewModel() public MainWindowViewModel()
{ {
sql_(); CountDown();
Sql_();
stuff_Product = ToObservableCollection<Product>(STUFFdataTable); //stuff_Product表转换 stuff_Product = ToObservableCollection<Product>(STUFFdataTable); //stuff_Product表转换
mac_Machine = ToObservableCollection<Machine>(MACHINEdataTable); mac_Machine = ToObservableCollection<Machine>(MACHINEdataTable);
@ -97,7 +116,7 @@ public class MainWindowViewModel : ViewModelBase
public ObservableCollection<Product> stuff_Product { get; set; } //stuff_Product动态表实力化 public ObservableCollection<Product> stuff_Product { get; set; } //stuff_Product动态表实力化
public ObservableCollection<Machine> mac_Machine { get; set; } //mac_Machine动态表实力化 public ObservableCollection<Machine> mac_Machine { get; set; } //mac_Machine动态表实力化
public ObservableCollection<Workflow> flow_Workflow { get; set; } //Dissolve动态表实力化 public ObservableCollection<Workflow> flow_Workflow { get; set; } //Dissolve动态表实力化
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new() public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new() //DataTable FOR ObservableCollection转换器
{ {
Type t = typeof(T); Type t = typeof(T);
PropertyInfo[] propertys = t.GetProperties(); PropertyInfo[] propertys = t.GetProperties();
@ -143,14 +162,12 @@ public class MainWindowViewModel : ViewModelBase
lst.Add(entity); lst.Add(entity);
} }
return lst; return lst;
} } //DataTable FOR ObservableCollection转换器
/// <summary> /// <summary>
/// 循环事件设定 /// 循环事件设定
/// </summary> /// </summary>
public void CountDown() public void CountDown()
{ {
//products = new ProductProvider().Select();
DispatcherTimer timer = new DispatcherTimer//初始化循环,每0.5秒调用一次Tick_Event DispatcherTimer timer = new DispatcherTimer//初始化循环,每0.5秒调用一次Tick_Event
{ {
Interval = TimeSpan.FromSeconds(0.1) Interval = TimeSpan.FromSeconds(0.1)
@ -163,12 +180,10 @@ public class MainWindowViewModel : ViewModelBase
// disTimer.Interval = new TimeSpan(10000000); //时间间隔为一秒。 // disTimer.Interval = new TimeSpan(10000000); //时间间隔为一秒。
// disTimer.Start();//计时开始 // disTimer.Start();//计时开始
} }
void Tick_Event(object sender, EventArgs e)//Tick_Event周期执行事件 void Tick_Event(object sender, EventArgs e)//Tick_Event周期执行事件
{ {
Sys_Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Sys_Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
} }
} }
public class Product //stuff_Product public class Product //stuff_Product

Loading…
Cancel
Save