I have an application which uses Twain driver to scan documents to preview on my application. When I am scanning the documents, it should show a Progress Indicator of the process of scanning the document. And right there, there is a cancel button if I wish to cancel the scan in mid process. However, there the "Cancel" text is not visible but the button is and I would like to make it visible but I am not sure about it.
Below is a screenshot of what I mean:
My code settings:
var settings = new ScanSettings
{
UseDocumentFeeder = ADF,
ShowTwainUI = EnableUI,
ShowProgressIndicatorUI = true,
UseDuplex = EnableDuplex,
Resolution = rs,
Page = pg
};
try
{
TwainHandler.StartScanning(settings);
}
catch (TwainException ex)
{
MessageBox.Show(ex.Message);
//Enabled = true;
//BringToFront();
}
}
I could only figure how to hide or enable the Progress Indicator as a whole but I can't make the cancel text show up.
Does anyone know what do I need to do?
Related
issue is that in step#2, if user doesnt pick a options or simply closes displayAlert than activityIndicator runs for ever. Any idea how can I stop Activity Indicator if user closed displayAlert (In Step#2)?
ref: imagecropper plugin
Below is the full flow of code that you see:
On MainPage - Start loading using activityIndicator
Open displayAlert, with 2 options: "upload image" or "take photo"
Open camera
Take Photo
Conform photo
go to main page and wait 2 seconds (this sucks but ok)
open crop image editor
Close crop image editor and go to main page
Stop loading using activityIndicator
defualt code from link
//run loading if user picked a option
activityIndicator.IsRunning = true;
//this code always get run last thing in method
new ImageCropper()
{
Success = (imageFile) =>
{
Device.BeginInvokeOnMainThread(() =>
{
//turn off loading
activityIndicator.IsRunning = false;
imageView.Source = ImageSource.FromFile(imageFile);
});
}
}.Show(this);
Sorry for late responses, actually I want to put this in comment, but it's really hard to read in comment.
I guess you can try this code:
new ImageCropper()
{
Success = (imageFile) =>
{
Device.BeginInvokeOnMainThread(() =>
{
//turn off loading
activityIndicator.IsRunning = false;
imageView.Source = ImageSource.FromFile(imageFile);
});
},
//this 'faiure' is not typo, check ImageCropper.cs in your link
Faiure = () =>
{
activityIndicator.IsRunning = false;
}
}.Show(this);
I am doing online Exam application using asp.net in this i have to disable the titlebar so that the user has no option to exit with in the time period.So please help with this one
Its not good practice to force user to stay on the page if they don't wish to, but you can have some work around if you want to confirm the close event before they leave the browser tab
function internalHandler(e) {
return "Please don't leave the page you can be fail in exams!";
}
if (window.addEventListener) {
window.addEventListener('beforeunload', internalHandler, true);
} else if (window.attachEvent) {
window.attachEvent('onbeforeunload', internalHandler);
}
If you prevent user to close it any way you don't have control over ALT + F4 or closes it from Task Manager
you can do it using javascript like this
var message = "You have not completed exam. Are you sure you want to leave?";
window.onbeforeunload = function(event) {
var e = e || window.event;
if (e) {
e.returnValue = message;
}
return message;
};
and you can unload it when user finish the exam
window.onbeforeunload = null;
or you can create your own browser application using c# windows forms. where you can set this custom option without having close button. You load your web application form in windows forms application easily.
onbeforeunload & onunload will help you out. You can't disable but you can show user an alert.
var showMsgTimer;
window.onbeforeunload = function(evt) {
var message = 'Don't Discard';
showMsgTimer = window.setTimeout(showMessage, 500);
evt = evt || window.evt;
evt.returnValue = message;
return message;
}
window.onunload = function () {
clearTimeout(showMsgTimer);
}
function showMessage() {
alert("You're Right!");
}
If this is not the one you expect. Then please try https://eureka.ykyuen.info/2011/02/22/jquery-javascript-capture-the-browser-or-tab-closed-event/
I have write the ActiveX using C# to communicate with the other browser-based system b, it need pops up an dialog in an other thread because of the existing architecture. the current behavior is that the dialog can be hidden behind if i click the browser title. Is it possible to keep the pops-up dialog always on the top of browser(IE8)? Thanks in advance.
public int operation()
{
....
MyMsgBox myMsgBox = new MyMsgBox(message,title);
evt = System.Threading.AutoResetEvent(false);
Thread showDialogThread = new Thread(ShowMsgDialog);
ShowDislogThread.SetApartmentState(System.Threading.ApartmentState.STA);
showDialogThread.Start(myMsgBox);
System.Threading.WaitHanle.WaitAll(new System.Threading.WaitHandle[] {evt});
....
}
public void ShowMsgDialog(object requestObj)
{
MyMsgBox msgBox = (MyMsgbox)requestObj;
msgBox.showDialog();
evt.Set();
}
Class MyMsgBox:Form
{
public MyMsgBox(string message, string title)
{
//do initialization....
}
}
I have tried to set the TopMost of Form to 'true', then it will be always on the top of all applications. it's not meet the requirement as the pops-up dialog need be only always on the top of browser. Thanks.
I don't think that what you want will be possible.
However, you can make a div stretched across all page and set and event on mouse move to call BringToFront on your ActiveX object. That should do the trick.
I have a tabpage user control and 3 property pages for the tabpage user control which are assigned dynamically. This tabpage control is being shown inside the dialog.
The processing and filtering of data for the tabpage control is taking more time and this is resulting in a busy icon shown for more than 10 seconds before opening the Dialog.
I would like to show an empty Dialog opened and show the busy icon while the processing and filtering of data is done and finally shows inside the Dialog.
This is basically changing the order of processing.
However, I am not able to achieve this, and once the dialog is opened it waits for the user input and after giving the input only it goes to the next line. (as observed during debugging).
In the code below, the line MnemonicSelector.InitializeMnemonicSelectorParameters(parameters);
is responsible for the processing and moving that after the showdialog is resulting in object not found action when the user clicks on any item inside the property page under the dialog.
public override MnemonicSelectorResult ShowMnemonicSelector(MnemonicSelectorSearchParameters parameters)
{
MnemonicSelector.InitializeMnemonicSelectorParameters(parameters);
ResizeMnemonicSelectorIfNeeded();
SetupMnemonicDialog(m_PropertyDialog, MnemonicSelector, MnemonicSelector.Title);
DialogResult dResult = ShowFakeDialog(m_PropertyDialog, MnemonicSelector.Title);
return MnemonicSelector.Result;
}
private void ResizeMnemonicSelectorIfNeeded()
{
if ((MnemonicSelector.ClientSize.Width < 909) || (MnemonicSelector.ClientSize.Height < 620))
m_PropertyDialog.ClientSize = new System.Drawing.Size(939, 697);
}
protected void SetupMnemonicDialog(PropertiesDialogControl propertydialog, PropertyPage page, string title)
{
List<PropertyPage> pages = new List<PropertyPage>();
pages.Insert(0, page);
PropertyPage[] propertyPages = pages.ToArray();
if (title != null)
propertydialog.Text = title;
propertydialog.SetPropertyPages(new List<PropertyPage>(propertyPages));
}
public virtual DialogResult ShowFakeDialog(Control contents, string title)
{
return ShowFakeDialog(contents, title, false, "");
}
public DialogResult ShowFakeDialog(Control contents, string title, bool isCancelButtonVisible, string cancelButtonText)
{
FakeDialog fakeDialog = new FakeDialog(this, contents, title, isCancelButtonVisible, cancelButtonText);
using (fakeDialog)
{
lock (this)
{
FakeDialog previousFakeDialog = _activeFakeDialog;
_activeFakeDialog = fakeDialog;
try
{
return fakeDialog.ShowDialog();
}
finally
{
_activeFakeDialog = previousFakeDialog;
}
}
}
}
Please advice on on I can achieve the desired functionality wherein, I can show the dialog and load the property pages (processing) later.
You should use a background worker thread for this. Check this. It should help you to use background worker to separate your progress animation from your processing logic.
I have the following code:
ShowPoup();
if (_watcher == null)
{
_watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
_watcher.MovementThreshold = 15; // use MovementThreshold to ignore noise in the signal
_watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
}
if (!_watcher.TryStart(true, TimeSpan.FromSeconds(3)))
{
MessageBox.Show("Please turn on location services on device under Settings.");
//HidePopup();
}
My problem is that the popup doesn't appear until after the _watcher.TryStart() method returns. The point of the popup is to show a loading overlay to tell the user the app is doing something. It's pointless to have it show after the work is done, at which point I hide the popup, so the user never sees anything.
I have this popup code throughout the app and this is the first time I've encountered this issue. Even if I call ShowPopup() in a separate method before calling the current method, it still doesn't show until after _watcher starts. I'm not sure why this is happening.
It looks like you are blocking the UI thread during the TryStart. If you can move the watcher initialization to a background thread (e.g. to the threadpool) then you can keep the display "alive".
Something like:
ShowPoup();
if (_watcher == null)
{
_watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
_watcher.MovementThreshold = 15; // use MovementThreshold to ignore noise in the signal
_watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
}
System.Threading.ThreadPool.QueueUserWorkItem((ignored) =>
{
if (!_watcher.TryStart(true, TimeSpan.FromSeconds(3)))
{
Dispatcher.BeginInvoke(() =>
{
HidePopup();
MessageBox.Show("Please turn on location services on device under Settings.");
}
});
});