//*********************************************************************************************************************** //*********************************************************************************************************************** /// <summary> /// Permet de définir une une fois les boutons de la barre d'application. /// </summary> /// <param name="Self">Objet concerné par l'appel.</param> /// <param name="Mode"></param> /// <param name="Buttons">Boutons de la barre d'application.</param> //----------------------------------------------------------------------------------------------------------------------- public static void SetButtons(this IApplicationBar Self, ApplicationBarMode Mode, params ApplicationBarIconButton[] Buttons) { //------------------------------------------------------------------------------------------------------------------- if (Self != null) { //--------------------------------------------------------------------------------------------------------------- if (ApplicationBars.ContainsKey(Self) && ApplicationBars[Self].IsSuspended) { //----------------------------------------------------------------------------------------------------------- ApplicationBars[Self].IsSuspended = false; var buttons = new List <ApplicationBarIconButton> (); foreach (ApplicationBarIconButton Button in Buttons) { buttons.Add(Button); } ApplicationBars[Self].Mode = Mode; ApplicationBars[Self].Buttons = buttons.ToArray(); //----------------------------------------------------------------------------------------------------------- } //--------------------------------------------------------------------------------------------------------------- else { Set(Self, Mode, Buttons); } //--------------------------------------------------------------------------------------------------------------- } //------------------------------------------------------------------------------------------------------------------- }
public void SetDefaults(ApplicationBarMode?mode, Color?background, Color?foreground, double?opacity = null, bool apply = true) { defaultMode = mode ?? ApplicationBarMode.Default; defaultBackground = background ?? DefaultColour; defaultForeground = foreground ?? DefaultColour; defaultOpacity = opacity ?? DefaultOpacity; if (apply && (managedBar != null)) { managedBar.Mode = defaultMode; managedBar.BackgroundColor = defaultBackground; managedBar.ForegroundColor = defaultForeground; managedBar.Opacity = defaultOpacity; } }
/// <summary> /// Provides derived classes an opportunity to handle changes to /// the Mode property. /// </summary> /// <param name="oldMode">The old Mode value.</param> /// <param name="newMode">The new Mode value.</param> protected virtual void OnModeChanged( ApplicationBarMode oldMode, ApplicationBarMode newMode) { if (this.applicationBar != null) { this.applicationBar.Mode = newMode; } this.modeChanged = true; }
private void ModeChanged(ApplicationBarMode mode) { internalApplicationBar.Mode = mode; }
private void ModeChanged(ApplicationBarMode mode) { _internalApplicationBar.Mode = mode; }
private void SynchronizeProperties() { if (this.isVisibleChanged) { this.applicationBar.IsVisible = this.IsVisible; } else if (GetBindingExpression(IsVisibleProperty) == null) { this.IsVisible = this.applicationBar.IsVisible; } if (this.isMenuEnabledChanged) { this.applicationBar.IsMenuEnabled = this.IsMenuEnabled; } else if (GetBindingExpression(IsMenuEnabledProperty) == null) { this.IsMenuEnabled = this.applicationBar.IsMenuEnabled; } if (this.backgroundColorChanged) { this.applicationBar.BackgroundColor = this.BackgroundColor; } else if (GetBindingExpression(BackgroundColorProperty) == null) { this.BackgroundColor = this.applicationBar.BackgroundColor; } if (this.foregroundColorChanged) { this.applicationBar.ForegroundColor = this.ForegroundColor; } else if (GetBindingExpression(ForegroundColorProperty) == null) { this.ForegroundColor = this.applicationBar.ForegroundColor; } if (this.modeChanged) { this.applicationBar.Mode = this.Mode; } else if (GetBindingExpression(ModeProperty) == null) { this.Mode = this.applicationBar.Mode; } if (this.bindableOpacityChanged) { this.applicationBar.Opacity = this.BindableOpacity; } else if (GetBindingExpression(BindableOpacityProperty) == null) { this.BindableOpacity = this.applicationBar.Opacity; } }
public ApplicationBarPage(ApplicationBarMode mode = ApplicationBarMode.Minimized) { this.Mode = mode; this.Buttons = new List<ApplicationBarIconButton>(); this.MenuItems = new List<ApplicationBarMenuItem>(); }
//----------------------------------------------------------------------------------------------------------------------- //*********************************************************************************************************************** /// <summary> /// Permet de définir une une fois les boutons de la barre d'application. /// </summary> /// <param name="Self">Objet concerné par l'appel.</param> /// <param name="Buttons">Boutons de la barre d'application.</param> //----------------------------------------------------------------------------------------------------------------------- private static void Set(this IApplicationBar Self, ApplicationBarMode Mode, params ApplicationBarIconButton[] Buttons) { //------------------------------------------------------------------------------------------------------------------- if (Self != null) { //--------------------------------------------------------------------------------------------------------------- var Rs = new List <ApplicationBarIconButton> (); var Is = new List <KeyValuePair <ApplicationBarIconButton, int> > (); var As = new List <ApplicationBarIconButton> (); var Bs = new List <ApplicationBarIconButton> (Buttons); foreach (ApplicationBarIconButton Button in Self.Buttons) { As.Add(Button); } //--------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------- // On retire tous les boutons du block 1 qui ne sont pas dans le block B //--------------------------------------------------------------------------------------------------------------- for (int Index = As.Count - 1; Index >= 0; Index--) { //----------------------------------------------------------------------------------------------------------- if (!Bs.Contains(As[Index])) { Rs.Add(As[Index]); As.RemoveAt(Index); } //----------------------------------------------------------------------------------------------------------- } //--------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------- // S'il reste des boutons dans le block A, on continue le traitement //--------------------------------------------------------------------------------------------------------------- if (As.Count > 0) { //----------------------------------------------------------------------------------------------------------- for (int Index = 0; Index < Bs.Count; Index++) { //------------------------------------------------------------------------------------------------------- if (Index < As.Count) { //--------------------------------------------------------------------------------------------------- // Le bouton n'est pas à la bonne place, on insert //--------------------------------------------------------------------------------------------------- if (Bs[Index] != As[Index]) { Is.Add(new KeyValuePair <ApplicationBarIconButton, int> (Bs[Index], Index)); As.Insert(Index, Bs[Index]); } //--------------------------------------------------------------------------------------------------- } //------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------- // Le block A est trop petit, on insert à la fin //------------------------------------------------------------------------------------------------------- else { //--------------------------------------------------------------------------------------------------- Is.Add(new KeyValuePair <ApplicationBarIconButton, int> (Bs[Index], Index)); As.Insert(Index, Bs[Index]); //--------------------------------------------------------------------------------------------------- } //------------------------------------------------------------------------------------------------------- } //----------------------------------------------------------------------------------------------------------- } //--------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------- else { Rs.Clear(); } //--------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------- // Des opérations sont a effectuer //--------------------------------------------------------------------------------------------------------------- if (Rs.Count > 0 || Is.Count > 0) { //----------------------------------------------------------------------------------------------------------- foreach (ApplicationBarIconButton Item in Rs) { Self.Buttons.Remove(Item); } //----------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------- foreach (KeyValuePair <ApplicationBarIconButton, int> Item in Is) { Self.Buttons.Insert(Item.Value, Item.Key); } //----------------------------------------------------------------------------------------------------------- } //--------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------- else if (As.Count == 0) { //----------------------------------------------------------------------------------------------------------- Self.Buttons.Clear(); var Timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(25) }; Timer.Tick += (sender, args) => { Timer.Stop(); Self.Buttons.Clear(); foreach (object Button in Buttons) { Self.Buttons.Add(Button); } }; Timer.Start(); //----------------------------------------------------------------------------------------------------------- } //--------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------- Self.Mode = Mode; //--------------------------------------------------------------------------------------------------------------- } //------------------------------------------------------------------------------------------------------------------- }