I apologize if this has already been answered. I've looked and looked, and I can't find anything like what I want, which I find greatly surprising. Please feel free to give me a "This has already been asked" with a link... :(
I'm in the early stages of creating a program in C#. The main window will have a list of files which are relevant to my application. I currently have them in a list view, although I can switch widget types if necessary. What I'd like is to make it possible for a user to right-click on one or more of the file names which would bring up the same context menu as one would get in Explorer. With e.g. "Open", "Edit", "Print", and etcetera.
Obviously I could put stuff in a context menu manually, but I'd like it to have the same choices as one would have in Explorer. There will be Word documents and text files and various other odds and ends. I don't know how the list of actions in the standard Windows context menu is populated, especially considering that the list changes depending on the file type selected and whether more than one file is selected.
I can provide code if necessary, although I don't have anything interesting yet.
So my questions are - How do I get the list of actions one gets when right-clicking a file or group of files in Explorer? Is there a Windows API that I can call? Or do I aggregate choices that I read in the registry? And if so, what do I read? Or what?
As a bonus, I'd like to be able to add a few commands of my own to the menu only within my own application. Mostly all I can find is how to write an extension to the context menu such that I can add an action that appears always when clicking a specific file type. That is NOT what I want. This is a bonus though, and I can always add buttons or a drop down menu or something if this won't work or if it requires heroic coding.
I've found this article which describes the process for c++ but I think you will be able to transition it. Using the shell context menu
EDIT:
Here is another link to a project with ready to use code (C#):
Explorer shell context menu
Related
i dont like the new interface of my search all, it suddenly change when i reinstall my visual studio
here is my search all result interface
the result suppose like this
Do you guys know how to change the result interface ?
It sounds like you are using 2 different types of search.
The first capture you provide is from Find and replace feature, that cand be raised with shortcut Ctlr + F, and when you select option "Find all". It returns a lsit fo files that match the text you are searching for. You may check Microsoft documentacion for Find and replace
The second capture represent the usage of Find references in your code, that provides a way to find where particular code elements are referenced throughout your codebase. You can find more information in Microsoft documentacion for Find references.
If you want to make use of Find references feature, you should use shortcut Shift + F12 or simply you can make right click over any object/class/element in your code, and select option Find all references.
Capture: Find all references using right click and contextual menu
Remember that this would not work with a simple piece of text, you must find references of an existant element, like a model, a class, a variable, etc.
Hope this info could be useful.
[EDIT]
Maybe I could misunderstand your question. If you refer to the theme (backgroud anf font color mainly) of the interface, you could set Light theme option, through main menu, selecting Tools menu, and then Options. once there, enter section General, under Environment option, and select Light option in dropdownlist associated with Color theme option.
Check this link (made for VS CE 2017, but work as well) to see captures of the process:
https://ourcodeworld.com/articles/read/869/how-to-change-to-a-dark-theme-in-visual-studio-community-2017
[EDIT FOR COMMENT]
I've checked it with VS 2019. As you said, default view for Find all feature looks like references result view. If you want to keep the "classic" list view, you can simply click on ListView button, at the right top, on the bar that appears over your result section, as you can see in following capture.
I'm very newer developing .NET web applications. Before read, I'm so sorry if I'm not able to explain correctly or if I'm confusing about something of .NET. Hope all of you can give me some light in .NET environment.
Context: We have two different solutions because the original idea was to develop two different applications with no common pages or content between them. Now, we need to have one of the aspx page that is in the solution1 inside the solution2 (and probably more in the future) because it's common between them.The idea is not to have two different maintenance of the same page. This two solutions have only one project inside them and each project has his own master page.
Solution1:
-Project1
Solution2:
-Project2
Question 1: Is it possible to import or use complete aspx page across the solutions? I mean, I know that is possible to import aspx files from the project1 into the project2, but doing this way, every change into the original aspx file of project1 means that is needed a new import into project2 (or this is what I think) to have the page up to date. What is the best way to share content between different solutions?
Thanks in advance.
You should be able to add the aspx page which exists in one solution (and version controlled hopefully!), to your other solution by adding it as a linked file.
MSDN explains how Visual Studio allows you to add an item as a link rather than directly adding the file to your project.
By linking to a file, you can capture ongoing changes to a source file without having to manually update a copy whenever changes are made. However, if the underlying file is deleted, the link will be broken.
To create a link to an existing item
In Solution Explorer, select the target project.
On the Project menu, select Add Existing Item.
In the Add Existing Item dialog box, locate and select the project
item you want to link.
From the Open button drop-down list, select Add As Link.
https://msdn.microsoft.com/en-us/library/9f4t9t92(v=vs.90).aspx#Anchor_0
Another helpful article by Grant Winney on the topic here:
https://grantwinney.com/visual-studio-add-file-as-link/
I'm currently creating an application that will hold multiple images, I've decided that on an image I would like a context menu to appear when right clicking and have an option to send to an image editing application such as Photoshop, Gimp, Paint etc...
I know how to create a context menu, however I am unsure on the code to use in order to send the image to the application itself.
If you want to open the file in the default application then that was already answered. If you want to do the same the Explorer is doing on "Edit" context menu item, then add these two lines in "Original, complicated answer" from the link above:
if (psi.Verbs.Contains("Edit", StringComparer.OrdinalIgnoreCase))
psi.Verb = "edit";
You should check the existence of the verb you want in psi.Verbs as per the MSDN. If there's no "edit" verb then the code calls default app.. by default.
If you want to give the user a list of all image editing apps that the user have installed then you would have to have a hardcoded database of such apps together with their installation GUIDs, check if they are installed, find out where they are installed (maybe not in the default place), and make a list of them, calling each with your file as a command line argument. It's too complicated to give code for that.
I found some code to help me in a project and when I first ran the code I received an error message indicating: "Visual Studio cannot start debugging because the debug target c:\path\'dirInfo.exe' is missing. Please build the project and retry, or set the OutPath and AssemblyName properties appropriately to point at the correct location for the target assembly."
Then I select OK and receive an error message indicating that partial is missing. I add partial to the code and receive 3 more error messages.
The type 'RecursiveSearchCS.Form1' already contains a definition for 'components'
does this mean I should delete this from the Form1.cs file?
Type 'RecursiveSearchCS.Form1' already defines a member called 'Dispose' with the same parameter types.
Type 'RecursiveSearchCS.Form1' already defines a member called 'InitializeComponent' with the same parameter types.
(I notice, when I comment out the InitializeComponent line and/or Dispose line, many more error messages populate in ERRORS)
By they way you can find the original code # MicrosoftSite.
Any help would be greatly appreciated.
Thank You
Just gut instinct, if you were following along and copy pasting remember one key thing:
The designer creates two files when you create a form: A "code" file, and a "designer" file. However, when microsoft (and others) release "templates", they like to merge these two files.
Just create a new .cs file and paste the code and all should be good. It's the code basically saying "in the designer, we already have this stuff". (a good way to note this is the "partial" keyword located before your Form1 declaration)
More info:
The Code file will house all your own implementations. That is click events, methods you personally override, events you bind to, etc. This is the default file when you select "View Code" from either your solution explorer or the dialog itself. Within this file is a construct that calls a "hidden" method, (InitializeComponent) that if you right click and "Go to Definition" will bring you to the next file:
The Designer file is the IDE's generated file. This takes everything you do in the designer and stores it for you. That includes new controls, location and properties of the controls, and the IDisposable implementation. The idea is to keep the "meat an potatoes" out of the way while you worry only about implementation.
Yes it sounds like you've copied the entire code which includes many things already contained within your Form in a partial class. Either remove these or remove the partial class and partial class declaration from your Form to get rid of these errors
I went to the Microsoft site to see what you did. The site shows code for an entire "one file" solution. We've all agreed that Visual Studio creates multi-file solutions, so you're duplicating code.
I don't know if the current answers/comments have helped you get this sample code working, so I thought I'd add my share. I was able to get this sample working by doing the following:
First, where the sample code at the Microsoft site shows declarations for button, textbox, labels, and combobox, rather than attempting to copy that portion, I simply used the toolbox and dragged a button, the labels, the textbox, and the combobox from the toolbox to my form.
You'll probably want to arrange these to your liking.
This process created my form correctly with the appropriate objects on it. All I had to do was use the properties window for each object and rename them according to what they were named in the sample. For example, my new button was originally button1, but I renamed it to btnSearch just as it is named in the Microsoft sample.
I noticed that the Microsoft sample has an established event handler setup for the Form1_load() event. I created this same event in my form by clicking the form in the designer, clicking properties, clicking on the Events button in that properties, and double-clicking the "Load" event. This automatically generated the appropriate code.
In a similar way, I had to create the btnSearch_Click() event. I did this by simply double-clicking the button in the designer.
After that, all I had to do was manually copy and paste from the specific sections of the sample to my code -- fill in the Form1_Load() event with what was in the sample. Copy the DirSearch() method over. Fill in the btnSearch_Click() event. That was it.
I hope this helps solve the overall issue and gives you more insight into how you can avoid these problems in the future.
You have duplicated functionality in the classes, you have a file that was automatically generated with that functionality already in it.
I'd like to write custom providers for start menu searching, but I can't seem to find where to begin.
Things I'd like to be able to do when I type in the search box on the start menu
Type "thomas" and see "IM Thomas" (if a Pidgin/whatever-IM-client-with-API contact exists with the name match)
Type "=1+2*3" and see "7", or "=2 gallons in ounces" and see "256"
Anything else I can think up where I have a store of custom data results that could be launched from the start menu. This would be especially useful for custom applications, letting our users type "order XYZ", which would search orders in the application and let the user open them from the start menu.
I'm not looking for a tool to do this for me. Rather, I'd like to find any documentation on writing custom search result providers, ideally in C#.
I believe you are looking for the Windows 7 API Code Pack for .NET.
On a related note, you can add all kinds of searches to your favourites in Windows Explorer. Check out Windows 7 Search Federation Providers.
Scott Hanselman's blog covers how to create a simple search connector by creating .osdx files, which are XML files that configure which URL(s) to invoke with the search terms. He then shows how to enable those connectors from within the start menu itself by adding entries to the registry.
You might want to look into SlickRun a search bar alternate/replacement. While I dont think it can be put in the place of the actual start menu search, going to thier site and getting involved will probably get you a lot closer to where you want to go.
For all I know, the functionality you describe may already be an option.
I just discovered Start++, which has plug-in support (it appears to use JavaScript with Windows Scripting Host).