void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: #line 9 "..\..\..\MatWindow.xaml" ((MatGUI.MatWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.Window_Closing); #line default #line hidden return; case 2: this.MainTabControl = ((MatGUI.PhantasmagoriaTabControl)(target)); return; } this._contentLoaded = true; }
private void MaskRect_Drop(object sender, DragEventArgs e) { posRect.Visibility = Visibility.Collapsed; maskRect.Visibility = Visibility.Collapsed; PhantasmagoriaTabItem source = e.Data.GetData(typeof(PhantasmagoriaTabItem)) as PhantasmagoriaTabItem; if (source != null) { PhantasmagoriaTabControl sourcesParent = source.Parent as PhantasmagoriaTabControl; if (sourcesParent == null) throw new Exception("MatPhantasmagoriaTabItem のParentが MatPhantasmagoriaTabControl でありません"); sourcesParent.Items.Remove(source); if (sourcesParent.Items.Count == 0) { if (sourcesParent != this) { RemoveSource(sourcesParent); } else { sourcesParent.Items.Add(source); return; } } if (dragTarget == DragPosition.Center) { Items.Add(source); } else { PhantasmagoriaTabControl sourcesNewParent = new PhantasmagoriaTabControl(); sourcesNewParent.Items.Add(source); Grid sourcesNewGrid = new Grid(); sourcesNewGrid.Children.Add(sourcesNewParent); PhantasmagoriaTabControl me = this; Grid myParent = Parent as Grid; if (myParent == null) throw new Exception("MatPhantasmagoriaTabControl のParentが Grid でありません"); myParent.Children.Remove(me); Grid myNewGrid = new Grid(); myNewGrid.Children.Add(me); switch (dragTarget) { case DragPosition.Top: PutToTop(myParent, myNewGrid, sourcesNewGrid); break; case DragPosition.Bottom: PutToBottom(myParent, myNewGrid, sourcesNewGrid); break; case DragPosition.Left: PutToLeft(myParent, myNewGrid, sourcesNewGrid); break; case DragPosition.Right: PutToRight(myParent, myNewGrid, sourcesNewGrid); break; default: break; } } } }
private void PhantasmagoriaSplitter_Drop(object sender, DragEventArgs e) { Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)); PhantasmagoriaTabItem source = e.Data.GetData(typeof(PhantasmagoriaTabItem)) as PhantasmagoriaTabItem; if (source == null) return; PhantasmagoriaTabControl sourcesParent = source.Parent as PhantasmagoriaTabControl; if (sourcesParent == null) throw new Exception("MatPhantasmagoriaTabItem のParentが MatPhantasmagoriaTabControl でありません"); sourcesParent.Items.Remove(source); if (sourcesParent.Items.Count == 0) { PhantasmagoriaTabControl.RemoveSource(sourcesParent); } Grid myParent = Parent as Grid; if (myParent == null) { sourcesParent.Items.Add(source); return; } Grid targetGrid, g1, g2; g1 = new Grid(); g2 = new Grid(); PhantasmagoriaTabControl newTabControl = new PhantasmagoriaTabControl(); newTabControl.Items.Add(source); g2.Children.Add(newTabControl); if (HorizontalAlignment == HorizontalAlignment.Left) { targetGrid = SearchGridInGridsChildren(myParent, 0, 1); if(targetGrid != null) { GridCopyToGrid(targetGrid, g1); PhantasmagoriaTabControl.PutToLeft(targetGrid, g1, g2); } } else if (HorizontalAlignment == HorizontalAlignment.Right) { targetGrid = SearchGridInGridsChildren(myParent, 0, 0); if (targetGrid != null) { GridCopyToGrid(targetGrid, g1); PhantasmagoriaTabControl.PutToRight(targetGrid, g1, g2); } } else if (VerticalAlignment == VerticalAlignment.Top) { targetGrid = SearchGridInGridsChildren(myParent, 1, 0); if (targetGrid != null) { GridCopyToGrid(targetGrid, g1); PhantasmagoriaTabControl.PutToTop(targetGrid, g1, g2); } } else if (VerticalAlignment == VerticalAlignment.Bottom) { targetGrid = SearchGridInGridsChildren(myParent, 0, 0); if (targetGrid != null) { GridCopyToGrid(targetGrid, g1); PhantasmagoriaTabControl.PutToBottom(targetGrid, g1, g2); } } }
public static void RemoveSource(PhantasmagoriaTabControl sourcesParent) { Grid sourcesGrid = sourcesParent.Parent as Grid; if (sourcesGrid == null) throw new Exception("MatPhantasmagoriaTabControl のParentが Grid でありません"); Grid sourcesGridGrid = sourcesGrid.Parent as Grid; if (sourcesGridGrid == null) throw new Exception("Grid のParentが Grid でありません"); sourcesGridGrid.Children.Remove(sourcesGrid); PhantasmagoriaSplitter s = null; Grid g = null; foreach (object o in sourcesGridGrid.Children) { if (s == null) s = o as PhantasmagoriaSplitter; if (g == null) g = o as Grid; } if (s != null) { sourcesGridGrid.Children.Remove(s); } if (g != null) { PhantasmagoriaTabControl t = g.Children[0] as PhantasmagoriaTabControl; Grid gg = g.Parent as Grid; if (t != null) { g.Children.Remove(t); sourcesGridGrid.Children.Remove(g); sourcesGridGrid.ColumnDefinitions.Clear(); sourcesGridGrid.RowDefinitions.Clear(); sourcesGridGrid.SetValue(Grid.ColumnProperty, 0); sourcesGridGrid.SetValue(Grid.RowProperty, 0); sourcesGridGrid.Children.Add(t); } if (gg != null) { g.SetValue(Grid.ColumnProperty, 0); g.SetValue(Grid.RowProperty, 0); g.Margin = new Thickness(0); gg.ColumnDefinitions.Clear(); gg.RowDefinitions.Clear(); gg.Children.Remove(g); Grid ggg = gg.Parent as Grid; if (ggg != null) { ggg.Children.Remove(gg); if (g.Children.Count != 0) { ggg.Children.Add(g); } else { Grid _g = null; foreach(object o in ggg.Children) { if (_g == null) _g = o as Grid; } if (_g != null) { if ((int)_g.GetValue(Grid.ColumnProperty) == 0) sourcesGridGrid.SetValue(Grid.ColumnProperty, 1); if ((int)_g.GetValue(Grid.RowProperty) == 0) sourcesGridGrid.SetValue(Grid.RowProperty, 1); } ggg.Children.Add(sourcesGridGrid); } } } } }