|
|
Sorry, but your link doesn't go anywhere...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I've written my own control in which I use three enumerations to set friendly values to Desgin-time properties.
public enum CornerStyles
{
Rounded,
Square
}
public enum Orientations
{
Vertical,
Horizontal
}
public enum Poles
{
Left,
Right,
Top,
Bottom
}
[Description( "Set the shape of the control's corners")]
[Category( "ColorTrackBar" )]
public CornerStyles ControlCornerStyle
{
set
{
this.cornerStyle=value;
this.Invalidate();
}
get{return this.cornerStyle;}
}
[Description( "Set whether the bar will be Veirtically or Horizontally oriented")]
[Category( "ColorTrackBar" )]
[RefreshProperties(RefreshProperties.All)]
public Orientations BarOrientation
{
set
{
this.barOrientation = value;
if(value==Orientations.Vertical)
this.MaximumValueSide=Poles.Bottom;
if(value==Orientations.Horizontal)
this.MaximumValueSide=Poles.Right;
base.Size=new Size(25,25);
trackRect=Rectangle.Empty;
this.Invalidate();
}
get{return this.barOrientation;}
}
[Description( "Select the side of the control to represent the maximum range value")]
[Category( "ColorTrackBar" )]
[RefreshProperties(RefreshProperties.All)]
public Poles MaximumValueSide
{
get
{
return maxSide;
}
set
{
switch(barOrientation)
{
case Orientations.Horizontal:
if(value==Poles.Top || value==Poles.Bottom)
{
throw new ArgumentException ("Since your Orientation is set to Horizontal, you can only select"+
" Left or Right for this property");
}
break;
case Orientations.Vertical:
if(value==Poles.Left || value==Poles.Right)
{
throw new ArgumentException ("Since your Orientation is set to Vertical, you can only select"+
" Top or Bottom for this property");
}
break;
}
maxSide=value;
trackRect=Rectangle.Empty;
this.Invalidate();
}
}
When I add this control to a windows form and build it I get no build errors if VS.NET currently has a .CS file open.
But when I'm looking at the form designer window and build it I get three errors in the TaskList window of VS.NET
:
The variable 'CornerStyles' is either undeclared or was never assigned.
The variable 'Orientations' is either undeclared or was never assigned.
The variable 'Poles' is either undeclared or was never assigned.
The odd thing is that these errors only occur when I have the Designer window open, so I think it might have something to do with how I'm exposing/using the enums ? Anyone have any Ideas ?
|
|
|
|
|
Hi all,
I'm writing some c# code to output some data in a format that a Fortran program can use. Yep, that's right, I did say Fortran
What I need is to write a floating point number into a string that is always 7 characters long, with a space prefixed before the number. For example:
1.34567
1234.67
.234567
I figured that this would be a simple job with String.Format(), like so:
double dNumber;
String.Format(" {0,7:g}", dNumber );
however, the output of this is something like:
91.3481478886182
141.785454332755
it seems that the alignment part of the format string is being ignored.
Can anyone tell me what I'm missing here?
Cheers,
Pete
|
|
|
|
|
hi,
if you don't mind please give little bit specific.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Umm, I'm not sure how much more specific I can be, but I'll try
Ok, I have a variable of type double, let's call it dNumber.
I want to create a string that represents that number. Let's call the string strFormatted.
The string must be formatted as follows:
the 1st character is a space
the next 7 characters represent the number
the string must always be 8 characters in length
here's some examples of correctly formatted strings.
12345678 <- characters in string
--------
1.34567
1234.67
0.23456
I figured the following function would do the trick:
string FormatToFortran( double dNumber )
{
return String.Format( " {0,7:g}", dNumber );
}
but unfortunately it doesn't. Format() seems to be ignoring the alignment section of the format string (the 7), and strings returned by FormatToFortran() are similar to the following:
130.312393712128
136.399493519436
121.295216530426
obviously, these aren't 8 characters in length.
So, I'm wondering what is wrong with my format string.
Hope that clarifies things. If not, feel free to ask away!
Cheers,
Pete
|
|
|
|
|
hi,
What i thought is correct. I got correct result.For me it's working properly.
i don't know why it is showing like that in your machine.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Argh! Really?
I'm using the VS 2005 beta. Maybe this is a bug in the .NET 2.0 runtime. Boo.
Just to double check, when you call FormatToFortran(), it /always/ returns a string of length 8, no matter what you put in?
Thanks for the help, by the way
|
|
|
|
|
OK, well I guess I managed to fix the problem by using the following format string:
String.Format(" {0,7:G6}", dNumber );
strange that the previous format string performed differently on different machines though.
|
|
|
|
|
I'm getting to grips with C#, but one thing still escapes me
If I have a number, 0x12345678, and I need to reorder it for some reason to 0x56781234, I could do this in C/C++
<br />
int i = 0x12345678;<br />
short *ps = (short*)&i;<br />
short s;<br />
<br />
s = ps [0];<br />
ps [0] = ps [1];<br />
ps [1] = s;<br />
i is then 0x56781234.
This sort of problem also pops up when a file has some binary data encoded in such a way that 3 bytes are used to represent a 4 byte int (PowerPoint does this if I remember correctly)
All attempts I've tried at this so far have resulted in unsafe code. I'd prefer a safe way, if this is possible.
Cheers
|
|
|
|
|
the only way i can recall now is to put your data in a string then manipulated it the way you want. after that cast it back.
i don't think there could be another way becuase you are accessing the memory directly here.
good luck!
|
|
|
|
|
How 'bout using the shift operators?
int i = 0x12345678;
i = (i << 16) + (i >> 16);
|
|
|
|
|
hi there,
i wonder if there´s a way to manipulate a window that i can only be dragged horizontal with mouse (i.e. vertical mouse movements are ignored).
any ideas? thanks, best regards
jkersch
|
|
|
|
|
|
well, i created a Bitmap as hwnd (a transparent images that resides on top of the screen (win32.getDC via native function in user32.dll) and i wonder how i can access window x and y position values and how i can get x and y of the mouse position.
is there something like a mousemove event with native win32 windows?
i have to bitmap hWnd to remain at the same x-position all the time.
and ideas?
thanks
jkersch
|
|
|
|
|
Has anyone used this? I have a very simple app that takes a xml file that I'd like to validate against a schema.
XmlValidatingReader(doc.InnerXml, XmlNodeType.Element, null);<br />
reader.ValidationType = ValidationType.Auto;<br />
reader.Schemas.Add(null, Server.MapPath(schema));<br />
reader.ValidationEventHandler += new ValidationEventHandler(ValidationHandler);<br />
while( reader.Read() );
It doesn't seem to matter what the xml is like, it never throws an exception. I've removed nodes in the xml and even passed in a xml file with a completely different structure and it passes right through.
|
|
|
|
|
try this
While objValidator.Read() And m_ValidationSuccess
End While
m_ValidationSuccess comes from validating call back
Bhaskara
|
|
|
|
|
Thanks for the VB
By implementing the ValidationHandler I can get any errors received during the validation. The problem is NO ERRORS are being generated.
|
|
|
|
|
I think I have discovered that the string function PadLeft in the 1.1 framework is broken. I experienced padding problems in my production app, so I built this simple program to test it. Form1 just contains a listbox name=listbox1 and the Items collection contains a string with 10 spaces in front of it.
private string[] texts = new string[5] {"Line One", "Line Two", "Line Three", "Line Four", "Line Five"};
private void Form1_Load(object sender, System.EventArgs e)
{
string item = this.listBox1.Items[0].ToString();
int len = 0;
for (int i=0; i<item.Length; i++)
{
if (item[i] != ' ')
{
len = i;
break;
}
}
for (int i=0; i<5; i++)
{
this.listBox1.Items.Add(String.Concat(texts[i], " unpadded"));
}
for (int i=0; i<5; i++)
{
this.listBox1.Items.Add(texts[i].PadLeft(len));
}
}
When executed, the padding eratically addes only one space and the third line is padded with nothing. All strings should have had 10 spaces padded in the left as per the framework documentation!!!
This signature left intentionally blank
|
|
|
|
|
theRealCondor wrote:
this.listBox1.Items.Add(texts[i].PadLeft(len));
This is your problem, PadLeft wants the total length, this would include what is already in the string which is why your results vary, each string length is different. The following works for me:
private void button_Click(object sender, EventArgs e)
{
string[] text = new string[]{"Line One", "Line Two", "Line Three", "Line Four", "Line Five"};
int len = 10;
char c = '.';
for(int i = 0; i < 5; i++)
box.Items.Add(text[i].PadLeft(len + text[i].Length, c));
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Re-reading the SDK I can see that they think they are stating this. Total length of string. Anyway --> this one gets inserted into the memory bank.
It is not the bugs that kill a programmer, it is the subtle errors that appear to be coded correctly.
Thanks Nick.
This signature left intentionally blank
|
|
|
|
|
Hi all!
Can anybody tell me where from to embed the Timeline control like one used in MS-Producer.I am studying DirectX 9.0 SDK documentation but havent found any clue yet.Any kind of help will be appreciated.
Thanks
|
|
|
|
|
I have a very typical problem. I am trying to create a user in activedirectory running in windows 2003 server. i am able to create user but when coming to setting password its not working.
the code :
String strPath = "LDAP://192.168.0.101:389/OU=100001,DC=Tserver,DC=local";
try
{
DirectoryEntry user = new DirectoryEntry(strPath, @"Tserver.local\administrator", "password", AuthenticationTypes.Secure | AuthenticationTypes.Sealing |AuthenticationTypes.ServerBind );
//create user
DirectoryEntry user = entry.Children.Add("cn=Test User", "user");
user.Properties["sAMAccountName"].Add("testuser");
user.Properties["sn"].Add("User");
user.Properties["givenName"].Add("Test");
user.Properties["description"].Add("Test account added with code.");
user.CommitChanges();
// User has to be saved prior to this step
user.Invoke("SetPassword", new string[] {"password1"} );
user.CommitChanges();
user.Close();
user.Dispose();
}
catch (Exception exx)
{
Response.Write("Exception: "+ exx.ToString() + " \n");
return;
}
Response.Write("Success: Password set.");
Error Description:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: The network path was not found.
Source Error:
Line 127:
Line 128: // User has to be saved prior to this step
Line 129: user.Invoke("SetPassword", new string[] {"princeton"} );
Line 130: user.Properties["userAccountControl"].Value = 0x200;
Line 131: user.CommitChanges();
Source File: c:\inetpub\wwwroot\adminlogin\pages\information.aspx.cs Line: 129
Stack Trace:
[FileNotFoundException: The network path was not found.]
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473
System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) +29
System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)
AdminLogin.Information.btnSave_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\adminlogin\pages\information.aspx.cs:129
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
I am looking for some help to solve this problem
I think this explains the problem well? Thank you in advance.
shambho Mahadeva
hap
|
|
|
|
|
99% of the time....when you get a System.Exception.FileNotFound it is due to the fact that you are trying to get an assembly and that assembly either does not exist on the target machine ... or it does exist but the assembly identifiers do not match.
For example: if you built your application and used System.Security.dll which had an assembly identifier of version 1.1.4322 but a service pack that your machine did not receive had version System.Security.dll at version 1.1.4325 then you would get that exception.
This signature left intentionally blank
|
|
|
|
|
But my dear friend i am able to create user add all other properties why not password. Is this System.Security.dll has some thing to do with setpassword native method alone. I dont know thats why i am posting this reply.
Kindly reply me
thanks in advance
anand
|
|
|
|
|