Example #1
0
 void bt_Click(Vec2 loc, MouseButtons buttons)
 {
     //if (w1.CurrentState == OForms.Windows.WindowState.Normal)
     //{
     //    windowManager.MaximizeWindow(w1);
     //}
     //else
     //{
     //    windowManager.RestoreWindow(w1);
     //}
     Window w = new Window(new Vec2(130, 30), new Vec2(120, 80), "Test Window 3");
     w.ClearColor = Colors.Blue;
     windowManager.AddWindow(w);
 }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            w1 = new Window(new Vec2(30, 30), new Vec2(120, 80), "Test Window 1");
            w1.ClearColor = Colors.Green;
            Button bt = new Button(new Vec2(10, 10), new Vec2(30, 10));
            bt.Click += new MouseEvent(bt_Click);
            bt.Parent = w1;
            w1.Controls.Add(bt);
            Window w2 = new Window(new Vec2(80, 30), new Vec2(120, 80), "Test Window 2");
            w2.ClearColor = Colors.Red;
            Window w3 = new Window(new Vec2(130, 30), new Vec2(120, 80), "Test Window 3");
            w3.ClearColor = Colors.Blue;
            windowManager.AddWindow(w1);
            windowManager.AddWindow(w2);
            windowManager.AddWindow(w3);
            windowManager.BringWindowToFront(w1);

            InitializeMouse();
            Forms.Cursor.Hide();

            i.Clear(Colors.White);

            //i.DrawString(new Vec2(30, 30), "T", fnt, 20, Orvid.Graphics.FontSupport.FontStyle.Normal, Colors.Black);

            // Draw exit button.
            ExitButton b = new ExitButton(new Vec2(DesktopWidth - 21, 1), new Vec2(20, 20), i, this);
            Objects.Add(b.evnts);


            DrawCursor();
            pictureBox1.Image = (System.Drawing.Bitmap)i;
            pictureBox1.Refresh();
            // Now we need to restore what was behind the mouse.
            Vec2 v = new Vec2((int)MouseX, (int)MouseY);
            i.DrawImage(v, behindMouseImage);
        }
Example #3
0
 /// <summary>
 /// Removes the window at the specified index.
 /// </summary>
 /// <param name="indx">The index of the window to remove.</param>
 private void RemoveWindow(int indx)
 {
     Window[] tmp = new Window[ActiveWindows.Length - 1];
     Array.Copy(ActiveWindows, tmp, indx);
     Array.Copy(ActiveWindows, indx + 1, tmp, indx, ActiveWindows.Length - indx - 1);
     ActiveWindows = tmp;
     if (ActiveWindows.Length > 0)
     {
         ActiveWindows[0].IsActiveWindow = true;
     }
     NeedToRedrawAll = true;
 }
Example #4
0
 /// <summary>
 /// Closes the specified window.
 /// </summary>
 /// <param name="w">The window to close.</param>
 public void CloseWindow(Window w)
 {
     for (int i = 0; i < ActiveWindows.Length; i++)
     {
         if (ActiveWindows[i] == w)
         {
             RemoveWindow(i);
             NeedToRedrawAll = true;
             w.DoClose();
             Taskbar.RemoveWindow(w);
             return;
         }
     }
 }
Example #5
0
        /// <summary>
        /// Sends the specified window to the back.
        /// </summary>
        /// <param name="w">The window to send to the back.</param>
        public void SendWindowToBack(Window w)
        {
            if (w.IsActiveWindow)
            {
                w.IsActiveWindow = false;
            }
            for (int i = 0; i < ActiveWindows.Length; i++)
            {
                if (ActiveWindows[i] == w)
                {
                    RemoveWindow(i);
                    NeedToRedrawAll = true;

                    Window[] winds = new Window[ActiveWindows.Length + 1];
                    Array.Copy(ActiveWindows, winds, ActiveWindows.Length);
                    winds[winds.Length - 1] = w;
                    ActiveWindows = winds;
                    ActiveWindows[0].IsActiveWindow = true;
                    Taskbar.Modified = true;
                    return;
                }
            }
            throw new Exception("Unable to find the specified window.");
        }
Example #6
0
 /// <summary>
 /// Bring the specified window to the front.
 /// </summary>
 /// <param name="w">The window to move to the front.</param>
 public void BringWindowToFront(Window w)
 {
     if (ActiveWindows.Length > 0)
     {
         ActiveWindows[0].IsActiveWindow = false;
     }
     w.IsActiveWindow = true;
     for (int i = 0; i < ActiveWindows.Length; i++)
     {
         if (ActiveWindows[i] == w)
         {
             RemoveWindow(i);
             InternalAddWindow(w);
             NeedToRedrawAll = true;
             Taskbar.Modified = true;
             return;
         }
     }
     throw new Exception("Specified Window not found!");
 }
Example #7
0
 /// <summary>
 /// Restore a window to the Normal state.
 /// </summary>
 /// <param name="w">The window to restore.</param>
 public void RestoreWindow(Window w)
 {
     w.CurrentState = WindowState.Normal;
 }
Example #8
0
 /// <summary>
 /// Minimizes the specified window.
 /// </summary>
 /// <param name="w">The window to minimize.</param>
 public void MinimizeWindow(Window w)
 {
     if (w.IsActiveWindow)
     {
         this.SendWindowToBack(w);
     }
     w.CurrentState = WindowState.Minimized;
 }
Example #9
0
 /// <summary>
 /// Adds the specified window without modifying the taskbar.
 /// </summary>
 /// <param name="w">The window to add.</param>
 private void InternalAddWindow(Window w)
 {
     w.Parent = this;
     w.IsActiveWindow = true;
     if (ActiveWindows.Length > 0)
     {
         ActiveWindows[0].IsActiveWindow = false;
     }
     Window[] tmp = new Window[ActiveWindows.Length + 1];
     Array.Copy(ActiveWindows, 0, tmp, 1, ActiveWindows.Length);
     tmp[0] = w;
     ActiveWindows = tmp;
     NeedToRedrawAll = true;
 }
Example #10
0
 /// <summary>
 /// Maximize the specified window.
 /// </summary>
 /// <param name="w">The window to maximize.</param>
 public void MaximizeWindow(Window w)
 {
     w.CurrentState = WindowState.Maximized;
 }
Example #11
0
 /// <summary>
 /// Adds a window at the front.
 /// </summary>
 /// <param name="w">The window to add.</param>
 public void AddWindow(Window w)
 {
     InternalAddWindow(w);
     Taskbar.AddWindow(w);
 }
Example #12
0
        /// <summary>
        /// Draws the over WindowButton.
        /// </summary>
        /// <param name="bounds">The bounds of the window to draw.</param>
        /// <param name="w">The window to draw.</param>
        private void DrawOverButton(BoundingBox bounds, Window w)
        {
            Vec2 tl = new Vec2(bounds.Left, bounds.Bottom) - TaskbarLocation;
            Vec2 tr = new Vec2(bounds.Right, bounds.Bottom) - TaskbarLocation;
            Vec2 br = new Vec2(bounds.Right, bounds.Top) - TaskbarLocation;
            Vec2 bl = new Vec2(bounds.Left, bounds.Top) - TaskbarLocation;

            if (w.IsActiveWindow && w.CurrentState != WindowState.Minimized)
            {
                Buffer.DrawRectangle(tl, br, WindowActiveOverBackColor);
                Buffer.DrawLines(new Vec2[] { tl, tr, br, bl, tl }, WindowActiveLineColor);
            }
            else
            {
                Buffer.DrawRectangle(tl, br, WindowInactiveOverBackColor);
                Buffer.DrawLines(new Vec2[] { tl, tr, br, bl, tl }, WindowInactiveLineColor);
            }

            DrawWindowName(bounds, w);

            WasOverButton = true;
        }
Example #13
0
 /// <summary>
 /// Draws the window's name on the taskbar,
 /// using the specified bounds.
 /// </summary>
 /// <param name="bounds">Bounds to use.</param>
 /// <param name="w">Window to draw.</param>
 private void DrawWindowName(BoundingBox bounds, Window w)
 {
     BoundingBox bnds = bounds - TaskbarLocation;
     //throw new Exception();
     //if (WindowManager.WindowFont.GetFontMetrics().StringWidth(w.Name) > bnds.Width - 6)
     //{
     //    // Doesn't fit on the button, need to remove some characters.
     //    string s = w.Name.Substring(0, w.Name.Length - 3) + "...";
     //    while (WindowManager.WindowFont.GetFontMetrics().StringWidth(s) > bnds.Width - 6)
     //    {
     //        if (s.Length == 3)
     //        {
     //            s = "."; // button is to small to have a name drawn.
     //            break;
     //        }
     //        else
     //        {
     //            // It's 4 to make up for the 3 extra characters we add.
     //            s = s.Substring(0, s.Length - 4) + "...";
     //        }
     //    }
     //    //throw new Exception();
     //    Buffer.DrawString(new Vec2(bnds.Left + 2, bnds.Bottom + 2), s, WindowManager.WindowFont, 10, Orvid.Graphics.FontSupport.FontStyle.Normal, TaskbarTextColor);
     //}
     //else // Fits on button.
     //{
     //    Buffer.DrawString(new Vec2(bnds.Left + 2, bnds.Bottom + 2), w.Name, WindowManager.WindowFont, 10, Orvid.Graphics.FontSupport.FontStyle.Normal, TaskbarTextColor);
     //}
 }
Example #14
0
 /// <summary>
 /// Removes the specified window from the taskbar.
 /// </summary>
 /// <param name="w">The window to remove.</param>
 public void RemoveWindow(Window w)
 {
     uint i;
     for (i = 0; i < Windows.Length; i++)
     {
         if (Windows[i] == w)
         {
             break;
         }
     }
     Window[] tmp = new Window[Windows.Length - 1];
     Array.Copy(Windows, tmp, i);
     Array.Copy(Windows, i + 1, tmp, i, Windows.Length - i - 1);
     Windows = tmp;
     Modified = true;
     Drawn = false;
 }
Example #15
0
 /// <summary>
 /// Adds the specified window to the taskbar.
 /// </summary>
 /// <param name="w">The window to add.</param>
 public void AddWindow(Window w)
 {
     Window[] tmp = new Window[Windows.Length + 1];
     Array.Copy(Windows, tmp, Windows.Length);
     tmp[tmp.Length - 1] = w;
     Windows = tmp;
     Modified = true;
     Drawn = false;
 }