Пример #1
0
        public void Button_Click(RVIClientContext context)
        {
            string          connString = "Server=192.168.2.111; Port=3306; Database=IEN; Uid=remoteUser; Pwd=12342580;";
            MySqlConnection connection = new MySqlConnection(connString);

            connection.Open();
            MySqlCommand    command = new MySqlCommand("SELECT * FROM test", connection);
            MySqlDataReader reader  = command.ExecuteReader();
            DataTable       table   = new DataTable();

            table.Load(reader);
            connection.Close();

            List <string> instructions = new List <string>()
            {
                RVIInstructions.DisableClickableRect("button"),         // Disable button
                RVIInstructions.DeleteFrame("button"),                  // Delete button frame
                RVIInstructions.Delay(20),                              // Delay server for 20ms
                RVIInstructions.SetFrame("resultFrame")                 // Set the frame for the result
            };

            int tableCountH = table.Columns.Count;
            int tableCountV = table.Rows.Count + 1;

            List <string> headers = new List <string>();
            List <string> cells   = new List <string>();


            foreach (DataColumn col in table.Columns)
            {
                headers.Add(col.ColumnName);
            }

            foreach (DataRow row in table.Rows)
            {
                foreach (object o in row.ItemArray)
                {
                    cells.Add(o.ToString());
                }
            }

            string finalString = "";

            foreach (string c in cells)
            {
                finalString += c + "·";
            }
            // Create scaled-borderless table with the headers, and a scaled only one with the cell contents
            instructions.Add(RVIInstructions.TableArraySB(new RVIVector2(0, 0.4f + 0.05f), 1f / tableCountH, 0.05f, (byte)tableCountH, (byte)tableCountV, 0.03f, headers.ToArray()));
            instructions.Add(RVIInstructions.TableArrayS(new RVIVector2(0, 0.4f), 1f / tableCountH, 0.02f, (byte)tableCountH, (byte)tableCountV, 0.01f, cells.ToArray()));
            instructions.Add(RVIInstructions.ReleaseFrame("resultFrame"));
            context.Run(instructions);
        }
Пример #2
0
        // Creates a borderless rectangle with text inside. The text size and lining are manually provided.
        public static List <byte[]> TextBoxSB(string[] args, long cKey)
        {
            List <byte[]> result = new List <byte[]>();

            RVIVector2 pos       = RVIVector2.Parse(args[0]);
            float      w         = float.Parse(args[1], CultureInfo.InvariantCulture);
            float      h         = float.Parse(args[2], CultureInfo.InvariantCulture);
            float      charScale = float.Parse(args[3], CultureInfo.InvariantCulture);
            string     text      = args[4];

            RVIVector2 arraypos = new RVIVector2(pos.x + (charScale / 2), pos.y + charScale / 2);

            result.AddRange(GetBytes(RVIInstructions.ArrayChar(arraypos, charScale, text), cKey));

            return(result);
        }
Пример #3
0
        // Creates a filled, borderless table. The text size and lining are manually provided.
        public static List <byte[]> TableArraySB(string[] args, long cKey)
        {
            List <byte[]> result = new List <byte[]>();

            if (!RVIDefinitions.Initialized)
            {
                RVIDefinitions.Initialize();
            }

            RVIVector2 pos       = RVIVector2.Parse(args[0]);
            float      width     = float.Parse(args[1], CultureInfo.InvariantCulture);
            float      height    = float.Parse(args[2], CultureInfo.InvariantCulture);
            byte       hCount    = byte.Parse(args[3], CultureInfo.InvariantCulture);
            byte       vCount    = byte.Parse(args[4], CultureInfo.InvariantCulture);
            float      charScale = float.Parse(args[5], CultureInfo.InvariantCulture);

            string[] contents = args[6].Split('·');

            float currentY = pos.y - charScale / 2;

            for (int v = 0; v < vCount; v++)
            {
                float currentX = pos.x;
                for (int h = 0; h < hCount; h++)
                {
                    int contentIndex = (v * hCount) + h;
                    if (contentIndex > contents.Length - 1)
                    {
                        return(result);
                    }

                    string instruct = RVIInstructions.TextBoxSB(new RVIVector2(currentX, currentY), width, height, charScale, contents[contentIndex]);
                    result.AddRange(GetBytes(instruct, cKey));

                    currentX += width;
                }
                currentY -= height;
            }

            return(result);
        }
Пример #4
0
        // Creates a borderless rectangle with text inside.. The text font size and lines of the text are automatically adjusted to the textbox area.
        public static List <byte[]> TextBoxB(string[] args, long cKey)
        {
            List <byte[]> result = new List <byte[]>();

            RVIVector2 pos  = RVIVector2.Parse(args[0]);
            float      w    = float.Parse(args[1], CultureInfo.InvariantCulture);
            float      h    = float.Parse(args[2], CultureInfo.InvariantCulture);
            string     text = args[3];

            float         charScale = 1;
            const int     CharactersPerLineThreshold = 28;
            bool          newLine        = false;
            List <string> lines          = new List <string>();
            string        currentLine    = "";
            int           currentCounter = 0;

            for (int i = 0; i < text.Length; i++)
            {
                currentCounter++;
                if (currentCounter % CharactersPerLineThreshold == 0 && currentCounter != 0)
                {
                    newLine = true;
                }
                if (text[i] == '·' && newLine)
                {
                    lines.Add(currentLine);
                    currentLine    = "";
                    newLine        = false;
                    currentCounter = 0;
                }
                else
                {
                    currentLine += text[i];
                }
            }
            lines.Add(currentLine);

            charScale = w / ((lines.Max(o => o.Length)) + 1);

            text = "";
            foreach (string line in lines)
            {
                text += line + "¬";
            }

            if (charScale >= h / 1.5f)
            {
                charScale = h / 1.5f;
            }

            RVIVector2 arraypos = new RVIVector2(pos.x + (charScale / 2), pos.y + h - charScale * 2);

            if (lines.Count == 1)
            {
                arraypos.y = pos.y + h / 2 - charScale / 2;
            }

            result.AddRange(GetBytes(RVIInstructions.ArrayChar(arraypos, charScale, text), cKey));

            return(result);
        }