Background
I want to drag "icons" from the desktop on to my form, they will then be visualised on the form, not changing in appearance.
When i say "icon", i mean shortcuts, folders and application icons.
Example
Question
What is the best way of recreating the icons on the form. Is there a tried and tested way, or do you have to recreated them using picture
boxes and labels?
What I've Tried so Far?
Picture boxes
Forms
I've had limited success with both, with the latter being the best so far. However both have their limitations.
Notes.
I do not need help with other areas of my problem like, how to drag icons, extracting icons, etc. It's purely just recreating the icon visually i'm struggling with.
Use a ListView and set the view property to LargeIcon.
You can obtain the icons through: Icon.ExtractAssociatedIcon. However, you may need to manage the icons as two files with the same extension may have different icons.
If you only want the image, then you can grab just the icon portion of the control after it's painted.
Related
At the moment I have no Idea how to start this. I created a blank UserControl in WPF. My Window looks like this at the moment:
The List on the right is a ListView. I want to Drag and Drop an Item of the List (Not the topic, asking that in another question soon). When i drop it on the white space, I want the Image to get drawn where I dropped it.
But I don't want it only to be an Image, in general, this Program is for creating a setup by drag and dropping the Modules on the right and create a configuration with the setup you've built in the big plain space. This image may make that more clear:
These Images need to be able to rearranged at any time, so I don't think I just need to draw them, I need to place an Object on the Work-place. Imagine it like Windows Forms, where you drag and drop your tools, rearrange them and be able to zoom in and out. I don't need the Zoom feature yet, but it's going to be in there too. Is there maybe a nuget that I can use for implementing a "Drawing-Board"?
As a learning project in C# .net I am re-creating a Gnome 3 plugin for seeing who of the streamers you follow on Twitch is live. I have the settings form done, I am now working on the interface that is viewed from a click on the taskbar.
This is a rough image of what I want the interface to look like. When two or more streamers are live the interface would add another block and resize the form vertically similar to the menu for selecting a Wifi network in Windows.
What would be the best way for me to complete this?
My current thought is to maybe create a custom control and just place those inside a FlowLayoutPanel with some kind of code to change the vertical size of the form to match the added entries. Maybe this can be done without a custom control and be done with code inside a FlowLayoutPanel? I'm not too sure.
Ideally I would also have a click event in the panel for each streamer so I could then open a browser to their channel. A slight highlight would also be a plus (maybe change the background colour based on mouse hover).
Thanks in advance for any suggestions!
What is the best way to solve this problem:
I create dynamically in my window application tabs with background image and according to image I put customUserControls. Then I save all tabs, images and userControls to database. So in my database I saved position of the userControls. But if I will open this application with saved information on screen with different resolution, then all userControls will be shown with wrong positions. I was thinking to solve this issue by saving screen resolution to database and before creation of userControls from database check current resolution with resolution from database, and if they differ, recalculate position of userControl.
Is there a better way to solve this issue?
This is filed under WPF. Why would you not layout the controls using the WPF layout grid, stack panels, and such to make use of the power of WPF?
Using the layout controls allows you to have a form that will appear properly no matter how it is re-sized or what resolution screen your application runs on.
I am trying to create a panel which will have a set of "buttons" on it.
These buttons should have the following behaviour:
Appear similar to a tag (with
rounded edges)
Contain a red
cross to remove the filter/tag from
the panel, similar to the way internet
explorer tabs have an embedded cross to close the individual tab.
allow the user to click
on the tag and respond like a normal
button (as long as the click is not
in the red cross)
Number 1 is no problem, this is just appearance, however, regarding numbers 2 and 3, I am not sure if there is already code out there do to something similar...and I dont really want to reinvent the wheel if I can avoid it!
My question is: Does anyone know if there is something out there in infragistics which will do this simply, or will I need to write this myself by subclassing winform buttons?
Thanks in advance!
Is this new development or maintenance of an existing project?
If it is maintenance, you have a somewhat tougher time ahead. You'll implement a UserControl, probably segmented into two buttons. Use docking to get the behavior as correct as possible. The far right button would contain your cross image; the left (which would need to auto-expand as you resize the control) would contain your primary button behavior. Play with the visual styles until you get them right (EG, removing borders, etc).
If this is new development, and you haven't gotten too far into it, you might consider using Windows Presentation Framework (WPF) instead of WinForms. It will be easier to build the control and get it to look exactly how you want it. WPF includes an extremely powerful control compositing system which allows you to layer multiple controls on top of each other and have them work exactly as you'd expect, and it carries the added advantage of allowing full visual control out-of-the-box.
Either way, this is more work than dropping in an external component ... I've used Infragistics for years, and I can't think of anything they have which is comparable. The closest, but only if you're building an MDI application and these controls are for window navigation, is the Tabbed MDI window management tools -- and there, only the tabs (which replace window title bars) have this behavior.
I don't think that infragistics can do something like this. The UltraButton control can't.
Implementing a own control wouldn't be that hard.
your probably going to have to make a costume control for this type of work.
i have a winforms application. i have a user control with a lot of icons. the user can load this control on a form many times (in a tabbed layout). right now i am loading the icons each time the control is created (could be up to 50 times in teh app). is there any way to cache these icons in the application. if i did this, would that decrease the number of gdi handles that i am using as this is becoming an issue.
You can make a singleton class for each icon. The first reference it creates the handle. Subsequent calls uses the existing handle.
Without knowing more about your user control my next suggestion can be only be very general. But you could have a single bitmap layer on which you draw all your icons. The remaining elements of your user control would exists above and around this bitmap.
Unfortunately this idea may be problematic performance wise. Require you to refactor the code you all ready use for arranging icons. Finally it is non-institutive from how frameworks with a control-form structure ideally works.
We ran into a resource problem with entry forms for the parameteric shape we ship with our CAM software. Too many text entries caused various forms of strangeness and leaks. So we instead created labels with borders that looked like text entries and had ONE text entry (and a combo box entry too). When the user tabs, enters, or clicked the single text entry moved to the new entry and the label was setup for the previous entry.
This is totally a non-intuitive setup than how you would normally code this but it was the only way to deal with our resource problem.
In my experience it seems that GUI Frameworks have issues when you have to deal with dozens or hundreds of entries and that you have to approach the problem using a different design.
If the issue is the number of "icons" (not sure what you mean here) you can use Image-Lists. For example, a Listview control can reference icons in an image-list, instead of keeping a full copy for each item (not sure if this applies to your case though).