I would like to know how to open new window in the browser with focus while keeping the other window open too.
I have a button in my silverlight app that must open a pdf in another window or tab, i want the new window to have focus while keeping the initial page open.
I can get the new window to open but without focus or i can get it to replace the current page , then returning to the app requires login etc.
So i need 3 things...
1)open new window
2)focus new window
3)leave old window open
Uri myUri = new Uri(#"http://......./ViewPDF.aspx");
HtmlPage.Window.Navigate(myUri, "_newWindow");
HtmlPage.Window.Navigate(myUri);
HtmlPage.Window.Eval("window.focs()")
HtmlPage.PopupWindow(myUri, "_blank", null);
None of these meet all 3 requirements.
please help..
Thanking you in advance
HtmlPopupWindowOptions options = new HtmlPopupWindowOptions();
options.Left = 300;
options.Top = 150;
options.Width = 1024;
options.Height = 768;
options.Directories = false;
options.Location = false;
options.Menubar = false;
options.Status = false;
options.Toolbar = false;
Uri myUri = new Uri(#"http://......./ViewPDF.aspx");
HtmlPage.PopupWindow(Uri, "_blank", options);
Related
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
}
}
);
}
I'm very new at programming in C# and Xamarin, and now I'm stuck.
I made a menu with some help, now I can do Cut/Copy/Paste which works fine, but now I want to make an Dialog or Window for some User Settings whenever they click on Settings in the menu. (I've made the menu in AppDelegate.cs)
I've look around a lot on Google and Xamarin forums, but al they talk about is to add a new kind of storyboard thingy. Which I guess will work, but I'm not using any storyboard (Just because we want to make everything out of code).
Found on Xamarin:
https://developer.xamarin.com/guides/mac/user-interface/working-with-dialogs/
And then the Preference window (That is what I prefer).
Code I made in AppDelegate.cs (Menu button which has to open an Window or Dialog):
var prefMenuItem = new NSMenuItem("Settings", ",", handler: delegate
{
var prefStyle = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;
var rect = new CoreGraphics.CGRect(200, 1000, 1024, 768);
prefWindow = new NSWindow(rect, prefStyle, NSBackingStore.Buffered, false);
prefWindow.Title = "Settings";
prefWindow.TitleVisibility = NSWindowTitleVisibility.Hidden;
});
'Settings' Button in the menu is visible btw.
Probably I forgot something, it won't open a thing.
How can I make this work?
Maybe this will work for you.
var prefMenuItem = new NSMenuItem("Settings", ",", handler: delegate
{
var prefStyle = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;
var rect = new CoreGraphics.CGRect(200, 1000, 1024, 768);
prefWindow = new NSWindow(rect, prefStyle, NSBackingStore.Buffered, false);
prefWindow.Title = "Settings";
prefWindow.TitleVisibility = NSWindowTitleVisibility.Hidden;
NSApplication.SharedApplication.RunModalForWindow(prefWindow);
});
I added NSApplication.SharedApplication.RunModalForWindow(prefWindow); in your code. This will open a new window.
Found this on: https://forums.xamarin.com/discussion/22729/xamarin-mac-how-to-set-position-of-modal-window
I am working on a project that I want to use the Chromium Web Browser and be able to read the data that would normally come though the DevTools "Network" tab. So basically all i really need is the URL and the status code (404, 200, 50x, etc).
I have everything working properly for the ChromiumWebBrowser part because that works perfectly but I cant seem to figure out the details on how to get the network data.
I found this in a github issues section but I dont really understand how to implement it. https://github.com/cefsharp/CefSharp/issues/1379
Any help would be greatly appreciated.
Here is what I have so far...
private ChromiumWebBrowser _wb;
public MainForm()
{
var cefsettings = new CefSettings { CachePath = "cache" };
cefsettings.CachePath = "cache";
if (cefsettings.CefCommandLineArgs.ContainsKey("enable-system-flash"))
{
string flashValue;
cefsettings.CefCommandLineArgs.TryGetValue("enable-system-flash", out flashValue);
if (flashValue != "1")
{
Debug.WriteLine("Flash Might Be Disabled For Chromium Web Browser");
}
}
else
{
cefsettings.CefCommandLineArgs.Add("enable-system-flash", "1");
}
//TODO: Get the latest version version folder
cefsettings.CefCommandLineArgs.Add("ppapi-flash-path","C:\\program Files (x86)\\Google\\Chrome\\Application\\51.0.2704.103\\PepperFlash\\pepflashplayer.dll");
Cef.Initialize(cefsettings);
InitializeComponent();
_wb = new ChromiumWebBrowser("http://youtube.com/")
{
Dock = DockStyle.Fill,
Location = new System.Drawing.Point(0, 22),
MinimumSize = new System.Drawing.Size(20, 20),
Size = new System.Drawing.Size(1280, 900),
TabIndex = 8
};
//Add ChromiumWebBrowser to the Browser Panel
pnlBrowser.Controls.Add(_wb);
}
Here is what I ended up doing...
Implemented a class called "RequestHandler" that implements the IRequestHandler interface. Copied most of the default code for this interfaces methods from the CEFSharp open source project and then just tweaked the "IRequestHandler.OnResourceResponse" portion to my liking.
Then on my main form that uses the web browser, I just used the code below...
//Create ChromiumWebBrowser
_wb = new ChromiumWebBrowser(Urls.HOME)
{
Dock = DockStyle.Fill,
Location = new System.Drawing.Point(0, 22),
MinimumSize = new System.Drawing.Size(20, 20),
Size = new System.Drawing.Size(1280, 900),
TabIndex = 8
};
//Add ChromiumWebBrowser to the Browser Panel and add events
pnlBrowser.Controls.Add(_wb);
var requestHandler = new RequestHandler();
_wb.RequestHandler = requestHandler;
I hope this helps someone!
The Message Boxes of WPF could be customized as i understand.
I was wondering is it possible to add a CheckBox to the WPF MessageBox with say - Don't show this message again etc.?
Possible, you can change the WPF control styles and templates as per your requirement, see these links for further references:
Custom Message Box
http://blogsprajeesh.blogspot.com/2009/12/wpf-messagebox-custom-control.html
http://www.codeproject.com/Articles/201894/A-Customizable-WPF-MessageBox
http://www.codeproject.com/Articles/22511/WPF-Common-TaskDialog-for-Vista-and-XP
Could just use a Window
Passed checked in the ctor so you can get the value back
bool checked = false;
Window1 win1 = new Window1(ref input);
Nullable<bool> dialogResult = win1.ShowDialog();
System.Diagnostics.Debug.WriteLine(dialogResult.ToString());
System.Diagnostics.Debug.WriteLine(checked.ToString());
I realize this is a very old thread, but I was searching this matter today and was surprised to see no replies mentioning Ookii: https://github.com/ookii-dialogs/ookii-dialogs-wpf
I was already using it for Folder Browsing. Now I wanted to add a "Don't Show Again" checkbox whenever the main window is closed, and it's really simple to use it.
Here's my code:
using Ookii.Dialogs.Wpf;
//create instance of ookii dialog
TaskDialog dialog = new();
//create instance of buttons
TaskDialogButton butYes = new TaskDialogButton("Yes");
TaskDialogButton butNo = new TaskDialogButton("No");
TaskDialogButton butCancel = new TaskDialogButton("Cancel");
//checkbox
dialog.VerificationText = "Dont Show Again"; //<--- this is what you want.
//customize the window
dialog.WindowTitle = "Confirm Action";
dialog.Content = "You sure you want to close?";
dialog.MainIcon = TaskDialogIcon.Warning;
//add buttons to the window
dialog.Buttons.Add(butYes);
dialog.Buttons.Add(butNo);
dialog.Buttons.Add(butCancel);
//show window
TaskDialogButton result = dialog.ShowDialog(this);
//get checkbox result
if (dialog.IsVerificationChecked)
{
//do stuff
}
//get window result
if (result != butYes)
{
//if user didn't click "Yes", then cancel the closing.
e.Cancel = true;
return;
}
When a user clicks on my button there appears a SharePoint modal dialog. The popup shows the user a confirmation message. This is already working.
Now I want the following: When the users clicks on the YES button, the first popup closes and and a new modal dialog opens.
Is this possible? And how? Or can i resize the dialog dynamicly when he's already open?
here are my methods to open the dialogs:
function OpenPopup() {
var options = SP.UI.$create_DialogOptions();
options.url = "popup.aspx";
options.width = 230;
options.height = 235;
options.title = "";
options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallbackNew);
SP.UI.ModalDialog.showModalDialog(options);
}
function OpenSecondPopup() {
var options = SP.UI.$create_DialogOptions();
options.url = "popup2.aspx";
options.width = 630;
options.height = 235;
options.title = "";
options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallbackNew);
SP.UI.ModalDialog.showModalDialog(options);
}
Is it not as simple as
Create a copy of your function CloseCallbackNew called CloseCallbackNewSecond
Change OpenSecondPopup to reference this new copy instead of the original
Add a call to OpenSecondPopup at the end of CloseCallbackNew, referencing the dialog result so as to only call it if the user clicked YES
It seems like this should call the second popup when the first is closed.