sc 11 months ago
parent
commit
a1c1f182fe
  1. 58
      View/ProductionPlanningView.xaml
  2. 57
      View/ProductionPlanningView.xaml.cs

58
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">
<UserControl.Resources>
<ConvertMoels:RowToIndexConverter x:Key="RowToIndexConverter"/>
</UserControl.Resources>
@ -24,7 +24,43 @@
<Grid Grid.Row="0">
<Ngantt:GanttControl x:Name="GanttChart"/>
</Grid>
<StackPanel x:Name="scr" Grid.Row="1" Height="60" Background="#FF00204E" Orientation="Horizontal">
<StackPanel Grid.Row="1" Height="60" Background="#FF00204E" Orientation="Horizontal">
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Height="60" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" >
<materialDesign:PackIcon Kind="DateRange" Width="40" Height="30" Margin="10" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static lang:Resources.SelectDate}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
<DatePicker x:Name="Sdatepicker" Width="150" FontSize="20" Height="40" FontWeight="Bold" Padding="1,1,0,1"
Focusable="False" Text="{x:Static lang:Resources.Startdate}" SelectedDateChanged="Sdatepicker_SelectedDateChanged"/>
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_Before" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" >
<materialDesign:PackIcon Kind="NavigateBefore" Width="40" Height="30" Margin="10" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static lang:Resources.Before}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_Today" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" >
<materialDesign:PackIcon Kind="NavigationVariantOutline" Width="40" Height="30" Margin="10" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static lang:Resources.Today}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_DayAfter" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" >
<materialDesign:PackIcon Kind="NavigateNext" Width="40" Height="30" Margin="10" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static lang:Resources.DayAfter}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
</StackPanel>
<StackPanel Grid.Row="1" Height="60" Background="#FF00204E" Orientation="Horizontal" HorizontalAlignment="Right">
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_Quit" x:Name="Quit">
<StackPanel Orientation="Horizontal" >
@ -49,24 +85,6 @@
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_Save" x:Name="Save">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Note" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.Save}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_Delete" x:Name="Delete">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Delete" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.Delete}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
</StackPanel>
</Grid>
</UserControl>

57
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<string> qw = MainWindowViewModel.Machines.AsEnumerable().Select(row => row.Field<string>("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();
}
}
}

Loading…
Cancel
Save