예제 #1
0
 public GraphControl(Grapher Graph)
 {
     InitializeComponent();
     graph = Graph;
     basePosition = this.Location;
     Moved = false;
 }
예제 #2
0
        public GridLine(bool isVertical, bool MajorLine, Size BitmapSize, Size WindowSize, Point Position, Grapher Owner)
        {
            owner = Owner;

            lineValue = new TextBox();
            Location = new Point();

            scaleX = (float)BitmapSize.Width / (float)WindowSize.Width;
            scaleY = (float)BitmapSize.Height / (float)WindowSize.Height;

              if (gridPen == null)
            gridPen = new Pen(Color.Black, 3);

            if (gridGraphics == null)
                gridGraphics = Graphics.FromImage(grid);

            oldBorders = new Rectangle(Position, WindowSize);

            disposed = false;

            lineValue.BackColor = Color.White;

            lineValue.Size = new Size(50, 20);
            lineValue.ReadOnly = true;
            lineValue.TextAlign = HorizontalAlignment.Center;

            vertical = isVertical;
            major = MajorLine;

            lineValue.Text = @"0";

            //if (isVertical) //not even sure if tracking the size is useful with the new paradigm
            //{
            //  //gridLine.Height = WindowSize.Height;
            //  lineSize.Height = WindowSize.Height;
            //  if (MajorLine)
            //    //gridLine.Width = gridLine.BackgroundImage.Width;
            //    lineSize.Width = (int)gridPen.Width;
            //  else
            //    //gridLine.Width = gridLine.BackgroundImage.Width / 2;
            //    lineSize.Width = (int)gridPen.Width / 2;

            //  scale = BitmapSize.Height / (float)WindowSize.Height;
            //}
            //else
            //{
            //  //gridLine.Width = WindowSize.Width;
            //  lineSize.Width = WindowSize.Width;
            //  if (MajorLine)
            //    //gridLine.Height = gridLine.BackgroundImage.Height;
            //    lineSize.Height = (int)gridPen.Width;
            //  else
            //    //gridLine.Height = gridLine.BackgroundImage.Height / 2;
            //    lineSize.Height = (int)gridPen.Width / 2;

            //  scale = BitmapSize.Width / (float)WindowSize.Width;
            //}

            Location = Position;
            //Draw line onto transparent bitmap using position
            if (vertical)
                gridGraphics.DrawLine(gridPen, Location.X, Location.Y, Location.X, owner.ClientSize.Height);
            else
                gridGraphics.DrawLine(gridPen, Location.X, Location.Y, owner.ClientSize.Width,	Location.Y);

            //Signal the graphbox to update it's image
            //this.Update(Position); // should just run error checking -- didn't seem to work.

            this.UpdateBox();

            Owner.Controls.Add(lineValue);

            lineValue.BringToFront(); //box should appear on top of the line
        }