Is there a way to increase the default font size of the RadMessageBox for the whole application without having to create a custom theme?
If not, how to just increase the font on the default theme in Visual Style Builder? I tried just increasing the label and button font sizes, but the style builder reset the whole form that hosts the message box to look very plain and cutting the text of the label (see attached screenshot).
Thank you.
It is possible to customize the font for all RadMessageBoxes within an application.
Implement a method ('SetTelerikControlStyles') which is called before any form and/or RadMessageBox is created. You only need to call this method once!
Add the following lines of code in the created method of step 1:
RadMessageBox.Instance.FormElement.TitleBar.Font = new Font("Calibri", 25f);
RadMessageBox.Instance.Controls["radLabel1"].Font = new Font("Calibri", 50f, FontStyle.Regular);
The FormElement.TitleBar.Font, as the name already reveals, is the title bar of the RadMessageBox.
Telerik is using dynamic named controls, so in this case radLabel1 represents the RadMessageBox text area.
Complete Program.cs sample:
using System;
using System.Drawing;
using System.Windows.Forms;
using Telerik.WinControls;
namespace WindowsFormsApplication
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
SetTelerikControlStyles();
Application.Run(new Form1());
}
private static void SetTelerikControlStyles()
{
RadMessageBox.Instance.FormElement.TitleBar.Font = new Font("Calibri", 25f);
// I added this additional check for safety, if Telerik modifies the name of the control.
if (RadMessageBox.Instance.Controls.ContainsKey("radLabel1"))
{
RadMessageBox.Instance.Controls["radLabel1"].Font = new Font("Calibri", 50f, FontStyle.Regular);
}
}
}
}
Related
I have this class derived from a Layout<view> which is the WrapLayout example from Creating a Custom Layout:
Tthe code is a little big, so I put it in this pastebin:
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace CustomLayout.ViewModels
{
// ...
// [EDIT] puting the relevant code for put the images whit
/// a tap gesture in the layout
var images = GetImages();
int i = 0;
foreach (var photo in images.Photos)
{
var image = new Image
{
Source = ImageSource.FromResource(photo),
WidthRequest = 50,
HeightRequest = 75
};
var cartaoTap = new TapGestureRecognizer();
cartaoTap.Tapped += (s, e) =>
{
cartaoClick(i);
};
image.GestureRecognizers.Add(cartaoTap);
customLayout.Children.Add(image);
i++;
}
// ...
private void cartaoClick(int index){
Navigation.PushAsync(new CartaoPage(cartao.GetImagem(index), cartao.GetNome(index), cartao.GetDescricao(index)));
}
}
pastebin Raw Code for the CustomLayout class
"Cartao" is a class with attributes like Nome, Descricao and Imagem.
In the tap gesture event I pass the int "i" value to the CartaoClcik(int index) method when I added the image in the CustomLayout, in my mind, I can get the index passed to the call of this method when I added the image in the click of the mouse in one of the image showed, but, when I run and click in a image, the index parameter is alawys of the last image added
[EDIT:].
After an inhumane search job on the internet, I see that is possible to implement a class derived from Image() and then implement the GestureRecognizer command directly in this class, but I dont know how I can implement that and also I dont know how to pass the parameter needed for the page to show the image in full screen in the `CartaoPage(Image img, string nome, string descr) whose parameters have to be passed in when the user click in a image showed in they screen
someone can help me?
[SOLVED]
I solved this question, to solve I created a class derived from Image() with a public int ID {get; set;} and then fill this attribute when I instantiate my image using my own class and then I pass this ID for my index.
I know that not is a elegant solution but is working here.
thanks for all
In my Xamarin app, I create a button (Xamarin.Forms.Button) programmatically. I need this button to show a different background image under normal vs hovered state. I have created a style resource similar to what is described at How to indicate currently selected control in Xamarin?. However, I cannot figure out how to apply this style to the button.
The Button class exposes a property called Image that is of FileImageSource type. The closest API I found to load my style resource is ImageSource.FromResource static method. However, this method seems to return StreamImageSource instance which is not what we need.
Class Button does not seem to provide any Style property.
Can you please suggest how I can programmatically associate a style to the button? Regards.
To achieve this request you need custom renderers.
To be able to apply your style f.e.: "myButtonStyle.xml" you have to create a custom renderer for your target platform:
Android:
[assembly: ExportRenderer (typeof (YourExtendedButtonClass), typeof (MyCustomButtonRenderer))]
namespace YourApp.Droid
{
public class MyCustomButtonRenderer : ButtonRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
{
base.OnElementChanged(e);
var myButton = this.Control as Android.Widget.Button;
myButton?.SetBackgroundResource(Resource.Drawable.myButtonStyle);
}
}
}
I am using Sharpshell to change my pdf and xlsx icons. Most of the times it works fine, but sometimes it shows black icons. Refreshing or restarting explorer has no effect on it.
Moreover, it works fine in certain Icon Views - for example in Details, Content it works fine, but not in Medium Icons or Tiles. Also, the icons work fine in the Server Manager tool.
There is one more thing - if I change the name of the file that has got the black icon, the correct icon immediately appears.
This is the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using SharpShell.SharpIconHandler;
using SharpShell.Attributes;
using SharpShell.Configuration;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using SharpShell.Diagnostics;
using SharpShell.Interop;
namespace IconHandlerTry2
{
[ComVisible(true)]
[COMServerAssociation(AssociationType.ClassOfExtension, ".pdf", ".xlsx")]
public class Class1 : SharpIconHandler
{
/// <summary>
/// Gets the icon.
/// </summary>
/// <param name="smallIcon">if set to <c>true</c> provide a small icon.</param>
/// <param name="iconSize">Size of the icon.</param>
/// <returns>
/// The icon for the file.
/// </returns>
protected override Icon GetIcon(bool smallIcon, uint iconSize)
{
string prefix = "C:\\Windows\\IconsForYou\\";
string filename = SelectedItemPath;
string iconFileName;
string[] splits = filename.Split('.');
string extension = splits[splits.Length - 1];
if (extension == "pdf")
iconFileName = prefix + "pdfDefault.ico";
else if (extension == "xlsx")
iconFileName = prefix + "xlsxDefault.ico";
else
iconFileName = prefix + "default.ico";
Icon icon = new Icon(iconFileName);
// Return the icon with the correct size. Use the SharpIconHandler 'GetIconSpecificSize'
// function to extract the icon of the required size.
return GetIconSpecificSize(icon, new Size((int)iconSize, (int)iconSize));
}
}
}
This is the simpler version. I will be working on hundreds of icons. Does anybody have any suggestion?
EDIT: I now see that the icons are assigned randomly. Whenever I clear the icon cache, some random icons are displayed. Sometimes there is nothing, so it becomes either full black or white. Same thing is happening in the Server Manager Tool. Please help!
I create an application on unity3d. I use Unity 5.0.2f1 (64-bit). I create a new project and add an empty gameobject. I click gameobject and add a gui text from inspector. My gui text is below :
I want to change the contenf of this text at each frame. I use below code but it doesn't change it.
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
private int count = 0;
public GUIText guiText;
// Use this for initialization
void Start () {
guiText.text = "Counter";
}
}
What should I do? I see asddffbhfbehfbhj every time.
Attach this script to your gameobject(the same game object that guitext is attached to)then assign the guitext component of your game object to your script via inspector(drag you guitext component and drop it in guitext variable that you see within your script component in inspector)
I would like to implement some think like toggle button in scout eclipse.
What I need is to change image of button for state.
I see function
setIconId(String)
but I dont know how to find parameter for this function. How to find image that scout use for different state of button?
Marko
setIconId(..) and Icons
It is a good practice in your Scout Application to pass as Argument from setIconId(..) a constant defined in the Icons Class. See Icons page on the wiki.
An example for your use case:
setIconId(Icons.WeatherSun)
In the Demo Widget Application there is an Icons class:
org.eclipsescout.demo.widgets.shared.Icons
Here some constants defined in this class:
public static final String WeatherRain = "weather_rain";
public static final String WeatherSnow = "weather_snow";
public static final String WeatherSun = "weather_sun";
The values defined in the constants represent an identifier for the image.
The Image lookup is realized by the ImageLocator. (Depending on the UI technology, the appropriate IconLocator will be used. For example, in case of Swing the SwingIconLocator implementation).
In case of weather_sun the default implementation of the ImageLocator will look for a File called weather_sun.<ext> (where <ext> can be gif, png and so on) in the \resources\icons\ folder of each plugins. In this case it will find the File: \org.eclipsescout.demo.widgets.client\resources\icons\weather_sun.png
If the image is not found, you will see a log entry like this:
!MESSAGE org.eclipse.scout.rt.ui.swing.SwingIconLocator.warnImageNotFound(SwingIconLocator.java:141) could not find image 'weather_sun'
In the Scout SDK, there is an Icons Editor. This Editor represents all the constants defined in the Icons class and the corresponding Icon. Is a file not found a red square is displayed instead of the image.
Toggle Button
There is no specific field for Toggle Button, use an AbstractButton an set the display style to DISPLAY_STYLE_TOGGLE.
See also:
10.8 - Buttons and Links in the Scout Boook.
ToggleButton wiki page.
Changing the icon in a Toogle Button
I think this code snippet does what you are looking for:
#Order(10)
public class ToggleButton1 extends AbstractButton {
#Override
protected boolean getConfiguredProcessButton() {
return false;
}
#Override
protected void execClickAction() throws ProcessingException {
if (isSelected()) {
setIconId(Icons.WeatherSun);
}
else {
setIconId(Icons.WeatherRain);
}
}
}
It would also be possible (and even better) to use execToggleAction instead of execClickAction.
Screenshot: