コード例 #1
0
ファイル: frmPorts.cs プロジェクト: damaro05/JenkingsTest
        private void updatePortInstance(int port, PictureBox pcb, Label lbl)
        {
            // Required var's
            bool sleep               = false;
            bool hiber               = false;
            bool extractor           = false;
            bool desolder            = false;
            GenericStationTools tool = default(GenericStationTools);
            string status            = "";

            // If the port exists
            if (port < nPorts)
            {
                // Setting the tool image
                tool = jbc.GetPortToolID(myID, (Port)port);
                pcb.BackgroundImage = (Image)My.Resources.Resources.ResourceManager.GetObject(tool.ToString() + "_mini");

                // Determinating the tool status
                sleep     = jbc.GetPortToolSleepStatus(myID, (Port)port) == OnOff._ON;
                hiber     = jbc.GetPortToolHibernationStatus(myID, (Port)port) == OnOff._ON;
                extractor = jbc.GetPortToolExtractorStatus(myID, (Port)port) == OnOff._ON;
                desolder  = jbc.GetPortToolDesolderStatus(myID, (Port)port) == OnOff._ON;
                if (sleep)
                {
                    status = Localization.getResStr(Configuration.PortsSleepId);
                }
                else if (hiber)
                {
                    status = Localization.getResStr(Configuration.PortsHiberId);
                }
                else if (extractor)
                {
                    status = Localization.getResStr(Configuration.PortsExtractorId);
                }
                else if (desolder)
                {
                    status = Localization.getResStr(Configuration.PortsDesolderId);
                }
                else if (tool == GenericStationTools.NO_TOOL)
                {
                    status = Localization.getResStr(Configuration.PortsNoToolId);
                }
                else
                {
                    status = Localization.getResStr(Configuration.PortsWorkId);
                }

                // Getting the temperature string
                string       tempStr = "";
                CTemperature temp    = jbc.GetPortToolActualTemp(myID, (Port)port);
                if (!Equals(temp, null))
                {
                    if (temp.isValid())
                    {
                        if (Configuration.Tunits == Configuration.CELSIUS_STR)
                        {
                            tempStr = temp.ToCelsius().ToString() + Configuration.Tunits;
                        }
                        if (Configuration.Tunits == Configuration.FAHRENHEIT_STR)
                        {
                            tempStr = temp.ToFahrenheit().ToString() + Configuration.Tunits;
                        }
                    }
                }

                // Showing the port data depending on the status
                int    textW   = System.Convert.ToInt32(lbl.CreateGraphics().MeasureString(Localization.getResStr(Configuration.PortsPortTitleId) + " " + (port + 1).ToString(), Configuration.PortsFont).Width);
                int    spaceW  = System.Convert.ToInt32(lbl.CreateGraphics().MeasureString(" ", Configuration.PortsFont).Width);
                int    nSpaces = System.Convert.ToInt32((lbl.Width - textW) / spaceW);
                string sTool   = tool.ToString();
                if (tool == GenericStationTools.NO_TOOL)
                {
                    sTool = " ";
                }
                lbl.Text = new string(' ', nSpaces);
                lbl.Text = lbl.Text + Localization.getResStr(Configuration.PortsPortTitleId) + " " + (port + 1).ToString() + "\r\n";
                lbl.Text = lbl.Text + sTool + "\r\n";
                if (status == Localization.getResStr(Configuration.PortsWorkId))
                {
                    lbl.Text = lbl.Text + tempStr;
                }
                else
                {
                    lbl.Text = lbl.Text + status;
                }
            }
        }