Example #1
0
        private void MainTabControl_DragDrop(object sender, DragEventArgs e)
        {
            TabPage source = (TabPage)e.Data.GetData(typeof(TabPage));

            SetCurrStatus($"MainTabControl_DragDrop:{source}");
            if (source != null)
            {
                for (int i = 0; i < MainTabControl.TabPages.Count; i++)
                {
                    if (MainTabControl.GetTabRect(i).Contains(e.X, e.Y))
                    {
                        //var tab = MainTabControl.TabPages[i];
                        //SetCurrStatus($"拖动开始:{MainTabControl.TabPages[i].Text},AlowDrop:{tab.AllowDrop}");
                        //tab.DoDragDrop(e, DragDropEffects.Move);
                        if (MainTabControl.TabPages.IndexOf(source) != i)
                        {
                            e.Effect = DragDropEffects.Move;
                            TabAdapter.Swap(MainTabControl.TabPages.IndexOf(source), i);
                            SetCurrStatus($"拖动结束:{e.Data}");
                            return;
                        }
                    }
                }
            }
            e.Effect = DragDropEffects.None;
        }
Example #2
0
        /// <summary>
        /// 新建文件菜单--菜单>文件>新建
        /// </summary>
        /// <param name="sender">新建文件菜单对象</param>
        /// <param name="e"></param>
        private void NewMenuItem_Click(object sender, EventArgs e)
        {
            var budle = new TabBundle
            {
                IsNew    = true,
                TabTitle = "新增选项卡" + TabAdapter.NextNo.ToString().PadLeft(3, '0'),
            };

            TabAdapter.Add(budle);
            SetCurrStatus($"新建标题:{budle.TabTitle}");
        }
Example #3
0
        public MainWindow()
        {
            InitializeComponent();

            //OutputForm output = new OutputForm();
            //output.TopLevel = false;
            //output.Parent = Output;
            ////output.MdiParent = this;
            //output.FormBorderStyle = FormBorderStyle.None;
            //output.Dock = DockStyle.Fill;
            ////this.Output.Controls.Add(output);
            //output.Show();

            SetCurrStatus($"就绪-窗口:{Id}");

            TabAdapter = new TabAdapter
            {
                MainWindow = this,
                TabControl = MainTabControl,
            };
        }
Example #4
0
        /// <summary>
        /// 打开文件--菜单>文件>打开
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult DialogResult = OpenFileDialog.ShowDialog();

            if (DialogResult == DialogResult.Cancel)
            {
                return;
            }
            string fileName = this.OpenFileDialog.FileName;

            if (DialogResult == DialogResult.OK && fileName.Length > 0)
            {
                try
                {
                    TabAdapter.OpenFile(fileName);
                    SetCurrStatus($"打开文件:{fileName}");
                }
                catch (Exception ex)
                {
                    SetCurrStatus($"打开失败:{ex.Message}");
                }
            }
        }
Example #5
0
        private void MainTabControl_DragOver(object sender, DragEventArgs e)
        {
            TabPage source = (TabPage)e.Data.GetData(typeof(TabPage));

            //SetCurrStatus($"MainTabControl_DragOver:{source}");
            if (source != null)
            {
                for (int i = 0; i < MainTabControl.TabPages.Count; i++)
                {
                    if (MainTabControl.GetTabRect(i).Contains(MainTabControl.PointToClient(new Point(e.X, e.Y))))
                    {
                        if (MainTabControl.TabPages.IndexOf(source) != i)
                        {
                            e.Effect = DragDropEffects.Move;
                            TabAdapter.Swap(MainTabControl.TabPages.IndexOf(source), i);
                            MainTabControl.SelectedTab = source;
                            SetCurrStatus($"拖动结束:{source.Text}");
                            return;
                        }
                    }
                }
            }
            e.Effect = DragDropEffects.None;
        }
Example #6
0
 /// <summary>
 /// 主窗口加载时
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainWindow_Load(object sender, EventArgs e)
 {
     // 选项卡初始化
     TabAdapter.MainWindow_Loaded();
 }