You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
4.5 KiB

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using GummingCommon;
using GummingEntity;
using GummingSupport;
using GummingControl;
using System.Text;
using GummingBusiness;
using Newtonsoft.Json;
using GummingLine;
namespace Gumming
{
public class DEV2SetViewModule : ViewModelBase
{
#region base parameters
private int rows = 20;
private int pagenumber = 1;
public DEV2SetView View { get; set; }
private bool IsConfirm;
private bool isLoading;
private AppEnum.PathType _CurrentPathType;
public AppEnum.PathType CurrentPathType
{
get
{
return _CurrentPathType;
}
set
{
_CurrentPathType = value;
OnPropertyChanged("CurrentPathType");
}
}
#endregion
#region constructor
public DEV2SetViewModule()
{
View = new DEV2SetView();
View.DataContext = this;
InitializeCommands();
InitializeParameters();
}
private void InitializeCommands()
{
ConfirmCommand = new DelegateCommand(OnConfirmCommand);
}
public override void InitializeParameters(object content = null)
{
IsConfirm = false;
WindowTitle = "";
}
~DEV2SetViewModule()
{
}
public void LoadDefaultValue()
{
DEV2Sets = new ObservableCollection<SysSettingEntity>();
var record = SysSettingDA.Load(new PagerEntity() { PageIndex = pagenumber, Rows = rows, Conditions = " and IsActive = 1 and SettingGroup ='DEV2' " });
List<SysSettingEntity> settings = (List<SysSettingEntity>)record.rows;
View.Dispatcher.Invoke((Action)(() =>
{
foreach (var s in settings)
{
s.Status = s.SettingStatus == 1;
s.StatusVisible = Visibility.Visible;
s.InputVisible = Visibility.Visible;
if (s.RecId.Contains("HomingOffset"))
{
s.StatusVisible = Visibility.Hidden;
}
s.StatusVisible = Visibility.Hidden;
s.Copy = (SysSettingEntity)s.Clone();
DEV2Sets.Add(s);
}
OnPropertyChanged("DEV2Sets");
}));
}
#endregion
#region Binding Properties
public string WindowTitle { get; private set; }
private string _TotalRecords;
public string TotalRecords
{
get
{
return _TotalRecords;
}
set
{
_TotalRecords = value;
OnPropertyChanged("TotalRecords");
}
}
private ObservableCollection<SysSettingEntity> _DEV2Sets;
public ObservableCollection<SysSettingEntity> DEV2Sets
{
get
{
return _DEV2Sets;
}
set
{
_DEV2Sets = value;
OnPropertyChanged("DEV2Sets");
}
}
private SysSettingEntity _SelectedSetting;
public SysSettingEntity SelectedSetting
{
get
{
return _SelectedSetting;
}
set
{
_SelectedSetting = value;
OnPropertyChanged("SelectedSetting");
}
}
#endregion
#region Binding Commands
private ICommand _ConfirmCommand;
public ICommand ConfirmCommand
{
get
{
return _ConfirmCommand;
}
set
{
_ConfirmCommand = value;
OnPropertyChanged("ConfirmCommand");
}
}
#endregion
#region Private Methods
private void OnConfirmCommand(Object sender)
{
foreach (var e in DEV2Sets)
{
e.SettingStatus = e.Status ? 1 : 0;
SysSettingDA.Update(e);
}
LoadDefaultValue();
DataSet.LoadSetting();
}
#endregion
}
}