public async void Execute(object parameter)
        {
            EmoticonItem item = (EmoticonItem)parameter;

            await App.ViewModel.Favorite.Add(item.Text, true);

            App.ViewModel.NoteMap.Add(item.Text.GetHashCode(), item.Note);
            App.Settings.Save();

            App.ViewModel.FavoriteList.Rebuild();

            MainPage page = ((MainPage)((PhoneApplicationFrame)App.RootFrame).Content);

            page.pivot.SelectedIndex = 1;
        }
        public void Execute(object parameter)
        {
            EmoticonItem item = (EmoticonItem)parameter;
            string       hash = item.GetHashCode().ToString();

            Grid grid = new Grid()
            {
                Width      = 159,
                Height     = 159,
                Background = (SolidColorBrush)App.Current.Resources["PhoneAccentBrush"]
            };
            TextBlock textBlock = new TextBlock()
            {
                Foreground          = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)),
                TextWrapping        = TextWrapping.NoWrap,
                Text                = item.Text,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                FontSize            = 50
            };

            grid.Children.Add(textBlock);

            grid.Arrange(new Rect(0, 0, grid.Width, grid.Height));
            grid.Measure(new Size(grid.Width, grid.Height));

            WriteableBitmap writeableBitmap = new WriteableBitmap(grid, null);

            writeableBitmap.Invalidate();
            string smallImage = string.Format("/Shared/ShellContent/small.{0}.jpg", hash);

            using (IsolatedStorageFileStream file =
                       IsolatedStorageFile.GetUserStoreForApplication().CreateFile(smallImage))
                writeableBitmap.SaveJpeg(file, (int)grid.Width, (int)grid.Height, 0, 95);

            grid.Width         = 336;
            grid.Height        = 336;
            textBlock.FontSize = 60;
            grid.Arrange(new Rect(0, 0, grid.Width, grid.Height));
            grid.Measure(new Size(grid.Width, grid.Height));
            writeableBitmap = new WriteableBitmap(grid, null);
            writeableBitmap.Invalidate();
            string middleImage = string.Format("/Shared/ShellContent/middle.{0}.jpg", hash);

            using (IsolatedStorageFileStream file =
                       IsolatedStorageFile.GetUserStoreForApplication().CreateFile(middleImage))
                writeableBitmap.SaveJpeg(file, (int)grid.Width, (int)grid.Height, 0, 95);

            grid.Width         = 691;
            textBlock.FontSize = 70;
            grid.Arrange(new Rect(0, 0, 691, 336));
            grid.Measure(new Size(691, 336));
            writeableBitmap = new WriteableBitmap(grid, null);
            writeableBitmap.Invalidate();
            string wideImage = string.Format("/Shared/ShellContent/wide.{0}.jpg", hash);

            using (IsolatedStorageFileStream file =
                       IsolatedStorageFile.GetUserStoreForApplication().CreateFile(wideImage))
                writeableBitmap.SaveJpeg(file, (int)grid.Width, (int)grid.Height, 0, 95);

#if WINDOWS_PHONE_71
            ShellTile.Create(new Uri(string.Format("/MainPage.xaml?copy={0}", item.Text), UriKind.Relative), new StandardTileData()
            {
                Title           = item.Note != "" ? item.Note : item.Text,
                BackgroundImage = new Uri("isostore:" + smallImage, UriKind.Absolute)
            });
#else
            ShellTile.Create(new Uri(string.Format("/MainPage.xaml?copy={0}", item.Text), UriKind.Relative), new FlipTileData()
            {
                Title = item.Note != "" ? item.Note : item.Text,
                SmallBackgroundImage = new Uri("isostore:" + smallImage, UriKind.Absolute),
                BackgroundImage      = new Uri("isostore:" + middleImage, UriKind.Absolute),
                WideBackgroundImage  = new Uri("isostore:" + wideImage, UriKind.Absolute)
            }, true);
#endif
        }
        public static void EditPrompt(EmoticonItem item = null)
        {
            item = item ?? new EmoticonItem(null, null);

            StackPanel   panel   = new StackPanel();
            PhoneTextBox TextBox = new PhoneTextBox();
            PhoneTextBox NoteBox = new PhoneTextBox();

            if (item.Text != null)
            {
                TextBox.Text = item.Text;
                NoteBox.Text = item.Note;
            }
            TextBox.Hint = AppResources.Emoticon;
            NoteBox.Hint = AppResources.Note;
            panel.Children.Add(TextBox);
            panel.Children.Add(NoteBox);

            CustomMessageBox messageBox = new CustomMessageBox()
            {
                Message              = AppResources.AddEmoticon,
                Content              = panel,
                LeftButtonContent    = AppResources.OK,
                IsLeftButtonEnabled  = true,
                RightButtonContent   = AppResources.Cancel,
                IsRightButtonEnabled = true
            };

            TextBox.TextChanged += (s, ev) =>
            {
                messageBox.IsLeftButtonEnabled = !string.IsNullOrWhiteSpace(TextBox.Text);
            };
            messageBox.Dismissed += (s, ev) =>
            {
                if (ev.Result == CustomMessageBoxResult.LeftButton)
                {
                    AppCollection <string>   favorite = App.ViewModel.Favorite;
                    Dictionary <int, string> noteMap  = App.ViewModel.NoteMap;

                    if (favorite.Contains(item.Text))
                    {
                        favorite.Remove(item.Text);
                        noteMap.Remove(item.Text.GetHashCode());
                    }
                    if (favorite.Contains(TextBox.Text))
                    {
                        favorite.Remove(TextBox.Text);
                    }
                    favorite.Add(TextBox.Text);

                    if (noteMap.ContainsKey(TextBox.Text.GetHashCode()))
                    {
                        noteMap[TextBox.Text.GetHashCode()] = NoteBox.Text;
                    }
                    else
                    {
                        noteMap.Add(TextBox.Text.GetHashCode(), NoteBox.Text);
                    }

                    App.Settings.Save();
                    App.ViewModel.FavoriteList.Rebuild();
                }
            };
            messageBox.Show();
            TextBox.Focus();
        }