private void toolStripMenuItemMergeWizard_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                var matches = new List <Session>();

                var originalTilesHash = selected.GenerateHash();
                foreach (var sessionObject in listBoxSessions.Items)
                {
                    var session = sessionObject as Session;
                    if (session == null || session == selected)
                    {
                        continue;
                    }

                    var currentTilesHash = session.GenerateHash();
                    if (currentTilesHash.Keys.Any(originalTilesHash.ContainsKey))
                    {
                        matches.Add(session);
                    }
                }

                if (matches.Count == 0)
                {
                    MessageBox.Show(@"No matches found", @"Merge Finished", MessageBoxButtons.OK);
                    return;
                }

                var mergeWizard = new MergeWizard.MergeWizard(selected, matches);
                if (mergeWizard.StartWizard() == DialogResult.OK)
                {
                    if (MessageBox.Show(@"The merge process was sucessfull.
Should the merged sessions be removed?",
                                        @"Merge Finished", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        listBoxSessions.Items.Remove(selected);
                        foreach (var mergeSession in mergeWizard.MatchingSessions)
                        {
                            if (!mergeSession.Skipped)
                            {
                                listBoxSessions.Items.Remove(mergeSession.Session);
                            }
                        }
                    }

                    selected = mergeWizard.FinalSession;
                    listBoxSessions.Items.Add(selected);
                    listBoxSessions.SelectedItem = selected;
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Exemple #2
0
        private void toolStripMenuItemMergeWizard_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                var matches = new List<Session>();

                var originalTilesHash = selected.GenerateHash();
                foreach (var sessionObject in listBoxSessions.Items)
                {
                    var session = sessionObject as Session;
                    if (session == null || session == selected)
                        continue;

                    var currentTilesHash = session.GenerateHash();
                    if (currentTilesHash.Keys.Any(originalTilesHash.ContainsKey))
                        matches.Add(session);
                }

                if (matches.Count == 0)
                {
                    MessageBox.Show(@"No matches found", @"Merge Finished", MessageBoxButtons.OK);
                    return;
                }

                var mergeWizard = new MergeWizard.MergeWizard(selected, matches);
                if (mergeWizard.StartWizard() == DialogResult.OK)
                {
                    if (MessageBox.Show(@"The merge process was sucessfull.
Should the merged sessions be removed?",
                                        @"Merge Finished", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        listBoxSessions.Items.Remove(selected);
                        foreach (var mergeSession in mergeWizard.MatchingSessions)
                            if (!mergeSession.Skipped) listBoxSessions.Items.Remove(mergeSession.Session);
                    }

                    selected = mergeWizard.FinalSession;
                    listBoxSessions.Items.Add(selected);
                    listBoxSessions.SelectedItem = selected;
                }
            }
            finally 
            {
                Cursor.Current = Cursors.Default;
            }
        }