Esempio n. 1
0
        public CLabel CreateStarLabel(string keyname, int posX, int posY, int width, int height, string text,
                                      int fontSize, FontStyle fontStyle,
                                      Color fontColor, Color backColor, bool isVisible)
        {
            var newItem = new CLabel(posX, posY, width, height, text,
                                     "Wingdings", 9, FontStyle.Regular, fontColor, backColor, TextAlign.Center, true);

            newItem.KeyName = keyname;
            newItem.Visible = isVisible;
            labels.Add(newItem);
            return(newItem);
        }
Esempio n. 2
0
        //public void SetWindowPos(IntPtr handle, bool topMost)
        //{
        //    const int HWND_TOPMOST = -1;
        //    const int HWND_NOTOPMOST = -2;
        //    const int SWP_SHOWWINDOW = 0x0040;
        //    const int SWP_HIDEWINDOW = 0x0080;
        //    const int SWP_NOREDRAW = 0x0008;

        //    if (topMost)
        //        SetWindowPos(handle, new IntPtr(HWND_TOPMOST), 0, 0, screenResX, screenResY, SWP_SHOWWINDOW);
        //    else
        //        SetWindowPos(handle, new IntPtr(HWND_NOTOPMOST), 0, 0, screenResX, screenResY, SWP_NOREDRAW);
        //}

        public void  CreateScreenSaver(int width, int height, Color titleFontColor, Color backColor, string fontName, int fontSize, FontStyle fontStyle)
        {
            screenSaverSize      = Utils.ScaleDimension(width, height, screenResX - (int)(100 * ratioX), screenResY - (int)(150 * ratioY));
            screenSaverX         = (screenResX - screenSaverSize.Width) / 2 - 1;
            screenSaverY         = (((screenResY - (int)(150 * ratioY)) - screenSaverSize.Height) / 2) + (int)(50 * ratioY) - 1;
            screenSaverFontColor = titleFontColor;
            screenSaverBackcolor = backColor;
            screenSaverTitle     = new CLabel(0, screenResY - (int)(100 * ratioY), screenResX, (int)(50 * ratioY), "",
                                              fontName, fontSize, fontStyle, screenSaverFontColor, screenSaverBackcolor,
                                              TextAlign.Center, false);
            CreateArrow();
        }
Esempio n. 3
0
        public CTicker CreateTicker(string keyname, int posX, int posY, int width, int height, string fontName, int fontSize,
                                    FontStyle fontStyle, Color fontColor, Color backColor, bool isVisible, bool isFocusable)
        {
            var newItem = new CTicker(posX, posY, width, height, fontName, fontSize, fontStyle, fontColor, backColor, isFocusable);

            newItem.KeyName = keyname;
            newItem.Visible = isVisible;
            if (keyname != "FnetMessage")
            {
                labels.Add(newItem);
            }
            else
            {
                fnetMessage = newItem;
            }

            return(newItem);
        }
Esempio n. 4
0
        public void ShowMenu(List <List <string> > menuCols, string titleText, string statusbarText, string currentMenu,
                             string additionalData, string additionalInfo, bool menuChanged, string preselectedMenuKey, bool isWindowTextReader,
                             string snapshotPath, string iconPath, bool showSideBar)
        {
            _currentMenu          = currentMenu;
            _additionalData       = additionalData;
            _additionalInfo       = additionalInfo;
            _menuStrings          = menuCols;
            menuColumnCount       = menuCols.Count;
            _isMenuTextReader     = isWindowTextReader;
            _snapshotPath         = snapshotPath != string.Empty ? snapshotPath + (snapshotPath[snapshotPath.Length - 1] != '\\' ? "\\" : string.Empty) : string.Empty;
            _iconPath             = iconPath;
            _showSideBar          = showSideBar;
            Width                 = menu_min_width;
            menu_first_item_shown = 0;

            var currentCol = 0;
            var indent     = menuCols.Count == 1 ? "      " : string.Empty;

            _menuItems.Clear();
            _titlebar = _statusbar = null;

            // create titlebar
            if (titleText != string.Empty)
            {
                _titlebar = new CLabel(0, 0,
                                       Width, (int)(menu_item_height * 1.2),
                                       titleText,
                                       menu_font_name, menu_font_size + 1, menu_font_style,
                                       menu_selected_font_color, menu_selected_backcolor, TextAlign.Left,
                                       false);
                _titlebar.BorderColor = menu_font_color;
            }

            // additional info
            _additionalInfoLayout             = BuildTable(additionalInfo, TextAlign.Left, 0);
            _additionalInfoLayout.PaddingLeft = 10;

            var itemWidth = Width;
            var yCounter  = 0;

            foreach (var menuRows in menuCols)
            {
                // on first column, decide menu size
                if (currentCol == 0)
                {
                    var maxWidth = Width;
                    foreach (var menuRow in menuRows)
                    {
                        var text = menuRow.Split('|').Length < 3 ? indent + menuRow.Split('|')[1] + indent : menuRow.Split('|')[1];
                        maxWidth = Math.Max(maxWidth, (int)menu_sprite_font.MeasureString(Utils.StringCleanup(text)).X + 8);
                    }
                    itemWidth = (int)Math.Min(maxWidth,
                                              _showSideBar && _currentMenu != "show_game_info" ? screenResX / 1.2 : screenResX - screenResX / 64) / menuColumnCount;
                }

                for (yCounter = 0; yCounter < menuRows.Count; yCounter++)
                {
                    var menuRow = menuRows[yCounter];
                    var arr     = menuRow.Split('|');
                    if (arr[1].StartsWith(("*#*T")))
                    {
                        // process table
                        var alignChar   = arr[1].Substring("*#*T".Length, 1);
                        var textAlign   = alignChar == "L" ? TextAlign.Left : alignChar == "C" ? TextAlign.Center : TextAlign.Right;
                        var tableString = string.Empty;
                        for (; yCounter < menuRows.Count; yCounter++)
                        {
                            var tableRow  = menuRows[yCounter].Split('|');
                            var rowString = menuRows[yCounter].Replace("*#*TL*#*", string.Empty).
                                            Replace("*#*TC*#*", string.Empty).
                                            Replace("*#*TR*#*", string.Empty).
                                            Replace("*#*/T*#*", string.Empty);
                            tableString += rowString + "\n";
                            if (tableRow[1].Contains("*#*/T*#*"))
                            {
                                break;
                            }
                        }
                        // remove last \n
                        tableString = tableString.Substring(0, tableString.Length - 1);

                        // inject table in menu
                        _menuItems.AddRange(BuildTable(tableString, textAlign, itemWidth).Items);
                    }
                    else
                    {
                        // process item
                        var lbl = new CLabel(0, 0,
                                             itemWidth, menu_item_height,
                                             arr.Length < 3 ? indent + arr[1] + indent : arr[1],
                                             menu_font_name, menu_font_size, menu_font_style,
                                             menu_font_color, Color.TransparentWhite,
                                             TextAlign.Left,
                                             arr.Length < 3 ? true : false);
                        lbl.KeyName   = arr[0];
                        lbl.Scrolling = false;
                        _menuItems.Add(lbl);
                    }
                }
                currentCol++;
            }
            menuRowsCount = yCounter;

            // create statusbar
            if (statusbarText != string.Empty)
            {
                _statusbar = new CLabel(0, 0,
                                        Width, (int)(menu_item_height * 0.9),
                                        statusbarText,
                                        menu_font_name, menu_font_size - 1, menu_font_style,
                                        menu_selected_font_color, menu_selected_backcolor, TextAlign.Right,
                                        false);
                _statusbar.BorderColor = menu_font_color;
            }

            _snapshotImage             = new CImage(string.Empty, screenResX / 4, screenResY / 4, null, false, true, true);
            _snapshotImage.BorderColor = menu_font_color;
            _previousSnapshotPath      = string.Empty;

            _iconImage        = new CImage(string.Empty, screenResX / 12, screenResX / 12, null, false, true, false);
            _previousIconPath = string.Empty;

            StartTransition(CDrawable.Transition.FadeIn, 0);
            SelectMenuItem(preselectedMenuKey, menuChanged);
        }
Esempio n. 5
0
        public CLayout BuildTable(string message, TextAlign textAlign, int tableWidth)
        {
            var tableLayout = new CLayout(0, 0, CLayout.Orientation.Vertical, false);

            // split lines
            var lines     = message.Split('\n');
            var lineCount = lines.Length;

            // get column count
            var columnCount = 0;

            for (var lineNo = 0; lineNo < lineCount; lineNo++)
            {
                columnCount = Math.Max(columnCount, lines[lineNo].Split('§').Length);
            }

            // define column widths
            var columnWidth = new int[columnCount];
            var totalWidth  = 0;

            for (var lineNo = 0; lineNo < lineCount; lineNo++)
            {
                var curLine = lines[lineNo];
                if (curLine.Contains("|"))
                {
                    curLine = curLine.Split('|')[1];
                }
                // skip empty lines
                if (string.IsNullOrEmpty(curLine))
                {
                    continue;
                }

                // split row in columns
                var line = curLine.Split('§');
                totalWidth = 0;
                for (var colNo = 0; colNo < line.Length; colNo++)
                {
                    // track column width if current row has no "colspan"
                    if (line.Length == columnCount)
                    {
                        columnWidth[colNo] = Math.Max(columnWidth[colNo],
                                                      (int)(menu_sprite_font.MeasureString(Utils.StringCleanup(line[colNo])).X + 8));
                        totalWidth += columnWidth[colNo];
                    }
                }
            }
            // if table width supplied, resize all columns
            if (tableWidth > 0 && totalWidth != tableWidth)
            {
                for (var colNo = 0; colNo < columnWidth.Length; colNo++)
                {
                    columnWidth[colNo] = (int)((float)columnWidth[colNo] / (float)totalWidth * (float)tableWidth);
                }
            }

            // find message width
            var messageWidth = 0;

            for (var i = 0; i < columnCount; i++)
            {
                messageWidth += columnWidth[i];
            }

            var messageHeight = lineCount * menu_item_height;

            for (var lineNo = 0; lineNo < lineCount; lineNo++)
            {
                var row     = new CLayout(0, 0, CLayout.Orientation.Horizontal, true);
                var curLine = lines[lineNo];
                if (curLine.Contains("|"))
                {
                    row.KeyName     = curLine.Split('|')[0];
                    row.IsFocusable = curLine.Split('|').Length < 3;
                    curLine         = curLine.Split('|')[1];
                }
                var line = curLine.Split('§');
                row.Width   = messageWidth;
                row.Gravity = LayoutGravity.Left;
                for (var colNo = 0; colNo < line.Length; colNo++)
                {
                    CLabel lbl;
                    lbl = new CLabel(0, 0,
                                     columnWidth[colNo], menu_item_height, line[colNo], menu_font_name,
                                     menu_font_size, menu_font_style, menu_font_color, Color.TransparentWhite, textAlign, false)
                    {
                        Scrolling = false
                    };
                    // first row is table header
                    //if (lineNo == 0)
                    //{
                    //    lbl = new CLabel(0, 0,
                    //                        columnWidth[colNo], (int)(menu_item_height * 1), line[colNo], menu_font_name,
                    //                        menu_font_size + 1, menu_font_style, menu_selected_font_color, menu_selected_backcolor, textAlign, false);
                    //    lbl.BackColor = menu_selected_backcolor;
                    //    lbl.BorderColor = menu_font_color;
                    //}
                    //else
                    //    lbl = new CLabel(0, 0,
                    //                        columnWidth[colNo], menu_item_height, line[colNo], menu_font_name,
                    //                        menu_font_size, menu_font_style, menu_font_color, Color.TransparentWhite, textAlign, false);
                    row.AddItem(lbl);
                }
                tableLayout.AddItem(row);
            }
            tableLayout.Update();
            return(tableLayout);
        }
Esempio n. 6
0
        public int ShowMessage(string message, TextAlign textAlign, int previousMessageHeight, int maxRows)
        {
            // split lines
            var lines     = message.Split('\n');
            var lineCount = Math.Min(lines.Length, maxRows);

            // get column count
            var columnCount = 0;

            for (var lineNo = 0; lineNo < lineCount; lineNo++)
            {
                columnCount = Math.Max(columnCount, lines[lineNo].Split('§').Length);
            }

            // define column widths
            var columnWidth = new int[columnCount];

            for (var lineNo = 0; lineNo < lineCount; lineNo++)
            {
                // skip empty lines
                if (string.IsNullOrEmpty(lines[lineNo]))
                {
                    continue;
                }

                // split row in columns
                var line = lines[lineNo].Split('§');
                for (var colNo = 0; colNo < line.Length; colNo++)
                {
                    // track column width if current row has no "colspan"
                    if (line.Length == columnCount)
                    {
                        columnWidth[colNo] = Math.Max(columnWidth[colNo],
                                                      (int)(menu_sprite_font.MeasureString(Utils.StringCleanup(line[colNo])).X *(lineNo == 0 ? 1.2 : 1) + 8));
                    }
                }
            }

            // find message width
            var messageWidth = 0;

            for (var i = 0; i < columnCount; i++)
            {
                messageWidth += columnWidth[i];
            }

            var messageHeight = lineCount * menu_item_height;

            if (previousMessageHeight == 0)
            {
                // first message: clear
                messageItems.Clear();
            }
            else
            {
                // appended message: re-position previous message
                foreach (var item in messageItems)
                {
                    item.Y -= ((messageHeight + (menu_item_height / 2)) / 2);
                }
            }

            var lblX = (screenResX - messageWidth) / 2;
            var lblY = (previousMessageHeight / 2) + (screenResY - messageHeight + (menu_item_height / 2)) / 2;

            var column = new CLayout(lblX, lblY, CLayout.Orientation.Vertical, true);

            for (var lineNo = 0; lineNo < lineCount; lineNo++)
            {
                if (!string.IsNullOrEmpty(lines[lineNo]))
                {
                    var line = lines[lineNo].Split('§');
                    var row  = new CLayout(lblX, lblY, CLayout.Orientation.Horizontal, true);
                    row.Width = messageWidth;
                    for (var colNo = 0; colNo < line.Length; colNo++)
                    {
                        CLabel lbl;
                        // first row is table header
                        if (lineNo == 0)
                        {
                            lbl = new CLabel(0, 0,
                                             columnWidth[colNo], (int)(menu_item_height * 1.2), line[colNo], menu_font_name,
                                             menu_font_size + 1, menu_font_style, menu_selected_font_color, menu_selected_backcolor, textAlign, false);
                            lbl.BorderColor = menu_font_color;
                        }
                        else
                        {
                            lbl = new CLabel(0, 0,
                                             columnWidth[colNo], menu_item_height, line[colNo], menu_font_name,
                                             menu_font_size, menu_font_style, menu_font_color, menu_backcolor, textAlign, false);
                        }
                        lbl.FillParent = line.Length != columnCount;
                        row.AddItem(lbl);
                    }
                    lblY += row.Height;
                    column.AddItem(row);
                }
            }
            messageItems.Add(column);
            column.Update();

            _showMessage = true;
            return(messageHeight);
        }