Esempio n. 1
0
        public IEnumerable <IResult> ExportExcel()
        {
            // yield return new SequentialResult(this.SwapPlayersIfNecessary().GetEnumerator());

            var dialog = new SaveFileDialogResult()
            {
                Title           = string.Format("Export match \"{0}\" to Excel...", Match.Title()),
                Filter          = Format.Excel.DialogFilter,
                DefaultFileName = Match.DefaultFilename(),
            };

            yield return(dialog);

            var fileName = dialog.Result;

            var serialization = new SerializeMatchResult(Match, fileName, Format.Excel.Serializer);

            yield return(serialization
                         .Rescue()
                         .WithMessage("Error exporting the match", string.Format("Could not export the match to {0}.", FileName))
                         .Propagate()); // Reraise the error to abort the coroutine


            //yield return new SerializeMatchResult(Match, FileName, Format.Excel.Serializer)
            //    //.IsBusy("Exporting")
            //    .Rescue()
            //    .WithMessage("Error exporting the match", string.Format("Could not export the match to {0}.", FileName))
            //    .Propagate();
        }
Esempio n. 2
0
        public IEnumerable <IResult> DownloadMatch()
        {
            if (FileName == null || FileName == string.Empty)
            {
                var dialog = new SaveFileDialogResult()
                {
                    Title           = string.Format("Save match \"{0}\"...", Match.Title()),
                    Filter          = Format.XML.DialogFilter,
                    DefaultFileName = Match.DefaultFilename(),
                };
                yield return(dialog);

                FileName = dialog.Result;
            }

            var serialization = new SerializeMatchResult(Match, FileName, Format.XML.Serializer);

            yield return(serialization
                         .Rescue()
                         .WithMessage("Error saving the match", string.Format("Could not save the match to {0}.", FileName))
                         .Propagate()); // Reraise the error to abort the coroutine

            MatchModified = false;
            NotifyOfPropertyChange("MatchModified");
        }
Esempio n. 3
0
        public IEnumerable <IResult> SaveMatch()
        {
            if (FileName == null || FileName == string.Empty)
            {
                var dialog = new SaveFileDialogResult()
                {
                    Title           = string.Format("Save match \"{0}\"...", Match.Title()),
                    Filter          = Format.XML.DialogFilter,
                    DefaultFileName = Match.DefaultFilename(),
                };
                yield return(dialog);

                FileName    = dialog.Result;
                MatchSaveAs = true;
                NotifyOfPropertyChange("MatchSaveAs");
            }

            //Remove Dummy Rally from Scouter
            var  lastRally      = Match.Rallies.LastOrDefault();
            bool haveToAddAgain = false;

            if (Match.Rallies.Any())
            {
                if (lastRally.Winner == MatchPlayer.None)
                {
                    Match.Rallies.Remove(lastRally);
                    haveToAddAgain = true;
                }
            }
            var serialization = new SerializeMatchResult(Match, FileName, Format.XML.Serializer);

            yield return(serialization
                         .Rescue()
                         .WithMessage("Error saving the match", string.Format("Could not save the match to {0}.", FileName))
                         .Propagate()); // Reraise the error to abort the coroutine

            if (haveToAddAgain)
            {
                Execute.OnUIThread((System.Action)(() => Match.Rallies.Add(lastRally)));
            }
            MatchModified = false;
            NotifyOfPropertyChange("MatchModified");
        }