Exemplo n.º 1
0
        //private Dictionary<String, int> parseText(String text, int width)
        //{
        //    String line = String.Empty;
        //    String returnString = String.Empty;
        //    //String[] wordArray = text.Split(' ');
        //    //count records how many rows it has.
        //    int count = 1;
        //    Dictionary<String, int> result = new Dictionary<String, int>();
        //    for (int i = 0; i < text.Length; i++)
        //    {
        //        char word = text[i];
        //        if (ResourceManager.font_.MeasureString(line + word).X > width)
        //        {
        //            int tempAddwidth = 0;
        //            while (i < text.Length && text[i] != ' ' && ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z')))
        //            {
        //                word = text[i];
        //                line = line + word;
        //                tempAddwidth += (int)ResourceManager.font_.MeasureString(word.ToString()).X;
        //                i++;
        //            }
        //            if (tempAddwidth > addwidth)
        //                addwidth = tempAddwidth;
        //            if (i < text.Length)
        //            {
        //                returnString = returnString + line + '\n';
        //                count++;
        //                line = String.Empty;
        //            }
        //        }
        //        if(i < text.Length)
        //            line = line + text[i];
        //    }
        //    result[returnString + line] = count;
        //    return result;
        //}
        //left 2; right 2; up & down 4; alignment
        public Vector2 drawTags(int startX, int startY, float angleDisplay, int height, float scale)
        {
            //int YOffset = 0;
            //int resultWidth = 0;
            if (allTags.Count > 1 && wallLabel == null)
            {
                //string result = String.Empty;
                wallLabel = new System.Windows.Forms.DataGridView();
                wallLabel.ColumnCount = 1;
                wallLabel.ColumnHeadersVisible = false;
                wallLabel.RowHeadersVisible = false;
                //change line automatically
                wallLabel.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
                wallLabel.BorderStyle = System.Windows.Forms.BorderStyle.None;
                wallLabel.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SingleHorizontal;
                wallLabel.DefaultCellStyle.WrapMode = System.Windows.Forms.DataGridViewTriState.True;

                //set column to fill the whole width
                wallLabel.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
                //background
                wallLabel.BackgroundColor = System.Drawing.Color.White;

                //wallLabel.MultiSelect = true;
                //wallLabel.SelectionChanged += new EventHandler(wallLabel_SelectionChanged);
                wallLabel.ReadOnly = true;
                wallLabel.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(wallLabel_CellMouseClick);
                //wallLabel.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(wallLabel_CellBeginEdit);
                wallLabel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
                wallLabel.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.White;
                wallLabel.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.Red;
                //wallLabel.EditMode = System.Windows.Forms.DataGridViewEditMode.
                foreach (String tag in allTags)
                {
                    if(tag.Length > 0)
                        wallLabel.Rows.Add(tag);
                    //Dictionary<String, int> result = parseText(tag, width - left - right);
                    //if (result.Values.First() > 1)
                    //    resultWidth = width + addwidth;
                    //else if (resultWidth < width && resultWidth < ResourceManager.font_.MeasureString(tag).Length() + 5)
                    //    resultWidth = (int)ResourceManager.font_.MeasureString(tag).Length() + 5;
                    //if (activeTagList.Contains(tag))
                    //{
                    //    Browser.Instance.batch_.DrawString(ResourceManager.font_, result.Keys.First(), new Vector2(startX + left, startY + YOffset), Color.Red);
                    //}
                    //else
                    //    Browser.Instance.batch_.DrawString(ResourceManager.font_, result.Keys.First(), new Vector2(startX + left, startY + YOffset), Color.Gray);
                    //Vector2 size = ResourceManager.font_.MeasureString(tag);
                    ////create bounding box for every tag
                    //tagBox[tag] = new BoundingBox2D(new Vector2(startX, startY + YOffset), new Vector2(startX + resultWidth, startY + YOffset + size.Y * result.Values.First()), angleDisplay);
                    //YOffset +=(int) size.Y * result.Values.First()+ up;

                }
                wallLabel.Location = new System.Drawing.Point(startX, startY);
                wallLabel.Size = new System.Drawing.Size(width, height);
                Browser.Instance.wall.Controls.Add(wallLabel);
                wallLabel.ClearSelection();
                wallLabel.Focus();
                Browser.Instance.wall.AddLabel(wallLabel);
            }
            else if (wallLabel != null)
            {
                //wallLabel.Update(new System.Drawing.Point(startX + (int)Browser.Instance.clientBounds.Min.X, startY + (int)Browser.Instance.clientBounds.Min.Y), new System.Drawing.Size((int)(width), height));
                wallLabel.Location = new System.Drawing.Point(startX, startY);
                wallLabel.Size = new System.Drawing.Size(width, height);

            }
            return new Vector2(width, 0);
        }