Esempio n. 1
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            LayoutRoot       = GetTemplateChild("LayoutRoot") as Grid;
            header           = GetTemplateChild("header") as CalendarHeader;
            yearheader       = GetTemplateChild("yearheader") as CalendarYearHeadar;
            semanticzoomDate = GetTemplateChild("semanticzoomDate") as SemanticZoom;
            gridviewDays     = GetTemplateChild("gridviewDays") as GridView;
            gridviewMonths   = GetTemplateChild("gridviewMonths") as GridView;

            Days   = new ObservableCollection <Day>();
            Months = new ObservableCollection <Month>();
            Years  = new ObservableCollection <Year>();

            this.Loaded += Calendar_Loaded;
            this.header.LeftButtonClick  += header_LeftButtonClick;
            this.header.RightButtonClick += header_RightButtonClick;

            this.yearheader.LeftButtonClick  += yearheader_LeftButtonClick;
            this.yearheader.RightButtonClick += yearheader_RightButtonClick;

            this.gridviewDays.ItemClick += gridviewDays_ItemClick;

            this.semanticzoomDate.ViewChangeStarted += semanticzoomDate_ViewChangeStarted;
        }
Esempio n. 2
0
        public SemanticZoom GetCurrentSemanticZoom(string name)
        {
            NavigationRootPage rootPage = Window.Current.Content as NavigationRootPage;

            if (rootPage != null)
            {
                Frame rootFrame = (Frame)rootPage.FindName("rootFrame");

                if (rootFrame != null)
                {
                    SemanticZoom sz = CoreVisualTreeHelper.Instance.FindVisualChildByName <SemanticZoom>(rootFrame.Content as Page, name);
                    if (sz != null)
                    {
                        return(sz);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
        private static void OnSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SemanticZoom @this = (SemanticZoom)d;

            if (!(@this.ZoomedInView is ListViewBase zoomedInList &&
                  @this.ZoomedOutView is ListViewBase zoomedOutList))
            {
                return;
            }

            if (e.NewValue is IEnumerable value)
            {
                CollectionViewSource source = new CollectionViewSource
                {
                    IsSourceGrouped = true,
                    Source          = value
                };

                // Assign the source data
                zoomedInList.ItemsSource  = source.View;
                zoomedOutList.ItemsSource = source.View.CollectionGroups;
            }
            else
            {
                zoomedInList.ItemsSource = zoomedOutList.ItemsSource = null;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest
        /// terms, this means the method is called just before a UI element displays in your app. Override this method to influence the
        /// default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (this.semanticZoom != null)
            {
                var view = this.semanticZoom.ZoomedInView as ListViewBase;
                if (view != null)
                {
                    view.SelectionChanged -= this.OnSelectionChanged;
                }

                this.semanticZoom.Tapped -= this.OnSemanticZoomTapped;
            }

            this.semanticZoom = this.GetTemplateChild(Picker <T> .PartSemanticZoom) as SemanticZoom;
            if (this.semanticZoom != null)
            {
                var view = this.semanticZoom.ZoomedInView as ListViewBase;
                if (view != null)
                {
                    view.SelectionChanged += this.OnSelectionChanged;
                }

                this.semanticZoom.IsZoomOutButtonEnabled = false;
                this.semanticZoom.Tapped += this.OnSemanticZoomTapped;
                this.semanticZoom.Tag     = this;
            }

            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                this.SetDataSource(this.GetDesignTimeData());
            }
        }
Esempio n. 5
0
        void rootPage_OutputFrameLoaded(object sender, object e)
        {
            // At this point, we know that the Output Frame has been loaded and we can go ahead
            // and reference elements in the page contained in the Output Frame.

            // Get a pointer to the content within the OutputFrame.
            Page outputFrame = (Page)rootPage.OutputFrame.Content;

            // Go find the elements that we need for this scenario.
            // ex: flipView1 = outputFrame.FindName("FlipView1") as FlipView;
            semanticZoom = outputFrame.FindName("semanticZoom") as SemanticZoom;
        }
        void UpdateGrouping()
        {
            if (Element?.ItemsSource == null)
            {
                return;
            }

            bool grouping = Element.IsGroupingEnabled;

            ((CollectionViewSource)List.DataContext).IsSourceGrouped = grouping;

            var templatedItems = TemplatedItemsView.TemplatedItems;

            if (grouping && templatedItems.ShortNames != null)
            {
                if (_zoom == null)
                {
                    ScrollViewer.SetIsVerticalScrollChainingEnabled(List, false);

                    var grid = new GridView {
                        ItemsSource = templatedItems.ShortNames, Style = (Windows.UI.Xaml.Style)WApp.Current.Resources["JumpListGrid"]
                    };

                    ScrollViewer.SetIsHorizontalScrollChainingEnabled(grid, false);

                    _zoom = new SemanticZoom {
                        IsZoomOutButtonEnabled = false, ZoomedOutView = grid
                    };

                    // Since we reuse our ScrollTo, we have to wait until the change completes or ChangeView has odd behavior.
                    _zoom.ViewChangeCompleted += OnViewChangeCompleted;

                    // Specific order to let SNC unparent the ListView for us
                    SetNativeControl(_zoom);
                    _zoom.ZoomedInView = List;
                }
                else
                {
                    _zoom.CanChangeViews = true;
                }
            }
            else
            {
                if (_zoom != null)
                {
                    _zoom.CanChangeViews = false;
                }
                else if (List != Control)
                {
                    SetNativeControl(List);
                }
            }
        }
Esempio n. 7
0
        void UpdateGrouping()
        {
            bool grouping = Element.IsGroupingEnabled;

            if (_collectionViewSource != null)
            {
                _collectionViewSource.IsSourceGrouped = grouping;
            }

            var templatedItems = TemplatedItemsView.TemplatedItems;

            if (grouping && templatedItems.ShortNames != null)
            {
                if (_zoom == null)
                {
                    ScrollViewer.SetIsVerticalScrollChainingEnabled(List, false);

                    var grid = new GridView {
                        ItemsSource = templatedItems.ShortNames, Style = (Microsoft.UI.Xaml.Style)WApp.Current.Resources["JumpListGrid"]
                    };

                    ScrollViewer.SetIsHorizontalScrollChainingEnabled(grid, false);

                    _zoom = new SemanticZoom {
                        IsZoomOutButtonEnabled = false, ZoomedOutView = grid
                    };

                    // Since we reuse our ScrollTo, we have to wait until the change completes or ChangeView has odd behavior.
                    _zoom.ViewChangeCompleted += OnViewChangeCompleted;

                    _zoom.ZoomedInView = List;
                }
                else
                {
                    _zoom.CanChangeViews = true;
                }

                SetNativeControl(_zoom);
            }
            else
            {
                if (_zoom != null)
                {
                    _zoom.CanChangeViews = false;
                }
            }
        }
Esempio n. 8
0
        private void Grid_Tapped(object sender, TappedRoutedEventArgs e)
        {
            SemanticZoom sz = this.semanticZoomShowByDate;

            sz.IsZoomedInViewActive = false;
        }
Esempio n. 9
0
        public object Execute(object sender, object parameter)
        {
            bool   result = false;
            object target;

            if (ReadLocalValue(TargetObjectProperty) != DependencyProperty.UnsetValue)
            {
                target = TargetObject;
            }
            else
            {
                target = sender;
            }

            if (target != null)
            {
                ListViewBase view   = null;
                ScrollViewer scroll = null;

                if (target.GetType() == typeof(SemanticZoom))
                {
                    SemanticZoom semanticZoom = (SemanticZoom)target;
                    if (semanticZoom.Visibility == Visibility.Visible)
                    {
                        if (semanticZoom.IsZoomedInViewActive)
                        {
                            view = (ListViewBase)semanticZoom.ZoomedInView;
                        }
                        else
                        {
                            view = (ListViewBase)semanticZoom.ZoomedOutView;
                        }
                    }
                }
                else if (target.GetType() == typeof(ListView))
                {
                    ListView listView = (ListView)target;
                    if (listView.Visibility == Visibility.Visible)
                    {
                        view = listView;
                    }
                }


                if (view != null)
                {
                    scroll = _getScrollViewer(view);

                    if (Up)
                    {
                        if (scroll.VerticalOffset > scroll.ViewportHeight / 2)
                        {
                            scroll.ChangeView(null, scroll.VerticalOffset - (scroll.ViewportHeight / 2), null);
                        }
                        else
                        {
                            scroll.ChangeView(null, 0, null);
                        }
                        result = true;
                    }
                    if (Down)
                    {
                        if (scroll.ScrollableHeight - scroll.VerticalOffset > 0)
                        {
                            if (scroll.ScrollableHeight - scroll.VerticalOffset > scroll.ViewportHeight / 2)
                            {
                                scroll.ChangeView(null, scroll.VerticalOffset + (scroll.ViewportHeight / 2), null);
                            }
                            else
                            {
                                scroll.ChangeView(null, scroll.ScrollableHeight, null);
                            }
                        }

                        result = true;
                    }
                }
            }



            return(result);
        }
 public static void SetSource(SemanticZoom element, IEnumerable value)
 {
     element.SetValue(SourceProperty, value);
 }
 public static IEnumerable GetSource(SemanticZoom element)
 {
     return((IEnumerable <IReadOnlyObservableGroup>)element.GetValue(SourceProperty));
 }