Example #1
0
        /// <summary>
        /// Discards selected changes from the selected project.
        /// </summary>
        public void Discard(string[] files)
        {
            if (CheckProjects())
            {
                return;
            }

            ClientUI.ShowProgress("Discarding...");

            try
            {
                var diffs  = CurrentProject.BuildDiff();
                var diff   = diffs.Where(file => files.Any(x => x == file.FileName)).ToList();
                var commit = Commit.FromDiff(diff.ToArray());

                CurrentProject.Discard(commit.Files,
                                       x =>
                {
                    ClientUI.SetProgress("Discarding " + diff.Count + " change(s). " + x);
                });
            }
            catch (Exception ex)
            {
                ClientUI.ShowMessage("Error when discarding, no changes were discared, message: <br>" + ex.Message, true);
            }

            ClientUI.HideProgress();

            ClientUI.ShowProgress("Discarding done! Loading...");
            CurrentProject.Refresh(delegate
            {
                UpdateView();
                ClientUI.HideProgress();
            });
        }