public override nfloat GetSizeToFitColumnWidth(NSOutlineView outlineView, nint column) { var tableColumn = Backend.Columns[(int)column] as TableColumn; var width = tableColumn.HeaderCell.CellSize.Width; CompositeCell templateCell = null; for (int i = 0; i < outlineView.RowCount; i++) { var cellView = outlineView.GetView(column, i, false) as CompositeCell; if (cellView == null) // use template for invisible rows { cellView = templateCell ?? (templateCell = (tableColumn as TableColumn)?.DataView?.Copy() as CompositeCell); if (cellView != null) { cellView.ObjectValue = outlineView.ItemAtRow(i); } } if (cellView != null) { if (column == 0) // first column contains expanders { width = (nfloat)Math.Max(width, cellView.Frame.X + cellView.FittingSize.Width); } else { width = (nfloat)Math.Max(width, cellView.FittingSize.Width); } } } return(width); }
public void ExpandAllItems() { for (int x = 0; x < sidebar.RowCount; x++) { sidebar.ExpandItem(sidebar.ItemAtRow(x)); } }
public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { // Cast item var product = item as Product; // This pattern allows you reuse existing views when they are no-longer in use. // If the returned view is null, you instance up a new view // If a non-null view is returned, you modify it enough to reflect the new data NSTableCellView view = (NSTableCellView)outlineView.MakeView (tableColumn.Title, this); if (view == null) { view = new NSTableCellView (); if (tableColumn.Title == "Product") { view.ImageView = new NSImageView (new CGRect (0, 0, 16, 16)); view.AddSubview (view.ImageView); view.TextField = new NSTextField (new CGRect (20, 0, 400, 16)); } else { view.TextField = new NSTextField (new CGRect (0, 0, 400, 16)); } view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable; view.AddSubview (view.TextField); view.Identifier = tableColumn.Title; view.TextField.BackgroundColor = NSColor.Clear; view.TextField.Bordered = false; view.TextField.Selectable = false; view.TextField.Editable = !product.IsProductGroup; } // Tag view view.TextField.Tag = outlineView.RowForItem (item); // Allow for edit view.TextField.EditingEnded += (sender, e) => { // Grab product var prod = outlineView.ItemAtRow(view.Tag) as Product; // Take action based on type switch(view.Identifier) { case "Product": prod.Title = view.TextField.StringValue; break; case "Details": prod.Description = view.TextField.StringValue; break; } }; // Setup view based on the column selected switch (tableColumn.Title) { case "Product": view.ImageView.Image = NSImage.ImageNamed (product.IsProductGroup ? "tags.png" : "tag.png"); view.TextField.StringValue = product.Title; break; case "Details": view.TextField.StringValue = product.Description; break; } return view; }
public override void SelectionDidChange(NSNotification notification) { switch (plotView.Model.Title) { case "Потерянное время": plotView.Model = PlotMaker .LostTimeComparePlot(((Interval)outlineView.ItemAtRow(outlineView.SelectedRow)).Row, maxTimeLost); break; case "ГПУ": plotView.Model = PlotMaker .GPUComparePlot(((Interval)outlineView.ItemAtRow(outlineView.SelectedRow)).Row, maxTimeGPU); break; } }
public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { // Cast item var product = item as Product; // This pattern allows you reuse existing views when they are no-longer in use. // If the returned view is null, you instance up a new view // If a non-null view is returned, you modify it enough to reflect the new data NSTextField view = (NSTextField)outlineView.MakeView(tableColumn.Title, this); if (view == null) { view = new NSTextField(); view.Identifier = tableColumn.Title; view.BackgroundColor = NSColor.Clear; view.Bordered = false; view.Selectable = false; view.Editable = !product.IsProductGroup; } // Tag view view.Tag = outlineView.RowForItem(item); // Allow for edit view.EditingEnded += (sender, e) => { // Grab product var prod = outlineView.ItemAtRow(view.Tag) as Product; // Take action based on type switch (view.Identifier) { case "Product": prod.Title = view.StringValue; break; case "Details": prod.Description = view.StringValue; break; } }; // Setup view based on the column selected switch (tableColumn.Title) { case "Product": view.StringValue = product.Title; break; case "Details": view.StringValue = product.Description; break; } return(view); }
partial void AddObject(NSObject sender) { nint row = MainOutlineView.SelectedRow; if (isObjectSelected(row)) { DirectoryNode node = MainOutlineView.ItemAtRow(row) as DirectoryNode; node.ShowAddWindow(); } }
public override NSIndexSet GetSelectionIndexes(NSOutlineView outlineView, NSIndexSet proposedSelectionIndexes) { if (updating) { return(proposedSelectionIndexes); } Notify(() => { owner.OnSelect?.Invoke( proposedSelectionIndexes .Select(row => outlineView.ItemAtRow((nint)row)) .OfType <NSNodeItem>() .Select(n => n.ModelNode) .ToArray() ); }); return(proposedSelectionIndexes); }
public void OnOutlineViewDoubleClicked(object sender, EventArgs e) { NSOutlineView obj = sender as NSOutlineView; if (obj != null) { nint row = obj.SelectedRow; if (row >= 0) { NSObject item = obj.ItemAtRow(row); if (item is DirectoryNode) { DirectoryNode node = item as DirectoryNode; LdapPropertiesWindowController awc = new LdapPropertiesWindowController(node.Name, node.ServerDTO); NSApplication.SharedApplication.RunModalForWindow(awc.Window); node.RefreshProperties(); MainTableView.DataSource = new PropertiesTableViewDataSource(node.NodeProperties); RefreshTableViewBasedOnSelection(row); } } } }
void ShowFolderSeletionPage() { Header = Properties_Resources.Which; Description = ""; bool firstRepo = true; Repositories = new List <RootFolder>(); Loader = new Dictionary <string, AsyncNodeLoader> (); foreach (KeyValuePair <String, String> repository in Controller.repositories) { RootFolder repo = new RootFolder() { Name = repository.Value, Id = repository.Key, Address = Controller.saved_address.ToString() }; Repositories.Add(repo); if (firstRepo) { repo.Selected = true; firstRepo = false; } else { repo.Selected = false; } CmisRepoCredentials cred = new CmisRepoCredentials() { UserName = Controller.saved_user, Password = Controller.saved_password, Address = Controller.saved_address, RepoId = repository.Key }; AsyncNodeLoader asyncLoader = new AsyncNodeLoader(repo, cred, PredefinedNodeLoader.LoadSubFolderDelegate, PredefinedNodeLoader.CheckSubFolderDelegate); asyncLoader.UpdateNodeEvent += delegate { InvokeOnMainThread(delegate { DataSource.UpdateCmisTree(repo); NSOutlineView view = OutlineController.OutlineView(); for (int i = 0; i < view.RowCount; ++i) { view.ReloadItem(view.ItemAtRow(i)); } }); }; asyncLoader.Load(repo); Loader.Add(repo.Id, asyncLoader); } DataSource = new CmisTree.CmisTreeDataSource(Repositories); DataSource.SelectedEvent += delegate(NSCmisTree cmis, int selected) { InvokeOnMainThread(delegate { RootFolder selectedRoot = null; foreach (RootFolder root in Repositories) { Node node = cmis.GetNode(root); if (node != null) { if (node.Parent == null && node.Selected == false) { selectedRoot = root; } node.Selected = (selected != 0); DataSource.UpdateCmisTree(root); } } NSOutlineView view = OutlineController.OutlineView(); if (selectedRoot != null) { foreach (RootFolder root in Repositories) { if (root != selectedRoot) { root.Selected = false; DataSource.UpdateCmisTree(root); } } view.ReloadData(); } else { for (int i = 0; i < view.RowCount; ++i) { view.ReloadItem(view.ItemAtRow(i)); } } }); }; DataDelegate = new OutlineViewDelegate(); OutlineController = new CmisOutlineController(DataSource, DataDelegate); ContinueButton = new NSButton() { Title = Properties_Resources.Continue, Enabled = (Repositories.Count > 0) }; CancelButton = new NSButton() { Title = Properties_Resources.Cancel }; NSButton BackButton = new NSButton() { Title = Properties_Resources.Back }; // DataDelegate.SelectionChanged += delegate // { // InvokeOnMainThread(delegate { // NSOutlineView view = OutlineController.OutlineView(); // if (view.SelectedRow >= 0) { // ContinueButton.Enabled = true; // } else { // ContinueButton.Enabled = false; // } // }); // }; DataDelegate.ItemExpanded += delegate(NSNotification notification) { InvokeOnMainThread(delegate { NSCmisTree cmis = notification.UserInfo["NSObject"] as NSCmisTree; if (cmis == null) { Console.WriteLine("ItemExpanded Error"); return; } NSCmisTree cmisRoot = cmis; while (cmisRoot.Parent != null) { cmisRoot = cmisRoot.Parent; } RootFolder root = Repositories.Find(x => x.Name.Equals(cmisRoot.Name)); if (root == null) { Console.WriteLine("ItemExpanded find root Error"); return; } Node node = cmis.GetNode(root); if (node == null) { Console.WriteLine("ItemExpanded find node Error"); return; } Loader[root.Id].Load(node); }); }; ContinueButton.Activated += delegate { InvokeOnMainThread(delegate { NSOutlineView view = OutlineController.OutlineView(); // NSCmisTree cmis = (NSCmisTree)(view.ItemAtRow(view.SelectedRow)); // while (cmis.Parent != null) // cmis = cmis.Parent; // RootFolder root = Repositories.Find(x=>x.Name.Equals(cmis.Name)); RootFolder root = Repositories.Find(x => (x.Selected != false)); if (root != null) { foreach (AsyncNodeLoader task in Loader.Values) { task.Cancel(); } Controller.saved_repository = root.Id; List <string> ignored = NodeModelUtils.GetIgnoredFolder(root); List <string> selected = NodeModelUtils.GetSelectedFolder(root); Controller.Add2PageCompleted(root.Id, root.Path, ignored.ToArray(), selected.ToArray()); } }); }; CancelButton.Activated += delegate { InvokeOnMainThread(delegate { foreach (AsyncNodeLoader task in Loader.Values) { task.Cancel(); } Controller.PageCancelled(); }); }; BackButton.Activated += delegate { InvokeOnMainThread(delegate { foreach (AsyncNodeLoader task in Loader.Values) { task.Cancel(); } Controller.BackToPage1(); }); }; OutlineController.View.Frame = new RectangleF(190, 60, 400, 240); ContentView.AddSubview(OutlineController.View); Buttons.Add(ContinueButton); Buttons.Add(BackButton); Buttons.Add(CancelButton); }
public static IEnumerable <NSObject> GetSelectedItems(this NSOutlineView outlineView) { return(GetSelectedIndices(outlineView) .Select(i => outlineView.ItemAtRow(i))); }
/// <summary> /// Create the UI /// </summary> private void CreateEdit() { RootFolder repo = new RootFolder() { Name = FolderName, Id = credentials.RepoId, Address = credentials.Address.ToString() }; repo.Selected = true; IgnoredFolderLoader.AddIgnoredFolderToRootNode(repo, Ignores); LocalFolderLoader.AddLocalFolderToRootNode(repo, localPath); List <RootFolder> repos = new List <RootFolder>(); repos.Add(repo); OutlineViewDelegate DataDelegate = new OutlineViewDelegate(); CmisTree.CmisTreeDataSource DataSource = new CmisTree.CmisTreeDataSource(repos); CmisOutlineController OutlineController = new CmisOutlineController(DataSource, DataDelegate); AsyncNodeLoader asyncLoader = new AsyncNodeLoader(repo, credentials, PredefinedNodeLoader.LoadSubFolderDelegate, PredefinedNodeLoader.CheckSubFolderDelegate); asyncLoader.UpdateNodeEvent += delegate { InvokeOnMainThread(delegate { DataSource.UpdateCmisTree(repo); NSOutlineView view = OutlineController.OutlineView(); for (int i = 0; i < view.RowCount; ++i) { view.ReloadItem(view.ItemAtRow(i)); } }); }; asyncLoader.Load(repo); DataDelegate.ItemExpanded += delegate(NSNotification notification) { InvokeOnMainThread(delegate { NSCmisTree cmis = notification.UserInfo["NSObject"] as NSCmisTree; if (cmis == null) { Console.WriteLine("ItemExpanded Error"); return; } NSCmisTree cmisRoot = cmis; while (cmisRoot.Parent != null) { cmisRoot = cmisRoot.Parent; } if (repo.Name != cmisRoot.Name) { Console.WriteLine("ItemExpanded find root Error"); return; } Node node = cmis.GetNode(repo); if (node == null) { Console.WriteLine("ItemExpanded find node Error"); return; } asyncLoader.Load(node); }); }; DataSource.SelectedEvent += delegate(NSCmisTree cmis, int selected) { InvokeOnMainThread(delegate { Node node = cmis.GetNode(repo); if (node == null) { Console.WriteLine("SelectedEvent find node Error"); } node.Selected = (selected != 0); DataSource.UpdateCmisTree(repo); NSOutlineView view = OutlineController.OutlineView(); for (int i = 0; i < view.RowCount; ++i) { try{ view.ReloadItem(view.ItemAtRow(i)); }catch (Exception e) { Console.WriteLine(e); } } }); }; OutlineController.View.Frame = new RectangleF(190, 60, 400, 240); ContentView.AddSubview(OutlineController.View); Controller.CloseWindowEvent += delegate { asyncLoader.Cancel(); }; Controller.OpenWindowEvent += delegate { InvokeOnMainThread(delegate { OrderFrontRegardless(); }); }; NSButton finish_button = new NSButton() { Title = Properties_Resources.SaveChanges, }; NSButton cancel_button = new NSButton() { Title = Properties_Resources.DiscardChanges }; Buttons.Add(finish_button); Buttons.Add(cancel_button); finish_button.Activated += delegate { Ignores = NodeModelUtils.GetIgnoredFolder(repo); Controller.SaveFolder(); InvokeOnMainThread(delegate { PerformClose(this); }); }; cancel_button.Activated += delegate { InvokeOnMainThread(delegate { PerformClose(this); }); }; this.Header = Properties_Resources.EditTitle; this.Description = ""; this.ShowAll(); }