protected LayoutAnchorable _ShowContent(object obj) { LayoutAnchorable a = new LayoutAnchorable(); if (obj is IPlatformClass) { IPlatformClass pc = (IPlatformClass)obj; if (pc.Vertex.Get(@"BaseEdge:\To:") != null && pc.Vertex.Get(@"BaseEdge:\To:").Value != null && (!GeneralUtil.CompareStrings(pc.Vertex.Get(@"BaseEdge:\To:").Value, ""))) { a.Title = pc.Vertex.Get(@"BaseEdge:\To:").Value.ToString(); } else { a.Title = (string)pc.Vertex.Value; } PlatformClassSimpleWrapper pcsw = new PlatformClassSimpleWrapper(); pcsw.SetContent(pc); a.Content = pcsw; a.IsVisibleChanged += pcsw.HideEventHandler; //a.Closing +=pcsw.ClosedEventHandler; a.Closed += pcsw.ClosedEventHandler; // not work - to focus //System.Windows.Input.Keyboard.Focus((IInputElement)pc); this.Pane.Children.Add(a); pcsw.IsIntialising = true; a.Hide(); // this works a.Show(); // for getting focus pcsw.IsIntialising = false; } else { a.Title = obj.ToString(); a.Content = obj; this.Pane.Children.Add(a); a.Hide(); // this works a.Show(); // for getting focus } //a.AddToLayout(this.dockingManager, AnchorableShowStrategy.Most); // maybe for later use return(a); }
private void AddOrShowView(ISubView view, bool show) { subviewmap[view.ContentID] = view; string viewname = view.ContentID; LayoutContent targetContent; LayoutAnchorable targetView; viewList.TryGetValue(viewname, out targetContent); targetView = targetContent as LayoutAnchorable; if (targetView == null) { targetView = new LayoutAnchorable(); viewList.Add(viewname, targetView); targetView.AddToLayout(DockMan, AnchorableShowStrategy.Most); targetView.DockAsDocument(); targetView.CanClose = false; targetView.Hide(); } if (targetView.Content == null) { targetView.Content = view.View; targetView.ContentId = viewname; targetView.Title = view.GetTitle(ResourceService.CurrentCulture); targetView.CanAutoHide = true; } if (show) { targetView.IsVisible = true; } }
/// <summary> /// Provides derived classes an opportunity to handle changes to the IsHidden property. /// </summary> protected virtual void OnIsHiddenChanged(DependencyPropertyChangedEventArgs e) { if (_anchorable != null) { if (_anchorable.IsHidden != (bool)e.NewValue) { if (_anchorable.IsHidden) { _anchorable.Show(); } else { _anchorable.Hide(); } } } }
private static void ToggleVisible(LayoutAnchorable Anchorable) { if (Anchorable.IsVisible) { Anchorable.Hide(); } else { Anchorable.Show(); } }
/// <summary> /// Just hides views if user is trying to close them. Will allow them /// to close if application is exiting. /// </summary> private void view_Closing(object sender, CancelEventArgs e) { if (exiting) { return; } e.Cancel = true; LayoutAnchorable layoutAnchorable = sender as LayoutAnchorable; layoutAnchorable.Hide(); }
public void ClearBindingOfHiddenWindowTest() { LayoutAnchorable layoutAnchorable = new LayoutAnchorable { FloatingWidth = 50, FloatingHeight = 100, ContentId = "Test" }; LayoutAnchorablePane layoutAnchorablePane = new LayoutAnchorablePane(layoutAnchorable); LayoutAnchorablePaneGroup layoutAnchorablePaneGroup = new LayoutAnchorablePaneGroup(layoutAnchorablePane); LayoutAnchorableFloatingWindow layoutFloatingWindow = new LayoutAnchorableFloatingWindow { RootPanel = layoutAnchorablePaneGroup }; var ctor = typeof(LayoutAnchorableFloatingWindowControl) .GetTypeInfo() .GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance) .First(x => x.GetParameters().Length == 1); LayoutAnchorableFloatingWindowControl floatingWindowControl = ctor.Invoke(new object[] { layoutFloatingWindow }) as LayoutAnchorableFloatingWindowControl; floatingWindowControl.SetBinding( UIElement.VisibilityProperty, new Binding("IsVisible") { Source = floatingWindowControl.Model, Converter = new BoolToVisibilityConverter(), Mode = BindingMode.OneWay, ConverterParameter = Visibility.Hidden }); BindingExpression visibilityBinding = floatingWindowControl.GetBindingExpression(UIElement.VisibilityProperty); Assert.IsNotNull(visibilityBinding); layoutAnchorable.Show(); layoutAnchorable.Hide(); visibilityBinding = floatingWindowControl.GetBindingExpression(UIElement.VisibilityProperty); Assert.IsNotNull(visibilityBinding); floatingWindowControl.Hide(); visibilityBinding = floatingWindowControl.GetBindingExpression(UIElement.VisibilityProperty); Assert.IsNull(visibilityBinding); }
void loadUIPanel() { foreach (IExteralUI ui in exteralUIs) { LayoutAnchorable layoutAnchorable = new LayoutAnchorable(); layoutAnchorable.ContentId = ui.name; layoutAnchorable.Title = ui.name; layoutAnchorable.CanClose = false; layoutAnchorable.Content = ui.content; ui.parent = layoutAnchorable; if (!ui.isActive) { layoutAnchorable.Hide(); } ProjectPane.Children.Add(layoutAnchorable); } }
private void ShowHideCamera(object sender, PropertyChangedEventArgs e) { //MIGHT NEED TO USE THIS CODE IN CASE IT CRASHES SAYING ITS TRYING TO ACCES FROM ANOTHER THREAD if (!this.Dispatcher.HasShutdownStarted && !this.Dispatcher.HasShutdownFinished) { this.Dispatcher.Invoke((Action)(() => { if (e.PropertyName == "IsActive") { LayoutAnchorable camLayoutAnch = null; var cvm = sender as CameraViewModel; var mainVM = DataContext as MainViewModel; if (cvm == mainVM.VMCamera1) { camLayoutAnch = this.LayoutCam1; } else if (cvm == mainVM.VMCamera2) { camLayoutAnch = this.LayoutCam2; } else if (cvm == mainVM.VMCamera3) { camLayoutAnch = this.LayoutCam3; } if (cvm.IsActive) { camLayoutAnch.Show(); } else if (!isAlreadyHidingCamLayout) { //We dont want to try and hide if it was already hidden through the GUI camLayoutAnch.Hide(); } else { //Reset for next time isAlreadyHidingCamLayout = false; } } })); } }
public void SetVisibility(LayoutAnchorable anchorable, bool visibility) { anchorable.AssertNotNull(nameof(anchorable)); try { if (visibility) { LayoutGroups[anchorable].Children.Add(anchorable); anchorable.Show(); LayoutGroups[anchorable].SelectedContentIndex = LayoutGroups[anchorable].Children.IndexOf(anchorable); } else { UpdateContainer(anchorable); anchorable.Hide(); } } catch { // Due to serializing/deserializing the application multiple times, a reference an an anchorable/an anchorable's parent might be lost. // If that's the case, we refresh the view and add it in the first available pane. if (DockingView != null && DockingView.DockingManager != null) { var root = DockingView.DockingManager.Layout; var availablePane = root.IfNotNull(o => o.Descendents().ExcludeDefaultValues().OfType <LayoutAnchorablePane>().FirstOrDefault()); if (availablePane != null) { if (LayoutGroups.ContainsKey(anchorable)) { LayoutGroups[anchorable] = availablePane; } else { LayoutGroups.Add(anchorable, availablePane); } LayoutGroups[anchorable].Children.Add(anchorable); LayoutGroups[anchorable].SelectedContentIndex = LayoutGroups[anchorable].Children.IndexOf(anchorable); } } // Do nothing. If this point is reached, it means the layout anchorable has not been loaded yet in the UI. // This can happen due to various UI events triggering by the initialization of viewModel components(MainMenuViewModel for example). } }
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) { bool result = false; if (layout != null && anchorableToShow != null) { var destPane = destinationContainer as LayoutAnchorablePane; if (anchorableToShow.Root == null) { anchorableToShow.AddToLayout(layout.Manager, GetContentAnchorableStrategy(anchorableToShow)); bool isHidden = GetContentAnchorableIsHidden(anchorableToShow); if (isHidden) { anchorableToShow.CanHide = true; anchorableToShow.Hide(); } result = true; } else if (destPane != null && anchorableToShow.IsHidden) { // Show a hidden Anchorable. if (anchorableToShow.PreviousContainerIndex < 0) { destPane.Children.Add(anchorableToShow); } else { int insertIndex = anchorableToShow.PreviousContainerIndex; if (insertIndex > destPane.ChildrenCount) { insertIndex = destPane.ChildrenCount; } destPane.Children.Insert(insertIndex, anchorableToShow); } result = true; } } return(result || m_WrappedStrategy.BeforeInsertAnchorable(layout, anchorableToShow, destinationContainer)); }
protected override void OnVisibilityChanged() { if (_anchorable?.Root != null) { if (_visibilityReentrantFlag.CanEnter) { using (_visibilityReentrantFlag.Enter()) { if (Visibility == Visibility.Hidden) { _anchorable.Hide(false); } else if (Visibility == Visibility.Visible) { _anchorable.Show(); } } } } base.OnVisibilityChanged(); }
/// <summary> /// /// </summary> private void LoadSettings() { double l = Left, t = Top, w = Width, h = Height; WindowState winState = WindowState; if (File.Exists(m_UserSettingsFile) == true) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(m_UserSettingsFile); XmlNode winNode = xmlDoc.SelectSingleNode("FlowSimulator/Window"); int version = int.Parse(winNode.Attributes["version"].Value); l = int.Parse(winNode.Attributes["left"].Value); t = int.Parse(winNode.Attributes["top"].Value); w = int.Parse(winNode.Attributes["width"].Value); h = int.Parse(winNode.Attributes["height"].Value); winState = (WindowState)Enum.Parse(typeof(WindowState), winNode.Attributes["windowState"].Value); XmlNode rootNode = xmlDoc.SelectSingleNode("FlowSimulator"); try { // m_SessionControl.LoadSettings(rootNode); // m_MessageControl.LoadSettings(rootNode); // m_TaskControl.LoadSettings(rootNode); // m_ReportControl.LoadSettings(rootNode); // //m_ScriptControl.LoadSettings(rootNode); // m_LogControl.LoadSettings(rootNode); } catch (System.Exception ex2) { LogManager.Instance.WriteException(ex2); } } if (File.Exists(m_DockSettingsFile) == true) { try { var serializer = new XmlLayoutSerializer(dockingManager1); serializer.LayoutSerializationCallback += (s, args) => { //args.Content = args.Content; //args.Content = Application.Current.MainWindow.FindName(args.Model.ContentId); if (args.Content is LayoutAnchorable) { LayoutAnchorable layout = args.Content as LayoutAnchorable; if (layout.CanHide && layout.IsHidden) { layout.Hide(); } } }; using (var stream = new StreamReader(m_DockSettingsFile)) serializer.Deserialize(stream); } catch (Exception ex3) { LogManager.Instance.WriteException(ex3); } } Left = l; Top = t; Width = w; Height = h; WindowState = winState; }
protected virtual void FixupLayout(LayoutRoot layout) { int i; foreach (ILayoutPreviousContainer layoutPreviousContainer in from lc in layout.Descendents().OfType <ILayoutPreviousContainer>() where lc.PreviousContainerId != null select lc) { ILayoutPaneSerializable layoutPaneSerializable = layout.Descendents().OfType <ILayoutPaneSerializable>().FirstOrDefault <ILayoutPaneSerializable>((ILayoutPaneSerializable lps) => lps.Id == layoutPreviousContainer.PreviousContainerId); if (layoutPaneSerializable == null) { throw new ArgumentException(string.Format("Unable to find a pane with id ='{0}'", layoutPreviousContainer.PreviousContainerId)); } layoutPreviousContainer.PreviousContainer = layoutPaneSerializable as ILayoutContainer; } LayoutAnchorable[] array = ( from lc in layout.Descendents().OfType <LayoutAnchorable>() where lc.Content == null select lc).ToArray <LayoutAnchorable>(); for (i = 0; i < (int)array.Length; i++) { LayoutAnchorable content = array[i]; LayoutAnchorable layoutAnchorable = null; if (content.ContentId != null) { layoutAnchorable = this._previousAnchorables.FirstOrDefault <LayoutAnchorable>((LayoutAnchorable a) => a.ContentId == content.ContentId); } if (this.LayoutSerializationCallback != null) { LayoutSerializationCallbackEventArgs layoutSerializationCallbackEventArg = new LayoutSerializationCallbackEventArgs(content, (layoutAnchorable != null ? layoutAnchorable.Content : null)); this.LayoutSerializationCallback(this, layoutSerializationCallbackEventArg); if (layoutSerializationCallbackEventArg.Cancel) { content.Close(); } else if (layoutSerializationCallbackEventArg.Content != null) { content.Content = layoutSerializationCallbackEventArg.Content; } else if (layoutSerializationCallbackEventArg.Model.Content != null) { content.Hide(false); } } else if (layoutAnchorable != null) { content.Content = layoutAnchorable.Content; content.IconSource = layoutAnchorable.IconSource; } else { content.Hide(false); } } LayoutDocument[] layoutDocumentArray = ( from lc in layout.Descendents().OfType <LayoutDocument>() where lc.Content == null select lc).ToArray <LayoutDocument>(); for (i = 0; i < (int)layoutDocumentArray.Length; i++) { LayoutDocument layoutDocument = layoutDocumentArray[i]; LayoutDocument layoutDocument1 = null; if (layoutDocument.ContentId != null) { layoutDocument1 = this._previousDocuments.FirstOrDefault <LayoutDocument>((LayoutDocument a) => a.ContentId == layoutDocument.ContentId); } if (this.LayoutSerializationCallback != null) { LayoutSerializationCallbackEventArgs layoutSerializationCallbackEventArg1 = new LayoutSerializationCallbackEventArgs(layoutDocument, (layoutDocument1 != null ? layoutDocument1.Content : null)); this.LayoutSerializationCallback(this, layoutSerializationCallbackEventArg1); if (layoutSerializationCallbackEventArg1.Cancel) { layoutDocument.Close(); } else if (layoutSerializationCallbackEventArg1.Content != null) { layoutDocument.Content = layoutSerializationCallbackEventArg1.Content; } else if (layoutSerializationCallbackEventArg1.Model.Content != null) { layoutDocument.Close(); } } else if (layoutDocument1 != null) { layoutDocument.Content = layoutDocument1.Content; } else { layoutDocument.Close(); } } layout.CollectGarbage(); }
//public HidePaneCmd(ISiteViewModel receiver, PaneViewModel pane): base(receiver) //{ // _pane = pane; //} public override void Execute() { _anchorable.Hide(); //((ISiteViewModelReceiver)Receiver).____HidePane(_pane); }