예제 #1
0
        public string Draw(string operatingSystem)
        {
            IWidget button;

            if (operatingSystem.Equals("Linux"))
            {
                button = new LinuxButton();
            }
            else
            {
                button = new WindowsButton();
            }

            IWidget menu;

            if (button.GetType() == typeof(LinuxButton))
            {
                menu = new LinuxMenu();
            }
            else
            {
                menu = new WindowsMenu();
            }

            return(button.Draw() + " & " + menu.Draw());
        }
예제 #2
0
            public override void CreateCloseButtonFor(Dialog dialogToClose)
            {
                _closeButton = new WindowsButton();

                // Nackdel: upprepande kod
                // (skulle kunna göra en metod av denna men då måste man komma ihåg att anropa den i varje fabrik)
                _closeButton.Render();
                _dialogToClose = dialogToClose;
            }
예제 #3
0
            // Nackdel: upprepning av kod
            public override void Render()
            {
                OkButton = new WindowsButton();

                var renderResult = OkButton.Render();

                _events.Add($"Ok button rendered as: {renderResult}");

                OkButton.OnClick = CloseDialog;
            }
예제 #4
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();
        }
예제 #5
0
        private void WindowButton_MouseClick(object sender, MouseEventArgs e)
        {
            MetroLink     button     = (MetroLink)sender;
            WindowsButton buttonType = (WindowsButton)button.Tag;

            switch (buttonType)
            {
            case WindowsButton.close:
                Close();
                break;

            case WindowsButton.maximized:
                WindowState = FormWindowState.Normal;
                break;

            case WindowsButton.minimized:
                WindowState = FormWindowState.Maximized;
                break;

            case WindowsButton.tray:
                WindowState = FormWindowState.Minimized;
                break;
            }
        }