添加排程右键功能与列表显示数据逻辑
This commit is contained in:
commit
f1b310c10d
5 files changed
+65
-6
No files matched your search
Generated
+9
@@ -2400,6 +2400,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 View 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string View {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("View", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Washing 的本地化字符串。
|
/// 查找类似 Washing 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -942,4 +942,7 @@
|
|||||||
<data name="Jump" xml:space="preserve">
|
<data name="Jump" xml:space="preserve">
|
||||||
<value>Jump</value>
|
<value>Jump</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="View" xml:space="preserve">
|
||||||
|
<value>View</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -942,4 +942,7 @@
|
|||||||
<data name="Jump" xml:space="preserve">
|
<data name="Jump" xml:space="preserve">
|
||||||
<value>Jump</value>
|
<value>Jump</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="View" xml:space="preserve">
|
||||||
|
<value>View</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -942,4 +942,7 @@
|
|||||||
<data name="Jump" xml:space="preserve">
|
<data name="Jump" xml:space="preserve">
|
||||||
<value>跳步</value>
|
<value>跳步</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="View" xml:space="preserve">
|
||||||
|
<value>视图</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -39,6 +39,7 @@ using nGantt.PeriodSplitter;
|
|||||||
using ScottPlot.TickGenerators.TimeUnits;
|
using ScottPlot.TickGenerators.TimeUnits;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Windows.Markup;
|
using System.Windows.Markup;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
|
||||||
namespace SunlightCentralizedControlManagement_SCCM_.View
|
namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||||
@@ -58,6 +59,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
|
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
|
||||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||||
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
||||||
|
DataTable WorkOrder;
|
||||||
private DateTime minDate;
|
private DateTime minDate;
|
||||||
private DateTime maxDate;
|
private DateTime maxDate;
|
||||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)//打开页面时的操作
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)//打开页面时的操作
|
||||||
@@ -65,25 +67,64 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
Sdatepicker.Text = DateTime.Now.ToString("yyyy/MM/dd");
|
Sdatepicker.Text = DateTime.Now.ToString("yyyy/MM/dd");
|
||||||
minDate = DateTime.Now.Date;
|
minDate = DateTime.Now.Date;
|
||||||
maxDate = minDate.AddDays(1);
|
maxDate = minDate.AddDays(1);
|
||||||
|
//添加表右键功能
|
||||||
|
ganttTaskContextMenuItems.Add(new ContextMenuItem(ViewClicked, Properties.Resources.View + "..."));
|
||||||
|
ganttTaskContextMenuItems.Add(new ContextMenuItem(EditClicked, Properties.Resources.edit + "..."));
|
||||||
|
ganttTaskContextMenuItems.Add(new ContextMenuItem(DeleteClicked, Properties.Resources.Delete + "..."));
|
||||||
|
GanttChart.GanttTaskContextMenuItems = ganttTaskContextMenuItems;
|
||||||
|
|
||||||
GanttChartNEW();
|
GanttChartNEW();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ObservableCollection<ContextMenuItem> ganttTaskContextMenuItems = new ObservableCollection<ContextMenuItem>();
|
||||||
private void GanttChartNEW()
|
private void GanttChartNEW()
|
||||||
{
|
{
|
||||||
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
|
WorkOrder = SQLiteHelpers.ExecuteDataSet(
|
||||||
|
"select * from WorkOrder where StartTime>'" + Sdatepicker.Text
|
||||||
|
+ "'or EndTime>'" + Sdatepicker.Text + "'Order by StartTime", null).Tables[0]; //读取表写入缓存
|
||||||
|
SQLiteHelpers.Close();
|
||||||
|
|
||||||
|
//生成表
|
||||||
GanttChart.ClearGantt();
|
GanttChart.ClearGantt();
|
||||||
GanttChart.Initialize(minDate, maxDate);
|
GanttChart.Initialize(minDate, maxDate);
|
||||||
var gridLineTimeLine = GanttChart.CreateTimeLine(new PeriodDaySplitter(minDate, maxDate), FormatDay);
|
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
|
// Set the timeline to atatch gridlines to
|
||||||
GanttChart.SetGridLinesTimeline(gridLineTimeLine, DetermineBackground);
|
GanttChart.SetGridLinesTimeline(gridLineTimeLine, DetermineBackground);
|
||||||
var rowgroup = GanttChart.CreateGanttRowGroup();
|
var rowgroup = GanttChart.CreateGanttRowGroup();
|
||||||
var row = GanttChart.CreateGanttRow(rowgroup, "GanttRow");
|
|
||||||
|
|
||||||
GanttChart.AddGanttTask(row, new GanttTask() { Start = DateTime.Parse("2024-12-30 00:30:00"), End = DateTime.Parse("2024-12-30 01:00:00"), Name = "GanttRow:"+"GanttTask 1", TaskProgressVisibility = System.Windows.Visibility.Hidden });
|
//生成表信息
|
||||||
GanttChart.AddGanttTask(row, new GanttTask() { Start = DateTime.Parse("2024-12-30 06:00:00"), End = DateTime.Parse("2024-12-30 07:00:00"), Name = "GanttRow:"+"GanttTask 2" });
|
List<string> Chart_machines = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换列名为机台
|
||||||
GanttChart.AddGanttTask(row, new GanttTask() { Start = DateTime.Parse("2024-12-30 10:00:00"), End = DateTime.Parse("2024-12-30 20:00:00"), Name = "GanttRow:"+"GanttTask 3" });
|
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]+"'");
|
||||||
|
|
||||||
|
for (int j = 0; j < dataRows.Count(); j++) //列表排程
|
||||||
|
{
|
||||||
|
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 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//创建日程图
|
||||||
|
private void ViewClicked(GanttTask ganttTask)
|
||||||
|
{
|
||||||
|
MessageBox.Show("New clicked for task " + ganttTask.Name);
|
||||||
|
}
|
||||||
|
private void EditClicked(GanttTask ganttTask)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Edit clicked for task " + ganttTask.Name);
|
||||||
|
}
|
||||||
|
private void DeleteClicked(GanttTask ganttTask)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Delete clicked for task " + ganttTask.Name);
|
||||||
|
}
|
||||||
private string FormatYear(Period period)
|
private string FormatYear(Period period)
|
||||||
{
|
{
|
||||||
return period.Start.Year.ToString();
|
return period.Start.Year.ToString();
|
||||||
|
|||||||
Reference in new issue
Block a user