Example #1
0
        protected override bool TryCalculateStateName(out string stateName)
        {
            try
            {
                // TODO: Get args
                var         view   = ApplicationView.GetForCurrentView();
                var         bounds = (Window.Current != null ? Window.Current.Bounds : Rect.Empty);
                LayoutState layout = new LayoutState();

                // See if we have event subscribers first
                if (LayoutStateCalculating != null)
                {
                    // Wrap in event args
                    var e = new LayoutStateCalculatingEventArgs(layout);

                    // Raise the event
                    LayoutStateCalculating(this, e);

                    // If the calculation was canceled, bail
                    if (e.IsCanceled)
                    {
                        stateName = null;
                        return(false);
                    }

                    // If the calculation was handled, process
                    if (e.IsHandled)
                    {
                        stateName = e.StateName;
                        return(true);
                    }
                }

                // No subscribers or none handled it. Pass to override.
                return(TryCalculateStateName(layout, out stateName));
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Could not calculate state name. {0}", ex.Message);
                stateName = null;
                return(false);
            }
        }
        protected override bool TryCalculateStateName(out string stateName)
        {
            try
            {
                // TODO: Get args
                var view = ApplicationView.GetForCurrentView();
                var bounds = (Window.Current != null ? Window.Current.Bounds : Rect.Empty);
                LayoutState layout = new LayoutState();

                // See if we have event subscribers first
                if (LayoutStateCalculating != null)
                {
                    // Wrap in event args
                    var e = new LayoutStateCalculatingEventArgs(layout);

                    // Raise the event
                    LayoutStateCalculating(this, e);

                    // If the calculation was canceled, bail
                    if (e.IsCanceled)
                    {
                        stateName = null;
                        return false;
                    }

                    // If the calculation was handled, process
                    if (e.IsHandled)
                    {
                        stateName = e.StateName;
                        return true;
                    }
                }

                // No subscribers or none handled it. Pass to override.
                return TryCalculateStateName(layout, out stateName);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Could not calculate state name. {0}", ex.Message);
                stateName = null;
                return false;
            }
        }