Exemple #1
0
        public void DrawSinglePoint(double XCoord, double YCoord, Brush color)
        {
            int xPixel, yPixel;

            GetCorrectPixelForDraw(XCoord, YCoord, out xPixel, out yPixel);

            Graphics g = DrawField.CreateGraphics();

            g.FillRectangle(color, xPixel, GetCorrectYCoord(yPixel), 1, 1);
        }
Exemple #2
0
        public void DrawPoint(double XCoord, double YCoord)
        {
            int xPixel, yPixel;

            GetCorrectPixelForDraw(XCoord, YCoord, out xPixel, out yPixel);

            Graphics g = DrawField.CreateGraphics();

            g.DrawLine(new Pen(Brushes.Gold, 2),
                       new Point(xPixel, GetCorrectYCoord(_pixelYCoordZero - 2)),
                       new Point(xPixel, GetCorrectYCoord(_pixelYCoordZero + 3)));
        }
Exemple #3
0
        public bool Draw(int indentation = 0, DrawField altDraw = null)
        {
            if (!active)
            {
                return(false);
            }
            if (indentation > 0)
            {
                EditorGUI.indentLevel += indentation;
            }
            var changed = altDraw == null?draw(this) : altDraw(this);

            if (indentation > 0)
            {
                EditorGUI.indentLevel -= indentation;
            }
            return(changed);
        }
Exemple #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Image busstop   = Properties.Resources.p_BusStop /*@"p_BusStop.png"*/;
            Image passenger = Properties.Resources.p_Passenger /*(@"p_Passenger.png")*/;
            Image bus       = Properties.Resources.p_Bus /*(@"p_Bus.png")*/;

            town          = new Town(Width, Height);
            draw          = new DrawField(town);
            town.BusStops = new List <BusStop>();
            town.BusStops.Add(new BusStop(busstop.Width, busstop.Height, Width, Height));
            town.BusStops.Add(new BusStop(Width - busstop.Width * 2 - busstop.Width / 2, busstop.Height, Width, Height));
            town.BusStops.Add(new BusStop(Width / 2 - busstop.Width + busstop.Width / 3, Height - busstop.Height - 50 - busstop.Height / 2, Width, Height));
            town.RandomBusesAndPassengers();

            draw = new DrawField(town, busstop, bus, passenger);
            DrawTimer.Start();
            ChangeTimer.Start();
        }
Exemple #5
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Image busstop   = Properties.Resources.p_Conveer; /*@"p_BusStop.png"*/;
            Image passenger = Properties.Resources.p_Mechanic /*(@"p_Passenger.png")*/;
            Image bus       = Properties.Resources.p_Pogruz /*(@"p_Bus.png")*/;
            Image revolt    = Properties.Resources.mark;

            town          = new Town(Width, Height);
            draw          = new DrawField(town);
            town.BusStops = new List <Conveer>();
            town.BusStops.Add(new Conveer(busstop.Width, busstop.Height, Width, Height));
            town.BusStops.Add(new Conveer(Width - busstop.Width * 2 - busstop.Width / 2, busstop.Height, Width, Height));
            town.BusStops.Add(new Conveer(busstop.Width, Height - busstop.Height - 50 - busstop.Height / 2, Width, Height));
            town.BusStops.Add(new Conveer(Width - busstop.Width * 2 - busstop.Width / 2, Height - busstop.Height - 50 - busstop.Height / 2, Width, Height));
            town.RandomBusesAndPassengers();

            draw = new DrawField(town, busstop, bus, passenger, revolt);
            DrawTimer.Start();
            ChangeTimer.Start();
        }
Exemple #6
0
        public void SetFindedMinimum(double minimum, double xCoord)
        {
            int  minPixX, minPixY;
            bool flagY = (minimum > 0);
            bool flagX = (xCoord > 0);

            GetCorrectPixelForDraw(xCoord, minimum, out minPixX, out minPixY);

            Graphics g     = DrawField.CreateGraphics();
            var      myPen = new Pen(Brushes.GreenYellow, 1);

            myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;

            // Отрисовка перпендикуляра к оси Х
            g.DrawLine(myPen,
                       new Point(minPixX, GetCorrectYCoord(minPixY)),
                       new Point(minPixX, GetCorrectYCoord(_pixelYCoordZero)));

            // Отображение значения
            g.DrawString(xCoord.ToString(),
                         new Font(this.Font, FontStyle.Italic),
                         Brushes.GreenYellow,
                         minPixX - 3, GetCorrectYCoord((flagY) ? _pixelYCoordZero - 10 : _pixelYCoordZero + 20));


            // Отрисовка перпендикуляра к оси Y
            g.DrawLine(myPen,
                       new Point(minPixX, GetCorrectYCoord(minPixY)),
                       new Point(_pixelXCoordZero, GetCorrectYCoord(minPixY)));

            // Отображение значения
            g.DrawString(minimum.ToString(),
                         new Font(this.Font, FontStyle.Italic),
                         Brushes.GreenYellow,
                         (flagX) ? _pixelXCoordZero + 12 : _pixelXCoordZero - 50, GetCorrectYCoord(minPixY - 4));

            SearchResultValue.Text = string.Format("{0:0.0000000}", minimum);
            FindedXValue.Text      = string.Format("{0:0.0000000}", xCoord);

            IterationCountValue.Text = _minExecutor.IterationCount.ToString();
        }
Exemple #7
0
 private void ReloadModelBttn_Click(object sender, EventArgs e)
 {
     DrawTimer.Dispose();
     ChangeTimer.Dispose();
     town.Dispose();
     Image busstop = Properties.Resources.p_BusStop /*@"p_BusStop.png"*/;
     Image passenger = Properties.Resources.p_Passenger/*(@"p_Passenger.png")*/;
     Image bus = Properties.Resources.p_Bus/*(@"p_Bus.png")*/;
     Image revolt = Properties.Resources.mark;
     town = new Town(Width, Height);
     draw = new DrawField(town);
     town.BusStops = new List<BusStop>();
     town.BusStops.Add(new BusStop(busstop.Width, busstop.Height, Width, Height));
     town.BusStops.Add(new BusStop(Width - busstop.Width * 2 - busstop.Width / 2, busstop.Height, Width, Height));
     town.BusStops.Add(new BusStop(busstop.Width, Height - busstop.Height - 50 - busstop.Height / 2, Width, Height));
     town.BusStops.Add(new BusStop(Width - busstop.Width * 2 - busstop.Width / 2, Height - busstop.Height - 50 - busstop.Height / 2, Width, Height));
     town.RandomBusesAndPassengers();
     draw = new DrawField(town, busstop, bus, passenger, revolt);
     DrawTimer.Start();
     ChangeTimer.Start();
 }
		public static bool DrawArray<T>(string labelString, ref T[] values, DrawField<T> drawFunc)
		{
			// Arrays are drawn with a label, and rows of values.

			bool bChanged = false;

			GUILayout.BeginHorizontal();
			{
				EditorGUILayout.PrefixLabel(labelString);

				GUILayout.BeginVertical(EditorStyles.helpBox);
				{
					int numElements = values.Length;
					int maxElementsPerRow = 4;

					GUILayout.BeginHorizontal();
					{
						for (int i = 0; i < numElements; ++i)
						{
							if (i > 0 && i % maxElementsPerRow == 0)
							{
								GUILayout.EndHorizontal();
								GUILayout.BeginHorizontal();
							}

							if (drawFunc(ref values[i]))
							{
								bChanged = true;
							}
						}
					}
					GUILayout.EndHorizontal();
				}
				GUILayout.EndVertical();
			}
			GUILayout.EndHorizontal();

			return bChanged;
		}
        void OnLoad()
        {
            DrawField drawField = new DrawField();

            drawField.Paint(this);
        }
Exemple #10
0
        public void ClearDrawField(bool isSecondCall = false)
        {
            double step     = Math.Round((_minExecutor.MaxValueX - _minExecutor.MinValueX) / 20, 2);
            double iterator = Math.Round((_minExecutor.MinValueX > 0) ? _minExecutor.MinValueX : _minExecutor.MinValueX + step, 1);

            int pixX, pixY;


            Graphics g = DrawField.CreateGraphics();

            g.Clear(Color.Black);

            _pixelXValue = ((_minExecutor.MaxValueX - _minExecutor.MinValueX) / DrawField.Width);
            _pixelYValue = ((_minExecutor.MaxValueY - _minExecutor.MinValueY) / DrawField.Height);

            if (_minExecutor.MinValueX > 0)
            {
                _pixelXCoordZero = 2;
            }
            else
            {
                _pixelXCoordZero = (int)((0.0 - _minExecutor.MinValueX) / _pixelXValue);
            }

            if (_minExecutor.MinValueY > 0)
            {
                _pixelYCoordZero = 2;
            }
            else
            {
                _pixelYCoordZero = (int)((0.0 - _minExecutor.MinValueY) / _pixelYValue);
            }

            #region Y-Ось
            // Ось Y
            g.DrawLine(new Pen(Brushes.Red, 1),
                       new Point(_pixelXCoordZero, GetCorrectYCoord(0)),
                       new Point(_pixelXCoordZero, GetCorrectYCoord(DrawField.Size.Height - 1)));

            // + Стрелочки
            g.DrawLine(new Pen(Brushes.Red, 1),
                       new Point(_pixelXCoordZero, GetCorrectYCoord(DrawField.Size.Height - 1)),
                       new Point(_pixelXCoordZero - 2, GetCorrectYCoord(DrawField.Size.Height - 5)));
            g.DrawLine(new Pen(Brushes.Red, 1),
                       new Point(_pixelXCoordZero, GetCorrectYCoord(DrawField.Size.Height - 1)),
                       new Point(_pixelXCoordZero + 2, GetCorrectYCoord(DrawField.Size.Height - 5)));

            // + Координаты
            step     = Math.Round((_minExecutor.MaxValueY - _minExecutor.MinValueY) / 20, 2);
            iterator = Math.Round((_minExecutor.MinValueY > 0) ? _minExecutor.MinValueY : _minExecutor.MinValueY + step, 1);

            while (iterator <= _minExecutor.MaxValueX - step)
            {
                GetCorrectPixelForDraw(0.0, iterator, out pixX, out pixY);
                g.DrawLine(new Pen(Brushes.Red, 2),
                           new Point(pixX - 2, GetCorrectYCoord(pixY)),
                           new Point(pixX + 2, GetCorrectYCoord(pixY)));
                g.DrawString(iterator.ToString(),
                             new Font(this.Font, FontStyle.Italic),
                             Brushes.OrangeRed,
                             pixX + 6, GetCorrectYCoord(pixY - 3));
                iterator += step;
                iterator  = Math.Round(iterator, 2);
            }
            #endregion

            #region X-Ось
            // Ось X
            g.DrawLine(new Pen(Brushes.Red, 1),
                       new Point(0, GetCorrectYCoord(_pixelYCoordZero)),
                       new Point(DrawField.Size.Width - 1, GetCorrectYCoord(_pixelYCoordZero)));

            // + Стрелочки
            g.DrawLine(new Pen(Brushes.Red, 1),
                       new Point(DrawField.Size.Width - 1, GetCorrectYCoord(_pixelYCoordZero)),
                       new Point(DrawField.Size.Width - 5, GetCorrectYCoord(_pixelYCoordZero - 2)));
            g.DrawLine(new Pen(Brushes.Red, 1),
                       new Point(DrawField.Size.Width - 1, GetCorrectYCoord(_pixelYCoordZero)),
                       new Point(DrawField.Size.Width - 5, GetCorrectYCoord(_pixelYCoordZero + 2)));


            // + Координаты
            step     = Math.Round((_minExecutor.MaxValueX - _minExecutor.MinValueX) / 20, 2);
            iterator = Math.Round((_minExecutor.MinValueX > 0) ? _minExecutor.MinValueX : _minExecutor.MinValueX + step, 1);

            while (iterator <= _minExecutor.MaxValueX - step)
            {
                GetCorrectPixelForDraw(iterator, 0.0, out pixX, out pixY);
                g.DrawLine(new Pen(Brushes.Red, 3),
                           new Point(pixX, GetCorrectYCoord(pixY + 10)),
                           new Point(pixX, GetCorrectYCoord(pixY - 2)));
                g.DrawString(iterator.ToString(),
                             new Font(this.Font, FontStyle.Italic),
                             Brushes.OrangeRed,
                             pixX - 3, GetCorrectYCoord(pixY - 5));
                iterator += step;
                iterator  = Math.Round(iterator, 2);
            }
            #endregion

            // Сама Функция
            _minExecutor.DrawFunction(_minExecutor.MinValueX, _minExecutor.MaxValueX, isSecondCall, Brushes.Pink);
        }
Exemple #11
0
 /// <summary>
 /// Raizes when Invertion is done
 /// </summary>
 /// <param name="img">New image, which will be setted to PictureBox</param>
 private void OnDone(Image img)
 {
     progressBW.Invoke(new Action <int>((progr) => progressBW.Value = progr), 0);
     DrawField.Invoke(new Action <Image>((i) => DrawField.Image     = i), img);
 }
Exemple #12
0
 public Property(DrawField draw, string label, string tooltip)
 {
     this.draw  = draw;
     this.label = new GUIContent(label, tooltip);
 }