|
Hi Wasim,
Refer to the below mentioned link:
Link [^]
I hope this would be helpful.
John Adams
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
i want to save a image form serialization....
hghghgh
|
|
|
|
|
Thats nice. Not really a question though is it?
So, where about are you? Do you have a stream which represents the image? If so, how did you get that image into the stream in the first place?
You've got to give at least a little bit of information to get any help.
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
[Serializable]
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
draw();
}
public void draw()
{
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red);
g.DrawRectangle(p, 23, 23, 78, 78);
}
using System.IO;
using System.Xml.Serialization;
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private static void Serialize()
{
Form1 obj = new Form1();
XmlSerializer mySerializer = new
XmlSerializer(typeof(Form1));
StreamWriter myWriter = new StreamWriter("C:\\myDrawing.xml");
mySerializer.Serialize(myWriter, obj);
myWriter.Close();
}
private static void DeSerialize()
{
Form1 obj = null;
XmlSerializer mySerializer =
new XmlSerializer(typeof(Form1));
FileStream myFileStream =
new FileStream("C:\\myDrawing.xml", FileMode.Open);
obj= (Form1)mySerializer.Deserialize(myFileStream);
obj.Draw();
}
private void Form2_Load(object sender, EventArgs e)
{
Serialize();
// Form1 f = new Form1();
// putIt objDele = new putIt(f.toi);
//objDele();
}
private void button1_Click(object sender, EventArgs e)
{
DeSerialize();
}
}
now i think its enough for understanding
?
hghghgh
|
|
|
|
|
Here you are serialising form1 - i.e. serialising its properties (text, size, position etc). This does not serialise the graphics. I suggest that if you want to save the graphics drawn at runtime you look at putting them into a bitmap, and saving that instead of using serialisation.
Chris
|
|
|
|
|
i have to save through serialization..
hghghgh
|
|
|
|
|
If you really, really must I think there is something deep within the graphics object for serialising it, but I couldn't tell you what off the top of my head. I suggest you have a look with Reflector at what is inside that might help you.
Chris
|
|
|
|
|
Do your drawing to a bitmap as suggested. Have a property of byte array. Save the bitmap to a memory stream and use the stream's ToArray method to set the data in your property. It should then serialize OK.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Your code shows nothing related to an image, and as the others stated,
you'll need to create an image to serialize (although your question
is really hard to understand).
System.Drawing.Image is serializable = here's a simple example:
Bitmap bm = new Bitmap(320, 240, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(bm);
Pen pen = new Pen(Color.Azure);
g.DrawEllipse(pen, 10, 10, 100, 100);
g.DrawRectangle(pen, 10, 10, 200, 200);
FileStream fs = new FileStream("c:\\serialized_bitmap.dat", FileMode.Create);
BinaryFormatter formatter = new BinaryFormatter();
try
{
formatter.Serialize(fs, bm);
}
catch (SerializationException )
{
throw;
}
finally
{
fs.Close();
}
Of course, you'll have to create your Image/Bitmap the way you need to.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thx dear!
now i understand.....
hghghgh
|
|
|
|
|
hi Friends,
can any body tell me that how i can load the Pdf file text into rich text box
wasim khan
|
|
|
|
|
You need to use a PDF library.
There are several open source .net PDF libraries, although most only support writing, not reading PDF files. See here[^] (PDF clown looks like the only one that reads PDF files)
There are loads of commercial PDF libraries, just google.
If you don't want to use a library, you'll need to download and read the official Adobe PDF spec[^] before writing your own PDF reader.
Simon
|
|
|
|
|
Hi Wasim,
Refer to the below mentioned link:
Read from a PDF file using C# [^]
I hope this would be helpful.
John Adams
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Hello everyone,
Im wondering if its possible to make my control behave in the way described below:
during editing text when user types enter normally cursor moves to the next line creating new emtpy line and then user can keep on writing. I would like to make it possible to move to another line by typeing enter only when the current line contains 10 characters.
Hope taht my description of the problem is clear,
thanks for any hint,
Witek
|
|
|
|
|
Use the KeyDown event, inside check if the Return key was pressed. If it was then you can check how many characters are in the current line. If there are not enough characters in the line then set e.Handled to true to ignore key.
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Hi,
I have a class as under:
public class ExampleClass : BaseClass
{
public int ExampleMethod(int _toValidate) {
ExampleValidator(_toValidate);
return 1;
}
}
The ExampleValidator method is contained in the BaseClass. It is used to validate the parameter _toValidate. The ExampleValidator check is very important and every method in the class ExampleClass should contain it. I want to create a unit test for this class ExampleClass, to test if every method does contain the ExampleValidator. How can I do that?
Can reflection help me?
Regards,
ap.
|
|
|
|
|
I think you are missing the point of unit testing.
A unit test should run a piece of code and check that the output/result is as expected. A unit test does not examine code to check the semantics.
What you should do is write several unit tests that run the ExampleMethod with different parameters and checked the results were correct. You would also write several unit tests that run the ExampleMethod with invalid parameters and check that the method failed in the correct way.
What you are asking about doing is called "static analysis". MS have a tool called FxCop[^] which does static analysis. (Or if you have Vs2005/08 team versions, they have "code analysis" built in, which is basically the same as FxCop).
If you google there are several tutorials for writing your own custom rules for FxCop. (see here[^])
There are plenty of other static analysis tools[^] if you want to try a few out. There is also DevPartner[^] from Compuware, which I've used in the past and you can add custom rules to.
Simon
|
|
|
|
|
Hi friends
I have class name FileInfo, I am using FileStream fs class. I opened a file at constructure with using FileStream class and not closed, but i unable to use same variable in other methods.
public Class FileInfo
{
public FileStream fs;
public FileInfo()
{
fs = new FileStream("c:\\abc.txt", FileMode.Create);
}
public Do()
{
BinaryWriter br = new BinaryReader(fs);
br.Write(bytes);
}
}
Unable to write to file
please help me
thanks in advance
-kk.tvm-
|
|
|
|
|
|
Hi Programm3r
Your solution is helpful for me.
I mistakely write as
BinaryWriter br = new BinaryReader(fs);
anyway
thanks
-kk.tvm-
|
|
|
|
|
Hi,
I want to get current instance of the visual studio IDE when multiple instances of the
studio is running. I wanrt to reteive the current active document in the currently active instance. The code in msdn gives only this much...
<br />
EnvDTE80.DTE2 dte2;<br />
dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.<br />
GetActiveObject("VisualStudio.DTE.9.0");<br />
but this doen't help me out, when multiple instances of studio are opened.
msdn says something about moniker objects to get it? but I am unable to find out... pls help.
thanks in advance,
vinod
|
|
|
|
|
Hi,
We have a number of computers (>300), for which we need to change a particular registry setting. So I wrote a C# program that uses this code to do that:
RegistryKey regkey = Registry.LocalMachine.OpenSubKey(KeyName, true);
regkey.SetValue(KeyValue, 2);
When I distribute the executable, it works perfectly for all XP machines. But the Vista machines (even while in user accounts with Admin access) throw an error:
System.Security.SecurityException: Requested registry access is not allowed
I've tried looking for solutions online but couldn't follow any. Anyone who can help me change a registry key value in Vista through C# code?
Thanks,
Sarab
|
|
|
|
|
To run it on Vista, right click on the application and select "Run as administrator".
Despite everything, the person most likely to be fooling you next is yourself.
modified on Friday, September 26, 2008 9:51 AM
|
|
|
|
|
In addition to what Guffa said, these may help.
Look at the System.Security.Permissions.RegistryPermission class
and/or
Add an app.manifest file and alter the requestedExecutionLevel - this will invoke UAC.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi all,
Could somebody help me pls ? i want to retrieve text from label or textbox on a windows form which i want. Then i type the text to textbox with winApis automatically. For example you think that a keygen it generates a serial i wanna get this then i want to send it to programs activation window.
Thanks,
Sampiyon FENERBAHCE
modified on Friday, September 26, 2008 4:20 AM
|
|
|
|