Example #1
0
        void RevisionListViewSelectionChanged(object sender, EventArgs e)
        {
            changesList.Items.Clear();
            if (revisionList.SelectedItems.Count == 0)
            {
                commentRichTextBox.Text    = "";
                commentRichTextBox.Enabled = false;
                return;
            }
            commentRichTextBox.Enabled = true;
            ListViewItem item       = revisionList.SelectedItems[0];
            LogMessage   logMessage = item.Tag as LogMessage;

            commentRichTextBox.Text = logMessage.Message;
            ChangedPathDictionary changes = logMessage.ChangedPaths;

            if (changes == null)
            {
                changesList.Items.Add("Loading...");
                if (!isLoadingChangedPaths)
                {
                    isLoadingChangedPaths = true;
                    loadChangedPathsItem  = item;
                    ThreadPool.QueueUserWorkItem(LoadChangedPaths);
                }
            }
            else
            {
                int pathWidth     = 70;
                int copyFromWidth = 70;
                using (Graphics g = CreateGraphics())
                {
                    foreach (DictionaryEntry entry in changes)
                    {
                        string path = (string)entry.Key;
                        path = path.Replace('\\', '/');
                        SizeF size = g.MeasureString(path, changesList.Font);
                        if (size.Width + 4 > pathWidth)
                        {
                            pathWidth = (int)size.Width + 4;
                        }
                        ChangedPath change   = (ChangedPath)entry.Value;
                        string      copyFrom = change.CopyFromPath;
                        if (copyFrom == null)
                        {
                            copyFrom = string.Empty;
                        }
                        else
                        {
                            copyFrom = copyFrom + " : r" + change.CopyFromRevision;
                            size     = g.MeasureString(copyFrom, changesList.Font);
                            if (size.Width + 4 > copyFromWidth)
                            {
                                copyFromWidth = (int)size.Width + 4;
                            }
                        }
                        ListViewItem newItem = new ListViewItem(new string[] {
                            SvnClient.GetActionString(change.Action),
                            path,
                            copyFrom
                        });
                        changesList.Items.Add(newItem);
                    }
                }
                changesList.Columns[1].Width = pathWidth;
                changesList.Columns[2].Width = copyFromWidth;
            }
        }