Dear Mahesh,
thanks for a good web about C#.
I have a question in "Visual C# " and wonder if you may help me.
I would like to load a bit map and store the positions of the cursor by moving the cursor over a line, into a matrix and have an out put of those cursor position as a TEXT file. how can I do that in C#?
thanks alot
Loading
yamidPosted Aug 27, 2008, 4:58 AM
this is the data file I was using...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
oBuilder = new StringBuilder();
this.MouseMove += new MouseEventHandler(Form1_MouseMove);
}
StringBuilder oBuilder;
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
textBox1.Text = e.X.ToString();
textBox2.Text = e.Y.ToString();
oBuilder.AppendLine("X: " + textBox1.Text + " Y: " + textBox2.Text);
}
StreamWriter oWriter;
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
string ContentFile = oBuilder.ToString();
SaveFileDialog oSDLg = new SaveFileDialog();
oSDLg.Filter = "(*.txt)|*.txt";
if (oSDLg.ShowDialog() == DialogResult.OK)
{
oWriter = new StreamWriter(oSDLg.FileName);
oWriter.Write(ContentFile);
oWriter.Flush();
}
oWriter.Close();
}
}
}
yamidPosted Aug 27, 2008, 4:50 AM
yamidPosted Aug 27, 2008, 4:22 AM
Bechir BejaouiPosted Aug 26, 2008, 3:04 PM
first, add those namespaces
using System.Text;
using System.IO;
add two textboxes into your form
then copy and paste this code in the code editor:
private void Form1_Load(object sender, EventArgs e)
{
oBuilder = new StringBuilder();
this.MouseMove+=new MouseEventHandler(Form1_MouseMove);
}
StringBuilder oBuilder;
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
textBox1.Text = e.X.ToString();
textBox2.Text = e.Y.ToString();
oBuilder.AppendLine("X: " + textBox1.Text + " Y: " + textBox2.Text);
}
StreamWriter oWriter;
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
string ContentFile = oBuilder.ToString();
SaveFileDialog oSDLg = new SaveFileDialog();
oSDLg.Filter = "(*.txt)|*.txt";
if (oSDLg.ShowDialog() == DialogResult.OK)
{
oWriter = new StreamWriter(oSDLg.FileName);
oWriter.Write(ContentFile);
oWriter.Flush();
}
oWriter.Close();
}
Bechir BejaouiPosted Aug 26, 2008, 3:04 PM
first, add those namespaces
using System.Text;
using System.IO;
add two textboxes into your form
then copy and paste this code in the code editor:
private void Form1_Load(object sender, EventArgs e)
{
oBuilder = new StringBuilder();
this.MouseMove+=new MouseEventHandler(Form1_MouseMove);
}
StringBuilder oBuilder;
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
textBox1.Text = e.X.ToString();
textBox2.Text = e.Y.ToString();
oBuilder.AppendLine("X: " + textBox1.Text + " Y: " + textBox2.Text);
}
StreamWriter oWriter;
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
string ContentFile = oBuilder.ToString();
SaveFileDialog oSDLg = new SaveFileDialog();
oSDLg.Filter = "(*.txt)|*.txt";
if (oSDLg.ShowDialog() == DialogResult.OK)
{
oWriter = new StreamWriter(oSDLg.FileName);
oWriter.Write(ContentFile);
oWriter.Flush();
}
oWriter.Close();
}