Пример #1
0
        internal override BaseScore Clone(string id)
        {
            RssScore copy = new RssScore();

            copy.Id = id;
            if (String.IsNullOrEmpty(id))
            {
                copy.Id = Tools.GenerateId();
            }

            copy.Name   = this.Name;
            copy.Url    = this.Url;
            copy.Image  = this.Image;
            copy.Parent = this.Parent;

            return((BaseScore)copy);
        }
Пример #2
0
        public override bool Merge(BaseScore newBaseScore, ImportOptions option)
        {
            RssScore newScore = newBaseScore as RssScore;

            if (newScore == null)
            {
                return(false);
            }

            bool result = base.Merge(newScore, option);

            if ((option & ImportOptions.Parsing) == ImportOptions.Parsing)
            {
                result |= (String.Compare(this.Url, newScore.Url, true) != 0) ||
                          (String.Compare(this.Encoding, newScore.Encoding, true) != 0);

                this.Url      = newScore.Url;
                this.Encoding = newScore.Encoding;
            }

            return(result);
        }
Пример #3
0
        public override IList <T> Build(BaseScore score, string[][] labels, int startLine, int startColumn,
                                        int startX, int startY, int pnlWidth, int pnlHeight,
                                        CreateControlDelegate <T> createControl,
                                        out bool overRight, out bool overDown, out int lineNumber, out int colNumber)
        {
            lineNumber = -1;
            colNumber  = -1;
            overRight  = false;
            overDown   = false;

            RssScore genScore = score as RssScore;

            if (genScore == null)
            {
                return(null);
            }

            int maxX          = startX + pnlWidth;
            int maxY          = startY + pnlHeight;
            int posX          = startX;
            int posY          = startY;
            int maxColumnSize = pnlWidth / m_charWidth;

            // for all the rows
            IList <T> controls   = new List <T>();
            int       totalLines = labels.Count(p => p != null && p[0] != ScoreCenterPlugin.C_HEADER);

            foreach (string[] row_ in labels)
            {
                // ignore empty lines
                if (row_ == null || row_.Length == 0)
                {
                    continue;
                }

                lineNumber++;

                // ignore lines on previous page
                if (lineNumber < startLine)
                {
                    continue;
                }

                // ignore if outside and break to next row
                if (LimitToPage && posY > maxY)
                {
                    overDown = true;
                    break;
                }

                bool     isHeader  = (row_[0] == ScoreCenterPlugin.C_HEADER);
                string[] row       = isHeader ? row_.Where(c => c != ScoreCenterPlugin.C_HEADER).ToArray() : row_;
                Style    lineStyle = (lineNumber % 2 == 0) ? m_defaultStyle : m_altStyle;

                int nbLines = 1;
                for (int index = startColumn; index < row.Length; index++)
                {
                    string cell = row[0];

                    // evaluate size of the control in pixel
                    int maxChar = maxColumnSize;

                    // count new lines
                    int nb = Tools.CountLines(cell);
                    nbLines = Math.Max(nbLines, nb);

                    int length = m_charWidth * maxChar;
                    int height = m_charHeight * nbLines;

                    // create the control
                    string[] aa = cell.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

                    T control = createControl(posX, posY, length, m_charHeight,
                                              ColumnDisplay.Alignment.Left,
                                              aa[0],
                                              m_fontName, m_fontSize, lineStyle, maxChar, 0);

                    if (control != null)
                    {
                        controls.Add(control);
                    }
                }

                // set Y pos to the bottom of the control
                posY += m_charHeight * nbLines;
            }

            Tools.LogMessage("{0} controls created", controls.Count);
            return(controls);
        }