Esempio n. 1
0
File: Form1.cs Progetto: zilo312/aa
        protected override void OnDoubleClick(EventArgs e)
        {
            int i = PageCoordinatesToLineIndex(mouseDoubleClickPosition);

            if (i >= 0)
            {
                TextLineInformation lineToBeChanged =
                    (TextLineInformation)documentLines[i];
                lineToBeChanged.Text = lineToBeChanged.Text.ToUpper();
                Graphics dc       = CreateGraphics();
                uint     newWidth = (uint)dc.MeasureString(lineToBeChanged.Text,
                                                           mainFont).Width;
                if (newWidth > lineToBeChanged.Width)
                {
                    lineToBeChanged.Width = newWidth;
                }
                if (newWidth + 2 * margin > documentSize.Width)
                {
                    documentSize.Width = (int)newWidth;
                    AutoScrollMinSize  = documentSize;
                }
                Rectangle changedRectangle = new Rectangle(
                    LineIndexToPageCoordinates(i),
                    new Size((int)newWidth,
                             (int)lineHeight));
                Invalidate(changedRectangle);
            }
            base.OnDoubleClick(e);
        }
Esempio n. 2
0
File: Form1.cs Progetto: zilo312/aa
        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)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);
        }
Esempio n. 3
0
File: Form1.cs Progetto: zilo312/aa
        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();
            if (nLines > 0)
            {
                documentHasData              = true;
                menuFilePrint.Enabled        = true;
                menuFilePrintPreview.Enabled = true;
            }
            else
            {
                documentHasData              = false;
                menuFilePrint.Enabled        = false;
                menuFilePrintPreview.Enabled = false;
            }

            CalculateLineWidths();
            CalculateDocumentSize();

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