Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 681859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:31:47+00:00 2026-05-14T01:31:47+00:00

using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Drawing.Imaging;

  • 0
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D; 

  public class Form1 : System.Windows.Forms.Form
  {

    public static float WXmin;
    public static float WYmin;
    public static float WXmax;  
    public static float WYmax;  
    public static int   VXmin;
    public static int   VYmin;
    public static int   VXmax;
    public static int   VYmax; 
    public static float Wx;
    public static float Wy; 
    public static float Vx; 
    public static float Vy;

    public Form1()
    {
      InitializeComponent();
    }

    private void InitializeComponent()
    {
      this.ClientSize = new System.Drawing.Size(400, 300);
      this.Text="Pass Args";
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.doLine);
      //this.Paint += new System.PaintEventHandler(this.eachCornerPix); 
      //eachCornerPix(out Wx, out Wy, out Vx, out Vy); 
    }

    static void Main() 
    {
      Application.Run(new Form1());
    }

    private void doLine(object sender, System.Windows.Forms.PaintEventArgs e)
    {
      Graphics g = e.Graphics;
      g.FillRectangle(Brushes.White, this.ClientRectangle);
      Pen p = new Pen(Color.Black);
      g.DrawLine(p, 0, 0, 100, 100);  // draw DOWN in y, which is positive since no matrix called
      eachCornerPix(sender, e, out Wx, out Wy, out Vx, out Vy); 
      p.Dispose();
    }

    private void eachCornerPix (object sender, System.EventArgs e, out float Wx, out float Wy, out float Vx, out float Vy)
    {
      Wx = 0.0f;
            Wy = 0.0f;
            Vx = 0.0f;
            Vy = 0.0f;
      Graphics g = this.CreateGraphics();
      Pen penBlu = new Pen(Color.Blue, 2);
      SolidBrush redBrush = new SolidBrush(Color.Red);
      int width = 2;    // 1 pixel wide in x
      int height = 2;
      float [] Wxc = {0.100f, 5.900f, 5.900f, 0.100f}; 
      float [] Wyc = {0.100f, 0.100f, 3.900f, 3.900f}; 
      Console.WriteLine("Wxc[0] = {0}", Wxc[0]);
      Console.WriteLine("Wyc[3] = {0}", Wyc[3]);
      /*
      for (int i = 0; i<3; i++)
      {
        Wx = Wxc[i];
        Wy = Wyc[i];
        Vx = ((Wx - WXmin)*((VXmax-VXmin)+VXmin)/(WXmax-WXmin));  
            Vy = ((Wy - WYmin)*(VYmax-VYmin)/(WYmax-WYmin)+VYmin); 
            Console.WriteLine("eachCornerPix Vx= {0}", Vx);
            Console.WriteLine("eachCornerPix Vy= {0}", Vy);
            g.FillRectangle(redBrush, Vx, Vy, width, height);
      }  
      */

      // What is there about this for loop that will not run?
      // When the comments above and after the for loop are removed, it gets an overflow?
      g.Dispose();
   }


  }
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:31:48+00:00Added an answer on May 14, 2026 at 1:31 am

    I’m not sure what a graphics overflow is, but here’s a problem with your code. You aren’t assigning values to any of your **max and **min variables, so they are all zero. So when you do this:

     Vx = ((Wx - WXmin)*((VXmax-VXmin)+VXmin)/(WXmax-WXmin));  
     Vy = ((Wy - WYmin)*(VYmax-VYmin)/(WYmax-WYmin)+VYmin); 
    

    You are dividing 0f by 0f in both cases, which results in Vx and Vy having an invalid value (NaN – not a number). Graphics.FillRectangle() probably doesn’t like being passed NaN.

    Also, shouldn’t your for loop be going through 4 times? This only goes 3 times:

    for (int i = 0; i<3; i++)
    

    You probably meant this:

    for (int i = 0; i<=3; i++)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Text;
In form1 i did: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Net;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
here's the code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.