diff --git a/View/ProductionPlanningView.xaml b/View/ProductionPlanningView.xaml index 76b8067..44e79cd 100644 --- a/View/ProductionPlanningView.xaml +++ b/View/ProductionPlanningView.xaml @@ -12,7 +12,7 @@ xmlns:Ngantt="clr-namespace:nGantt;assembly=nGantt" d:DataContext="{d:DesignInstance Type=viewmodel:ProductionPlanningModel}" mc:Ignorable="d" Loaded="UserControl_Loaded" - d:DesignHeight="630" d:DesignWidth="1280"> + d:DesignHeight="900" d:DesignWidth="1800"> @@ -24,7 +24,43 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -49,24 +85,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/View/ProductionPlanningView.xaml.cs b/View/ProductionPlanningView.xaml.cs index 4200613..81e6759 100644 --- a/View/ProductionPlanningView.xaml.cs +++ b/View/ProductionPlanningView.xaml.cs @@ -38,6 +38,7 @@ using nGantt; using nGantt.PeriodSplitter; using ScottPlot.TickGenerators.TimeUnits; using System.Runtime.Serialization; +using System.Windows.Markup; namespace SunlightCentralizedControlManagement_SCCM_.View @@ -51,37 +52,37 @@ namespace SunlightCentralizedControlManagement_SCCM_.View { InitializeComponent(); DataContext = new ProductionPlanningModel(); - //ch.ZoomMode = LiveChartsCore.Measure.ZoomAndPanMode.PanX | LiveChartsCore.Measure.ZoomAndPanMode.ZoomY; + Sdatepicker.Language = XmlLanguage.GetLanguage(Configini.IniReadvalue("SYS", "Language")); } + private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini"); private SQLiteHelper SQLiteHelpers = null; //定义数据库 private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径 - private int GantLenght { get; set; } + private DateTime minDate; + private DateTime maxDate; private void UserControl_Loaded(object sender, RoutedEventArgs e)//打开页面时的操作 { - // List qw = MainWindowViewModel.Machines.AsEnumerable().Select(row => row.Field("name")).ToList();//转换列名为机台 - // int asd = qw.Count(); - GantLenght = 1; - DateTime minDate = DateTime.Parse("2012-02-01").Date; - DateTime maxDate = minDate.AddDays(GantLenght); + Sdatepicker.Text = DateTime.Now.ToString("yyyy/MM/dd"); + minDate = DateTime.Now.Date; + maxDate = minDate.AddDays(1); + - GanttChart.Initialize(minDate, maxDate); + GanttChartNEW(); + } + private void GanttChartNEW() + { + 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 PeriodDaySplitter(minDate, maxDate), FormatDayName); - // Set the timeline to atatch gridlines to GanttChart.SetGridLinesTimeline(gridLineTimeLine, DetermineBackground); + var rowgroup = GanttChart.CreateGanttRowGroup(); + var row = GanttChart.CreateGanttRow(rowgroup, "GanttRow"); - - var rowgroup1 = GanttChart.CreateGanttRowGroup("HeaderdGanttRowGroup"); - var row1 = GanttChart.CreateGanttRow(rowgroup1, "GanttRow 1"); - GanttChart.AddGanttTask(row1, new GanttTask() { Start = DateTime.Parse("2012-02-01 00:30:00"), End = DateTime.Parse("2012-02-01 01:00:00"), Name = "GanttRow 1:GanttTask 1", TaskProgressVisibility = System.Windows.Visibility.Hidden }); - GanttChart.AddGanttTask(row1, new GanttTask() { Start = DateTime.Parse("2012-02-01 06:00:00"), End = DateTime.Parse("2012-02-01 07:00:00"), Name = "GanttRow 1:GanttTask 2" }); - GanttChart.AddGanttTask(row1, new GanttTask() { Start = DateTime.Parse("2012-02-01 10:00:00"), End = DateTime.Parse("2012-02-01 20:00:00"), Name = "GanttRow 1:GanttTask 3" }); - - + 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" }); + 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" }); } private string FormatYear(Period period) { @@ -135,5 +136,23 @@ namespace SunlightCentralizedControlManagement_SCCM_.View } + private void ListViewItem_Before(object sender, MouseButtonEventArgs e)//前一天 + { + 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"); + } + private void ListViewItem_DayAfter(object sender, MouseButtonEventArgs e)//后一天 + { + Sdatepicker.Text = DateTime.Parse(Sdatepicker.Text).AddDays(1).ToString("yyyy/MM/dd"); + } + private void Sdatepicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)//时间控件 + { + minDate = DateTime.Parse(sender.ToString()); + maxDate = DateTime.Parse(sender.ToString()).AddDays(1); + GanttChartNEW(); + } } }