public Color GetColor(RDMPCollection collection) { switch (collection) { case RDMPCollection.None: return(SystemColors.Control); case RDMPCollection.Tables: return(Color.FromArgb(255, 220, 255)); case RDMPCollection.Catalogue: return(Color.FromArgb(255, 255, 220)); case RDMPCollection.DataExport: return(Color.FromArgb(200, 255, 220)); case RDMPCollection.SavedCohorts: return(Color.FromArgb(255, 220, 220)); case RDMPCollection.Favourites: return(SystemColors.Control); case RDMPCollection.Cohort: return(Color.FromArgb(210, 240, 255)); case RDMPCollection.DataLoad: return(Color.DarkGray); default: throw new ArgumentOutOfRangeException("collection"); } }
private void CreateColorIndicator(TreeListView tree, RDMPCollection collection) { if (Tree.Parent == null || collection == RDMPCollection.None) { return; } var indicatorHeight = BackColorProvider.IndiciatorBarSuggestedHeight; BackColorProvider p = new BackColorProvider(); var ctrl = new Control(); ctrl.BackColor = p.GetColor(collection); ctrl.Location = new Point(Tree.Location.X, tree.Location.Y - indicatorHeight); ctrl.Height = indicatorHeight; ctrl.Width = Tree.Width; if (Tree.Dock != DockStyle.None) { ctrl.Dock = DockStyle.Top; } else { ctrl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; } Tree.Parent.Controls.Add(ctrl); }
/// <summary> /// Brings the specified collection to the front (must already be visible) /// </summary> /// <param name="collection"></param> public void Pop(RDMPCollection collection) { if (_visibleToolboxes.ContainsKey(collection)) { switch (_visibleToolboxes[collection].DockState) { case DockState.DockLeftAutoHide: _visibleToolboxes[collection].DockState = DockState.DockLeft; break; case DockState.DockRightAutoHide: _visibleToolboxes[collection].DockState = DockState.DockRight; break; case DockState.DockTopAutoHide: _visibleToolboxes[collection].DockState = DockState.DockTop; break; case DockState.DockBottomAutoHide: _visibleToolboxes[collection].DockState = DockState.DockBottom; break; } _visibleToolboxes[collection].Activate(); } }
public RDMPConcept GetConceptForCollection(RDMPCollection rdmpCollection) { switch (rdmpCollection) { case RDMPCollection.None: return(RDMPConcept.NoIconAvailable); case RDMPCollection.Tables: return(RDMPConcept.TableInfo); case RDMPCollection.Catalogue: return(RDMPConcept.Catalogue); case RDMPCollection.DataExport: return(RDMPConcept.Project); case RDMPCollection.SavedCohorts: return(RDMPConcept.AllCohortsNode); case RDMPCollection.Favourites: return(RDMPConcept.Favourite); case RDMPCollection.Cohort: return(RDMPConcept.CohortIdentificationConfiguration); case RDMPCollection.DataLoad: return(RDMPConcept.LoadMetadata); default: throw new ArgumentOutOfRangeException("rdmpCollection"); } }
public Image GetBackgroundImage(Size size, RDMPCollection collection) { var bmp = new Bitmap(size.Width, size.Height); using (var g = Graphics.FromImage(bmp)) g.FillRectangle(new SolidBrush(GetColor(collection)), 2, size.Height - IndiciatorBarSuggestedHeight, size.Width - 4, IndiciatorBarSuggestedHeight); return(bmp); }
public bool IsRootObjectOfCollection(RDMPCollection collection, object rootObject) { //if the collection an arbitrary one then it is definetly not the root collection for anyone if (collection == RDMPCollection.None) { return(false); } return(_windowManager.GetCollectionForRootObject(rootObject) == collection); }
public Bitmap DrawBottomBar(Bitmap image, RDMPCollection collection) { var newImage = new Bitmap(image.Width, image.Height); using (var g = Graphics.FromImage(newImage)) { g.FillRectangle(new SolidBrush(GetColor(collection)), 0, 0, newImage.Width, newImage.Height); g.DrawImage(image, 0, 0); } return(newImage); }
private void ToolboxButtonClicked(object sender, EventArgs e) { RDMPCollection collection = ButtonToEnum(sender); if (_manager.IsVisible(collection)) { _manager.Pop(collection); } else { _manager.Create(collection); } }
private PersistableToolboxDockContent Show(RDMPCollection collection, RDMPCollectionUI control, string label, Bitmap image) { BackColorProvider c = new BackColorProvider(); image = c.DrawBottomBar(image, collection); var content = _windowFactory.Create(ActivateItems, control, label, image, collection);//these are collections so are not tracked with a window tracker. content.Closed += (s, e) => content_Closed(collection); _visibleToolboxes.Add(collection, content); content.Show(_mainDockPanel, DockState.DockLeft); return(content); }
/// <summary> /// Attempts to ensure that a compatible RDMPCollectionUI is made visible for the supplied object which must be one of the expected root Tree types of /// an RDMPCollectionUI. For example Project is the a root object of DataExportCollectionUI. If a matching collection is already visible or no collection /// supports the supplied object as a root object then nothing will happen. Otherwise the coresponding collection will be shown /// </summary> /// <param name="root"></param> public void ShowCollectionWhichSupportsRootObjectType(object root) { RDMPCollection collection = GetCollectionForRootObject(root); if (collection == RDMPCollection.None) { return; } if (IsVisible(collection)) { Pop(collection); return; } Create(collection); }
public NavigateToObjectUI(IActivateItems activator, string initialSearchQuery = null, RDMPCollection focusedCollection = RDMPCollection.None) : base(activator) { _coreIconProvider = activator.CoreIconProvider; _favouriteProvider = Activator.FavouritesProvider; _magnifier = FamFamFamIcons.magnifier; InitializeComponent(); CompletionAction = Emphasise; activator.Theme.ApplyTo(toolStrip1); _searchables = Activator.CoreChildProvider.GetAllSearchables(); _usefulPropertyFinder = new AttributePropertyFinder <UsefulPropertyAttribute>(_searchables.Keys); textBox1.Focus(); textBox1.Text = initialSearchQuery; textBox1.TextChanged += tbFind_TextChanged; textBox1.KeyUp += _scintilla_KeyUp; FetchMatches(initialSearchQuery, CancellationToken.None); StartPosition = FormStartPosition.CenterScreen; DoubleBuffered = true; _types = _searchables.Keys.Select(k => k.GetType()).Distinct().ToArray(); _typeNames = new HashSet <string>(_types.Select(t => t.Name)); foreach (Type t in StartingEasyFilters.SelectMany(v => v.Value)) { if (!_typeNames.Contains(t.Name)) { _typeNames.Add(t.Name); } } //autocomplete is all Type names (e.g. "Catalogue") + all short codes (e.g. "c") textBox1.AutoCompleteMode = AutoCompleteMode.Append; textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource; textBox1.AutoCompleteCustomSource.AddRange( _typeNames.Union(ShortCodes.Select(kvp => kvp.Key)).ToArray()); Type[] startingFilters = null; if (focusedCollection != RDMPCollection.None && StartingEasyFilters.ContainsKey(focusedCollection)) { startingFilters = StartingEasyFilters[focusedCollection]; } BackColorProvider backColorProvider = new BackColorProvider(); foreach (Type t in EasyFilterTypesAndAssociatedCollections.Keys) { var b = new ToolStripButton(); b.Image = activator.CoreIconProvider.GetImage(t); b.CheckOnClick = true; b.Tag = t; b.DisplayStyle = ToolStripItemDisplayStyle.Image; string shortCode = ShortCodes.Single(kvp => kvp.Value == t).Key; b.Text = $"{t.Name} ({shortCode})"; b.CheckedChanged += CollectionCheckedChanged; b.Checked = startingFilters != null && startingFilters.Contains(t); b.BackgroundImage = backColorProvider.GetBackgroundImage(b.Size, EasyFilterTypesAndAssociatedCollections[t]); toolStrip1.Items.Add(b); } }
public PersistableToolboxDockContent Create(IActivateItems activator,Control control, string label, Bitmap image, RDMPCollection collection) { var content = new PersistableToolboxDockContent(collection); AddControlToDockContent(activator, control, content, label, image); return content; }
public RDMPCollectionCreatedEventHandlerArgs(RDMPCollection collection) { Collection = collection; }
public bool IsRootObjectOfCollection(RDMPCollection collection, object rootObject) { throw new NotImplementedException(); }
private void content_Closed(RDMPCollection collection) { //no longer visible _visibleToolboxes.Remove(collection); }
/// <summary> /// Closes the specified RDMPCollectionUI (must be open - use IsVisible to check this) /// </summary> /// <param name="collection"></param> public void Destroy(RDMPCollection collection) { _visibleToolboxes[collection].Close(); }
public PersistableToolboxDockContent(RDMPCollection collectionType) { CollectionType = collectionType; }
/// <summary> /// Returns true if the corresponding RDMPCollectionUI is open (even if it is burried under other windows). /// </summary> /// <param name="collection"></param> /// <returns></returns> public bool IsVisible(RDMPCollection collection) { return(_visibleToolboxes.ContainsKey(collection)); }
/// <summary> /// Sets up common functionality for an RDMPCollectionUI with the default settings /// </summary> /// <param name="collection"></param> /// <param name="tree">The main tree in the collection UI</param> /// <param name="activator">The current activator, used to launch objects, register for refresh events etc </param> /// <param name="iconColumn">The column of tree view which should contain the icon for each row object</param> /// <param name="renameableColumn">Nullable field for specifying which column supports renaming on F2</param> public void SetUp(RDMPCollection collection, TreeListView tree, IActivateItems activator, OLVColumn iconColumn, OLVColumn renameableColumn) { SetUp(collection, tree, activator, iconColumn, renameableColumn, new RDMPCollectionCommonFunctionalitySettings()); }
/// <summary> /// Creates a new instance of the given RDMPCollectionUI specified by the Enum collectionToCreate at the specified dock position /// </summary> /// <param name="collectionToCreate"></param> /// <param name="position"></param> /// <returns></returns> public PersistableToolboxDockContent Create(RDMPCollection collectionToCreate, DockState position = DockState.DockLeft) { PersistableToolboxDockContent toReturn; RDMPCollectionUI collection; switch (collectionToCreate) { case RDMPCollection.Catalogue: collection = new CatalogueCollectionUI(); toReturn = Show(RDMPCollection.Catalogue, collection, "Catalogues", CatalogueIcons.Catalogue); break; case RDMPCollection.DataLoad: collection = new LoadMetadataCollectionUI(); toReturn = Show(RDMPCollection.DataLoad, collection, "Load Configurations", CatalogueIcons.LoadMetadata); break; case RDMPCollection.Tables: collection = new TableInfoCollectionUI(); toReturn = Show(RDMPCollection.Tables, collection, "Tables", CatalogueIcons.TableInfo); break; case RDMPCollection.DataExport: if (RepositoryLocator.DataExportRepository == null) { WideMessageBox.Show("Data export database unavailable", "Cannot create DataExport Toolbox because DataExportRepository has not been set/created yet"); return(null); } collection = new DataExportCollectionUI(); toReturn = Show(RDMPCollection.DataExport, collection, "Data Export", CatalogueIcons.Project); break; case RDMPCollection.Cohort: collection = new CohortIdentificationCollectionUI(); toReturn = Show(RDMPCollection.Cohort, collection, "Cohort Builder", CatalogueIcons.CohortIdentificationConfiguration); break; case RDMPCollection.SavedCohorts: collection = new SavedCohortsCollectionUI(); toReturn = Show(RDMPCollection.SavedCohorts, collection, "Saved Cohorts", CatalogueIcons.AllCohortsNode); break; case RDMPCollection.Favourites: collection = new FavouritesCollectionUI(); toReturn = Show(RDMPCollection.Favourites, collection, "Favourites", CatalogueIcons.Favourite); break; default: throw new ArgumentOutOfRangeException("collectionToCreate"); } toReturn.DockState = position; collection.SetItemActivator(ActivateItems); if (CollectionCreated != null) { CollectionCreated(this, new RDMPCollectionCreatedEventHandlerArgs(collectionToCreate)); } return(toReturn); }
/// <summary> /// Sets up common functionality for an RDMPCollectionUI /// </summary> /// <param name="collection"></param> /// <param name="tree">The main tree in the collection UI</param> /// <param name="activator">The current activator, used to launch objects, register for refresh events etc </param> /// <param name="iconColumn">The column of tree view which should contain the icon for each row object</param> /// <param name="renameableColumn">Nullable field for specifying which column supports renaming on F2</param> /// <param name="settings">Customise which common behaviorurs are turned on</param> public void SetUp(RDMPCollection collection, TreeListView tree, IActivateItems activator, OLVColumn iconColumn, OLVColumn renameableColumn, RDMPCollectionCommonFunctionalitySettings settings) { Settings = settings; _collection = collection; IsSetup = true; _activator = activator; _activator.RefreshBus.Subscribe(this); RepositoryLocator = _activator.RepositoryLocator; Tree = tree; Tree.FullRowSelect = true; Tree.HideSelection = false; Tree.KeyPress += Tree_KeyPress; Tree.RevealAfterExpand = true; if (!Settings.SuppressChildrenAdder) { Tree.CanExpandGetter += CanExpandGetter; Tree.ChildrenGetter += ChildrenGetter; } if (!Settings.SuppressActivate) { Tree.ItemActivate += CommonItemActivation; } Tree.CellRightClick += CommonRightClick; Tree.SelectionChanged += (s, e) => RefreshContextMenuStrip(); if (iconColumn != null) { iconColumn.ImageGetter += ImageGetter; } if (Tree.RowHeight != 19) { Tree.RowHeight = 19; } //add colour indicator bar Tree.Location = new Point(Tree.Location.X, tree.Location.Y + 3); Tree.Height -= 3; CreateColorIndicator(Tree, collection); //what does this do to performance? Tree.UseNotifyPropertyChanged = true; ParentFinder = new TreeNodeParentFinder(Tree); DragDropProvider = new DragDropProvider( _activator.CommandFactory, _activator.CommandExecutionFactory, tree); if (renameableColumn != null) { RenameProvider = new RenameProvider(_activator, tree, renameableColumn); RenameProvider.RegisterEvents(); } if (Settings.AddFavouriteColumn) { FavouriteColumnProvider = new FavouriteColumnProvider(_activator, tree); FavouriteColumn = FavouriteColumnProvider.CreateColumn(); } if (settings.AddIDColumn) { IDColumnProvider = new IDColumnProvider(tree); IDColumn = IDColumnProvider.CreateColumn(); Tree.AllColumns.Add(IDColumn); Tree.RebuildColumns(); } if (Settings.AddCheckColumn) { CheckColumnProvider = new CheckColumnProvider(tree, _activator.CoreIconProvider); CheckColumn = CheckColumnProvider.CreateColumn(); Tree.AllColumns.Add(CheckColumn); Tree.RebuildColumns(); } CoreIconProvider = activator.CoreIconProvider; CopyPasteProvider = new CopyPasteProvider(); CopyPasteProvider.RegisterEvents(tree); CoreChildProvider = _activator.CoreChildProvider; _activator.Emphasise += _activator_Emphasise; Tree.TreeFactory = TreeFactoryGetter; Tree.RebuildAll(true); Tree.FormatRow += Tree_FormatRow; Tree.CellToolTipGetter += Tree_CellToolTipGetter; if (Settings.AllowSorting) { if (Tree.PrimarySortColumn == null) { Tree.PrimarySortColumn = Tree.AllColumns.FirstOrDefault(c => c.IsVisible && c.Sortable); } //persist user sort orders if (TreeGuids.ContainsKey(_collection)) { //if we know the sort order fo this collection last time var lastSort = UserSettings.GetLastColumnSortForCollection(TreeGuids[_collection]); //reestablish that sort order if (lastSort != null && Tree.AllColumns.Any(c => c.Text == lastSort.Item1)) { Tree.PrimarySortColumn = Tree.GetColumn(lastSort.Item1); Tree.PrimarySortOrder = lastSort.Item2 ? SortOrder.Ascending : SortOrder.Descending; } //and track changes to the sort order Tree.AfterSorting += TreeOnAfterSorting; } } else { foreach (OLVColumn c in Tree.AllColumns) { c.Sortable = false; } } }
public RDMPContextMenuStrip CreateMenu(IActivateItems activator, TreeListView tree, RDMPCollection collection, params IAtomicCommand[] commands) { var toReturn = new RDMPContextMenuStrip(new RDMPContextMenuStripArgs(activator, tree, collection), collection); foreach (IAtomicCommand command in commands) { toReturn.Items.Add(CreateMenuItem(command)); } return(toReturn); }
/// <summary> /// Sets up common functionality for an RDMPCollectionUI /// </summary> /// <param name="collection"></param> /// <param name="tree">The main tree in the collection UI</param> /// <param name="activator">The current activator, used to launch objects, register for refresh events etc </param> /// <param name="iconColumn">The column of tree view which should contain the icon for each row object</param> /// <param name="renameableColumn">Nullable field for specifying which column supports renaming on F2</param> /// <param name="settings">Customise which common behaviorurs are turned on</param> public void SetUp(RDMPCollection collection, TreeListView tree, IActivateItems activator, OLVColumn iconColumn, OLVColumn renameableColumn, RDMPCollectionCommonFunctionalitySettings settings) { Settings = settings; _collection = collection; IsSetup = true; _activator = activator; _activator.RefreshBus.Subscribe(this); RepositoryLocator = _activator.RepositoryLocator; Tree = tree; Tree.FullRowSelect = true; Tree.HideSelection = false; Tree.KeyPress += Tree_KeyPress; Tree.CellToolTip.InitialDelay = UserSettings.TooltipAppearDelay; Tree.CellToolTipShowing += Tree_CellToolTipShowing; Tree.RevealAfterExpand = true; if (!Settings.SuppressChildrenAdder) { Tree.CanExpandGetter += CanExpandGetter; Tree.ChildrenGetter += ChildrenGetter; } if (!Settings.SuppressActivate) { Tree.ItemActivate += CommonItemActivation; } Tree.CellRightClick += CommonRightClick; Tree.KeyUp += CommonKeyPress; if (iconColumn != null) { iconColumn.ImageGetter += ImageGetter; } if (Tree.RowHeight != 19) { Tree.RowHeight = 19; } //add colour indicator bar Tree.Location = new Point(Tree.Location.X, tree.Location.Y + 3); Tree.Height -= 3; CreateColorIndicator(Tree, collection); //what does this do to performance? Tree.UseNotifyPropertyChanged = true; ParentFinder = new TreeNodeParentFinder(Tree); DragDropProvider = new DragDropProvider( _activator.CommandFactory, _activator.CommandExecutionFactory, tree); if (renameableColumn != null) { RenameProvider = new RenameProvider(_activator, tree, renameableColumn); RenameProvider.RegisterEvents(); } if (Settings.AddFavouriteColumn) { FavouriteColumnProvider = new FavouriteColumnProvider(_activator, tree); FavouriteColumn = FavouriteColumnProvider.CreateColumn(); SetupColumnTracking(FavouriteColumn, new Guid("ab25aa56-957c-4d1b-b395-48299be8e467")); } if (settings.AddIDColumn) { IDColumnProvider = new IDColumnProvider(tree); IDColumn = IDColumnProvider.CreateColumn(); Tree.AllColumns.Add(IDColumn); SetupColumnTracking(IDColumn, new Guid("9d567d9c-06f5-41b6-9f0d-e630a0e23f3a")); Tree.RebuildColumns(); } if (Settings.AddCheckColumn) { CheckColumnProvider = new CheckColumnProvider(tree, _activator.CoreIconProvider); CheckColumn = CheckColumnProvider.CreateColumn(); SetupColumnTracking(CheckColumn, new Guid("8d9c6a0f-82a8-4f4e-b058-e3017d8d60e0")); Tree.AllColumns.Add(CheckColumn); Tree.RebuildColumns(); } CoreIconProvider = activator.CoreIconProvider; CopyPasteProvider = new CopyPasteProvider(); CopyPasteProvider.RegisterEvents(tree); CoreChildProvider = _activator.CoreChildProvider; _activator.Emphasise += _activator_Emphasise; Tree.TreeFactory = TreeFactoryGetter; Tree.RebuildAll(true); Tree.FormatRow += Tree_FormatRow; Tree.KeyDown += Tree_KeyDown; if (Settings.AllowSorting) { SetupColumnSortTracking(Tree, TreeGuids.ContainsKey(collection) ? TreeGuids[collection] : Guid.Empty); } else { foreach (OLVColumn c in Tree.AllColumns) { c.Sortable = false; } } }