private void UpdateSeparatorVisibility(int index, AppBarSeparator separator)
        {
            var visibility = separator.Visibility;

            if (index == 0)
            {
                if (visibility == Visibility.Visible)
                {
                    separator.SetCurrentValue(VisibilityProperty, Visibility.Collapsed);
                }
            }
            else
            {
                RestoreSeparatorVisibility(separator);
            }
        }
        void AppBarButtonPage_Loaded(object sender, RoutedEventArgs e)
        {
            // Add compact button to the command bar. It provides functionality specific
            // to this page, and is removed when leaving the page.

            CommandBar appBar = NavigationRootPage.Current.PageHeader.TopCommandBar;

            separator = new AppBarSeparator();
            appBar.PrimaryCommands.Insert(0, separator);

            compactButton        = new AppBarToggleButton();
            compactButton.Icon   = new SymbolIcon(Symbol.FontSize);
            compactButton.Label  = "IsCompact";
            compactButton.Click += CompactButton_Click;
            appBar.PrimaryCommands.Insert(0, compactButton);
        }
        private void NoteList_Unloaded(object sender, RoutedEventArgs e)
        {
            ParentCommandBar.PrimaryCommands.Remove(DeleteNotes);
            DeleteNotes = null;

            ParentCommandBar.PrimaryCommands.Remove(EditNote);
            EditNote = null;

            ParentCommandBar.PrimaryCommands.Remove(SyncPosition);
            SyncPosition = null;

            ParentCommandBar.PrimaryCommands.Remove(Seperator);
            Seperator = null;

            ParentCommandBar.PrimaryCommands.Remove(NotesFromAllBooks);
            NotesFromAllBooks = null;
        }
Пример #4
0
        private void OnConnectionEstablished()
        {
            AppBarButton connectBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "ConnectDevice") as AppBarButton;

            connectBtn.Visibility = Visibility.Collapsed;

            AppBarButton refreshBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "RefreshDeviceList") as AppBarButton;

            refreshBtn.Visibility = Visibility.Collapsed;

            AppBarButton disconnectBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "DisconnectDevice") as AppBarButton;

            disconnectBtn.Visibility = Visibility.Visible;

            AppBarSeparator seperator1 = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarSeparator && ((AppBarSeparator)i).Name == "sperator1") as AppBarSeparator;

            seperator1.Visibility = Visibility.Collapsed;

            AppBarSeparator seperator2 = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarSeparator && ((AppBarSeparator)i).Name == "sperator2") as AppBarSeparator;

            seperator2.Visibility = Visibility.Visible;

            AppBarToggleButton headlights = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarToggleButton && ((AppBarToggleButton)i).Name == "Headlights") as AppBarToggleButton;

            headlights.Visibility = Visibility.Visible;

            if (App.AppData.ConnectedAucovei.IsNewGeneration)
            {
                AppBarToggleButton camera =
                    App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i =>
                                                                              i is AppBarToggleButton && ((AppBarToggleButton)i).Name == "Camera") as AppBarToggleButton;
                camera.Visibility = Visibility.Visible;
            }

            //AppBarButton deleteroute = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "DeleteRoute") as AppBarButton;
            //deleteroute.Visibility = Visibility.Visible;

            AppBarButton hornBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "Horn") as AppBarButton;

            hornBtn.Visibility = Visibility.Visible;

            this.rootPage.NotifyUser("Connected to " + App.AppData.ConnectedAucovei.DisplayName + "!", NotifyType.StatusMessage);

            this.rootPage.UpdateNavigation(1);
            this.Frame.Navigate(typeof(AddWaypoints));
        }
Пример #5
0
        private void DisconnectBtn_Click(object sender, RoutedEventArgs e)
        {
            this.ResetAppLevelParameters();
            this.rootPage.UpdateNavigation(0);

            AppBarButton refreshBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "RefreshDeviceList") as AppBarButton;

            refreshBtn.Visibility = Visibility.Visible;

            AppBarButton disconnectBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "DisconnectDevice") as AppBarButton;

            disconnectBtn.Visibility = Visibility.Collapsed;

            AppBarSeparator seperator = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarSeparator && ((AppBarSeparator)i).Name == "sperator1") as AppBarSeparator;

            seperator.Visibility = Visibility.Collapsed;

            AppBarButton connectBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "ConnectDevice") as AppBarButton;

            connectBtn.Visibility = Visibility.Visible;

            AppBarSeparator seperator1 = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarSeparator && ((AppBarSeparator)i).Name == "sperator1") as AppBarSeparator;

            seperator1.Visibility = Visibility.Collapsed;

            AppBarSeparator seperator2 = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarSeparator && ((AppBarSeparator)i).Name == "sperator2") as AppBarSeparator;

            seperator2.Visibility = Visibility.Collapsed;

            AppBarToggleButton headlights = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarToggleButton && ((AppBarToggleButton)i).Name == "Headlights") as AppBarToggleButton;

            headlights.Visibility = Visibility.Collapsed;

            AppBarToggleButton camera = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarToggleButton && ((AppBarToggleButton)i).Name == "Camera") as AppBarToggleButton;

            camera.Visibility = Visibility.Collapsed;

            AppBarButton deleteroute = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "DeleteRoute") as AppBarButton;

            deleteroute.Visibility = Visibility.Collapsed;

            AppBarButton hornBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "Horn") as AppBarButton;

            hornBtn.Visibility = Visibility.Collapsed;
        }
Пример #6
0
        private ICommandBarElement AddCommandBarButton(IObservableVector <ICommandBarElement> commands, CommandBarButton button)
        {
            if (button == CommandBarButton.Separator)
            {
                var separator = new AppBarSeparator();
                commands.Add(separator);
                return(separator);
            }

            var appBarButton = new AppBarButton()
            {
                Icon  = button.Icon,
                Label = button.Label,
            };

            appBarButton.Click += button.Handler;
            commands.Add(appBarButton);
            return(appBarButton);
        }
Пример #7
0
        protected override Size MeasureOverride(Size availableSize)
        {
            var sizeToReport = base.MeasureOverride(availableSize);

            // Account for the size of the Content area
            var contentWidth = this.ContentMinWidth;

            // Account for the size of the More button
            var expandButtonWidth = 0.0;

            if (moreButton != null && moreButton.Visibility == Visibility.Visible)
            {
                expandButtonWidth = moreButton.DesiredSize.Width;
            }

            double requestedWidth = expandButtonWidth + contentWidth;

            // Include the size of all the PrimaryCommands
            foreach (var cmd in this.PrimaryCommands)
            {
                var uie = cmd as UIElement;
                requestedWidth += uie.DesiredSize.Width;
            }

            // First, move items to the overflow until the remaining PrimaryCommands fit
            for (int i = this.PrimaryCommands.Count - 1; i > 0 && requestedWidth > availableSize.Width; i--)
            {
                var item    = this.PrimaryCommands[i];
                var element = item as UIElement;

                if (element == null)
                {
                    continue;
                }

                requestedWidth -= element.DesiredSize.Width;

                if (this.overflow.Count == 0 && !(element is AppBarSeparator))
                {
                    // Insert a separator to differentiate between the items that were already in the overflow versus
                    // those we moved
                    var abs = new AppBarSeparator();
                    abs.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                    this.separatorQueue.Enqueue(new Tuple <ICommandBarElement, double>(abs, abs.DesiredSize.Width));
                    separatorQueueWidth += abs.DesiredSize.Width;
                }

                this.PrimaryCommands.RemoveAt(i);

                // move separators we've queued up
                while (separatorQueue.Count > 0)
                {
                    var next = separatorQueue.Dequeue();
                    separatorQueueWidth -= next.Item2;
                    overflow.Push(next);
                    this.SecondaryCommands.Insert(0, next.Item1);
                }

                // We store the measured size before it moves to overflow and will rely on that value
                // when determining how many items to move back out the overflow.
                overflow.Push(new Tuple <ICommandBarElement, double>(item, element.DesiredSize.Width));

                this.SecondaryCommands.Insert(0, (ICommandBarElement)element);

                // if a separator was adjacent to the one we removed then move the separator to our holding queue so that it doesn't appear without actually separating the content
                var last = this.PrimaryCommands.LastOrDefault() as AppBarSeparator;
                if (last != null)
                {
                    this.PrimaryCommands.RemoveAt(this.PrimaryCommands.Count - 1);
                    this.separatorQueue.Enqueue(new Tuple <ICommandBarElement, double>(last, last.DesiredSize.Width));
                    separatorQueueWidth += last.DesiredSize.Width;
                    requestedWidth      -= last.DesiredSize.Width;
                }
            }

            //else if (requestedWidth < availableSize.Width) // Check if we have room to move items out of the overflow
            //{
            // Next move items out of the overflow if room is available
            while (overflow.Count > 0 && requestedWidth + separatorQueueWidth + overflow.Peek().Item2 <= availableSize.Width)
            {
                var t = overflow.Pop();

                this.SecondaryCommands.Remove(t.Item1);

                if (this.overflow.Count == 1)
                {
                    overflow.Pop();
                    this.SecondaryCommands.RemoveAt(0);
                }

                if (t.Item1 is AppBarSeparator)
                {
                    this.separatorQueue.Enqueue(t);
                    separatorQueueWidth += t.Item2;
                    continue;
                }
                else
                {
                    while (separatorQueue.Count > 0)
                    {
                        var next = separatorQueue.Dequeue();
                        separatorQueueWidth -= next.Item2;
                        this.PrimaryCommands.Add(next.Item1);
                        requestedWidth += next.Item2;
                    }
                }

                // Sometimes this property is being set to disabled
                ((Control)t.Item1).IsEnabled = true;

                this.PrimaryCommands.Add(t.Item1);
                requestedWidth += t.Item2;

                // check to see if after moving this item we leave a separator at the top of the overflow
                if (this.overflow.Count > 0)
                {
                    var test = this.overflow.Peek();
                    if (test.Item1 is AppBarSeparator)
                    {
                        // we won't leave an orphaned separator
                        this.SecondaryCommands.RemoveAt(0);
                        var top = this.overflow.Pop();

                        var element = top.Item1 as UIElement;
                        element.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                        this.separatorQueue.Enqueue(new Tuple <ICommandBarElement, double>(top.Item1, element.DesiredSize.Width));
                        separatorQueueWidth += element.DesiredSize.Width;
                    }
                }
            }
            //}

            return(sizeToReport);
        }
Пример #8
0
        protected override Size MeasureOverride(Size availableSize)
        {
            var sizeToReport = base.MeasureOverride(availableSize);

            // Account for the size of the Content area
            var contentWidth = this.ContentMinWidth;

            // Account for the size of the More button
            var expandButtonWidth = 0.0;
            if (moreButton != null && moreButton.Visibility == Visibility.Visible)
            {
                expandButtonWidth = moreButton.DesiredSize.Width;
            }

            double requestedWidth = expandButtonWidth + contentWidth;

            // Include the size of all the PrimaryCommands
            foreach (var cmd in this.PrimaryCommands)
            {
                var uie = cmd as UIElement;
                requestedWidth += uie.DesiredSize.Width;
            }

            // First, move items to the overflow until the remaining PrimaryCommands fit
            for (int i = this.PrimaryCommands.Count - 1; i >= 0 && requestedWidth > availableSize.Width; i--)
            {
                var item = this.PrimaryCommands[i];
                var element = item as UIElement;

                if (element == null)
                {
                    continue;
                }

                requestedWidth -= element.DesiredSize.Width;

                if (this.overflow.Count == 0 && this.SecondaryCommands.Count > 0 && !(element is AppBarSeparator))
                {
                    // Insert a separator to differentiate between the items that were already in the overflow versus
                    // those we moved
                    var abs = new AppBarSeparator();
                    abs.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                    this.separatorQueue.Enqueue(new Tuple<ICommandBarElement, double>(abs, abs.DesiredSize.Width));
                    separatorQueueWidth += abs.DesiredSize.Width;
                }

                this.PrimaryCommands.RemoveAt(i);

                // move separators we've queued up
                while (separatorQueue.Count > 0)
                {
                    var next = separatorQueue.Dequeue();
                    separatorQueueWidth -= next.Item2;
                    overflow.Push(next);
                    this.SecondaryCommands.Insert(0, next.Item1);
                }

                // We store the measured size before it moves to overflow and will rely on that value
                // when determining how many items to move back out the overflow.
                overflow.Push(new Tuple<ICommandBarElement, double>(item, element.DesiredSize.Width));

                this.SecondaryCommands.Insert(0, (ICommandBarElement)element);

                // if a separator was adjacent to the one we removed then move the separator to our holding queue so that it doesn't appear without actually separating the content
                var last = this.PrimaryCommands.LastOrDefault() as AppBarSeparator;
                if (last != null)
                {
                    this.PrimaryCommands.RemoveAt(this.PrimaryCommands.Count - 1);
                    this.separatorQueue.Enqueue(new Tuple<ICommandBarElement, double>(last, last.DesiredSize.Width));
                    separatorQueueWidth += last.DesiredSize.Width;
                    requestedWidth -= last.DesiredSize.Width;
                }
            }

            // Next move items out of the overflow if room is available
            while (overflow.Count > 0 && requestedWidth + separatorQueueWidth + overflow.Peek().Item2 <= availableSize.Width)
            {
                var t = overflow.Pop();

                this.SecondaryCommands.RemoveAt(0);

                if (this.overflow.Count == 1 && this.SecondaryCommands.Count > 1)
                {
                    // must be the separator injected earlier
                    overflow.Pop();
                    this.SecondaryCommands.RemoveAt(0);
                }

                if (t.Item1 is AppBarSeparator)
                {
                    this.separatorQueue.Enqueue(t);
                    separatorQueueWidth += t.Item2;
                    continue;
                }
                else
                {
                    while (separatorQueue.Count > 0)
                    {
                        var next = separatorQueue.Dequeue();
                        this.PrimaryCommands.Add(next.Item1);
                        separatorQueueWidth -= next.Item2;
                        requestedWidth += next.Item2;
                    }
                }

                // Sometimes this property is being set to disabled
                ((Control)t.Item1).IsEnabled = true;

                this.PrimaryCommands.Add(t.Item1);
                requestedWidth += t.Item2;

                // check to see if after moving this item we leave a separator at the top of the overflow
                if (this.overflow.Count > 0)
                {
                    var test = this.overflow.Peek();
                    if (test.Item1 is AppBarSeparator)
                    {
                        // we won't leave an orphaned separator
                        this.SecondaryCommands.RemoveAt(0);
                        var top = this.overflow.Pop();

                        var element = top.Item1 as UIElement;
                        element.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                        this.separatorQueue.Enqueue(new Tuple<ICommandBarElement, double>(top.Item1, element.DesiredSize.Width));
                        separatorQueueWidth += element.DesiredSize.Width;
                    }
                }
            }

            return sizeToReport;
        }
Пример #9
0
        /// <summary>
        /// Ajoute un bouton à la barre
        /// </summary>
        /// <param name="objectType">type d'objet à créer</param>
        /// <param name="emplacement">Type d'emplacment du bouton sur la CommandBar, PrimaryCommands ou SecondaryCommands</param>
        /// <param name="icon">Icon du bouton</param>
        /// <param name="label">Label du bouton</param>
        /// <param name="command">ICommand du bouton</param>
        /// <param name="commandParameter">CommandParameter de la ICommand du bouton</param>
        private static CommandBarElement AddObjectToCommandBar(CommandBarButtonType objectType, CommandBarEmplacement emplacement, IconElement icon, string label, ICommand command, object commandParameter, FlyoutBase flyout)
        {
            ICommandBarElement element = null;

            switch (objectType)
            {
                case CommandBarButtonType.Button:
                    element = new AppBarButton
                    {
                        Icon = icon,
                        Label = label,
                        Command = command,
                        CommandParameter = commandParameter
                    };
                    break;
                case CommandBarButtonType.ToggleButton:
                    element = new AppBarToggleButton()
                    {
                        Icon = icon,
                        Label = label,
                        Command = command,
                        CommandParameter = commandParameter
                    };
                    break;
                case CommandBarButtonType.FlyoutButton:
                    element = new AppBarButton()
                    {
                        Icon = icon,
                        Label = label,
                        Flyout = flyout
                    };
                    break;
                case CommandBarButtonType.Separator:
                    element = new AppBarSeparator();
                    break;
            }

            if (element != null)
            {
                if (emplacement == CommandBarEmplacement.Primary)
                {
                    _commandBar.PrimaryCommands.Add(element);
                }
                else
                {
                    _commandBar.SecondaryCommands.Add(element);
                }

                if (_commandBar.Visibility == Visibility.Collapsed)
                {
                    _commandBar.Visibility = Visibility.Visible;
                }
            }
            return new CommandBarElement() { Element = element, Emplacement = emplacement };
        }
Пример #10
0
            public RichEditBoxSelectionFlyout()
            {
                Opened += RichEditBoxSelectionFlyout_Opened;

                Placement = Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode.TopEdgeAlignedLeft;

                ResourceLoader loader = ResourceLoader.GetForCurrentView();

                CutButton = new AppBarButton()
                {
                    Label = loader.GetString("CutButton/Text")
                };
                CutButton.Click += CutButton_Click;
                PrimaryCommands.Add(CutButton);

                CopyButton = new AppBarButton()
                {
                    Label = loader.GetString("CopyButton/Text")
                };
                CopyButton.Click += CopyButton_Click;
                PrimaryCommands.Add(CopyButton);

                PasteButton = new AppBarButton()
                {
                    Label = loader.GetString("PasteButton/Text")
                };
                PasteButton.Click += PasteButton_Click;
                PrimaryCommands.Add(PasteButton);

                SelectAllButton = new AppBarButton()
                {
                    Label = loader.GetString("SelectAllButton/Text")
                };
                SelectAllButton.Click += SelectAllButton_Click;
                SecondaryCommands.Add(SelectAllButton);

                HighlightSeparator = new AppBarSeparator();
                SecondaryCommands.Add(HighlightSeparator);

                HighlightButton = new AppBarButton()
                {
                    Label = loader.GetString("HighlightButton/Text")
                };
                HighlightButton.Click += HighlightButton_Click;
                SecondaryCommands.Add(HighlightButton);

                RemoveHighlightButton = new AppBarButton()
                {
                    Label = loader.GetString("RemoveHighlightButton/Text")
                };
                RemoveHighlightButton.Click += RemoveHighlightButton_Click;
                SecondaryCommands.Add(RemoveHighlightButton);

                CaseSeparator = new AppBarSeparator();
                SecondaryCommands.Add(CaseSeparator);

                UppercaseButton = new AppBarButton()
                {
                    Label = loader.GetString("UppercaseButton/Text")
                };
                UppercaseButton.Click += UppercaseButton_Click;
                SecondaryCommands.Add(UppercaseButton);

                LowercaseButton = new AppBarButton()
                {
                    Label = loader.GetString("LowercaseButton/Text")
                };
                LowercaseButton.Click += LowercaseButton_Click;
                SecondaryCommands.Add(LowercaseButton);

                SearchSeparator = new AppBarSeparator();
                SecondaryCommands.Add(SearchSeparator);

                SearchButton = new AppBarButton()
                {
                    Label = "[search]"
                };
                SearchButton.Click += SearchButton_Click;
                SecondaryCommands.Add(SearchButton);

                CutButton.Icon = new FontIcon {
                    Glyph = "\uE8C6"
                };
                CopyButton.Icon = new FontIcon {
                    Glyph = "\uE8C8"
                };
                PasteButton.Icon = new FontIcon {
                    Glyph = "\uE77F"
                };

                if (ApiInformation.IsTypePresent("Windows.UI.Xaml.Input.KeyboardAccelerator"))
                {
                    KeyboardAccelerator CtrlX = new KeyboardAccelerator();
                    CtrlX.Key           = VirtualKey.X;
                    CtrlX.Modifiers     = VirtualKeyModifiers.Control;
                    CtrlX.IsEnabled     = false;
                    CutButton.AccessKey = "X";
                    CutButton.KeyboardAccelerators.Add(CtrlX);

                    KeyboardAccelerator CtrlC = new KeyboardAccelerator();
                    CtrlC.Key            = VirtualKey.C;
                    CtrlC.Modifiers      = VirtualKeyModifiers.Control;
                    CtrlC.IsEnabled      = false;
                    CopyButton.AccessKey = "C";
                    CopyButton.KeyboardAccelerators.Add(CtrlC);

                    KeyboardAccelerator CtrlV = new KeyboardAccelerator();
                    CtrlV.Key             = VirtualKey.V;
                    CtrlV.Modifiers       = VirtualKeyModifiers.Control;
                    CtrlV.IsEnabled       = false;
                    PasteButton.AccessKey = "V";
                    PasteButton.KeyboardAccelerators.Add(CtrlV);

                    KeyboardAccelerator CtrlA = new KeyboardAccelerator();
                    CtrlA.Key                 = VirtualKey.A;
                    CtrlA.Modifiers           = VirtualKeyModifiers.Control;
                    CtrlA.IsEnabled           = false;
                    SelectAllButton.AccessKey = "A";
                    SelectAllButton.KeyboardAccelerators.Add(CtrlA);
                }
            }
Пример #11
0
        private void CreateCommandBarButtons()
        {
            AppBarButton connectBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "ConnectDevice") as AppBarButton;

            if (connectBtn == null)
            {
                connectBtn = new AppBarButton();
                BitmapIcon icon = new BitmapIcon();
                icon.UriSource       = new Uri("ms-appx:///Assets/link.png");
                connectBtn.Icon      = icon;
                connectBtn.Name      = "ConnectDevice";
                connectBtn.Label     = "Connect Device";
                connectBtn.IsEnabled = false;
                connectBtn.Click    += this.ConnectBtn_Click;
                App.AppCommandBar.PrimaryCommands.Insert(0, connectBtn);
            }

            AppBarButton refreshBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "RefreshDeviceList") as AppBarButton;

            if (refreshBtn == null)
            {
                refreshBtn        = new AppBarButton();
                refreshBtn.Icon   = new SymbolIcon(Symbol.Refresh);
                refreshBtn.Name   = "RefreshDeviceList";
                refreshBtn.Label  = "Refresh List";
                refreshBtn.Click += this.RefreshBtn_Click;
                App.AppCommandBar.PrimaryCommands.Insert(1, refreshBtn);
            }

            AppBarButton disconnectBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "DisconnectDevice") as AppBarButton;

            if (disconnectBtn == null)
            {
                disconnectBtn = new AppBarButton();
                BitmapIcon icon = new BitmapIcon();
                icon.UriSource           = new Uri("ms-appx:///Assets/unlink.png");
                disconnectBtn.Icon       = icon;
                disconnectBtn.Name       = "DisconnectDevice";
                disconnectBtn.Label      = "Disconnect Device";
                disconnectBtn.Click     += this.DisconnectBtn_Click;
                disconnectBtn.Visibility = Visibility.Collapsed;
                App.AppCommandBar.PrimaryCommands.Insert(1, disconnectBtn);
            }

            AppBarSeparator seperator1 = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarSeparator && ((AppBarSeparator)i).Name == "sperator1") as AppBarSeparator;

            if (seperator1 == null)
            {
                seperator1            = new AppBarSeparator();
                seperator1.Name       = "sperator1";
                seperator1.Visibility = Visibility.Collapsed;
                App.AppCommandBar.PrimaryCommands.Insert(1, seperator1);
            }

            AppBarButton hornBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "Horn") as AppBarButton;

            if (hornBtn == null)
            {
                hornBtn = new AppBarButton();
                BitmapIcon icon = new BitmapIcon();
                icon.UriSource     = new Uri("ms-appx:///Assets/Horn.png");
                hornBtn.Icon       = icon;
                hornBtn.Name       = "Horn";
                hornBtn.Label      = "Horn";
                hornBtn.Tapped    += this.Toggle_Tapped;
                hornBtn.Visibility = Visibility.Collapsed;
                App.AppCommandBar.PrimaryCommands.Insert(2, hornBtn);
            }

            AppBarToggleButton headlights = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarToggleButton && ((AppBarToggleButton)i).Name == "Headlights") as AppBarToggleButton;

            if (headlights == null)
            {
                headlights = new AppBarToggleButton();
                BitmapIcon icon = new BitmapIcon();
                icon.UriSource        = new Uri("ms-appx:///Assets/headlights.png");
                headlights.Icon       = icon;
                headlights.Name       = "Headlights";
                headlights.Label      = "Headlights";
                headlights.Tapped    += this.Toggle_Tapped;;
                headlights.Visibility = Visibility.Collapsed;
                App.AppCommandBar.PrimaryCommands.Insert(3, headlights);
            }

            AppBarToggleButton camera = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarToggleButton && ((AppBarToggleButton)i).Name == "Camera") as AppBarToggleButton;

            if (camera == null)
            {
                camera = new AppBarToggleButton();
                BitmapIcon icon = new BitmapIcon();
                icon.UriSource    = new Uri("ms-appx:///Assets/camera.png");
                camera.Icon       = icon;
                camera.Name       = "Camera";
                camera.Label      = "Camera";
                camera.Tapped    += this.Toggle_Tapped;;
                camera.Visibility = Visibility.Collapsed;
                App.AppCommandBar.PrimaryCommands.Insert(4, camera);
            }

            AppBarButton deleteroute = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "DeleteRoute") as AppBarButton;

            if (deleteroute == null)
            {
                deleteroute            = new AppBarButton();
                deleteroute.Icon       = new SymbolIcon(Symbol.Delete);
                deleteroute.Name       = "DeleteRoute";
                deleteroute.Label      = "Delete Route";
                deleteroute.Tapped    += this.Toggle_Tapped;
                deleteroute.Visibility = Visibility.Collapsed;
                App.AppCommandBar.PrimaryCommands.Insert(5, deleteroute);
            }

            AppBarSeparator seperator2 = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarSeparator && ((AppBarSeparator)i).Name == "sperator2") as AppBarSeparator;

            if (seperator2 == null)
            {
                seperator2            = new AppBarSeparator();
                seperator2.Name       = "sperator2";
                seperator2.Visibility = Visibility.Collapsed;
                App.AppCommandBar.PrimaryCommands.Insert(6, seperator2);
            }

            AppBarButton TestBtn = App.AppCommandBar.PrimaryCommands.ToList().FirstOrDefault(i => i is AppBarButton && ((AppBarButton)i).Name == "TestBtn") as AppBarButton;

            if (TestBtn == null)
            {
                TestBtn            = new AppBarButton();
                TestBtn.Icon       = new SymbolIcon(Symbol.Admin);
                TestBtn.Name       = "TestBtn";
                TestBtn.Label      = "TestBtn";
                TestBtn.Visibility = Visibility.Collapsed;
                TestBtn.Tapped    += async(o, i) =>
                {
                    double[] array = { 17.454489832744, 78.3010964468122 };
                    JToken   token = JToken.FromObject(array);
                    JArray   arr   = new JArray();
                    arr.Add(token);
                    //await SendCommandToCar("{" + arr.ToString() + "}", 100);
                    //await Task.Delay(100);
                    //await SendCommandToCar(arr.ToString(), 100);
                };

                App.AppCommandBar.PrimaryCommands.Insert(6, TestBtn);
            }
        }
Пример #12
0
        public NavigationPage()
        {
            Loaded += NavigationPage_Loaded;

            // Use a CommandBar rather than an AppBar so that we get default layout
            CommandBar commandBar = new CommandBar();

            commandBar.HorizontalContentAlignment = HorizontalAlignment.Left;

            AppBarButton HomeButton;
            AppBarButton HelpButton;
            AppBarButton AboutButton;
            AppBarButton AddButton;

            AppBarSeparator Separator = new AppBarSeparator();

            if (GetType() == typeof(ListManager.Views.Lists))
            {
                AddButton        = new AppBarButton();
                AddButton.Label  = "Edit Lists";
                AddButton.Icon   = new SymbolIcon(Symbol.Edit);
                AddButton.Click += AddButton_Click;
                commandBar.PrimaryCommands.Add(AddButton);

                HelpButton        = new AppBarButton();
                HelpButton.Label  = "Help";
                HelpButton.Icon   = new SymbolIcon(Symbol.Help);
                HelpButton.Click += HelpButton_Click;
                commandBar.PrimaryCommands.Add(HelpButton);

                AboutButton        = new AppBarButton();
                AboutButton.Label  = "About";
                AboutButton.Icon   = new SymbolIcon(Symbol.Important);
                AboutButton.Click += AboutButton_Click;
                commandBar.PrimaryCommands.Add(AboutButton);
            }

            if (GetType() == typeof(ListManager.Views.ListItems))
            {
                HomeButton        = new AppBarButton();
                HomeButton.Label  = "Home";
                HomeButton.Icon   = new SymbolIcon(Symbol.Home);
                HomeButton.Click += ListsButton_Click;
                commandBar.PrimaryCommands.Add(HomeButton);

                AddButton        = new AppBarButton();
                AddButton.Label  = "Edit Lists";
                AddButton.Icon   = new SymbolIcon(Symbol.Edit);
                AddButton.Click += AddButton_Click;
                commandBar.PrimaryCommands.Add(AddButton);

                HelpButton        = new AppBarButton();
                HelpButton.Label  = "Help";
                HelpButton.Icon   = new SymbolIcon(Symbol.Help);
                HelpButton.Click += HelpButton_Click;
                commandBar.PrimaryCommands.Add(HelpButton);
            }

            if (GetType() == typeof(ListManager.Views.ListEdit))
            {
                HomeButton        = new AppBarButton();
                HomeButton.Label  = "Home";
                HomeButton.Icon   = new SymbolIcon(Symbol.Home);
                HomeButton.Click += ListsButton_Click;
                commandBar.PrimaryCommands.Add(HomeButton);

                HelpButton        = new AppBarButton();
                HelpButton.Label  = "Help";
                HelpButton.Icon   = new SymbolIcon(Symbol.Help);
                HelpButton.Click += HelpButton_Click;
                commandBar.PrimaryCommands.Add(HelpButton);
            }

            if (GetType() == typeof(ListManager.Views.Help))
            {
                AppBarButton ListsButton = new AppBarButton();
                ListsButton.Label  = "Home";
                ListsButton.Icon   = new SymbolIcon(Symbol.Home);
                ListsButton.Click += ListsButton_Click;
                commandBar.PrimaryCommands.Add(ListsButton);

                AddButton        = new AppBarButton();
                AddButton.Label  = "Edit Lists";
                AddButton.Icon   = new SymbolIcon(Symbol.Edit);
                AddButton.Click += AddButton_Click;
                commandBar.PrimaryCommands.Add(AddButton);
            }

            if (GetType() == typeof(ListManager.Views.About))
            {
                AppBarButton ListsButton = new AppBarButton();
                ListsButton.Label  = "Home";
                ListsButton.Icon   = new SymbolIcon(Symbol.Home);
                ListsButton.Click += ListsButton_Click;
                commandBar.PrimaryCommands.Add(ListsButton);

                AddButton        = new AppBarButton();
                AddButton.Label  = "Edit Lists";
                AddButton.Icon   = new SymbolIcon(Symbol.Edit);
                AddButton.Click += AddButton_Click;
                commandBar.PrimaryCommands.Add(AddButton);
            }

            if (GetType() == typeof(ListManager.Views.TestPages.LoadPhoneDatabase))
            {
                HomeButton        = new AppBarButton();
                HomeButton.Label  = "Home";
                HomeButton.Icon   = new SymbolIcon(Symbol.Home);
                HomeButton.Click += ListsButton_Click;
                commandBar.PrimaryCommands.Add(HomeButton);

                AddButton        = new AppBarButton();
                AddButton.Label  = "Edit Lists";
                AddButton.Icon   = new SymbolIcon(Symbol.Edit);
                AddButton.Click += AddButton_Click;
                commandBar.PrimaryCommands.Add(AddButton);
            }

            //HelpButton = new AppBarButton();
            //HelpButton.Label = "Help";
            //HelpButton.Icon = new SymbolIcon(Symbol.Help);
            //HelpButton.Click += HelpButton_Click;
            //commandBar.PrimaryCommands.Add(HelpButton);

            AppBarButton DatabaseButton = new AppBarButton();

            DatabaseButton.Label  = "Testing";
            DatabaseButton.Icon   = new SymbolIcon(Symbol.Setting);
            DatabaseButton.Click += DatabaseButton_Click;
            commandBar.PrimaryCommands.Add(DatabaseButton);

            BottomAppBar = commandBar;
            BottomAppBar.HorizontalAlignment = HorizontalAlignment.Center;
            BottomAppBar.FlowDirection       = FlowDirection.LeftToRight;
        }