Add SVG images to resource file - c#

I think this issue transcends Dev Express, which is why I haven't gone to the vendor's forum just yet (although I could be wrong). In the latest release of Dev Express Winforms (17.2), there is support for SVG images on the ribbon bar items. When you use the Dev Express picker and add them to project resources, it looks like this:
I have some SVG images of my own I'd like to add. Dragging and dropping them adds them as files. Doing an import through the designer adds them to the form resources, and I want them as project resources (we reuse icons across multiple forms).
Is there an easy way to add local SVG images to my Resources File and have them visible to all controls within the project, the way the Dev Express gallery images are?
If not, is there a hard way?

Consider using the SvgImageCollection component which specially designed to store vector images for DevExpress controls.
You can invoke the SvgImageCollection's smart tag and click "Edit Collection" to invoke the Collection Editor dialog. Use the "Add" selector to choose where to import SVG images from:

Don't know if something has changed or if something has happened in the last three years, but this is now super easy -- barely an inconvenience.
To add an SVG to the resources, go to the ImageOptions.SvgImage property of any control, Click on the properties (ellipsis) button, and it will bring up this familiar form:
The "import" button will allow you to add local SVGs into the resource file, which can then be accessed by the entire project.

Related

Why XAML doesn't need to be compiled?

If I create a button in XAML I can directly view it in internet explorer, however if I create the same button in C# I need to compile the code first. Why does it work that way? How does the browser know what to display, shouldn't it treat the XAML as pure XML.
For example, if I have a pure XAML file, that has no reference to code behind, I can open it in internet explorer and it displays it, I am wondering why it works this way, without any compilation?
This is because very early versions of Silverlight supported XAML files in the raw. It's not considered best practice to deploy applications in this way, but it's probably fine if you just have an animation or vector image you want to render. You can read more in this old article here:
http://www.windows-now.com/blogs/rrelyea/archive/2004/1.aspx

Creating UI framework more like Visual studio

I want to develop the application UI much like as VS2010 or any similar UI models. My requirements are as below:
Opening new project will create empty canavs.
When I will do add data sheet it will add new tab page in that.
Remaining few things I will do on that added tab page like showing charts, different types of controls etc.
When I will press 'Save' it will persist whatever there on UI like added tab pages and every controls on it on disk.
When I will open any saved project, It will recreate everything what was there on UI at the time of saving the project.
I will have recently open project list.
Any idea for creating how to create such UI?
Thanks,
Omky
Maybe develop your solution over Visual Studio SDK? A good sample is AddonStudio for World of Warcraft which is customized dev. environment for World of Warcraft addon development based on Visual Studio.
It's quite easy to implement the Visual Studio-inspired UI using DevExpress Docking library for WinForms.

How to create an Explorer-like folder browser control?

Using C# and WinForms in VS2008, I want to create a file browser control that looks and acts like the left pane in Windows Explorer. To my astonishment, such a control does not ship with .NET by default.
Ideally, I would like its contents to be exactly the same as in Explorer. For example, on Windows 7, it should show the Favorites and Libraries pseudo-folders. Of course, I do not want to code specifically for each version of Windows if I can help it.
I have browsed around, and there are some examples of such controls, but they are all hand-rolled and therefore won't work 100% the same as the one in Explorer.
Is there any way I can simply reuse the Explorer control instead? Or, if not, to get access to a tree of the items that it would show?
Microsoft provides a walkthrough for creating a Windows Explorer style interface in C#.
There are also several examples on Code Project and other sites. Immediate examples are Explorer Tree, My Explorer, File Browser and Advanced File Explorer but there are others. Explorer Tree seems to look the best from the brief glance I took.
I used the search term windows explorer tree view C# in Google to find these links.
It's not as easy as it seems to implement a control like that. Explorer works with shell items, not filesystem items (ex: the control panel, the printers folder, and so on). If you need to implement it i suggest to have a look at the Windows shell functions at http://msdn.microsoft.com/en-us/library/bb776426(VS.85).aspx.
Take a look at Shell MegaPack control set. It provides Windows Explorer like folder/file browsing with most of the features and functionality like context menus, renaming, drag-drop, icons, overlay icons, thumbnails, etc

Graphically template a .NET winforms application

I created a pretty fancy winforms app for my company. We had a graphic designer create the GUI, which was a pain to implement, all graphical buttons, lots of layered backgrounds and logos, animations, etc.
But now my company wants to resell it under different brands. But since I mostly coded it well, I told my higher ups I could have a totally rebranded version done in under a week. Basically all I would do is change a bunch of settings in an xml settings file, swap out the graphics with a new set, and build.
Problem is if they want 5 or 6 different brands, I'd have 5 different builds to support (I really should be supporting 1, with diff templates)
The problem is its not easy (as far as I know) to swap out the images in a winforms app. I have all the graphical resources in a single folder, but once each file is entered into its respective image list or container in visual studio, the only way to get it to update is to remove it and re-add it, changing the source folder doesnt cause the embedded image to refresh. This would be incredibly tedious for each build, there has got to be an easier way.
Add On:
So after some further investigation, I am leaning torwards some sort of resx file editor. However the ones I have seen so far are more focused on translating strings to various languages, and are either very weak, or can not at all edit binary resources like bitmaps/png's. Though if you open a resx file in an xml viewer (I use notepad 2 with .resx set to use xml sytax highlighting) MS is kind enough to tell you exactly how each type is compiled (mostly variations of base 64)
I think your goal should be having "brandable" resource files; you're essentially localizing your application, except you just have a few different versions of English.
You can use ResGen.exe and ResourceManager to load an external resources file, so you could use 5 different "resources" files but keep your code base the same.
This post may also help...
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/b388c700-0e07-452b-a19e-ce02775f78a6/
Edit: BTW, I will second the comment that if you're going through a great deal of effort on this, consider WPF... Most of those "graphical" elements could possibly be done natively especially if it's gradients and stuff, not to mention the easy templating.
What I would do is just load all the graphics of the disk at start up from a folder and create any imagelists needed as appropriate, instead of doing this in the designer. If you are worried that someone would steal the graphics, then I would create a simple file format (possibly encrypted) for my graphics and a small simple app for you or the designer to use to convert into this format from regular files. Then it's just a question of swapping out this folder between different brands.
If most of your forms are similar (i.e. same logo, same buttons on the bottom, etc.) you can use visual inheritance on WinForms to define a set of "Base Forms" from which your actual forms inherit.
If you develop a set of "Base Forms" for each of your brands, each set in a separate assembly you can plug-in the needed work to generate a new brand is reduced to generate a new set of Base Forms.
Hope it helps
It's too late now, but WPF would have been a better choice than WinForms, as it is easier to skin.
However have a look at what DevExpress does for WinForms, as their controls have a skinning system. It is not too hard to swap a DevExpress winform control for a standard winform control.
I think you should be thinking about creating user controls for the dynamically replaceable areas of the form. At runtime, you could swap out one assembly out for another.

Displaying Flash content in a C# WinForms application

What is the best way to display Flash content in a C# WinForms application? I would like to create a user control (similar to the current PictureBox) that will be able to display images and flash content.
It would be great to be able to load the flash content from a stream of sorts rather than a file on disk.
While I haven't used a flash object inside a windows form application myself, I do know that it's possible.
In Visual studio on your toolbox, choose to add a new component.
Then in the new window that appears choose the "COM Components" tab to get a list in which you can find the "Shockwave Flash Object"
Once added to the toolbox, simply use the control as you would use any other "standard" control from visual studio.
three simple commands are available to interact with the control:
AxShockwaveFlash1.Stop()
AxShockwaveFlash1.Movie = FilePath &
"\FileName.swf"
AxShockwaveFlash1.Play()
which, I think, are all self explanatory.
It would be great to be able to load
the flash content from a stream of
sorts rather than a file on disk.
I just saw you are also looking for a means to load the content from a stream,
and because I'm not really sure that is possible with the shockwave flash object I will give you another option (two actually).
the first is the one I would advise you to use only when necessary, as it uses the full blown "webbrowser component" (also available as an extra toolbox item), which is like trying to shoot a fly with a bazooka.
of course it will work, as the control will act as a real browser window (actually the internet explorer browser), but its not really meant to be used in the way you need it.
the second option is to use something I just discovered while looking for more information about playing flash content inside a windows form. F-IN-BOX is a commercial solution that will also play content from a given website URL. (The link provided will direct you to the .NET code you have to use).
Sven, you reached the same conclusion as I did: I found the Shockwave Flash Object, all be it from a slightly different route, but was stumped on how to load the files from somewhere other than file on disk/URL. The F-IN-BOX, although just a wrapper of the Shockwave Flash Object seems to provide much more functionality, which may just help me!
Shooting flys with bazookas may be fun, but an embeded web brower is not the path that I am looking for. :)
There was a link on Adobe's site that talked about "Embedding and Communicating with the Macromedia Flash Player in C# Windows Applications" but they seem to have removed it :(

Categories

Resources