|
We had some good discussion about lat/lon to distance conversion around this article.
Search CP for "GPS" and you can get more.
Best,
Jun
|
|
|
|
|
I suggest you become very familier with coordinate systems as you attempting to plot a coordinate system designed for a 3D sphere (ish) onto a 2D image. There are so many approaches depending on what you know about the image(s) that you need to study them all. Drawing a black blob on the image is the least of your worries.
I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerrywww.many-monkeys.com
|
|
|
|
|
I am developing a Save method in my business Process that allows me to Save the current object (scheme) and all it child collection objects, so that all I need to do is call bp.Save(Scheme) and it saves via reflection the entire tree.
I have a class "Scheme" which contains as properties a number of ReadOnlyCollections e.g. ReadOnlyCollections<milestone> and ReadOnlyCollections<partner>.
"Milestone", "Partner" and "Scheme" have a "Save" method and inherit from the same object (hcdbEntity).
I want use Reflection to call the "Save" method on the Scheme and each Milestone in the collection(becuase I have many other collections hanging off Scheme and Milestone) and don't want to hard code.
When I view the property info for the scheme I have to check for contains "ReadOnlyCollection" as the property.PropertyName holds "ReadOnlyCollection'1".
property.PropertyType = {Name = "ReadOnlyCollection`1" FullName = "System.Collections.ObjectModel.ReadOnlyCollection`1[[Business.Entity.Scheme.SchemeMilestone, Business.Entity.Scheme, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"}
The currentValue that gets returned by calling the Invoke method returns a list of the seperate items in the collection, but gives me no way to process them individually, or get a handle on them to call the Invoke method to call their Save method, or to be able to transverse down the tree to call collections further down as required.
private void DoA(HcdbEntityClass entity)
{
Type t = null;
System.Reflection.PropertyInfo[] properties;
object currentValue = null;
t = entity.GetType();
properties = t.GetProperties();
foreach (PropertyInfo property in properties)
{
Type a = property.GetType();
if (property.PropertyType.Name.Contains("ReadOnlyCollection"))
{
currentValue = t.InvokeMember(property.Name, BindingFlags.GetProperty, null, entity, new object[0], CultureInfo.CurrentCulture);
}
}
}
I am assuming that I need to return a object and use the generic.MakeGenericType to regenerate the collection type for the object. I have spent more than a day trying without sucesss, anybody done this sort of thing before and have a small sample;), or am what I am doing impossible.
nearly bald
Satvinder
|
|
|
|
|
Have you considered serialization rather than reflecting through your objects?
|
|
|
|
|
Why don't you just serialize it with the BinaryFormatter, SoapFormatter, or XmlSerializer?
:josh:
My WPF Blog[^]
|
|
|
|
|
You can define an interface so you do not have to check for the readonly collection. Then a simple is comparsion will let you know. Also reflection seems unncessary.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Cheers Guys, hadn't thought of that, What is beneifit of using the XMLSerilizer method as against using a Interface.
Satvinder
|
|
|
|
|
I am using the SendKeys class to switch to a browser and enter login details. This works fine in IE, but in Firefox, the letters are each typed twice (e.g. jjoohhnn), and Tab and Enter don't seem to work correctly.
The right window has the focus, because something is being entered, but not correctly, at least not in Firefox.
I use:
SendKeys.Send("john{TAB}doe{ENTER}");
Is this a problem with the code, or might Firefox be at fault?
Can anyone help?
Thanks!
|
|
|
|
|
I've had similar problems with SendKeys; generally it doesn't seem to work too well. I was able to get around some issues by doing different things with Send, SendWait, and adding an Application.DoEvents call after the Send.
In other words, I've found SendKeys to be unreliable. I suggest you look into sending window messages via the Win32 SendMessage API.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Messianic Instrumentals (with audio)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
hi all,
my operating system is english. and its date format is mm/dd/yy. but in turkish normal date format is: dd/mm/yy.
i wrote a code which stores some datas.
but if i search for some data in database according to date, it gives errors on computers which has turkish operating system.
the only solution is to change date format of such computers to english(us).
but do i have to do that ?
cant i do any trick so that it makes my program run on any computers (which has english or turkish operating systems )?
help please,
thanks in advance,
bye.
|
|
|
|
|
Use UTC format for dates in the database and searching
|
|
|
|
|
You should try using the current culture to get your date format. When converting a DateTime , you should do it using a particular culture. You can use System.Globalization.CultureInfo.CurrentCulture to determine the culture settings of the computer that the program is running on. Also, when you call Parse on a DateTime , use the IFormatProvider : http://msdn2.microsoft.com/en-us/library/kc8s65zs.aspx[^]
Logifusion[^]
|
|
|
|
|
Hi,
What is the difference between the following two lines?
string strTest = "";
string strTest = @"";
Thanks
|
|
|
|
|
Absolutely nothing. @ is only required to prevent escape characters from being interpreted.
|
|
|
|
|
Using the @ symbol allows you to do this
string strTest = @"C:\Program Files\MyApp";
rather than
string strTest = "C:\\Program Files\\MyApp";
|
|
|
|
|
It also allows you to do this:
string s = @"Well, maybe it's
better if you pick up a book
on C#. You'll get quick answers
on the forum, but they won't
be complete. And, sometimes,
they'll have some ""sarcasm"".";
Logifusion[^]
|
|
|
|
|
|
hi all,when i try to access my application(which contain nearly 1000 records) it raise this error message
"timeout expired.timeout period elapsed prior to completion of the operation or the server is not responding"
i dont know what is this prob and why this is happening...any idea.....?
Regards,
ayyp
-- modified at 9:31 Friday 7th July, 2006
|
|
|
|
|
Ok, you're using .NET remoting or sockets? If you're trying to bring over 1000 records in a single call, chances are it's timing out; it gives up after some period of time.
Instead of trying to bring over all 1000 records in a single call, serialize your records into a stream, then send that stream over byte-by-byte. This will be faster, more performant, and more scalable. You also shouldn't get any timeouts this way provided you don't try to stream too many bytes per call. Try streaming 65000 bytes per call, that's 65k and should work alright on high speed connections.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Messianic Instrumentals (with audio)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
sorry,i dont know how to do this can u send any sample code,.......that will help me.........plz.....
Regards,
ayyp
|
|
|
|
|
I have a DataView that contain multiple rows. It has a column say ColumnX that contains values composed of one or more words.
When i pass a multi-word value(one composed of two or more words) to the Find() method of the DataView for search in ColumnX, it just returns me the index of the row where a first word is matched in the ColumnX.
For example:
string searchvalue="Lossy Gray";
int index=dv.Find((object)searchword);
it return index of the row where a match for "Lossy" is found event though thre is row with "Lossy Gray".
I want only index of that row where all words are matched.
Thanks
|
|
|
|
|
How to disable "X" button at the top right of winform ?
Thanks...
|
|
|
|
|
|
Depend on how you would like for it to behave
1. Handle form closing event, set e.Cancel to true Or
2. Use Win32 API
<br />
const int SC_CLOSE = 0xF060;<br />
const int MF_BYCOMMAND = 0x0;<br />
<br />
[System.Runtime.InteropServices.DllImport("user32.dll")]<br />
public static extern IntPtr RemoveMenu(IntPtr menuHwnd, int position, int flags );<br />
<br />
public static void EnableApplicationClose( System.Windows.Forms.Form form, bool val )<br />
{<br />
IntPtr menu = GetSystemMenu( form.Handle, val ? 1 : 0 );<br />
if ( !val && menu != IntPtr.Zero )<br />
RemoveMenu( menu, SC_CLOSE, MF_BYCOMMAND );<br />
else<br />
{<br />
form.Enabled = false;<br />
form.Enabled = true;<br />
} <br />
}<br />
<br />
[System.Runtime.InteropServices.DllImport("user32.dll")]<br />
public static extern IntPtr GetSystemMenu(IntPtr hwnd, int bRevert);
Jup
-- modified at 9:03 Friday 7th July, 2006
|
|
|
|
|
Hi,
I am getting the above mentioned error while excuting the following simple example ( relating to dispose and finalize). Exact output is also attached after the program.
Can any body explain me the cause for this?
Thanks a lot in advance
//#PROGRAM
using System;
namespace test
{
//Base.cs
public class Base : IDisposable
{
private bool disposed = false;
private readonly int id;
public int ID
{
get
{
return id;
}
}
public Base(int theID)
{
id = theID;
}
public void Disp()
{
Console.WriteLine("You can run me after disposing{0}",id);
}
protected virtual void Dispose(bool disposing)
{
if (!disposed)
{
if (disposing)
{
Console.WriteLine("Base Cleaning up managed resources on {0}",id);
// Code to clean up managed resources
}
Console.WriteLine("Base Cleaning up unmanaged resources on {0}", id);
// Code to clean up unmanaged resources
}
disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
~Base()
{
//Following line gives error for object 2
Console.WriteLine("*** Finalize called on Base {0}", id);
Dispose(false);
}
}
//Derived.cs
public class Derived : test.Base
{
private bool disposed = false;
public Derived(int theID) : base(theID) {}
protected override void Dispose(bool disposing)
{
if (!disposed)
{
try
{
if (disposing)
{
Console.WriteLine("Derived Cleaning up managed resources");
// Code to clean up managed resources
}
Console.WriteLine("Derived Cleaning up unmanaged resources");
// Code to clean up unmanaged resources
}
finally
{
base.Dispose(disposing);
}
}
disposed = true;
}
}
//Test.cs
class Test
{
[STAThread]
static void Main(string[] args)
{
Derived object1 = new Derived(1);
Derived object2 = new Derived(2);
object1.Dispose();
}
}
}
//#OUTPUT
Derived Cleaning up managed resources
Derived Cleaning up unmanaged resources
Base Cleaning up managed resources on 1
Base Cleaning up unmanaged resources on 1
An unhandled exception of type 'System.ObjectDisposedException' occurred in mscorlib.dll
Additional information: Cannot write to a closed TextWriter.
Unhandled Exception: System.ObjectDisposedException: Cannot write to a closed TextWriter.
at System.IO.__Error.WriterClosed()
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count)
at System.IO.TextWriter.WriteLine(String value)
at System.IO.TextWriter.WriteLine(String format, Object arg0)
at System.IO.SyncTextWriter.WriteLine(String format, Object arg0)
at System.Console.WriteLine(String format, Object arg0)
at test.Base.Dispose(Boolean disposing)
at test.Derived.Dispose(Boolean disposing)
at test.Base.Finalize()The program '[3476] test.exe' has exited with code 0 (0x0).
Note that if you comment the lines relating object1, the program runs fine without any exception.
//#OUTPUT WHEN line 1 & 3 are commented in Main()
Derived Cleaning up unmanaged resources
Base Cleaning up unmanaged resources on 2
techno_adi
|
|
|
|
|