How do I programmatically disable DatePicker? - wpf

There are times I want to disable DatePicker. These do not work:
gDPickDate.ReadOnly = "True";
gDPickDate.IsReadOnly = "True";
The complier complains about gDPickDate.ReadOnly and gDPickDate.IsReadOnly. It never compiles.
How do I programmatically disable DatePicker?
I have found posts about doing this via WPF. I have not seen any via a C# command.

DPickDate.IsEnabled works --- https://social.msdn.microsoft.com/Forums/vstudio/en-US/89090c37-d029-46f7-bb86-ff66c651f247/how-do-i-programmatically-disable-datepicker?forum=wpf

Try this:
gDPickDate.IsHitTestVisible = false;
gDPickDate.Focusable = false;

Related

UIAutomation FlaUI - Detect opening windows on application level

I am using FlaUI for test automation and it works fine so far. Now I am trying to detect opening windows and while plain UIAutomation offers to register an eventhandler for "AutomationElement.RootElement" I cannot find a way to translate this to FlaUI as it always expects an AutomationElement. I can only think of the MainWindow, but this changes with Splash, Login, Enviroment-Selections, etc.
This is what I have now, but it does not fire when I open a window:
Window win = app.GetMainWindow(automation, TimeSpan.FromSeconds(5));
UIA3AutomationEventHandler automationEventHandler = new UIA3AutomationEventHandler(win.FrameworkAutomationElement, automation.EventLibrary.Window.WindowOpenedEvent, TestAction);
automation.NativeAutomation.AddAutomationEventHandler(automation.EventLibrary.Window.WindowOpenedEvent.Id,automation.NativeAutomation.GetRootElement(), (Interop.UIAutomationClient.TreeScope)TreeScope.Descendants, null, automationEventHandler);
Following the working plain UIAutomation code:
Automation.AddAutomationEventHandler(WindowPattern.WindowOpenedEvent,
AutomationElement.RootElement,
TreeScope.Descendants,
someDelegate);
Any help would be highly appreciated! Thanks everybody!
FlaUI has a GetDesktop method on the automation object which is the RootElement. You should be able to register an event there.
With #Roemer' help I made it work. Thank you so much!
using (var automation = new UIA3Automation())
{
AutomationElement root = automation.GetDesktop();
UIA3AutomationEventHandler automationEventHandler = new UIA3AutomationEventHandler(root.FrameworkAutomationElement,
automation.EventLibrary.Window.WindowOpenedEvent, HandleClickOnceDialogs);
automation.NativeAutomation.AddAutomationEventHandler(automation.EventLibrary.Window.WindowOpenedEvent.Id,
root.ToNative(),
(Interop.UIAutomationClient.TreeScope)TreeScope.Descendants,
null, automationEventHandler);
}
private void HandleClickOnceDialogs(AutomationElement element, EventId id)
{
}

Window.close not Working in page Refernce Apex method

I have page reference method in apex controller.
I need to close the current tab .
Here is my code:
public PageReference savePostSurveyAnswer(){
String sitePathPrefix = Site.getPathPrefix();
System.debug('savePostSurveyAnswer method start');
CaseIdentifierIdValue = ApexPages.currentPage().getParameters().get('caseIdentifierId');
ShGl_PostChatSurvey__c postChatSurvey = new ShGl_PostChatSurvey__c();
postChatSurvey.ShGl_SurveyQuestion1__c = question1;
postChatSurvey.ShGl_SurveyQuestion2__c = question2;
postChatSurvey.ShGl_SurveyQuestion3__c = question3;
postChatSurvey.ShGl_SurveyQuestion4__c = question4;
postChatSurvey.ShGl_SurveyResponse1__c = questionAnsSelected1;
postChatSurvey.ShGl_SurveyResponse2__c = questionAnsSelected2;
postChatSurvey.ShGl_SurveyResponse3__c = questionAnsSelected3;
postChatSurvey.ShGl_SurveyResponse4__c = questionAnsSelected4;
postChatSurvey.ShGl_Market_Code__c = 'US'; //new data base model
postChatSurvey.ShGl_UniqueCaseIdentifier__c = CaseIdentifierIdValue;
//postChatSurvey.ShGl_LiveTranscriptChatKey__c = chatKeyIdValue;
//postChatSurvey.ShGl_CaseOfSurvey__c = (Id) LiveChatTranscriptObj.CaseId; //through trigger
Database.SaveResult postSaveResult = Database.insert(postChatSurvey);
return new PageReference('javascript:window.close();');
}
Thanks in advance.
Any help would be appreciated.
When you check the documentation for Window.close() you will find the reason:
This method is only allowed to be called for windows that were opened by a script using the window.open() method. If the window was not opened by a script, an error similar to this one appears in the console: Scripts may not close windows that were not opened by script.
In short: The browser won't let you. This is not specific to Salesforce or VF. Windows.close() would anyway not close a tab, but the whole browser window.
If you are looking to close a console tab, this question/answer might provide what you are looking for.

Checkbox uncheck for windows 8.1 phone app

I have a control checkbox that allows the app to play sounds (SoundEnableBox) when it is checked. If they uncheck it I want it to stay unchecked (So I need to programmadigally uncheck the box when the page is reloaded. The default is set to checked. Every time the page is reloaded it gets checked again.
I tried the following code but it is not working. Do I need to bind the property? to keep it unchecked?
if (GlobalVariables.SoundsEnabled.GlobalBool == false)
{
SoundsEnabledBox.Unchecked = true;
}
I know this should be simple but not with windows phone for some reason.
After looking at this for a short while I decided to change the default to unchecked and wrote the following logic to correct the issue I was having.
if (GlobalVariables.SoundsEnabled.GlobalBool == false)
{
SoundsEnabledBox.IsChecked = false;
}
else if (GlobalVariables.SoundsEnabled.GlobalBool == true)
{
SoundsEnabledBox.IsChecked = true;
}

ExtJS 4 - Load Mask giving errors in IE8 and IE9 when used while opening a window

I have a window which opens up on a button click. The window takes time to load and hence I am using load mask in following way:
handler:function(){
var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"Loading..."});
myMask.show();
var winAppln = showWin(myMask);
if(winAppln){
var task = new Ext.util.DelayedTask(function(){
winAppln.show();
});
task.delay(2000);
}
}
I am hiding the mask object in the afterrender function of window in following way:
afterrender:function(){
if(maskObj){
maskObj.hide();
}
}
The above code works fine in all the browsers, except IE (version 9 and 8).
In IE9 and IE8, there is an error generated as "Invalid Argument" in ext-all-debug.js at line 8682 which is as following
me.dom.style[ELEMENT.normalize(style)] = value;
Could anyone guide that what can be a possible reason behind this.
Also, my main purpose is to cover the lag between the click of button & opening of window, so that user is aware about something is happening. Is there a better way of doing this other then using Load Mask, or could Load Mask be used in some different manner, then as shown above?
Thanks in advance.
PS: I am using ExtJS Version 4.0.7
As per the things found by me so far, this issue is caused when the window has modal:true set.
IE 8 and 9 create a conflict between loadMask and modal:true and throw an error.
A workaround for this is to take off modal:true from the window and set it to true in the afterrender event of window once the loadmask hide function has been called as below:
afterrender:function(){
if(maskObj){
maskObj.hide();
}
this.modal = true;
}
Hope this helps someone looking for the same.
There is a bug in ExtJS4 Ext.LoadMask which is a problem in Internet Explorer 7 and 8.
When showing a loading mask, ExtJs tries to figure out the zIndex of the parent element, then setting the zIndex of the loading mask. In Internet Explorer 7/8 an element could also have set the zIndex "auto". parseInt of the string "auto" is NaN. Setting the zIndex to NaN causes an error in IE7/IE8.
The solution: override LoadMask
Ext.override(Ext.LoadMask, {
setZIndex: function(index) {
var me = this,
owner = me.activeOwner;
if (owner) {
index = parseInt(owner.el.getStyle('zIndex'), 10) + 1;
}
if (!isNaN(index)) {
me.getMaskEl().setStyle('zIndex', index - 1);
return me.mixins.floating.setZIndex.apply(me, arguments);
} else {
return '';
}
}
});
This topic is discussed also in Sencha Forums:
http://www.sencha.com/forum/showthread.php?228673-LoadMask-and-setZIndex-and-NaN
http://www.sencha.com/forum/showthread.php?246839
Give it a try with
Ext.getBody().mask("Loading")
I use this instead of LoadMask just because in ext you can't mask more than one component with dimmed background color, .mask() does the trick. LoadMask is prettier, but has some issues, so .mask could work.

Mono winforms app fullscreen in Ubuntu?

Just wondering if there's a known way of getting a Mono System.Windows.Forms application to go fullscreen on Ubuntu/Gnome.
Mono is 2.4.2.3
Ubuntu is 9.10
Doing it on Windows requires a pinvoke, clearly not going to work here.
This is what I get setting window border to none, window position to centre, and state to maximised:
alt text http://dl.dropbox.com/u/116092/misc/permalink/joggler/screenshot01.png
Update.
Have also tried:
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
CTRL-F11
Text = string.Empty; // No caption
MaximizeBox = false;
MinimizeBox = false;
ControlBox = false;
FormBorderStyle = None;
WindowState = Maximized;
FormBorderStyle = FormBorderStyle.None;
Location = new Point(0, 0);
Size = Screen.PrimaryScreen.Bounds.Size;
All of which I end up with the same result.
I have come across a lead which involves a pinvoke involving _NET_WM_STATE_FULLSCREEN but that's as far as I've got with it. Any pointers on that would be appreciated.
_NET_WM_STATE_FULLSCREEN will just get rid of the borders. The GNOME panel will still appear.
According to the following post, the secret is to get rid of the minimum/maximum sizes so that the window manager does the resizing itself:
http://linux.derkeiler.com/Mailing-Lists/GNOME/2010-01/msg00035.html
Here is some documentation on the native spec:
http://standards.freedesktop.org/wm-spec/wm-spec-latest.html
http://www.x.org/docs/ICCCM/icccm.pdf
To talk directly to the X Window System you have to pinvoke into XLib. In order to send something like _NET_WM_STATE_FULLSCREEN you have to have a pointer to the window and also to the display.
I am not sure how to find the display but I can help with a pointer to the window. When running on X, the property Form.Handle should be a pointer to the X window.
Not sure what you mean by "Full Screen" - but I've written several Windows.Forms applications that take over the screen, and without a single PInvoke.
Here's how I configure my main form ...
Text = string.Empty; // No caption
MaximizeBox = false;
MinimizeBox = false;
ControlBox = false;
FormBorderStyle = None;
WindowState = Maximized;
Optionally,
TopMost = true;
Hope this helps.
You need to disable visual effects in ubuntu.
edit:
And make sure your form size is at least screen resolution without borders. If borders are on design time and you are removing them in code you will need something like 1030x796 for a 1024x768 display.
I have been suffered by this problem 2 days and finally i got the solution:
click the 1st icon on left tool bar and search compizconfig program. Go to preference-> unity and you will see there is a tick for unity plugin on the left side. Remove that tick and you will see the top menu bar disappeared.
Though this thread is very old but I still hope I can help anyone who gets this problem and seek for help.
Have you tried this?
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
Unfortunately I have no Ubuntu available right now, but I can see old patches for this in old mono versions...
It should be possible to display every app running inside gnome in fullscreen mode with the "CTRL+F11" hotkey.
Maybe you could try
System.Windows.Forms.SendKeys.Send();
but that is just a guess, I haven't got a Linux running atm to try this. But maybe this helps.
I can't test it at the moment, but have you tried a simple resize?
form.FormBorderStyle = FormBorderStyle.None
form.Location = Point(0, 0)
form.Size = Screen.PrimaryScreen.Bounds.Size
I have worked around this for now by setting the autohide property of the panel.
Not ideal because it depends on the user changing their environment to use my application, but better than nothing.
YMMV. http://fixunix.com/xwindows/91585-how-make-xlib-based-window-full-screen.html
The following worked:
(Inspiration was taken from here: https://bugzilla.xamarin.com/show_bug.cgi?id=40997)
1) sudo apt-get install wmctrl
2) In your code:
Form form = new MainWindow();
form.FormBorderStyle = FormBorderStyle.None;
form.WindowState = FormWindowState.Maximized;
form.Load += (s, e) => {
Process process = new Process {
StartInfo = new ProcessStartInfo {
FileName = "wmctrl",
Arguments = $"-r :ACTIVE: -b add,fullscreen",
CreateNoWindow = true
}
};
process.Start();
process.WaitForExit();
};
Application.Run(form);

Resources