|
Beware of creating a large bitmap buffer every time you re-paint. Instead, create a new buffer bitmap when the window is resized. (You might already be doing this, but just checking.)
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
hi, I want to add grid control in my project as given in MS Project.
1. the problem is i couldn't find how to add no. of blank rows and columns like excel sheet. so, when i open new project it should be appeared blank sheet on the screen.
2.another thing how can i give functionality of tree view on clik on indent and outdent.
3. is there any ocx for network diagram, calendar control and gantt chart??
pls reply me soon.
-bhavin
|
|
|
|
|
if i have a string with multiple lines in it like this:
0 @IQLNP-M7@ INDI
1 NAME Benoni /THOMPSON/
2 GIVN Benoni
2 SURN THOMPSON
1 AFN QLNP-M7
1 SEX M
1 SOUR @S01@
1 BIRT
2 DATE 14 Apr 1782
2 PLAC Alstead, N.h.
1 DEAT
2 DATE 24 Oct 1857
2 PLAC Shalersville, N.h.
1 FAMS @F6073064@
1 FAMC @F6073065@
0 @IQLNP-KV@ INDI
1 NAME Job /THOMPSON/
2 GIVN Job
2 SURN THOMPSON
1 AFN QLNP-KV
1 SEX M
1 SOUR @S01@
1 FAMS @F6073065@
0 @IQLNP-L2@ INDI
1 NAME Lovice /CRANE/
2 GIVN Lovice
2 SURN CRANE
1 AFN QLNP-L2
1 SEX F
1 SOUR @S01@
1 FAMS @F6073065@
...
how would i split it into chunks from the '0' lines to the '0' lines, like this:
**Chunk 1**
0 @IQLNP-M7@ INDI
1 NAME Benoni /THOMPSON/
2 GIVN Benoni
2 SURN THOMPSON
1 AFN QLNP-M7
1 SEX M
1 SOUR @S01@
1 BIRT
2 DATE 14 Apr 1782
2 PLAC Alstead, N.h.
1 DEAT
2 DATE 24 Oct 1857
2 PLAC Shalersville, N.h.
1 FAMS @F6073064@
1 FAMC @F6073065@
**Chunk 2**
0 @IQLNP-KV@ INDI
1 NAME Job /THOMPSON/
2 GIVN Job
2 SURN THOMPSON
1 AFN QLNP-KV
1 SEX M
1 SOUR @S01@
1 FAMS @F6073065@
**Chunk 3**
0 @IQLNP-L2@ INDI
1 NAME Lovice /CRANE/
2 GIVN Lovice
2 SURN CRANE
1 AFN QLNP-L2
1 SEX F
1 SOUR @S01@
1 FAMS @F6073065@
...
etc.
thanks,
Rob
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
When reading one line at a time check the value of the first character, if it is '0' you have reached your break point, else append it (a StringBuilder object would work nicely here). There are articles available for reading files in C# if this is what you are asking about. HTH.
-Nick Parker
|
|
|
|
|
i started out by reading each line one by one with a streamreader but i didn't want to access the file everytime i needed it so i read the whole thing at once and dumped it into a string. now i just need to figure out how to split the string up. i'll look into the stringbuilder class though.
thanks,
Rob
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
Search for "\n0 @" in string (or use something faster like StringBuilder). Like this (check syntax, not tested):
string multiple=" ... ";
ArrayList chunks=new ArrayList(1);
while(multiple!="")
{
int p=multiple.IndexOf("\n0 @");
if(p<0)
{
chunks.Add(multiple);
break;
}
chunks.Add(multiple.Substring(0,p));
multiple=multiple.Substring(p+1);
}
Hi,
AW
|
|
|
|
|
could i use the string.split method and use "\n0 @" as the delimeter? btw, what does the @ mean in '\n0 @'?
thanks for the help,
Rob
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
1. No. Unfortunately Split method uses chars ... You must use above one character "\n0"
2. All Your "0" groups starts with " @" after "0". It is unnecessary, new line and zero will be enough.
Hi,
AW
|
|
|
|
|
use RegExp
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
This seems to work - i'm sure it can be optimised though:
string s = "0 @IQLNP-M7@ INDI" + Environment.NewLine;
s += "1 NAME Benoni /THOMPSON/" + Environment.NewLine;
s += "2 GIVN Benoni" + Environment.NewLine;
s += "2 SURN THOMPSON" + Environment.NewLine;
s += "1 AFN QLNP-M7" + Environment.NewLine;
s += "1 SEX M" + Environment.NewLine;
s += "1 SOUR @S01@" + Environment.NewLine;
s += "1 BIRT" + Environment.NewLine;
s += "2 DATE 14 Apr 1782" + Environment.NewLine;
s += "2 PLAC Alstead, N.h." + Environment.NewLine;
s += "1 DEAT" + Environment.NewLine;
s += "2 DATE 24 Oct 1857" + Environment.NewLine;
s += "2 PLAC Shalersville, N.h." + Environment.NewLine;
s += "1 FAMS @F6073064@" + Environment.NewLine;
s += "1 FAMC @F6073065@" + Environment.NewLine;
s += "0 @IQLNP-KV@ INDI" + Environment.NewLine;
s += "1 NAME Job /THOMPSON/" + Environment.NewLine;
s += "2 GIVN Job" + Environment.NewLine;
s += "2 SURN THOMPSON" + Environment.NewLine;
s += "1 AFN QLNP-KV" + Environment.NewLine;
s += "1 SEX M" + Environment.NewLine;
s += "1 SOUR @S01@" + Environment.NewLine;
s += "1 FAMS @F6073065@" + Environment.NewLine;
s += "0 @IQLNP-L2@ INDI" + Environment.NewLine;
s += "1 NAME Lovice /CRANE/" + Environment.NewLine;
s += "2 GIVN Lovice" + Environment.NewLine;
s += "2 SURN CRANE" + Environment.NewLine;
s += "1 AFN QLNP-L2" + Environment.NewLine;
s += "1 SEX F" + Environment.NewLine;
s += "1 SOUR @S01@" + Environment.NewLine;
s += "1 FAMS @F6073065@" + Environment.NewLine;
int index = 0;
System.Collections.ArrayList indexList = new System.Collections.ArrayList();
indexList.Add(0);
while (index != -1)
{
index = s.IndexOf(Environment.NewLine + "0 ", index + 1, s.Length - (index + 1));
if(index != -1)
{
indexList.Add(index);
}
}
string[] splitStrings = new string[indexList.Count];
for(int i = 0 ; i < indexList.Count ; i++)
{
if(i == indexList.Count - 1)
{
splitStrings[i] = s.Substring(Convert.ToInt32(indexList[i]), s.Length - Convert.ToInt32(indexList[i]));
}
else
{
splitStrings[i] = s.Substring(Convert.ToInt32(indexList[i]), Convert.ToInt32(indexList[i+1])-Convert.ToInt32(indexList[i]));
}
if(splitStrings[i].StartsWith(Environment.NewLine))
{
splitStrings[i] = splitStrings[i].Substring(Environment.NewLine.Length, splitStrings[i].Length - Environment.NewLine.Length);
}
}
foreach(string newString in splitStrings)
{
MessageBox.Show(newString);
}
|
|
|
|
|
I created a Bitmap object like so
private void FOrm1_Paint( object sender, PaintEventArgs e )
{
Bitmap bmp = new Bitmap(100, 100, e.Grpahics);
}
what I want to do is draw rectangles and things like that inside. But inorder to do that I need to get a graphics object of its surface.
Anyone know how or pointers or links?
Maybe I have to convert it to a HBitmap, I font know!
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
what I want to do is draw rectangles and things like that inside. But inorder to do that I need to get a graphics object of its surface.
You already have a Graphics object embedded within the PaintEventArgs, you are using it when you are creating the Bitmap object above when you access it like e.Graphics . You can continue using this object such as
e.Graphics.DrawLine(0, 0, this.Width, this.Height);
or
Graphics grfx = e.Graphics;
grfx.DrawLine(0, 0, this.Width, this.Height);
Either way works. HTH
-Nick Parker
|
|
|
|
|
yeah but its not contained within the bitmap. I want the bitmap to be a container so to speak. It will eventually be moved outside this after testing and then just draw the bitmap
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
yeah but its not contained within the bitmap. I want the bitmap to be a container so to speak. It will eventually be moved outside this after testing and then just draw the bitmap
Not exactly sure what you mean by this Ista, check out my article Web Graphics On The Fly in ASP.NET[^] if you are still having questions about drawing to a Bitmap object. This articles covers the concept under ASP.NET but the idea is still the same whether or not it is for the web or a Windows application.
-Nick Parker
|
|
|
|
|
Like take MFC. to draw within a bitmap object you get a CDC object then call FillRect and such commands. Graphics object is just a context anyhow so how would I get a context to the bitmap?
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
Graphics object is just a context anyhow so how would I get a context to the bitmap?
Not exactly sure what you mean, are you having a problem with the following (which is within the article)? This ties the Graphics object to your Bitmap object.
Bitmap bmp = new Bitmap(this.Width, this.Height, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(bmp);
-Nick Parker
|
|
|
|
|
Your my hero Nick
thanks,
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
I got this sample from:
http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/cryptography/fileencrypt/encrypt.src&file=CS\fileencrypt.cs&font=3
Just wondering why there isn't a "key" in the code: You need a key for DES encryption don't you?
Here's the code snippet:
FileStream fs = new FileStream("EncryptedFile.txt",FileMode.Create,FileAccess.Write);
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
ICryptoTransform desencrypt = des.CreateEncryptor();
CryptoStream cryptostream = new CryptoStream(fs,desencrypt,CryptoStreamMode.Write);
cryptostream.Write(bytearrayinput,0,bytearrayinput.Length);
cryptostream.Close();
Thanks.
norm
|
|
|
|
|
Norm
If the Key property is not set in DESCryptoServiceProvider, it's auto-initialized to a random value. Since the example merely encryts and decrypts in the same session this doesn't really matter, but of course in a Real World Example (tm), the key would either be accepted from the user (as a password and then preseumably hashed by MD5 or something) or would be saved somewhere (eek!).
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Hey guys,
My friend and I just finished up an article describe a product of ours called TwainSharp. I was wondering if you guys wouldn't mind taking a look at the article to see if it would be a good fit to post on code project or not.
http://xsdev.net/tutorials/twainsharp/
Thanks,
Steven
|
|
|
|
|
or you explaining or selling. Twain coms are easy to use anyhow.
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
i am trying to write dg tablestyle grid column widths to the registry:
opening and creating keys is just fine, i can open regedit and see the keys.
it is when i try to assign a key value to the width of a column that i get the errors.
here is how i save the key:
<br />
Param.SetValue("IHDetailIDWidth",this.dgIssueHistory.TableStyles["IssueHistory"].GridColumnStyles["DetailID"].Width);<br />
and here is how i am trying to retrieve the key:
<br />
int ID = Param.GetValue("IHDetailIDWidth");<br />
when i don't run the second line of code, i get no errors, and it is writting to the registry just fine.
when i try to run the code to retrieve the values is when i get this error: Object reference not set to an instance of an object.
it highlights the section of code where i set the value though.
any ideas on what i'm doing wrong?
|
|
|
|
|
mikemilano wrote:
when i try to run the code to retrieve the values is when i get this error: Object reference not set to an instance of an object.
Are you creating your Param object before you call the GetValues() method?
For example:
MyAppSettings Param = new MyAppSettings();
...
Param.GetValue("IHDetailIDWidth");
Also, check in your GetValue methods code to make sure all objects referenced have been created.
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
i am creating a Param object before i call GetValues()
here's a little more of the code with the 2 methods i'm using.
I can comment out either one of the 'problem' lines, and the methods work fine, but it is when both are not commented that i get the object error.
private void CreateStyles(DataGrid dg)
{
DataGridTableStyle style = new DataGridTableStyle();
style.MappingName = "IssueHistory";
DataGridTextBoxColumn DetailID = new DataGridTextBoxColumn();
DetailID.MappingName = "DetailID";
DetailID.WidthChanged += new EventHandler(this.SaveIssueGrid);
RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software");
RegistryKey SC = softwareKey.OpenSubKey("SC");
if( SC != null)
{
RegistryKey Param = SC.OpenSubKey("Param");
if(Param != null)
{
DetailID.Width = (int)Param.GetValue("IHDetailIDWidth",50);
}
}
}
void SaveIssueGrid(object sender, EventArgs e)
{
RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software",true);
RegistryKey SC = softwareKey.CreateSubKey("SC");
RegistryKey Param = SC.CreateSubKey("Param");
Param.SetValue("IHDetailIDWidth",this.dgIssueHistory.TableStyles["IssueHistory"].GridColumnStyles["DetailID"].Width);
}
sorry for the big code post, but i've been working on this for hours with the same results.
|
|
|
|
|
Sorry for the late reply.
Since you know the keys/subkeys that you want to open, try and open/create them all at once. This gets rid of the multiple CreateSubKey/OpenSubKey statements which may be part of the problem.
I was able to get a small example working, that I hope will help you. Create a new C# Windows Application and place 2 buttons (btnRead and btnWrite), one label (label1) on the form. Add the Click events for the two buttons using the Designer Property Grid. Replace the generated Click events with the following code:
<code>
private void btnRead_Click(object sender, System.EventArgs e)
{
RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey(@"Software\SC\Param");
if ( softwareKey != null )
{
int x = (int)softwareKey.GetValue("IHDetailIDWidth", 50);
label1.Text = x.ToString();
}
}
private void btnWrite_Click(object sender, System.EventArgs e)
{
RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey(@"Software\SC\Param", true);
softwareKey.SetValue("IHDetailIDWidth",this.Width);
}
</code>
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|