コード例 #1
0
        private void Form2_Resize(object sender, System.EventArgs e)
        {
            Console.Write("Enter your name: ");

            Control control = (Control)sender;

            // Ensure the Form remains square (Height = Width).
            //if(control.Size.Height != control.Size.Width)
            //{
            //    control.Size = new Size(control.Size.Width, control.Size.Width);
            //}

            var appRect = new Geometry.Rectangle(0f, Size.Width - 10, 0f, Size.Height);
            var boxRect = appRect.RatedRectangle(appRatio);

            systemControls.resizeToWindowRect(boxRect);
            connectionIndicators.resizeToWindowRect(boxRect);
            palleteVisuals.resizeToWindowRect(boxRect);
            servoControls.resizeToWindowRect(boxRect);
            errorBox.resizeToWindowRect(boxRect);
            bg.Reorient((int)boxRect.L, (int)boxRect.T, (int)boxRect.W + 2, (int)boxRect.H);
        }
コード例 #2
0
        private void InitializeComponent()
        {
            this.components      = new System.ComponentModel.Container();
            this.AutoScaleMode   = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize      = new System.Drawing.Size(appWidthInit, appHeightInit);
            this.Text            = "Paletleyici Kontrolleri";
            this.BackColor       = Color.DimGray;
            this.FormBorderStyle = FormBorderStyle.Sizable;
            this.Icon            = new System.Drawing.Icon(References.ProjectPath + "Images\\t-ara128.ico");

            var n  = 5;
            var n2 = String.Format("{0}", n);

            SetErrorTexts();

            systemControls.PalleteButton.ClickAction = () =>
            {
                // input is the list of options, change options here
                List <string> orders   = ConnectionManager.Sql.GetOrders();
                List <string> zeroless = new List <string>();
                foreach (string order in orders)
                {
                    zeroless.Add(order.Substring(5));
                }
                pp.Opening(zeroless.ToArray());
                pp.ShowDialog();
                if (pp.Confirmed)
                {
                    var no = pp.RobotNo - 1;
                    ConnectionManager.EmptyCell(no);
                    emptyCell(no);
                    var order = orders[pp.SelectedIndex];
                    var p     = ConnectionManager.Sql.GetPallet(order);

                    // pp.SelectedIndex returns the selected index

                    // adjust the following line according to the returned index
                    var product = ConnectionManager.Sql.Select("Siparis_No", order);
                    int k       = ConnectionManager.GetKatMax(product.GetHeight(), product.GetWidth(), product.GetYontem(),
                                                              product.GetProductType());
                    int l = ConnectionManager.GetPalletMax(product.GetHeight(), product.GetWidth(), product.GetYontem(),
                                                           product.GetProductType());
                    assignCell(no + 1, long.Parse(orders[pp.SelectedIndex]), p, l);
                    ConnectionManager.AssignCell(long.Parse(order), no + 1, p, k, product);
                }
            };


            systemControls.ReconnectButton.ClickAction = () =>
            {
                ConnectionManager.Connect();
            };

            systemControls.AddProductButton.ClickAction = () =>
            {
                nbp.Opening();
                nbp.ShowDialog();
                if (nbp.confirmed)
                {
                    var info = nbp.GetLines;
                    ConnectionManager.EmptyCell(nbp.RobotNo - 1);
                    emptyCell(nbp.RobotNo - 1);
                    int k = ConnectionManager.GetPalletMax(int.Parse(info[0]), int.Parse(info[1]), int.Parse(info[4]), int.Parse(info[2]));
                    int l = ConnectionManager.GetKatMax(int.Parse(info[0]), int.Parse(info[1]), int.Parse(info[4]), int.Parse(info[2]));

                    ConnectionManager.AssignNonBarcodeCell(nbp.RobotNo, int.Parse(info[0]), int.Parse(info[1]), int.Parse(info[2]), int.Parse(info[3]), info[4], int.Parse(info[5]),
                                                           int.Parse(info[6]), int.Parse(info[7]), l);
                    assignCell(nbp.RobotNo, 0, new Pallet(int.Parse(info[5]), int.Parse(info[6]), int.Parse(info[2]), int.Parse(info[3])), k);
                    ConnectionManager.PatternMode = true;
                }
            };

            systemControls.BypassButton.ClickAction = () =>
            {
                ConnectionManager.BypassTaper(!bypassing);
                bypassing = !bypassing;
            };

            servoControls.Implement(this.Controls);
            servoControls.applyPressed = () =>
            {
                ConnectionManager.SendServoAdjustments(servoControls.getValues());
                servoControls.ResetNumbers();
            };

            errorBox.Implement(this.Controls);

            errorBox._fixButton.ClickAction = () =>
            {
                var x = 0.0;
                foreach (var i in activeErrors)
                {
                    x = x + Math.Pow(2, i);
                }

                ConnectionManager.SendFixSignal(x);
            };

            systemControls.Implement(this.Controls);
            palleteVisuals.Implement(this.Controls);

            ConnectionManager.BarcodeConnectionChanged += barcodeIndicatorUpdater;
            ConnectionManager.PlcConnectionChanged     += plcIndicatorUpdater;
            ConnectionManager.TaperConnectionChanged   += taperIndicatorUpdater;
            ConnectionManager.ProductIncoming          += productAdd;
            ConnectionManager.ProductDropped           += productFill;
            ConnectionManager.CellFull     += resetKat;
            ConnectionManager.CellAssigned += assignCell;
            ConnectionManager.ErrorUpdate  += updateErrors;
            ConnectionManager.Init();
            LoadData();
            ConnectionManager.Connect();
            connectionIndicators.Implement(this.Controls);
            connectionIndicators.BarcodeConnect(ConnectionManager.BarcodeClient.Connected);
            connectionIndicators.PlcConnect(ConnectionManager.Plc.IsConnected);
            connectionIndicators.TaperConnect(ConnectionManager.Plc2.IsConnected);

            Resize += new EventHandler(Form2_Resize);

            bg.Reorient(0, 0, appWidth, appHeight);
            Controls.Add(bg);

            var appRect = new Geometry.Rectangle(0f, ClientSize.Width, 0f, ClientSize.Height);

            var boxRect = appRect.RatedRectangle(appRatio);

            systemControls.resizeToWindowRect(boxRect);
            connectionIndicators.resizeToWindowRect(boxRect);
            palleteVisuals.resizeToWindowRect(boxRect);
            servoControls.resizeToWindowRect(boxRect);
            errorBox.resizeToWindowRect(boxRect);
            bg.Reorient((int)boxRect.L, (int)boxRect.T, (int)boxRect.W, (int)boxRect.H);
        }