Beispiel #1
0
        private void InsertAtCorrectPosition(ListBox listBox, ChangeEntry entry)
        {
            var position = 0;

            while (position < listBox.Items.Count && ((ChangeEntry)listBox.Items[position]).Index < entry.Index)
            {
                position++;
            }

            listBox.Items.Insert(position, entry);
        }
Beispiel #2
0
        public void OpenChangeSet(string path)
        {
            if (!File.Exists(path))
            {
                MessageBox.Show(
                    $"Could not find the specified change set:\r\n  '{path}'",
                    "Error while opening change set",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            try
            {
                using (var textReader = File.OpenText(path))
                {
                    var xmlReader = new XmlSerializer(typeof(ChangeSet));
                    var changeSet = (ChangeSet)xmlReader.Deserialize(textReader);

                    PendingChangesListBox.Items.Clear();
                    IgnoredChangesListBox.Items.Clear();
                    CompletedListBox.Items.Clear();

                    var changes = loadOrderedCheckbox.Checked
              ? (IEnumerable <Change>)changeSet.MemberChanges.OrderBy(e => $"{e.Namespace}__{e.Name}")
              : changeSet.MemberChanges;

                    var index = 0;
                    foreach (var change in changes)
                    {
                        var changeEntry = new ChangeEntry(index++, change);
                        PendingChangesListBox.Items.Add(changeEntry);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Could not open change set:\r\n" + ex,
                    "Error while opening change set",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void OpenChangeSetFromDisk(object sender, EventArgs args)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                using (var textReader = File.OpenText(openFileDialog1.FileName))
                {
                    var xmlReader = new XmlSerializer(typeof(ChangeSet));
                    var changeSet = (ChangeSet)xmlReader.Deserialize(textReader);

                    PendingChangesListBox.Items.Clear();
                    IgnoredChangesListBox.Items.Clear();
                    CompletedListBox.Items.Clear();

                    var changes = loadOrderedCheckbox.Checked
              ? changeSet.MemberChanges.Where(e => e is MemberChange).OrderBy(e => $"{e.Namespace}__{e.Name}")
              : changeSet.MemberChanges.Where(e => e is MemberChange);

                    var index = 0;
                    foreach (var change in changes)
                    {
                        var changeEntry = new ChangeEntry(index++, change);
                        PendingChangesListBox.Items.Add(changeEntry);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Could not open change set:\r\n" + ex,
                    "Error while opening change set",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }