Exemplo n.º 1
0
        protected override void OnDoubleClick(EventArgs e)
        {
            int i = PageCoordinatesToLineIndex(this.mouseDoubleClickPosition);

            if (i >= 0)
            {
                TextLineInformation lineToBeChanged =
                    (TextLineInformation)documentLines[i];
                lineToBeChanged.Text = lineToBeChanged.Text.ToUpper();
                Graphics dc       = this.CreateGraphics();
                uint     newWidth = (uint)dc.MeasureString(lineToBeChanged.Text,
                                                           mainFont).Width;
                if (newWidth > lineToBeChanged.Width)
                {
                    lineToBeChanged.Width = newWidth;
                }
                if (newWidth + 2 * margin > this.documentSize.Width)
                {
                    this.documentSize.Width = (int)newWidth;
                    this.AutoScrollMinSize  = this.documentSize;
                }
                Rectangle changedRectangle = new Rectangle(
                    LineIndexToPageCoordinates(i),
                    new Size((int)newWidth,
                             (int)this.lineHeight));
                this.Invalidate(changedRectangle);
            }
            base.OnDoubleClick(e);
        }
Exemplo n.º 2
0
        private void LoadFile(string FileName)
        {
            StreamReader sr = new StreamReader(FileName);
            string       nextLine;

            documentLines.Clear();
            nLines = 0;
            TextLineInformation nextLineInfo;

            while ((nextLine = sr.ReadLine()) != null)
            {
                nextLineInfo      = new TextLineInformation();
                nextLineInfo.Text = nextLine;
                documentLines.Add(nextLineInfo);
                ++nLines;
            }
            sr.Close();
            documentHasData = (nLines > 0) ? true : false;

            CalculateLineWidths();
            CalculateDocumentSize();

            this.Text = standardTitle + " - " + FileName;
            this.Invalidate();
        }
Exemplo n.º 3
0
        private int WorldCoordinatesToLineIndex(Point position)
        {
            if (!documentHasData)
            {
                return(-1);
            }
            if (position.Y < margin || position.X < margin)
            {
                return(-1);
            }
            int index = (int)(position.Y - margin) / (int)this.lineHeight;

            // check position isn't below document
            if (index >= documentLines.Count)
            {
                return(-1);
            }
            // now check that horizontal position is within this line
            TextLineInformation theLine =
                (TextLineInformation)documentLines[index];

            if (position.X > margin + theLine.Width)
            {
                return(-1);
            }

            // all is OK. We can return answer
            return(index);
        }
Exemplo n.º 4
0
        private void LoadFile(string FileName)
        {
            StreamReader sr = new StreamReader(FileName);
            string nextLine;
            documentLines.Clear();
            nLines = 0;
            TextLineInformation nextLineInfo;
            while ( (nextLine = sr.ReadLine()) != null)
            {
                nextLineInfo = new TextLineInformation();
                nextLineInfo.Text = nextLine;
                documentLines.Add(nextLineInfo);
                ++nLines;
            }
            sr.Close();
            documentHasData = (nLines>0) ? true : false;

            //CalculateLineWidths();
            CalculateDocumentSize();

            this.Text = standardTitle + " - " + FileName;
            this.Invalidate();
        }