How do I have VS recognize an existing icon? - wpf

VS 2019, I add an existing icon (x.ico) --- Properties => Resources.resx => (right click) Open => Resources.resx. --- I drag and drop x.ico into Resources.resx.
The x.ico now appears under Resources.resx\Resources.Designer.cs\Resources.
I place the x.ico name into:
<Window x:Class="x.MainWindow"
...
Icon="x.ico"
>
This is how I've done it in the past.
There are no errors when I compile. However when I run it => IOException: Cannot locate resource 'x.ico'.

The reason why this isn't working is that WPF doesn't like ICO files. If you want to use ICOs, you will need to load the ICO from resources in code, convert it, and then set the Icon property in code.
However, if you change your icon into a PNG, then your original approach will work.
Your XAML will look like this:
Icon="Resources/x.png"
And like the commenters mentioned, make sure that x.png in the Resources folder has its build action set to Resource.

There is no need to convert the .ico to .png. This works:
Project Name (right click) => Properties => Application (left side) => Icon => Browse to the existing .ico.

Related

Can't modify the icon of DXRibbonWindow in WPF

I tried to custome the icon of DXRibbonWindow by adding Icon=<Icon url> in DXRibbonWindow tag, like this:
<DXRibbonWindow Icon="<Icon Url>" ... ></RXRibbonWindow>
but it doesn't work, the icon remains as default, how can i custom the window icon?
Are you using a URL or a file path? I believe the property will only work with a correctly formatted file path to a suitable file type.
Here is an example from DevExpress for reference:
Icon="/WpfApplication9;component/Images/webcam_32.ico">

Changing ExtJS Images

I created a theme which extends the ext-theme-classic, but I want to use the neptune-theme images for tools, sliders etc.
I copied the neptune-theme images folder into my resources folder and changed the
$relative-image-path-for-uis
to this directory, but it doesn't work.
Where's my mistake?
The problem here might be the image file type.
Example: ext-theme-classic form images use .gif while ext-theme-neptune uses .png. So if you want to use neptune's form images, copy the images to your custom theme then find an image editor and change its file type from png to gif.
Or you need to override Component.scss (sass/var/) then set the following:
from:
$image-extension: 'gif' !default;
to:
$image-extension: 'png' !default;
Note: I haven't actually tried the second option but I think it should work :)

How to display image in Krypton Button

In my existing system Krypton button is been used. I want to display image instead of text in the button. My current Buttonstyle is set as "LowProfile". I am confused about the button style mode in tool kit also. I couldnt find any relevant documents for the ButtonStyle.
So my questions are:
Where can I find the good document/tutorial for the krypton tool kit?
How to display image in the krypton Button?
Image can be added in StateCommon -> Back -> Image -> {Select your image}
Also to visualize the image set Draw to True
Krypton is now open source.
https://github.com/ComponentFactory/Krypton
You can find some examples of KryptonButton in the KryptonExplorer.exe and KryptonButtonExamples.exe demo projects.
Source code for these projects are available here:
https://github.com/ComponentFactory/Krypton/tree/master/Source/Krypton%20Toolkit%20Examples
In these projects, the image is added with Properties, Values, Image, {Select your image}
Otherwise, you can also use: Properties, StateCommon, Back, Image, {Select your image}
The difference between Values and StateCommon seems to be "some padding" and therefore the image is not directly on the border/edge of the button.

Enable Text Color plugin of Tinymce in Toolbar of Visual Editor

How can i Enable the Text Color plugin of Tinymce in Toolbar of Visual Editor ?
I was able to enable the print, search and replace plugins inside the Visual Editor by editing this file
Composite/content/misc/editors/visualeditor/includes/toolbarsimple.inc
and
modifying a line in below file to include the searchreplace, print plugins
Composite/content/misc/editors/visualeditor/visualeditor.js
plugins: "compositelink,compositetable,compositeimage,compositerendering,compositecharmap,compositefield,compositetext,paste,lists,searchreplace,print",
Similarly is there any way to enable the inbuild feature of Tinymce namely Text Color, Font Size, Font Family, Table, Row, Column in the toolbar of the Visual Editor without making the changes through styles which is done by editing this file
Frontend/Config/VisualEditor/common.xml
Thanks
Ajith
Managed to get the Text Color, Background Color, Font Family, Font Size up and running inside the Composite C1 editor.
Listing down the steps below for the benefit of others.
Copy all the files and folder from Website\Composite\content\misc\editors\visualeditor\tiny_mce\themes\advanced except editor_template.js and editor_template_src.js into your Website\Composite\content\misc\editors\visualeditor\tiny_mce\themes\composite folder.
Edit the file Website\Composite\content\misc\editors\visualeditor\visualeditor.js and include the below lines in the config section.
skin: 'default',
theme_advanced_buttons1: "forecolor,backcolor,fontselect,fontsizeselect",
theme_advanced_buttons2: "",
For a complete list of options visit the TinyMCE link and go to View Source.
You might also want to inclue inlinepopups in the plugins: line for proper rendering of the popups. Any additional plugins like insertdatetime, media, print,searchreplace, etc can also be included in the same line.
To include the plugins like insertdatetime, media, print, searchreplace in existing toolbar row, edit the Website\Composite\content\misc\editors\visualeditor\includes\toolbarsimple.inc file and include the respective tags containing the commands. For eg.
<ui:toolbargroup>
<ui:toolbarbutton cmd="mceSearch" tooltip="Search" image="${skin}/wysiwygeditor/search.png" isdisabled="false" />
<ui:toolbarbutton cmd="mceReplace" tooltip="Replace" image="${skin}/wysiwygeditor/replace.png" isdisabled="false" />
</ui:toolbargroup>
Copy and merge the code from the Website\Composite\content\misc\editors\visualeditor\tiny_mce\themes\advanced\editor_template_src.js file into the Website\Composite\content\misc\editors\visualeditor\tiny_mce\themes\composite\editor_template.js file. Most of the functions can be copied over as it is. Only the common ones like renderUI need special attention. I directly gave a call to the simpleLayout function instead of using a switch in the renderUI
ic = t._simpleLayout(s, tb, o, p);
There could be some issue with not being able to see the entire content in the editor for large content, to fix this issue edit the Website\Composite\content\misc\editors\visualeditor\tiny_mce\themes\composite\skins\default\ui.css file and modify the .defaultSkin iframe css to specify proper height or overflow scroll.
To include more features to your toolbar, just edit theme_advanced_buttons1.
Good Luck..
Ajith
With Composite C1 you need to do styling (like font face, font size, colors and table related styles) using CSS classes and make these classes available to end-users.
The front-end developer define classes needed in CSS and then register them in the toolbar configuration file from where the end-user can select the styles. Composite C1 does not promote having font tags or style attributes in the content html, so if that is what you really want you need to make changes to the core javascript.
You can read about customizing the Visual Editor toolbar here http://docs.composite.net/Console/CustomizingVisualEditor.

Adding an image to a button in XAML

I'm trying to add an image to a button in my silverlight 3 application but cannot get the image to appear. I added a folder, named \images, to my Silverlight application folder and an using a relative path in the Source attribute of the Image. What am I doing wrong?
<Button Width="200"
Height="200">
<Image Source="images\document.png"></Image>
</Button>
The easiest way to find out what is going on is to add an event handler for the ImageFailed event to see what URL it is trying to use.
You should probably try using forward slashes instead of back slashes, but I'm not sure if that is the real issue.

Resources