|
|
@ -41,6 +41,7 @@ using System.Runtime.Serialization; |
|
|
|
using System.Windows.Markup; |
|
|
|
using System.Collections.ObjectModel; |
|
|
|
using SkiaSharp; |
|
|
|
using System.Windows.Threading; |
|
|
|
|
|
|
|
|
|
|
|
namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
@ -55,6 +56,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
InitializeComponent(); |
|
|
|
DataContext = new ProductionPlanningModel(); |
|
|
|
Sdatepicker.Language = XmlLanguage.GetLanguage(Configini.IniReadvalue("SYS", "Language")); |
|
|
|
CountDown(); |
|
|
|
} |
|
|
|
|
|
|
|
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini"); |
|
|
@ -64,7 +66,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
private DateTime minDate; |
|
|
|
private DateTime maxDate; |
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)//打开页面时的操作
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Sdatepicker.Text = DateTime.Now.ToString("yyyy/MM/dd"); |
|
|
|
minDate = DateTime.Now.Date; |
|
|
|
maxDate = minDate.AddDays(1); |
|
|
@ -76,12 +78,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
ganttTaskContextMenuItems.Add(new ContextMenuItem(DeleteClicked, Properties.Resources.Delete + "...")); |
|
|
|
GanttChart.GanttTaskContextMenuItems = ganttTaskContextMenuItems; |
|
|
|
|
|
|
|
GanttChartNEW(); |
|
|
|
} |
|
|
|
GanttChartNEW(); |
|
|
|
} |
|
|
|
|
|
|
|
private ObservableCollection<ContextMenuItem> ganttTaskContextMenuItems = new ObservableCollection<ContextMenuItem>(); |
|
|
|
private void GanttChartNEW() |
|
|
|
{ |
|
|
|
public void GanttChartNEW() |
|
|
|
{ |
|
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
|
|
WorkOrder = SQLiteHelpers.ExecuteDataSet( |
|
|
@ -93,28 +95,27 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
GanttChart.ClearGantt(); |
|
|
|
GanttChart.Initialize(minDate, maxDate); |
|
|
|
var gridLineTimeLine = GanttChart.CreateTimeLine(new PeriodDaySplitter(minDate, maxDate), FormatDay); |
|
|
|
GanttChart.CreateTimeLine(new PeriodHourSplitter(minDate, maxDate), FormatHour); |
|
|
|
|
|
|
|
GanttChart.CreateTimeLine(new PeriodHourSplitter(minDate, maxDate), FormatHour); |
|
|
|
// Set the timeline to atatch gridlines to
|
|
|
|
GanttChart.SetGridLinesTimeline(gridLineTimeLine, DetermineBackground); |
|
|
|
var rowgroup = GanttChart.CreateGanttRowGroup(); |
|
|
|
|
|
|
|
//生成表信息
|
|
|
|
List<string> Chart_machines = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换列名为机台
|
|
|
|
for (int i= 0; i<Chart_machines.Count(); i++)//列表机台号
|
|
|
|
{ |
|
|
|
for (int i = 0; i < Chart_machines.Count(); i++)//列表机台号
|
|
|
|
{ |
|
|
|
var row = GanttChart.CreateGanttRow(rowgroup, Chart_machines[i]); |
|
|
|
DataRow[] dataRows = WorkOrder.Select("Machines='"+ Chart_machines[i]+"'"); |
|
|
|
DataRow[] dataRows = WorkOrder.Select("Machines='" + Chart_machines[i] + "'"); |
|
|
|
|
|
|
|
for (int j = 0; j < dataRows.Count(); j++) //列表排程
|
|
|
|
{ |
|
|
|
// if(string.IsNullOrEmpty(dataRows[j].Field<string>("color")))
|
|
|
|
|
|
|
|
GanttChart.AddGanttTask(row, new GanttTask() { |
|
|
|
Start = DateTime.Parse(dataRows[j].Field<string>("StartTime")), |
|
|
|
End = DateTime.Parse(dataRows[j].Field<string>("EndTime")), |
|
|
|
Name = Properties.Resources.ProcessName +";"+ dataRows[j].Field<string>("ProgramName"), |
|
|
|
TaskProgressVisibility = System.Windows.Visibility.Hidden }); |
|
|
|
GanttChart.AddGanttTask(row, new GanttTask() |
|
|
|
{ |
|
|
|
Start = DateTime.Parse(dataRows[j].Field<string>("StartTime")), |
|
|
|
End = DateTime.Parse(dataRows[j].Field<string>("EndTime")), |
|
|
|
Name = Properties.Resources.ProcessName + ";" + dataRows[j].Field<string>("ProgramName"), |
|
|
|
TaskProgressVisibility = System.Windows.Visibility.Hidden |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}//创建日程图
|
|
|
@ -174,25 +175,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
} |
|
|
|
private void WorkOrderNumder_Click(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
Picture.Width = 0; |
|
|
|
// Select_WorkOrderNumder.Text;
|
|
|
|
} |
|
|
|
private void ListViewItem_Before(object sender, MouseButtonEventArgs e)//前一天
|
|
|
|
{ |
|
|
|
Picture.Width = 0; |
|
|
|
Sdatepicker.Text = DateTime.Parse(Sdatepicker.Text).AddDays(-1).ToString("yyyy/MM/dd"); |
|
|
|
} |
|
|
|
private void ListViewItem_Today(object sender, MouseButtonEventArgs e)//今天
|
|
|
|
{ |
|
|
|
Sdatepicker.Text = DateTime.Now.ToString("yyyy/MM/dd"); |
|
|
|
Picture.Width = 0; |
|
|
|
Sdatepicker.Text = DateTime.Now.ToString("yyyy/MM/dd"); |
|
|
|
} |
|
|
|
private void ListViewItem_DayAfter(object sender, MouseButtonEventArgs e)//后一天
|
|
|
|
{ |
|
|
|
Sdatepicker.Text = DateTime.Parse(Sdatepicker.Text).AddDays(1).ToString("yyyy/MM/dd"); |
|
|
|
Picture.Width = 0; |
|
|
|
Sdatepicker.Text = DateTime.Parse(Sdatepicker.Text).AddDays(1).ToString("yyyy/MM/dd"); |
|
|
|
} |
|
|
|
private void Sdatepicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)//时间控件
|
|
|
|
{ |
|
|
|
Picture.Width = 0; |
|
|
|
minDate = DateTime.Parse(sender.ToString()); |
|
|
|
maxDate = DateTime.Parse(sender.ToString()).AddDays(1); |
|
|
|
GanttChartNEW(); |
|
|
|
} |
|
|
|
|
|
|
|
public void CountDown() |
|
|
|
{ |
|
|
|
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
|
|
|
{ |
|
|
|
Interval = TimeSpan.FromSeconds(1)//秒
|
|
|
|
}; |
|
|
|
timer1s.Tick += Tick_Event_1S; |
|
|
|
timer1s.Start(); |
|
|
|
} |
|
|
|
public static bool UI; |
|
|
|
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
|
|
|
{ |
|
|
|
if (UI) |
|
|
|
{ |
|
|
|
GanttChartNEW(); |
|
|
|
UI= false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|