private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            //Workaround: the initial selection for a FlipView isn't respected when it's made before the page is loaded,
            // so it's necessary to clear its state and try again once the page is loaded.  Clearly this is not intended
            // to be necessary.
            if (sender == this)
            {
                var originallySelectedItem = Item;
                Item = null;
                UpdateLayout();
                Item = originallySelectedItem;
            }

            var control = sender as Control;

            if (viewStateAwareControls.Count == 0)
            {
                if (_displayHandler == null)
                {
                    _displayHandler = Page_OrientationChanged;
                    _layoutHandler  = Page_LayoutChanged;
                }
                DisplayProperties.OrientationChanged += _displayHandler;
                ApplicationLayout.GetForCurrentView().LayoutChanged += _layoutHandler;
            }
            viewStateAwareControls.Add(control);
            SetCurrentViewState(control);
        }
        ApplicationLayout GetAppLayout(ApplicationInteractionMode intaractionMode)
        {
            ApplicationLayout layout = ApplicationLayout.Mobile;

            if (intaractionMode == ApplicationInteractionMode.Mouse ||
                intaractionMode == ApplicationInteractionMode.Touch
                )
            {
                var width = Window.Current.Bounds.Width;
                if (width <= 519)
                {
                    layout = ApplicationLayout.Mobile;
                }
                else if (width <= 799)
                {
                    layout = ApplicationLayout.Tablet;
                }
                else
                {
                    layout = ApplicationLayout.Desktop;
                }
            }
            else if (intaractionMode == ApplicationInteractionMode.Controller)
            {
                layout = ApplicationLayout.TV;
            }

            return(layout);
        }
 private void Page_Unloaded(object sender, RoutedEventArgs e)
 {
     viewStateAwareControls.Remove(sender as Control);
     if (viewStateAwareControls.Count == 0)
     {
         DisplayProperties.OrientationChanged -= _displayHandler;
         ApplicationLayout.GetForCurrentView().LayoutChanged -= _layoutHandler;
     }
 }
        void InitializeWindow()
        {
            Debug.Assert(MainWindow != null, "Window cannot be null");

            MainWindow.Active();
            MainWindow.Show();

            // in case of no use of preloaded window
            if (BaseLayout == null)
            {
                var conformant = new Conformant(MainWindow);
                conformant.Show();

                var layout = new ApplicationLayout(conformant);

                layout.Show();

                BaseLayout = layout;

                if (Device.Idiom == TargetIdiom.Watch)
                {
                    BaseCircleSurface   = new CircleSurface(conformant);
                    Forms.CircleSurface = BaseCircleSurface;
                }
                conformant.SetContent(BaseLayout);
            }

            MainWindow.AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_90 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270;

            MainWindow.Deleted += (s, e) =>
            {
                Exit();
            };

            Device.Info.CurrentOrientation = MainWindow.GetDeviceOrientation();

            MainWindow.RotationChanged += (sender, e) =>
            {
                Device.Info.CurrentOrientation = MainWindow.GetDeviceOrientation();
            };

            MainWindow.BackButtonPressed += (sender, e) =>
            {
                if (_platform != null)
                {
                    if (!_platform.SendBackButtonPressed())
                    {
                        Exit();
                    }
                }
            };

            _platform = Platform.CreatePlatform(BaseLayout);
            BaseLayout.SetContent(_platform.GetRootNativeView());
            _platform.RootNativeViewChanged += (s, e) => BaseLayout.SetContent(e.RootNativeView);
        }
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     if (_displayHandler == null)
     {
         _displayHandler = Page_OrientationChanged;
         _layoutHandler  = Page_LayoutChanged;
     }
     DisplayProperties.OrientationChanged += _displayHandler;
     ApplicationLayout.GetForCurrentView().LayoutChanged += _layoutHandler;
     SetCurrentOrientation(this);
 }
示例#6
0
        protected void Initialize()
        {
            var conformant = new Conformant(this);

            conformant.Show();

            var layout = new ApplicationLayout(conformant);

            layout.Show();

            BaseLayout = layout;
            conformant.SetContent(BaseLayout);
        }
示例#7
0
        public static void Initialize(this Window platformWindow)
        {
            var baseLayout = (ELayout?)platformWindow.GetType().GetProperty("BaseLayout")?.GetValue(platformWindow);

            if (baseLayout == null)
            {
                var conformant = new Conformant(platformWindow);
                conformant.Show();

                var layout = new ApplicationLayout(conformant);
                layout.Show();

                baseLayout = layout;
                conformant.SetContent(baseLayout);
            }
            platformWindow.SetBaseLayout(baseLayout);
            var modalStack = new ModalStack(baseLayout)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            modalStack.Show();
            baseLayout.SetContent(modalStack);
            platformWindow.SetModalStack(modalStack);

            platformWindow.Active();
            platformWindow.Show();
            platformWindow.AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_90 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270;

            platformWindow.RotationChanged += (sender, e) =>
            {
                // TODO : should update later
            };

            platformWindow.BackButtonPressed += (s, e) => OnBackButtonPressed(platformWindow);
        }
示例#8
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (_displayHandler == null)
            {
                _displayHandler = Page_OrientationChanged;
                _layoutHandler  = Page_LayoutChanged;
            }
            DisplayProperties.OrientationChanged += _displayHandler;
            ApplicationLayout.GetForCurrentView().LayoutChanged += _layoutHandler;

            if (App.PreviousSubreddit == null || App.PreviousSubreddit != App.SelectedSubreddit || App.LastRefresh < DateTime.Now.Subtract(App.RefreshInterval))
            {
                App.JsonClient = new HttpClient();
                var response = App.JsonClient.GetAsync("http://www.reddit.com" + App.SelectedSubreddit.data.url + ".json").Result.Content;
                LoadCollection(response);
                App.LastRefresh = DateTime.Now;
            }
            else
            {
                Items          = App.Posts.children;
                PageTitle.Text = App.SelectedSubreddit.data.url;
            }
            SetCurrentViewState(this);
        }
 private void Page_Unloaded(object sender, RoutedEventArgs e)
 {
     DisplayProperties.OrientationChanged -= _displayHandler;
     ApplicationLayout.GetForCurrentView().LayoutChanged -= _layoutHandler;
 }
        //private void RespCallback(IAsyncResult ar)
        //{
        //    RequestState rs = (RequestState)ar.AsyncState;
        //    WebRequest req = rs.Request;
        //    WebResponse response = req.EndGetResponse(ar);
        //    Stream responseStream = response.GetResponseStream();
        //    rs.ResponseStream = responseStream;
        //    //LoadCollection(responseStream);
        //}

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            //App.BaseFilePath = this.BaseUri.AbsolutePath;
            //CollectionViewSource.Source = Subreddits.Items;
            //ItemGridView.ItemsSource = Subreddits;
            ItemGridView.IncrementalLoadingTrigger = IncrementalLoadingTrigger.Edge;
            //Subreddits.LoadMoreItemsAsync(25, this.Dispatcher);

            //ItemGridView.DataContext = Subreddits;

            App.SearchPane = SearchPane.GetForCurrentView();
            if (_displayHandler == null)
            {
                _displayHandler = Page_OrientationChanged;
                _layoutHandler  = Page_LayoutChanged;
            }
            DisplayProperties.OrientationChanged += _displayHandler;
            ApplicationLayout.GetForCurrentView().LayoutChanged += _layoutHandler;

            if (App.Subreddits == null || App.Subreddits.Count == 0)
            {
                //Task.Run(() =>
                //{
                //    //App.Subreddits = new Collections.RedditCollection(App.isLoggedIn);
                //    //App.Subreddits.CollectionChanged += new Windows.Foundation.Collections.VectorChangedEventHandler<object>(Subreddits_CollectionChanged);
                //    //App.Subreddits.LoadMoreItemsAsync(25);

                //});
                //ItemGridView.ItemsSource = App.Subreddits;
                //if (App.isLoggedIn)
                //{
                //    try
                //    {
                //        var request = (HttpWebRequest)WebRequest.Create("http://www.reddit.com/reddits/mine.json");
                //        request.CookieContainer = new CookieContainer();

                //        Cookie c = new Cookie("reddit_session", App.cookie.Replace(",", "%2C"));
                //        request.CookieContainer.Add(new Uri("http://www.reddit.com"), c);

                //        RequestState rs = new RequestState();
                //        rs.Request = request;

                //        var response = request.BeginGetResponse(new AsyncCallback(RespCallback), rs);
                //        //LoadCollection(response);
                //    }
                //    catch (Exception)
                //    {

                //    }
                //}
                //else
                //{
                //    var client = new HttpClient();
                //    var response = client.GetAsync("http://www.reddit.com/reddits.json").Result.Content;
                //    LoadCollection(response);
                //}
            }
            else
            {
                //CollectionViewSource.Source = App.Subreddits;
                this.UpdateLayout();
            }

            SettingsPane settingsPane = SettingsPane.GetForCurrentView();

            if (settingsPane.ApplicationCommands.Count == 0)
            {
                settingsPane.ApplicationCommands.Add(new SettingsCommand(KnownSettingsCommand.Account, new UICommandInvokedHandler(AccountCommandHandler)));
            }

            SetCurrentViewState(this);
        }