Ejemplo n.º 1
0
 public Application()
 {
     window = new WindowsWindow(new UI.WindowProps(1280, 720));
     window.SetEventCallback(OnEvent);
     if (Instance == null)
     {
         return;
     }
     Instance = this;
 }
Ejemplo n.º 2
0
        public static void TestLibrary()
        {
            // Linux version
            Console.WriteLine("Testing Linux version");
            Console.WriteLine();

            Button button = new LinuxButton(new Rectangle(20, 40, 50, 30));

            button.Print();
            button.Press();
            Console.WriteLine();

            Window window = new LinuxWindow(new Rectangle(30, 10, 250, 300));

            window.Print();
            window.Minimize();
            window.Print();
            window.Maximize();
            window.Print();
            Console.WriteLine();

            DropdownList dropdownList = new LinuxDropdownList(new Rectangle(60, 70, 200, 600));

            dropdownList.Print();
            dropdownList.Unroll();
            dropdownList.Print();
            dropdownList.Roll();
            dropdownList.Print();
            Console.WriteLine();

            // Windows version
            Console.WriteLine("Testing Windows version");
            Console.WriteLine();

            button = new WindowsButton(new Rectangle(50, 240, 150, 330));
            button.Print();
            button.Press();
            Console.WriteLine();

            window = new WindowsWindow(new Rectangle(170, 130, 550, 350));
            window.Print();
            window.Minimize();
            window.Print();
            window.Maximize();
            window.Print();
            Console.WriteLine();

            dropdownList = new WindowsDropdownList(new Rectangle(160, 270, 240, 500));
            dropdownList.Print();
            dropdownList.Unroll();
            dropdownList.Print();
            dropdownList.Roll();
            dropdownList.Print();
            Console.WriteLine();
        }
Ejemplo n.º 3
0
 public void SetPosition(int X, int Y)
 {
     if (runningWindows)
     {
         WindowsWindow.SetPosition(this, X, Y);
     }
     else
     {
         LinuxWindow.SetPosition(this, X, Y);
     }
 }
Ejemplo n.º 4
0
 public void Show()
 {
     if (runningWindows)
     {
         WindowsWindow.Show(this);
     }
     else
     {
         LinuxWindow.Show(this);
     }
 }
Ejemplo n.º 5
0
 public void Hide()
 {
     if (runningWindows)
     {
         WindowsWindow.Hide(this);
     }
     else
     {
         LinuxWindow.Hide(this);
     }
 }
Ejemplo n.º 6
0
 static void CleanupWindowHandles(List <long> handles)
 {
     if (handles != null)
     {
         foreach (var handle in handles)
         {
             var window = new WindowsWindow(new IntPtr(handle));
             window.ShowInCurrentState();
         }
     }
 }
        /// <summary>
        ///     Shows a window.
        /// </summary>
        /// <param name="window"> The window to show. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="window" /> is null. </exception>
        public static void ShowWindow(this Window window)
        {
            if (window == null)
            {
                throw new ArgumentNullException(nameof(window));
            }

            IntPtr hWnd = window.GetWindowHandle();

            WindowsWindow.ShowWindow(hWnd);
        }
        /// <summary>
        ///     Enables or disables a window.
        /// </summary>
        /// <param name="window"> The window to enable/disable. </param>
        /// <param name="enable"> true if the window should be enabled, false if it should be disabled. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="window" /> is null. </exception>
        public static void EnableWindow(this Window window, bool enable)
        {
            if (window == null)
            {
                throw new ArgumentNullException(nameof(window));
            }

            IntPtr hWnd = window.GetWindowHandle();

            WindowsWindow.EnableWindow(hWnd, enable);
        }
        /// <summary>
        ///     Moves a window to the primary screen.
        /// </summary>
        /// <param name="window"> The window to move. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="window" /> is null. </exception>
        public static void MoveWindowToPrimaryScreen(this Window window)
        {
            if (window == null)
            {
                throw new ArgumentNullException(nameof(window));
            }

            IntPtr hWnd = window.GetWindowHandle();

            WindowsWindow.MoveWindowToPrimaryScreen(hWnd);
        }
        public SourceWindowViewModel(WindowsWindow window, TabControl sourceTabs)
        {
            foreach (TabItem t in sourceTabs.Items.OfType <TabItem>().OrderBy(ti => (string)ti.Header))
            {
                this.tabDescriptors.Add(new SourceWindowDescriptor(t.Header as string));
            }

            window.SourceList.ItemsSource = this.tabDescriptors;

            this.closeSourceTabCommand = new RelayCommand(
                p => {
                // Close all the selected items in the list view
                foreach (SourceWindowDescriptor descriptor in window.SourceList.SelectedItems.OfType <SourceWindowDescriptor>().ToList())
                {
                    var tabHeader = descriptor.Name;
                    foreach (TabItem ti in sourceTabs.Items.OfType <TabItem>().ToList())
                    {
                        if ((string)ti.Header == tabHeader)
                        {
                            sourceTabs.Items.Remove(ti);
                            this.tabDescriptors.Remove(descriptor);
                            break;
                        }
                    }
                }
            },

                p => { return(window.SourceList.SelectedItems.Count > 0); }
                );

            this.activateSourceTabCommand = new RelayCommand(
                p => {
                SourceWindowDescriptor descriptor = window.SourceList.SelectedItem as SourceWindowDescriptor;

                var tabHeader = descriptor.Name;
                foreach (TabItem ti in sourceTabs.Items.OfType <TabItem>().ToList())
                {
                    if ((string)ti.Header == tabHeader)
                    {
                        sourceTabs.SelectedItem = ti;
                        break;
                    }
                }
                window.Close();
            },

                p => { return(window.SourceList.SelectedItems.Count == 1); }
                );
        }
        /// <summary>
        ///     Moves a window to a screen.
        /// </summary>
        /// <param name="window"> The window to move. </param>
        /// <param name="screenIndex"> The screen index or -1 to move to the primary screen. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="window" /> is null. </exception>
        /// <exception cref="ArgumentOutOfRangeException"> <paramref name="screenIndex" /> is below zero. </exception>
        public static void MoveWindowToScreen(this Window window, int screenIndex)
        {
            if (window == null)
            {
                throw new ArgumentNullException(nameof(window));
            }

            if (screenIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(screenIndex));
            }

            IntPtr hWnd = window.GetWindowHandle();

            WindowsWindow.MoveWindowToScreen(hWnd, screenIndex);
        }
        /// <summary>
        ///     Moves a window to a screen.
        /// </summary>
        /// <param name="window"> The window to move. </param>
        /// <param name="screen"> The screen or null to move to the primary screen. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="window" /> or <paramref name="screen" /> is null. </exception>
        public static void MoveWindowToScreen(this Window window, Screen screen)
        {
            if (window == null)
            {
                throw new ArgumentNullException(nameof(window));
            }

            if (screen == null)
            {
                throw new ArgumentNullException(nameof(screen));
            }

            IntPtr hWnd = window.GetWindowHandle();

            WindowsWindow.MoveWindowToScreen(hWnd, screen);
        }
Ejemplo n.º 13
0
            public IWindow Create()
            {
                if (os != OsType.Windows)
                {
                    throw new NotImplementedException();
                }
                else
                {
                    var window = new WindowsWindow(title, dimensions /* ... */);

                    window.Initialize();
                    window.DoSomeComplexSetup();

                    return(window);
                }
            }
        /// <summary>
        ///     Moves a window to a new position and size.
        /// </summary>
        /// <param name="window"> The window to move to a new position and size. </param>
        /// <param name="x"> The new x position of the window (top-left of the window). </param>
        /// <param name="y"> The new y position of the window (top-left of the window). </param>
        /// <param name="width"> The new width of the window. </param>
        /// <param name="height"> The new height of the window. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="window" /> is null. </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <paramref name="width" /> or <paramref name="height" /> is less than
        ///     zero.
        /// </exception>
        public static void RelocateWindow(this Window window, int x, int y, int width, int height)
        {
            if (window == null)
            {
                throw new ArgumentNullException(nameof(window));
            }

            if (width < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(width));
            }

            if (height < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(height));
            }

            IntPtr hWnd = window.GetWindowHandle();

            WindowsWindow.RelocateWindow(hWnd, x, y, width, height);
        }