Пример #1
0
        public DownloaderWindow(OctarineController _controller)
        {
            controller = _controller;
            items      = new List <OctarineDownloadItem>();

            this.Size          = new Size(320, 240);
            this.Text          = "Pobieranie - Octarine";
            this.ShowInTaskbar = false;

            lb_downloads          = new Label();
            lb_downloads.Text     = "Dostępne pobierania";
            lb_downloads.Size     = new Size(100, 150);
            lb_downloads.Location = new Point(20, 20);
            this.Controls.Add(lb_downloads);
            lst_downloads         = new ListBox();
            lst_downloads.Size    = new Size(160, 150);
            lb_downloads.Location = new Point(140, 20);
            this.Controls.Add(lst_downloads);

            btn_download          = new Button();
            btn_download.Text     = "Pobierz";
            btn_download.Size     = new Size(130, 50);
            btn_download.Location = new Point(20, 250);
            btn_download.Click   += (sender, e) => DownloadFile(lst_downloads.SelectedIndex);
            this.Controls.Add(btn_download);

            btn_close          = new Button();
            btn_close.Text     = "Zamknij";
            btn_close.Size     = new Size(130, 50);
            btn_close.Location = new Point(170, 250);
            btn_close.Click   += (sender, e) => this.Close();
            this.Controls.Add(btn_close);
            this.CancelButton = btn_close;
        }
Пример #2
0
        public OctarineWindow(OctarineController tcontroller)
        {
            controller = tcontroller;
            controller.SetWindow(this);
            this.Shown += (sender, e) => {
                _CurrentWindow = this;
                controller.Initiate();
            };

            this.Size = new Size(800, 600);
            this.Text = "Octarine";

            edt_result           = new RichTextBox();
            edt_result.Size      = new Size(760, 560);
            edt_result.Location  = new Point(20, 20);
            edt_result.ReadOnly  = true;
            edt_result.Multiline = true;
            this.Controls.Add(edt_result);

            MenuStrip ms = new MenuStrip();

            ms.Parent = this;
            ToolStripMenuItem mb_file = new ToolStripMenuItem("&Plik");
            ToolStripMenuItem mi_open = new ToolStripMenuItem("&Otwórz", null,
                                                              new EventHandler((sender, e) => { BrowseFile(); }));

            mi_open.ShortcutKeys = Keys.Control | Keys.O;
            mb_file.DropDownItems.Add(mi_open);
            ToolStripMenuItem mi_save = new ToolStripMenuItem("Zapi&sz", null,
                                                              new EventHandler((sender, e) => { SaveFile(); }));

            mi_save.ShortcutKeys = Keys.Control | Keys.S;
            mb_file.DropDownItems.Add(mi_save);
            ToolStripMenuItem mi_exit = new ToolStripMenuItem("Za&kończ", null,
                                                              new EventHandler((sender, e) => { this.Close(); }));

            mb_file.DropDownItems.Add(mi_exit);
            ms.Items.Add(mb_file);
            ToolStripMenuItem mb_tools    = new ToolStripMenuItem("&Narzędzia");
            ToolStripMenuItem mi_settings = new ToolStripMenuItem("Wybór &silnika", null,
                                                                  new EventHandler((sender, e) => {
                OctarineSettingsWindow wnd_settings = new OctarineSettingsWindow(this.controller);
                wnd_settings.ShowDialog(this);
            }));

            mb_tools.DropDownItems.Add(mi_settings);
            ms.Items.Add(mb_tools);
            foreach (ToolStripMenuItem mi in additionalMenus)
            {
                ms.Items.Add(mi);
            }
            MainMenuStrip = ms;
        }
Пример #3
0
        public OctarineSettingsWindow(OctarineController tcontroller)
        {
            controller = tcontroller;

            engines = new List <OctarineEngine.IEngine>();
            foreach (OctarineEngine.IEngine engine in OctarineEngines.engines)
            {
                engines.Add(engine);
            }

            this.Size          = new Size(320, 480);
            this.Text          = "Ustawienia - Octarine";
            this.ShowInTaskbar = false;

            lb_engine          = new Label();
            lb_engine.Size     = new Size(100, 100);
            lb_engine.Location = new Point(20, 20);
            lb_engine.Text     = "Silnik";
            this.Controls.Add(lb_engine);
            lst_engine          = new ListBox();
            lst_engine.Size     = new Size(180, 100);
            lst_engine.Location = new Point(120, 20);
            this.Controls.Add(lst_engine);

            lb_language          = new Label();
            lb_language.Size     = new Size(100, 100);
            lb_language.Location = new Point(20, 140);
            lb_language.Text     = "Język";
            this.Controls.Add(lb_language);
            lst_language          = new ListBox();
            lst_language.Size     = new Size(100, 100);
            lst_language.Location = new Point(120, 140);
            this.Controls.Add(lst_language);
            btn_downloadLanguages          = new Button();
            btn_downloadLanguages.Text     = "Pobierz pakiety językowe";
            btn_downloadLanguages.Size     = new Size(80, 100);
            btn_downloadLanguages.Location = new Point(200, 140);
            btn_downloadLanguages.Enabled  = false;
            btn_downloadLanguages.Click   += (sender, e) => DownloadLanguages();
            this.Controls.Add(btn_downloadLanguages);

            lb_quality          = new Label();
            lb_quality.Size     = new Size(100, 100);
            lb_quality.Location = new Point(20, 260);
            lb_quality.Text     = "Jakość";
            this.Controls.Add(lb_quality);
            lst_quality          = new ListBox();
            lst_quality.Size     = new Size(100, 100);
            lst_quality.Location = new Point(120, 260);
            this.Controls.Add(lst_quality);

            btn_ok          = new Button();
            btn_ok.Text     = "OK";
            btn_ok.Size     = new Size(50, 50);
            btn_ok.Location = new Point(20, 410);
            this.Controls.Add(btn_ok);

            btn_cancel          = new Button();
            btn_cancel.Text     = "Anuluj";
            btn_cancel.Size     = new Size(50, 50);
            btn_cancel.Location = new Point(250, 410);
            this.Controls.Add(btn_cancel);

            this.CancelButton = btn_cancel;
            this.AcceptButton = btn_ok;

            lst_engine.SelectedIndexChanged += (sender, e) => ShowLanguagesForEngine(engines[lst_engine.SelectedIndex]);
            if (engines.Count() > 0)
            {
                foreach (OctarineEngine.IEngine engine in engines)
                {
                    lst_engine.Items.Add(engine.Name);
                    if (engine == controller.Engine)
                    {
                        lst_engine.SelectedIndex = lst_engine.Items.Count - 1;
                    }
                }
            }

            lst_language.SelectedIndexChanged += (sender, e) => {
                var engine = engines[lst_engine.SelectedIndex];
                if (engine.Languages == null)
                {
                    ShowQualitiesForLanguage(engine, null);
                }
                else
                {
                    ShowQualitiesForLanguage(engine, engine.Languages[lst_language.SelectedIndex]);
                }
            };

            btn_cancel.Click += (sender, e) => this.Close();
            btn_ok.Click     += (sender, e) => {
                if (engines.Count() > 0)
                {
                    var engine = engines[lst_engine.SelectedIndex];
                    if (lst_language.SelectedIndex == -1)
                    {
                        MessageBox.Show(this, "Nie wybrano języka.", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (!engine.CanEnable(false))
                    {
                        return;
                    }
                    controller.Engine = engine;
                    int q = 0;
                    if (lst_quality.Items.Count > 1)
                    {
                        q = lst_quality.SelectedIndex + 1;
                    }
                    if (engine.Languages != null)
                    {
                        controller.SetLanguage(engine, engine.Languages[lst_language.SelectedIndex], q);
                    }
                    this.Close();
                }
            };
        }