Esempio n. 1
0
        /// <summary>
        /// 現在アクティブなタブ以外を全て閉じる
        /// </summary>
        /// <returns></returns>
        public bool CloseFileOtherAll()
        {
            IEditorDocContent editor = ActiveDocument;

            if (editor == null)
            {
                //現在アクティブなエディタがないので何もせずに終了
                return(true);
            }

            //現在アクティブなエディタの位置を取得する
            int docLen = 0;

            IDockContent[] docList           = m_mainPanel.Documents;
            int            activeEditorIndex = 0;

            for (int i = 0; i < docList.Length; i++)
            {
                if (editor == docList[i])
                {
                    activeEditorIndex = i;
                }
                if (docList[i] is IEditorDocContent)
                {
                    docLen++;
                }
            }

            //ドッキングウィンドウからエディタを検索する
            for (int i = 0; i < docList.Length; i++)
            {
                if (i != activeEditorIndex)                     //アクティブだったエディタではないとき
                {
                    if (docList[i] is IEditorDocContent)
                    {
                        //エディタを閉じる
                        editor = (IEditorDocContent)docList[i];
                        editor.ActivateForm();
                        editor.CloseForm();

                        if (editor.IsClosed == false)
                        {
                            //閉じることができなかったので失敗を返す
                            return(false);
                        }
                    }
                }
            }

            //すべて閉じれたので成功を返す
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// エディタを閉じる
        /// 未保存の時は保存するかどうかのダイアログを表示する
        /// エディタを閉じるのに成功したらtrueを返す
        /// </summary>
        public bool CloseFile()
        {
            IEditorDocContent editor = ActiveDocument;

            if (editor == null)
            {
                //閉じるエディタがないので何もせずに終了
                return(true);
            }

            //現在アクティブなエディタの位置を取得する
            int docLen = 0;

            IDockContent[] docList           = m_mainPanel.Documents;
            int            activeEditorIndex = 0;

            for (int i = 0; i < docList.Length; i++)
            {
                if (editor == docList[i])
                {
                    activeEditorIndex = i;
                }
                if (docList[i] is IEditorDocContent)
                {
                    docLen++;
                }
            }

            //閉じる
            editor.CloseForm();
            if (editor.IsClosed == true)
            {
                if (docLen > 1)                 //自分とこれからアクティブにする個数分だけ存在するとき
                {
                    //閉じるエディタの一つ前の位置をアクティブにする
                    int index = 0;
                    if (activeEditorIndex == 0)
                    {
                        //前がいないので一つ後ろを指定する
                        index = 1;
                    }
                    else
                    {
                        //一つ前を指定する
                        index = activeEditorIndex - 1;
                    }
                    ((IEditorDocContent)docList[index]).ActivateForm();
                }
            }

            return(editor.IsClosed);
        }
Esempio n. 3
0
        /// <summary>
        /// すべてのエディタを閉じる
        /// すべて閉じたらtrueを返す
        /// </summary>
        public bool CloseFileAll()
        {
            //ドッキングウィンドウからエディタを検索する
            IDockContent[] docList = m_mainPanel.Documents;
            foreach (IDockContent doc in docList)
            {
                if (doc is IEditorDocContent)
                {
                    //エディタを閉じる
                    IEditorDocContent editor = (IEditorDocContent)doc;
                    editor.ActivateForm();
                    editor.CloseForm();

                    if (editor.IsClosed == false)
                    {
                        //閉じることができなかったので失敗を返す
                        return(false);
                    }
                }
            }

            //すべて閉じれたので成功を返す
            return(true);
        }