foolios

Members
  • Content count

    170
  • Joined

  • Last visited

Community Reputation

133 Neutral

About foolios

  • Rank
    Member
  1. Sorry, I meant, what difference would it make? Is this how you would make 0 straight up? How does it work this way?
  2. Quote:Original post by Niksan2 You could always swap cos/sin around also. How do you mean?
  3. Thank you so much for the suggestion. When I do as you say: x = x0 + (float)(Math.Cos(((double)degrees - 90 / 360) * 2 * Math.PI) * length); y = y0 + (float)(Math.Sin(((double)degrees - 90 / 360) * 2 * Math.PI) * length); It seems to break everything. All the lines line up straight right at 360'
  4. C#/VS2005 360 degrees is straight to the right, but I want 360 degrees to be straight up when the line is drawn in my circle. Can someone please show or explain how I can adjust this? I am guessing that something needs to be adjusted in the lines: x = x0 + (float)(Math.Cos(((double)degrees / 360) * 2 * Math.PI) * length); y = y0 + (float)(Math.Sin(((double)degrees / 360) * 2 * Math.PI) Code Snippet using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication2 { public partial class Form1 : Form { //set the degree variable, default 0 int degrees; // First snippet //create a random type object that will hold our randomly generated number/degree Random createRandom = new Random(); int dialPosition, dialPosition2, dialPosition3, dialPosition4, dialPosition5; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { newReads(); } //drawLine method that will create conversions of degrees to radians private void drawLine(Bitmap draw) { //set the length that the lines will be drawn to int length; //create points for determining center of the circles float x0, y0, x, y; // Set x0 and y0 to your own numbers. Points to draw our radial line from x0 = pictureBox1.Width / 2; y0 = pictureBox1.Height / 2; if (x0 < y0) length = (int)x0 - 3; else length = (int)y0 - 3; x = x0 + (float)(Math.Cos(((double)degrees / 360) * 2 * Math.PI) * length); y = y0 + (float)(Math.Sin(((double)degrees / 360) * 2 * Math.PI) * length); //create a graphics object that will allow us to create the pen object Graphics g; //create our pen to draw with Pen myPen = new Pen(Color.Black, 2); g = Graphics.FromImage(draw); //draw our circle g.DrawEllipse(new Pen(Color.Black, 1), x0 - length, y0 - length, length * 2, length * 2); //draw our line using the points from earlier calculations and assignments g.DrawLine(myPen, x0, y0, x, y); } private void button1_Click(object sender, EventArgs e) { listBox1.SelectedIndex = -1; pictureBox1.BackColor = Color.White; listBox5.SelectedIndex = -1; pictureBox5.BackColor = Color.White; newReads(); } private void newReads() { //generate a new degree for the dial when button click degrees = createRandom.Next(0, 359); dialPosition = degrees; label1.Text = dialPosition.ToString(); Bitmap draw = new Bitmap(pictureBox1.Width, pictureBox1.Height); drawLine(draw); pictureBox1.Image = draw; //generate a new degree for the dial when button click degrees = createRandom.Next(0, 359); dialPosition2 = degrees; Bitmap draw2 = new Bitmap(pictureBox2.Width, pictureBox2.Height); drawLine(draw2); pictureBox2.Image = draw2; //generate a new degree for the dial when button click degrees = createRandom.Next(0, 359); dialPosition3 = degrees; Bitmap draw3 = new Bitmap(pictureBox3.Width, pictureBox3.Height); drawLine(draw3); pictureBox3.Image = draw3; //generate a new degree for the dial when button click degrees = createRandom.Next(0, 359); dialPosition4 = degrees; Bitmap draw4 = new Bitmap(pictureBox4.Width, pictureBox4.Height); drawLine(draw4); pictureBox4.Image = draw4; //generate a new degree for the dial when button click degrees = createRandom.Next(0, 359); dialPosition5 = degrees; label5.Text = dialPosition5.ToString(); Bitmap draw5 = new Bitmap(pictureBox5.Width, pictureBox5.Height); drawLine(draw5); pictureBox5.Image = draw5; } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedIndex == 1) { if (dialPosition > 34 & dialPosition < 72) { pictureBox1.BackColor = Color.Green; } else { pictureBox1.BackColor = Color.Red; } } } private void listBox5_SelectedIndexChanged(object sender, EventArgs e) { if (listBox5.SelectedIndex == 1) { if (dialPosition5 > 34 & dialPosition5 < 72) { pictureBox5.BackColor = Color.Green; } else { pictureBox5.BackColor = Color.Red; } } } } }
  5. I got incorrect cast at first, then switched everything to double. But now I get invalid arguments in the last line. I don't know why. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace MeterDials { public partial class DialsForm : Form { public DialsForm() { InitializeComponent(); } private void DialsForm_Load(object sender, EventArgs e) { } private void Bttn_Reset_Click(object sender, EventArgs e) { System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red); System.Drawing.Graphics formGraphics; formGraphics = this.CreateGraphics(); formGraphics.DrawLine(myPen, 0, 0, 200, 200); myPen.Dispose(); formGraphics.Dispose(); Random createRandom = new Random(); double degrees = createRandom.Next(0, 359); label1.Text = degrees.ToString(); double length = 10; double x0, y0, x, y; x0 = degrees; degrees = createRandom.Next(0, 359); y0 = degrees; x = x0 + (Math.Cos((degrees / 360) * 2 * Math.PI) * length); y = y0 + (Math.Sin((degrees / 360) * 2 * Math.PI) * length); formGraphics.DrawLine(myPen, 0, 0, x, y); } private void DialsForm_Paint_1(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Pen mypen = new Pen(Color.Black, 2); SolidBrush mybrush = new SolidBrush(Color.Blue); g.DrawEllipse(mypen, 20, 20, 100, 100); g.DrawEllipse(mypen, 140, 20, 100, 100); g.DrawEllipse(mypen, 260, 20, 100, 100); g.DrawEllipse(mypen, 380, 20, 100, 100); g.DrawEllipse(mypen, 500, 20, 100, 100); } } }
  6. Sure, let me clarify it a little more. Ok, meter dials rotate clockwise and counter clockwise beginning from the right dial to the left dial. Meter dials have 10 numbers on them as opposed to a regular time clocks 12. These numbers are from 0 - 9. What happens is that after electrical usage, the dials spin. I want to be able to read these dials from a distance without having to actually read the numbers. I figure if I practice reading them from just the hand positions since I can see those from far away that that would speed up my reading greatly since I read a great number of these dials all day long. So, I figure if the program could draw these hands/lines randomly at certain clock positions, I could use that to practice. If the first dial randomly chose position 2 which is about where the 3 0'clock position is on a regular time clock, I would then guess that it was a 2. I would set the degrees or range of where a 2 would be on this dial and have the program check whether I guessed the number correctly. I hope that explains it much better. I really need to see an example of what you are explaining, it's mostly over my head. Thank you so much for replying.
  7. How to draw a line from the center of a circle to a random point on the diameter of that circle. I am hoping to make a lil' proggy that will help improve my ability to read dials at work. I removed the dial numbers and just want to be able to read them by position. So far I have the five circles drawing up right where I want them on the form. I can draw a line, but I can't figure out how to have the line go to random points on the diameter. I imagine that what I'll need it to do is draw itself from a center location to the diameter's edge. A random numbered degree 1-360 I am guessing. Then once that's working take a number of the degrees and assign them to a number of the dial. So a range of 1-10' might be the numeral one on the dial. Well, I can only hope that this could work out something like that. Anyways here's what I have so far. I really don't know what I am doing, but I would really appreciate some assistance in having such a handy app to study from. I can print out a hundred sheets and just right on them, but this iiiiis 2008 so maybe some software would be ideal; SAVE THE TREES? hehe using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace MeterDials { public partial class DialsForm : Form { public DialsForm() { InitializeComponent(); } private void DialsForm_Load(object sender, EventArgs e) { } private void Bttn_Reset_Click(object sender, EventArgs e) { System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red); System.Drawing.Graphics formGraphics; formGraphics = this.CreateGraphics(); formGraphics.DrawLine(myPen, 0, 0, 200, 200); myPen.Dispose(); formGraphics.Dispose(); } private void DialsForm_Paint_1(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Pen mypen = new Pen(Color.Black, 2); SolidBrush mybrush = new SolidBrush(Color.Blue); //g.FillEllipse(mybrush, 10, 50, 150, 150); g.DrawEllipse(mypen, 20, 20, 100, 100); g.DrawEllipse(mypen, 140, 20, 100, 100); g.DrawEllipse(mypen, 260, 20, 100, 100); g.DrawEllipse(mypen, 380, 20, 100, 100); g.DrawEllipse(mypen, 500, 20, 100, 100); } } } A sample I found that may help figure something out: Edge coordinates: x_edge coordinate = x_center + Math.Cos(u) * radius y_edge coordinate = y_center - Math.Sin(u) * radius where u is the angle measured in radians. To convert from degrees to radians, use: degrees * Math.PI / 180. Where I have no idea where to begin with this. Thank you so much for your time in reviewing this. Thanks in advance for any assistance.
  8. It seems to work if I change the directory. What kind of problem could I be having with the temporary internet files directory for ie? I am logged in as administrator.
  9. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; namespace DeletingFiles { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { string path = @"C:\Documents and Settings\Administrator\Local Settings\Application Data\Mozilla\Firefox\Profiles\8lrj220l.default\Cache"; string target = @"C:\Documents and Settings\Administrator\Local Settings\Temporary Internet Files"; try { if (Directory.Exists(target)) { label1.Text = "IE has: " + Directory.GetFiles(target).Length.ToString(); foreach (string filename in System.IO.Directory.GetFiles(target, "*.gif")) { System.IO.File.Delete(filename); } } if (Directory.Exists(path)) { label1.Text += "\nFireFox has: " + Directory.GetFiles(path).Length.ToString(); } } catch (Exception) { label1.Text = "The process failed."; } finally { } } } } Files still there. Or else I deleted something else by accident. ;x
  10. I am wondering what part of the language to look into to delete files that are in a directory. I would like to try to make my small app have this functionality. Is it possible to have deletion occur to certain file types in that directory as well? Thanks in advance
  11. I am thinking it should actually just be: start iexplore "http://www.google.com/?q=foo" q does appear to be the name of the right input field on the page: <input maxlength=2048 name=q size=55 title="Google Search" value=""> But shouldn't there be quotes around name=q to be more like name="q" ??
  12. iexplorer.exe "http://www.google.com/index.html?name=foolios start iexplore "http://www.google.com/?q=foolios" When I run the script, I get the following error returned by the browser's page: Google Error Not Found The requested URL /?q=foolios was not found on this server. I also tried: iexplorer.exe "http://www.google.com/?name=foo start iexplore "http://www.google.com/?q=foo" And lastly I tried: start iexplore "www.google.com/index.html?name=foolios but I get this weird address result: http://%22www.google.com/index.html?name=foolios which points to a dead page.
  13. I was wondering if there was a way to set up some kind of script, etc. that would fill in a form field with a name when I double clicked that script on the desktop. For example, a web browser would open to a specific page and the name of a person would be filled into the proper form field on that page. ex: opens ie, then directs it to nbc.com/whathaveyoupage.html, then finds the input box with the name name and adds a specific name into that form field. I was hoping there was a simple way to do this without installing a specific piece of software to do it. Maybe not possible otherwise, I don't know, but I'd like to find out. A bat file could contain the following to get this started, but it needs the fill field with name part: start iexplore http://www.google.com But how do you add the part where I would like a specific name to go into the input field named q? input value would be scripted as?