Example #1
0
        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);
            if (e.Property.Name == "GanttItemsSourceHeader")
            {
                PageChartList = new ObservableCollection <PageChartModel>();
                if (GanttItemsSourceHeader.Count <= 16)
                {
                    PageChartList.Add(new PageChartModel()
                    {
                        PageIndex = 1
                    });
                }
                else
                {
                    for (int i = 0; i < Convert.ToInt32(Math.Ceiling(GanttItemsSourceHeader.Count / Convert.ToDouble(16))); i++)
                    {
                        PageChartList.Add(new PageChartModel()
                        {
                            PageIndex = i + 1
                        });
                    }
                }
                this.ItemsSource = PageChartList;

                foreach (var item in this.ItemsSource)
                {
                    int index = (item as PageChartModel).PageIndex;
                    OperationMonitorChartControl chart = this.ItemContainerGenerator.ContainerFromItem(item) as OperationMonitorChartControl;
                    int count = (GanttItemsSourceHeader.Count - (index - 1) * 16) >= 16 ? (index - 1) * 16 + 16 : GanttItemsSourceHeader.Count;
                    ObservableCollection <TimeItemModel> temp = new ObservableCollection <TimeItemModel>();
                    for (int i = (index - 1) * 16; i < count; i++)
                    {
                        temp.Add(GanttItemsSourceHeader[i]);
                    }
                    chart.StartTime = temp[0].TimeName;
                    chart.EndTime   = temp[^ 1].DateTimeList[^ 1];
        public void PrintControl()
        {
            PrintListWindow window = new PrintListWindow();

            if (window.ShowDialog() == true)
            {
                foreach (var item in this.ItemsSource)
                {
                    OperationMonitorChartControl chart = this.ItemContainerGenerator.ContainerFromItem(item) as OperationMonitorChartControl;
                    var printDialog = new PrintDialog();
                    SetPrintProperty(printDialog);
                    if (window.PrintQueueSelected != null)
                    {
                        printDialog.PrintQueue = window.PrintQueueSelected;

                        Point point = chart.TransformToAncestor(this).Transform(new Point(0, 0));
                        chart.Measure(new Size(chart.ActualWidth, chart.ActualHeight));
                        chart.Arrange(new Rect(new Size(chart.ActualWidth, chart.ActualHeight)));
                        printDialog.PrintVisual(chart, "");
                        chart.Arrange(new Rect(point.X, point.Y, chart.ActualWidth, chart.ActualHeight));
                    }
                }
            }
        }
        protected override DependencyObject GetContainerForItemOverride()
        {
            OperationMonitorChartControl gridCell = new OperationMonitorChartControl();

            return(gridCell);
        }
        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);
            if (e.Property.Name == "GanttItemsSourceHeader")
            {
                PageChartList = new ObservableCollection <PageChartModel>();
                if (GanttItemsSourceHeader.Count <= 16)
                {
                    PageChartList.Add(new PageChartModel()
                    {
                        PageIndex = 1
                    });
                }
                else
                {
                    for (int i = 0; i < Convert.ToInt32(Math.Ceiling(GanttItemsSourceHeader.Count / Convert.ToDouble(16))); i++)
                    {
                        PageChartList.Add(new PageChartModel()
                        {
                            PageIndex = i + 1
                        });
                    }
                }
                this.ItemsSource = PageChartList;

                foreach (var item in this.ItemsSource)
                {
                    int index = (item as PageChartModel).PageIndex;
                    OperationMonitorChartControl chart = this.ItemContainerGenerator.ContainerFromItem(item) as OperationMonitorChartControl;
                    int count = (GanttItemsSourceHeader.Count - (index - 1) * 16) >= 16 ? (index - 1) * 16 + 16 : GanttItemsSourceHeader.Count;
                    ObservableCollection <TimeItemModel> temp = new ObservableCollection <TimeItemModel>();
                    for (int i = (index - 1) * 16; i < count; i++)
                    {
                        temp.Add(GanttItemsSourceHeader[i]);
                    }
                    chart.StartTime = temp[0].TimeName;
                    chart.EndTime   = temp[temp.Count - 1].DateTimeList[temp[temp.Count - 1].DateTimeList.Count - 1];
                    chart.GanttItemsSourceHeader = new ObservableCollection <TimeItemModel>(temp);
                }
            }
            else if (e.Property.Name == "ProjectGroupInfo")
            {
                foreach (var item in this.ItemsSource)
                {
                    int index = (item as PageChartModel).PageIndex;
                    OperationMonitorChartControl chart = this.ItemContainerGenerator.ContainerFromItem(item) as OperationMonitorChartControl;
                    ObservableCollection <LineLegendGroupModel> temp = new ObservableCollection <LineLegendGroupModel>();
                    LineLegendGroupModel tempGroup = null;
                    int count = 1;

                    foreach (var group in ProjectGroupInfo)
                    {
                        foreach (var legend in group.LegendItemList)
                        {
                            if (legend.ProjectTime >= chart.StartTime && legend.ProjectTime <= chart.EndTime)
                            {
                                if (count == 9)
                                {
                                    tempGroup = new LineLegendGroupModel();
                                    temp.Add(tempGroup);
                                    count = 0;
                                }
                                if (count < 10)
                                {
                                    if (tempGroup == null)
                                    {
                                        tempGroup = new LineLegendGroupModel();
                                        temp.Add(tempGroup);
                                    }
                                    tempGroup.LegendItemList.Add(legend);
                                }
                                count++;
                            }
                        }
                    }
                    chart.ProjectGroupInfo = new ObservableCollection <LineLegendGroupModel>(temp);
                }
            }
            else if (e.Property.Name == "LineServiceData")
            {
                foreach (var item in this.ItemsSource)
                {
                    int index = (item as PageChartModel).PageIndex;
                    OperationMonitorChartControl       chart = this.ItemContainerGenerator.ContainerFromItem(item) as OperationMonitorChartControl;
                    ObservableCollection <LineService> temp  = new ObservableCollection <LineService>();
                    foreach (var lineData in LineServiceData)
                    {
                        LineService lineService = ObjectMapper.CopyTo <LineService>(lineData);
                        ObservableCollection <LineData> lineDatas = new ObservableCollection <LineData>();
                        foreach (var time in lineData.LineServicesData)
                        {
                            if (time.PointXDate >= chart.StartTime && time.PointXDate <= chart.EndTime.AddMinutes(5))
                            {
                                lineDatas.Add(time);
                            }
                        }
                        lineService.LineServicesData = lineDatas;
                        temp.Add(lineService);
                    }
                    chart.LineServiceData = new ObservableCollection <LineService>(temp);
                }
            }
        }