Newly Created toolbar icon is not Showing in the Toolbar - c#

I want to add a new icon to the Notepad++ toolbar.
I've tried following code
internal static void SetToolBarIcon()
{
toolbarIcons tbIcons = new toolbarIcons();
tbIcons.hToolbarBmp = tbBmp.GetHbitmap();
IntPtr pTbIcons = Marshal.AllocHGlobal(Marshal.SizeOf(tbIcons));
Marshal.StructureToPtr(tbIcons, pTbIcons, false);
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_ADDTOOLBARICON, PluginBase._funcItems.Items[idMyDlg]._cmdID, pTbIcons);
Marshal.FreeHGlobal(pTbIcons);
}
Now my problem is that instead of an icon I only see a black square in the toolbar

Remember to save your icon in the Resources.resx

Related

Visual Studio Custom ToolBox Item Collection Value

i am currently working on my own TabControl, just to give me more options in customization.
To come along with this, i've made my own TabPage too.
Edit: Rewrote my question with pictures:
I want this Field:
After Clicking on "Collection" you gain a new Box to "Add" and "Remove" the Values
So here's what i've done:
If i now hit "Add" some pages appear, if i hit "remove" some pages disappear.
So far so good.
Clicking on "OK" does not show them up (but they are still there, after reopening the menu)
Now the random stuff happens:
If i press "Cancel" all the 'tabs' are generated.
If i open the menu again, all the "tabPages" are shown as there ClassType.
Here is the code of my TabControl Class
//The List for my TabPages
List<FancyTabPage> listPages = new List<FancyTabPage>();
//My Wrapper to get the Menu for the Designer shown in the Picture
public List<FancyTabPage> Pages
{
set { this.listPages = value; drawTabPages(); }
get { return this.listPages; }
}
//My function to generate the buttons
private void drawTabPages()
{
this.Controls.Clear();
resizeTabPages();
int zaehlerMax = listPages.Count;
for (int zaehler = 0; zaehler != zaehlerMax; zaehler++)
{
this.Controls.Add(listPages[zaehler].PageButton);
}
}

No icon in task bar

I have default settings for application icon, it appears normally in title window , alt-tab menu, explorer, etc. but in taskbar it is shown like this:
How to fix this and get normal icon in taskbar?
Right-click on the windows and select the Properties and apply the icon like the image
One of my problems was related to loginDialog. It is possible to get an icon in taskbar using custom icon, but still problem with standard icon is present.
var loginDialog = new LoginView();
loginDialog.Loaded += (sender, args) => {
var window = loginDialog.ParentOfType<Window>();
if (window != null) {
window.ShowInTaskbar = true;
window.Icon = BitmapFrame.Create(new Uri("pack://application:,,,/App;component/Themes/MainIcon.png"));
}
};

How to detect Xamarin Forms tabbed page click - iOS?

My scenario is, I have a Tabbed page in Xamarin Forms:
public partial class MainPage : TabbedPage
{
public MainPage()
{
InitializeComponent();
var playPage = new NavigationPage(new PlayPage())
{
Title = "Play",
Icon = "play.png"
};
var settingsPage = new NavigationPage(new SettingsPage())
{
Title = "Settings",
Icon = "settings.png"
};
var favoritesPage = new NavigationPage(new FavoritesPage())
{
Title = "Favorites",
Icon = "fave.png"
};
var aboutPage = new NavigationPage(new AboutPage())
{
Title = "About",
Icon = "info.png"
};
Children.Add(playPage);
Children.Add(favoritesPage);
Children.Add(settingsPage);
Children.Add(aboutPage);
}
}
I want to add a pause and play function to my app. On start up, the PlayPage would initially have the play.png icon and when I click on the PlayPage again it would change the icon to pause.png. Page is not changing just the page icon. Anyone has any idea how this could be done?
Edit:
So I have created a custom renderer, in OnElementChanged I utilize the ViewControllerSelected:
var tabbarController = (UITabBarController)this.ViewController;
if (null != tabbarController)
{
tabbarController.ViewControllerSelected += OnTabBarReselected;
}
And my OnTabBarReselected I have:
private void OnTabBarReselected(object sender, UITabBarSelectionEventArgs e)
{
switch (TabBar.SelectedItem.Title)
{
case "Play":
TabBar.SelectedItem.Title = "Pause";
TabBar.SelectedItem.Image = UIImage.FromFile("pause.png");
break;
}
}
This only does half of the work. It changes the Title of the selected tab bar from Play to Pause after I click on the same tab but not the Icon. The icon remains "play.png" until I get out of that tab page (selecting another tab). Anyone has any idea why?
You will need to implement a custom renderer to pull this off. There are some implementations on James Montemagno's blog where he talks about changing the icons.
iOS:
http://motzcod.es/post/138225183932/tintcolor-selectedimage-xamarin-forms-ios
Droid:
http://motzcod.es/post/157544468267/xamarin-forms-android-selected-and-unselected-tab-colors
This is however not necessarily related to your requirement of tapping the icon and changing that specific icon since all this code only runs when the page initially loads. It could be a nice starting point though. Check in there if there's a property on TabbedPage that changes when you tap on the current tab and change the icon at that point.
You also have a OnCurrentPageChanged event you can override in TabbedPage, but that isn't called when the page is already active.

Creating a windowless menu-bar icon application in Monomac/Xamarin C#

I am attempting to create an application in MonoMac/Xamarin.Mac that does not have a dock icon, nor a visible window when it launches and only an icon in the top-right menu bar.
I have set LSUIElement = 1 (tried both String and Boolean types) in Info.plist, but the status menu icon isn't displayed at all when the application launches. The only way I can get it to appear is by removing the LSUIElement flag, although then the dock icon becomes visible.
The snippet I am using is:
public partial class AppDelegate : NSApplicationDelegate
{
public AppDelegate ()
{
}
public override void FinishedLaunching (NSObject notification)
{
// Construct menu that will be displayed when tray icon is clicked
var notifyMenu = new NSMenu();
var exitMenuItem = new NSMenuItem("Quit",
(a,b) => { System.Environment.Exit(0); }); // Just add 'Quit' command
notifyMenu.AddItem(exitMenuItem);
// Display tray icon in upper-right-hand corner of the screen
var sItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
sItem.Menu = notifyMenu;
sItem.Image = NSImage.FromStream(System.IO.File.OpenRead(
NSBundle.MainBundle.ResourcePath + #"/menu_connected.png"));
sItem.HighlightMode = true;
// Remove the system tray icon from upper-right hand corner of the screen
// (works without adjusting the LSUIElement setting in Info.plist)
NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Accessory;
}
}
Does anyone know of a good way of creating a windowless application in MonoMac that doesn't have a dock icon and only a menu bar icon?
Thanks,
BB
Try specifying a .xib for the "Main nib file name'
I did this some time ago, and it works fine for me. Something like this:
New monomac project
Created an 'AppController' class in C#:
[Register("AppController")]
public partial class AppController : NSObject
{
public AppController()
{
}
public override void AwakeFromNib()
{
var statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
statusItem.Menu = statusMenu;
statusItem.Image = NSImage.ImageNamed("f3bfd_Untitled-thumb");
statusItem.HighlightMode = true;
}
In MainMenu.xib, I deleted the application menu
In MainMenu.xib, I added an custom object and set it's type to AppController
I created my status menu in the .xib and then connected it to the AppController with an outlet
In info.plist, I add the "Application is agent (UIElement)" value as a string and set it to "1"
Try it out with a .xib. If it doesn't work, maybe I can share my project for you to take apart.

How do I get a control which looks like a TabControl with no tabs?

We have a form which displays media items in tab pages of a tab control, and I'm implementing a feature which allows users to 'pop out' the tab pages into their own forms.
However, when I add the media player to a form rather than a TabPage, the background switches from the gradient fill of a tab page to the plain SystemColors.Control background of the parent form. I need to add the the media player to a control which has the same background as a TabControl, but which doesn't display a tab at the top. I tried adding the media player to the TabControl's control collection, but that just throws an exception.
How do I get a control which looks like a TabControl with no tabs? Should I keep trying to add the media player to a TabControl, or should I try to write a Panel with a custom-drawn background? If the latter, how do I make sure that works with all possible themes?
The questions seems to be about the UseVisbleBackgroundStyle. AFAIK only buttons and TabPages have this property.
The following is a very dirty hack, just to get you started:
1) derive a customControl from Panel and add "using System.Windows.Forms.VisualStyles;"
2) Add the following code
//warning: incomplete, add error checking etc
private readonly VisualStyleElement element = VisualStyleElement.Tab.Body.Normal;
public bool UseVisbleBackgroundStyle { get; set; }
protected override void OnPaint(PaintEventArgs pe)
{
if (UseVisbleBackgroundStyle)
{
var x = new VisualStyleRenderer(element);
x.DrawBackground(pe.Graphics, this.ClientRectangle);
}
else
{
base.OnPaint(pe);
}
}
Thanks to Henk - I eventually went with:
protected override void OnPaintBackground(PaintEventArgs e)
{
if (TabRenderer.IsSupported && Application.RenderWithVisualStyles)
{
TabRenderer.DrawTabPage(pe.Graphics, this.ClientRectangle);
}
else
{
base.OnPaintBackground(pe);
ControlPaint.DrawBorder3D(pe.Graphics, this.ClientRectangle, Border3DStyle.Raised);
}
}
Try creating your own customer UserControl
This answer is modified from another answer site. It does the trick rather cleanly.
In the load event for the window containing the tab control, try:
// TabControl is the name of the tab control in this window.
TabControl.Appearance = TabAppearance.FlatButtons;
TabControl.Multiline = false;
TabControl.SizeMode = TabSizeMode.Fixed;
TabControl.ItemSize = new Size(0,1);
// The tabs are now gone. Select the panel you want to display
TabControl.SelectTab("InProgressTab");

Categories

Resources