Example #1
0
 public void Initialize(Item item)
 {
     _view                  = new RatingWindow();
     _viewModel             = new RatingViewModel();
     _viewModel.RateCommand = new RelayCommand(ExecuteRateCommand);
     _viewModel.Item        = item;
     _view.DataContext      = _viewModel;
     _view.ShowDialog();
 }
        private void CheckUserOwnMotionRelation()
        {
            var relationRequest = new UserOwnMotionStoreRequest(MotionID);

            relationRequest.ProcessSuccessfully += (reply) =>
                                                   Dispatcher.BeginInvoke((Action) delegate
            {
                switch (reply.user_own_motion.rel)
                {
                case UserOwnMotionReply.Rel.OWNED:
                    var ratingWindow = new RatingWindow();
                    ratingWindow.SetInfo(Info.motion_id, Info.version_id);
                    if (ratingWindow.ShowDialog(StaticMainWindow.Window) == true)
                    {
                        var commentCount = (uint)ReviewStackPanel.Children.Count;
                        numberOfComment  = 0;
                        ReviewStackPanel.Children.Clear();
                        UpdateComment(0, commentCount + 1);
                    }
                    break;

                case UserOwnMotionReply.Rel.NOT_OWNED:
                    var title = (string)TryFindResource("MustOwnMotionText");
                    WPFMessageBox.Show(StaticMainWindow.Window, "", title, MessageBoxButton.OK,
                                       MessageBoxImage.Warning, MessageBoxResult.OK);

                    break;
                }
            });
            relationRequest.ProcessError += (reply, msg) =>
            {
                if (reply == null)
                {
                    Debug.Fail("reply is null");
                }
                else
                {
                    Debug.Fail(reply.type.ToString(), msg);
                }
                Dispatcher.BeginInvoke((Action) delegate
                {
                    var titleError = (string)Application.Current.TryFindResource("StoreConnectionkErrorText");
                    var msgError   = (string)Application.Current.TryFindResource("CheckNetworkText");
                    WPFMessageBox.Show(StaticMainWindow.Window, msgError, titleError, MessageBoxButton.OK,
                                       MessageBoxImage.Error, MessageBoxResult.OK);
                });
            };
            GlobalVariables.StoreWorker.AddRequest(relationRequest);
        }