Esempio n. 1
0
        /// <summary>
        /// Populates the page with content passed during navigation. Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            if (e.NavigationParameter == null)
            {
                this.Frame.GoBack();
            }

            if (!(e.NavigationParameter is Guid))
            {
                this.Frame.GoBack();
                return;
            }

            Guid      guid     = (Guid)e.NavigationParameter;
            ITerminal terminal = TerminalManager.GetTerminal(guid);

            if (terminal == null)
            {
                this.Frame.GoBack();
                return;
            }

            this.Terminal = terminal;

            this.previewGrid.ItemsSource = TerminalManager.Terminals;
        }
        /// <summary>
        /// Occurs when the connect button is clicked.
        /// </summary>
        /// <param name="sender">The object where the event handler is attached.</param>
        /// <param name="e">The event data.</param>
        private void connectButton_Click(object sender, RoutedEventArgs e)
        {
            var connectionData = this.CreateConnectionDataFromForm();

            Guid guid = TerminalManager.Create(connectionData);

            this.Frame.Navigate(typeof(TerminalPage), guid);
        }
Esempio n. 3
0
        /// <summary>
        /// Occurs when an item in the preview grid view is clicked.
        /// </summary>
        /// <param name="sender">The object where the event handler is attached.</param>
        /// <param name="e">The event data.</param>
        private void PreviewGrid_ItemClick(object sender, ItemClickEventArgs e)
        {
            ITerminal terminal = e.ClickedItem as ITerminal;

            if (terminal == null)
            {
                return;
            }

            this.Frame.Navigate(typeof(TerminalPage), TerminalManager.GetGuid(terminal));
        }
Esempio n. 4
0
        /// <summary>
        /// Occurs when the close button of an item in the preview grid view is clicked.
        /// </summary>
        /// <param name="sender">The object where the event handler is attached.</param>
        /// <param name="e">The event data.</param>
        private void PreviewGrid_ItemCloseButtonClick(object sender, RoutedEventArgs e)
        {
            ITerminal terminal = ((Button)sender).Tag as ITerminal;

            TerminalManager.Remove(terminal);
            if (this.Terminal == terminal)
            {
                var switchToTerminal = TerminalManager.Terminals.Where(t => t != terminal).FirstOrDefault();
                if (switchToTerminal == null)
                {
                    this.NavigationHelper.GoBack();
                }
                else
                {
                    this.Terminal = switchToTerminal;
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Occurs when an item in the favorites list view is clicked.
        /// </summary>
        /// <param name="sender">The object where the event handler is attached.</param>
        /// <param name="e">The event data.</param>
        private void ItemView_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (e.ClickedItem == null)
            {
                return;
            }

            string id = ((ConnectionData)e.ClickedItem).Id;

            var connectionData = FavoritesDataSource.GetFavorite(id);

            if (connectionData == null)
            {
                return;
            }

            Guid guid = TerminalManager.Create(connectionData);

            this.Frame.Navigate(typeof(TerminalPage), guid);
        }
Esempio n. 6
0
        /// <summary>
        /// Preserves state associated with this page in case the application is suspended or the
        /// page is discarded from the navigation cache.  Values must conform to the serialization
        /// requirements of <see cref="SuspensionManager.SessionState"/>.
        /// </summary>
        /// <param name="sender">The source of the event; typically <see cref="NavigationHelper"/></param>
        /// <param name="e">Event data that provides an empty dictionary to be populated with
        /// serializable state.</param>
        private void navigationHelper_SaveState(object sender, SaveStateEventArgs e)
        {
            InputPane input = InputPane.GetForCurrentView();

            input.Showing -= InputPaneShowing;
            input.Hiding  -= InputPaneHiding;

            if (this.screenDisplay != null)
            {
                this.screenDisplay.Dispose();
                this.screenDisplay = null;
            }

            if (this.Terminal != null)
            {
                if (!this.Terminal.IsConnected)
                {
                    TerminalManager.Remove(this.Terminal);
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Occurs when the close button of an item in the preview grid view is clicked.
        /// </summary>
        /// <param name="sender">The object where the event handler is attached.</param>
        /// <param name="e">The event data.</param>
        private void PreviewGrid_ItemCloseButtonClick(object sender, RoutedEventArgs e)
        {
            ITerminal terminal = ((Button)sender).Tag as ITerminal;

            TerminalManager.Remove(terminal);
        }