|
sebs2004 wrote:
If (z == 19 && iAmAHole)
what's z ? do you want to go through the cube in just 20 steps?
How do you know you're not just looping through it without getting to the other side?
I think first of all you need some criteria characterizing your end cube.
there are no facts, only interpretations
|
|
|
|
|
Oh, sorry.
x,y,z are coordinates within my cube.
z is depth, so I am pretty much only testing for top-to-bottom connections.
I need to either rotate the cube or change the end conditions later in order to be able to test for connections from the 2 other angles.
so, z==19 (Array is 0..19) && isHole indicate that I have reached a "hole" on the opposite side, ending my search.
Cheers
Sid
|
|
|
|
|
ok, so this part I don't understand:
else if ((AmIPartOfTheWay(cubeaboveme) || AmIPartOfTheWay (cubeleftofme) ||
....... (for each cube, just not the one I came from) )
return true;
it seems that the cubes repeat calling each other endlessly.
say u have a big cube of 2X2X2, and all top 4 cubes are holes, the other 4 not. than the code above returns true cause each one of the top ones has a neighbor hole, right?;)
there are no facts, only interpretations
|
|
|
|
|
I have an mdi container form that contains a tab control down the left and when a tab is clicked it loads a form to fill the reaming area inside the mdi form. The problem I have is that when it loads you can see the form beign drawn and it looks aweful. Is there anyway that the form can be loaded without it showing each control being drawn?
|
|
|
|
|
Indeed you can
at the start of your code add
this.SuspendLayout()
..and after everything's done..
this.ResumeLayout(true)
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
I have the following method to retrieve user details from Active Directory.
public StringCollection getUserDetails(string user)
{
StringCollection coll = new StringCollection();
try
{
DirectorySearcher search = new DirectorySearcher(obEntry);
search.Filter = "(SAMAccountName=" + user + ")";
search.PropertiesToLoad.Add("Name");
search.PropertiesToLoad.Add("displayName");
SearchResult result = search.FindOne();
if( result != null )
{
DirectoryEntry dirEntry = result.GetDirectoryEntry();
foreach(string key in dirEntry.Properties.PropertyNames)
{
// Each property contains a collection of its own
// that may contain multiple values
foreach( object propVal in dirEntry.Properties[key] )
{
string[] Names = {key + "=" + propVal};
coll.AddRange(Names);
}
}
}
return coll;
}
catch( Exception ex )
{
throw new Exception("User not authenticated: " + ex.Message);
}
}
All my output is returned into a stringcollection as shown below.
<string>givenName=Reinier
<string>homeDrive=M:
<string>instanceType=4
<string>lastLogoff=System.__ComObject
<string>lastLogon=System.__ComObject
The problem i have is that some values are returned as System.__ComObject. I would like to see the value there too. Is there a way to iterate through System.__ComObject and return it's values(s) ? Somewhere i have to check propVal for it's type and read out the values if type is System.__ComObject ??
Hope someone can put me on the right track !
|
|
|
|
|
The date properties are returned via the IADsLargeInteger[^] interface, which doesn't seem to have been included in the .NET framework. You will need to manually import it to get the data:
using System;
using System.DirectoryServices;
using System.Runtime.InteropServices;
public sealed class AdsiUtils
{
private AdsiUtils() {}
[
ComImport,
Guid("9068270b-0939-11d1-8be1-00c04fd8d503"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)
]
private interface IADsLargeInteger
{
[DispId(2)] int HighPart { get; set; }
[DispId(3)] int LowPart { get; set; }
}
public static DateTime AdsDateValue(object value)
{
try
{
IADsLargeInteger v = value as IADsLargeInteger;
if (null == v) return DateTime.MinValue;
long dV = ((long)v.HighPart << 32) + (long)v.LowPart;
return DateTime.FromFileTime(dV);
}
catch
{
return DateTime.MinValue;
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hi Richard, thanks for your answer although i'm not there yet. I added the code to my class and get this message while compiling:
C:\Inetpub\wwwroot\ADSI\ADSI.cs(54): The type or namespace name 'IAdsLargeInteger' could not be found (are you missing a using directive or an assembly reference?)
C:\Inetpub\wwwroot\ADSI\ADSI.cs(55): The name 'v' does not exist in the class or namespace 'ADSI.ADSI'
C:\Inetpub\wwwroot\ADSI\ADSI.cs(56): The type or namespace name 'v' could not be found (are you missing a using directive or an assembly reference?)
Any idea what i'm missing here ?
|
|
|
|
|
Sorry - there was a typo in the code!
Change the first line within the try block to:
IADsLargeInteger v = value as IADsLargeInteger;
I've modified the original post to show the correct code.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
wow, works great ! this great, thanks a lot Richard !
got one more question though I also have types like these
objectGUID = System.Byte[]
objectSid = System.Byte[]
Would you happen to know how to read data form System.Byte[] ?
|
|
|
|
|
The objectGUID is simple - just call:
Guid objectGuid = new Guid((byte[])entry.Properties["objectGUID"].Value);
The objectSid is a bit more complicated. With a little help from PInvoke.net[^], the following should work:
[DllImport("kernel32.dll", SetLastError=true)]
private static extern IntPtr LocalFree(IntPtr hMem);
[DllImport("advapi32", CharSet=CharSet.Auto, SetLastError=true)]
private static extern bool ConvertSidToStringSid(
[MarshalAs(UnmanagedType.LPArray)] byte[] pSID,
out IntPtr ptrSid);
public static string FormatSid(byte[] sid)
{
if (null == sid || 0 == sid.Length)
throw new ArgumentNullException("sid");
IntPtr ptrSid;
if (!ConvertSidToStringSid(sid, out ptrSid))
throw new System.ComponentModel.Win32Exception();
try
{
return Marshal.PtrToStringAuto(ptrSid);
}
finally
{
LocalFree(ptrSid);
}
}
...
string objectSid = FormatSid((byte[])entry.Properties["objectSid"].Value);
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
string select = "Id = " + id + " AND Address = "+address+ " AND Record ="+record;
datarow[] rowa = db.var.Select(select);
id, address are variable int's and record variable string.
the problem here is that the integers are accepted but the string is not. it throws an exception: "Cannot find collumn[schools]". schools is the value of the string. the collumn name must be Record and string record is a value of a row that belongs to that collumn.
if i make a int of record, then i will accepted. But it doesn't accept a string... why?????????????
|
|
|
|
|
Your SQL WHERE command is translated to this: Lets say Id=2, address=1, record="hello":
Id=2 AND Adress=1 AND Record=hello
This is actually saying that Column [Record] should de equal to Column [hello]. That's why ur getting that error. The correct WHERE command should state that hello is a string:
Id=2 AND Adress=1 AND Record='hello'
Thus ur filter command must be:
string select = "Id = " + id + " AND Address = "+address+ " AND Record ='" + record + "'";
|
|
|
|
|
ooooww thankss. yes it worksss finee noww..
|
|
|
|
|
In my C# code i have a variable EmbedTextBox.Text = this.OpenFileDialog;
I want to use that same variable's contents in my HTML code e.g.
"<html><value=mms://server/EmbedTextBox.Text></html>"
which does not work.
is there an easy of doing this?
|
|
|
|
|
You need to programatically change the content of "value" during the creation of the HTML-Code.
Remember, even if you have a PHP, ASP or whatever script, it still needs to feed the browser valid HTML-code. So, what the server reads:
<?PHP
echo "<html><head>"
echo "<title>" + $ver + "th version of my site</title></head><body></body></html>"
?>
and sends
"<html></head><title>7th version of my site</title></head><body></body></html>"
Basically, in your code, the browser probably understands that it should fill the textbox with "mms://......." as a string, not with the content behind that link. This you would have to do via client- or server-side scripts, preferrably server-side ones.
Cheers
Sid
|
|
|
|
|
Hi all,
I have a question on c# dll loading in .Net.
Let say two dlls, dll A and dll B, object 1 in dll A
refers to an object 2 in dll B. So, if the object1
is running and invoke object 2 in dll B, will the whole dll B being loaded in the memory or just the
object 2 being loaded ? I ask this question coz I concern on the amount of memory usage.
Thanks
|
|
|
|
|
Hai pyhtang,
At runime, while obj in dll A , refers to obj in dll B,,,, only that particluar object will get loaded in to memory.
A dll is nothing but a class library, hence a dll can contain multiple classes. instatntiating a single class will load only that particlar object into memory.
Regs,
Manivannan.P
|
|
|
|
|
|
Why!?!
I found this interesting bit of text in the C# specification at MSDN here[^], when trying to find out why my code isnt working:
First, the set of all accessible members named N declared in T and the base types of T is constructed. Declarations that include an override modifier are excluded from the set.
Can anyone explain to me why? It seems illogical.
Consider the following:
class A {
public virtual int Foo () { return 1; }
}
class B : A {
new int Foo () { return 2; }
static void Main () { System.Console.WriteLine (new C ().Foo ()); }
}
class C : B {
public override int Foo () { return 3; }
It outputs 2, because the code is executed in B. If B didn't define a Foo() method, it would output 1. Logically (well, to me anyway) it should output 3!
--
Dave
|
|
|
|
|
Hi David.
w.r.to, the code sample,,,,
class B : A {
new int Foo () { return 2; }
static void Main () {System.Console.WriteLine (new C ().Foo ()); }
}
This is an apt example for Hiding Methods. The statement 'new int Foo () { return 2; }' in Class B , informs the compiler that the base class member has been hidden and hence it continues executing the method in B.
w.r.to the statement,
If B didn't define a Foo() method, it would output 1....check out it would output only '3'.
I hope is this what you wanted to clarify.
regards,
Manivannan.P
|
|
|
|
|
I'm having problems trying to figure out where to put an Equals override so ArrayList.Contains(object) will work with a class i have made.
this is what i have.
public class CField
{
public string m_FieldName;
...
}
public class CClause
{
public ArrayList alCField = new ArrayList();
...
{
and i want to do this
if(clause.alCField.Contains(string aFieldName)){...}
This ^^ if statment always fails. I've tryed the folowing in CField:
public override bool Equals(Object obj)
{//Check for null and compare run-time types.
if (obj == null || GetType() != obj.GetType()) return false;
CField f = (CField)obj;
return (this.m_FieldName == f.m_FieldName);
}
My way of thinking says that the abouve if should call the override but it dosn't so i'm stuck. I'm starting to miss the old STL.
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
An ArrayList doesn't support searching based on a key (in your case, m_FieldName).
You should implement IComparable and use another container, e.g., a SortedList, wich will allow you to search based on a key.
Yes, even I am blogging now!
|
|
|
|
|
I realized the problem was somewhere else in the code
I did want to point out that while ArrayList doesn't support a key search My_al[keyName] it has two search options, Contains which leverages off of Equals, and BinarySearch which leverages off of the IComparable interface.
Is there an article here that explains how to override Equals and IComparable. The help on MSDN doesn’t give a complex example.
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
is there a way i can read a file that was create with print to file (the pcl file) and do a print preview on it
thanks
chad
|
|
|
|