Enable toolbar in new popup window IE - c#

How to enable toolbar in new popup window where the toolbar is disabled.
I mean if the window is created using window.open("","toolbar=no") then that window don't have toolbar enabled.I want to enable toolbar in that.Is there any way to programmatically/manually achieve that

this would do the trick.But I dont know why this code dint show up in any forum.
It is so simple all you have to do is find all the InternetExplorer instance and set the Toolbar flag to true
internal static void enableToolbar()
{
ShellWindows shellWindows = new ShellWindows();
foreach (InternetExplorer ie in shellWindows)
{
String filename = ie.Name;
if (filename.Contains("Internet Explorer"))
{
ie.ToolBar = 1;
}
}
}

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

WPF Open new Window and set its property

In my WPF Program (I'm using MVVM Pattern) I have a simple button with its command.
When user click on this button the command execute method is called and a new Window is created.
In this application there are two ways to open this window: left mouse click and shitf + left mouse click on the same button.
The difference is the follow: by left mouse click the "Advanced" tab of my tabcontrol in my window isn't showed, else, by left mouse click + shift the "Advanced" tab is showed.
I have implemented this logic but i think that this isn't the best way to do it. This is the code:
Execute method of my Command:
private void OptionsExecute()
{
var isAdvancedTabVisibile = false;
if (Keyboard.Modifiers == ModifierKeys.Shift)
{
isAdvancedTabVisibile = true;
}
_windowFactory.OpenOptionsWindow(isAdvancedTabVisibile);
}
XAML (Using the name of properties):
<dx:DXTabControl Margin="5" Name="myTabControl">
<dx:DXTabItem Header="Avanzate" Name="advanced">
…
</dx:DXTabItem>
</dx:DXTabControl>
C# utility method to open Window (Following MVVM Pattern):
public void OpenOptionsWindow(bool isAdvancedTabVisible)
{
OptionsWindow window = new OptionsWindow();
var tabCollection=window.myTabControl.Items;
var tabList=tabCollection.Cast<DXTabItem>().ToList();
if (isAdvancedTabVisible)
{
tabList.FirstOrDefault(ti => ti.Name == "advanced").Visibility = Visibility.Visible;
}
else
{
tabList.FirstOrDefault(ti => ti.Name == "advanced").Visibility = Visibility.Collapsed;
}
window.ShowDialog();
}
My question is: there is a better way to do the same thing? A way by setting a flag property in my ViewModel and bind the tabitem Visibility to this property? Any other suggestion?
Thanks.

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

Handling key events on WebBrowser control?

Currently I am using an application which play ppt and flash in WebBrowser Control.
In WebBrowser I am able to hide context menu by using
this.IsWebBrowserContextMenuEnabled = false;
and capture key event by using
this.PreviewKeyDown += new PreviewKeyDownEventHandler(IWebBrowser_PreviewKeyDown);
but while playing the ppt, both context menu and keypress events are not functioning i.e. I can see context menu and arrow key force the ppt to change the slide.
Again while playing flash, context menu is visible and I can handle key event. is there any other setting to it can same for whatever (HTML, PPT, Flash, PDF) is playing in webBrowser?
Edit :1
Here is my existing code
class IWebBrowser : WebBrowser
public IWebBrowser(RegionOptions options)
{
try
{
this.Width = 600;
this.Height = 400;
this.IsWebBrowserContextMenuEnabled = false;
this.ScrollBarsEnabled = false;
this.ScriptErrorsSuppressed = true;
this.WebBrowserShortcutsEnabled = false;
this.AllowNavigation = true;
CreateContextMenu();
this.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(IWebBrowser_DocumentCompleted);
this.PreviewKeyDown += new PreviewKeyDownEventHandler(IWebBrowser_PreviewKeyDown);
}
catch (Exception ex)
{
log.Error("IWebBrowser - ctor ", ex);
}
}
private void CreateContextMenu()
{
ContextMenuStrip myContextMenu = new ContextMenuStrip();
this.ContextMenuStrip = myContextMenu;
ToolStripMenuItem myFirstTooltip = new ToolStripMenuItem();
ToolStripMenuItem mySecondTooltip = new ToolStripMenuItem();
ToolStripMenuItem myThirdTooltip = new ToolStripMenuItem();
myFirstTooltip.Text = "Item One";
mySecondTooltip.Text = "Item Two";
myThirdTooltip.Text = "Item Three";
myContextMenu.Items.Add(myFirstTooltip);
myContextMenu.Items.Add(mySecondTooltip);
myContextMenu.Items.Add(myThirdTooltip);
}
context menu Images for different controls played in webbrowser
Display a webpage..................
flash played in webbrowser.................
ppt played in webbrowser.....................
Follow these steps to get rid of the default context menu
Do what you've done to hide default context menu
this.IsWebBrowserContextMenuEnabled = false;
Add a ContextMenuStrip control to your window and give a name (let's say MyMenu)
Set your browser control's ContextMenuStrip property to MyMenu
Now, whatever the document type you display on your Browser control it'll only display your custom menu.
Hope this helped!
All the best
Override all the mouse event flags Here is an example I hope this example will help you
You've to catch the PreviewKeyDown event in your WebControl where is playing your ppt/flash and rise it to the content page or whatever.
You can check how:
define Custom Event for WebControl in asp.net

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.

Categories

Resources