Exemplo n.º 1
0
        public MyTaskList()
        {
            isHaveMoreItems = true;
            if (roamingSettings.Values.ContainsKey(Constants.SettingName.LoadPageSize))
            {
                pageSize = Convert.ToInt32(roamingSettings.Values[Constants.SettingName.LoadPageSize]);
            }

            UserAccountHelper userAccount = new UserAccountHelper();

            userName = userAccount.GetUserNameFromLocker();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            this.loading.IsActive = true;
            UserAccountHelper userAccount = new UserAccountHelper();

            userName = userAccount.GetUserNameFromLocker();

            IntialMyContactModel();

            //初始化页面内容
            object[] parameters = e.Parameter as object[];
            InitPageContent(parameters);
            this.loading.IsActive = false;

            base.OnNavigatedTo(e);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            AppShell shell = Window.Current.Content as AppShell;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (shell == null)
            {
                // Create a AppShell to act as the navigation context and navigate to the first page
                shell = new AppShell();

                // Set the default language
                shell.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                shell.AppFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }
            }

            // Place our app shell in the current Window
            Window.Current.Content = shell;

            if (shell.AppFrame.Content == null)
            {
                // When the navigation stack isn't restored, navigate to the first page
                // suppressing the initial entrance animation.
                shell.AppFrame.Navigate(typeof(Views.Page1), e.Arguments, new Windows.UI.Xaml.Media.Animation.SuppressNavigationTransitionInfo());
            }

            UserAccountHelper userAccount = new UserAccountHelper();
            userName = userAccount.GetUserNameFromLocker();

            // Ensure the current window is active
            Window.Current.Activate();
        }
Exemplo n.º 4
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            UserAccountHelper userAccout = new UserAccountHelper();

            userName = userAccout.GetUserNameFromLocker();
            if (userName == string.Empty)
            {
                await new MessageBox("你尚未登陆", MessageBox.NotifyType.CommonMessage).ShowAsync();
                this.Frame.Navigate(typeof(UserAccount));
                return;
            }

            this.lvInformationList.ItemsSource = myTaskList;
            myTaskList.DataLoading            += LstInformationList_DataLoading;
            myTaskList.DataLoaded += LstInformationList_DataLoaded;

            base.OnNavigatedTo(e);
        }
Exemplo n.º 5
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            UserAccountHelper userAccount = new UserAccountHelper();

            userName = userAccount.GetUserNameFromLocker();
            if (userName == string.Empty)
            {
                await new MessageBox("你尚未登陆", MessageBox.NotifyType.CommonMessage).ShowAsync();
                this.Frame.Navigate(typeof(UserAccount));
                return;
            }
            //当从ShowPicture返回时,如果执行了取消上传的操作,e.Parameter是有值的
            //那么就将这个StorageFile从App.list中移除
            if (e.Parameter is Dictionary <string, Image> )
            {
                Dictionary <string, Image>   data  = e.Parameter as Dictionary <string, Image>;
                KeyValuePair <string, Image> value = data.FirstOrDefault();
                if (value.Value != null)
                {
                    App.lstPicture.RemoveAt(Convert.ToInt32(value.Key));

                    #region 2016年2月14日19:34:27 此代码依靠页面缓存,实现:如果取消一图片上传,回到此界面时此图片预览消失,但是由于需要改动页面状态中某些图片的名字(Name属性),与系统默认的缓存机制发生冲突,会发生VS无法捕获的异常
                    //Image image = value.Value;
                    //string strRight = null;
                    ////string strLeft = "null";
                    //Object objRight = image.GetValue(RelativePanel.RightOfProperty);
                    //if (objRight != null)
                    //{
                    //    strRight = objRight.ToString();
                    //}
                    ////object objLeft= image.GetValue(RelativePanel.LeftOfProperty);
                    ////if(objLeft!=null)
                    ////{
                    ////    strLeft = objLeft.ToString();
                    ////}
                    ////this.tbMessage.Text = "AlignRight:" + strRight + "\nAlignLeft:" + strLeft;

                    //string name = image.Name;
                    //string imgNeedModifyName = "";
                    //foreach (var obj in root.Children)
                    //{
                    //    if(obj is Image)
                    //    {
                    //        object objRightName = obj.GetValue(RelativePanel.RightOfProperty);
                    //        if (objRightName != null)
                    //        {
                    //            string strRightName = objRightName.ToString();
                    //            if (strRightName == name)
                    //            {
                    //                Image imgRightNeedModify = obj as Image;
                    //                imgNeedModifyName=imgRightNeedModify.Name;
                    //                imgRightNeedModify.SetValue(RelativePanel.RightOfProperty, strRight);
                    //                break;
                    //                //isNeedModifyName = true;
                    //            }
                    //            //if(isNeedModifyName)
                    //            //{
                    //            //    Image imageNeedModifyName = obj as Image;
                    //            //    imageNeedModifyName.Name = (Convert.ToInt32(imageNeedModifyName.Name) - 1).ToString();
                    //            //}
                    //        }
                    //    }
                    //}

                    //bool isNeedModifyName = false;
                    //foreach (var obj in root.Children)
                    //{
                    //    if (obj is Image)
                    //    {
                    //        object objRightName = obj.GetValue(RelativePanel.RightOfProperty);
                    //        if (objRightName != null)
                    //        {
                    //            string strRightName = objRightName.ToString();
                    //            if (strRightName == name)
                    //            {
                    //                isNeedModifyName = true;
                    //            }
                    //            if (isNeedModifyName)
                    //            {
                    //                Image imageNeedModifyName = obj as Image;
                    //                imageNeedModifyName.Name = (Convert.ToInt32(imageNeedModifyName.Name) - 1).ToString();
                    //            }
                    //        }
                    //    }
                    //}
                    //numForImageName--;
                    //image.Visibility = Visibility.Collapsed;
                    #endregion

                    #region 废旧代码 2016年2月13日22:56:13
                    //int pictureCounter = App.list.Count;
                    //numForImageName = 0;
                    //if (pictureCounter > 0)
                    //{
                    //    int i = 0;
                    //    while (i < pictureCounter)
                    //    {
                    //        Image image = new Image();
                    //        BitmapImage bitmap = new BitmapImage();
                    //        using (var stream = await App.list[i].OpenReadAsync())
                    //        {
                    //            await bitmap.SetSourceAsync(stream);
                    //            image.Source = bitmap;
                    //            image.Name = numForImageName.ToString();
                    //            image.Height = 50;
                    //            image.Width = 50;
                    //            image.Margin = new Thickness(5);
                    //            image.Tapped += Image_Tapped;
                    //            if (imageName == "")
                    //            {
                    //                image.SetValue(RelativePanel.AlignLeftWithPanelProperty, true);
                    //                imageName = image.Name;
                    //            }
                    //            else
                    //            {
                    //                image.SetValue(RelativePanel.RightOfProperty, imageName);
                    //                imageName = image.Name;
                    //            }
                    //            root.Children.Add(image);
                    //            i++;
                    //            numForImageName++;
                    //        }
                    //    }
                    //    btnAdd.SetValue(RelativePanel.RightOfProperty, imageName);
                    //    //btnAdd.Visibility = Visibility.Collapsed;
                    //}
                    #endregion
                }
            }

            //注意:页面状态全部由我自己维护,所以以下代码使用App.list中储存的StorageFile
            //来恢复想要上传的图片预览和按钮
            numForImageName = 0;
            int pictureCounter = App.lstPicture.Count;
            if (pictureCounter > 0)
            {
                int i = 0;
                while (i < pictureCounter)
                {
                    Image       image  = new Image();
                    BitmapImage bitmap = new BitmapImage();
                    using (var stream = await App.lstPicture[i].OpenReadAsync())
                    {
                        await bitmap.SetSourceAsync(stream);

                        image.Source  = bitmap;
                        image.Name    = numForImageName.ToString();
                        image.Height  = 50;
                        image.Width   = 50;
                        image.Margin  = new Thickness(5);
                        image.Tapped += Image_Tapped;
                        if (imageName == "")
                        {
                            image.SetValue(RelativePanel.AlignLeftWithPanelProperty, true);
                            imageName = image.Name;
                        }
                        else
                        {
                            image.SetValue(RelativePanel.RightOfProperty, imageName);
                            imageName = image.Name;
                        }
                        root.Children.Add(image);
                        i++;
                        numForImageName++;
                    }
                }
                btnAddPicture.SetValue(RelativePanel.RightOfProperty, imageName);
            }

            base.OnNavigatedTo(e);
        }