Diamonddrake 397 Master Poster

It's different on a per language basis, but in most languages:

Braces {} are generally for object notation and grouping.
they define an object. Such as when you use them to define a class, enum, stuct ect.
Or for enclosing a memeber or code group, such as a method or property.

In your example:

string[] Meats = { "Roast Beef", "Salami", "Turkey", "Ham", "Pastrani" };

This is an object notation. It's not short hand specifically for creating an array, you can actually create any object this way.

public class myobject
    {
      public string Title {get; set;}

      public bool isInit {get; set;}
    }

    //create shorthand:
    myobject mo = new myobject(){Title="mytitle", isInit=false};

Brackets [] are indexers
when an object can be indexed, the [] supply a selector for the index.
When decaling a type, adding [] to the end is stating that you want an indexable array.
The only other time you will see brackets in C# is for flags. Sometimes when you define a class or interface you will want to flag the members for serialiaztion such as if you wanted to ignore a property in a class you would use the [XmlIgnore()] flag.

public class myobject
    {
       [XmlIgnore()]
       public bool ShipmentSpecified
       { get; set; }
    }

Parentheses () are used in math, casting, grouping, and calling.

Mainly () are for parameters. They are used to denote a situation where a parameter could be passed or recieved. This is most …

iConqueror commented: thankyou that was very helpful +1
Diamonddrake 397 Master Poster

63e834471f9c1463ee1caed517a7fbf1

I'm working on an a windows phone project where I need to support fully transparent backgrounds in my controls to overlay ontop of dynamic image. I want to use this "new item" path I created to show how many updates an item has. I attached an image showing the effect I'm trying to create. The number needs to be dynamic. I've trying combinding geometries, but I'm having trouble figuring out how to even get started converting both my xaml defined path and text into geometries, and then combinding them with a xor to create the exclusion. It seems like there would be an easier way. I'm open to suggestions.

Thank you.

Diamonddrake 397 Master Poster

SetForgroundWindow doesn't work the way you think, it used to in older versions of windows, but in xp service pack 3 and newer it just flashes the window on the taskbar unless the parent application of the window already has focus.

This was added to keep windows from poping up and taking focus while a user was typing or playing a game.

So what you have come up with, setting the windows state, is the correct way to do it, you can't just call setforgroundwindow, it won't work, because it was redesigned not to.

Diamonddrake 397 Master Poster

the United States Post Service website has a web api for zipcode look up, so I guess I have all the information I need now, this is a very complicated solution, but it is a solution none the less, thank you for your help everyone.

Diamonddrake 397 Master Poster

our zip codes aren't that complicated :) well basically its a 5 digit number, but then again, they are able to be fined tuned down to a smaller area via another 5 digit number hyphenated onto that one, but only carriers seem to know where to get that information from, its not listed anywhere I've ever seen.

on a further note, I didn't even think about using the zip to find out what the city was. Hrm, I wonder if there is a API for that online or something.

Diamonddrake 397 Master Poster

yes, its always a 5 digit us postal zip code.

Diamonddrake 397 Master Poster

I thought about using regular expressions and look for "some letters" space "some letters" space 5numbers to get the location, but that's where the possibility of city names with spaces like those above, I'm not all that good at regular expressions is there a way to check for San, St, Saint ect optionally in an expression like that?

Diamonddrake 397 Master Poster

none of them are fixed The order is always the same, but the length, start and end index all depend on the length of the status which could be any of several different statuses.

Diamonddrake 397 Master Poster

I am working on an application where I am presented a string that has some information, its always in the same order, but not always the same length with no special separators, here is an example

"May 30 10:08 am ARRIVAL AT UNIT WILMINGTON DE 19850"

I need to be able to take these string and separate them into 3 parts

Time = "May 30 10:08 am";
Status = "ARRIVAL AT UNIT";
Location = "WILMINGTON DE 19850";

the location will always be a city but might have a space in it like "SAN JOSE"
this is for a package tracking application, I hit a snag on this, just not sure how I should do it, or how even to do it.

I could loop through all the months and call contains, if its found, save it and remove it from the string. the get the next 12 characters and append it to month and have the time. I'm not sure if that's the best practice, but then I have no idea how to separate the status from the location.

ideas friends?

Diamonddrake 397 Master Poster

turns out I can serialize, in the schema I needed maxOccurs="unbounded" and now everything works fine. Visual Studio has a nice Schema generator built into, I guess I should have looked there first :)

XSD.exe still used to generate the classes though.

Thanks

Diamonddrake 397 Master Poster

I am working on a little USPS tracking class, very simple calls web api returns xml, parses the xml to an object, passes that object back via an event.

for some reason I can't seem to get the XML to parse correctly. I there are an unknown amount of a certain node in the root node, so deserialization is out, but using XMLReader I can only get the first value from the TrackDetails nodes.

Here is the xml example

<?xml version="1.0"?>

<TrackResponse><TrackInfo ID="EJ958088694US"><TrackSummary>

Your item was delivered at 1:39 pm on June 1 in WOBURN MA 01815.

</TrackSummary><TrackDetail>

May 30 7:44 am NOTICE LEFT WOBURN MA 01815.

</TrackDetail><TrackDetail>

May 30 7:36 am ARRIVAL AT UNIT NORTH READING MA 01889.

</TrackDetail><TrackDetail>

May 29 6:00 pm ACCEPT OR PICKUP PORTSMOUTH NH 03801.

</TrackDetail></TrackInfo></TrackResponse>

no problem getting the ID from the attribute or the track summary, but I can't seem to get all the trackDetails, I get the first one, but never any of the others. I don't do much xml parsing and normally I just use serialization. So this is proving problematic for me.

some Code i have tried

using (XmlReader reader = XmlReader.Create(new StringReader(e.Result)))
  {
                reader.MoveToContent();

                    while (reader.Read())
                    {
                        if (reader.IsStartElement())
                        {
                            switch (reader.Name)
                            {
                                
                                case "TrackInfo":
                                    reader.MoveToFirstAttribute();
                                    Pack.PackageID = reader.Value;
                                    break;


                                case "TrackSummary":
                                    Pack.TrackingSummary = reader.ReadElementContentAsString();
                                    break;

                                case "TrackDetail":
                                    Pack.TrackingDetails.Add(new TrackingDetail(reader.ReadElementContentAsString()));
                                    break;

                                default:
                                    reader.Skip();
                                    break;
                            }
                        }

                    }

or

using (XmlReader reader = XmlReader.Create(new StringReader(e.Result)))
  {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        { …
Diamonddrake 397 Master Poster

in silverlight there is no collectionsbase, but the List<T> is inheritable. So i created an object that inherited from List<T> and replaced the add method with one that added itself to the objects add via a property I added to the type I strongly typed it the list to contain.

wow, that sounded complicated. Either way it worked. had an issue with serialization though, because this created a circular reference, but using the attribute [XMLIgnore()] I managed to have everything work the way i wanted it.

Diamonddrake 397 Master Poster

I can easily get the index when i have a reference to the list. but from inside the list item I do not have a reference to the list.

public partial class Form1 : Form
    {
        List<MyObject> list;
        public Form1()
        {
            InitializeComponent();
            CreatingList();
            GetIndex();
        }

        private void CreatingList()
        {
            list = new List<MyObject>();
            MyObject m1 = new MyObject(1, "one");
            MyObject m2 = new MyObject(2, "two");
            list.Add(m1);
            list.Add(m2);
        }
    }

    class MyObject
    {
        public int id { get; set; }
        public string name { get; set; }

        public MyObject(int _id, string _name)
        {
            id = _id;
            name = _name;
        }

        public int MyIndex
        {
          get
            {
              return thisobjectsParentCollection.IndexOf(this);
            }
        }
    }

I guess I could create a custom IEnumerable object that added its self to a property of each object added to it. But I really don't want to do that.

Can anyone see another way?

Diamonddrake 397 Master Poster

I have an object that i use in a generic list, i need to expose a property in that object that will return the index position of the object in the list plus one.

example

Items in list
myobject1
myobject2
myobject3

myobject2.indexValue would equal 1

any idea how I can acomplish this reliably?

Diamonddrake 397 Master Poster

Its exactly the same. The only problem is that people are behind routers, firewalls, and other systems that make a direct connection more difficult.

So what you end up having to do is create a server somewhere that is directly connected to the internet, that way all the clients can connect to it without having to forward ports and all that jazz.

It's really not worth the effort unless you have the resources to keep up a dedicated server, and really want to use such a chat application.

Diamonddrake 397 Master Poster

Here's an even simpler example. You did unnecessary steps that can be avoided, even though yours is a good example. :)

Note: "Control" is the name of the object you want to move, so link it up in the Designer area first.

private Point pointMouse = new Point();
private Control ctrlMoved = new Control();
private bool bMoving = false;

private void Control_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
	//if not left mouse button, exit
	if (e.Button != MouseButtons.Left)
	{
		return;
	}
	// save cursor location
	pointMouse = e.Location;
	//remember that we're moving
	bMoving = true;
}

private void Control_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
	bMoving = false;
}

private void Control_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
	//if not being moved or left mouse button not used, exit
	if (!bMoving || e.Button != MouseButtons.Left)
	{
		return;
	}
	//get control reference
	ctrlMoved = (Control)sender;
	//set control's position based upon mouse's position change
	ctrlMoved.Left += e.X - pointMouse.X;
	ctrlMoved.Top += e.Y - pointMouse.Y;
}

This is practically the same code as the OP, only you used a point instead of two ints (which is a good idea but to each their own)

I would like to point out when you declared the ctrlMoved variable, you set it to a "new control" since you are using that variable to hold reference to existing controls, That is unnecessary and you are creating an orphaned object. Same thing with the pointMouse variable. You immediately assign it to reference e.location so the "new point" is never used, its just orphaned …

Diamonddrake 397 Master Poster

It failed to upload for me too, anyway, I still can't see what you didn't understand about this. but I made the changes, and now it works.

http://www.megaupload.com/?d=QAYT0IL0

I think I am done helping with the application. I have a lot of things to do, good luck.

Diamonddrake 397 Master Poster

My email provider refused to send the attachment because of its file size, I have uploaded it to megaupload you can find it here

Diamonddrake 397 Master Poster

upload your project to the post using the advanced editor and I will take a look at it.

Diamonddrake 397 Master Poster

Ok, putting all your logic code that was in the on paint into the timer event was very simple, just a copy and paste and it worked without a fuss. still flickered with a bacground and then I found that you were invalidating the panel from the paint event (you should never do that) So i removed that call from the logic loop and now the background doesn't flicker.

the move speeds need to be modified but other than that, it does seem to work.

I'll email it to you.

Diamonddrake 397 Master Poster

I am downloading it now, I taught myself through books, trial and error, codeproject articles and from help of people here on daniweb. C# is an easy language. Programming is a challenge. I guess that's why I do it.

Diamonddrake 397 Master Poster

if you are still using the serialization class that I provided for you. then you are doing it all wrong. Don't worry about the xml. its created automatically. Just edit the generic list.

in this code example http://www.daniweb.com/forums/post1420401.html#post1420401

I explained the changes that you needed to make, why have you not followed it? It is not paste in code, but it explains what you need to do.

you have a list that HOLDS all your data, then you have a listview that DISPLAYS all your data. when you remove the data from the LISTVIEW you need to also remove it from the LIST that holds the data.

the easiest way would be when you add the data to the listview that you set the listview item's tag property to a reference tot he object in the original list that way you can remove the data from the list using the listitems tag property.

Just try to do what I am telling you. If after 2 hours, you still don't get it. Post your entire project as it is and I will edit it to work.

I really hate to see programmers give up like this.

Diamonddrake 397 Master Poster

if you post your project, I will take a look at it. See if I can integrate it for you.

I didn't have the finances to go to school, but hopefully I will soon. I'm 23, I see the software I marketed to be a sign that I have what it takes, but there is a long way for me to go. Really I should get into games, that seems to be the future of the programming industry. That's all that really sells these days, I'm thinking of getting into programming for the android and windows phone 7. Maybe I can make some money. :)

Diamonddrake 397 Master Poster

I posted an explanation. ALL you have to do is when you remove the item from the listview, find that item in the generic list of objects and remove it there. I don't understand what you don't get.

Diamonddrake 397 Master Poster

The error is due to a namespace conflict. at the top of your class the using statements that are in place are there to limit the amount of typing you have to do. Since you have a "system.windows.forms" and a "system.threading" using declarations, in order to disambiguate you will have to use the full namespace to the timer basically you just have to use

System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();

The game will still likely be slow, just because its a GDI and winforms control based game. But it should drastically speed the game up. It would be better if you used directX or XNA but both of which would require a total rewrite and you would have a lot of learning to do before you could actually start writing reliable code.

Programming is a great hobby, but as the human condition goes, there will always be someone way better than you, no matter how good you are. And with programming, you can be a great great at one thing, and suck at another. I love programming and have enjoyed doing it for the past 3 years or so, started as a hobby, still is for the most part. I sold an automation app to a multi-international corporation that designs and manufactures stoves so technically I am a pro :) but only technically. lol

The guys to look out for here in the C# department are sknake, ddanbe, adatapost, and Ryshad many people make good contributions these are …

Diamonddrake 397 Master Poster

I see, it appears that the all your trouble stems from the fact that you are doing all your game logic in the paint event.

All your frame advance type game logic should be handled in a timer event or something, NOT the panels paint event.

every time anything moves or changes in or over the panel, the paint event gets called, and it should ONLY handle DRAWING for the panel. Since you are using pictureboxes for most of your characters and such they handles thier own redraws, thats the only reason this works at all.

create a timer timer that fires how ever many millisecons you want your frame difference to be, and on its Tick event put practically all that code that you have in the game panel's tick event. then when the game starts, be sure to start the timer and then your panel's background should be fine.

during that paint event, that's what draws the background on the panel, its sealed in the Panel class and happens before anything you added there, but it isn't update til all that's code runs. Pain events are for PAINTING! remember that and you will see a big performance increase.

More on XNA, xna is in C#, but supports 2 different drawing systems, a specialed managed directX which lets you use the client's graphics card to make the game run faster. and then a 2d drawing system that is 1000 times more efficient than using …

Diamonddrake 397 Master Poster

This is more complicated than you would think, Are you invalidating the entire control surface? or just what may have changed? are your picturebox's userdrawn with a transparent background? or just regular pictureboxes? are you drawing directly to the surface of the panel using its paint event? or are you moving controls in front of it?

The root of the problem would be that you are refreshing the entire panel. Requiring it to be redrawn. GDI+ is slow. That's why games are usually written in XNA for C# or DirectX, openGL, ect. If you are going to use GDI+ for a game, you need to make sure that you only invalidate areas that change, not entire sets of controls or the entire game surface at every update.

for example, if the top left corner 20px wide and 10px tall displays the score, then that information might need to be updated often. If that information is on its own control, then that control will handle invalidating it's self. But if that data is drawn onto the panel, then it should be manually invalidated, but you should pass the rectangle that contains the area to be invalidated to the invalidate method.

Kind of long winded, I hope you got something out of that.
for any other assistance, we will need to see some code to know what we are dealing with.

Diamonddrake 397 Master Poster

OK, turns out that the problem is more to do with the desktop being the root of the namespace yadda yadda relative to the current desktop. It involves a bunch of relative paths, But I found another way.

I still have much testing to do to get the XP compatibility reliable enough to use, once I get it settled. I will post some snippets or a CodeProject article.

If anyone has any further information on this subject. Please do post it.

Diamonddrake 397 Master Poster

Ok, it works in VISTA and SEVEN only. XP needs a different api, i found some code that seems to work

Resolved. SHChangeNotify with SHCNE_RENAMEFOLDER doing this. Thanks to all. Here is a source.
1) Define Pinvoke functions:

[DllImport("shell32.dll")]
public static extern Int32 SHParseDisplayName( [MarshalAs(UnmanagedType.LPWStr)] String pszName, 
IntPtr pbc, out IntPtr ppidl, UInt32 sfgaoIn,  out UInt32 psfgaoOut);

[DllImport("Shell32.dll")]
public static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);

2) Method to notify system about new desktop folder path:

public static void ApplyNewDesktopPath(string OldDesktop, string NewDesktop)
{
     uint iAttribute;
     IntPtr oldPidl;
     IntPtr newPidl;
     SHParseDisplayName(OldDesktop, IntPtr.Zero, out oldPidl, 0, out iAttribute);
     SHParseDisplayName(NewDesktop, IntPtr.Zero, out newPidl, 0, out iAttribute);
     SHChangeNotify(0x00020000, 0x1000, oldPidl, newPidl);
}

3) Refresh desktop to show new content:

public static void RefreshDesktop()
{
    SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
}

it will let me change the desktop folder, but won't let me change it back to the regular desktop. I have to kill explorer to get the refresh.

i think it might have to do with not releasing the pidls properly. i'm tring to figure it out, any ideas would be appreciated.

kvprajapati commented: :) useful! +11
Diamonddrake 397 Master Poster

I seemed to have found my answer :) But I can only test on Windows 7 and vista because I don't have an XP Machine. Can someone with an XP machine test this snippet for me and tell me if it works.

class Program

    {

        public static class KnownFolder

        {

            public static Guid Desktop = new Guid("B4BFCC3A-DB2C-424C-B029-7FE99A87C641");

        }

 

        [DllImport("shell32.dll")]

        private extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, IntPtr token, [MarshalAs(UnmanagedType.LPWStr)] string path);

        [DllImport("Shell32.dll")]

        public static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);

 

        static void Main(string[] args)

        {

            string newPath = @"path to new desktop folder";

            int flags = 0;

            SHSetKnownFolderPath(ref KnownFolder.Desktop, (uint)flags, IntPtr.Zero, newPath);

            SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);

        }

    }
Diamonddrake 397 Master Poster

I am working on a combination productivity and source/version control app. One of the features i would like to add might sound crazy, but I would like to substitute the User's windows Desktop folder with the project files "Working Directory" That way, until the the software is exited, or the project is closed. The windows desktop, the easiest location to find regardless of what you are doing, will be your project folder (If only I had a magic desk that only showed me stuff I needed when I needed it :)

In windows vista and 7 its easy to accomplish this in explorer, in the properties for special folders like the desktop there is a location tab that allows you to change the folder, it works immediately and very well. With the exception of renaming the folder you set to Desktop, it works exactly how I would like it too.

But I can't seem to find out how to accomplish this programmatically. I have tried changing the "shell folder" HKCU registry entry, and although this works for everything but the literal desktop. I can't seem to get the actual desktop desktop to display the changes.

Anyone have any ideas?

Diamonddrake 397 Master Poster

One thing about choosing the method of sending email is what will be sending the mail. Its important that if this is a mail application, and you intend to allow the end user to modify the serer settings to match their own info, or you intend to use this for personal use only. Then its fine to use this method.

But if you are creating a production application and you expect to distribute it. Yahoos not going to be happy with you sending 100,000 smtp relays on your free yahoo account, plus the messages will always be traceable back to your account, and you will be liable for that.

If you are, for example, adding a call home system in an application, to report errors, or maybe a feedback mailer. Then a good system would be to have the desktop app post some vars to a script on a webserver somewhere and have the server either handle the smtp server setup so you can change it easily and it will reflect in all the applications that use it. Or have the webserver its self handle the SMTP. all asp.net web servers have smtp built in. They always suggest you don't use it, and VS will give you warnings that its depreciated. But it works, if you just use System.Web.Mail.SmtpMail.Send(message) on a asp.net site. It will just send it. No questions asked. Then you can set a response and have your desktop app check for …

Diamonddrake 397 Master Poster

If the items in the list box get hightlight when you hit the keys this sounds like that form isn't getting your keydowns, but the listbox is because its focused. In the designer, click on the form's title bar to select it, then in the property inspector set the form's "KeyPreview" property to true. This will make the parent form get the key event instead of just the selected control in this case the listbox.

That should do it.

jonsca commented: Nice one +6
Diamonddrake 397 Master Poster

There is a dozen ways you could go about this, if you want it to be really smooth, then you might want to do your UI in directX, openGL, or XNA. But if you don't want to learn advanced drawing techniques and you just want an animation that moves a control and re-sizes it. Just throw a timer on the form, and on every say. 150 milliseconds move the desired item toward the center and make it a little bit bigger.

Diamonddrake 397 Master Poster

using hide is a good method. But, if you create all your controls from a different form, then dynamically add them to the new form's control collection. The first form will have references to all the controls. Make sure that when you close the new form that you remove all the controls from the controls collection so they don't get disposed.

This system does infact work, but can get very messy. I would recommend Narue's suggestion of hiding the form unless its of the utmost importance that it be closed.

Diamonddrake 397 Master Poster

If you learned from my example and implemented all the changes I explained. it would certainly work.

The problem is that you aren't passing the changes (in this case deleteing) from the listview back to the collection that holds your data.

At this point I have helped you all I am willing, If you want someone to write your program for you. Tell me all what you need and pay me to do it. I love to help out the community here at daniweb and I'll teach you to fish, but I won't catch your fish for free.

Diamonddrake 397 Master Poster

OK, I figured it out. All those other controls use custom collections derived from CollectionBase, this allows you to do customize the add and remove methods of the collection class to do such things as that I mentioned. also its strongly types so I can easily make sure that only my Segment Controls can be added to the view.

Thanks again daniweb for giving me a place to talk to myself until I figure it out...

Diamonddrake 397 Master Poster

sometimes there is a separate process, service, or pool of processes that serve no other purpose but to make sure that no matter a certain process is still running. this is often called a babysitter process. Many many viruses have them. So when you kill it, it starts again.

So long as you identify your bad processes well, then I imagine it can't be any more harmful than the virus itsself.

you still want to throw some thread.sleeps in the loop to slow done the repeat rate.

best of luck.

Diamonddrake 397 Master Poster

I've been playing around with different browsers, I'm a big fan of FireFox because it works well on older machines, and scrolls smoother than IE 7 and 8. With the exception of the tab bar placement The interface is very usable. Seems to work fine. I could imagine that if they fix the tab placement I might use it.

Hard to say, I feel like FireFox has the perfect usage of space to decrease time it takes to complete frequent tasks, while being minimal enough not to keep me in a constant scroll. I hate tool bars... I think that was IEs downfall from the start.

Diamonddrake 397 Master Poster

The reason your loop eats up the proc is because you are running an infinite loop with While(true) you should be using some kind of reachable goal While(somevalue == true) that way you can break the loop by reaching a goal. If you throw a Thread.Sleep(500) in the loop, you will allow the loop to sleep, easing the usage of the proc and letting the OS prioritize another process for CPU usage.

the cancellation is a little different. you have to put a if statement in the loop, on every itteration you should check the CancelationPending property of the background worker. this will tell you if backgroundworker.CancelAsync has been called.

http://msdn.microsoft.com/en-us/library/cc221403%28v=vs.95%29.aspx

It's a fairly simple process.

BTW. its not the best idea to be constantly looping and killing processes. You can put the system in a bad place, especially if the process you are killing has a babysitter or crash protection service attached to it.

Diamonddrake 397 Master Poster

I have hacked up this gorgeous files system tree view that looks like the windows 7 explorer sidebar. Its starts as one control, and that control lives in another control that makes up an "segment" whom are created and added to a host that handles scrolling ect.

I have the control working fine, assuming I rig up the resize event and directoryChanged event of each "segment" to the one handler method that they need to be attached to in the client code. I would really like this to be handled automatically by the host control.

I though that i could expose a collection of items as a property and when they were added to it I could rig up the events ect. I found that I could to this if I write a Addtoitems method and a removefromitems method. But I was hoping for that listview style items collection.

Just using a property I can't get the information I need from the changes made to the collection.

Any ideas?

Diamonddrake 397 Master Poster

When using a background thread to do some lengthy possibly blocking processes, its necessary to invoke any gui update calls onto the gui thread. In all my reading I have come to the conclusion that most programmers feel that it is and should be up to the gui code to check if an invoke is necessary and perform it. But if you use the BackgroundWorker class, its reportprogress and workercompleted events somehow handle the invoke transparently.

my question is, does anyone know exactly how the the background worker does this? I have some ideas but I was just curious. Creating my own asynchronous classes that don't use the background worker, I have interest in performing this type of transparent invoke.

Its not at all important, but I am certainly curious. I'm considering decompiling the background worker class with reflector, but I haven't put all that much effort into it yet, i was just curious if anyone here had some ideas.

Diamonddrake 397 Master Poster

Hi!

I will prefer VB.Net, the reason is that it provide some functionality which i found preferable to me.

1) When I created a button both in C# and VB.Net and double clicked on it, at code behind btn_Click code generated. But when I decided to remove that code:
In VB.Net I can just select and delete the code, on the other hand in C# if i do the same designer the next execution will point to abc.designer.cs file o remove the delegate used. May be it is not important for somehow, but if you going to check that which event of a control raised by which priority, then you will feel the difference when select the best event.

2) If you have a low configuration PC which don't allow Visual Studio to process quickly:

In C#, if you decided to code on an event of a control and your current window is .cs file every time you need to display the form and click on the event button on the window and select an event for code.On the other hand VB.Net allows you to select the drop down on .vb file and select the control at the same place on the next drop down you can select the event you want to code.

These things are wired to me and compelling me to work on Vb.Net more. But still I can bear with both :)

Regards,
-Shahan

Hard to agree with this, Those things have …

Diamonddrake 397 Master Poster

C#

It's cleaner, its less typing, less room for typos, easier to find your place.
plus, Script#, the micro .net framework, Cosmos and dozens of other great programming tools are based on C#, not VB.

Diamonddrake 397 Master Poster

A project I am working needed a question style message box, but I wanted that contemporary look of Vista and Seven. I set out to see how it was accomplished, turns out there are some special APIs that exist in Vista and Seven that don't exist in XP that accomplish that look. This isn't what I hoped for. I want an interface that looks contemporary even in XP.

So I decided to create a very simple messagebox type form that had the appearance of the vista/seven question dialogs, the simplest way possible. This is my result. it uses the multiline label control I already posted here, but I included all the code here for simplicity.

I wanted that windows forms MessageBox.Show() static simplicity. So I created a static class that creates an instance of the messagebox with overloaded constructors to make it simple.

its as easy as

if (QuestionBox.Show("Example Caption", "Example question?", "Example Description") == DialogResult.Yes)
                {
                    //do something
                }

best part is, all managed, no extra api calls, and it looks identical in XP, Vista, and windows 7

kvprajapati commented: Helpful! +11
cale.macdonald commented: Very clean, concise, well written +2
Diamonddrake 397 Master Poster

at the end of the this thread page, underneath my post and above the text box where you type your reply is a an area with purple and gray text, asking if you want to mark the thread as solved. just click the link that's in the middle of if.

Diamonddrake 397 Master Poster

There is also a beforeLabelEdit event. Can't think of anything I would use that for. Don't forget to mark the thread as solved.

Diamonddrake 397 Master Poster

by "copy" do you simply mean take the text from the treeview (treeview? huh, title says listbox) and have it be displayed in a textbox or listbox.

Strings are Reference type, so "copying" the information is substantially more complicated than assigning a reference to the text property of a textbox.

but the short answer is textbox.text = treeview.SelectedNode.Text; The text property that all classes the inherit from the System.Windows.Forms.Control class contains whatever text is being displayed by that control. On a form, its the title caption, on a label its the display text, in a textbox its the text that's in it, and in the Node class that represents a member of a tree view its the text displayed on that node.

so you simple set the text property of the control you want to "copy" the text to with the text property of the control you want to "copy" the text from.

If you can't tell... I'm really bored right now... this is probably the simplest question I have ever seen on this forum... and normally silly questions like this one don't get answered. Because it will take you longer to read this long post than it would have to google it and find the answer.

for a free project to download with dozens of lines of source code try http://www.c-sharpcorner.com/uploadfile/scottlysle/treeviewbasics04152007195731pm/treeviewbasics.aspx

Diamonddrake 397 Master Poster

When the program opens you need to save its current directory to a string, then append the resource folder name and song file name.

this method will return the directory that your application was open from.

private string GetAssemblyPath()
        {
            System.Reflection.Assembly exe = System.Reflection.Assembly.GetEntryAssembly();

            return System.IO.Path.GetDirectoryName(exe.Location);
        }

then you can do something like

axWindowsMediaPlayer1.URL = "GetAssemblyPath() + \\Resources\\2pac.mp3";
Diamonddrake 397 Master Poster

The Listview control has an event called "AfterLabelEdit" This event will fire after you change the text with beginedit. it will fire this event and you can validate/update the changes then