Setting project/application icon programmatically - c#

I would like to be able to set the icon of a project/application in VS programmatically. NOTE: I know how to do this for individual forms, but I would like to do it for the actual application itself, i.e. the icon that the .exe has (and the one that will show in Uninstall Programs and Files..etc).
You can do this in My Project, but I can't seem to find any way to do this via code?
I know how to use Build Configurations and Custom constants etc and I assume the answer would use something like that?
Thanks for any and all assistance with this!

Related

When creating a custom file extension, is it possible to assign it an icon different from the application icon?

Hello wonderful people!
I have created some code for an application which upon startup, simply makes sure the registry has a key for my own file extension (or I guess 'class', as Windows calls it). It allows me to double-click a file with said extension and have it open with my program. Simple.
My query is this; is it possible for me to change the icon for this file class, to be different from the icon of my application? I would prefer to have some different icons for the various file extensions I'm registering, much in the same way that Photoshop for example gives a different icon for .PSD files than the actual application icon.
In simpler terms, I would like to mimic this behaviour but with my own icons and application:
Photoshop (the actual application):
Photoshop Document file:
I am working in C# and WPF. And I should also specify that the solution I'm looking for should be able to work in a scenario where I was to send my application to someone else to install on their computer; they should be able to see all the icons as described. I'd kindly request that in your answers you provide code examples, as I am not particularly familiar with working directly with the registry.
I should also specify that my application does have an icon, and this is currently what the custom filetype displays in Windows Explorer.

Can I dynamically add a user control to a silverlight application without recompiling it?

I have a silverlight application with several menu buttons, each of which opens up a user control in a center "work space" area. It works fine. Now what I'd like to do is make some more user controls, compile them into a dll, and through say, a configuration file, have the silverlight app add a new menu button and make it make one of those new controls appear. The difficult part is, I'd like to be able to do this without recompiling the silverlight app. I'd like another developer to be able to make a user control that does some things, compile it into a dll, and drop it into the silverlight directory with some changes to a config file to get the main app to load it in. Is there a way I could do this?
Since noone else has replied yet:
What you want to do is reflect classes form a third-party dll at runtime. This is possibly too big a subject for SO, and all I can really recommend is looking up examples of it, and maybe the msdn section on it.
You'll also want to look up serialization and deserialization in C# and silverlight (this question might be a good start).
Sorry I can't be more help than that, but hopefully someone more experienced will weigh in with a useful article or some such.
Good luck :)

How to list all the elements of an application?

I'm trying to click a button on a windows application from other application. Basically, I want to click app B's button from app A's code.
I can use winapi findWindow to get a handler. The problem is that I have no idea the name of the button on the app B. Is this possible to list all the names or ids of an application?
I'm using c# to make it happen.
Since you're looking at suggestions (it's a pretty generic question really, it might or might not work depending on what other app/window is, is it e.g. browser or a 3rd party app etc., does it support automation)
Take a look at this closely related answer (it might be a duplicate but you're kind of 'looking for' still so maybe note).
Accessing Elements from Other Processes
Also this one on how to 'access' other app's 'inputs'
Pinvoke SetFocus to a particular control
I have not tested this. But it looks like a intressting libary. Maybe there is some function you can use. It is called White. This is just a sample:
Application application = Application.Launch("foo.exe");
Window window = application.GetWindow("bar", InitializeOption.NoCache);
Button button = window.Get<Button>("save");
button.Click();
You can use tool such as Spy++ (included in any Visual Studio except Express editions) to find name and class of that button and then use these information as parameters of FindWindow().

Simpler Breadcrumb Bar Sample

my question is very simple. I am building an app(WPF CSharp) and I need user to give me paths that my app is going to use. Previously I added textboxes to show pathways, however, later I decided that it would be cool to use a Win 7 style Explorer navigation bar, which is a Breadcrumb bar. I found a great open source component for it here (http://www.codeproject.com/KB/tree/WPFBreadcrumbBar.aspx) however, I could not use it in my app. I added references both to Toolbox section and Project>References section. I can also add the control to my WPF window from Toolbox, yet I could not figure out how to fill it, how to change and show items in it etc. With respect to component author, I think article on Codeproject is not very 'understandable'(XAML? I want C# code please) and also PopulateItems event, for instance, did not work for me. So, if someone give me a basic example on how to add items to this bar easily, change items, or shortly, shows me how to make it work, I will appreciate for that,
Thanks.
I Guess it depends on how you want to present it. If you want to use a tab control to simulate the functionality you could go this route:
http://www.wpfblogger.com/post/BreadCrumb-TabControl-Style-for-WPF-40.aspx

How do I browse the local directory's files without using OpenFileDialog? (C#)

I want to build something where the user to browse the local files on the application I am providing, the screen is actually identical to OpenFileDialog, but I do not want that to be a dialog but a control on my form.
I tried to use a Web Browser control, it works, but I have to write a bunch of navigation code in order for that to work, and another problem is if the user selected any files on that screen, I am not sure how to capture the results.
So is there another way to do that? Or maybe override some of the OpenFileDialog control to make it not only showing as a dialog but a normal control.
Thanks
Maybe something like this is what you are looking for:
It uses the tree view.
http://www.codeproject.com/KB/cs/TreeViewFileExplorer.aspx
It's better to use the openfiledialog and attempt to ownerdraw that (which I think you can enable).
Use controls from Shell MegaPack - they can be put on your own forms, and provide lots of customization and flexibility.
DISCLAIMER: I work for LogicNP Software, the developer of Shell MegaPack.

Categories