Example #1
0
        private void configureControls()
        {
            //close button control
            closeBtn.Click += (s, args) => {
                undock();
            };

            resizeStrip.MouseMove += (s, a) =>
            {
                if (resizeStrip.Dock == DockStyle.Top || resizeStrip.Dock == DockStyle.Bottom)
                {
                    Cursor.Current = Cursors.HSplit;
                }
                else
                {
                    Cursor.Current = Cursors.VSplit;
                }
            };
            resizeStrip.MouseLeave += (s, a) =>
            {
                Cursor.Current = Cursors.Default;
            };

            //resize control
            resizeStrip.MouseDown += (s, a) =>
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.HSplit;

                Boolean abort        = true;
                Thread  resizeThread = new Thread(() =>
                {
                    resizeStrip.MouseUp += (s2, a2) =>
                    {
                        abort = false;
                    };

                    while (abort)
                    {
                        try
                        {
                            if (resizeStrip.Dock == DockStyle.Top)
                            {
                                Invoke(new NoArgFunction(() =>
                                {
                                    int yDelta = resizeStrip.PointToScreen(resizeStrip.Location).Y - Cursor.Position.Y;
                                    Size       = new Size(Width, Height + yDelta);
                                }));
                            }
                            else if (resizeStrip.Dock == DockStyle.Right)
                            {
                                Invoke(new NoArgFunction(() =>
                                {
                                    int xDelta = Cursor.Position.X - resizeStrip.PointToScreen(resizeStrip.Location).X + Width - resizeStrip.Width;
                                    Size       = new Size(Width + xDelta, Height);
                                }));
                            }
                            else if (resizeStrip.Dock == DockStyle.Left)
                            {
                                Invoke(new NoArgFunction(() =>
                                {
                                    int xDelta = Cursor.Position.X - resizeStrip.PointToScreen(resizeStrip.Location).X;// +Width - resizeStrip.Width;
                                    Console.WriteLine(xDelta);
                                    Size = new Size(Width - xDelta, Height);
                                }));
                            }
                            else if (resizeStrip.Dock == DockStyle.Bottom)
                            {
                                throw new NotImplementedException("HELP");
                            }

                            Thread.Sleep(1);
                        }
                        catch (ThreadAbortException e)
                        {
                        }
                    }

                    Invalidate();
                });


                resizeThread.Start();
            };
        }