IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

WinRT Discussion :

Changement de page: écran noir


Sujet :

WinRT

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 192
    Points : 79
    Points
    79
    Par défaut Changement de page: écran noir
    Bonjour

    Encore moi qui patauge dans ma découverte de dev sous windows8

    Je me suis inspiré du code de ce tuto (plutôt bien fait), pour faire un écran de chargement avant l'affichage d'images:
    Première question, dans ces tutos, il est dit que les classes dans Commom étaient automatiquement générées par visual studio (comme LayoutAwarePage). Dans Common je n'ai qu'un seul fichier StandardStyles.xaml. Pourquoi?

    Deuxième point,
    dans mon application je commence donc par lire dans un fichier un certain nombre d'information (des offset d'image). Pendant ce chargement, j'affiche un petit écran de chargement (comme dans le tuto) :
    Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    public sealed partial class ExtendedSplachScreen : UserControl
        {
            private SplashScreen splashScreen; // Variable to hold the splash screen object.
            private MZHandler mzHandler = null;
     
            public ExtendedSplachScreen(SplashScreen splash, MZHandler mozzoHandeler)
            {
                this.splashScreen = splash;
                this.mzHandler = mozzoHandeler;
     
                this.InitializeComponent();
     
                this.extendedSplashImage.SetValue(Canvas.LeftProperty, this.splashScreen.ImageLocation.X);
                this.extendedSplashImage.SetValue(Canvas.TopProperty, this.splashScreen.ImageLocation.Y);
                this.extendedSplashImage.Height = this.splashScreen.ImageLocation.Height;
                this.extendedSplashImage.Width = this.splashScreen.ImageLocation.Width;
     
                AttachHandler();
     
                ExecuteParsing();
            }
     
            private void ExecuteParsing()
            {
                if (this.mzHandler != null)
                {
                    this.mzHandler.ParseMZFileAsyncr();
                }
            }
     
            internal void splashScreen_Dismissed(SplashScreen sender, object args)
            {
     [...]
            }
     
            void mzHandlerPageLoadProgress(object sender, MZHandler.PageLoadEnventArgs e)
            {
                txtLoading.Text = "Chargement page " + e.nbPage;
            }
            void mzHandlerPagesLoaded(object sender, MZHandler.PageLoadEnventArgs e)
            {
                Navigate(this.mzHandler);
            }
     
            void AttachHandler()
            {
                this.splashScreen.Dismissed += splashScreen_Dismissed;
                this.mzHandler.LoadMZFileProgress += mzHandlerPageLoadProgress;
                this.mzHandler.PagesLoaded += mzHandlerPagesLoaded;
            }
     
            void DetachHandler()
            {
                [...]
            }
     
            void Navigate(MZHandler mzHandler)
            {
                DetachHandler();
                var rootFrame = new Frame();
                rootFrame.Navigate(typeof(MainPage), mzHandler);
     
                // Place the frame in the current Window and ensure that it is active
                Window.Current.Content = rootFrame;
                Window.Current.Activate();
            }
        }
    Jusque là, pas de problème.

    C'est au moment d'afficher la page "MainPage" que ca ne va pas. 9 fois sur 10, j'ai un écran noir . Je suis quasiment sur que mon objet MainPage est bien construit (dans une version précédente, je l'affichais sans problème). J'ai passé la journée à chercher d'ou ca pouvais venir (break pont, pas à pas...), je ne vois pas pourquoi j'ai un écran noir et pas ma page.
    Voici le xaml de mainpage:
    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    <Page
        x:Class="MZReader01.MainPage"
        IsTabStop="false"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:MZReader01"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
     
        <!-- Ressource de la page -->
        <Page.Resources>
            <!-- Style pour le bouton zoom -->
            <Style x:Key="ZoomAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
                <Setter Property="AutomationProperties.AutomationId" Value="ZoomAppBarButton"/>
                <Setter Property="AutomationProperties.Name" Value="Zoom"/>
                <Setter Property="Content" Value="&#xE12E;"/>
            </Style>
            <!-- Template pour l'affichage d'une page avec l'image de la page (Thumbnail/Mini) et un texte -->
            <DataTemplate x:Key="PageTemplate">
                <Border Background="Orange">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="300"/>
                        </Grid.ColumnDefinitions>
                        <Grid Grid.Column="0">
                            <StackPanel x:Name="ImagePanel" Height="669" Margin="20,10,10,0" VerticalAlignment="Top" Width="1036" HorizontalAlignment="Center" Orientation="Horizontal">
                                <Image x:Name="ImageView" Source="{Binding ImageData}" Margin="0,10,10,10"
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Bottom"/>
                            </StackPanel>
                        </Grid>
                        <Grid Grid.Column="1">
                            <TextBlock x:Name="ImageNameFied" Text="{Binding PageText}" TextWrapping="Wrap" Margin="10,10,10,10" 
                               FontSize="24"
                               Foreground="AliceBlue"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"/>
                        </Grid>
                    </Grid>
                </Border>
            </DataTemplate>
            <!-- Instanciation du template selector pour le flipview -->
            <local:MZPageTemplateSelector x:Key="pageTemplateSelector" PageTemplate="{StaticResource PageTemplate}"/>
        </Page.Resources>
     
        <!-- Tool bar en bas de la page -->
        <Page.BottomAppBar>
            <AppBar IsOpen="True" HorizontalContentAlignment="Center" IsSticky="True">
                <Grid>
                    <StackPanel Orientation="Horizontal">
                        <Button x:Name="PreviousButton" Style="{StaticResource PreviousAppBarButtonStyle}" Click="PreviousButton_Click"/>
                        <Button x:Name="ZoonButton" Style="{StaticResource ZoomAppBarButtonStyle}" Click="ZoonButton_Click"/>
                        <Button x:Name="NextButton" Style="{StaticResource NextAppBarButtonStyle}" Click="NextButton_Click"/>
                    </StackPanel>
                </Grid>
            </AppBar>
        </Page.BottomAppBar>
     
        <!-- Grid principal -->
        <Grid x:Name="MainGrid" Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
            <FlipView x:Name="pageFlipView" ItemTemplateSelector="{StaticResource pageTemplateSelector}"></FlipView>
        </Grid>
    </Page>
    (Remarquer la forte ressemblance avec mon topic précédent

    Je patine, je tourne en rond... Est ce qq un aurait juste une petite idée pour orienter mes cherches.
    Merci d'avance

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 192
    Points : 79
    Points
    79
    Par défaut
    Bon je vais me répondre

    Je problème venait du fait que mon chargement se produisait très rapidement, même trop.
    C'est à dire que la page ExtendedSplachScreen n'était pas encore affichée que le traitement était déjà fini et que j'essayais d'afficher la page suivante. Du coup écran noir. Évident une fois qu'on a mis les brackpoint aux bons endroits et vérifié sa callstack

    Par rapport au code que j'ai posté la correction est simple:
    La fonction qui fait le traitement de load ne doit pas être appelée dans le constructeur de ExtendedSplachScreen, car la page n'ai pas encore affichée à ce moment la. Il faut l'appeler dans L'event Loaded :
    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <Page
        x:Class="MozzoView.View.MozzoSplashScreenLoading"
        IsTabStop="false"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:MozzoView.View"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" Loaded="ScreenLoaded">
    Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    private void ScreenLoaded(object sender, RoutedEventArgs e)
    {
        if (this.mzHandler != null)
        {
            this.mzHandler.ParseMZ();
        }
    }

    Avec ca, même si le traitement de chargement est très/trop rapide, il n'y a plus d'écran noir et la page suivante est affichée.
    En espérant que ca pourra servir a d'autres ^^

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. changement de dalle = écran noir
    Par tchenoo dans le forum Périphériques
    Réponses: 7
    Dernier message: 10/03/2015, 19h59
  2. écran noir après changement de carte mère
    Par bubulateuf dans le forum Composants
    Réponses: 1
    Dernier message: 04/06/2012, 19h40
  3. Réponses: 6
    Dernier message: 22/06/2007, 15h51
  4. écran noir avec un shader d'éclairage au pixel près
    Par captainSeb dans le forum OpenGL
    Réponses: 2
    Dernier message: 16/05/2005, 12h30
  5. Visual C++ 6 : Problème impression d'écran noir
    Par charliejo dans le forum MFC
    Réponses: 6
    Dernier message: 24/01/2005, 09h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo