Esempio n. 1
0
        /// <summary>
        /// 加入AddTextRow
        /// </summary>
        /// <returns></returns>
        public static TextRow AddTextRowToFixedFooter(this IGrid grid)
        {
            TextRow row = new TextRow();

            row.CanBeCurrent  = false;
            row.CanBeSelected = false;
            grid.FixedFooterRows.Add(row);
            return(row);
        }
Esempio n. 2
0
        private void AddRow(ITabularParameterRow row)
        {
            var textRow = new TextRow(row.Type, row.VerificationStatus);

            for (var i = 0; i < row.Values.Count; i++)
            {
                var cell = new TextCell(row.Values[i]);
                textRow.Add(cell);
                _columns[i].EnsureFit(cell.Text);
            }
            _rows.Add(textRow);
        }
Esempio n. 3
0
        private ExternalRow CreateRow(TextRow tRow, ref int index)
        {
            ExternalRow row = new ExternalRow();

            row.Number = index++;

            ColumHeader.ForEach(c => row.Cells.Add(new ExternalCell()
            {
                Column = c, Row = row, Value = tRow[c.Number - 1]
            }));

            return(row);
        }
Esempio n. 4
0
        private ProfileAttributesRow CreateRow(TextRow tRow, ref int index)
        {
            ProfileAttributesRow row = new ProfileAttributesRow();

            row.Number = index++;

            ColumHeader.ForEach(c => row.Cells.Add(new ProfileAttributeCell()
            {
                Column = c, Row = row, Value = tRow[c.Number - 1]
            }));

            return(row);
        }
Esempio n. 5
0
        public ITextRow AddRow(params object[] cols)
        {
            TextRow row = new TextRow(this);

            foreach (object o in cols)
            {
                String str = o.ToString().Trim();
                row.Add(str);
                //if (colLength.Count >= row.Count)
                //{
                //    int curLength = colLength[row.Count - 1];
                //    if (str.Length > curLength) colLength[row.Count - 1] = str.Length;
                //}
                //else
                //{
                //    colLength.Add(str.Length);
                //}
            }
            rows.Add(row);
            return(row);
        }
Esempio n. 6
0
        public ITextRow AddRow(params string[][] cols)
        {
            var row = new TextRow(this);

            foreach (object o in cols)
            {
                var str = o.ToString().Trim();
                row.Add(str);
                if (_colLength.Count >= row.Count)
                {
                    var curLength = _colLength[row.Count - 1];
                    if (str.Length > curLength)
                    {
                        _colLength[row.Count - 1] = str.Length;
                    }
                }
                else
                {
                    _colLength.Add(str.Length);
                }
            }
            _rows.Add(row);
            return(row);
        }
Esempio n. 7
0
        public static void drawParagraph(NvgContext vg, float x, float y, float width, float height, float mx, float my)
        {
            TextRow[]       rows   = new TextRow[3];
            GlyphPosition[] glyphs = new GlyphPosition[100];
            string          text   = "This is longer chunk of text.\n  \n  Would have used lorem ipsum but she    was busy jumping over the lazy dog with the fox and all the men who came to the aid of the party.";
            StringSegment   start;
            int             nrows, i, nglyphs, j, lnum = 0;
            float           lineh;
            float           caretx, px;
            Bounds          bounds = new Bounds();
            float           a;
            float           gx = 0, gy = 0;
            int             gutter = 0;

            for (i = 0; i < rows.Length; ++i)
            {
                rows[i] = new TextRow();
            }

            vg.Save();

            vg.FontSize(18.0f);
            vg.FontFace("sans");
            vg.TextAlign(Alignment.Left | Alignment.Top);

            float ascender, descender;

            vg.TextMetrics(out ascender, out descender, out lineh);

            // The text break API can be used to fill a large buffer of rows,
            // or to iterate over the text just few lines (or just one) at a time.
            // The "next" variable of the last returned item tells where to continue.
            start = text;
            while (true)
            {
                nrows = vg.TextBreakLines(start, width, rows, out start);

                if (nrows <= 0)
                {
                    break;
                }
                for (i = 0; i < nrows; i++)
                {
                    TextRow row = rows[i];
                    var     hit = mx > x && mx < (x + width) && my >= y && my < (y + lineh);

                    vg.BeginPath();
                    vg.FillColor(new Color(255, 255, 255, hit ? 64 : 16));
                    vg.Rect(x, y, row.Width, lineh);
                    vg.Fill();

                    vg.FillColor(new Color(255, 255, 255, 255));
                    vg.Text(x, y, row.Str);

                    if (hit)
                    {
                        caretx  = (mx < x + row.Width / 2) ? x : x + row.Width;
                        px      = x;
                        nglyphs = vg.TextGlyphPositions(x, y, row.Str, glyphs);
                        for (j = 0; j < nglyphs; j++)
                        {
                            float x0  = glyphs[j].X;
                            float x1  = (j + 1 < nglyphs) ? glyphs[j + 1].X : x + row.Width;
                            float gx2 = x0 * 0.3f + x1 * 0.7f;
                            if (mx >= px && mx < gx2)
                            {
                                caretx = glyphs[j].X;
                            }
                            px = gx2;
                        }
                        vg.BeginPath();
                        vg.FillColor(new Color(255, 192, 0, 255));
                        vg.Rect(caretx, y, 1, lineh);
                        vg.Fill();

                        gutter = lnum + 1;
                        gx     = x - 10;
                        gy     = y + lineh / 2;
                    }
                    lnum++;
                    y += lineh;
                }
            }

            if (gutter > 0)
            {
                string txt = gutter.ToString();
                vg.FontSize(13.0f);
                vg.TextAlign(Alignment.Right | Alignment.Middle);

                vg.TextBounds(gx, gy, txt, ref bounds);

                vg.BeginPath();
                vg.FillColor(new Color(255, 192, 0, 255));
                vg.RoundedRect((int)bounds.b1 - 4, (int)bounds.b2 - 2,
                               (int)(bounds.b3 - bounds.b1) + 8,
                               (int)(bounds.b4 - bounds.b2) + 4,
                               ((int)(bounds.b4 - bounds.b2) + 4) / 2 - 1);
                vg.Fill();

                vg.FillColor(new Color(32, 32, 32, 255));
                vg.Text(gx, gy, txt);
            }

            y += 20.0f;

            vg.FontSize(13.0f);
            vg.TextAlign(Alignment.Left | Alignment.Top);
            vg.TextLineHeight(1.2f);

            vg.TextBoxBounds(x, y, 150, "Hover your mouse over the text to see calculated caret position.", ref bounds);

            // Fade the tooltip out when close to it.
            gx = (float)Math.Abs((mx - (bounds.b1 + bounds.b3) * 0.5f) / (bounds.b1 - bounds.b3));
            gy = (float)Math.Abs((my - (bounds.b2 + bounds.b4) * 0.5f) / (bounds.b2 - bounds.b4));
            a  = maxf(gx, gy) - 0.5f;
            a  = clampf(a, 0, 1);
            vg.GlobalAlpha(a);

            vg.BeginPath();
            vg.FillColor(new Color(220, 220, 220, 255));
            vg.RoundedRect(bounds.b1 - 2, bounds.b2 - 2, (int)(bounds.b3 - bounds.b1) + 4, (int)(bounds.b4 - bounds.b2) + 4, 3);
            px = (int)((bounds.b3 + bounds.b1) / 2);
            vg.MoveTo(px, bounds.b2 - 10);
            vg.LineTo(px + 7, bounds.b2 + 1);
            vg.LineTo(px - 7, bounds.b2 + 1);
            vg.Fill();

            vg.FillColor(new Color(0, 0, 0, 220));
            vg.TextBox(x, y, 150, "Hover your mouse over the text to see calculated caret position.");

            vg.Restore();
        }
Esempio n. 8
0
 public override void CreateScreen(Player player, Level level, Camera camera, Message message)
 {
     TextRow[] textRows = new TextRow[(player.GetAllText().Length) + (level.GetAllText().Length) + (message.GetAllText().Length)];
     WriteToConsole(textRows);
 }
 /// <summary>
 /// 加入AddTextRow
 /// </summary>
 /// <returns></returns>
 public static TextRow AddTextRowToFixedFooter(this IGrid grid)
 {
     TextRow row = new TextRow();
     row.CanBeCurrent = false;
     row.CanBeSelected = false;
     grid.FixedFooterRows.Add(row);
     return row;
 }
Esempio n. 10
0
        private void DrawParagraph(float x, float y, float width, float mx, float my)
        {
            string text = "This is a longer chunk of text.\n  \n"
                          + "  Would have used lorem ipsum but she    was busy jumping over the lazy dog with the fox and all the men who came to the aid of the party.";
            string            hoverText = "Hover your mouse over the text to see the calculated caret position.";
            uint              gutter = 0;
            uint              lnum = 0;
            float             gx = 0.0f, gy = 0.0f;
            Rectangle <float> bounds;
            float             px;

            _nvg.Save();

            _nvg.FontSize(15.0f);
            _nvg.FontFace("sans");
            _nvg.TextAlign(Align.Left | Align.Top);
            _nvg.TextMetrics(out _, out _, out float lineh);

            string start = text;
            string end = null;
            int    nrows;

            while ((nrows = _nvg.TextBreakLines(start, end, width, out TextRow[] rows, 3)) != 0)
            {
                for (uint i = 0; i < nrows; i++)
                {
                    TextRow row = rows[i];
                    bool    hit = mx > x && mx < (x + width) && my >= y && my < (y + lineh);

                    _nvg.BeginPath();
                    _nvg.FillColour(_nvg.Rgba(255, 255, 255, hit ? (byte)64 : (byte)16));
                    _nvg.Rect(x + row.MinX, y, row.MaxX - row.MinX, lineh);
                    _nvg.Fill();

                    _nvg.FillColour(Colour.White);
                    _ = _nvg.Text(x, y, row.Start, row.End.Length != 0 ? row.End : null);

                    if (hit)
                    {
                        float caretX = (mx < x + row.Width / 2.0f) ? x : x + row.Width;
                        px = x;
                        int glyphCount = _nvg.TextGlyphPositions(x, y, row.Start, row.End, out GlyphPosition[] glyps, 100);
                        for (uint j = 0; j < glyphCount; j++)
                        {
                            float x0 = glyps[j].X;
                            float x1 = (j + 1 < glyphCount) ? glyps[j + 1].X : x + row.Width;
                            gx = x0 * 0.3f + x1 * 0.7f;
                            if (mx >= px && mx < gx)
                            {
                                caretX = glyps[j].X;
                            }
                            px = gx;
                        }
                        _nvg.BeginPath();
                        _nvg.FillColour(_nvg.Rgba(255, 192, 0, 255));
                        _nvg.Rect(caretX, y, 1.0f, lineh);
                        _nvg.Fill();

                        gutter = lnum + 1;
                        gx     = x - 10.0f;
                        gy     = y + lineh / 2.0f;
                    }

                    lnum++;
                    y += lineh;
                }

                start = rows[^ 1].Next;
Esempio n. 11
0
        public CsvFile ReadFile(String fullname, dtoCsvSettings settings, int lines)
        {
            CsvFile         result = null;
            TextFieldParser parser = null;

            try{
                result = new CsvFile();
                using (parser = new TextFieldParser(fullname, System.Text.Encoding.Default))
                {
                    parser.Delimiters     = settings.GetColumnDelimiters;
                    parser.TrimWhiteSpace = true;
                    long rowIndex = 1;
                    while ((lines <= 0 && !parser.EndOfData) || (rowIndex <= lines))
                    {
                        try
                        {
                            string[] parts = parser.ReadFields();
                            if (!(settings.RowsToSkip > 0 && rowIndex <= settings.RowsToSkip))
                            {
                                if (rowIndex == 1 && settings.FirstRowColumnNames)
                                {
                                    List <TextColumn> columns = new List <TextColumn>();
                                    columns.AddRange((from i in Enumerable.Range(1, parts.Count()).ToList()
                                                      select new TextColumn()
                                    {
                                        Number = i, Value = parts[i - 1]
                                    }).ToList());
                                    result.ColumHeader.AddRange(columns);
                                }
                                else
                                {
                                    List <string> cells = parts.ToList();
                                    if (cells.Where(c => !string.IsNullOrEmpty(c)).Any())
                                    {
                                        TextRow row = new TextRow();
                                        row.AddRange(cells);
                                        result.Rows.Add(row);
                                    }
                                    else
                                    {
                                        rowIndex--;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        rowIndex++;
                    }
                    if (result.Rows.Count > 0)
                    {
                        int colCount = result.ColumHeader.Count;
                        int colToAdd = (from r in result.Rows select r.Count).Max();
                        if (colToAdd > 0 && colCount < colToAdd)
                        {
                            result.ColumHeader.AddRange((from i in Enumerable.Range(colCount + 1, colToAdd - colCount).ToList() select new TextColumn()
                            {
                                Number = i
                            }).ToList());
                        }
                        colCount = result.ColumHeader.Count;
                        foreach (TextRow tRow in result.Rows.Where(r => r.Count < colCount).ToList())
                        {
                            tRow.AddRange((from i in Enumerable.Range(1, colCount - tRow.Count).ToList() select "").ToList());
                        }
                    }
                }
                parser.Dispose();
                parser = null;
            }
            catch (Exception ex) {
                if (parser != null)
                {
                    parser.Dispose();
                }
                result = null;
            }
            return(result);
        }
Esempio n. 12
0
        private void Search()
        {
            mCurrentSearchRow = 0;

            // Reset the back color of each row that was found in the previous search, if any.
            foreach (Xceed.Grid.DataRow dataRow in m_foundRows)
            {
                dataRow.ResetBackColor();

                // We must not forget the parent groups of the data row for which their
                // GroupManagerRow's BackColor has been modified.
                Group parentGroup = dataRow.ParentGroup as Group;

                while (parentGroup != null)
                {
                    parentGroup.Collapse();
                    parentGroup.HeaderRows[0].ResetBackColor();
                    parentGroup = parentGroup.ParentGroup as Group;
                }
            }

            m_foundRows.Clear();
            bool caseSensitive = mChkCaseSensitive.Checked;

            if (this.mtxtbSearch.Text.Length > 0)
            {
                string searchString = null;
                if (caseSensitive)
                {
                    searchString = this.mtxtbSearch.Text;
                }
                else
                {
                    searchString = this.mtxtbSearch.Text.ToUpper();
                }

                bool currentRow = false;
                // Iterates each data rows of the grid and check if the searched string applies to it.
                foreach (Xceed.Grid.DataRow dataRow in gridControl1.DataRows)
                {
                    // We compare the specified string with the GetDisplayText() of the Cell to
                    // make sure that the search will apply on what's displayed in the grid
                    // (can make a difference with date values for instance).

                    string cellData = null;
                    if (caseSensitive)
                    {
                        cellData = dataRow.Cells["String_text"].GetDisplayText();
                    }
                    else
                    {
                        cellData = dataRow.Cells["String_text"].GetDisplayText().ToUpper();
                    }

                    if (cellData.Contains(searchString))
                    {
                        // Make sure that each parent group of the found data row are expanded.
                        if ((dataRow.ParentGroup != null) && dataRow.ParentGroup.Collapsed)
                        {
                            Group parentGroup = dataRow.ParentGroup as Group;

                            while (parentGroup != null)
                            {
                                parentGroup.Expand();
                                parentGroup = parentGroup.ParentGroup as Group;
                            }
                        }

                        if (!currentRow)
                        {
                            gridControl1.FirstVisibleRow = dataRow;
                            currentRow = true;
                        }


                        // Highlight the found data row by changing its back color
//                  dataRow.BackColor = Color.AliceBlue;
                        dataRow.BackColor = Color.LightSteelBlue;
                        // Highlight the found data row's parent groups by changing their
                        // GroupManagerRow's back color.
                        this.TagGroups(dataRow);
                        m_foundRows.Add(dataRow);
                    }
                }

                // Add a text row in the grid fixed footers displaying the number of rows found.
                TextRow searchResultsRow = new TextRow(m_foundRows.Count.ToString() + " item" + ((m_foundRows.Count == 1) ? "" : "s") + " found.");
                searchResultsRow.Font              = new Font("Verdana", 9, FontStyle.Bold | FontStyle.Italic);
                searchResultsRow.Height            = searchResultsRow.Height + 10;
                searchResultsRow.ForeColor         = Color.AliceBlue;
                searchResultsRow.BackColor         = Color.SteelBlue;
                searchResultsRow.CanBeSelected     = false;
                searchResultsRow.CanBeCurrent      = false;
                searchResultsRow.VerticalAlignment = VerticalAlignment.Center;

                gridControl1.FixedFooterRows.Clear();
                gridControl1.FixedFooterRows.Add(searchResultsRow);

                if (m_foundRows.Count > 0)
                {
                    this.btnFilter.Enabled = true;
                }
            }
            else
            {
                gridControl1.FixedFooterRows.Clear();
                this.btnFilter.Enabled = false;
            }

            gridControl1.Focus();
        }
		public static void SetFormulario(TextRow element, Formulario newFormulario)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, TextRowDomainRoleId, newFormulario);
		}
		public static Formulario GetFormulario(TextRow element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, TextRowDomainRoleId) as Formulario;
		}
		/// <summary>
		/// Constructor
		/// Creates a FormularioHasTextRows link in the same Partition as the given Formulario
		/// </summary>
		/// <param name="source">Formulario to use as the source of the relationship.</param>
		/// <param name="target">TextRow to use as the target of the relationship.</param>
		public FormularioHasTextRows(Formulario source, TextRow target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(FormularioHasTextRows.FormularioDomainRoleId, source), new DslModeling::RoleAssignment(FormularioHasTextRows.TextRowDomainRoleId, target)}, null)
		{
		}