Widget IOutlinedDocument.GetOutlineWidget() { if (outlineTreeView != null) { return(outlineTreeView); } outlineTreeStore = new TreeStore(typeof(object)); outlineTreeModelSort = new TreeModelSort(outlineTreeStore); settings = OutlineSettings.Load(); comparer = new OutlineNodeComparer(new AstAmbience(TypeSystemService.Workspace.Options), settings, outlineTreeModelSort); outlineTreeModelSort.SetSortFunc(0, comparer.CompareNodes); outlineTreeModelSort.SetSortColumnId(0, SortType.Ascending); outlineTreeView = new MonoDevelop.Ide.Gui.Components.PadTreeView(outlineTreeStore); var pixRenderer = new CellRendererImage(); pixRenderer.Xpad = 0; pixRenderer.Ypad = 0; outlineTreeView.TextRenderer.Xpad = 0; outlineTreeView.TextRenderer.Ypad = 0; TreeViewColumn treeCol = new TreeViewColumn(); treeCol.PackStart(pixRenderer, false); treeCol.SetCellDataFunc(pixRenderer, new TreeCellDataFunc(OutlineTreeIconFunc)); treeCol.PackStart(outlineTreeView.TextRenderer, true); treeCol.SetCellDataFunc(outlineTreeView.TextRenderer, new TreeCellDataFunc(OutlineTreeTextFunc)); outlineTreeView.AppendColumn(treeCol); outlineTreeView.HeadersVisible = false; outlineTreeView.Selection.Changed += delegate { JumpToDeclaration(false); }; outlineTreeView.RowActivated += delegate { JumpToDeclaration(true); }; var analysisDocument = DocumentContext.ParsedDocument; if (analysisDocument != null) { lastCU = analysisDocument.GetAst <SemanticModel> (); } outlineTreeView.Realized += delegate { RefillOutlineStore(); }; UpdateSorting(); var sw = new CompactScrolledWindow(); sw.Add(outlineTreeView); sw.ShowAll(); return(sw); }
void CreateControl() { control = new HPaned(); store = new Gtk.TreeStore(typeof(Xwt.Drawing.Image), // image - type typeof(bool), // read? typeof(TaskListEntry), // read? -- use Pango weight typeof(string)); SemanticModelAttribute modelAttr = new SemanticModelAttribute("store__Type", "store__Read", "store__Task", "store__Description"); TypeDescriptor.AddAttributes(store, modelAttr); TreeModelFilterVisibleFunc filterFunct = new TreeModelFilterVisibleFunc(FilterTasks); filter = new TreeModelFilter(store, null); filter.VisibleFunc = filterFunct; sort = new TreeModelSort(filter); sort.SetSortFunc(VisibleColumns.Type, SeverityIterSort); sort.SetSortFunc(VisibleColumns.Project, ProjectIterSort); sort.SetSortFunc(VisibleColumns.File, FileIterSort); sort.SetSortFunc(VisibleColumns.Category, CategoryIterSort); view = new PadTreeView(sort); view.Selection.Mode = SelectionMode.Multiple; view.ShowExpanders = true; view.RulesHint = true; view.DoPopupMenu += ShowPopup; AddColumns(); LoadColumnsVisibility(); view.Columns [VisibleColumns.Type].SortColumnId = VisibleColumns.Type; view.Columns [VisibleColumns.Project].SortColumnId = VisibleColumns.Project; view.Columns [VisibleColumns.File].SortColumnId = VisibleColumns.File; view.Columns [VisibleColumns.Category].SortColumnId = VisibleColumns.Category; sw = new MonoDevelop.Components.CompactScrolledWindow(); sw.ShadowType = ShadowType.None; sw.Add(view); TaskService.Errors.TasksRemoved += ShowResults; TaskService.Errors.TasksAdded += TaskAdded; TaskService.Errors.TasksChanged += TaskChanged; TaskService.Errors.CurrentLocationTaskChanged += HandleTaskServiceErrorsCurrentLocationTaskChanged; IdeApp.Workspace.FirstWorkspaceItemOpened += OnCombineOpen; IdeApp.Workspace.LastWorkspaceItemClosed += OnCombineClosed; view.RowActivated += OnRowActivated; iconWarning = ImageService.GetIcon(Ide.Gui.Stock.Warning, Gtk.IconSize.Menu); iconError = ImageService.GetIcon(Ide.Gui.Stock.Error, Gtk.IconSize.Menu); iconInfo = ImageService.GetIcon(Ide.Gui.Stock.Information, Gtk.IconSize.Menu); iconEmpty = ImageService.GetIcon(Ide.Gui.Stock.Empty, Gtk.IconSize.Menu); control.Add1(sw); logView = new LogView { Name = "buildOutput" }; control.Add2(logView); control.ShowAll(); control.SizeAllocated += HandleControlSizeAllocated; sw.SizeAllocated += HandleSwSizeAllocated; logView.Visible = OutputViewVisible; logBtn.Active = OutputViewVisible; // Load existing tasks foreach (TaskListEntry t in TaskService.Errors) { AddTask(t); } control.FocusChain = new Gtk.Widget [] { logView }; }
public UserTasksView() { highPrioColor = StringToColor((string)PropertyService.Get("Monodevelop.UserTasksHighPrioColor", "")); normalPrioColor = StringToColor((string)PropertyService.Get("Monodevelop.UserTasksNormalPrioColor", "")); lowPrioColor = StringToColor((string)PropertyService.Get("Monodevelop.UserTasksLowPrioColor", "")); store = new ListStore( typeof(string), // priority typeof(bool), // completed typeof(string), // desc typeof(Task), // user task typeof(Gdk.Color), // foreground color typeof(int)); // font style sortModel = new TreeModelSort(store); view = new MonoDevelop.Ide.Gui.Components.PadTreeView(sortModel); view.RulesHint = true; view.SearchColumn = (int)Columns.Description; view.Selection.Changed += new EventHandler(SelectionChanged); TreeViewColumn col; CellRendererComboBox cellRendPriority = new CellRendererComboBox(); cellRendPriority.Values = priorities; cellRendPriority.Editable = true; cellRendPriority.Changed += new ComboSelectionChangedHandler(UserTaskPriorityEdited); col = view.AppendColumn(GettextCatalog.GetString("Priority"), cellRendPriority, "text", Columns.Priority, "foreground-gdk", Columns.Foreground, "weight", Columns.Bold); col.Resizable = true; col.SortColumnId = (int)Columns.Priority; CellRendererToggle cellRendCompleted = new CellRendererToggle(); cellRendCompleted.Toggled += new ToggledHandler(UserTaskCompletedToggled); cellRendCompleted.Activatable = true; col = view.AppendColumn(String.Empty, cellRendCompleted, "active", Columns.Completed); cellRendDesc = view.TextRenderer; cellRendDesc.Editable = true; cellRendDesc.Edited += new EditedHandler(UserTaskDescEdited); col = view.AppendColumn(GettextCatalog.GetString("Description"), cellRendDesc, "text", Columns.Description, "strikethrough", Columns.Completed, "foreground-gdk", Columns.Foreground, "weight", Columns.Bold); col.Resizable = true; col.SortColumnId = (int)Columns.Description; newButton = new Button(); newButton.Label = GettextCatalog.GetString("New Task"); newButton.Image = new Gtk.Image(Gtk.Stock.New, IconSize.Button); newButton.Image.Show(); newButton.Clicked += new EventHandler(NewUserTaskClicked); newButton.TooltipText = GettextCatalog.GetString("Create New Task"); copyButton = new Button(); copyButton.Label = GettextCatalog.GetString("Copy Task"); copyButton.Image = new Gtk.Image(Gtk.Stock.Copy, IconSize.Button); copyButton.Image.Show(); copyButton.Clicked += CopyUserTaskClicked; copyButton.TooltipText = GettextCatalog.GetString("Copy Task Description"); delButton = new Button(); delButton.Label = GettextCatalog.GetString("Delete Task"); delButton.Image = new Gtk.Image(Gtk.Stock.Delete, IconSize.Button); delButton.Image.Show(); delButton.Clicked += new EventHandler(DeleteUserTaskClicked); delButton.TooltipText = GettextCatalog.GetString("Delete Task"); TaskService.UserTasks.TasksChanged += DispatchService.GuiDispatch <TaskEventHandler> (UserTasksChanged); TaskService.UserTasks.TasksAdded += DispatchService.GuiDispatch <TaskEventHandler> (UserTasksChanged); TaskService.UserTasks.TasksRemoved += DispatchService.GuiDispatch <TaskEventHandler> (UserTasksChanged); if (IdeApp.Workspace.IsOpen) { solutionLoaded = true; } IdeApp.Workspace.FirstWorkspaceItemOpened += CombineOpened; IdeApp.Workspace.LastWorkspaceItemClosed += CombineClosed; PropertyService.PropertyChanged += DispatchService.GuiDispatch <EventHandler <PropertyChangedEventArgs> > (OnPropertyUpdated); ValidateButtons(); // Initialize with existing tags. UserTasksChanged(this, null); }
void CreateView() { if (view != null) { return; } ReloadPriorities(); TaskService.CommentTasksChanged += OnCommentTasksChanged; CommentTag.SpecialCommentTagsChanged += OnCommentTagsChanged; MonoDevelopWorkspace.LoadingFinished += OnWorkspaceItemLoaded; IdeApp.Workspace.WorkspaceItemUnloaded += OnWorkspaceItemUnloaded; IdeApp.Workspace.LastWorkspaceItemClosed += LastWorkspaceItemClosed; IdeApp.Workbench.DocumentOpened += WorkbenchDocumentOpened; IdeApp.Workbench.DocumentClosed += WorkbenchDocumentClosed; highPrioColor = StringToColor(IdeApp.Preferences.UserTasksHighPrioColor); normalPrioColor = StringToColor(IdeApp.Preferences.UserTasksNormalPrioColor); lowPrioColor = StringToColor(IdeApp.Preferences.UserTasksLowPrioColor); store = new Gtk.ListStore( typeof(int), // line typeof(string), // desc typeof(string), // file typeof(string), // path typeof(TaskListEntry), // task typeof(Gdk.Color), // foreground color typeof(int)); // font weight sortModel = new TreeModelSort(store); view = new MonoDevelop.Ide.Gui.Components.PadTreeView(sortModel); view.RulesHint = true; view.SearchColumn = (int)Columns.Description; view.DoPopupMenu = (evt) => IdeApp.CommandService.ShowContextMenu(view, evt, CreateMenu()); view.RowActivated += new RowActivatedHandler(OnRowActivated); TreeViewColumn col; col = view.AppendColumn(GettextCatalog.GetString("Line"), view.TextRenderer, "text", Columns.Line, "foreground-gdk", Columns.Foreground, "weight", Columns.Bold); col.Clickable = false; col = view.AppendColumn(GettextCatalog.GetString("Description"), view.TextRenderer, "text", Columns.Description, "foreground-gdk", Columns.Foreground, "weight", Columns.Bold); col.SortColumnId = (int)Columns.Description; col.Resizable = true; col = view.AppendColumn(GettextCatalog.GetString("File"), view.TextRenderer, "text", Columns.File, "foreground-gdk", Columns.Foreground, "weight", Columns.Bold); col.SortColumnId = (int)Columns.File; col.Resizable = true; col = view.AppendColumn(GettextCatalog.GetString("Path"), view.TextRenderer, "text", Columns.Path, "foreground-gdk", Columns.Foreground, "weight", Columns.Bold); col.SortColumnId = (int)Columns.Path; col.Resizable = true; LoadColumnsVisibility(); OnWorkspaceItemLoaded(null, EventArgs.Empty); comments.TasksAdded += GeneratedTaskAdded; comments.TasksRemoved += GeneratedTaskRemoved; IdeApp.Preferences.UserTasksHighPrioColor.Changed += OnPropertyUpdated; IdeApp.Preferences.UserTasksNormalPrioColor.Changed += OnPropertyUpdated; IdeApp.Preferences.UserTasksLowPrioColor.Changed += OnPropertyUpdated; // Initialize with existing tags. foreach (TaskListEntry t in comments) { AddGeneratedTask(t); } view.Destroyed += delegate { view.RowActivated -= OnRowActivated; TaskService.CommentTasksChanged -= OnCommentTasksChanged; CommentTag.SpecialCommentTagsChanged -= OnCommentTagsChanged; MonoDevelopWorkspace.LoadingFinished -= OnWorkspaceItemLoaded; IdeApp.Workspace.WorkspaceItemUnloaded -= OnWorkspaceItemUnloaded; comments.TasksAdded -= GeneratedTaskAdded; comments.TasksRemoved -= GeneratedTaskRemoved; IdeApp.Preferences.UserTasksHighPrioColor.Changed -= OnPropertyUpdated; IdeApp.Preferences.UserTasksNormalPrioColor.Changed -= OnPropertyUpdated; IdeApp.Preferences.UserTasksLowPrioColor.Changed -= OnPropertyUpdated; }; }
void CellRendererEdited(CellRendererTextAdv sender, string pathStr, string newText, int colNum) { TreeModelSort model = (TreeModelSort)treeDebaters.Model; TreePath path = new TreePath(pathStr); TreeIter iter = TreeIter.Zero; model.GetIter(out iter, path); EditableDebater d = (EditableDebater)model.GetValue(iter, 0); try { ColumnInfo prop = columns[treeDebaters.Columns[colNum].Title]; // This parses the given new string, // and updates the data in store prop.parseAndSet(d, newText); // existing Debater: Update Data in (possibly) existing Rounds // tries to keep data consisting, but there's no guarantee // BlackList/WhiteList and ExtraInfo are not // used in RoundDebater, so skip this by condition colNum<4 if (newDebaterPath == null && colNum < 4) { var rd = new EditableDebater(d); var p = prop.get(d); // Only simple Renaming of Role is possible if Rounds exist if (colNum == 3 && Tournament.I.Rounds.Count > 0 && ((d.Role.IsTeamMember != rd.Role.IsTeamMember) || (d.Role.IsJudge != rd.Role.IsJudge))) { MiscHelpers.ShowMessage(this, "Changing Role from Judge to TeamMember (or vice versa)" + " is not possible since Rounds are already set.", MessageType.Error); // reset to old role... d.Role = rd.Role; return; } // check if new TeamName is already present if (colNum == 3 && d.Role.IsTeamMember) { int n = 0; foreach (object[] row in store) { EditableDebater d_ = (EditableDebater)row[0]; if (!d.Equals(d_) && d_.Role.TeamName == d.Role.TeamName) { n++; } } if (n == 3) { MiscHelpers.ShowMessage(this, "New TeamName is already present in three other Debaters.", MessageType.Error); // reset to old role... d.Role = rd.Role; return; } } // check for duplicate if (colNum < 3) { // need a temporary flag, throwing exceptions in delegates doesnt work... // the following flag stuff isn't elegant, but it should work bool flag = false; model.Foreach((model_, _, iter_) => { if (!iter.Equals(iter_)) { EditableDebater d_ = (EditableDebater)model_.GetValue(iter_, 0); if (d_.Equals(d)) { // reset to old value... prop.get(rd).Set(d); flag = true; return(true); } } return(false); }); if (flag) { throw new TargetInvocationException(new Exception("Debater exists.")); } } // keep data consistent in existing rounds foreach (RoundData round in Tournament.I.Rounds) { foreach (RoomData room in round.Rooms) { foreach (RoundDebater rd_ in room.GetRoomMembers()) { if (rd_ == null) { continue; } if (rd_.Equals(rd)) { p.UnsafeSetRoundDebater(rd_); } if (rd_.Role.TeamName == rd.Role.TeamName) { rd_.Role.TeamName = d.Role.TeamName; } } } if (rd.Role.IsTeamMember) { foreach (TeamData team in round.AllTeams) { foreach (RoundDebater rd_ in team) { if (rd_.Equals(rd)) { p.UnsafeSetRoundDebater(rd_); } if (rd_.Role.TeamName == rd.Role.TeamName) { rd_.Role.TeamName = d.Role.TeamName; } } } } else if (rd.Role.IsJudge) { foreach (RoundDebater rd_ in round.AllJudges) { if (rd_.Equals(rd)) { p.UnsafeSetRoundDebater(rd_); } } } } // Renaming TeamName needs extra Handling if (colNum == 3 && rd.Role.IsTeamMember && d.Role.IsTeamMember) { foreach (object[] row in store) { EditableDebater d_ = (EditableDebater)row[0]; if (d_.Role.TeamName == rd.Role.TeamName) { d_.Role.TeamName = d.Role.TeamName; } } } } // newDebater is entered... else if (newDebaterPath != null && colNum < 3) { // continue with entering data (goto next column) // as idle so that cells are resized GLib.Idle.Add(delegate { treeDebaters.SetCursor(ConvertStorePathToModelPath(newDebaterPath), treeDebaters.Columns[colNum + 1], true); return(false); }); } else if (newDebaterPath != null) { // new Debater entered completely (at least all necessary data) iter = TreeIter.Zero; if (store.GetIter(out iter, newDebaterPath)) { // as idle to prevent gtk critical (no idea why this happens) GLib.Idle.Add(delegate { store.Remove(ref iter); newDebaterPath = null; if (IsNotInStore(d)) { store.AppendValues(d); SaveDebaters(); } else { MiscHelpers.ShowMessage(this, "Debater exists.", MessageType.Error); } UpdateDebatersInfo(); btnDebaterAdd.GrabFocus(); return(false); }); } } // Gui stuff treeDebaters.ColumnsAutosize(); // ugly method of resorting the TreeSortModel... SortType st; int sortColumn; model.GetSortColumnId(out sortColumn, out st); if (st == SortType.Descending) { model.SetSortColumnId(sortColumn, SortType.Ascending); model.SetSortColumnId(sortColumn, SortType.Descending); } else { model.SetSortColumnId(sortColumn, SortType.Descending); model.SetSortColumnId(sortColumn, SortType.Ascending); } // save data from store if not adding new debater if (newDebaterPath == null) { SaveDebaters(); } } catch (TargetInvocationException e) { MessageDialog md = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.OkCancel, e.InnerException.Message + ". Try again?"); md.DefaultResponse = ResponseType.Ok; ResponseType r = (ResponseType)md.Run(); md.Destroy(); if (r == ResponseType.Ok) { // As Idle otherwise Editable isn't destroyed correctly GLib.Idle.Add(delegate { sender.TempEditString = newText; treeDebaters.SetCursor(path, treeDebaters.Columns[colNum], true); return(false); }); } else { if (newDebaterPath == null) { return; } iter = TreeIter.Zero; if (store.GetIter(out iter, newDebaterPath)) { // remove not finished new debater, // with idle call, // prevents Gtk critical filter model assertion. GLib.Idle.Add(delegate { newDebaterPath = null; store.Remove(ref iter); return(false); }); } } } }
void CreateControl() { control = new HPaned(); store = new Gtk.ListStore(typeof(Gdk.Pixbuf), // image - type typeof(bool), // read? typeof(Task)); // read? -- use Pango weight TreeModelFilterVisibleFunc filterFunct = new TreeModelFilterVisibleFunc(FilterTaskTypes); filter = new TreeModelFilter(store, null); filter.VisibleFunc = filterFunct; sort = new TreeModelSort(filter); sort.SetSortFunc(VisibleColumns.Type, SeverityIterSort); sort.SetSortFunc(VisibleColumns.Project, ProjectIterSort); sort.SetSortFunc(VisibleColumns.File, FileIterSort); view = new PadTreeView(sort); view.RulesHint = true; view.DoPopupMenu = (evnt) => IdeApp.CommandService.ShowContextMenu(view, evnt, CreateMenu()); AddColumns(); LoadColumnsVisibility(); view.Columns[VisibleColumns.Type].SortColumnId = VisibleColumns.Type; view.Columns[VisibleColumns.Project].SortColumnId = VisibleColumns.Project; view.Columns[VisibleColumns.File].SortColumnId = VisibleColumns.File; sw = new MonoDevelop.Components.CompactScrolledWindow(); sw.ShadowType = ShadowType.None; sw.Add(view); TaskService.Errors.TasksRemoved += DispatchService.GuiDispatch <TaskEventHandler> (ShowResults); TaskService.Errors.TasksAdded += DispatchService.GuiDispatch <TaskEventHandler> (TaskAdded); TaskService.Errors.TasksChanged += DispatchService.GuiDispatch <TaskEventHandler> (TaskChanged); TaskService.Errors.CurrentLocationTaskChanged += HandleTaskServiceErrorsCurrentLocationTaskChanged; IdeApp.Workspace.FirstWorkspaceItemOpened += OnCombineOpen; IdeApp.Workspace.LastWorkspaceItemClosed += OnCombineClosed; view.RowActivated += new RowActivatedHandler(OnRowActivated); iconWarning = sw.RenderIcon(Stock.Warning, Gtk.IconSize.Menu, ""); iconError = sw.RenderIcon(Stock.Error, Gtk.IconSize.Menu, ""); iconInfo = sw.RenderIcon(Gtk.Stock.DialogInfo, Gtk.IconSize.Menu, ""); control.Add1(sw); outputView = new LogView(); control.Add2(outputView); Control.ShowAll(); control.SizeAllocated += HandleControlSizeAllocated; bool outputVisible = PropertyService.Get <bool> (outputViewVisiblePropertyName, false); if (outputVisible) { outputView.Visible = true; logBtn.Active = true; } else { outputView.Hide(); } sw.SizeAllocated += HandleSwSizeAllocated; // Load existing tasks foreach (Task t in TaskService.Errors) { AddTask(t); } control.FocusChain = new Gtk.Widget [] { sw }; }
public static TreeIter ConvertViewToModel(TreeIter iter, TreeModelSort sortedModel, TreeModelFilter filterModel) { var iter1 = sortedModel.ConvertIterToChildIter(iter); return(filterModel.ConvertIterToChildIter(iter1)); }
public WindowBuilder() { _columnFilter = 0; _textToFilter = ""; _processIdToKill = new List <int>(); _listStore = new ListStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string)); Application.Init(); _window = new Window("Label sample"); _window.Resize(1300, 600); _window.Title = "Process Watch"; _window.SetIconFromFile("icons/processIconSmall.png"); _window.BorderWidth = 5; _window.DeleteEvent += OnWindowClose; var aboutButton = new Button(); var aboutIcon = new Image(); aboutIcon.Pixbuf = new Pixbuf("icons/information.png"); aboutButton.Image = aboutIcon; aboutButton.TooltipText = "About Process Watch"; aboutButton.Clicked += (sender, args) => { _aboutDialog.Show(); }; _aboutDialog = CreateAboutDialog(); var filterButton = new Button(); filterButton.Image = new Image(Stock.Find, IconSize.Button); filterButton.TooltipText = "Filtration utilities"; filterButton.Clicked += (sender, args) => { if (_filtrationHBox.IsVisible) { _filtrationHBox.Hide(); } else { _filtrationHBox.ShowAll(); } }; var windowHBox = new HBox(false, 5); windowHBox.PackEnd(aboutButton, false, false, 0); windowHBox.PackEnd(filterButton, false, false, 0); _processNameEntry = new Entry(); _processNameEntry.Changed += OnChanged; _processIdEntry = new Entry(); _processIdEntry.Changed += OnChanged; _processIdEntry.TextInserted += OnlyNumerical; // String values for the combobox - filtration direction _filtrationDirectionOptions = new[] { ">", "≥", "=", "≤", "<" }; // String values for the combobox - memory usage units _memoryFiltrationDirectionUnits = new[] { "B", "KB", "MB", "GB" }; _memoryFiltrationEntry = new Entry(); _memoryFiltrationEntry.MaxWidthChars = 7; _memoryFiltrationEntry.WidthChars = 7; _memoryFiltrationEntry.Changed += OnChanged; _memoryFiltrationEntry.TextInserted += OnlyNumerical; _memoryFiltrationDirectionComboBox = new ComboBox(_filtrationDirectionOptions); _memoryFiltrationDirectionComboBox.Changed += OnChanged; _memoryFiltrationUnitsComboBox = new ComboBox(_memoryFiltrationDirectionUnits); _memoryFiltrationUnitsComboBox.Changed += OnChanged; _memoryFiltrationHbox = new HBox(); _memoryFiltrationHbox.PackStart(_memoryFiltrationDirectionComboBox, false, false, 0); _memoryFiltrationHbox.PackStart(_memoryFiltrationEntry, false, false, 0); _memoryFiltrationHbox.PackStart(_memoryFiltrationUnitsComboBox, false, false, 0); _cpuFiltrationEntry = new Entry(); _cpuFiltrationEntry.MaxWidthChars = 7; _cpuFiltrationEntry.WidthChars = 7; _cpuFiltrationEntry.Changed += OnChanged; _cpuFiltrationEntry.TextInserted += OnlyNumerical; _cpuFiltrationDirectionComboBox = new ComboBox(_filtrationDirectionOptions); _cpuFiltrationDirectionComboBox.Changed += OnChanged; var cpuFiltrationLabel = new Label("%"); _cpuFiltrationHbox = new HBox(); _cpuFiltrationHbox.PackStart(_cpuFiltrationDirectionComboBox, false, false, 0); _cpuFiltrationHbox.PackStart(_cpuFiltrationEntry, false, false, 0); _cpuFiltrationHbox.PackStart(cpuFiltrationLabel, false, false, 0); _filtrationOptions = new[] { "All processes", "Filter by PID", "Filter by Process Name", "Filter by Memory Usage", "Filter by CPU usage", }; var filtrationCombo = new ComboBox(_filtrationOptions); filtrationCombo.Changed += ComboOnChanged; _filtrationHBox = new HBox(false, 5); _filtrationHBox.PackStart(filtrationCombo, false, false, 0); string[] columnLabels = { "PID", "Process name", "Memory usage", "Priority", "User CPU Time", "Privileged CPU Time", "Total CPU Time", "CPU usage", "Threads", "Start Time" }; _treeModelFilter = new TreeModelFilter(_listStore, null); _treeModelFilter.VisibleFunc = Filter; var treeModelSort = new TreeModelSort(_treeModelFilter); treeModelSort.SetSortFunc(0, WindowBuilderHelper.IdSortFunc); treeModelSort.SetSortFunc(1, WindowBuilderHelper.ProcessNameSortFunc); treeModelSort.SetSortFunc(2, WindowBuilderHelper.MemoryUsageSortFunc); treeModelSort.SetSortFunc(3, WindowBuilderHelper.PrioritySortFunc); treeModelSort.SetSortFunc(4, WindowBuilderHelper.UserCpuTimeSortFunc); treeModelSort.SetSortFunc(5, WindowBuilderHelper.PrivilegedCpuTimeSortFunc); treeModelSort.SetSortFunc(6, WindowBuilderHelper.TotalCpuTimeSortFunc); treeModelSort.SetSortFunc(7, WindowBuilderHelper.CpuUsageSortFunc); treeModelSort.SetSortFunc(8, WindowBuilderHelper.ThreadCountSortFunc); treeModelSort.SetSortFunc(9, WindowBuilderHelper.StartTimeSortFunc); var treeView = new TreeView(); treeView.Model = treeModelSort; treeView.Selection.Mode = SelectionMode.Multiple; treeView.Selection.Changed += OnSelectionChanged; treeView.TooltipColumn = 1; // Create a scrollable window var scrolledWindow = new ScrolledWindow(); scrolledWindow.Add(treeView); // Create a CellRendererText responsible for proper rendering cell data var cellRendererText = new CellRendererText(); cellRendererText.Alignment = Pango.Alignment.Right; cellRendererText.Xalign = 0.5f; // Load the _treeView with TreeViewColumns for (int i = 0; i < 10; i++) { var treeViewColumn = new TreeViewColumn(); treeViewColumn.Clickable = true; treeViewColumn.Resizable = true; treeViewColumn.Title = columnLabels[i]; treeViewColumn.SortIndicator = true; treeViewColumn.Alignment = 0.5f; treeViewColumn.Expand = true; treeViewColumn.SortColumnId = i; treeViewColumn.PackStart(cellRendererText, true); treeViewColumn.AddAttribute(cellRendererText, "text", i); switch (i) { case 0: break; case 1: _window.GetSize(out int width, out int height); treeViewColumn.MaxWidth = Math.Abs(width / 2); break; case 2: treeViewColumn.SetCellDataFunc(cellRendererText, WindowBuilderHelper.MemoryUsageFormatter); break; case 3: break; case 4: treeViewColumn.SetCellDataFunc(cellRendererText, WindowBuilderHelper.UserCpuTimeFormatter); break; case 5: treeViewColumn.SetCellDataFunc(cellRendererText, WindowBuilderHelper.PrivilegedCpuTimeFormatter); break; case 6: treeViewColumn.SetCellDataFunc(cellRendererText, WindowBuilderHelper.TotalCpuTimeFormatter); break; case 7: treeViewColumn.SetCellDataFunc(cellRendererText, WindowBuilderHelper.CpuUsageFormatter); break; case 8: break; case 9: treeViewColumn.SetCellDataFunc(cellRendererText, WindowBuilderHelper.StartTimeFormatter); break; } treeView.AppendColumn(treeViewColumn); } var killButton = new Button("Kill process"); killButton.Clicked += KillProcess; var windowVBox = new VBox(false, 5); windowVBox.PackStart(windowHBox, false, false, 0); windowVBox.PackStart(_filtrationHBox, false, false, 0); windowVBox.PackStart(scrolledWindow, true, true, 0); windowVBox.PackStart(killButton, false, false, 0); _window.Add(windowVBox); // Create an instance of the object Updater _processGrabber = new ProcessGrabber(); // Add a callback executed when _processGrabber takes process data. // The callback clears the _treeView content and loads new data // Before clearing the _treeView content the callback saves the current scroll position _processGrabber.OnResult += (sender, processList) => { Application.Invoke(delegate { _currentScrollPosition = treeView.Vadjustment.Value; StoreClear(); LoadStore(processList); treeView.ShowAll(); }); }; // Add a callback executed after 'Changed' event raised after changing the position of the _treeView // When the _treeView content is reloaded the previous scroll position is updated treeView.Vadjustment.Changed += (sender, args) => { treeView.Vadjustment.Value = _currentScrollPosition; }; // Start the Timer process responsible for grabbing process data periodically _processGrabber.Run(); treeView.ShowAll(); _window.ShowAll(); // Hide widgets related to process filtration _filtrationHBox.Hide(); }
public SearchResultsPage(FileSearch search) { VPaned paned; TreeViewColumn column; ToolItem spacerItem; ToolItem filterItem; Alignment filterAlignment; ToolButton searchAgainToolButton; this.search = search; downloadToolButton = new ToolButton(new Image("gtk-save", IconSize.LargeToolbar), "Download"); downloadToolButton.IsImportant = true; downloadToolButton.Sensitive = false; downloadToolButton.Clicked += DownloadToolButtonClicked; searchAgainToolButton = new ToolButton(new Image("gtk-refresh", IconSize.LargeToolbar), "Search Again"); searchAgainToolButton.IsImportant = true; searchAgainToolButton.Clicked += SearchAgainToolButtonClicked; spacerItem = new ToolItem(); spacerItem.Expand = true; filterButton = new ToggleButton("Filter Results"); filterButton.Image = new Image(Gui.LoadIcon(16, "application-x-executable")); filterButton.Toggled += delegate(object o, EventArgs args) { this.ShowFilter = filterButton.Active; }; filterAlignment = new Alignment(0.5f, 0.5f, 0, 0); filterAlignment.Add(filterButton); filterItem = new ToolItem(); filterItem.Add(filterAlignment); browseToolButton = new ToolButton(new Image("gtk-open", IconSize.LargeToolbar), "Browse"); browseToolButton.IsImportant = true; browseToolButton.Sensitive = false; browseToolButton.Clicked += BrowseToolButtonClicked; toolbar = new Toolbar(); toolbar.ToolbarStyle = ToolbarStyle.BothHoriz; toolbar.Insert(downloadToolButton, -1); toolbar.Insert(browseToolButton, -1); toolbar.Insert(spacerItem, -1); toolbar.Insert(filterItem, -1); toolbar.Insert(new SeparatorToolItem(), -1); toolbar.Insert(searchAgainToolButton, -1); toolbar.ShowAll(); this.PackStart(toolbar, false, false, 0); resultCountByTypeCache = new Dictionary <FilterType, int>(); Gdk.Pixbuf audioPixbuf = Gui.LoadIcon(16, "audio-x-generic"); Gdk.Pixbuf videoPixbuf = Gui.LoadIcon(16, "video-x-generic"); Gdk.Pixbuf imagePixbuf = Gui.LoadIcon(16, "image-x-generic"); Gdk.Pixbuf docPixbuf = Gui.LoadIcon(16, "x-office-document"); unknownPixbuf = Gui.LoadIcon(16, "text-x-generic"); folderPixbuf = Gui.LoadIcon(16, "folder"); typeStore = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(FilterType)); typeStore.AppendValues(null, "All Results", FilterType.All); typeStore.AppendValues(null, "-"); typeStore.AppendValues(audioPixbuf, "Audio", FilterType.Audio); typeStore.AppendValues(videoPixbuf, "Video", FilterType.Video); typeStore.AppendValues(imagePixbuf, "Images", FilterType.Image); typeStore.AppendValues(docPixbuf, "Documents", FilterType.Document); typeStore.AppendValues(folderPixbuf, "Folders", FilterType.Folder); typeStore.AppendValues(unknownPixbuf, "Other", FilterType.Other); typeTree = new TreeView(); typeTree.HeadersVisible = false; typeTree.RowSeparatorFunc = delegate(TreeModel m, TreeIter i) { string text = (string)m.GetValue(i, 1); return(text == "-"); }; typeTree.Selection.Changed += TypeSelectionChanged; typeTree.Model = typeStore; CellRendererPixbuf pixbufCell = new CellRendererPixbuf(); CellRendererText textCell = new CellRendererText(); CellRendererText countTextCell = new CellRendererText(); countTextCell.Sensitive = false; countTextCell.Alignment = Pango.Alignment.Right; countTextCell.Xalign = 1; column = new TreeViewColumn(); column.PackStart(pixbufCell, false); column.PackStart(textCell, true); column.PackStart(countTextCell, false); column.AddAttribute(pixbufCell, "pixbuf", 0); column.AddAttribute(textCell, "text", 1); column.SetCellDataFunc(countTextCell, new TreeCellDataFunc(TypeCountCellFunc)); typeTree.AppendColumn(column); TreeView artistTree = new TreeView(); artistTree.HeadersVisible = false; TreeView albumTree = new TreeView(); albumTree.HeadersVisible = false; HBox topBox = new HBox(); topBox.PackStart(Gui.AddScrolledWindow(typeTree), true, true, 0); topBox.PackStart(Gui.AddScrolledWindow(artistTree), true, true, 1); topBox.PackStart(Gui.AddScrolledWindow(albumTree), true, true, 0); topBox.Homogeneous = true; resultsStore = new ListStore(typeof(SearchResult)); resultsStore.RowInserted += delegate { Refilter(); }; resultsStore.RowDeleted += delegate { Refilter(); }; resultsTree = new TreeView(); resultsTree.RowActivated += resultsTree_RowActivated; resultsTree.ButtonPressEvent += resultsTree_ButtonPressEvent; resultsTree.Selection.Changed += ResultsTreeSelectionChanged; imageColumns = new List <TreeViewColumn>(); audioColumns = new List <TreeViewColumn>(); videoColumns = new List <TreeViewColumn>(); fileOnlyColumns = new List <TreeViewColumn>(); folderOnlyColumns = new List <TreeViewColumn>(); column = new TreeViewColumn(); column.Title = "File Name"; column.Clickable = true; column.Sizing = TreeViewColumnSizing.Autosize; column.Resizable = true; column.SortColumnId = 0; //resultsTree.ExpanderColumn = column; CellRenderer cell = new CellRendererPixbuf(); column.PackStart(cell, false); column.SetCellDataFunc(cell, new TreeCellDataFunc(IconFunc)); cell = new CellRendererText(); column.PackStart(cell, true); column.SetCellDataFunc(cell, new TreeCellDataFunc(FileNameFunc)); resultsTree.AppendColumn(column); column = resultsTree.AppendColumn("Codec", new CellRendererText(), new TreeCellDataFunc(CodecFunc)); column.Clickable = true; column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 120; column.Resizable = true; column.SortColumnId = 1; videoColumns.Add(column); column = resultsTree.AppendColumn("Format", new CellRendererText(), new TreeCellDataFunc(FormatFunc)); column.Clickable = true; column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 90; column.Resizable = true; column.SortColumnId = 2; imageColumns.Add(column); column = resultsTree.AppendColumn("Resolution", new CellRendererText(), new TreeCellDataFunc(ResolutionFunc)); column.Clickable = true; column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 90; column.Resizable = true; column.SortColumnId = 3; videoColumns.Add(column); imageColumns.Add(column); column = resultsTree.AppendColumn("Artist", new CellRendererText(), new TreeCellDataFunc(ArtistFunc)); column.Clickable = true; column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 110; column.Resizable = true; column.SortColumnId = 4; audioColumns.Add(column); column = resultsTree.AppendColumn("Album", new CellRendererText(), new TreeCellDataFunc(AlbumFunc)); column.Clickable = true; column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 110; column.Resizable = true; column.SortColumnId = 5; audioColumns.Add(column); column = resultsTree.AppendColumn("Bitrate", new CellRendererText(), new TreeCellDataFunc(BitrateFunc)); column.Clickable = true; column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 70; column.Resizable = true; column.SortColumnId = 6; audioColumns.Add(column); column = resultsTree.AppendColumn("Size", new CellRendererText(), new TreeCellDataFunc(SizeFunc)); column.Clickable = true; column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 70; column.SortColumnId = 7; column.Resizable = true; fileOnlyColumns.Add(column); column = resultsTree.AppendColumn("Sources", new CellRendererText(), new TreeCellDataFunc(SourcesFunc)); column.Clickable = true; column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 85; column.SortColumnId = 8; column.Resizable = true; fileOnlyColumns.Add(column); column = resultsTree.AppendColumn("User", new CellRendererText(), new TreeCellDataFunc(UserFunc)); column.Clickable = true; column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 85; column.SortColumnId = 8; column.Resizable = true; folderOnlyColumns.Add(column); column = resultsTree.AppendColumn("Full Path", new CellRendererText(), new TreeCellDataFunc(FullPathFunc)); column.Clickable = true; column.Resizable = true; column.SortColumnId = 9; column = resultsTree.AppendColumn("Info Hash", new CellRendererText(), new TreeCellDataFunc(InfoHashFunc)); column.Clickable = true; column.Resizable = true; column.SortColumnId = 10; fileOnlyColumns.Add(column); resultsFilter = new TreeModelFilter(resultsStore, null); resultsFilter.VisibleFunc = resultsFilterFunc; resultsSort = new TreeModelSort(resultsFilter); for (int x = 0; x < resultsTree.Columns.Length; x++) { resultsSort.SetSortFunc(x, resultsSortFunc); } resultsTree.Model = resultsSort; ScrolledWindow resultsTreeSW = new ScrolledWindow(); resultsTreeSW.Add(resultsTree); paned = new VPaned(); paned.Add1(topBox); paned.Add2(resultsTreeSW); paned.Position = 160; paned.ShowAll(); filterWidget = new FilterWidget(search); filterWidget.FiltersChanged += filterWidget_FiltersChanged; filterWidget.Hidden += filterWidget_Hidden; this.PackStart(filterWidget, false, false, 0); this.PackStart(paned, true, true, 0); TypeSelectionChanged(typeTree, EventArgs.Empty); search.NewResults += (EventHandler <SearchResultsEventArgs>)DispatchService.GuiDispatch(new EventHandler <SearchResultsEventArgs>(search_NewResults)); search.ClearedResults += (EventHandler)DispatchService.GuiDispatch(new EventHandler(search_ClearedResults)); resultPopupMenu = new Menu(); browseResultMenuItem = new ImageMenuItem("Browse"); browseResultMenuItem.Image = new Image(Gui.LoadIcon(16, "document-open")); browseResultMenuItem.Activated += BrowseToolButtonClicked; resultPopupMenu.Append(browseResultMenuItem); downloadResultMenuItem = new ImageMenuItem("Download"); downloadResultMenuItem.Image = new Image(Gui.LoadIcon(16, "go-down")); downloadResultMenuItem.Activated += DownloadToolButtonClicked; resultPopupMenu.Append(downloadResultMenuItem); resultPropertiesMenuItem = new ImageMenuItem(Gtk.Stock.Properties, null); resultPropertiesMenuItem.Activated += FilePropertiesButtonClicked; resultPopupMenu.Append(resultPropertiesMenuItem); }
/// <summary> /// Initializes a new instance of the <see cref="GamePage"/> class. The given package group and node tree are /// wrapped by the page. /// </summary> /// <param name="packageGroup">The package group which the node tree maps to.</param> /// <param name="nodeTree">The prebuilt node tree to display.</param> /// <param name="version">The Warcraft version that the game page is contextually relevant for.</param> public GamePage(PackageGroup packageGroup, SerializedTree nodeTree, WarcraftVersion version) { this.UiTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); this.TreeModel = new FileTreeModel(nodeTree); this.GameContext = new WarcraftGameContext(version, packageGroup, this.TreeModel); this.TreeAlignment = new Alignment(0.5f, 0.5f, 1.0f, 1.0f) { TopPadding = 1, BottomPadding = 1 }; this.TreeFilter = new TreeModelFilter(new TreeModelAdapter(this.TreeModel), null) { VisibleFunc = TreeModelVisibilityFunc }; this.TreeSorter = new TreeModelSort(this.TreeFilter); this.TreeSorter.SetSortFunc(0, SortGameTreeRow); this.TreeSorter.SetSortColumnId(0, SortType.Descending); this.Tree = new TreeView(this.TreeSorter) { HeadersVisible = true, EnableTreeLines = true }; CellRendererPixbuf nodeIconRenderer = new CellRendererPixbuf { Xalign = 0.0f }; CellRendererText nodeNameRenderer = new CellRendererText { Xalign = 0.0f }; TreeViewColumn column = new TreeViewColumn { Title = "Data Files", Spacing = 4 }; column.PackStart(nodeIconRenderer, false); column.PackStart(nodeNameRenderer, false); column.SetCellDataFunc(nodeIconRenderer, RenderNodeIcon); column.SetCellDataFunc(nodeNameRenderer, RenderNodeName); this.Tree.AppendColumn(column); ScrolledWindow sw = new ScrolledWindow { this.Tree }; this.TreeAlignment.Add(sw); this.Tree.RowActivated += OnRowActivated; this.Tree.ButtonPressEvent += OnButtonPressed; this.Tree.Selection.Changed += OnSelectionChanged; this.TreeContextMenu = new Menu(); // Save item context button this.SaveItem = new ImageMenuItem { UseStock = true, Label = Stock.Save, CanFocus = false, TooltipText = "Save the currently selected item to disk.", UseUnderline = true }; this.SaveItem.Activated += OnSaveItem; this.TreeContextMenu.Add(this.SaveItem); // Export item context button this.ExportItem = new ImageMenuItem("Export") { Image = new Image(Stock.Convert, IconSize.Button), CanFocus = false, TooltipText = "Exports the currently selected item to another format.", }; this.ExportItem.Activated += OnExportItemRequested; this.TreeContextMenu.Add(this.ExportItem); // Open item context button this.OpenItem = new ImageMenuItem { UseStock = true, Label = Stock.Open, CanFocus = false, TooltipText = "Open the currently selected item.", UseUnderline = true }; this.OpenItem.Activated += OnOpenItem; this.TreeContextMenu.Add(this.OpenItem); // Queue for export context button this.QueueForExportItem = new ImageMenuItem("Queue for export") { Image = new Image(Stock.Convert, IconSize.Button), CanFocus = false, TooltipText = "Queues the currently selected item for batch export.", }; this.QueueForExportItem.Activated += OnQueueForExportRequested; this.TreeContextMenu.Add(this.QueueForExportItem); // Separator SeparatorMenuItem separator = new SeparatorMenuItem(); this.TreeContextMenu.Add(separator); // Copy path context button this.CopyPathItem = new ImageMenuItem("Copy path") { Image = new Image(Stock.Copy, IconSize.Button), CanFocus = false, TooltipText = "Copy the path of the currently selected item.", }; this.CopyPathItem.Activated += OnCopyPath; this.TreeContextMenu.Add(this.CopyPathItem); this.TreeAlignment.ShowAll(); }
/// <summary> /// Constructor. Initialises the jobs TreeView and the controls associated with it. /// </summary> /// <param name="owner"></param> public CloudJobDisplayView(ViewBase owner) : base(owner) { store = new ListStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string)); Type[] types = new Type[columnTitles.Length]; tree = new TreeView() { CanFocus = true, RubberBanding = true, Name = "custom_treeview" }; tree.Selection.Mode = SelectionMode.Multiple; for (int i = 0; i < columnTitles.Length; i++) { types[i] = typeof(string); TreeViewColumn col = new TreeViewColumn { Title = columnTitles[i], SortColumnId = i, Resizable = true, Sizing = TreeViewColumnSizing.GrowOnly }; CellRendererText cell = new CellRendererText(); col.PackStart(cell, false); col.AddAttribute(cell, "text", i); tree.AppendColumn(col); } store = new ListStore(types); // this filter holds the model (data) and is used to filter jobs based on whether // they were submitted by the user filterOwner = new TreeModelFilter(store, null) { VisibleFunc = FilterOwnerFunc }; filterOwner.Refilter(); // the filter then goes into this TreeModelSort, which is used to sort results when // the user clicks on a column header sort = new TreeModelSort(filterOwner) { DefaultSortFunc = (model, a, b) => SortData(model, a, b, Array.IndexOf(columnTitles, "Start Time")) }; for (int i = 0; i < columnTitles.Length; i++) { int count = i; sort.SetSortFunc(i, (model, a, b) => SortData(model, a, b, count)); } // change the colour of every other row - makes it easier to read string style = "style \"custom-treestyle\"{ GtkTreeView::odd-row-color = \"#ECF2FD\" GtkTreeView::even-row-color = \"#FFFFFF\" GtkTreeView::allow-rules = 1 } widget \"*custom_treeview*\" style \"custom-treestyle\""; //tree.CanFocus = true; tree.RulesHint = true; Rc.ParseString(style); // the tree holds the sorted, filtered data tree.Model = sort; // the tree goes into this ScrolledWindow, allowing users to scroll down // to view more jobs ScrolledWindow scroll = new ScrolledWindow(); scroll.Add(tree); // never allow horizontal scrolling, and only allow vertical scrolling when needed scroll.HscrollbarPolicy = PolicyType.Automatic; scroll.VscrollbarPolicy = PolicyType.Automatic; // the scrolled window goes into this frame to distinguish the job view // from the controls beside it Frame treeContainer = new Frame("Cloud Jobs"); treeContainer.Add(scroll); chkFilterOwner = new CheckButton("Display my jobs only"); // display the user's jobs only by default myJobsOnly = true; chkFilterOwner.Active = true; chkFilterOwner.Toggled += ApplyFilter; chkFilterOwner.Yalign = 0; downloadProgress = new ProgressBar(new Adjustment(0, 0, 1, 0.01, 0.01, 1)); lblDownloadProgress = new Label("Downloading: "); downloadProgressContainer = new HBox(); downloadProgressContainer.PackStart(lblDownloadProgress, false, false, 0); downloadProgressContainer.PackStart(downloadProgress, false, false, 0); loadingProgress = new ProgressBar(new Adjustment(0, 0, 100, 0.01, 0.01, 100)); loadingProgress.Adjustment.Lower = 0; loadingProgress.Adjustment.Upper = 100; lblDownloadStatus = new Label(""); lblDownloadStatus.Xalign = 0; btnChangeDownloadDir = new Button("Change Download Directory"); btnChangeDownloadDir.Clicked += BtnChangeDownloadDir_Click; tblButtonContainer = new Table(1, 1, false); tblButtonContainer.Attach(btnChangeDownloadDir, 0, 1, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); btnDownload = new Button("Download"); btnDownload.Clicked += BtnDownload_Click; HBox downloadButtonContainer = new HBox(); downloadButtonContainer.PackStart(btnDownload, false, true, 0); btnDelete = new Button("Delete Job(s)"); btnDelete.Clicked += BtnDelete_Click; HBox deleteButtonContainer = new HBox(); deleteButtonContainer.PackStart(btnDelete, false, true, 0); btnStop = new Button("Stop Job(s)"); btnStop.Clicked += BtnStop_Click; HBox stopButtonContainer = new HBox(); stopButtonContainer.PackStart(btnStop, false, true, 0); btnSetup = new Button("Credentials"); btnSetup.Clicked += BtnSetup_Click; HBox setupButtonContainer = new HBox(); setupButtonContainer.PackStart(btnSetup, false, true, 0); progress = new HBox(); progress.PackStart(new Label("Loading Jobs: "), false, false, 0); progress.PackStart(loadingProgress, false, false, 0); vboxDownloadStatuses = new VBox(); controlsContainer = new VBox(); controlsContainer.PackStart(chkFilterOwner, false, false, 0); controlsContainer.PackStart(downloadButtonContainer, false, false, 0); controlsContainer.PackStart(stopButtonContainer, false, false, 0); controlsContainer.PackStart(deleteButtonContainer, false, false, 0); controlsContainer.PackStart(setupButtonContainer, false, false, 0); controlsContainer.PackEnd(tblButtonContainer, false, false, 0); hboxPrimary = new HBox(); hboxPrimary.PackStart(treeContainer, true, true, 0); hboxPrimary.PackStart(controlsContainer, false, true, 0); vboxPrimary = new VBox(); vboxPrimary.PackStart(hboxPrimary); vboxPrimary.PackStart(lblDownloadStatus, false, false, 0); vboxPrimary.PackEnd(progress, false, false, 0); vboxPrimary.PackEnd(downloadProgressContainer, false, false, 0); _mainWidget = vboxPrimary; vboxPrimary.ShowAll(); downloadProgressContainer.HideAll(); HideLoadingProgressBar(); }
// heavily inspired by http://www.mono-project.com/GtkSharp_TreeView_Tutorial private void CreateTreeView() { // fire off an event when the text in the Entry changes filter_entry.Changed += OnFilterEntryTextChanged; // create a column for the prediction var prediction_cell = new CellRendererText(); prediction_cell.BackgroundGdk = white; prediction_column.PackStart(prediction_cell, true); prediction_column.SortIndicator = true; prediction_column.Clickable = true; prediction_column.Clicked += new EventHandler(PredictionColumnClicked); // create a column for the rating var rating_cell = new CellRendererText(); rating_cell.Editable = true; rating_cell.Edited += RatingCellEdited; rating_cell.BackgroundGdk = white; //rating_cell.Alignment = Pango.Alignment.Center; // TODO this does not seem to work - what's the problem? rating_column.PackStart(rating_cell, true); rating_column.SortIndicator = true; rating_column.Clickable = true; rating_column.Clicked += new EventHandler(RatingColumnClicked); // set up a column for the movie title var movie_cell = new CellRendererText(); movie_cell.BackgroundGdk = white; movie_column.PackStart(movie_cell, true); movie_column.SortIndicator = true; movie_column.Clickable = true; movie_column.Clicked += new EventHandler(MovieColumnClicked); // add the columns to the TreeView treeview1.AppendColumn(prediction_column); treeview1.AppendColumn(rating_column); treeview1.AppendColumn(movie_column); // set up the render objects for the columns prediction_column.SetCellDataFunc(prediction_cell, new TreeCellDataFunc(RenderPrediction)); rating_column.SetCellDataFunc(rating_cell, new TreeCellDataFunc(RenderRating)); movie_column.SetCellDataFunc(movie_cell, new TreeCellDataFunc(RenderMovieTitle)); var movie_store = new ListStore(typeof(Movie)); // add all movies to the store foreach (Movie movie in movies.movie_list) { movie_store.AppendValues(movie); } pre_filter = new TreeModelFilter(movie_store, null); pre_filter.VisibleFunc = new TreeModelFilterVisibleFunc(PreFilter); name_filter = new TreeModelFilter(pre_filter, null); // specify the function that determines which rows to filter out and which ones to display name_filter.VisibleFunc = new TreeModelFilterVisibleFunc(FilterByName); sorter = new TreeModelSort(name_filter); sorter.DefaultSortFunc = ComparePredictionReversed; treeview1.Model = sorter; treeview1.ShowAll(); }
/// <summary> /// Constructor. Initialises the jobs TreeView and the controls associated with it. /// </summary> /// <param name="owner"></param> public CloudJobView(ViewBase owner) : base(owner) { dl = new CloudDownloadView(this); dl.Download += OnDoDownload; dl.Visible = false; // Give the ListStore 1 more column than the tree view. // This last column displays the job owner but is not shown by the TreeView in its own column. store = new ListStore(Enumerable.Repeat(typeof(string), Enum.GetValues(typeof(Columns)).Length + 1).ToArray()); tree = new Gtk.TreeView() { CanFocus = true, RubberBanding = true }; tree.Selection.Mode = SelectionMode.Multiple; for (int i = 0; i < columnTitles.Length; i++) { TreeViewColumn col = new TreeViewColumn { Title = columnTitles[i], SortColumnId = i, Resizable = true, Sizing = TreeViewColumnSizing.GrowOnly }; CellRendererText cell = new CellRendererText(); col.PackStart(cell, false); col.AddAttribute(cell, "text", i); col.SetCellDataFunc(cell, OnSetCellData); tree.AppendColumn(col); } // this filter holds the model (data) and is used to filter jobs based on whether // they were submitted by the user filterOwner = new TreeModelFilter(store, null) { VisibleFunc = FilterOwnerFunc }; filterOwner.Refilter(); // the filter then goes into this TreeModelSort, which is used to sort results when // the user clicks on a column header sort = new TreeModelSort(filterOwner) { // By default, sort by start time descending. DefaultSortFunc = (model, a, b) => - 1 * SortData(model, a, b, (int)Columns.StartTime) }; for (int i = 0; i < columnTitles.Length; i++) { sort.SetSortFunc(i, (model, a, b) => SortData(model, a, b, i)); } // the tree holds the sorted, filtered data tree.Model = sort; // the tree goes into this ScrolledWindow, allowing users to scroll down // to view more jobs ScrolledWindow scroll = new ScrolledWindow(); scroll.Add(tree); // never allow horizontal scrolling, and only allow vertical scrolling when needed scroll.HscrollbarPolicy = PolicyType.Automatic; scroll.VscrollbarPolicy = PolicyType.Automatic; // The scrolled window goes into this frame to distinguish the job view // from the controls beside it. Frame treeContainer = new Frame("Cloud Jobs"); treeContainer.Add(scroll); chkMyJobsOnly = new CheckButton("Display my jobs only"); chkMyJobsOnly.Toggled += OnToggleFilter; // Display only the user's jobs by default. chkMyJobsOnly.Active = true; chkMyJobsOnly.Yalign = 0; downloadProgress = new ProgressBar(new Adjustment(0, 0, 1, 0.01, 0.01, 1)); downloadProgressContainer = new HBox(); downloadProgressContainer.PackStart(new Label("Downloading: "), false, false, 0); downloadProgressContainer.PackStart(downloadProgress, false, false, 0); loadingProgress = new ProgressBar(new Adjustment(0, 0, 100, 0.01, 0.01, 100)); loadingProgress.Adjustment.Lower = 0; loadingProgress.Adjustment.Upper = 100; btnChangeDownloadDir = new Button("Change Download Directory"); btnChangeDownloadDir.Clicked += OnChangeDownloadPath; Table tblButtonContainer = new Table(1, 1, false); tblButtonContainer.Attach(btnChangeDownloadDir, 0, 1, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); btnDownload = new Button("Download"); btnDownload.Clicked += OnDownloadJobs; HBox downloadButtonContainer = new HBox(); downloadButtonContainer.PackStart(btnDownload, false, true, 0); btnDelete = new Button("Delete Job(s)"); btnDelete.Clicked += OnDeleteJobs; HBox deleteButtonContainer = new HBox(); deleteButtonContainer.PackStart(btnDelete, false, true, 0); btnStop = new Button("Stop Job(s)"); btnStop.Clicked += OnStopJobs; HBox stopButtonContainer = new HBox(); stopButtonContainer.PackStart(btnStop, false, true, 0); btnSetup = new Button("Credentials"); btnSetup.Clicked += OnSetupClicked; HBox setupButtonContainer = new HBox(); setupButtonContainer.PackStart(btnSetup, false, true, 0); jobLoadProgressContainer = new HBox(); jobLoadProgressContainer.PackStart(new Label("Loading Jobs: "), false, false, 0); jobLoadProgressContainer.PackStart(loadingProgress, false, false, 0); VBox controlsContainer = new VBox(); controlsContainer.PackStart(chkMyJobsOnly, false, false, 0); controlsContainer.PackStart(downloadButtonContainer, false, false, 0); controlsContainer.PackStart(stopButtonContainer, false, false, 0); controlsContainer.PackStart(deleteButtonContainer, false, false, 0); controlsContainer.PackStart(setupButtonContainer, false, false, 0); controlsContainer.PackEnd(tblButtonContainer, false, false, 0); HBox hboxPrimary = new HBox(); hboxPrimary.PackStart(treeContainer, true, true, 0); hboxPrimary.PackStart(controlsContainer, false, true, 0); VBox vboxPrimary = new VBox(); vboxPrimary.PackStart(hboxPrimary); vboxPrimary.PackEnd(jobLoadProgressContainer, false, false, 0); vboxPrimary.PackEnd(downloadProgressContainer, false, false, 0); mainWidget = vboxPrimary; mainWidget.Destroyed += OnDestroyed; vboxPrimary.ShowAll(); downloadProgressContainer.HideAll(); HideLoadingProgressBar(); }
public Gtk.Widget GetOutlineWidget() { if (outlineTreeView != null) { return(outlineTreeView); } outlineTreeStore = new TreeStore(typeof(object)); outlineTreeModelSort = new TreeModelSort(outlineTreeStore); /* * settings = ClassOutlineSettings.Load(); * comparer = new ClassOutlineNodeComparer(GetAmbience(), settings, outlineTreeModelSort); * * outlineTreeModelSort.SetSortFunc(0, comparer.CompareNodes); * outlineTreeModelSort.SetSortColumnId(0, SortType.Ascending); */ outlineTreeView = new MonoDevelop.Ide.Gui.Components.PadTreeView(outlineTreeStore); var pixRenderer = new CellRendererPixbuf(); pixRenderer.Xpad = 0; pixRenderer.Ypad = 0; outlineTreeView.TextRenderer.Xpad = 0; outlineTreeView.TextRenderer.Ypad = 0; TreeViewColumn treeCol = new TreeViewColumn(); treeCol.PackStart(pixRenderer, false); treeCol.SetCellDataFunc(pixRenderer, new TreeCellDataFunc(OutlineTreeIconFunc)); treeCol.PackStart(outlineTreeView.TextRenderer, true); treeCol.SetCellDataFunc(outlineTreeView.TextRenderer, new TreeCellDataFunc(OutlineTreeTextFunc)); outlineTreeView.AppendColumn(treeCol); outlineTreeView.HeadersVisible = false; outlineTreeView.Selection.Changed += delegate { JumpToDeclaration(false); }; outlineTreeView.RowActivated += delegate { JumpToDeclaration(true); }; if (Document.ParsedDocument is ParsedDModule) { SyntaxTree = (Document.ParsedDocument as ParsedDModule).DDom; } outlineTreeView.Realized += delegate { RefillOutlineStore(); }; //UpdateSorting(); var sw = new CompactScrolledWindow(); sw.Add(outlineTreeView); sw.ShowAll(); return(sw); }
void CreateControl() { control = new HPaned(); store = new Gtk.TreeStore(typeof(Xwt.Drawing.Image), // image - type typeof(bool), // read? typeof(TaskListEntry), // read? -- use Pango weight typeof(string)); TreeModelFilterVisibleFunc filterFunct = new TreeModelFilterVisibleFunc(FilterTasks); filter = new TreeModelFilter(store, null); filter.VisibleFunc = filterFunct; sort = new TreeModelSort(filter); sort.SetSortFunc(VisibleColumns.Type, SeverityIterSort); sort.SetSortFunc(VisibleColumns.Project, ProjectIterSort); sort.SetSortFunc(VisibleColumns.File, FileIterSort); view = new PadTreeView(sort); view.ShowExpanders = true; view.RulesHint = true; view.DoPopupMenu = (evnt) => IdeApp.CommandService.ShowContextMenu(view, evnt, CreateMenu()); AddColumns(); LoadColumnsVisibility(); view.Columns[VisibleColumns.Type].SortColumnId = VisibleColumns.Type; view.Columns[VisibleColumns.Project].SortColumnId = VisibleColumns.Project; view.Columns[VisibleColumns.File].SortColumnId = VisibleColumns.File; sw = new MonoDevelop.Components.CompactScrolledWindow(); sw.ShadowType = ShadowType.None; sw.Add(view); TaskService.Errors.TasksRemoved += ShowResults; TaskService.Errors.TasksAdded += TaskAdded; TaskService.Errors.TasksChanged += TaskChanged; TaskService.Errors.CurrentLocationTaskChanged += HandleTaskServiceErrorsCurrentLocationTaskChanged; IdeApp.Workspace.FirstWorkspaceItemOpened += OnCombineOpen; IdeApp.Workspace.LastWorkspaceItemClosed += OnCombineClosed; view.RowActivated += new RowActivatedHandler(OnRowActivated); iconWarning = ImageService.GetIcon(Ide.Gui.Stock.Warning, Gtk.IconSize.Menu); iconError = ImageService.GetIcon(Ide.Gui.Stock.Error, Gtk.IconSize.Menu); iconInfo = ImageService.GetIcon(Ide.Gui.Stock.Information, Gtk.IconSize.Menu); iconEmpty = ImageService.GetIcon(Ide.Gui.Stock.Empty, Gtk.IconSize.Menu); control.Add1(sw); outputView = new LogView { Name = "buildOutput" }; control.Add2(outputView); Control.ShowAll(); control.SizeAllocated += HandleControlSizeAllocated; bool outputVisible = OutputViewVisible; if (outputVisible) { outputView.Visible = true; logBtn.Active = true; } else { outputView.Hide(); } sw.SizeAllocated += HandleSwSizeAllocated; // Load existing tasks foreach (TaskListEntry t in TaskService.Errors) { AddTask(t); } control.FocusChain = new Gtk.Widget [] { sw }; }