Caliburn micro ShowDialog wont appear a second time - dependency-injection

I am working on an application that has a splash screen and then a login screen before it pulls up the application. I am using Caliburn Micro to tie everything together but for some reason I am only able to get the Splash Screen to appear. Once the splash screen finishes loading, I call the secondWindow.ShowDialog(LogOnVM) and nothing happens. If I comment out the splash screen code, the the login screen does appear just fine. They just don't appear one after another.
I used Application.Windows.Count after the second ShowDialog gets called and it does show a count of 1. (It is 0 after the first dialog closes) So I know there is a form opening somewhere but I its not visible or something.
I have even tried creating a new instance of WindowManager but that did nothing either.
I have placed:
var cmWindowManager = IoC.Get<IWindowManager>();
var cmSplashScreenViewModel = IoC.Get<SplashScreenViewModel>();
cmWindowManager.ShowDialog(cmSplashScreenViewModel);
var cmLogOnViewModel = IoC.Get<LogOnViewModel>();
var result = cmWindowManager.ShowDialog(cmLogOnViewModel);
Here is how it is being setup. Should I create a second SimpleContainer
protected override void Configure()
{
LogManager.GetLog = x => new DebugLog(x);
sc = new SimpleContainer();
sc.Singleton<IWindowManager, WindowManager>();
sc.Singleton<IEventAggregator, EventAggregator>();
sc.Singleton<IFakeStartupTask, FakeStartupTask>();
sc.PerRequest<SplashScreenViewModel>();
sc.Singleton<IMessageBoxService, MessageBoxService>();
sc.PerRequest<LogOnViewModel>();
}

you need to call TryClose() in your cmSplashScreenViewModel
Below code can show twice the login window (after the 1st login closed)
var login = this.container.GetExportedValue<LoginViewModel>();
var windowManager = IoC.Get<IWindowManager>();
windowManager.ShowDialog(login);
windowManager.ShowDialog(login);

Related

View is completely black for few seconds in first launch in ios, swift

I was requested to show two Splash Screens when app launch. one
for a specific group of customers and other for another group of
customers. As I know, Apple doesn't allow to show two splash
screens, because it is already signed to Bundle. so I decided to
use an UIImageView and change the image by checking the group.
To check the group I used deep links which provide by the Branch.io. when someone came from the referral link which we created, it show one image and if someone came from normal way we show another image as launch image, instead of splash screen. it works properly.
But when the first launch it shows Black Screen for five to six seconds(considerable time) and show the image.
If it is not the first time, it works properly.(black screen for 1 to 2 second.)
Below is the way which I used to check the condition and show the image in another viewController.
in AppDelegate, inside the didFinishLaunchWithOption method I checked with branch like below.
let branch : Branch = Branch.getInstance()
// branch.setDebug()
branch.initSessionWithLaunchOptions(launchOptions) { (params, error) in
if error == nil {
let clickedBranchlink : Bool = params["+clicked_branch_link"] as! Bool
let isfirstSession : Bool = params["+is_first_session"] as! Bool
if clickedBranchlink == true {
let theReferrer : String = params["referrer"] as! String
if theReferrer == "groupA" {
// in here I checked the group and set userdefault values and navigate to the view which the image view has and show the image according to this condition.
}
}
}
NOTE: is there a way to increase the process of this and reduce the
black screen. do I do this inside a main thread. because first time it
avoid to go through the branch.initSessionWithLaunchOptions and then
it goes through it. hope your help with this.
This initSessionWithLaunchOptions will be called every time you launch the app and the app is not in the background. Given your observation that the issue only occurs the first time the app is installed, my hunch is that you have code running in didFinishLaunchingWithOptions before the Branch initSessionWithLaunchOptions function is called.
The Branch initialization process involves sending a network request and then waiting for a response, so this is always going to take some time - but there will be no difference in the time it takes on install vs. any other open. Start this asynchronous Branch initialization as quickly as possible, before any other code in didFinishLaunchtingWithOptions executes, and you should be able to reduce the time before the splash page displays. This should eliminate any variability in the time it takes to display the splash image that you believe may be related to Branch.

Angular Material: How to display one toast after another one is displayed while keeping both on screen?

I'm using $mdToast (Angular Material framework) directive to show several status messages in my Angular(-Material) web app.
When the user signs-in, if the login is successful a toast is shown by calling:
$scope.showToastMessage = function() {
var toast = $mdToast.simple()
.content("Login successful);
.action('OK')
.highlightAction(false)
.position($scope.getToastPosition());
$mdToast.show(toast).then(function(toast) {
//...
}
});
};
After login success I need to make another check (e.g. valid session cookie) and show another toast message without overriding the previous one and after the previous one is actually showed.
The issues I get here are:
the second toast is shown before the new one (probably due to $mdTost's async nature)
this second toast is shown for less than one second and then disappears leaving on screen only the first one (basicly the second one is shown first and then hidden when the first one appears)
A solution could be either:
creating the second toast inside then .then callback: this doesn't work either because requires the user interventions to press the "OK" action button
calling $mdToast.updateContent(); (https://material.angularjs.org/#/api/material.components.toast/service/$mdToast) which would overwrite previous toast message (this is not the best solution but would be fine either) but I can't figure out how:
(1) choose a specific toast shown on screen (let's suppose I have several toasts shown by different calls) , and
(2) update the toast message after a delay (let's say 3 seconds) in order to show to make the user undersand that the login was successful but there is some other information.
Any clue?
I was not sure if you wanted to show both toasts at the same time or not. If you wanted to show the sequentially you can put the second call to toast inside of the then because the action (OK) resolves the promise of the first toast. This is what I've tried:
var toast = $mdToast.simple()
.content('top left')
.action('OK')
.highlightAction(false)
.position($scope.getToastPosition());
var toast2 = $mdToast.simple()
.content('Checking some other things')
.highlightAction(false)
.position('top left');
$mdToast.show(toast).then(function() {
$mdToast.show(toast2);
});
See this CodePen.

JavaFX8: Application in fullscreen mode doesn't show focus on elements

I have the following problem: I would like to see which textfield or button is focused when I enter my multiscreen application in fullscreen mode. But for some reason, it is not showing the focus "glow" around for example a textfield. This is not a major problem, while it is focused the way I want it (requestFocus() does its job).
But it now gets annoying when I want to use AutoComplete TextField Completion from ControlsFX (How to implement AutoComplete TextField using ControlsFX), because the list is not shown in full screen mode.
I will clarify the situation with these screenshots:
How it is now in fullscreen mode:
How it should be (and how it is in non fullscreen):
To be clear: the problem doesn't only exist with AutoComplete TextField, but with every FXML element.
If I use the fullscreen mode from OSX itself, it works the proper way (It gives an error on the background). But I want the application to start in fullscreen mode.
This the code from my Main.java:
public class Main extends Application {
//Get the screenscontroller instance
octocash.GUI_Screens.ScreensController mainContainer = octocash.GUI_Screens.ScreensController.getInstance();
//Get the configuration instance
Configuration initApp = Configuration.getInstance();
//Create an object of Functions to establish a database connection
public static Functions databaseConnection = new Functions();
//Create a stage object to hold the primarystage
public static Stage primaryStage;
#Override
public void start(Stage stage) throws Exception {
primaryStage = stage; //set the primary stage
databaseConnection.DB_Connect(); //establish database connection
//Load the initial screen (lockscreen)
mainContainer.loadScreen(Configuration.lockScreen, Configuration.lockScreenFile);
mainContainer.setScreen(Configuration.lockScreen);
Group root = new Group(); //Create a group to hold all other screens
root.getChildren().addAll(mainContainer); //Add all Screenscontroller screens to the Group
Scene scene = new Scene(root); //set the group to the scene
stage.getIcons().add(new Image("file:src/octocash/images/octo_cash_logo.png")); //add a menubar icon
stage.setTitle("OctoCash Development"); //set the window name
stage.setScene(scene); //set the scene
stage.setFullScreen(true); //full screen without borders (no program menu bars)
stage.setFullScreenExitHint(""); //Don't show "Press ESC to exit full screen"
//stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); //DO NOT TURN ON UNLESS YOU CREATED ANOTHER METHOD TO EXIT THE PROGRAM
stage.show(); //show the application
}
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
launch(args); // start the application
}
}
As you can see, I am using a ScreensController, which is basically a StackPane with all of the screens in it.
I hope the question is clear to you all.
Any help is greatly appreciated!
I figured out that this is an error in Java JDK 8u25. I have now updated to Java JDK 8u40, and this solves the problem. Also, I have tested the fullscreen focus on Windows and Linux, and there it also works. So if you are having the same problem, just update your JDK.

XNA loading/splash screen on game start

I'm trying to have a loading screen that pops up as soon as you run that executable that launches the game, whilst the game loads I want to display an image on the desktop much like how Gamemaker allows you to have a loading image.
I've had a brief look around and most people want an image to be shown whilst they load content which is not what I want, or perhaps it is... =P
My guess would be to set the game window borderless at the start, load the splash screen, draw it, then begin all the main loading (Specifically loading DirectInput through SlimDX takes a while). However would this support having a transparent/irregular shaped image? E.G if I wanted a borderless circle to be displayed whilst the game loads, would that be possible?
Thanks.
It's very simple. Just implement System.Threading and you're done.
Here's how it works, first add:
using System.Threading;
to the top of your class, then add the following things:
//the enum for state types
enum GameState
{
Loading,
StartMenu
}
//Init our gameState enum as variable
GameState gameState;
protected override void LoadContent()
{
gameState = GameState.Loading;
spriteBatch = new SpriteBatch(GraphicsDevice);
device = GraphicsDevice;
Window.Title = "Your Window";
//Other stuff that you had here before, now go in LoadGame()
loadingscreen = Content.Load<Texture2D>("loading");
Thread bgLoad = new Thread(new ThreadStart(LoadGame));
bgLoad.IsBackground = true;
bgLoad.Start();
}
public void LoadGame()
{
//Loading stuff here
gameState = GameState.StartMenu; //or GameState.Playing
}
and then put a loading texture in your Content Project
If I understand you correctly, you essentially want to have a window opened that is not full screen that also lacks the regular border and buttons that accompanies a window.
I can't test this but this should be a good start.
Here!
I would start by creating a bare bones Game1 class that can track an image and keep track of time for a timer.
Later you could add logic that actually tracks the loading of assets in the main program.
To start I'd just test it for a fixed time like 3 seconds.

Blackberry - problem with UiApplication.popScreen() on Blackberry OS 4.5

I have a application with a screen manager class that is causing me some problems.
The application makes requests to the server to perform searches and allows the user to view results.
The application has worked fine on all OS versions up to 4.5 where we are sudden having
problems viewing a screen under certain circumstances.
It occurs when the user has performed a search and they wait for the results.
While waiting for results, they press the trackball which displays a menu.
This is not needed to display the results, it just happened that the user decided to press it.
When the results come back from the server, the results screen should automatically be displayed. On OS 4.5, the code displays the results screen runs but then the application completely falls over. If the user doesn't press the trackball while waiting, the application works fine.
Looking at the logs, they show no exception being thrown and the only suspect line being
System data:VM:DPNAv=78,p
By adding in some more log lines I have discovered that the code is reaching the
UiApplication.getUiApplication().popScreen(screen);
line in the method hideScreen(Screen screen) but when called from hideCurrentScreen(). By adding in some more debugging I find that the active screen at this point is DefaultMenuScreen (as the menu button has been pressed)
So it seems the problem is that I am trying to pop one of my own screens from the display
stack when the DefaultMenuScreen one is the active one. I repeat that this code did work on OS previous to 4.5. By running the same code on the 8300 with OS 4.2.2 with the debugging statements, I can see that the same thing happens, the active screen is the DefaultScreen but removing my own screen does not cause the whole application to crash.
The one way round this I could see, was to change the hideCurrentScreen() to just remove the active screen but this does not seem like the correct way to do it.
Has anyone else had experience of this? Can anyone tell me why this is happening? What are we meant to do if we cannot remove our screens when a DefaultMenuScreen is the active one?
This occurs in both device and simulator for 8310 and 9700.
The screen manager code is as follows.
public class ScreenManager
{
private Hashtable screens;
private String currentScreenName;
public ScreenManager()
{
screens=new Hashtable();
}
/**
* Description of the Method
*
*#param sCardName Description of Parameter
*/
public boolean showScreen( String sScreenName )
{
boolean bSuccess=false;
if (sScreenName != null && sScreenName.length() > 0 )
{
MainScreen screen=(MainScreen)screens.get(sScreenName);
if (screen!=null)
{
// We have a new screen to display so pop the current screen off the stack
hideCurrentScreen();
// If the screen is on the stack then pop the screens until we get our target screen
// otherwise just push the screen onto the stack.
if (screen.isDisplayed())
{
Screen activeScreen=null;
synchronized(UiApplication.getEventLock())
{
activeScreen=UiApplication.getUiApplication().getActiveScreen();
}
while (screen!=activeScreen && activeScreen!=null)
{
activeScreen=hideScreen(activeScreen);
}
bSuccess=(screen==activeScreen);
}
else
{
synchronized(UiApplication.getEventLock())
{
UiApplication.getUiApplication().pushScreen(screen);
bSuccess=true;
}
}
}
}
if (bSuccess)
{
this.currentScreenName=sScreenName;
}
else
{
Logger.warning("ScreenManager: Failed to display screen ["+ sScreenName +"]");
}
return bSuccess;
}
private Screen hideCurrentScreen()
{
Screen activeScreen=null;
if(currentScreenName!=null)
{
MainScreen screen=(MainScreen)screens.get(currentScreenName);
activeScreen=hideScreen(screen);
}
return activeScreen;
}
private Screen hideScreen(Screen screen)
{
Screen activeScreen=null;
if (screen!=null && screen.isDisplayed())
{
Logger.finest("Hiding Screen ["+currentScreenName+"]");
synchronized(UiApplication.getEventLock())
{
UiApplication.getUiApplication().popScreen(screen);
activeScreen=UiApplication.getUiApplication().getActiveScreen();
}
Logger.finest("Hid Screen ["+currentScreenName+"]");
}
return activeScreen;
}
//Rest of code omitted
}
The only way round this I managed to find was what I mentioned in the question. When I want to remove the current screen. I need to check it is the same as the active screen. If it is not the same then I just remove the active screen until I reach the screen I am looking for. This would only happen if a menu or pop up was displayed. Also, I need to add checks to my custom pop-up code to make sure it does not try and remove a screen that has already been removed.
It seems a bit messy but could not find any other alternatives.
The way we pop screens in our app is to explicitly pop the screen you want off the stack, as opposed to just the top-most screen. This either requires keeping track of which screens you have on the stack, or some code to iterate through the screens on the stack and search for the particular screen you want to pop off.

Resources