public MainWindow(string profilePath) : base(Gtk.WindowType.Toplevel)
    {
        Build();
        notebook1.Page = 1;

        Config = GuiCompare.Config.GetConfig();

        //
        // Configure the GUI
        //
        info_manager = new InfoManager(this, profilePath);

        treeStore = new Gtk.TreeStore(typeof(string),                          // Name
                                      typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf),  // TypeIcon, StatusIcon
                                      typeof(Gdk.Pixbuf), typeof(string),      // MissingIcon, MissingText
                                      typeof(Gdk.Pixbuf), typeof(string),      // ExtraIcon, ExtraText
                                      typeof(Gdk.Pixbuf), typeof(string),      // ErrorIcon, ErrorText
                                      typeof(Gdk.Pixbuf), typeof(string),      // TodoIcon, TodoText
                                      typeof(Gdk.Pixbuf), typeof(string),      // NiexIcon, NiexText
                                      typeof(ComparisonNode), typeof(string)); // Node, Foreground

        treeFilter             = new Gtk.TreeModelFilter(treeStore, null);
        treeFilter.VisibleFunc = FilterTree;
        tree.Model             = treeFilter;

        // Create a column for the node name
        Gtk.TreeViewColumn nameColumn = new Gtk.TreeViewColumn();
        nameColumn.Title     = "Name";
        nameColumn.Resizable = true;

        Gtk.CellRendererText   nameCell   = new Gtk.CellRendererText();
        Gtk.CellRendererPixbuf typeCell   = new Gtk.CellRendererPixbuf();
        Gtk.CellRendererPixbuf statusCell = new Gtk.CellRendererPixbuf();

        nameColumn.PackStart(statusCell, false);
        nameColumn.PackStart(typeCell, false);
        nameColumn.PackStart(nameCell, true);

        tree.AppendColumn(nameColumn);

        nameColumn.AddAttribute(nameCell, "text", (int)TreeCol.Name);
        nameColumn.AddAttribute(nameCell, "foreground", (int)TreeCol.Foreground);
        nameColumn.AddAttribute(typeCell, "pixbuf", (int)TreeCol.TypeIcon);
        nameColumn.AddAttribute(statusCell, "pixbuf", (int)TreeCol.StatusIcon);

        // Create a column for the status counts
        Gtk.TreeViewColumn countsColumn = new Gtk.TreeViewColumn();
        countsColumn.Title     = "Counts";
        countsColumn.Resizable = true;

        Gtk.CellRendererPixbuf missingPixbufCell = new Gtk.CellRendererPixbuf();
        Gtk.CellRendererText   missingTextCell   = new Gtk.CellRendererText();
        Gtk.CellRendererPixbuf extraPixbufCell   = new Gtk.CellRendererPixbuf();
        Gtk.CellRendererText   extraTextCell     = new Gtk.CellRendererText();
        Gtk.CellRendererPixbuf errorPixbufCell   = new Gtk.CellRendererPixbuf();
        Gtk.CellRendererText   errorTextCell     = new Gtk.CellRendererText();
        Gtk.CellRendererPixbuf todoPixbufCell    = new Gtk.CellRendererPixbuf();
        Gtk.CellRendererText   todoTextCell      = new Gtk.CellRendererText();
        Gtk.CellRendererPixbuf niexPixbufCell    = new Gtk.CellRendererPixbuf();
        Gtk.CellRendererText   niexTextCell      = new Gtk.CellRendererText();

        countsColumn.PackStart(missingPixbufCell, false);
        countsColumn.PackStart(missingTextCell, false);
        countsColumn.PackStart(extraPixbufCell, false);
        countsColumn.PackStart(extraTextCell, false);
        countsColumn.PackStart(errorPixbufCell, false);
        countsColumn.PackStart(errorTextCell, false);
        countsColumn.PackStart(todoPixbufCell, false);
        countsColumn.PackStart(todoTextCell, false);
        countsColumn.PackStart(niexPixbufCell, false);
        countsColumn.PackStart(niexTextCell, false);

        tree.AppendColumn(countsColumn);

        countsColumn.AddAttribute(missingPixbufCell, "pixbuf", (int)TreeCol.MissingIcon);
        countsColumn.AddAttribute(missingTextCell, "text", (int)TreeCol.MissingText);
        countsColumn.AddAttribute(extraPixbufCell, "pixbuf", (int)TreeCol.ExtraIcon);
        countsColumn.AddAttribute(extraTextCell, "text", (int)TreeCol.ExtraText);
        countsColumn.AddAttribute(errorPixbufCell, "pixbuf", (int)TreeCol.ErrorIcon);
        countsColumn.AddAttribute(errorTextCell, "text", (int)TreeCol.ErrorText);
        countsColumn.AddAttribute(todoPixbufCell, "pixbuf", (int)TreeCol.TodoIcon);
        countsColumn.AddAttribute(todoTextCell, "text", (int)TreeCol.TodoText);
        countsColumn.AddAttribute(niexPixbufCell, "pixbuf", (int)TreeCol.NiexIcon);
        countsColumn.AddAttribute(niexTextCell, "text", (int)TreeCol.NiexText);

        CreateTags(AdditionalInfoText.Buffer);

        tree.Selection.Changed += delegate(object sender, EventArgs e) {
            Gtk.TreeIter iter;
            if (tree.Selection.GetSelected(out iter))
            {
                List <string>  msgs     = null;
                ComparisonNode n        = tree.Model.GetValue(iter, (int)TreeCol.Node) as ComparisonNode;
                TextBuffer     buffer   = AdditionalInfoText.Buffer;
                bool           showInfo = false;
                TextIter       textIter = TextIter.Zero;

                buffer.Clear();

                if (!String.IsNullOrEmpty(n.ExtraInfo))
                {
                    showInfo = true;
                    textIter = buffer.StartIter;

                    buffer.InsertWithTagsByName(ref textIter, "Additional information:\n", "bold");
                    InsertWithMarkup(buffer, ref textIter, "\t" + n.ExtraInfo + "\n");
                }

                if (n != null)
                {
                    msgs = n.Messages;
                }
                if (msgs != null && msgs.Count > 0)
                {
                    if (!showInfo)
                    {
                        showInfo = true;
                        textIter = buffer.StartIter;
                    }

                    buffer.InsertWithTagsByName(ref textIter, "Errors:\n", "red", "bold");

                    for (int i = 0; i < msgs.Count; i++)
                    {
                        buffer.InsertWithTagsByName(ref textIter, String.Format("\t{0}: ", i + 1), "bold");
                        InsertWithMarkup(buffer, ref textIter, msgs [i]);
                    }
                }

                if (n != null)
                {
                    msgs = n.Todos;
                }
                if (msgs != null && msgs.Count > 0)
                {
                    if (!showInfo)
                    {
                        showInfo = true;
                        textIter = buffer.StartIter;
                    }

                    buffer.InsertWithTagsByName(ref textIter, "TODO:\n", "green", "bold");
                    for (int i = 0; i < msgs.Count; i++)
                    {
                        buffer.InsertWithTagsByName(ref textIter, String.Format("\t{0}: ", i + 1), "bold");
                        buffer.Insert(ref textIter, msgs [i]);
                    }
                }

                if (showInfo)
                {
                    AdditionalInfoWindow.Visible = true;
                }
                else
                {
                    AdditionalInfoWindow.Visible = false;
                }

                string msdnUrl = n != null ? n.MSDNUrl : null;
                if (!String.IsNullOrEmpty(msdnUrl))
                {
                    Status = GetMSDNVersionedUrl(msdnUrl);
                }
                else
                {
                    Status = String.Empty;
                }
            }
        };

        tree.RowActivated += delegate(object sender, RowActivatedArgs args) {
            Gtk.TreeIter iter;
            if (!tree.Model.GetIter(out iter, args.Path))
            {
                return;
            }

            ComparisonNode n = tree.Model.GetValue(iter, (int)TreeCol.Node) as ComparisonNode;
            if (n == null || String.IsNullOrEmpty(n.MSDNUrl))
            {
                return;
            }

            System.Diagnostics.Process browser = new System.Diagnostics.Process();
            browser.StartInfo.FileName        = GetMSDNVersionedUrl(n.MSDNUrl);
            browser.StartInfo.UseShellExecute = true;
            browser.Start();
        };

        //
        // Load configuration
        //
        ShowMissing.Active = Config.ShowMissing;
        ShowErrors.Active  = Config.ShowErrors;
        ShowExtra.Active   = Config.ShowExtra;
        ShowPresent.Active = Config.ShowPresent;
        ShowTodo.Active    = Config.ShowTodo;

        //
        // Legend
        //
        legendImageOK.Pixbuf      = okPixbuf;
        legendImageError.Pixbuf   = errorPixbuf;
        legendImageNIEX.Pixbuf    = niexPixbuf;
        legendImageMissing.Pixbuf = missingPixbuf;
        legendImageTODO.Pixbuf    = todoPixbuf;
        legendImageExtra.Pixbuf   = extraPixbuf;
    }
示例#2
0
	public MainWindow (string profilePath) : base(Gtk.WindowType.Toplevel)
	{
		Build ();
		notebook1.Page = 1;

		Config = GuiCompare.Config.GetConfig ();
		
		//
		// Configure the GUI
		//
		info_manager = new InfoManager (this, profilePath);
		
		treeStore = new Gtk.TreeStore (typeof (string), // Name
		                               typeof (Gdk.Pixbuf), typeof (Gdk.Pixbuf), // TypeIcon, StatusIcon
		                               typeof (Gdk.Pixbuf), typeof (string), // MissingIcon, MissingText
		                               typeof (Gdk.Pixbuf), typeof (string), // ExtraIcon, ExtraText
		                               typeof (Gdk.Pixbuf), typeof (string), // ErrorIcon, ErrorText
		                               typeof (Gdk.Pixbuf), typeof (string), // TodoIcon, TodoText
		                               typeof (Gdk.Pixbuf), typeof (string), // NiexIcon, NiexText
		                               typeof (ComparisonNode), typeof (string)); // Node, Foreground
		
		treeFilter = new Gtk.TreeModelFilter (treeStore, null);
		treeFilter.VisibleFunc = FilterTree;
		tree.Model = treeFilter;
		
		// Create a column for the node name
		Gtk.TreeViewColumn nameColumn = new Gtk.TreeViewColumn ();
		nameColumn.Title = "Name";
		nameColumn.Resizable = true;
		
		Gtk.CellRendererText nameCell = new Gtk.CellRendererText ();
		Gtk.CellRendererPixbuf typeCell = new Gtk.CellRendererPixbuf ();
		Gtk.CellRendererPixbuf statusCell = new Gtk.CellRendererPixbuf ();
		
		nameColumn.PackStart (statusCell, false);
		nameColumn.PackStart (typeCell, false);
		nameColumn.PackStart (nameCell, true);
		
		tree.AppendColumn (nameColumn);
		
		nameColumn.AddAttribute (nameCell, "text", (int)TreeCol.Name);
		nameColumn.AddAttribute (nameCell, "foreground", (int)TreeCol.Foreground);
		nameColumn.AddAttribute (typeCell, "pixbuf", (int)TreeCol.TypeIcon);
		nameColumn.AddAttribute (statusCell, "pixbuf", (int)TreeCol.StatusIcon);
		
		// Create a column for the status counts
		Gtk.TreeViewColumn countsColumn = new Gtk.TreeViewColumn ();
		countsColumn.Title = "Counts";
		countsColumn.Resizable = true;
		
		Gtk.CellRendererPixbuf missingPixbufCell = new Gtk.CellRendererPixbuf ();
		Gtk.CellRendererText missingTextCell = new Gtk.CellRendererText ();
		Gtk.CellRendererPixbuf extraPixbufCell = new Gtk.CellRendererPixbuf ();
		Gtk.CellRendererText extraTextCell = new Gtk.CellRendererText ();
		Gtk.CellRendererPixbuf errorPixbufCell = new Gtk.CellRendererPixbuf ();
		Gtk.CellRendererText errorTextCell = new Gtk.CellRendererText ();
		Gtk.CellRendererPixbuf todoPixbufCell = new Gtk.CellRendererPixbuf ();
		Gtk.CellRendererText todoTextCell = new Gtk.CellRendererText ();
		Gtk.CellRendererPixbuf niexPixbufCell = new Gtk.CellRendererPixbuf ();
		Gtk.CellRendererText niexTextCell = new Gtk.CellRendererText ();
		
		countsColumn.PackStart (missingPixbufCell, false);
		countsColumn.PackStart (missingTextCell, false);
		countsColumn.PackStart (extraPixbufCell, false);
		countsColumn.PackStart (extraTextCell, false);
		countsColumn.PackStart (errorPixbufCell, false);
		countsColumn.PackStart (errorTextCell, false);
		countsColumn.PackStart (todoPixbufCell, false);
		countsColumn.PackStart (todoTextCell, false);
		countsColumn.PackStart (niexPixbufCell, false);
		countsColumn.PackStart (niexTextCell, false);
		
		tree.AppendColumn (countsColumn);

		countsColumn.AddAttribute (missingPixbufCell, "pixbuf", (int)TreeCol.MissingIcon);
		countsColumn.AddAttribute (missingTextCell, "text", (int)TreeCol.MissingText);
		countsColumn.AddAttribute (extraPixbufCell, "pixbuf", (int)TreeCol.ExtraIcon);
		countsColumn.AddAttribute (extraTextCell, "text", (int)TreeCol.ExtraText);
		countsColumn.AddAttribute (errorPixbufCell, "pixbuf", (int)TreeCol.ErrorIcon);
		countsColumn.AddAttribute (errorTextCell, "text", (int)TreeCol.ErrorText);
		countsColumn.AddAttribute (todoPixbufCell, "pixbuf", (int)TreeCol.TodoIcon);
		countsColumn.AddAttribute (todoTextCell, "text", (int)TreeCol.TodoText);
		countsColumn.AddAttribute (niexPixbufCell, "pixbuf", (int)TreeCol.NiexIcon);
		countsColumn.AddAttribute (niexTextCell, "text", (int)TreeCol.NiexText);

		CreateTags (AdditionalInfoText.Buffer);

		tree.Selection.Changed += delegate (object sender, EventArgs e) {
			Gtk.TreeIter iter;
			if (tree.Selection.GetSelected (out iter)) {
				List<string> msgs = null;
				ComparisonNode n = tree.Model.GetValue (iter, (int)TreeCol.Node) as ComparisonNode;
				TextBuffer buffer = AdditionalInfoText.Buffer;
				bool showInfo = false;
				TextIter textIter = TextIter.Zero;

				buffer.Clear ();

				if (!String.IsNullOrEmpty (n.ExtraInfo)) {
					showInfo = true;
					textIter = buffer.StartIter;

					buffer.InsertWithTagsByName (ref textIter, "Additional information:\n", "bold");
					InsertWithMarkup (buffer, ref textIter, "\t" + n.ExtraInfo + "\n");
				}

				if (n != null) msgs = n.Messages;
				if (msgs != null && msgs.Count > 0) {
					if (!showInfo) {
						showInfo = true;
						textIter = buffer.StartIter;
					}

					buffer.InsertWithTagsByName (ref textIter, "Errors:\n", "red", "bold");

					for (int i = 0; i < msgs.Count; i ++) {
						buffer.InsertWithTagsByName (ref textIter, String.Format ("\t{0}: ", i + 1), "bold");
						InsertWithMarkup (buffer, ref textIter, msgs [i]);
					}
				}
				
				if (n != null) msgs = n.Todos;
				if (msgs != null && msgs.Count > 0) {
					if (!showInfo) {
						showInfo = true;
						textIter = buffer.StartIter;
					}

					buffer.InsertWithTagsByName (ref textIter, "TODO:\n", "green", "bold");
					for (int i = 0; i < msgs.Count; i ++) {
						buffer.InsertWithTagsByName (ref textIter, String.Format ("\t{0}: ", i + 1), "bold");
						buffer.Insert (ref textIter, msgs [i]);
					}
				}
				
				if (showInfo)
					AdditionalInfoWindow.Visible = true;
				else
					AdditionalInfoWindow.Visible = false;

				string msdnUrl = n != null ? n.MSDNUrl : null;
				if (!String.IsNullOrEmpty (msdnUrl))
					Status = GetMSDNVersionedUrl (msdnUrl);
				else
					Status = String.Empty;
			}
		};

		tree.RowActivated += delegate (object sender, RowActivatedArgs args) {
			Gtk.TreeIter iter;
			if (!tree.Model.GetIter (out iter, args.Path))
				return;

			ComparisonNode n = tree.Model.GetValue (iter, (int)TreeCol.Node) as ComparisonNode;
			if (n == null || String.IsNullOrEmpty (n.MSDNUrl))
				return;

			System.Diagnostics.Process browser = new System.Diagnostics.Process ();
			browser.StartInfo.FileName = GetMSDNVersionedUrl (n.MSDNUrl);
			browser.StartInfo.UseShellExecute = true;
			browser.Start ();
		};
		
		//
		// Load configuration
		//
		ShowMissing.Active = Config.ShowMissing;
		ShowErrors.Active = Config.ShowErrors;
		ShowExtra.Active = Config.ShowExtra;
		ShowPresent.Active = Config.ShowPresent;
		ShowTodo.Active = Config.ShowTodo;

		//
		// Legend
		//
		legendImageOK.Pixbuf = okPixbuf;
		legendImageError.Pixbuf = errorPixbuf;
		legendImageNIEX.Pixbuf = niexPixbuf;
		legendImageMissing.Pixbuf = missingPixbuf;
		legendImageTODO.Pixbuf = todoPixbuf;
		legendImageExtra.Pixbuf = extraPixbuf;
	}