Exemplo n.º 1
0
        private void ShowItemFlyout(object sender, RightTappedRoutedEventArgs e)
        {
            var element = sender as FrameworkElement;
            var flyout  = Flyout.GetAttachedFlyout(element) as MenuFlyout;

            flyout.ShowAt(element, e.GetPosition(element));
        }
Exemplo n.º 2
0
        private void PageMap_MapRightTapped(MapControl sender, MapRightTappedEventArgs args)
        {
            var flyout = (MenuFlyout)Flyout.GetAttachedFlyout(PageMap);

            ((MenuFlyoutItem)flyout.Items[1]).CommandParameter = args.Location;
            flyout.ShowAt(sender, args.Position);
        }
Exemplo n.º 3
0
        public static void Img_Tapped(object sender, Action closeCallBack)
        {
            ToolTip toolTip = (ToolTip)ToolTipService.GetToolTip((Image)sender);

            if (toolTip != null)
            {
                if (toolTip.IsOpen)
                {
                    toolTip.IsOpen = false;
                }

                toolTip.IsEnabled = false;
            }

            var flyout = Flyout.GetAttachedFlyout((FrameworkElement)sender);

            var trigger = new CloseFlyoutTrigger()
            {
                Flyout = (Flyout)flyout,

                mCloseCallback = closeCallBack
            };

            flyout.Opened += trigger.Flyout_Opened;

            flyout.Closed += trigger.Flyout_Closed;

            FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender);
        }
Exemplo n.º 4
0
        private void ShowNoteFlyoutIfEnabled(FrameworkElement element)
        {
            if (!IsNoteFlyoutEnabled)
            {
                return;
            }
            if (ReorderMode == ListViewReorderMode.Enabled)
            {
                return;
            }
            if (element == null)
            {
                return;
            }

            openedFlyout = Flyout.GetAttachedFlyout(element);
            if (openedFlyout == null)
            {
                return;
            }

            openedFlyout.Closed += OpenedFlyout_Closed;

            Flyout.ShowAttachedFlyout(element);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Opens the editor, binding it to a temporary copy of the current location
        /// that can be saved, or discarded if the user dismisses the editor.
        /// </summary>
        /// <param name="location"></param>
        private void EditLocation(LocationData location)
        {
            this.locationInEdit = location;
            var element = this.GetTemplateRootForLocation(location);
            var flyout  = Flyout.GetAttachedFlyout(element) as Flyout;

            (flyout.Content as FrameworkElement).DataContext = location.Clone();
            flyout.ShowAt(element);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Applies the changes represented by the specified LocationData to
        /// the cached location in edit, saves the changes to the file system,
        /// and updates the user interface to account for the changes.
        /// </summary>
        private async Task SaveAsync(LocationData workingCopy)
        {
            Flyout.GetAttachedFlyout(this.GetTemplateRootForLocation(this.locationInEdit)).Hide();

            this.isNewLocationInEdit = false;
            this.isExistingLocationBeingRepositioned = false;
            bool isAddressNew      = workingCopy.Address != this.locationInEdit.Address;
            bool areCoordinatesNew = !workingCopy.Position.Equals(this.locationInEdit.Position);

            // If just the address OR just the coordinates are new,
            // clear the other value so that it can be updated.
            if (isAddressNew ^ areCoordinatesNew)
            {
                if (isAddressNew)
                {
                    workingCopy.Position = new BasicGeoposition();
                }
                if (areCoordinatesNew)
                {
                    workingCopy.Address = string.Empty;
                }
            }

            // If the address, the coordinates, or both have changed, clear the travel
            // info and the route so that it doesn't reflect the old position.
            if (isAddressNew || areCoordinatesNew)
            {
                workingCopy.ClearTravelInfo();
                this.InputMap.Routes.Clear();
            }

            this.locationInEdit.Copy(workingCopy);

            var currentLocation = await this.GetCurrentLocationAsync();

            if (currentLocation != null)
            {
                if (isAddressNew ^ areCoordinatesNew)
                {
                    await LocationHelper.TryUpdateMissingLocationInfoAsync(this.locationInEdit, currentLocation);
                }
            }

            await LocationDataStore.SaveLocationDataAsync(this.Locations);

            if (currentLocation != null)
            {
                bool isNetworkAvailable = await this.TryUpdateLocationsTravelInfoAsync(this.Locations, currentLocation);

                if (isNetworkAvailable)
                {
                    this.InputMap.Routes.Add(new MapRouteView(this.locationInEdit.FastestRoute));
                }
            }
        }
Exemplo n.º 7
0
        private async void DisplayToast(String message)
        {
            toastText.Text = message;
            Flyout.ShowAttachedFlyout(animationToolBar);

            await Task.Delay(2300);

            var flyout = Flyout.GetAttachedFlyout(animationToolBar);

            flyout.Hide();
        }
Exemplo n.º 8
0
 /// <summary>
 /// Enters map selection mode, where the user can reposition the selected
 /// location by tapping a new location on the map control.
 /// </summary>
 private void EnableMapSelection(object sender, RoutedEventArgs e)
 {
     this.isMapSelectionEnabled              = true;
     this.InputMap.MapTapped                += InputMap_MapTapped;
     this.InputMap.MapHolding               -= InputMap_MapHolding;
     this.LocationsView.Visibility           = Visibility.Collapsed;
     this.ChangingLocationMessage.Visibility = Visibility.Visible;
     this.HideLocationsButton.IsEnabled      = false;
     this.AddCurrentLocationButton.IsEnabled = false;
     //   this.AddNewLocationButton.IsEnabled = false;
     Flyout.GetAttachedFlyout(this.GetTemplateRootForLocation(this.locationInEdit)).Hide();
 }
Exemplo n.º 9
0
        /// <summary>
        /// Occurs when an item in the list of available keys is clicked.
        /// </summary>
        /// <param name="sender">The object where the event handler is attached.</param>
        /// <param name="e">The event data.</param>
        private async void Keys_ItemClick(object sender, ItemClickEventArgs e)
        {
            PrivateKeyData privateKeyData = e.ClickedItem as PrivateKeyData;

            if (e.ClickedItem == null)
            {
                return;
            }

            MessageDialog dlg = null;

            try
            {
                PrivateKeyFile privateKey;
                using (var privateKeyStream = new MemoryStream(privateKeyData.Data))
                {
                    privateKey = new PrivateKeyFile(privateKeyStream);
                }

                var addedAgentKey = PrivateKeyAgentManager.PrivateKeyAgent.AddSsh2(privateKey.HostKey, privateKeyData.FileName);
                if (addedAgentKey != null)
                {
                    this.AgentKeys.Add(addedAgentKey);
                }
                else
                {
                    dlg = new MessageDialog("This private key is already loaded into the agent.", "Error loading private key");
                }
                this.SetEmptyHintVisibilities();
            }
            catch (SshPassPhraseNullOrEmptyException)
            {
                var clickedItem = ((ListViewBase)sender).ContainerFromItem(e.ClickedItem);
                this.loadKeyPasswordErrorTextBlock.Visibility = Visibility.Collapsed;
                this.loadKeyPasswordBox.Tag = e.ClickedItem;
                Flyout.GetAttachedFlyout((ListViewBase)this.keysGridView).ShowAt((FrameworkElement)clickedItem);
                this.loadKeyPasswordBox.Focus(FocusState.Programmatic);
            }
            catch (SshException ex)
            {
                dlg = new MessageDialog(ex.Message, "Error loading private key");
            }

            if (dlg != null)
            {
                await dlg.ShowAsync();
            }
        }
Exemplo n.º 10
0
        private void RenameTextBox_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs args)
        {
            if (args.Handled)
            {
                return;
            }
            if (args.Key != Windows.System.VirtualKey.Enter)
            {
                return;
            }
            args.Handled = true;
            var textBox = (TextBox)sender;

            _ = HostedConfigListItem.Rename(textBox.Text);
            Flyout.GetAttachedFlyout(hostedConfigNameTextBlock).Hide();
        }
Exemplo n.º 11
0
        private void OnButtonClicked(object sender, RoutedEventArgs e)
        {
            var btn    = sender as Button;
            var flyout = Flyout.GetAttachedFlyout(Header);

            if (ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutShowOptions"))
            {
                var options = new FlyoutShowOptions();
                options.Placement = FlyoutPlacementMode.BottomEdgeAlignedRight;
                flyout.ShowAt(btn, options);
            }
            else
            {
                flyout.ShowAt(Header);
            }
        }
Exemplo n.º 12
0
        private void OnUnloaded()
        {
            while (Frame.CanGoBack)
            {
                Frame.GoBack();
            }
            Frame.BackStack.Clear();
            NoteUnloaded?.Invoke(this, EventArgs.Empty);
            OnSaveState();

            if (ApiInformation.IsTypePresent("FlyoutBaseClosingEventArgs"))
            {
                Flyout.GetAttachedFlyout(ReminderAppBarButton).Closing -= Flyout_Closing;
                Flyout.GetAttachedFlyout(ReminderAppBarButton).Closed  -= Flyout_Closed;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Handles the Tapped event of the map control to reposition a location
        /// when map selection mode is enabled.
        /// </summary>
        private async void InputMap_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            this.InputMap.Routes.Clear();
            this.isExistingLocationBeingRepositioned = true;
            this.locationInEditOriginalPosition      = this.locationInEdit.Position;
            this.locationInEdit.Position             = args.Location.Position;

            var element  = this.GetTemplateRootForLocation(this.locationInEdit);
            var flyout   = Flyout.GetAttachedFlyout(element) as Flyout;
            var location = (flyout.Content as FrameworkElement).DataContext as LocationData;

            location.Position = args.Location.Position;
            location.Address  = String.Empty;
            await LocationHelper.TryUpdateMissingLocationInfoAsync(location, null);

            this.DisableMapSelection();
            flyout.ShowAt(element);
        }
Exemplo n.º 14
0
        private void OnLoaded()
        {
            if (openImagePicker)
            {
                viewModel.OpenImagePicker();
            }

            if (viewModel.Note.IsEmpty() && !openImagePicker)
            {
                NoteTitleTextBox.Focus(FocusState.Programmatic);
            }

            if (ApiInformation.IsTypePresent("FlyoutBaseClosingEventArgs"))
            {
                Flyout.GetAttachedFlyout(ReminderAppBarButton).Closing += Flyout_Closing;
                Flyout.GetAttachedFlyout(ReminderAppBarButton).Closed  += Flyout_Closed;
            }
        }
        private void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs args)
        {
            if (args.Handled)
            {
                return;
            }
            if (args.Key != Windows.System.VirtualKey.Enter)
            {
                return;
            }
            args.Handled = true;
            var textBox = (TextBox)sender;
            var item    = (HostedConfigListItem)textBox.DataContext;

            _ = item.Rename(textBox.Text);
            var nameText = hostedConfigList.ContainerFromItem(item).FindDescendantByName("nameText");

            Flyout.GetAttachedFlyout(nameText).Hide();
        }
Exemplo n.º 16
0
        public static void Img_Tapped(object sender)
        {
            ToolTip toolTip = (ToolTip)ToolTipService.GetToolTip((Image)sender);

            if (toolTip != null)
            {
                if (toolTip.IsOpen)
                {
                    toolTip.IsOpen = false;
                }

                toolTip.IsEnabled = false;
            }

            var flyout = Flyout.GetAttachedFlyout((FrameworkElement)sender);

            flyout.Opened += ImagePreviewPanel.Flyout_Opened;

            FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Occurs when the load key button is clicked.
        /// </summary>
        /// <param name="sender">The object where the event handler is attached.</param>
        /// <param name="e">The event data.</param>
        private async void keyLoadButton_Click(object sender, RoutedEventArgs e)
        {
            PrivateKeyData privateKeyData = this.loadKeyPasswordBox.Tag as PrivateKeyData;

            if (privateKeyData == null)
            {
                return;
            }

            try
            {
                PrivateKeyFile privateKey;
                using (var privateKeyStream = new MemoryStream(privateKeyData.Data))
                {
                    privateKey = new PrivateKeyFile(privateKeyStream, loadKeyPasswordBox.Password);
                }

                var addedAgentKey = PrivateKeyAgentManager.PrivateKeyAgent.AddSsh2(privateKey.HostKey, privateKeyData.FileName);
                if (addedAgentKey != null)
                {
                    this.AgentKeys.Add(addedAgentKey);
                }
                else
                {
                    MessageDialog dlg = new MessageDialog("This private key is already loaded into the private key agent.", "Error loading private key");
                    await dlg.ShowAsync();
                }

                Flyout.GetAttachedFlyout(this.keysGridView).Hide();
                this.SetEmptyHintVisibilities();
            }
            catch (Exception)
            {
                this.loadKeyPasswordErrorTextBlock.Text       = "Wrong password.";
                this.loadKeyPasswordErrorTextBlock.Visibility = Visibility.Visible;
                this.loadKeyPasswordBox.Focus(FocusState.Programmatic);
            }

            this.loadKeyPasswordBox.Password = string.Empty;
        }
Exemplo n.º 18
0
        //private void DoSwivle(object sender, RoutedEventArgs e) { var ignore = swivleContentDialog.ShowAsync(); }

        //private void DoReaderboard(object sender, RoutedEventArgs e) { var ignore = readerboardContentDialog.ShowAsync(); }

        private void DoEscalator(object sender, RoutedEventArgs e)
        {
            Flyout.GetAttachedFlyout((FrameworkElement)sender).ShowAt((FrameworkElement)sender);
        }