|
Hey I just did one (well a TypeCOnvertor for it)
private string pcname = ".";
[Category("Interface Options")]
[TypeConverter(typeof(ControlOptions.MachineConvertor))]
public string MachineName
{
get {return pcname;}
set {pcname = value;
sname = value;
}
}
[DllImport("Netapi32")]
private static extern int NetServerEnum(
string servername,
int level,
out int buffer,
int maxlen,
out int entriesread,
out int totalentries,
int servertype,
string domain,
int resumehandle);
[DllImport("Netapi32")]
private static extern int NetApiBufferFree(IntPtr ptr);
[StructLayout(LayoutKind.Sequential)]
class ServerInfo
{
public int platformid;
[MarshalAs(UnmanagedType.LPWStr)]
public string name;
public int majorver;
public int minorver;
public int type;
[MarshalAs(UnmanagedType.LPWStr)]
public string comment;
}
class MachineConvertor : TypeConverter
{
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
int eread, etot, buffer;
int l = 20;
int size = Marshal.SizeOf(typeof(ServerInfo));
int res = NetServerEnum(
null,
101,
out buffer,
size * l,
out eread,
out etot,
3,
null,
0);
int p = buffer;
ArrayList arr = new ArrayList(etot);
for (int i = 0; i < eread; i++)
{
ServerInfo si = Marshal.PtrToStructure((IntPtr) p, typeof(ServerInfo)) as ServerInfo;
arr.Add(si.name);
p += size;
}
res = NetApiBufferFree((IntPtr) buffer);
return new StandardValuesCollection(arr);
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
}
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
I'v designed a custom control for myself, (so it's a dll) and anybody could use it , but i want it to be only for me! I have heard somethings about .key files but i don't know what r them!
|
|
|
|
|
Specify the licenseProvider to use by applying a LicenseProviderAtribute to your control's class.
Create the License file in accordance with the implementation of the LicenseProvider that you are using.
In the constructor of your control, call LicenceManager.Validate to validate your license.
Dispose of your license in the control's Dispose method.
Hope this is helpful.
Andy Harman
|
|
|
|
|
Hi!
A little puzzle...
You create a C# Windows Forms project.
You name your form 'frmClient'.
You add another form (with right click in solution explorer)
and name it 'frmClientDetails'.
The user, when using the 'frmClient', press the button 'btnClientDetails'.
This button close 'frmClient' and instanciate 'frmClientDetails', to let
the user fiddle with the clients details.
The question I have, is what is the code to provide this functionnality?
In VB6 (god forgive me) it was simple ...
Unload frmClient
frmClientDetails.show
In C#, It obviously a most erronous approach...
Ok, I know its kinda simple, I'm sure, but please,
help me out in this simple problem!
Thanks!
Orlanda
|
|
|
|
|
im not quiet sure what you are shooting for... but if the components on your second form are already intialized i.e MyRichTextBox = new RichTectBox(); try FormClient.Hide(); FormClientDetails.Show();
this will keep the form loaded and just simply hide it from the user ...
Jesse M
|
|
|
|
|
Hi !
How do I know if the components on the second are initialized ?
thanks!
;)
Orlanda
|
|
|
|
|
the formxxx.Handle property is not null
|
|
|
|
|
Here is the code, Jessy, for my main form, the one that was created with the project, and the one that loads first.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace PersonnaInterfaceSystem
{
///
/// Summary description for frmPISmain.
///
public class frmPISmain : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox6;
private System.Windows.Forms.PictureBox picLogo;
private System.Windows.Forms.Button btnQuit;
private System.Windows.Forms.PictureBox pictureBox9;
private System.Windows.Forms.PictureBox picContacts;
private System.Windows.Forms.PictureBox picPersonnaliser;
private System.Windows.Forms.PictureBox picCommunauté;
private System.Windows.Forms.PictureBox picCourrier;
private System.Windows.Forms.PictureBox picHoraire;
private System.Windows.Forms.PictureBox picSmithers;
private System.Windows.Forms.PictureBox picErendering;
private System.Windows.Forms.Button btn;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public frmPISmain()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
hiden (too BIG!)
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new frmPISmain());
}
private void btnQuit_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void btn_Click(object sender, System.EventArgs e)
{
frmPISmain.ActiveForm.Hide();
frmPISContact.ActiveForm.Show();
}
}
}
Heres the error I get!:
************************
An unhandled exception of type 'System.NullReferenceException' occurred in PersonnaInterfacceSystem.exe
Additional information: Object reference not set to an instance of an object.
************************
I just added another form with a right click, and then I just gave it some controls and what not. I just want to do the c# equivalent of VB's:
Unload form1
form2.show
hellllp!
Thanks,
;)
Me again
|
|
|
|
|
Anonymous wrote:
frmPISmain.ActiveForm.Hide();
frmPISContact.ActiveForm.Show();
the following would be better :
frmPISmain.Hide();
frmPISContact childForm = new frmPISContact();
childForm.Show();
|
|
|
|
|
Hi,
I need to implement a toolbar with 32*32 icons on it.Also I want its height to be 50 pixels and the buttons to be centered verticaly on it. The toolbar is resized, but buttons are positioned on its top...
Any ideas how this could be done? I read the class info about ToolBar and ToolBarButton but didn't find the suitable property or method
Thanks in advance!
Gogou
|
|
|
|
|
Creating an image list with 32x32 images and assigning it to a toolbar sounds like it will do what you're after. If not, then your stated goal is not clear enough.
|
|
|
|
|
Hello,
How to create the following specific control:
I want to put the list of names.
User can select multiple names by clicking their check-boxes.
Also User should be able to hilight one/many names and user can move these names up/down with the arrow keys provided in the control.
How can I do this?
Thank you in advance,
Vikas
|
|
|
|
|
Why do you need a user control? You can do all that with a simple check listbox.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
whats the fastest Way to open a Large (7.83 Meg) Text File into a RichTextBox the current method i have is
<br />
FileStream fs = File.OpenRead(LoadFileOnStart);<br />
byte[] b;<br />
if(LoadFileOnStart.ToLower().EndsWith("rtf")|LoadFileOnStart.ToLower().EndsWith("doc")){<br />
fs = File.OpenRead(LoadFileOnStart);<br />
b = new byte[fs.Length];<br />
ASCIIEncoding temp = new ASCIIEncoding();<br />
while (fs.Read(b,0,b.Length) >= 0) <br />
{<br />
MainTextArea.Rtf = temp.GetString(b);<br />
}<br />
what do you recommend ? (this takes ruffly 3 to 4 seconds to open the 7.83 meg file on my comp)
Jesse M
|
|
|
|
|
Try this, instead:
using (StreamReader r = new StreamReader(LoadFileOnStart, System.Text.Encoding.Default))
MainTextArea.Rtf = r.ReadToEnd();
This will give you almost optimum I/O time, without doubling the memory size (you're doing it), but there will still be some overhead for the RTF loading and parsing.
I see dumb people
|
|
|
|
|
thanks alot =)...i got that sample from the .Net library...i new it was doubling.. cause i would alt+ctl+del in winxp too see my memory.. lol 220 megs of ram.. thats almost half my memory =).... anyways im gonna go try that....thanks alot
JTM..
i see dumb people too...
|
|
|
|
|
May I ask why you did
using (StreamReader r = new StreamReader(LoadFileOnStart, System.Text.Encoding.Default))
and not
StreamReader r = new StreamReader(LoadFileOnStart, System.Text.Encoding.Default)
Thanks.
Mark Sanders
sanderssolutions.com
|
|
|
|
|
to Mark Sanders :
You create an instance in a using statement to ensure that Dispose is called on the object when the using statement is exited. A using statement can be exited either when the end of the using statement is reached or if, for example, an exception is thrown and control leaves the statement block before the end of the statement.
The object you instantiate must implement the System.IDisposable interface.
<br />
Example<br />
using System.Drawing;<br />
class a<br />
{<br />
public static void Main()<br />
{<br />
using (Font MyFont = new Font("Arial", 10.0f), MyFont2 = new Font("Arial", 10.0f))<br />
{<br />
}
<br />
<br />
<br />
<br />
|
|
|
|
|
|
From MSDN:
RichTextBox.LoadFile Method (String)
Loads a Rich Text Format (RTF) or standard ASCII text file into the RichTextBox control.
public void LoadFile(
string path
);
Parameters
path
The name and location of the file to load into the control.
Why not use this method? I'm pretty sure MS would have implemented the "best" way for this. Have you tried it maybe? What speed are you getting?
Cheers
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
well im more concerned with memory then speed actually.. my program standsat about 14mb of memory when all its embeded images are loaded (.exe size is 600kb) but when i open this 7.83mb file of just text... all of a sudden the program is taking 50mb of memory... i know that before i close the stream reader i use the StreamReader.Flush() too clear its buffer.....anyways thats my concern... any ideas? there are no other codes be excuted when it opens... if you want the full source too look at ill send it k leppie ? (1150 lines)
Jesse M
|
|
|
|
|
jtmtv18 wrote:
i know that before i close the stream reader i use the StreamReader.Flush() too clear its buffer.....anyways thats my concern... any ideas?
There are some overloads to that function that can take a stream as a parameter. That mite help.
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
how can i apply that to this leppie ?
(LoadFileOnStart Comes from command line args via drag and drop (like notepad does when you click on a .Txt file)
<br />
if(LoadFileOnStart.ToLower().EndsWith("rtf")|LoadFileOnStart.ToLower().EndsWith("doc")){<br />
using (StreamReader r = new StreamReader(LoadFileOnStart,System.Text.Encoding.Default)){<br />
MainTextArea.Rtf = r.ReadToEnd();<br />
r.Close();<br />
}<br />
}<br />
i have been reading about memory optimization on msdn and i think i can rewrite this program agian and get better performance....i just wrote it so i could figure out command line args (i can now replace this program with notepad and it loads the file on startup through command args) i also wrote it too use reflection...which i figured out...anyways the point is it has no clear direction allthough the save function is actually really cool anyways.....
Jesse M
|
|
|
|
|
jtmtv18 wrote:
if(LoadFileOnStart.ToLower().EndsWith("rtf")|LoadFileOnStart.ToLower().EndsWith("doc")){
using (StreamReader r = new StreamReader(LoadFileOnStart,System.Text.Encoding.Default)){
MainTextArea.Rtf = r.ReadToEnd();
r.Close();
}
}
if(LoadFileOnStart.ToLower().EndsWith("rtf")|LoadFileOnStart.ToLower().EndsWith("doc"))
{
using (Stream r = File.OpenRead(LoadFileOnStart)){
MainTextArea.LoadFile(r, RichTextBoxStreamType.RichText);
r.Close();
}
}
?
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
Can anyone recommend a fast way to send large files to a webservice?
To my knowledge DIME does support chunking, but proxy service and SOAP do
not automatically. I think the solution here is to chunk files into
DIME records and then modify each SOAP message to append the record as an
attachment. I couldnt find any sample code, but the article below
discusses the modifying the soap envelope to add the dime record.
Is there other ways for the WSDK or SOAP3.0 make multiple HTTP calls for each record within a single DIME message?
Id be interested in any other comments on this ..
-- Ingram
http://www.microsoft.com/indonesia/msdn/insidewsepipe.asp#insidewsepipe_topi
c6[^]
Ingram Leedy
You can't depend on your eyes when your imagination is out of focus.
--Mark Twain
|
|
|
|