create pop-up disclaimer window on web map load

4972
4
03-16-2011 07:34 AM
by Anonymous User
Not applicable
Hi all,

I would like a visitor to my SL-powered web map to be presented with a disclaimer window that they must accept (via checkbox) before being allowed to view the application.  Any ideas on where to start?
0 Kudos
4 Replies
by Anonymous User
Not applicable
For the benefit of the community:

It looks like the best way to approach this is to leverage 'Child Windows,' which first became available at SL3.  This type of popup window can be configured with buttons such that the application pauses loading until the user clicks the 'accept disclaimer' button - if the 'do not accept' button is clicked, the application closes.  You just need to run the code at startup, and the window can be populated with whatever disclaimer text your legal department requires.  See this webpage for an introduction:

http://www.silverlighttoys.com/Tutorials.aspx?tutorial=2
0 Kudos
JMcNeil
Occasional Contributor III
I would just keep it super simple and create a windowpanel or a collapsible panel that fires up when the project opens.  If I was using a collapsiblePanel I would set the IsEpanded="True", Place it in the middle of the app/screen set the hieght / width to cover most of the app.  Throw your disclaimer in there and at the bottom place a checkbox and a close button next to it...write your close button to fire with an if statement...if the checkbox is check allow the panel to close or you could maybe bind the checkbox to the panel.

Well I just saw your new post and it looks much nicer and cleaner than my suggestion....good luck!

J
0 Kudos
KeithGanzenmuller
Occasional Contributor II
Where did you end up putting the code to pop-up your disclaimer childwindow?

I created one and for now it pops up on the maps Loaded event. Seems to work fine, I was just wondering if there is a better spot for it.


Thanks,
KG
0 Kudos
BrandonCales
New Contributor III
I know this post is rather old, but wanted to share my solution. I believe I got it from this forum somewhere.

MainPage.xaml.cs
//add this just inside the main usercontrol class
        //Disclaimer
        Disclaimer disclaimer = new Disclaimer();
        public bool DisclaimerShown = false;
...
...
//add this in after the MainPage() section
#region Disclaimer
        private void ShowDisclaimerOnLoad(object sender, EventArgs e)
        {
            if (DisclaimerShown == false)
            {
                if (GetCookie("GIS-Disclaimer") != "TRUE")
                {
                    SetCookie("GIS-Disclaimer", "TRUE");

                    disclaimer.Show();

                    DisclaimerShown = true;
                }
                else
                {
                    //MapBlackout.Visibility = Visibility.Collapsed;
                }
            }

            if (sender.ToString() != "MyMap_Progress") { disclaimer.Show(); }
        }

        private void SetCookie(string key, string value)
        {
            // Expire in 7 days
            DateTime expireDate = DateTime.Now + TimeSpan.FromDays(7);

            string newCookie = key + "=" + value + ";expires=" + expireDate.ToString("R");
            HtmlPage.Document.SetProperty("cookie", newCookie);
        }

        private string GetCookie(string key)
        {
            string[] cookies = HtmlPage.Document.Cookies.Split(';');

            foreach (string cookie in cookies)
            {
                string[] keyValue = cookie.Split('=');
                if (keyValue.Length == 2)
                {
                    if (keyValue[0].ToString() == key)
                        return keyValue[1];
                }
            }
            return null;
        }
        #endregion Disclaimer



Create a Disclaimer.xaml...
<controls:ChildWindow x:Class="COVGIS.Disclaimer"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
                      
           Width="400" Height="400" 
           Title="Disclaimer" HasCloseButton="False">
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0">
            <TextBlock TextWrapping="Wrap" FontWeight="Bold" TextAlignment="Center">
               GIS(IT) makes no warranty, representation or guaranty as to the content, sequence, accuracy, timeliness or completeness of any of the database information provided herein.
            </TextBlock>
            <TextBlock TextWrapping="Wrap" Margin="0,10,0,0">
               GIS(IT) makes no warranty, representation or guaranty as to the content, sequence, accuracy, timeliness or completeness of any of the database information provided herein.
            </TextBlock>
            <TextBlock TextWrapping="Wrap" Margin="0,10,0,0">
               GIS(IT) makes no warranty, representation or guaranty as to the content, sequence, accuracy, timeliness or completeness of any of the database information provided herein.
            </TextBlock>
            <TextBlock TextWrapping="Wrap" Margin="0,10,0,0">
               some text
            </TextBlock>
            <TextBlock TextWrapping="Wrap" Margin="0,10,0,0">
               some text
            </TextBlock>
            <TextBlock TextWrapping="Wrap" Margin="0,10,0,0" FontStyle="Italic" FontWeight="Normal" FontStretch="Normal" FontSize="10" Foreground="DarkRed">
               some text
            </TextBlock>
        </StackPanel>
        <Button x:Name="OKButton" Content="OK" Width="75" Height="23" HorizontalAlignment="center" Grid.Row="1" Click="OKButton_Click" />
    </Grid>
</controls:ChildWindow>



In the codebehind...add this
private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }
0 Kudos