public void Float(object parameter) { IBMenuItem from = parameter as IBMenuItem; if (from == null) { throw new IBDisableCommandException("コマンドターゲットが不正、または取得できません"); } ContextMenu cm = from.Parent as ContextMenu; if (cm == null) { throw new IBDisableCommandException("コマンドターゲットが不正、または取得できません"); } IBTabItem trg = cm.PlacementTarget as IBTabItem; if (trg == null) { throw new IBDisableCommandException("コマンドターゲットが不正、または取得できません"); } IBTabControl tc = trg.Parent as IBTabControl; if (tc == null) { throw new IBDisableCommandException("コマンドターゲットが不正、または取得できません"); } IBPanel panel = tc.Parent as IBPanel; if (panel == null) { throw new IBDisableCommandException("コマンドターゲットが不正、または取得できません"); } IBWindow ibw = new IBWindow(); ibw.InputBindings.AddRange(Application.Current.MainWindow.InputBindings); ibw.SetIBTabItem(trg); ibw.Show(); if (tc.Items.Count == 0) { panel.RemoveIBPanel(); } }
public void DoCloseCommand(object parameter) { IBMenuItem from = parameter as IBMenuItem; if (from == null) { throw new IBDisableCommandException("コマンドターゲットが不正、または取得できません"); } ContextMenu cm = from.Parent as ContextMenu; if (cm == null) { throw new IBDisableCommandException("コマンドターゲットが不正、または取得できません"); } IBTabItem trg = cm.PlacementTarget as IBTabItem; if (trg == null) { throw new IBDisableCommandException("コマンドターゲットが不正、または取得できません"); } IBTabControl tc = trg.Parent as IBTabControl; if (tc == null) { throw new IBDisableCommandException("コマンドターゲットが不正、または取得できません"); } IBPanel panel = tc.Parent as IBPanel; if (panel == null) { throw new IBDisableCommandException("コマンドターゲットが不正、または取得できません"); } trg.RemoveFromParent(); if (tc.Items.Count == 0) { panel.RemoveIBPanel(); } }
private void MaskRect_Drop(object sender, DragEventArgs e) { EndDrag(); if (e.Data.GetData(typeof(IBTabItem)) == null) { return; } IBTabItem ti = e.Data.GetData(typeof(IBTabItem)) as IBTabItem; if (ti == null) { throw new IBLayoutException("ドロップされたパネルを取得できませんでした"); } if (!ti.AllowDropToAnother) { return; } IBPanel parentPanel = Parent as IBPanel; if (parentPanel == null) { throw new IBLayoutException("IBTabControl の親が IBPanel でありません"); } IBTabControl parent_ti = ti.Parent as IBTabControl; if (parent_ti == null) { throw new IBLayoutException("IBTabItem の親が IBTabControl でありません"); } IBPanel parent_parent_ti = parent_ti.Parent as IBPanel; if (parent_parent_ti == null) { throw new IBLayoutException("IBTabControl の親が IBPanel でありません"); } if (currentDropPos == Position.newWindow) { IBWindow ibw = new IBWindow(); ibw.SetIBTabItem(ti); ibw.Show(); } else { if (parentPanel == parent_parent_ti && parent_ti.Items.Count == 1) { return; } if (currentDropPos == Position.center) { ti.RemoveFromParent(); Items.Add(ti); ti.IsSelected = true; } else { IBTabControl tc2 = new IBTabControl(); ti.RemoveFromParent(); tc2.Items.Add(ti); parentPanel.AddIBTabControl(tc2, currentDropPos); } } if (parent_ti.Items.Count == 0) { parent_parent_ti.RemoveIBPanel(); } }
private void Border_Drop(object sender, DragEventArgs e) { IsDropping = false; if (e.Data.GetData(typeof(IBTabItem)) == null) { return; } IBTabItem ti = e.Data.GetData(typeof(IBTabItem)) as IBTabItem; if (ti == null) { throw new IBLayoutException("ドロップされたパネルを取得できません"); } if (!ti.AllowDropToAnother) { return; } IBPanel parentPanel = Parent as IBPanel; if (parentPanel == null) { throw new IBLayoutException("IBPanelSplitter の親が IBPanel でありません"); } IBWorkspace Workspace = parentPanel.GetVisualParent() as IBWorkspace; if (Workspace == null) { throw new IBLayoutException("IBWorkspace を取得できません"); } IBTabControl parent_ti = ti.Parent as IBTabControl; if (parent_ti == null) { throw new IBLayoutException("IBTabItem の親が IBTabControl でありません"); } IBPanel parent_parent_ti = parent_ti.Parent as IBPanel; if (parent_parent_ti == null) { throw new IBLayoutException("IBTabControl の親が IBPanel でありません"); } if (parentPanel == parent_parent_ti && parent_ti.Items.Count == 1) { return; } IBTabControl tc2 = new IBTabControl(); IBPanel p = new IBPanel(); IBPanel p1 = new IBPanel(); p1 = Workspace.Content as IBPanel; p1.RemoveFromParent(); p.Children.Add(p1); ti.RemoveFromParent(); tc2.Items.Add(ti); if (HorizontalAlignment == HorizontalAlignment.Left) { p.P2 = p1; p.CurrentPos = p1.CurrentPos; p.AddIBTabControl(tc2, Position.left); Workspace.Content = p; } else if (HorizontalAlignment == HorizontalAlignment.Right) { p.P1 = p1; p.CurrentPos = p1.CurrentPos; p.AddIBTabControl(tc2, Position.right); Workspace.Content = p; } else if (VerticalAlignment == VerticalAlignment.Top) { p.P2 = p1; p.CurrentPos = p1.CurrentPos; p.AddIBTabControl(tc2, Position.top); Workspace.Content = p; } else if (VerticalAlignment == VerticalAlignment.Bottom) { p.P1 = p1; p.CurrentPos = p1.CurrentPos; p.AddIBTabControl(tc2, Position.bottom); Workspace.Content = p; } if (parent_ti.Items.Count == 0) { parent_parent_ti.RemoveIBPanel(); } }