root.node
[tfs.git] / tools / tf / FileView.cs
blob802b7296f57e022463e69b27f25b9831778a63f7
1 using System;
2 using System.IO;
3 using System.Collections;
4 using System.Collections.Generic;
5 using System.Net;
6 using System.Text;
7 using Gtk;
8 using Pango;
9 using Microsoft.TeamFoundation.Client;
10 using Microsoft.TeamFoundation.VersionControl.Common;
11 using Microsoft.TeamFoundation.VersionControl.Client;
13 public class FileView : Gtk.ScrolledWindow, IExploreViewChild
15 private Gtk.TextBuffer viewBuffer;
16 private Driver driver;
18 public FileView(Driver driver)
20 this.driver = driver;
21 Gtk.TextView view = new Gtk.TextView();
22 view.CursorVisible = false;
23 view.Editable = false;
24 view.ModifyFont(Pango.FontDescription.FromString("Vera Sans Mono 16"));
26 viewBuffer = view.Buffer;
27 Add(view);
30 public void UpdatePath(string path)
32 if (String.IsNullOrEmpty(path)) return;
33 Microsoft.TeamFoundation.VersionControl.Client.Item item = driver.VersionControlServer.GetItem(path, VersionSpec.Latest, 0, true);
35 string tname = System.IO.Path.GetTempFileName();
36 item.DownloadFile(tname);
38 using (StreamReader sr = new StreamReader(tname))
40 viewBuffer.Text = sr.ReadToEnd();
43 File.Delete(tname);