private bool ShouldHideTabGroup(ViewElement element, bool hideOnlyActiveView) { FloatSite floatSite = ViewElement.FindRootElement(element) as FloatSite; bool flag = floatSite != null && !floatSite.HasMultipleOnScreenViews; return(element.Parent is TabGroup && (flag && this.Preferences.AlwaysHideAllViewInFloatingTabGroup || !hideOnlyActiveView)); }
private void OnViewSitesChanged(object sender, NotifyCollectionChangedEventArgs args) { if (args.OldItems != null) { foreach (object obj in (IEnumerable)args.OldItems) { FloatSite floatSite = obj as FloatSite; if (floatSite != null) { this.FloatingWindowManager.RemoveFloat(floatSite); } } } if (args.NewItems == null) { return; } foreach (object obj in (IEnumerable)args.NewItems) { FloatSite floatSite = obj as FloatSite; if (floatSite != null) { this.FloatingWindowManager.AddFloat(floatSite); } } }
public void AddFloat(FloatSite floatSite) { floatSite.IsVisibleChanged += new EventHandler(this.OnFloatSiteIsVisibleChanged); if (!floatSite.IsVisible) { return; } this.ShowFloat(floatSite); }
public void RemoveAllFloats(WindowProfile profile) { foreach (ViewElement viewElement in (IEnumerable <ViewElement>)profile.Children) { FloatSite floatSite = viewElement as FloatSite; if (floatSite != null) { this.RemoveFloat(floatSite); } } }
private bool ValidateElement(ViewElement element) { if (!this.IsFiniteSizeInValidRange(element.MinimumHeight)) { element.MinimumHeight = (double)ViewElement.MinimumHeightProperty.DefaultMetadata.DefaultValue; } if (!this.IsFiniteSizeInValidRange(element.MinimumWidth)) { element.MinimumWidth = (double)ViewElement.MinimumWidthProperty.DefaultMetadata.DefaultValue; } if (!this.IsFiniteSizeInValidRange(element.AutoHideHeight)) { element.AutoHideHeight = (double)ViewElement.AutoHideHeightProperty.DefaultMetadata.DefaultValue; } if (!this.IsFiniteSizeInValidRange(element.AutoHideWidth)) { element.AutoHideWidth = (double)ViewElement.AutoHideWidthProperty.DefaultMetadata.DefaultValue; } if (!this.IsFiniteSizeInValidRange(element.FloatingHeight)) { element.FloatingHeight = (double)ViewElement.FloatingHeightProperty.DefaultMetadata.DefaultValue; } if (!this.IsFiniteSizeInValidRange(element.FloatingWidth)) { element.FloatingWidth = (double)ViewElement.FloatingWidthProperty.DefaultMetadata.DefaultValue; } if (!this.IsValueInValidRange(element.FloatingLeft, double.NegativeInfinity, double.PositiveInfinity, false, false)) { element.FloatingLeft = (double)ViewElement.FloatingLeftProperty.DefaultMetadata.DefaultValue; } if (!this.IsValueInValidRange(element.FloatingTop, double.NegativeInfinity, double.PositiveInfinity, false, false)) { element.FloatingTop = (double)ViewElement.FloatingTopProperty.DefaultMetadata.DefaultValue; } MainSite site1 = element as MainSite; if (site1 != null) { return(this.ValidateElement(site1)); } FloatSite site2 = element as FloatSite; if (site2 != null) { return(this.ValidateElement(site2)); } DocumentGroupContainer container = element as DocumentGroupContainer; if (container != null) { return(this.ValidateElement(container)); } return(true); }
private void CloseFloat(FloatSite floatSite) { FloatingWindow floatingWindow; if (!this.floatingWindows.TryGetValue(floatSite, out floatingWindow)) { return; } floatingWindow.ForceClose(); this.floatingWindows.Remove(floatSite); this.delayShownElements.Remove(floatingWindow); }
private void OnFloatSiteIsVisibleChanged(object sender, EventArgs args) { FloatSite floatSite = (FloatSite)sender; if (floatSite.IsVisible) { this.ShowFloat(floatSite); } else { this.CloseFloat(floatSite); } }
private void OnFloatingControlClosing(object sender, CancelEventArgs args) { FloatSite floatSite = ((FrameworkElement)sender).DataContext as FloatSite; if (floatSite != null) { foreach (View view in floatSite.FindAll((Predicate <ViewElement>)(element => element is View))) { view.Hide(); } } args.Cancel = floatSite.IsVisible; }
private FloatingWindow GetFloatingControl(FloatSite floatSite) { FloatingWindow floatingWindow; if (!this.floatingWindows.TryGetValue(floatSite, out floatingWindow)) { floatingWindow = this.CreateFloatingWindow(floatSite); floatingWindow.Closing += new CancelEventHandler(this.OnFloatingControlClosing); new WindowInteropHelper((Window)floatingWindow).Owner = this.OwnerWindow; this.floatingWindows[floatSite] = floatingWindow; } return(floatingWindow); }
private bool ValidateElement(FloatSite site) { bool flag = true; if (site.Children.Count == 0) { flag = false; } if (site.Parent != null) { flag = false; } return(flag); }
private void ShowFloat(FloatSite floatSite) { FloatingWindow floatingControl = this.GetFloatingControl(floatSite); floatingControl.DataContext = (object)floatSite; this.EnsureFloatingSiteInVisibleBounds(floatSite); if (this.CanShowFloatingWindows) { floatingControl.Show(); } else { this.DelayShowElement(floatingControl); } }
public void ActivateFloatingControl(ViewElement element) { if (element == null) { throw new ArgumentNullException("element"); } FloatSite key = ViewElement.FindRootElement(element) as FloatSite; FloatingWindow floatingWindow; if (key == null || !this.floatingWindows.TryGetValue(key, out floatingWindow)) { return; } floatingWindow.Activate(); }
private void OnToggleDocked(object sender, ExecutedRoutedEventArgs args) { if (!this.CanToggleDocked(args)) { return; } ViewElement element = (ViewElement)args.Parameter; if (FloatSite.IsFloating(element)) { DockOperations.SnapToBookmark(element); } else { DockOperations.Float(element, element.WindowProfile); } }
public void EnsureFloatingSiteInVisibleBounds(FloatSite site) { Rect logicalRect = new Rect(site.FloatingLeft, site.FloatingTop, site.FloatingWidth, site.FloatingHeight); RECT lprc = new RECT(DpiHelper.LogicalToDeviceUnits(logicalRect)); IntPtr hMonitor = Microsoft.VisualStudio.PlatformUI.NativeMethods.MonitorFromRect(ref lprc, 1U); MONITORINFO monitorInfo = new MONITORINFO(); monitorInfo.cbSize = (uint)Marshal.SizeOf((object)monitorInfo); if (!Microsoft.VisualStudio.PlatformUI.NativeMethods.GetMonitorInfo(hMonitor, ref monitorInfo)) { return; } Rect rect = DpiHelper.DeviceToLogicalUnits(monitorInfo.rcWork.WPFRectValue); bool flag1 = logicalRect.Right < rect.Left + (double)this.MonitorPadding; bool flag2 = logicalRect.Left > rect.Right - (double)this.MonitorPadding; bool flag3 = logicalRect.Top < rect.Top + (double)this.MonitorPadding; bool flag4 = logicalRect.Top > rect.Bottom - (double)this.MonitorPadding; if (!flag1 && !flag2 && (!flag3 && !flag4)) { return; } if (flag1) { site.FloatingLeft = rect.Left; } else if (flag2) { site.FloatingLeft = rect.Right - site.FloatingWidth; } if (flag3) { site.FloatingTop = rect.Top; } else { if (!flag4) { return; } site.FloatingTop = rect.Bottom - site.FloatingHeight; } }
private void OnFloatingWindowSizeChanged(object sender, SizeChangedEventArgs args) { FloatingWindow floatingWindow = (FloatingWindow)sender; FloatSite site = floatingWindow.DataContext as FloatSite; if (site == null || floatingWindow.WindowState != WindowState.Normal) { return; } foreach (ViewElement viewElement in site.FindAll((Predicate <ViewElement>)(element => { if (element.IsVisible) { return(element != site); } return(false); }))) { viewElement.FloatingWidth = args.NewSize.Width; viewElement.FloatingHeight = args.NewSize.Height; } }
private void OnFloatingWindowLocationChanged(object sender, RoutedEventArgs args) { FloatingWindow floatingWindow = (FloatingWindow)sender; FloatSite floatSite = floatingWindow.DataContext as FloatSite; if (floatSite == null || floatingWindow.WindowState != WindowState.Normal) { return; } foreach (ViewElement viewElement in floatSite.FindAll((Predicate <ViewElement>)(element => { if (element.IsVisible) { return(!(element is FloatSite)); } return(false); }))) { viewElement.FloatingLeft = floatingWindow.Left; viewElement.FloatingTop = floatingWindow.Top; } }
public void RemoveFloat(FloatSite floatSite) { floatSite.IsVisibleChanged -= new EventHandler(this.OnFloatSiteIsVisibleChanged); this.CloseFloat(floatSite); }
protected virtual FloatingWindow CreateFloatingWindow(FloatSite floatSite) { return(new FloatingWindow()); }