//public
        public ScreenControl(int PosX, int PosY)
        {
            this.BackColor = System.Drawing.Color.Navy;
            this.Location  = new System.Drawing.Point(PosX, PosY);
            this.Name      = "panelVirtual";
            this.Size      = new System.Drawing.Size(640, 480);
            this.Visible   = true;
            this.Paint    += new System.Windows.Forms.PaintEventHandler(this.DrawScreenControl);

            ScreenKey SK_Control = new ScreenKey();

            // init Box
            Point P1 = new Point(0, 0);
            Point P2 = new Point(20, 30);

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 32; j++)
                {
                    ScreenBox[j, i] = new BoxScreenControl(P1, P2);
                    P1.X           += 20;
                    P2.X           += 20;
                }
                P1.X  = 0;
                P2.X  = 20;
                P1.Y += 30;
                P2.Y += 30;
            }
        }
        // State -> Map
        #region Map

        #endregion

        // State -> Play
        #region Play
        private void RefreshPlay(StateTable st)
        {
            labelActualState.Text   = "Actual state : ";
            labelDislpayScreen.Text = "Display screen : ";
            treeViewStatePart.Nodes[0].Nodes.Clear();
            treeViewStatePart.Nodes[1].Nodes.Clear();

            for (int i = 0; i < st.PART.Length; i++)
            {
                if (st.PART[i].mask == null || SC == null)
                {
                    break;
                }

                if (st.PART[i].mask == "SCREEN_DISPLAY")
                {
                    ScreenKey temp = ScreenKey.GetScreenKey(st.PART[i].value);
                    if (temp == null)
                    {
                        labelDislpayScreen.Text += "NOT EXIST!!!";
                        //break;
                    }
                    else
                    {
                        SC.LoadCharScreen(temp.text, false, temp.numar);
                        Refresh();
                        labelDislpayScreen.Text = "Display screen : " + temp.numar;
                    }



                    treeViewStatePart.Nodes[0].Nodes.Add(st.PART[i].value + "->" + st.PART[i].name);
                    //break;
                }
                else if (st.PART[i].mask.Contains("SCREEN_"))
                {
                    treeViewStatePart.Nodes[0].Nodes.Add(st.PART[i].value + "->" + st.PART[i].name);
                }
                else if (st.PART[i].mask.Contains("STATE_"))
                {
                    if (!st.PART[i].mask.Contains("STATE_EXTENSION") && !st.PART[i].mask.Contains("STATE_EXTENDED"))
                    {
                        treeViewStatePart.Nodes[1].Nodes.Add(st.PART[i].value + "->" + st.PART[i].name);
                    }
                    else if (st.PART[i].mask.Contains("STATE_EXTENDED"))
                    {
                        treeViewStatePart.Nodes[1].Nodes.Add("---EXTENDED---" + st.PART[i + 1].description);
                    }
                }
                else if (st.PART[i].mask.Contains("NUMBER") && i > 0)
                {
                    treeViewStatePart.Nodes[1].Nodes.Add("---EXTENDED---" + st.PART[i + 1].description);
                }
            }
            labelActualState.Text += st.PART[0].value;
        }
        private void comboBoxSubscreen_SelectedIndexChanged(object sender, EventArgs e)
        {
            SC.ClearScreenBox(0, 0);
            ScreenKey temp = ScreenKey.GetScreenKey(comboBoxSubscreen.Text);

            SC.LoadCharScreen(temp.text, false, temp.numar);
            textBoxScreenView.Text = temp.numar;
            textBoxScreen.Text     = temp.text;
            SC.Refresh();
        }
        private void treeViewStatePart_AfterSelect(object sender, TreeViewEventArgs e)
        {
            labelDislpayScreen.Text = "Display screen : ";
            SC.ClearScreenBox(0, 0);
            SC.Refresh();

            if (treeViewStatePart.SelectedNode.Parent == null)
            {
                return;
            }
            else if (treeViewStatePart.SelectedNode.Parent.Text == "SCREENS")
            {
                SC.ClearScreenBox(0, 0);
                string    screenNr = treeViewStatePart.SelectedNode.Text.Substring(0, treeViewStatePart.SelectedNode.Text.IndexOf("->"));
                ScreenKey tempSK   = ScreenKey.GetScreenKey(screenNr);

                if (tempSK == null)
                {
                    SC.LoadCharScreen(((char)0x1B).ToString() + "(1<NOT EXIST>", false, screenNr);
                    SC.Refresh();
                    return;
                }
                labelDislpayScreen.Text = "Display screen : " + screenNr.ToString();
                SC.LoadCharScreen(ScreenKey.GetScreenKey(screenNr).text, true, screenNr);
                SC.Refresh();
            }
            else if (treeViewStatePart.SelectedNode.Parent.Text == "STATES" && treeViewStatePart.SelectedNode.Text[0] != '-')
            {
                if (StateTable.ViewStateTables.Count == 0)
                {
                    StateTable st = new StateTable(listBoxStateTabels.Items[listBoxStateTabels.SelectedIndex].ToString());
                    StateTable.ViewStateTables.Add(st);
                }

                string     stateNr = treeViewStatePart.SelectedNode.Text.Substring(0, treeViewStatePart.SelectedNode.Text.IndexOf("->"));
                StateTable temp    = StateTable.FindStateTabelsInList(stateNr);
                int        i       = listBoxStateTabels.FindString(temp.textTable);
                listBoxStateTabels.SelectedIndex = i;

                StateTable.RemoveViewStatesTables(StateTable.SelectViewStates);
                StateTable.ViewStateTables.Add(temp);
                StateTable.RefreshViewStatesTables(comboBoxViewStates);
            }
        }
        private void listBoxScreenKeyboard_SelectedIndexChanged(object sender, EventArgs e)
        {
            SC.ClearScreenBox(0, 0);
            labelFF.Visible = true;

            SC.ScreenBox[0, 0] = new BoxScreenControl(new Point(0, 0), new Point(20, 30), 'N');
            string numarScreen = listBoxScreenKeyboard.Items[listBoxScreenKeyboard.SelectedIndex].ToString();

            textBoxScreen.Text = ScreenKey.GetScreenKey(numarScreen).text;
            SK         = SC.LoadCharScreen(textBoxScreen.Text, false, ScreenKey.GetScreenKey(numarScreen).numar);
            SC.Visible = true;
            SC.Refresh();
            textBoxScreenView.Text = SK.numar;

            if (textBoxScreen.Text.Contains(((char)0x0C).ToString()))
            {
                labelFF.Visible = false;
            }
            labelVoice.Text            = "Voices : " + SK.VoiceList.Count.ToString();
            labelGraphic.Text          = "Graphics : " + SK.GraphicPictures.Count.ToString();
            labelPicture.Text          = "Pictures : " + SK.Picture.Count.ToString();
            labelLogo.Text             = "Logos : " + SK.Logo.Count.ToString();
            labelDisplayImageFile.Text = "Display Image Files : " + SK.DisplayImageFileCommand.Count.ToString();
            // idle screen
            labelIdleScreen.Text = "Idle screens : " + SK.ScreenIdle.Count.ToString();
            comboBoxIdleScreen.Items.Clear();
            comboBoxIdleScreen.Text = "";
            for (int i = 0; i < SK.ScreenIdle.Count; i++)
            {
                comboBoxIdleScreen.Items.Add(SK.ScreenIdle[i].numar);
            }

            // subscreen
            labelSubscreen.Text = "Subscreens : " + SK.SubScreen.Count.ToString();
            comboBoxSubscreen.Items.Clear();
            comboBoxSubscreen.Text = "";
            for (int i = 0; i < SK.SubScreen.Count; i++)
            {
                comboBoxSubscreen.Items.Add(SK.SubScreen[i].numar);
            }
        }
        private void buttonSplitSelect_Click(object sender, EventArgs e)
        {
            ScreenKey.ScreenKeys.Clear();
            StateTable.ListOfStateTables.Clear();
            StateTable.ViewStateTables.Clear();
            StateTable.RefreshViewStatesTables(comboBoxViewStates);

            StreamReader sr = new StreamReader(pathFile + @"\SplitIn\MessageIn.anl");

            // terminal commands
            sr.BaseStream.Position = 0;
            if (checkBoxTerminalCommands.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Terminal Commands.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();

                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        if (line[0] == '1' && line[2] == (char)28)
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // screen/keyboard data
            sr.BaseStream.Position = 0;
            if (checkBoxScreenKeyboard.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Screen Keyboard.tdb");
                StreamWriter writer = f.CreateText();
                writer.Close();

                f      = new FileInfo(pathFile + @"\SplitIn\Screen Keyboard.anl");
                writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == '1')  // 3.....11
                        {
                            ScreenKeyDataLoad.SaveToFile(line, pathFile + @"\SplitIn\Screen Keyboard.tdb", true);
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();

                ScreenKey.LoadScreenKeys(pathFile + @"\SplitIn\Screen Keyboard.tdb");
            }

            // state tables
            sr.BaseStream.Position = 0;
            if (checkBoxStateTables.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\State Tables.anl");
                StreamWriter writer = f.CreateText();

                FileInfo     stateDB = new FileInfo(pathFile + @"\SplitIn\State Tables.tdb");
                StreamWriter writer2 = stateDB.CreateText();
                writer2.Close();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == '2')  // 3.....12
                        {
                            writer.WriteLine(line);
                            StateTablesLoad stl = new StateTablesLoad(line);
                            stl.SaveToFile(pathFile + @"\SplitIn\State Tables.tdb");
                        }
                    }
                    line = sr.ReadLine();
                }
                writer.Close();

                StateTable.LoadListOfStateTables(pathFile + @"\SplitIn\State Tables.tdb");
                // load list
                comboBoxViewStateTabel.Text = "ALL";
                listBoxStateTabels.Items.Clear();
                for (int i = 0; i < StateTable.ListOfStateTables.Count; i++)
                {
                    listBoxStateTabels.Items.Add(StateTable.ListOfStateTables[i].textTable);
                }
            }

            // configuration parameters
            sr.BaseStream.Position = 0;
            if (checkBoxConfigurationParameters.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Configuration Parameters.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == '3')  // 3.....13
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // FIT data
            sr.BaseStream.Position = 0;
            if (checkBoxFIT.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\FIT.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == '5')  // 3.....15
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Configuration ID Number Load
            sr.BaseStream.Position = 0;
            if (checkBoxConfigurationIDNumber.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Configuration ID Number.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == '6')  // 3.....16
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Enhanced Configuration Parameters Load
            sr.BaseStream.Position = 0;
            if (checkBox1EnhancedConfigurationParameters.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Enhanced Configuration Parameters.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == 'A')  // 3.....16
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // MAC Field Selection Load
            sr.BaseStream.Position = 0;
            if (checkBoxMACFieldSelection.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\MAC Field Selection.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == 'B')  // 3.....1B
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Date and Time
            sr.BaseStream.Position = 0;
            if (checkBoxDateAndTime.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Date and Time.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == 'C')  // 3.....1C
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Dispenser Currency Cassette Mapping Table
            sr.BaseStream.Position = 0;
            if (checkBoxDispencerCurrencyCassetteMapp.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Dispenser Currency Cassette Mapping Table.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == 'E')  // 3.....1E
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // XML Configuration Download
            sr.BaseStream.Position = 0;
            if (checkBoxXMLConfigurationDownload.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\XML Configuration Download.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == 'I')  // 3.....1I
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Interactive Transaction Response
            sr.BaseStream.Position = 0;
            if (checkBoxInteractiveTransactionResponse.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Interactive Transaction Response.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '2' && (line[posSep3 + 2] >= '0' && line[posSep3 + 2] <= '9'))   // 3.....2(0-9)
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Encryption Key Change
            sr.BaseStream.Position = 0;
            if (checkBoxEncryptionKeyChange.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Encryption Key Change.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '3' && (line[posSep3 + 2] >= '1' && line[posSep3 + 2] <= '9'))  // 3.....3(1-9)
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Extended Encryption Key Change
            sr.BaseStream.Position = 0;
            if (checkBoxExtendedEncryptionKeyChange.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Extended Encryption Key Change.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '3' && ((line[posSep3 + 2] >= '1' && line[posSep3 + 2] <= '9') || (line[posSep3 + 2] >= 'A' && line[posSep3 + 2] <= 'K')))  // 4.....2(1-9)|(A-K)
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // HostToExitMessages
            sr.BaseStream.Position = 0;
            if (checkBoxHostToExitMessages.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Host to Exit Messages.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 1);
                        if (posSep3 > 0 && line[0] == '7' && line[posSep3 + 1] == '1')  // 7.....1
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Transaction Reply Command
            sr.BaseStream.Position = 0;
            if (checkBoxTransactionReplyCommand.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Transaction Reply Command.anl");
                StreamWriter writer = f.CreateText();

                string line     = sr.ReadLine();
                bool   mutiline = false;

                while (line != null)
                {
                    if (mutiline == true)
                    {
                        if (line.Contains(stopSeparatorMessage) && line[0] == stopSeparatorMessage[0]) // sfarsitul mesajului
                        {
                            mutiline = false;
                            writer.WriteLine(stopSeparatorMessage);
                        }
                        else
                        {
                            writer.WriteLine(line);
                        }
                    }

                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '4')  // 4.....
                        {
                            mutiline = true;
                            writer.WriteLine(startSeparatorMessage);
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            sr.Close();
        }
        // incarca aria screen-ului cu caractere
        public ScreenKey LoadCharScreen( string strScreen, bool showIdleScreen, string numar )
        {
            SK_Control = new ScreenKey();
            SK_Control.numar = numar;
            SK_Control.text = strScreen;

            int ii = 0;
            int jj = 0;
            int offset = 0; // caractere pe lungime dubla

            string font = BoxScreenControl.NDCFONTS[0];
            float size = BoxScreenControl.SIZEFONTS[0];
            Color tempColorBCK = Color.Navy;
            Brush tempBrText = Brushes.Yellow;
            Brush lastTempBrText = Brushes.Yellow;

            // initial value
            int leftMargin = 0;

            ii = 0;
            jj = 0;
            //ClearScreenBox(0, 0);

            for(int i = 0; i < strScreen.Length; i++)
            {
                char ch = strScreen[i];
                switch(ch)
                {
                    case (char)0x0C:    // FF
                        ii = 0;
                        jj = 0;
                        ClearScreenBox(0,0);
                        tempColorBCK = Color.Navy;
                        tempBrText = Brushes.Yellow;
                        font = BoxScreenControl.NDCFONTS[0];
                        size = BoxScreenControl.SIZEFONTS[0];
                        offset = 0;
                        break;
                    case (char)0x0E:    // SO
                        if (strScreen.Length <= i+3)
                            return null;
                        ScreenKey temp = ScreenKey.GetScreenKey(strScreen.Substring(i + 1, ScreenKey.NrOfCharScreenNumber));

                        if (temp != null)
                        {
                            i += ScreenKey.NrOfCharScreenNumber;
                            // temp este un idle screen
                            if (strScreen.Length > i + 6 && strScreen[i + 1] == (char)0x1B && strScreen[i + 2] == '[' && strScreen[i + 6] == 'z')
                            {
                                temp.idle = Convert.ToInt16(strScreen.Substring(i + 3, 3));
                                SK_Control.ScreenIdle.Add(temp);
                                i += 6;
                            }
                            else
                            {
                                i -= ScreenKey.NrOfCharScreenNumber;
                                strScreen = strScreen.Remove(i, ScreenKey.NrOfCharScreenNumber+1);
                                strScreen = strScreen.Insert(i, temp.text);
                                SK_Control.SubScreen.Add(temp);
                                i--;
                            }
                        }
                        //‘G00’ – standard Insert Card picture
                        //‘G01’ – standard Press Key picture
                        //‘G03’ – standard Make A Deposit picture
                        //‘G04’ – standard Take Receipt picture
                        //‘G05’ – standard Take Money picture
                        //‘G06’ – standard Take Statement picture.
                        else if (strScreen[i + 1] == 'G')// G – Graphic Pictures
                        {
                            string strPath = @"C:\NTGlobal\Final\XFS\Dll\" + strScreen.Substring(i + 1, 3) + ".pcx";
                            SK_Control.GraphicPictures.Add(new Photo(strPath, ii, jj));
                            i += 3;
                        }
                        break;
                    case (char)0x0F:    // SI
                        if( i + 2 < strScreen.Length )
                        {
                            int tempii = GetPos(strScreen[i + 1]);
                            if (tempii < 0)
                                break;
                            int tempjj = GetPos(strScreen[i + 2]);
                            if (tempjj < 0)
                                break;
                            ii = tempii;
                            jj = tempjj;
                            i = i + 2;
                        }
                        break;
                    case (char)0x09:    // HT
                        // Causes the name encoded on Track 1 of the card to be displayed, starting at the current cursor position (32 characters maximum). Both ISO and VISA display formats are supported.
                        // tab?
                        break;
                    case (char)0x11:    // DC1
                        break;
                    case (char)0x12:    // DC2
                        break;
                    case (char)0x1B:    // ESC
                        // Digital Audio Control Sequence
                        #region Digital Audio Control Sequence
                        if ( strScreen.Length > i + 8 && strScreen[i + 1] == 'P' && strScreen[i + 2] == '0' )
                        {
                            string terminatorVoice = "" + ((char)0x1B).ToString() + ('\\').ToString();
                            int stopVoice = strScreen.IndexOf(terminatorVoice, i+1);
                            char id = strScreen[i + 2];
                            string messageNumber = strScreen.Substring(i + 3, stopVoice - i - 5);
                            char nr = strScreen[stopVoice-1];
                            SK_Control.VoiceList.Add(new Voice(id, messageNumber, nr));
                            i = stopVoice + 1;
                        }
                        #endregion
                        #region Screen blinking and colour control
                        // Screen blinking and colour control
                        else if (strScreen.Length > i + 7 && strScreen[i + 4] == ';' && strScreen[i + 1] == '[')
                        {
                            string color = strScreen.Substring(i + 2, 2);
                            // background color
                            if (color == "30" || color == "C0")
                                tempColorBCK = Color.Black;
                            else if (color == "31" || color == "C1")
                                tempColorBCK = Color.Red;
                            else if (color == "C2" || color == "32")
                                tempColorBCK = Color.Green;
                            else if (color == "C3" || color == "33")
                                tempColorBCK = Color.Yellow;
                            else if (color == "34" || color == "C4")
                                tempColorBCK = Color.Blue;
                            else if (color == "35" || color == "C5")
                                tempColorBCK = Color.Magenta;
                            else if (color == "36" || color == "C6")
                                tempColorBCK = Color.Cyan;
                            else if (color == "C7" || color == "37")
                                tempColorBCK = Color.White;
                            else if (color == "80")
                                tempColorBCK = Color.Transparent;
                            // text color
                            else if (color == "20" || color == "BO")
                                tempBrText = Brushes.Black;
                            else if (color == "21" || color == "B1")
                                tempBrText = Brushes.Red;
                            else if (color == "B2" || color == "22")
                                tempBrText = Brushes.Green;
                            else if (color == "B3" || color == "23")
                                tempBrText = Brushes.Yellow;
                            else if (color == "24" || color == "B4")
                                tempBrText = Brushes.Blue;
                            else if (color == "25" || color == "B5")
                                tempBrText = Brushes.Magenta;
                            else if (color == "26" || color == "B6")
                                tempBrText = Brushes.Cyan;
                            else if (color == "B7" || color == "27")
                                tempBrText = Brushes.White;
                            // blink
                            else if (color == "10")
                            {
                                lastTempBrText = tempBrText;
                                tempBrText = Brushes.Violet;
                            }
                            else if (color == "11")
                                tempBrText = lastTempBrText;
                            else if (color == "00")
                                tempBrText = lastTempBrText;

                            i += 7;
                        }
                        // Screen blinking and colour control
                        else if (strScreen.Length > i + 5 && strScreen[i + 4] == 'm' && strScreen[i + 1] == '[')
                        {
                            string color = strScreen.Substring(i + 2, 2);
                            // background color
                            if (color == "30" || color == "C0")
                                tempColorBCK = Color.Black;
                            else if (color == "31" || color == "C1")
                                tempColorBCK = Color.Red;
                            else if (color == "C2" || color == "32")
                                tempColorBCK = Color.Green;
                            else if (color == "C3" || color == "33")
                                tempColorBCK = Color.Yellow;
                            else if (color == "34" || color == "C4")
                                tempColorBCK = Color.Blue;
                            else if (color == "35" || color == "C5")
                                tempColorBCK = Color.Magenta;
                            else if (color == "36" || color == "C6")
                                tempColorBCK = Color.Cyan;
                            else if (color == "C7" || color == "37")
                                tempColorBCK = Color.White;
                            else if (color == "80")
                                tempColorBCK = Color.Transparent;
                            // text color
                            else if (color == "20" || color == "BO")
                                tempBrText = Brushes.Black;
                            else if (color == "21" || color == "B1")
                                tempBrText = Brushes.Red;
                            else if (color == "B2" || color == "22")
                                tempBrText = Brushes.Green;
                            else if (color == "B3" || color == "23")
                                tempBrText = Brushes.Yellow;
                            else if (color == "24" || color == "B4")
                                tempBrText = Brushes.Blue;
                            else if (color == "25" || color == "B5")
                                tempBrText = Brushes.Magenta;
                            else if (color == "26" || color == "B6")
                                tempBrText = Brushes.Cyan;
                            else if (color == "B7" || color == "27")
                                tempBrText = Brushes.White;
                            // blink
                            else if (color == "10")
                            {
                                lastTempBrText = tempBrText;
                                tempBrText = Brushes.Violet;
                            }
                            else if (color == "11")
                                tempBrText = lastTempBrText;
                            else if (color == "00")
                                tempBrText = lastTempBrText;

                            i += 4;
                        }
                        #endregion
                        // Changing display in idle
                        else if (strScreen.Length > i + 6 && strScreen[i + 5] == 'z' && strScreen[i + 1] == '[')
                        {
                            int delayTime = Convert.ToInt16(strScreen.Substring(i + 2, 3));
                            i += 5;
                        }
                        #region Character set 1
                        // select character set - 1
                        else if (strScreen.Length > i + 2 && strScreen[i + 1] == '(')
                        {
                            switch(strScreen[i+2])
                            {
                                case '1':
                                    offset = 0;
                                    font = BoxScreenControl.NDCFONTS[0];
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    break;
                                case '2':
                                    offset = 0;
                                    font = BoxScreenControl.NDCFONTS[1];
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    break;
                                case '3':
                                    offset = 0;
                                    font = BoxScreenControl.NDCFONTS[2];
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    break;
                                case '4':
                                    offset = 0;
                                    font = BoxScreenControl.NDCFONTS[3];
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    break;
                                case '5':
                                    offset = 0;
                                    font = BoxScreenControl.NDCFONTS[4];
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    break;
                                case '>':
                                    offset = 1;
                                    size = BoxScreenControl.SIZEFONTS[1];
                                    font = BoxScreenControl.NDCFONTS[5];
                                    break;
                                case '?':
                                    offset = 1;
                                    size = BoxScreenControl.SIZEFONTS[1];
                                    font = BoxScreenControl.NDCFONTS[6];
                                    break;
                                case '7':
                                    offset = 0;
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    font = BoxScreenControl.NDCFONTS[7];
                                    break;
                                case ':':
                                    offset = 0;
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    font = BoxScreenControl.NDCFONTS[8];
                                    break;
                                case ';':
                                    offset = 0;
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    font = BoxScreenControl.NDCFONTS[9];
                                    break;
                                case 'B':
                                    offset = 1;
                                    size = BoxScreenControl.SIZEFONTS[1];
                                    font = BoxScreenControl.NDCFONTS[10];
                                    break;
                            }
                            i = i + 2;
                        }
                        #endregion
                        #region Character set 2
                        // select character set - 2
                        else if (strScreen.Length > i + 2 && strScreen[i + 1] == ')')
                        {
                            switch (strScreen[i + 2])
                            {
                                case '1':
                                    offset = 0;
                                    font = BoxScreenControl.NDCFONTS[0];
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    break;
                                case '2':
                                    offset = 0;
                                    font = BoxScreenControl.NDCFONTS[1];
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    break;
                                case '3':
                                    offset = 0;
                                    font = BoxScreenControl.NDCFONTS[2];
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    break;
                                case '4':
                                    offset = 0;
                                    font = BoxScreenControl.NDCFONTS[3];
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    break;
                                case '5':
                                    offset = 0;
                                    font = BoxScreenControl.NDCFONTS[4];
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    break;
                                case '>':
                                    offset = 1;
                                    size = BoxScreenControl.SIZEFONTS[1];
                                    font = BoxScreenControl.NDCFONTS[5];
                                    break;
                                case '?':
                                    offset = 1;
                                    size = BoxScreenControl.SIZEFONTS[1];
                                    font = BoxScreenControl.NDCFONTS[6];
                                    break;
                                case '7':
                                    offset = 0;
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    font = BoxScreenControl.NDCFONTS[7];
                                    break;
                                case ':':
                                    offset = 0;
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    font = BoxScreenControl.NDCFONTS[8];
                                    break;
                                case ';':
                                    offset = 0;
                                    size = BoxScreenControl.SIZEFONTS[0];
                                    font = BoxScreenControl.NDCFONTS[9];
                                    break;
                                case 'B':
                                    offset = 1;
                                    size = BoxScreenControl.SIZEFONTS[1];
                                    font = BoxScreenControl.NDCFONTS[10];
                                    break;
                            }
                            i = i + 2;
                        }
                        #endregion
                        // Set Left Margin Position
                        else if (strScreen.Length > i + 5 && strScreen[i + 1] == '[' && strScreen[i + 5] == 'P')
                        {
                            leftMargin = Convert.ToInt32(strScreen.Substring(i+2, 2));
                            i = i + 5;
                        }
                        // select logo
                        else if (strScreen.Length > i + 5 && strScreen[i + 1] == 'P' && strScreen[i + 2] == '1')
                        {
                            string strPath = @"C:\NTGlobal\Final\XFS\Dll\pic00" + strScreen.Substring(i + 3, 2) + ".pcx";
                            SK_Control.Logo.Add(new Photo(strPath, ii, jj));
                            i += 5;
                        }
                        // Picture Control Command
                        else if (strScreen.Length > i + 5 && strScreen[i + 1] == 'P' && strScreen[i + 2] == '2')
                        {
                            string terminatorPicture = "" + ((char)0x1B).ToString() + ('\\').ToString();
                            int stopPicture = strScreen.IndexOf(terminatorPicture, i + 1);
                            string strPath = @"C:\NTGlobal\Final\XFS\Dll\pic00" + strScreen.Substring(i + 3, stopPicture - i - 3) + ".pcx";
                            SK_Control.Picture.Add(new Photo(strPath, ii, jj));
                            i = stopPicture + 1;
                        }
                        //
                        else if (strScreen.Length > i + 2 && strScreen[i + 1] == 'P' && strScreen[i + 2] == 'i') // not suported
                        {
                            string terminator = "" + ((char)0x1B).ToString() + ('\\').ToString();
                            int stop = strScreen.IndexOf(terminator, i + 1);
                            i = stop + 1;// +1;
                        }
                        // Display Image File Command
                        else if (strScreen.Length > i + 5 && strScreen[i + 1] == 'P' && strScreen[i + 2] == 'E')
                        {
                            string terminatorDisplay = "" + ((char)0x1B).ToString() + ('\\').ToString();
                            int stopDisplay = strScreen.IndexOf(terminatorDisplay, i + 1);
                            string strPath = @"C:\NTGlobal\Final\XFS\Dll" + strScreen.Substring(i + 3, stopDisplay - i - 3);// .avi?
                            SK_Control.DisplayImageFileCommand.Add(new Photo(strPath, ii, jj));
                            i = stopDisplay + 1;
                        }
                        // Display Lifted Cheque Image Command
                        else if (strScreen.Length > i + 5 && strScreen[i + 1] == 'P' && strScreen[i + 2] == 'E')
                        {
                            // not implement
                            string terminatorDisplay = "" + ((char)0x1B).ToString() + ('\\').ToString();
                            int stopDisplay = strScreen.IndexOf(terminatorDisplay, i + 1);
                            string strPath = @"C:\NTGlobal\Final\XFS\Dll\" + strScreen.Substring(i + 3, stopDisplay - i - 3);// .avi?
                            SK_Control.DisplayImageFileCommand.Add(new Photo(strPath, ii, jj));
                            i = stopDisplay + 1;
                        }
                        break;
                    case (char)0x0D:    // CR
                        ii++;
                        jj = leftMargin;
                        break;
                    case (char)0x0B:    // VT
                        break;
                    default:
                        {
                            if (ii >= 16)
                                break;

                            ScreenBox[jj, ii].character = ch;
                            ScreenBox[jj, ii].colorBCK = tempColorBCK;
                            ScreenBox[jj, ii].brText = tempBrText;
                            ScreenBox[jj, ii].font = font;
                            ScreenBox[jj, ii].size = size;

                            jj = jj + offset + 1;
                            if( jj >= 32 )
                            {
                                jj = 0;
                                ii = ii + offset + 1;
                            }
                            break;
                        }
                }

            }

            if( !showIdleScreen )
                return SK_Control;

            ScreenKey tempSK = SK_Control;
            for (int i = 0; i < SK_Control.ScreenIdle.Count; i++)
            {
                LoadCharScreen(SK_Control.ScreenIdle[i].text, false, "");
                Refresh();
                System.Threading.Thread.Sleep(tempSK.ScreenIdle[i].idle/*30*/ * 10);
                SK_Control = tempSK;
            }

            return SK_Control;
        }
        //public
        public ScreenControl(int PosX, int PosY)
        {
            this.BackColor = System.Drawing.Color.Navy;
            this.Location = new System.Drawing.Point(PosX, PosY);
            this.Name = "panelVirtual";
            this.Size = new System.Drawing.Size(640, 480);
            this.Visible = true;
            this.Paint += new System.Windows.Forms.PaintEventHandler(this.DrawScreenControl);

            ScreenKey SK_Control = new ScreenKey();

            // init Box
            Point P1 = new Point(0, 0);
            Point P2 = new Point(20, 30);
            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 32; j++)
                {
                    ScreenBox[j, i] = new BoxScreenControl(P1, P2);
                    P1.X += 20;
                    P2.X += 20;
                }
                P1.X = 0;
                P2.X = 20;
                P1.Y += 30;
                P2.Y += 30;
            }
        }
        public ScreenKey LoadCharScreen(string strScreen, bool showIdleScreen, string numar)   // incarca aria screen-ului cu caractere
        {
            SK_Control       = new ScreenKey();
            SK_Control.numar = numar;
            SK_Control.text  = strScreen;

            int ii     = 0;
            int jj     = 0;
            int offset = 0; // caractere pe lungime dubla

            string font           = BoxScreenControl.NDCFONTS[0];
            float  size           = BoxScreenControl.SIZEFONTS[0];
            Color  tempColorBCK   = Color.Navy;
            Brush  tempBrText     = Brushes.Yellow;
            Brush  lastTempBrText = Brushes.Yellow;

            // initial value
            int leftMargin = 0;

            ii = 0;
            jj = 0;
            //ClearScreenBox(0, 0);

            for (int i = 0; i < strScreen.Length; i++)
            {
                char ch = strScreen[i];
                switch (ch)
                {
                case (char)0x0C:        // FF
                    ii = 0;
                    jj = 0;
                    ClearScreenBox(0, 0);
                    tempColorBCK = Color.Navy;
                    tempBrText   = Brushes.Yellow;
                    font         = BoxScreenControl.NDCFONTS[0];
                    size         = BoxScreenControl.SIZEFONTS[0];
                    offset       = 0;
                    break;

                case (char)0x0E:        // SO
                    if (strScreen.Length <= i + 3)
                    {
                        return(null);
                    }
                    ScreenKey temp = ScreenKey.GetScreenKey(strScreen.Substring(i + 1, ScreenKey.NrOfCharScreenNumber));

                    if (temp != null)
                    {
                        i += ScreenKey.NrOfCharScreenNumber;
                        // temp este un idle screen
                        if (strScreen.Length > i + 6 && strScreen[i + 1] == (char)0x1B && strScreen[i + 2] == '[' && strScreen[i + 6] == 'z')
                        {
                            temp.idle = Convert.ToInt16(strScreen.Substring(i + 3, 3));
                            SK_Control.ScreenIdle.Add(temp);
                            i += 6;
                        }
                        else
                        {
                            i        -= ScreenKey.NrOfCharScreenNumber;
                            strScreen = strScreen.Remove(i, ScreenKey.NrOfCharScreenNumber + 1);
                            strScreen = strScreen.Insert(i, temp.text);
                            SK_Control.SubScreen.Add(temp);
                            i--;
                        }
                    }
                    //‘G00’ – standard Insert Card picture
                    //‘G01’ – standard Press Key picture
                    //‘G03’ – standard Make A Deposit picture
                    //‘G04’ – standard Take Receipt picture
                    //‘G05’ – standard Take Money picture
                    //‘G06’ – standard Take Statement picture.
                    else if (strScreen[i + 1] == 'G')    // G – Graphic Pictures
                    {
                        string strPath = @"C:\NTGlobal\Final\XFS\Dll\" + strScreen.Substring(i + 1, 3) + ".pcx";
                        SK_Control.GraphicPictures.Add(new Photo(strPath, ii, jj));
                        i += 3;
                    }
                    break;

                case (char)0x0F:        // SI
                    if (i + 2 < strScreen.Length)
                    {
                        int tempii = GetPos(strScreen[i + 1]);
                        if (tempii < 0)
                        {
                            break;
                        }
                        int tempjj = GetPos(strScreen[i + 2]);
                        if (tempjj < 0)
                        {
                            break;
                        }
                        ii = tempii;
                        jj = tempjj;
                        i  = i + 2;
                    }
                    break;

                case (char)0x09:        // HT
                    // Causes the name encoded on Track 1 of the card to be displayed, starting at the current cursor position (32 characters maximum). Both ISO and VISA display formats are supported.
                    // tab?
                    break;

                case (char)0x11:        // DC1
                    break;

                case (char)0x12:        // DC2
                    break;

                case (char)0x1B:        // ESC
                    // Digital Audio Control Sequence
                    #region Digital Audio Control Sequence
                    if (strScreen.Length > i + 8 && strScreen[i + 1] == 'P' && strScreen[i + 2] == '0')
                    {
                        string terminatorVoice = "" + ((char)0x1B).ToString() + ('\\').ToString();
                        int    stopVoice       = strScreen.IndexOf(terminatorVoice, i + 1);
                        char   id            = strScreen[i + 2];
                        string messageNumber = strScreen.Substring(i + 3, stopVoice - i - 5);
                        char   nr            = strScreen[stopVoice - 1];
                        SK_Control.VoiceList.Add(new Voice(id, messageNumber, nr));
                        i = stopVoice + 1;
                    }
                    #endregion
                    #region Screen blinking and colour control
                    // Screen blinking and colour control
                    else if (strScreen.Length > i + 7 && strScreen[i + 4] == ';' && strScreen[i + 1] == '[')
                    {
                        string color = strScreen.Substring(i + 2, 2);
                        // background color
                        if (color == "30" || color == "C0")
                        {
                            tempColorBCK = Color.Black;
                        }
                        else if (color == "31" || color == "C1")
                        {
                            tempColorBCK = Color.Red;
                        }
                        else if (color == "C2" || color == "32")
                        {
                            tempColorBCK = Color.Green;
                        }
                        else if (color == "C3" || color == "33")
                        {
                            tempColorBCK = Color.Yellow;
                        }
                        else if (color == "34" || color == "C4")
                        {
                            tempColorBCK = Color.Blue;
                        }
                        else if (color == "35" || color == "C5")
                        {
                            tempColorBCK = Color.Magenta;
                        }
                        else if (color == "36" || color == "C6")
                        {
                            tempColorBCK = Color.Cyan;
                        }
                        else if (color == "C7" || color == "37")
                        {
                            tempColorBCK = Color.White;
                        }
                        else if (color == "80")
                        {
                            tempColorBCK = Color.Transparent;
                        }
                        // text color
                        else if (color == "20" || color == "BO")
                        {
                            tempBrText = Brushes.Black;
                        }
                        else if (color == "21" || color == "B1")
                        {
                            tempBrText = Brushes.Red;
                        }
                        else if (color == "B2" || color == "22")
                        {
                            tempBrText = Brushes.Green;
                        }
                        else if (color == "B3" || color == "23")
                        {
                            tempBrText = Brushes.Yellow;
                        }
                        else if (color == "24" || color == "B4")
                        {
                            tempBrText = Brushes.Blue;
                        }
                        else if (color == "25" || color == "B5")
                        {
                            tempBrText = Brushes.Magenta;
                        }
                        else if (color == "26" || color == "B6")
                        {
                            tempBrText = Brushes.Cyan;
                        }
                        else if (color == "B7" || color == "27")
                        {
                            tempBrText = Brushes.White;
                        }
                        // blink
                        else if (color == "10")
                        {
                            lastTempBrText = tempBrText;
                            tempBrText     = Brushes.Violet;
                        }
                        else if (color == "11")
                        {
                            tempBrText = lastTempBrText;
                        }
                        else if (color == "00")
                        {
                            tempBrText = lastTempBrText;
                        }

                        i += 7;
                    }
                    // Screen blinking and colour control
                    else if (strScreen.Length > i + 5 && strScreen[i + 4] == 'm' && strScreen[i + 1] == '[')
                    {
                        string color = strScreen.Substring(i + 2, 2);
                        // background color
                        if (color == "30" || color == "C0")
                        {
                            tempColorBCK = Color.Black;
                        }
                        else if (color == "31" || color == "C1")
                        {
                            tempColorBCK = Color.Red;
                        }
                        else if (color == "C2" || color == "32")
                        {
                            tempColorBCK = Color.Green;
                        }
                        else if (color == "C3" || color == "33")
                        {
                            tempColorBCK = Color.Yellow;
                        }
                        else if (color == "34" || color == "C4")
                        {
                            tempColorBCK = Color.Blue;
                        }
                        else if (color == "35" || color == "C5")
                        {
                            tempColorBCK = Color.Magenta;
                        }
                        else if (color == "36" || color == "C6")
                        {
                            tempColorBCK = Color.Cyan;
                        }
                        else if (color == "C7" || color == "37")
                        {
                            tempColorBCK = Color.White;
                        }
                        else if (color == "80")
                        {
                            tempColorBCK = Color.Transparent;
                        }
                        // text color
                        else if (color == "20" || color == "BO")
                        {
                            tempBrText = Brushes.Black;
                        }
                        else if (color == "21" || color == "B1")
                        {
                            tempBrText = Brushes.Red;
                        }
                        else if (color == "B2" || color == "22")
                        {
                            tempBrText = Brushes.Green;
                        }
                        else if (color == "B3" || color == "23")
                        {
                            tempBrText = Brushes.Yellow;
                        }
                        else if (color == "24" || color == "B4")
                        {
                            tempBrText = Brushes.Blue;
                        }
                        else if (color == "25" || color == "B5")
                        {
                            tempBrText = Brushes.Magenta;
                        }
                        else if (color == "26" || color == "B6")
                        {
                            tempBrText = Brushes.Cyan;
                        }
                        else if (color == "B7" || color == "27")
                        {
                            tempBrText = Brushes.White;
                        }
                        // blink
                        else if (color == "10")
                        {
                            lastTempBrText = tempBrText;
                            tempBrText     = Brushes.Violet;
                        }
                        else if (color == "11")
                        {
                            tempBrText = lastTempBrText;
                        }
                        else if (color == "00")
                        {
                            tempBrText = lastTempBrText;
                        }

                        i += 4;
                    }
                    #endregion
                    // Changing display in idle
                    else if (strScreen.Length > i + 6 && strScreen[i + 5] == 'z' && strScreen[i + 1] == '[')
                    {
                        int delayTime = Convert.ToInt16(strScreen.Substring(i + 2, 3));
                        i += 5;
                    }
                    #region Character set 1
                    // select character set - 1
                    else if (strScreen.Length > i + 2 && strScreen[i + 1] == '(')
                    {
                        switch (strScreen[i + 2])
                        {
                        case '1':
                            offset = 0;
                            font   = BoxScreenControl.NDCFONTS[0];
                            size   = BoxScreenControl.SIZEFONTS[0];
                            break;

                        case '2':
                            offset = 0;
                            font   = BoxScreenControl.NDCFONTS[1];
                            size   = BoxScreenControl.SIZEFONTS[0];
                            break;

                        case '3':
                            offset = 0;
                            font   = BoxScreenControl.NDCFONTS[2];
                            size   = BoxScreenControl.SIZEFONTS[0];
                            break;

                        case '4':
                            offset = 0;
                            font   = BoxScreenControl.NDCFONTS[3];
                            size   = BoxScreenControl.SIZEFONTS[0];
                            break;

                        case '5':
                            offset = 0;
                            font   = BoxScreenControl.NDCFONTS[4];
                            size   = BoxScreenControl.SIZEFONTS[0];
                            break;

                        case '>':
                            offset = 1;
                            size   = BoxScreenControl.SIZEFONTS[1];
                            font   = BoxScreenControl.NDCFONTS[5];
                            break;

                        case '?':
                            offset = 1;
                            size   = BoxScreenControl.SIZEFONTS[1];
                            font   = BoxScreenControl.NDCFONTS[6];
                            break;

                        case '7':
                            offset = 0;
                            size   = BoxScreenControl.SIZEFONTS[0];
                            font   = BoxScreenControl.NDCFONTS[7];
                            break;

                        case ':':
                            offset = 0;
                            size   = BoxScreenControl.SIZEFONTS[0];
                            font   = BoxScreenControl.NDCFONTS[8];
                            break;

                        case ';':
                            offset = 0;
                            size   = BoxScreenControl.SIZEFONTS[0];
                            font   = BoxScreenControl.NDCFONTS[9];
                            break;

                        case 'B':
                            offset = 1;
                            size   = BoxScreenControl.SIZEFONTS[1];
                            font   = BoxScreenControl.NDCFONTS[10];
                            break;
                        }
                        i = i + 2;
                    }
                    #endregion
                    #region Character set 2
                    // select character set - 2
                    else if (strScreen.Length > i + 2 && strScreen[i + 1] == ')')
                    {
                        switch (strScreen[i + 2])
                        {
                        case '1':
                            offset = 0;
                            font   = BoxScreenControl.NDCFONTS[0];
                            size   = BoxScreenControl.SIZEFONTS[0];
                            break;

                        case '2':
                            offset = 0;
                            font   = BoxScreenControl.NDCFONTS[1];
                            size   = BoxScreenControl.SIZEFONTS[0];
                            break;

                        case '3':
                            offset = 0;
                            font   = BoxScreenControl.NDCFONTS[2];
                            size   = BoxScreenControl.SIZEFONTS[0];
                            break;

                        case '4':
                            offset = 0;
                            font   = BoxScreenControl.NDCFONTS[3];
                            size   = BoxScreenControl.SIZEFONTS[0];
                            break;

                        case '5':
                            offset = 0;
                            font   = BoxScreenControl.NDCFONTS[4];
                            size   = BoxScreenControl.SIZEFONTS[0];
                            break;

                        case '>':
                            offset = 1;
                            size   = BoxScreenControl.SIZEFONTS[1];
                            font   = BoxScreenControl.NDCFONTS[5];
                            break;

                        case '?':
                            offset = 1;
                            size   = BoxScreenControl.SIZEFONTS[1];
                            font   = BoxScreenControl.NDCFONTS[6];
                            break;

                        case '7':
                            offset = 0;
                            size   = BoxScreenControl.SIZEFONTS[0];
                            font   = BoxScreenControl.NDCFONTS[7];
                            break;

                        case ':':
                            offset = 0;
                            size   = BoxScreenControl.SIZEFONTS[0];
                            font   = BoxScreenControl.NDCFONTS[8];
                            break;

                        case ';':
                            offset = 0;
                            size   = BoxScreenControl.SIZEFONTS[0];
                            font   = BoxScreenControl.NDCFONTS[9];
                            break;

                        case 'B':
                            offset = 1;
                            size   = BoxScreenControl.SIZEFONTS[1];
                            font   = BoxScreenControl.NDCFONTS[10];
                            break;
                        }
                        i = i + 2;
                    }
                    #endregion
                    // Set Left Margin Position
                    else if (strScreen.Length > i + 5 && strScreen[i + 1] == '[' && strScreen[i + 5] == 'P')
                    {
                        leftMargin = Convert.ToInt32(strScreen.Substring(i + 2, 2));
                        i          = i + 5;
                    }
                    // select logo
                    else if (strScreen.Length > i + 5 && strScreen[i + 1] == 'P' && strScreen[i + 2] == '1')
                    {
                        string strPath = @"C:\NTGlobal\Final\XFS\Dll\pic00" + strScreen.Substring(i + 3, 2) + ".pcx";
                        SK_Control.Logo.Add(new Photo(strPath, ii, jj));
                        i += 5;
                    }
                    // Picture Control Command
                    else if (strScreen.Length > i + 5 && strScreen[i + 1] == 'P' && strScreen[i + 2] == '2')
                    {
                        string terminatorPicture = "" + ((char)0x1B).ToString() + ('\\').ToString();
                        int    stopPicture       = strScreen.IndexOf(terminatorPicture, i + 1);
                        string strPath           = @"C:\NTGlobal\Final\XFS\Dll\pic00" + strScreen.Substring(i + 3, stopPicture - i - 3) + ".pcx";
                        SK_Control.Picture.Add(new Photo(strPath, ii, jj));
                        i = stopPicture + 1;
                    }
                    //
                    else if (strScreen.Length > i + 2 && strScreen[i + 1] == 'P' && strScreen[i + 2] == 'i')     // not suported
                    {
                        string terminator = "" + ((char)0x1B).ToString() + ('\\').ToString();
                        int    stop       = strScreen.IndexOf(terminator, i + 1);
                        i = stop + 1;    // +1;
                    }
                    // Display Image File Command
                    else if (strScreen.Length > i + 5 && strScreen[i + 1] == 'P' && strScreen[i + 2] == 'E')
                    {
                        string terminatorDisplay = "" + ((char)0x1B).ToString() + ('\\').ToString();
                        int    stopDisplay       = strScreen.IndexOf(terminatorDisplay, i + 1);
                        string strPath           = @"C:\NTGlobal\Final\XFS\Dll" + strScreen.Substring(i + 3, stopDisplay - i - 3);// .avi?
                        SK_Control.DisplayImageFileCommand.Add(new Photo(strPath, ii, jj));
                        i = stopDisplay + 1;
                    }
                    // Display Lifted Cheque Image Command
                    else if (strScreen.Length > i + 5 && strScreen[i + 1] == 'P' && strScreen[i + 2] == 'E')
                    {
                        // not implement
                        string terminatorDisplay = "" + ((char)0x1B).ToString() + ('\\').ToString();
                        int    stopDisplay       = strScreen.IndexOf(terminatorDisplay, i + 1);
                        string strPath           = @"C:\NTGlobal\Final\XFS\Dll\" + strScreen.Substring(i + 3, stopDisplay - i - 3);// .avi?
                        SK_Control.DisplayImageFileCommand.Add(new Photo(strPath, ii, jj));
                        i = stopDisplay + 1;
                    }
                    break;

                case (char)0x0D:        // CR
                    ii++;
                    jj = leftMargin;
                    break;

                case (char)0x0B:        // VT
                    break;

                default:
                {
                    if (ii >= 16)
                    {
                        break;
                    }

                    ScreenBox[jj, ii].character = ch;
                    ScreenBox[jj, ii].colorBCK  = tempColorBCK;
                    ScreenBox[jj, ii].brText    = tempBrText;
                    ScreenBox[jj, ii].font      = font;
                    ScreenBox[jj, ii].size      = size;

                    jj = jj + offset + 1;
                    if (jj >= 32)
                    {
                        jj = 0;
                        ii = ii + offset + 1;
                    }
                    break;
                }
                }
            }

            if (!showIdleScreen)
            {
                return(SK_Control);
            }

            ScreenKey tempSK = SK_Control;
            for (int i = 0; i < SK_Control.ScreenIdle.Count; i++)
            {
                LoadCharScreen(SK_Control.ScreenIdle[i].text, false, "");
                Refresh();
                System.Threading.Thread.Sleep(tempSK.ScreenIdle[i].idle /*30*/ * 10);
                SK_Control = tempSK;
            }

            return(SK_Control);
        }
Beispiel #10
0
        private void listBoxScreenKeyboard_SelectedIndexChanged(object sender, EventArgs e)
        {
            SC.ClearScreenBox(0, 0);
            labelFF.Visible = true;

            SC.ScreenBox[0, 0] = new BoxScreenControl(new Point(0, 0), new Point(20, 30), 'N');
            string numarScreen = listBoxScreenKeyboard.Items[listBoxScreenKeyboard.SelectedIndex].ToString();
            textBoxScreen.Text = ScreenKey.GetScreenKey(numarScreen).text;
            SK = SC.LoadCharScreen(textBoxScreen.Text, false, ScreenKey.GetScreenKey(numarScreen).numar);
            SC.Visible = true;
            SC.Refresh();
            textBoxScreenView.Text = SK.numar;

            if ( textBoxScreen.Text.Contains(((char)0x0C).ToString()) )
                labelFF.Visible = false;
            labelVoice.Text = "Voices : " + SK.VoiceList.Count.ToString();
            labelGraphic.Text = "Graphics : " + SK.GraphicPictures.Count.ToString();
            labelPicture.Text = "Pictures : " + SK.Picture.Count.ToString();
            labelLogo.Text = "Logos : " + SK.Logo.Count.ToString();
            labelDisplayImageFile.Text = "Display Image Files : " + SK.DisplayImageFileCommand.Count.ToString();
            // idle screen
            labelIdleScreen.Text = "Idle screens : " + SK.ScreenIdle.Count.ToString();
            comboBoxIdleScreen.Items.Clear();
            comboBoxIdleScreen.Text = "";
            for (int i = 0; i < SK.ScreenIdle.Count; i++)
                comboBoxIdleScreen.Items.Add( SK.ScreenIdle[i].numar );

            // subscreen
            labelSubscreen.Text = "Subscreens : " + SK.SubScreen.Count.ToString();
            comboBoxSubscreen.Items.Clear();
            comboBoxSubscreen.Text = "";
            for (int i = 0; i < SK.SubScreen.Count; i++)
                comboBoxSubscreen.Items.Add(SK.SubScreen[i].numar);
        }