No icon in task bar - c#

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"));
}
};

Related

Open link in new tab ContextMenuStrip with CefSharp and EasyTabs

I am trying to make a fully-featured web browser in C# using the chromium embedded framework also known as CefSharp. For the tab control, I am using EasyTabs.
I want to have a custom context menu strip that has a "Open link in new tab" menu item.
This is what I have tried, but nothing happens when you run the application and click Open link in new tab.
I'd appreciate any help I can get.
if (commandId == (CefMenuCommand)OpenLinkInNewTab )
{
ResistBrowser.frmMain form;
ResistBrowser.AppContainer appcontainer1;
appcontainer1 = new ResistBrowser.AppContainer();
form = new ResistBrowser.frmMain();
browserControl.Load(parameters.SelectionText);
appcontainer1.Tabs.Add(
// Our First Tab created by default in the Application will have as content the Form1
new TitleBarTab(appcontainer1)
{
Content = new ResistBrowser.frmMain
{
Text = form.Text
}
}
);
}

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.

Newly Created toolbar icon is not Showing in the Toolbar

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

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 can I use the Windows look'n'feel for a system tray context menu?

I'm working with a NotifyIcon and ContextMenuStrip, I don't want to use the default menu look and feel which is shipped out of the box with this control which is different to Windows (Vista in my case) by using contextMenu.RenderMode = ToolStripRenderMode.ManagerRenderMode or contextMenu.RenderMode = ToolStripRenderMode.Professional:
I don't want this using contextMenu.RenderMode = ToolStripRenderMode.System:
I just want to use the standard, normal Windows "look and feel" as seen in countless, probably non-.net applications *grumble*:
Any ideas guys on how to achieve this?
On Vista, it renders correctly (i.e., the same way DropBox renders on my machine) when using all the defaults.
Here's a sample program that works for me. Try it, and if it doesn't render correctly for you, try uncommenting the two commented lines.
using System;
using System.Windows.Forms;
using System.Drawing;
public class AC : ApplicationContext
{
NotifyIcon ni;
public void menu_Quit(Object sender, EventArgs args)
{
ni.Dispose();
ExitThread();
}
public AC()
{
ni = new NotifyIcon();
ni.Icon = SystemIcons.Information;
ContextMenu menu = new ContextMenu();
menu.MenuItems.Add("Quit", new EventHandler(menu_Quit));
ni.ContextMenu = menu;
ni.Visible = true;
}
public static void Main(string[] args)
{
//Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false);
AC ac = new AC();
Application.Run(ac);
}
}
For reference, this is how to get a notification icon with a Windows-styled context menu:
1) In the controls toolbox, right-click All Windows Forms > Choose Items
2) Tick ContextMenu > OK
3) Right-click All Windows Forms > Sort Items Alphabetically
4) Drag the new ContextMenu into the form designer
5) Right-click ContextMenu1 > Properties > Rename it to something memorable (for future reference, I've renamed mine to myNotifyIconContext)
6) In the Solution Explorer, expand Form1.cs (etc) > Double-click Form1.Designer.cs
7) Find your notification icon - it will look something like this:
//
// notifyIcon1
//
this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "My Notification Icon";
this.notifyIcon1.Visible = true;
Here, I previously had a ContextMenuStrip.
8) Change the first line of code to (or add):
this.notifyIcon1.ContextMenu = this.myNotifyIconContext;
et voila!

Categories

Resources