Esempio n. 1
0
        private void PPositionChanged(object sender, PositionChangedEventArgs args)
        {
            var xDatamodelCurrent = XforDb(args.Position.X);
            var draggablePoint    = (DraggablePoint)sender;

            //add node to replace moving sidenode (left).
            if (Math.Abs(args.PreviousPosition.X - CompXdBStart) < 3 && _points.First().Equals(draggablePoint))
            {
                AddPointToList(CompXdBStart, args.PreviousPosition.Y, false);
            }
            //add node to replace moving sidenode (right).
            if (Math.Abs(args.PreviousPosition.X - (CompXdBStart + 96)) < 3 && _points.Last().Equals(draggablePoint))
            {
                AddPointToList(CompXdBStart + 96, args.PreviousPosition.Y, true);
            }

            //from previous to current
            if (LineData.Any(q => q.Position.X < args.Position.X))
            {
                var xDatamodelPrevious =
                    XforDb(LineData.Where(q => q.Position.X < args.Position.X).Max(q => q.Position.X));
                double positions  = Math.Abs(xDatamodelPrevious - xDatamodelCurrent);
                var    previousdB = Compressor.CompressorValues[xDatamodelPrevious];

                for (var position = 0; position <= positions; position++)
                {
                    Compressor.CompressorValues[position + xDatamodelPrevious] = previousdB +
                                                                                 (args.Position.Y - previousdB) * (position / positions);
                }
            }
            //from current to next
            if (LineData.Any(q => q.Position.X > args.Position.X))
            {
                var    xDatamodelNext = XforDb(LineData.Where(q => q.Position.X > args.Position.X).Min(q => q.Position.X));
                double positions      = Math.Abs(xDatamodelCurrent - xDatamodelNext);
                var    addition       = 1 / positions;
                var    nextDb         = Compressor.CompressorValues[xDatamodelNext];

                for (var position = 0; position < positions; position++)
                {
                    Compressor.CompressorValues[position + xDatamodelCurrent] = args.Position.Y + addition * (nextDb - args.Position.Y) * position;
                }
            }
            SendCompressor(Id, Compressor);
        }
        //private void ScaleFont(Label lab)
        //{
        //    SizeF extent = TextRenderer.MeasureText(lab.Text, lab.Font);

        //    float hRatio = lab.Height / extent.Height;
        //    float wRatio = lab.Width / extent.Width;
        //    float ratio = (hRatio < wRatio) ? hRatio : wRatio;

        //    float newSize = lab.Font.Size * ratio;

        //    lab.Font = new Font(lab.Font.FontFamily, newSize, lab.Font.Style);
        //}
        private void LoadDataERPMQCToShow()
        {
            //Load data from m_ERPMQC
            LoadDataMQC dataMQC = new LoadDataMQC();

            dept        = "B01";
            process     = "MQC";
            ListMQCshow = dataMQC.listMQCItemsOfDept(dateTimeFrom, dateTimeTo, dept, process);
            var listshowline = ListMQCshow
                               .OrderBy(u => u.line)
                               .GroupBy(u => u.line)
                               .Select(grp => grp.ToList())
                               .ToList();
            List <MQCItem1> ListShowbyLine = new List <MQCItem1>();

            foreach (var LineData in listshowline)
            {
                MQCItem1 mQC     = new MQCItem1();
                DateTime maxDate = LineData.Select(d => d.DateRun).Max();
                mQC = LineData.Where(d => d.DateRun == maxDate).ToList()[0];

                ListShowbyLine.Add(mQC);
            }

            int topCount = CountColumn * CountRow;

            //ListMQCTake = ListMQCshow.Take(topCount).ToList();
            layoutMain.Controls.Clear();

            if (ListShowbyLine.Count <= topCount)
            {
                int countList = 0;
                for (int i = 0; i < CountRow; i++)
                {
                    for (int j = 0; j < CountColumn; j++)
                    {
                        if (countList < ListShowbyLine.Count)
                        {
                            //   line.Dispose();
                            if (this.WindowState == FormWindowState.Normal)
                            {
                                line = new LineUI(ListShowbyLine[countList], cb_Department.Text, 20);
                            }
                            else if (this.WindowState == FormWindowState.Maximized)
                            {
                                line = new LineUI(ListShowbyLine[countList], cb_Department.Text, 25);
                            }
                            line.Name = ListShowbyLine[countList].line;

                            line.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                                 | System.Windows.Forms.AnchorStyles.Left)
                                                                                | System.Windows.Forms.AnchorStyles.Right)));

                            layoutMain.Controls.Add(line, j, i);
                            countList++;
                        }
                    }
                }
            }


            lb_Clock.Text = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss");
        }