public void RemoveFromParent()
        {
            IBPanel tc1parent = Parent as IBPanel;

            if (tc1parent == null)
            {
                return;
            }

            tc1parent.Children.Remove(this);
        }
        private void AddToBottom(IBTabControl tc2)
        {
            if (P1 == null)
            {
                P1 = new IBPanel();
                P1.Children.Add(TC);
                P1.TC = TC;
            }
            else
            {
                P1.RemoveFromParent();
            }

            if (P2 == null)
            {
                P2 = new IBPanel();
                P2.Children.Add(tc2);
                P2.TC = tc2;
            }
            else
            {
                P2.RemoveFromParent();
            }

            RowDefinition newRow1 = new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star), MinHeight = 50.0
            };
            RowDefinition newRow2 = new RowDefinition()
            {
                Height = new GridLength(200, GridUnitType.Pixel), MinHeight = 50.0
            };

            RowDefinitions.Add(newRow1);
            RowDefinitions.Add(newRow2);

            P1.CurrentPos = Position.top;
            P1.SetColumnRow();

            PS.Width               = double.NaN;
            PS.Margin              = new Thickness(0, 0, 0, -3);
            PS.VerticalAlignment   = VerticalAlignment.Bottom;
            PS.HorizontalAlignment = HorizontalAlignment.Stretch;
            PS.SetValue(RowProperty, 0);

            P2.CurrentPos = Position.bottom;
            P2.SetColumnRow();

            Children.Add(P1);
            Children.Add(PS);
            Children.Add(P2);
        }
        private void AddToRight(IBTabControl tc2)
        {
            if (P1 == null)
            {
                P1 = new IBPanel();
                P1.Children.Add(TC);
                P1.TC = TC;
            }
            else
            {
                P1.RemoveFromParent();
            }

            if (P2 == null)
            {
                P2 = new IBPanel();
                P2.Children.Add(tc2);
                P2.TC = tc2;
            }
            else
            {
                P2.RemoveFromParent();
            }

            ColumnDefinition newColumn1 = new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star), MinWidth = 50.0
            };
            ColumnDefinition newColumn2 = new ColumnDefinition()
            {
                Width = new GridLength(200, GridUnitType.Pixel), MinWidth = 50.0
            };

            ColumnDefinitions.Add(newColumn1);
            ColumnDefinitions.Add(newColumn2);

            P1.CurrentPos = Position.left;
            P1.SetColumnRow();

            PS.Height              = double.NaN;
            PS.Margin              = new Thickness(0, 0, -3, 0);
            PS.VerticalAlignment   = VerticalAlignment.Stretch;
            PS.HorizontalAlignment = HorizontalAlignment.Right;
            PS.SetValue(ColumnProperty, 0);

            P2.CurrentPos = Position.right;
            P2.SetColumnRow();

            Children.Add(P1);
            Children.Add(PS);
            Children.Add(P2);
        }
Exemple #4
0
        protected override void MaskRect_MouseLeave(object sender, MouseEventArgs e)
        {
            //base.MaskRect_MouseLeave(sender, e);

            if (isMouseDown)
            {
                if (!isDummyItem)
                {
                    DragDrop.DoDragDrop(this, this, DragDropEffects.Move);
                }
                IBPanel.ResetLayout();
            }

            isMouseDown = false;
        }
Exemple #5
0
        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();
            }
        }
        /// <summary>
        /// 指定された位置にあるIBPanelを検索して返します
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public IBPanel GetChildIBPanelAt(Position p)
        {
            IBPanel result = null;

            foreach (UIElement u in Children)
            {
                result = u as IBPanel;

                if (result != null)
                {
                    if (result.CurrentPos == p)
                    {
                        return(result);
                    }
                }
            }

            return(result);
        }
Exemple #7
0
        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();
            }
        }
Exemple #8
0
        protected virtual void MaskRect_MouseLeave(object sender, MouseEventArgs e)
        {
            if (isMouseDown)
            {
                try
                {
                    DragDrop.DoDragDrop(this, this, DragDropEffects.Move);
                    IBPanel.ResetLayout();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(
                        "レイアウトの変更中に例外がスローされました。\n\n"
                        + ex.Message + "\n\n場所 : " + ex.Source + "\nターゲット : " + ex.TargetSite,
                        "レイアウトの変更に失敗しました",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                }
            }

            isMouseDown = false;
        }
        /// <summary>
        /// このIBPanelを親のIBPanelから削除します
        /// </summary>
        public void RemoveIBPanel()
        {
            IBPanel parent = Parent as IBPanel;

            if (parent == null)
            {
                return;
            }

            IBPanel p = null;

            if (parent.P1 == this)
            {
                p = parent.P2;
            }
            else
            {
                p = parent.P1;
            }

            if (parent.P1 != null)
            {
                parent.P1.RemoveFromParent();
                parent.P1 = null;
            }

            if (parent.P2 != null)
            {
                parent.P2.RemoveFromParent();
                parent.P2 = null;
            }

            parent.Children.Clear();

            IBTabControl tc = null;

            if (p.Children.Count != 0)
            {
                tc = p.Children[0] as IBTabControl;
            }

            if (tc != null)
            {
                p.Children.Remove(tc);
                parent.Children.Add(tc);

                parent.TC = tc;

                parent.ColumnDefinitions.Clear();
                parent.RowDefinitions.Clear();
            }
            else
            {
                Window      parent_parentW  = parent.Parent as Window;
                IBPanel     parent_parentP  = parent.Parent as IBPanel;
                IBWorkspace parent_parentWS = parent.Parent as IBWorkspace;

                if (parent_parentW != null)
                {
                    parent_parentW.Content = p;
                }

                if (parent_parentP != null)
                {
                    parent_parentP.Children.Add(p);

                    IBPanel panel = null;
                    foreach (object o in parent_parentP.Children)
                    {
                        panel = o as IBPanel;
                        if (panel != null)
                        {
                            if (panel.Children.Count == 0)
                            {
                                break;
                            }
                        }
                    }
                    parent_parentP.Children.Remove(panel);
                }

                if (parent_parentWS != null)
                {
                    parent_parentWS.Content = p;
                }
            }
        }
        /// <summary>
        /// 全てのIBPanelを調べてレイアウトの不整合を修正します
        /// </summary>
        public static void ResetLayout()
        {
            foreach (IBPanel p in AllIBPanelList)
            {
                IBPanel p1 = null, p2 = null;
                foreach (object o in p.Children)
                {
                    if (p1 == null)
                    {
                        p1 = o as IBPanel;
                    }
                    else if (p2 == null)
                    {
                        p2 = o as IBPanel;
                    }
                }

                if (p1 != null && p2 != null)
                {
                    switch (p1.CurrentPos)
                    {
                    case Position.left:
                        p2.CurrentPos = Position.right;
                        break;

                    case Position.right:
                        p2.CurrentPos = Position.left;
                        break;

                    case Position.top:
                        p2.CurrentPos = Position.bottom;
                        break;

                    case Position.bottom:
                        p2.CurrentPos = Position.top;
                        break;

                    default:
                        break;
                    }

                    p1.SetColumnRow();
                    p2.SetColumnRow();

                    if (p.TC != null)
                    {
                        p.TC.EndDrag();
                    }
                    if (p1.TC != null)
                    {
                        p1.TC.EndDrag();
                    }
                    if (p2.TC != null)
                    {
                        p2.TC.EndDrag();
                    }

                    if (p.P1 == null)
                    {
                        p.P1 = p1;
                    }
                    if (p.P2 == null)
                    {
                        p.P2 = p2;
                    }
                }
            }
        }
        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();
            }
        }