Пример #1
0
        /// <summary>
        /// TileWideImageAndText01
        /// One wide image over one string of regular text wrapped over a maximum of two lines.
        /// http://msdn.microsoft.com/en-us/library/windows/apps/hh761491#TileWideImageAndText01
        ///
        /// TileSquarePeekImageAndText04
        /// Top: Square image, no text. Bottom: One string of regular text wrapped over a maximum of four lines.
        /// http://msdn.microsoft.com/en-us/library/windows/apps/hh761491#TileSquarePeekImageAndText04
        /// </summary>
        /// <param name="item"></param>
        private static void CreateNotePreviewTile(NoteDataCommon item)
        {
            var imgWideUrl = GetPreviewImage(item, true).ToString();
            ITileWide310x150ImageAndText01 tileContent = TileContentFactory.CreateTileWide310x150ImageAndText01();

            tileContent.TextCaptionWrap.Text = item.Title;
            tileContent.Image.Src            = imgWideUrl;
            tileContent.Image.Alt            = item.Title;

            var imgUrl = GetPreviewImage(item, false).ToString();
            ITileSquare150x150PeekImageAndText04 squareTileContent = TileContentFactory.CreateTileSquare150x150PeekImageAndText04();

            squareTileContent.Image.Src         = imgUrl;
            squareTileContent.Image.Alt         = item.Title;
            squareTileContent.TextBodyWrap.Text = item.Title;
            tileContent.Square150x150Content    = squareTileContent;

            tileContent.Branding = TileBranding.Logo;
            ScheduledTileNotification schduleTile = new ScheduledTileNotification(tileContent.GetXml(), DateTime.Now.AddSeconds(10));

            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(schduleTile);
        }
Пример #2
0
        /// <summary>
        /// TileWideSmallImageAndText04
        /// On the left, one small image; on the right, one header string of larger text on the first line over one string of regular text wrapped over a maximum of four lines.
        /// http://msdn.microsoft.com/en-us/library/windows/apps/hh761491#TileWideSmallImageAndText04
        ///
        /// TileSquarePeekImageAndText02
        /// Top: Square image, no text. Bottom: One header string in larger text on the first line, over one string of regular text wrapped over a maximum of three lines.
        /// http://msdn.microsoft.com/en-us/library/windows/apps/hh761491#TileSquarePeekImageAndText02
        /// </summary>
        /// <param name="item"></param>
        private static void CreateSeconderyWithImage(NoteDataCommon item)
        {
            var imgUrl     = GetPreviewImage(item, false).ToString();
            var imgWideUrl = GetPreviewImage(item, true).ToString();

            ITileWide310x150SmallImageAndText04 tileContent = TileContentFactory.CreateTileWide310x150SmallImageAndText04();

            tileContent.TextHeading.Text  = item.Title;
            tileContent.TextBodyWrap.Text = item.Description.Equals(Consts.DefaultDescriptionText) ? string.Empty : item.Description.ToShortString();
            tileContent.Image.Src         = imgWideUrl;
            tileContent.Image.Alt         = item.Title;

            ITileSquare150x150PeekImageAndText02 squareTileContent = TileContentFactory.CreateTileSquare150x150PeekImageAndText02();

            squareTileContent.Image.Src         = imgUrl;
            squareTileContent.Image.Alt         = item.Title;
            squareTileContent.TextHeading.Text  = item.Title;
            squareTileContent.TextBodyWrap.Text = item.Description.Equals(Consts.DefaultDescriptionText) ? string.Empty : item.Description.ToShortString();
            tileContent.Square150x150Content    = squareTileContent;

            tileContent.Branding = TileBranding.Name;
            TileUpdateManager.CreateTileUpdaterForSecondaryTile(item.UniqueId).Update(tileContent.CreateNotification());
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            if (pageState != null && pageState.ContainsKey("ID"))
            {
                navigationParameter = pageState["ID"];
            }

            Note = NotesDataSource.GetItem((string)navigationParameter) as NoteDataCommon;
            if (Note == null)
            {
                this.Frame.Navigate(typeof(GroupedItemsPage));
            }

            Note.PropertyChanged -= CurrentNotePropertyChanged;

            if (string.IsNullOrEmpty(Note.Title))
            {
                Note.Title = Consts.DefaultTitleText;
            }
            if (string.IsNullOrEmpty(Note.Description))
            {
                Note.Description = Consts.DefaultDescriptionText;
            }
            if (string.IsNullOrEmpty(Note.Address))
            {
                Note.Address = Consts.DefaultAddressText;
            }

            Note.PropertyChanged += CurrentNotePropertyChanged;

            this.DefaultViewModel["Item"] = Note;
            _printer = new PrinterManager(this, Note);

            // LAB #9 TILES
            //pageTitle.Focus(FocusState.Keyboard);
            DrawDefaultAppBar();
        }
Пример #4
0
        /// <summary>
        /// Open File Picker allowing the user to select images from his machine.
        /// After user select and close the FileOpenPicker we call DataManager.CopyImages with the choosen files and the Note the user is working on.
        /// </summary>
        /// <param name="forItem">Note item that will be linked to those images</param>
        /// <returns></returns>
        async public static Task OpenFilePicker(NoteDataCommon forItem)
        {
            if (Helpers.EnsureUnsnapped())
            {
                FileOpenPicker openPicker = new FileOpenPicker();
                openPicker.ViewMode = PickerViewMode.Thumbnail;
                openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                openPicker.FileTypeFilter.Add(".jpg");
                openPicker.FileTypeFilter.Add(".png");
                openPicker.FileTypeFilter.Add(".bmp");
                openPicker.FileTypeFilter.Add(".gif");
                openPicker.FileTypeFilter.Add(".tif");
                IReadOnlyList <StorageFile> files = await openPicker.PickMultipleFilesAsync();

                if (files.Count > 0)
                {
                    await DataManager.CopyImages(files, forItem);
                }
                else
                {
                    return;
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Showing Camera Capture UI
        /// After the user has approve the picture we create new image file under Images folder and add link to new image.
        /// </summary>
        /// <param name="forItem">Note item that will be linked to that image</param>
        /// <returns></returns>
        async public static Task ShowCamera(NoteDataCommon forItem)
        {
            try
            {
                CameraCaptureUI dialog      = new CameraCaptureUI();
                Size            aspectRatio = new Size(16, 9);
                dialog.PhotoSettings.CroppedAspectRatio = aspectRatio;
                StorageFile file = await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo);

                if (file != null)
                {
                    var storage = Windows.Storage.ApplicationData.Current.LocalFolder;
                    var folder  = await storage.CreateFolderAsync(FolderNames.Images.ToString(), Windows.Storage.CreationCollisionOption.OpenIfExists);

                    var copiedFile = await file.CopyAsync(folder, file.Name, NameCollisionOption.GenerateUniqueName);

                    forItem.Images.Add(string.Format("{0}/{1}", FolderNames.Images.ToString(), copiedFile.Name));
                }
            }
            catch
            {
                Helpers.ShowErrorMessageAsync("Show Camera", "Unexpected error launching camera or save camera image");
            }
        }
Пример #6
0
        /// <summary>
        /// TileWideText01
        /// One header string in larger text on the first line, four strings of regular text on the next four lines. Text does not wrap.
        /// http://msdn.microsoft.com/en-us/library/windows/apps/hh761491#TileWideText01
        ///
        /// TileSquareText01
        /// One header string in larger text on the first line; three strings of regular text on each of the next three lines. Text does not wrap.
        /// http://msdn.microsoft.com/en-us/library/windows/apps/hh761491#TileSquareText01
        /// </summary>
        /// <param name="item"></param>
        private static void CreateTextToDoTile(NoteDataCommon item)
        {
            ITileWide310x150Text01 tileContent = TileContentFactory.CreateTileWide310x150Text01();

            tileContent.RequireSquare150x150Content = true;
            tileContent.TextHeading.Text            = item.Title;
            var count = item.ToDo.Count >= 4 ? 4 : item.ToDo.Count;

            for (var i = 0; i < count; i++)
            {
                var value = item.ToDo[i].Done == true?string.Format("{0} {1}", "√", item.ToDo[i].Title) : item.ToDo[i].Title;

                switch (i)
                {
                case 0:
                    tileContent.TextBody1.Text = value;
                    break;

                case 1:
                    tileContent.TextBody2.Text = value;
                    break;

                case 2:
                    tileContent.TextBody3.Text = value;
                    break;

                case 3:
                    tileContent.TextBody4.Text = value;
                    break;
                }
            }

            ITileSquare150x150Text01 squareTileContent = TileContentFactory.CreateTileSquare150x150Text01();

            squareTileContent.TextHeading.Text = item.Title;
            count = item.ToDo.Count >= 3 ? 3 : item.ToDo.Count;
            for (var i = 0; i < count; i++)
            {
                var value = item.ToDo[i].Done == true?string.Format("{0} {1}", "√", item.ToDo[i].Title) : item.ToDo[i].Title;

                switch (i)
                {
                case 0:
                    squareTileContent.TextBody1.Text = value;
                    break;

                case 1:
                    squareTileContent.TextBody2.Text = value;
                    break;

                case 2:
                    squareTileContent.TextBody3.Text = value;
                    break;
                }
            }

            tileContent.Branding             = TileBranding.Name;
            tileContent.Square150x150Content = squareTileContent;

            TileUpdateManager.CreateTileUpdaterForSecondaryTile(item.UniqueId).Update(tileContent.CreateNotification());
        }