示例#1
0
        void CRMAppBar_Loaded(object sender, RoutedEventArgs e)
        {
            _loadedInstance = sender as CRMAppBar;

            restoreAppBarContentDataContext();
            _container.AppBarContent = _appBarContent;
        }
示例#2
0
        public CRMAppBar()
        {
            //DefaultStyleKeyProperty.OverrideMetadata(typeof(CRMAppBar), new FrameworkPropertyMetadata(typeof(CRMAppBar)));

            if (UIHelper.IsInDesignMode || _instance == null)
            {
                _instance = this;

                _container            = new CRMAppBarContainer();
                _container.Background = _instance.Background;
                Content = _container;

                if (!UIHelper.IsInDesignMode)
                {
                    WeakEventManager <CRMAppBar, PropertyChangedEventArgs> .AddHandler(this, "PropertyChanged", CRMAppBar_PropertyChanged);

                    EventManager.RegisterClassHandler(typeof(CRMAppBar), CRMAppBar.MouseEnterEvent,
                                                      new RoutedEventHandler(OnLocalMouseEnter));

                    EventManager.RegisterClassHandler(typeof(CRMAppBar), CRMAppBar.MouseLeaveEvent,
                                                      new RoutedEventHandler(OnLocalMouseLeave));

                    WeakEventManager <CRMAppBar, TouchEventArgs> .AddHandler(this, "TouchEnter", OnLocalTouchEnter);

                    WeakEventManager <CRMAppBar, TouchEventArgs> .AddHandler(this, "TouchMove", OnLocalTouchMove);

                    WeakEventManager <CRMAppBar, TouchEventArgs> .AddHandler(this, "TouchLeave", OnLocalTouchLeave);
                }
            }

            WeakEventManager <CRMAppBar, RoutedEventArgs> .AddHandler(this, "Loaded", CRMAppBar_Loaded);

            WeakEventManager <CRMAppBar, RoutedEventArgs> .AddHandler(this, "Unloaded", CRMAppBar_Unloaded);
        }
示例#3
0
        private static void OnExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue == e.OldValue)
            {
                return;
            }

            CRMAppBar panel = d as CRMAppBar;

            if (!panel.AutoHide)
            {
                return;
            }

            if (panel == null)
            {
                return;
            }

            bool newVal = (bool)e.NewValue;

            panel.IsExpanded = newVal;

            bool expanded = (bool)panel.GetValue(IsExpandedProperty);

            Storyboard heightAnimation = createDoubleAnimation(panel, expanded);

            Timeline opacity = doubleAnimation(0.0, 1.0, expanded, OpacityProperty);

            Storyboard.SetTargetName(opacity, panel.Name);
            Storyboard.SetTargetProperty(opacity, new PropertyPath(OpacityProperty));
            heightAnimation.Children.Add(opacity);

            heightAnimation.Begin(panel);
        }
示例#4
0
        private static void OnClosedHeightChange(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CRMAppBar panel = d as CRMAppBar;

            if (!panel.AutoHide)
            {
                return;
            }

            if (panel != null)
            {
                panel.Height = (double)e.NewValue;
            }
        }
示例#5
0
        private static void SetExpanded(object sender, bool expanded)
        {
            CRMAppBar panel = sender as CRMAppBar;

            if (!panel.AutoHide)
            {
                return;
            }

            if (panel != null)
            {
                panel.IsExpanded = expanded;
            }
        }
示例#6
0
        private void OnLocalTouchEnter(object sender, TouchEventArgs e)
        {
            CRMAppBar appBar = sender as CRMAppBar;

            if (appBar == null)
            {
                return;
            }

            appBar.CaptureTouch(e.TouchDevice);

            OnLocalMouseEnter(sender, e);
            e.Handled = true;
        }
示例#7
0
        private void OnLocalTouchLeave(object sender, TouchEventArgs e)
        {
            CRMAppBar button = sender as CRMAppBar;

            if (button == null)
            {
                return;
            }

            TouchPoint tp     = e.GetTouchPoint(button);
            Rect       bounds = new Rect(new Point(0, 0), button.RenderSize);

            if (!bounds.Contains(tp.Position)) // Si esta fuera de la AppBar. Si está dentro solo levantó el dedo!
            {
                OnLocalMouseLeave(sender, new RoutedEventArgs());
            }

            button.ReleaseTouchCapture(e.TouchDevice);
            e.Handled = true;
        }
示例#8
0
        public CRMAppBar()
        {
            //DefaultStyleKeyProperty.OverrideMetadata(typeof(CRMAppBar), new FrameworkPropertyMetadata(typeof(CRMAppBar)));

            if (UIHelper.IsInDesignMode || _instance == null)
            {
                _instance = this;
                
                _container = new CRMAppBarContainer();
                _container.Background = _instance.Background;                
                Content = _container;

                if (!UIHelper.IsInDesignMode)
                {
                    WeakEventManager<CRMAppBar, PropertyChangedEventArgs>.AddHandler(this, "PropertyChanged", CRMAppBar_PropertyChanged);

                    EventManager.RegisterClassHandler(typeof(CRMAppBar), CRMAppBar.MouseEnterEvent,
                                     new RoutedEventHandler(OnLocalMouseEnter));

                    EventManager.RegisterClassHandler(typeof(CRMAppBar), CRMAppBar.MouseLeaveEvent,
                                     new RoutedEventHandler(OnLocalMouseLeave));

                    WeakEventManager<CRMAppBar, TouchEventArgs>.AddHandler(this, "TouchEnter", OnLocalTouchEnter);
                    WeakEventManager<CRMAppBar, TouchEventArgs>.AddHandler(this, "TouchMove", OnLocalTouchMove);
                    WeakEventManager<CRMAppBar, TouchEventArgs>.AddHandler(this, "TouchLeave", OnLocalTouchLeave);
                }
            }

            WeakEventManager<CRMAppBar, RoutedEventArgs>.AddHandler(this, "Loaded", CRMAppBar_Loaded);
            WeakEventManager<CRMAppBar, RoutedEventArgs>.AddHandler(this, "Unloaded", CRMAppBar_Unloaded);
        }
示例#9
0
        void CRMAppBar_Loaded(object sender, RoutedEventArgs e)
        {
            _loadedInstance = sender as CRMAppBar;

            restoreAppBarContentDataContext();
            _container.AppBarContent = _appBarContent;        
        }