/// <summary> /// Adds a UserControl to the main component container /// </summary> /// <param name = "control">UserControl element</param> /// <param name = "controlTabTitle">The title to give the tab element</param> public void AddMainComponent(UserControl control, string controlTabTitle) { try { Framework.EventBus.Publish(new PanelEvent(this)); var alreadyOpen = false; DocumentContent focusThis = null; foreach (DocumentContent cCtrl in this.MainComponentContainer.Items) { if (cCtrl.Tag.ToString().CompareTo(controlTabTitle) == 0) { alreadyOpen = true; focusThis = cCtrl; } } if (alreadyOpen == false) { var title = controlTabTitle; if (controlTabTitle.Contains("\\")) { var parts = controlTabTitle.Split('\\'); title = parts[parts.Length - 1]; } var newContentControl = new ContentControl { Margin = new Thickness(0), Content = control }; var newDocumentContent = new DocumentContent { Title = title, Background = Brushes.White, Content = newContentControl, Icon = Framework.Images.GetImage("CutHS", "VS2010ImageLibrary", 12).Source, Tag = controlTabTitle }; newDocumentContent.Closing += this.NewDocumentContentClosing; this.MainComponentContainer.Items.Add(newDocumentContent); newDocumentContent.Show(this.dockManager); newDocumentContent.Activate(); } else { focusThis.Show(this.dockManager); focusThis.Activate(); var newWindow = ( IUserControl )control; newWindow.Dispose(); } control.Focus(); control.BringIntoView(); } catch (Exception error) { Framework.EventBus.Publish(error); } }
/// <summary> /// Requests the Panel realizer to add a User control to its display /// </summary> /// <param name = "control">The user control</param> /// <param name = "toolbarName">The title on the toolbar header</param> /// <param name = "image">The image icon assoacited with the control</param> public void AddSideComponent(UserControl control, string toolbarName, Image image) { if (control == null) { return; } try { Framework.EventBus.Publish(new PanelEvent(this)); var shown = false; foreach (DockableContent tabEntry in this.SideBarExplorer.Items) { if (tabEntry.Content == control) { shown = true; tabEntry.Show(this.dockManager); tabEntry.Activate(); } } if (control.Parent == null && shown == false) { var aSideBarcontrol = new DockableContent { Background = Brushes.White, Title = toolbarName, Icon = image.Source, Content = control, ToolTip = toolbarName, HideOnClose = false, IsLocked = false }; aSideBarcontrol.Closing += this.ASideBarcontrolClosing; this.SideBarExplorer.Items.Add(aSideBarcontrol); aSideBarcontrol.Show(this.dockManager); aSideBarcontrol.Activate(); } control.Focus(); control.BringIntoView(); } catch (Exception error) { Framework.EventBus.Publish(error); } }
private void FilterEntityAttributes(UserControl selectedControl) { ToggleControls(false, Properties.OutputStrings.FilteringAttributesFormat1, _entityName); this.lstVwAttributes.Dispatcher.Invoke(() => { lstVwAttributes.RowDefinitions.Clear(); lstVwAttributes.Children.Clear(); }); var list = _listAttributeControls.OfType <IAttributeMetadataControl <AttributeMetadata> >(); var textName = string.Empty; this.txtBFilterAttribute.Dispatcher.Invoke(() => { textName = txtBFilterAttribute.Text.Trim(); }); if (!string.IsNullOrEmpty(textName)) { textName = textName.ToLower(); if (Guid.TryParse(textName, out Guid tempGuid)) { list = list.Where(ent => ent.AttributeMetadata.MetadataId == tempGuid); } else { list = list .Where(ent => (selectedControl != null && ent == selectedControl) || ent.AttributeMetadata.LogicalName.IndexOf(textName, StringComparison.InvariantCultureIgnoreCase) > -1 || ( ent.AttributeMetadata.DisplayName != null && ent.AttributeMetadata.DisplayName.LocalizedLabels != null && ent.AttributeMetadata.DisplayName.LocalizedLabels .Where(l => !string.IsNullOrEmpty(l.Label)) .Any(lbl => lbl.Label.IndexOf(textName, StringComparison.InvariantCultureIgnoreCase) > -1) ) ); } } this.lstVwAttributes.Dispatcher.Invoke(() => { int index = 0; foreach (var item in list.OrderBy(a => a.AttributeMetadata.LogicalName)) { if (item is UserControl control) { var itemRowDef = new RowDefinition() { Height = new GridLength(10, GridUnitType.Auto), }; lstVwAttributes.RowDefinitions.Add(itemRowDef); control.VerticalAlignment = VerticalAlignment.Stretch; control.HorizontalAlignment = HorizontalAlignment.Stretch; Grid.SetRow(control, index); lstVwAttributes.Children.Add(control); index++; if (item is MemoAttributeMetadataControl || item is MultiSelectPicklistAttributeMetadataControl ) { itemRowDef.Height = new GridLength(200, GridUnitType.Pixel); lstVwAttributes.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(5), }); var splitter = new GridSplitter() { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, Height = 5, }; Grid.SetRow(splitter, index); lstVwAttributes.Children.Add(splitter); index++; } } } var last = lstVwAttributes.Children.OfType <UIElement>().LastOrDefault(); if (last != null && last is GridSplitter) { lstVwAttributes.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30), }); } if (selectedControl != null) { selectedControl.BringIntoView(); selectedControl.Focus(); } }); ToggleControls(true, Properties.OutputStrings.FilteringAttributesCompletedFormat1, _entityName); }
private void Button_Click_1(object sender, RoutedEventArgs e) { UserControl vercontr = new UserControl(); vercontr.BringIntoView(); }