Пример #1
0
        private void OnClick_AddNewProject(object sender, RoutedEventArgs e)
        {
            bool isTrial = (Application.Current as App).IsTrial;
            if(!isTrial || (isTrial && this.ProjectItems.Items.Count < 1))
            {
                NavigationService.Navigate(new Uri("/Views/AddNewProject.xaml", UriKind.Relative));
            }
            else
            {
                Coding4Fun.Phone.Controls.MessagePrompt messagePrompt = new Coding4Fun.Phone.Controls.MessagePrompt();
                messagePrompt.IsCancelVisible = true;
                messagePrompt.Body = new TextBlock
                {
                    Text = "Thanks for trying uknit! This trial lets you use only 1 project. Would you like to buy the app to add unlimited projects?",
                    FontSize = 30.0,
                    TextWrapping = TextWrapping.Wrap
                };

                messagePrompt.Completed += (str, res) =>
                {
                    if(res.PopUpResult == Coding4Fun.Phone.Controls.PopUpResult.Ok)
                    {
                        this.MarketPlaceDetail.Show();
                    }
                };

                messagePrompt.Show();

            }
        }
Пример #2
0
        private void OnContextMenuClick_DeleteProject(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;
            string projectName = menuItem.Tag.ToString();

            Coding4Fun.Phone.Controls.MessagePrompt messagePrompt = new Coding4Fun.Phone.Controls.MessagePrompt();
            messagePrompt.IsCancelVisible = true;
            messagePrompt.Body = new TextBlock
            {
                Text = String.Format("You are about to delete \'{0}\'. Are you sure you want to do this?", projectName),
                FontSize = 30.0,
                TextWrapping = TextWrapping.Wrap
            };

            messagePrompt.Completed += (str, res) =>
                {
                    if(res.PopUpResult == Coding4Fun.Phone.Controls.PopUpResult.Ok)
                    {
                        DeleteProject(projectName);
                        MessageBox.Show(String.Format("Deleted \'{0}\'", projectName));
                    }
                };

            messagePrompt.Show();
        }
Пример #3
0
        private void OnClick_ResetCounter(object sender, EventArgs e)
        {
            Coding4Fun.Phone.Controls.MessagePrompt messagePrompt = new Coding4Fun.Phone.Controls.MessagePrompt();
            messagePrompt.IsCancelVisible = true;
            messagePrompt.Body = new TextBlock
            {
                Text = "Yikes! Do you seriously want to reset this counter to 0?",
                FontSize = 30.0,
                TextWrapping = TextWrapping.Wrap
            };

            messagePrompt.Completed += (str, res) =>
            {
                if(res.PopUpResult == Coding4Fun.Phone.Controls.PopUpResult.Ok)
                {
                    this.ClearCounterValues();
                    MessageBox.Show("Counter has been reset.");
                }
            };

            messagePrompt.Show();
        }
Пример #4
0
        private void OnClick_PinToStart(object sender, EventArgs e)
        {
            if(!this.Project.IsPinnedToStart)
            {
                WriteableBitmap tileBitmap = this.ProjectVM.CreateRowCounterBitmap(this.Project);

                this.Project.IsPinnedToStart = true;
                this.AppSettings.ModifyKnittingProjectByName(this.ProjectName, this.Project);

                Uri projectPage = new Uri(String.Format("/Views/RowCounter.xaml?ProjectName={0}&SecondaryTile=1", this.ProjectName), UriKind.Relative);
                this.NewPin = true;
                this.AppSettings.CreateTile(tileBitmap, this.ProjectName, projectPage);
            }
            else
            {
                Coding4Fun.Phone.Controls.MessagePrompt messagePrompt = new Coding4Fun.Phone.Controls.MessagePrompt();
                messagePrompt.IsCancelVisible = true;
                messagePrompt.Body = new TextBlock
                {
                    Text = "Are you sure you want to unpin this tile?",
                    FontSize = 30.0,
                    TextWrapping = TextWrapping.Wrap
                };

                messagePrompt.Completed += (str, res) =>
                {
                    if(res.PopUpResult == Coding4Fun.Phone.Controls.PopUpResult.Ok)
                    {
                        Dispatcher.BeginInvoke(() =>
                        {
                            this.Project.IsPinnedToStart = false;
                            this.AppSettings.ModifyKnittingProjectByName(this.ProjectName, this.Project);
                            this.AppSettings.DeleteTile(this.ProjectName);

                            ApplicationBarIconButton pinButton = (ApplicationBarIconButton)(this.ApplicationBar.Buttons[1]);
                            pinButton.Text = "pin to start";
                            pinButton.IconUri = new Uri("Content/Images/pushpin.png", UriKind.Relative);
                        });
                    }
                };

                messagePrompt.Show();
            }
        }
Пример #5
0
        private void OnClick_Restore(object sender, RoutedEventArgs e)
        {
            Coding4Fun.Phone.Controls.MessagePrompt messagePrompt = new Coding4Fun.Phone.Controls.MessagePrompt();
            messagePrompt.IsCancelVisible = true;
            messagePrompt.Body = new TextBlock
            {
                Text = "Whoa, you're about to restore uknit to it's default settings (ruler calibration, etc). You really want I should do this?",
                FontSize = 30.0,
                TextWrapping = TextWrapping.Wrap
            };

            messagePrompt.Completed += (str, res) =>
            {
                if(res.PopUpResult == Coding4Fun.Phone.Controls.PopUpResult.Ok)
                {
                    this.AppSettings.RestoreDefaults();
                    MessageBox.Show("Defaults restored.");
                }
            };

            messagePrompt.Show();
        }
Пример #6
0
        private void AskForCalibration()
        {
            Coding4Fun.Phone.Controls.MessagePrompt messagePrompt = new Coding4Fun.Phone.Controls.MessagePrompt();
            messagePrompt.IsCancelVisible = true;
            messagePrompt.Body = new TextBlock
            {
                Text = "I noticed that you haven't calibrated the ruler yet. This is important to make sure the ruler is somewhat accurate. Afterall, you don't want to make a baby hat that fits Andre the Giant. Would you like to calibrate now?",
                FontSize = 20.0,
                TextWrapping = TextWrapping.Wrap
            };

            messagePrompt.Completed += (str, res) =>
            {
                if(res.PopUpResult == Coding4Fun.Phone.Controls.PopUpResult.Ok)
                {
                    Dispatcher.BeginInvoke(() =>
                    {
                        this.RulerSettingsSwitch.IsChecked = true;
                        this.CalibrationSwitch.IsChecked = true;
                        this.AppSettings.SetRulerCalibrated();
                    });
                }
            };

            messagePrompt.Show();
        }
        void Channel_ShellToastNotificationReceived(object sender, NotificationEventArgs e)
        {
            System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
            {

                var msg = new Coding4Fun.Phone.Controls.MessagePrompt();
                var stack = new StackPanel();
                var titleTextBlock = new TextBlock() { Text = "Show push details?", FontSize = 24 };
                stack.Children.Add(titleTextBlock);
                if (e.Collection.ContainsKey("wp:Text1"))
                {
                    var pushTitleTextBlock = new TextBlock() { Text = e.Collection["wp:Text1"], FontSize = 20 };
                    stack.Children.Add(pushTitleTextBlock);
                }
                if (e.Collection.ContainsKey("wp:Text2"))
                {
                    var pushBodyTextBlock = new TextBlock() { Text = e.Collection["wp:Text2"], FontSize = 18, TextWrapping = TextWrapping.Wrap };
                    stack.Children.Add(pushBodyTextBlock);
                }

                if (e.Collection.ContainsKey("wp:Param"))
                {
                    ParsePushContent(e.Collection["wp:Param"]);
                }

                msg.Body = stack;
                msg.IsCancelVisible = true;
                msg.Completed += new EventHandler<Coding4Fun.Phone.Controls.PopUpEventArgs<string, Coding4Fun.Phone.Controls.PopUpResult>>(msg_Completed);
                msg.Show();
            }
            );
        }