Exemplo n.º 1
0
        /// <summary>
        /// Finishes the message load process.
        /// </summary>
        /// <param name="abort">Set to true if the aborting a message load prematurely.</param>
        private void FinishMessageLoad(bool abort)
        {
            lock (this)
            {
                if (abort && _messageLoadThread != null)
                {
                    _messageLoadThread.Abort();
                }

                if (_workingProcess != null)
                {
                    Action x = delegate
                    {
                        if (workingPanel.Visible)
                        {
                            workingPanel.Visible = false;
                        }
                    };

                    OnAfterMessageListLoaded(new VisualizableProcessEventArgs(_workingProcess));

                    workingPanel.Invoke(x);

                    _messageLoadThread = null;
                }
            }
        }
Exemplo n.º 2
0
 public static void AddLoaderToPanel(Panel panel, PictureBox loader)
 {
     panel.Invoke((MethodInvoker)delegate
     {
         panel.Controls.Add(loader);
     });
 }
Exemplo n.º 3
0
 /// <summary>
 /// Set panel visibility from within a thread
 /// </summary>
 /// <param name="panel">Panel</param>
 /// <param name="visible">Visible or not</param>
 public static void setPanelVisibilityFromThread(Panel panel, bool visible)
 {
     panel.Invoke((MethodInvoker)delegate
     {
         panel.Visible = visible;
     });
 }
Exemplo n.º 4
0
 public static void RemoveLoaderFromPanel(Panel panel, PictureBox loader)
 {
     panel.Invoke((MethodInvoker)delegate
     {
         panel.Controls.Remove(loader);
     });
 }
Exemplo n.º 5
0
        /// <summary>
        /// Updates the message of an existing panel
        /// </summary>
        /// <param name="informationPanel">Panel to update</param>
        /// <param name="message">Message to display</param>
        public static void ChangeInformationPanelMessage(Panel informationPanel, string message)
        {
            MethodInvoker mi = delegate
            {
                foreach (var label in informationPanel.Controls.OfType<Label>())
                {
                    if (label.Name == "InfoLabel")
                    {
                        label.Text = message;
                    }
                }
            };

            if (informationPanel.InvokeRequired)
            {
                informationPanel.Invoke(mi);
            }
            else
            {
                mi();
            }
        }
Exemplo n.º 6
0
        private void DestroyHostedProcess()
        {
            if (_process != null && !_process.HasExited)
            {
                _process.Exited   -= Process_Exited;
                _process.Disposed -= Process_Disposed;
                _process.Kill();
                _process.Dispose();
                _process = null;
            }

            if (_hostGrid != null)
            {
                _hostGrid.Dispatcher.Invoke(() => _hostGrid.Children.Clear());
                _hostGrid = null;
            }

            if (_hostPanel != null)
            {
                _hostPanel.Invoke((MethodInvoker) delegate { _hostPanel.Dispose(); });
                _hostPanel = null;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates child process.
        /// </summary>
        /// <param name="panelHandle">The panel handle.</param>
        private void CreateGameProcess(IntPtr panelHandle)
        {
            IsLoading = true;

            Task.Factory.StartNew(
                () =>
            {
                // Get all instances of SSFIV.exe running on the local
                // computer.
                Process[] sfivInstances = Process.GetProcessesByName("SSFIV");

                if (sfivInstances.Length > 0)
                {
                    sfivInstances[0].Kill();
                }

                _gameProcess = new Process
                {
                    StartInfo =
                    {
                        FileName              = _gameExecuteablePath,
                        WindowStyle           = ProcessWindowStyle.Minimized,
                        RedirectStandardInput = true,
                        ErrorDialog           = false,
                        UseShellExecute       = false,
                    }
                };

                _gameProcess.EnableRaisingEvents = true;
                _gameProcess.Exited += GameProcessExited;

                lock (this)
                {
                    uint _oldErrorMode = NativeModel.SetErrorMode(NativeModel.SEM_FAILCRITICALERRORS
                                                                  | NativeModel.SEM_NOGPFAULTERRORBOX);

                    try
                    {
                        _gameProcess.Start();
                    }
                    catch (InvalidOperationException invEx)
                    {
                        // Expected, handled
                        Debug.WriteLine(invEx.Message);
                    }
                    catch (Exception ex)
                    {
                        Execute.OnUIThread(() =>
                                           System.Windows.MessageBox.Show(
                                               System.Windows.Application.Current.MainWindow,
                                               string.Format("The game coulnd't start: {0} !", ex.Message),
                                               "Error",
                                               MessageBoxButton.OK,
                                               MessageBoxImage.Error));
                    }

                    _gameProcess.WaitForInputIdle();

                    // For correct responding, it's important to let sleep our thread for a while.
                    System.Threading.Thread.Sleep(1000);


                    while (_gameProcessMainWindowHandle == IntPtr.Zero)
                    {
                        Thread.Sleep(100);
                        _gameProcessMainWindowHandle = _gameProcess.MainWindowHandle;
                        _gameProcess.Refresh();
                    }

                    int dwStyle = NativeModel.GetWindowLong(_gameProcessMainWindowHandle, NativeModel.GWL_STYLE);
                    NativeModel.SetWindowLong(_gameProcessMainWindowHandle, NativeModel.GWL_STYLE,
                                              new IntPtr(dwStyle & ~NativeModel.WS_CAPTION & ~NativeModel.WS_THICKFRAME));

                    NativeModel.SetWindowPos(_gameProcessMainWindowHandle, IntPtr.Zero, 0, 0,
                                             Convert.ToInt32(Math.Floor((double)_panel.Width)),
                                             Convert.ToInt32(Math.Floor((double)_panel.Height)), NativeModel.SWP_ASYNCWINDOWPOS);

                    _panel.Invoke(new MethodInvoker(delegate { NativeModel.SetParent(_gameProcessMainWindowHandle, _panel.Handle); }));
                }

                Execute.OnUIThread(() =>
                {
                    NotifyOfPropertyChange(() => IsStopped);
                    EnableWindow();
                });

                PanelResize(this, null);
            }).ContinueWith(
                (t) =>
            {
                Execute.OnUIThread(() =>
                {
                    IsLoading = false;
                });
            }
                );
        }
Exemplo n.º 8
0
        private void Task(Panel p1, int i,int count)
        {
            try
            {
                if (p1.InvokeRequired)
                {
                    SetTextCallback d = new SetTextCallback(Task);
                    p1.Invoke(d, new Object[] { p1, i,count });
                }
                else
                {
                    int w = ((PopupContent)panelContainer.Tag).Width;
                    int h = ((PopupContent)panelContainer.Tag).Height;
                    int left = ((PopupContent)panelContainer.Tag).TargetControl.FindForm().Width - w - 20;
                    int top = ((PopupContent)panelContainer.Tag).TargetControl.FindForm().Height - 40;
                    if (p1.Height >= h)
                    {
                        p1.SetBounds(left, top - h,w, h);
                    }
                    else
                    {
                        p1.SetBounds(left, top - i * (int)Convert.ToDouble(h / count), p1.Width, i * (int)Convert.ToDouble(h / count));
                    }

                    if (!p1.Visible)
                    {
                        p1.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Task函数执行错误");
            }
        }
Exemplo n.º 9
0
        private void Shadow(Panel p1, int i,int count)
        {
            try
            {
                if (p1.InvokeRequired)
                {
                    SetTextCallback d = new SetTextCallback(Shadow);
                    p1.Invoke(d, new Object[] { p1, i, count });
                }
                else
                {

                    int w = ((PopupContent)panelContainer.Tag).Width;
                    int h = ((PopupContent)panelContainer.Tag).Height;

                    if (p1.Width >= w)
                        p1.Width = w;
                    else
                        p1.Width = i * (int)Convert.ToDouble(w / count);

                    if (p1.Height >= h)
                        p1.Height = h;
                    else
                        p1.Height = i * (int)Convert.ToDouble(h / count);

                    if (!p1.Visible)
                    {
                        p1.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("ShowPanel函数执行错误");
            }
        }
Exemplo n.º 10
0
 private void updatePanel(Panel pnl, bool value)
 {
     if (pnl.InvokeRequired)
     { pnl.Invoke(new panelDelegate(updatePanel), new object[] { pnl, value }); }
     else
     {
         pnl.Visible = value;
     }
 }
Exemplo n.º 11
0
        private void ClearPanel(Panel panel)
        {
            //CREATE TITLE LABEL
            MetroLabel title_label = new MetroLabel();
            title_label.Theme = MetroThemeStyle.Dark;
            title_label.ForeColor = Color.White;
            title_label.AutoSize = true;
            title_label.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            title_label.Location = new System.Drawing.Point(74, 11);
            title_label.Size = new System.Drawing.Size(205, 19);
            title_label.TabIndex = 3;
            title_label.Text = "FACE COMPARISON ONGOING";

            //CREATE LINE SEPARATOR
            MetroLabel separator_label = new MetroLabel();
            separator_label.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            separator_label.Location = new System.Drawing.Point(19, 39);
            separator_label.Size = new System.Drawing.Size(335, 2);
            separator_label.TabIndex = 2;

            //COZ THIS IS NOT ON THE UI THREAD
            if (panel.InvokeRequired)
            {
                //CLEAR THE PANEL
                Action action = () => panel.Controls.Clear();
                panel.Invoke(action);

                //ADD TITLE AND SEPARATOR LINE TO PANEL
                action = () => panel.Controls.AddRange(new Control[] { title_label, separator_label });
                panel.Invoke(action);
            }

            //IF ON UI THREAD::HIGHLY UNLIKELY
            else
            {
                //CLEAR THE PANEL
                panel.Controls.Clear();

                //ADD TITLE AND SEPARATOR LINE TO PANEL
                panel.Controls.AddRange(new Control[] { title_label, separator_label });
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// When the MainWindow changes in size, we must resize the _conversationWindowParentPanel,
 /// and redock the ConversationWindow to it.
 /// </summary>
 void HandleWindowSizeChanged(object sender, EventArgs eventArgs)
 {
     _conversationWindowParentPanel.Invoke((Action)ResizeConversation);
 }
Exemplo n.º 13
0
        public void GoCurier()
        {
            //Thread.Sleep(1000);
            Address   address;
            Client    c;
            CurierCar curier;
            //создание картинки клиента
            PictureBox boxClient = new PictureBox
            {
                Size     = new Size(80, 80),
                Visible  = true,
                Image    = image2,
                Location = new Point(0, 0),
                SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
            };
            //создание картинки доставщика
            PictureBox boxCurier = new PictureBox
            {
                Size     = new Size(80, 80),
                Visible  = true,
                Image    = image3,
                Location = new Point(0, 0),
                SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
            };

            panelclient.Invoke((Action)(() => panelclient.Controls.Add(boxClient)));
            panelclient.Invoke((Action)(() => panelclient.Controls.Add(boxCurier)));
            Random rnd   = new Random();
            int    value = rnd.Next(0, 6);

            switch (value)
            {
            case 0:
                address = new Address("Левобережный");
                c       = new Client(address, boxClient);
                MoveC(c.picture, 0, 0, 0);
                c.picture.Invoke((Action)(() => c.picture.Visible = true));
                break;

            case 1:
                address = new Address("Левобережный");
                c       = new Client(address, boxClient);
                MoveC(c.picture, 80, 0, 0);
                c.picture.Invoke((Action)(() => c.picture.Visible = true));
                break;

            case 2:
                address = new Address("Центральный");
                c       = new Client(address, boxClient);
                MoveC(c.picture, 0, 250, 0);
                c.picture.Invoke((Action)(() => c.picture.Visible = true));
                break;

            case 3:
                address = new Address("Центральный");
                c       = new Client(address, boxClient);
                MoveC(c.picture, 100, 250, 0);
                c.picture.Invoke((Action)(() => c.picture.Visible = true));
                break;

            case 4:
                address = new Address("Правобережный");
                c       = new Client(address, boxClient);
                MoveC(c.picture, 0, 580, 0);
                c.picture.Invoke((Action)(() => c.picture.Visible = true));
                break;

            case 5:
                address = new Address("Правобережный");
                c       = new Client(address, boxClient);
                MoveC(c.picture, 100, 580, 0);
                c.picture.Invoke((Action)(() => c.picture.Visible = true));
                break;

            default:
                address = new Address("NONE");
                c       = new Client(address, boxClient);
                MoveC(c.picture, 300, 250, 0);
                c.picture.Invoke((Action)(() => c.picture.Visible = true));
                break;
            }
            logger.Log("Район: " + address);
            //хотение пиццы и вычитание ресурсов для пиццы
            value = rnd.Next(0, 3);
            switch (value)
            {
            case 0:
                logger.Log("Заказ: Сырная пицца");
                if (Cheese.Count > 0)
                {
                    logger.Log("Доставляем: Сырная пицца");
                    Cheese.Count--;
                    tp1.BeginInvoke((Action)(() => tp1.Text = Convert.ToString(Cheese.Count)));
                }
                else
                {
                    logger.Log("Готовим Сырную пиццу из:");
                    logger.Log("| сыр, помидор, огурец |");
                    logger.Log("Доставляем: Сырная пицца");
                    cheescook.Create();
                }
                break;

            case 1:
                logger.Log("Заказ: Куриная пицца");
                if (Chicken.Count > 0)
                {
                    logger.Log("Доставляем: Куриная пицца");
                    Chicken.Count--;
                    tp2.BeginInvoke((Action)(() => tp2.Text = Convert.ToString(Chicken.Count)));
                }
                else
                {
                    logger.Log("Готовим Куриную пиццу из:");
                    logger.Log("| помидор, курица, ананас |");
                    logger.Log("Доставляем: Куриная пицца");
                    chikcook.Create();
                }
                break;

            case 2:
                logger.Log("Заказ: Мясная пицца");
                if (Sausage.Count > 0)
                {
                    logger.Log("Доставляем: Мясная пицца");
                    Sausage.Count--;
                    tp3.BeginInvoke((Action)(() => tp3.Text = Convert.ToString(Sausage.Count)));
                }
                else
                {
                    logger.Log("Готовим Мясную пиццу из:");
                    logger.Log("| огурец, ананас, колбаса |");
                    logger.Log("Доставляем: Мясная пицца");
                    sauscook.Create();
                }
                break;

            default:

                break;
            }
            logger.Log("---------");
            UpdateStock();
            curier = new CurierCar(boxCurier, new Point(c.picture.Location.X, c.picture.Location.Y));
            MoveC(curier.picture, 558, 350, 0);
            curier.picture.Invoke((Action)(() => curier.picture.Visible = true));
            MoveC(curier.picture, c.picture.Location.X + 80, c.picture.Location.Y, 100);
            curier.picture.Invoke((Action)(() => curier.picture.Dispose()));
            c.picture.Invoke((Action)(() => c.picture.Dispose()));
        }
Exemplo n.º 14
0
        // Populate mods panels
        public void PopulateMods()
        {
            List<string> modTypes = new List<string>() { "cars", "tracks", "skins", "misc" };

            foreach (string type in modTypes)
            {
                List<Mod> modList = new List<Mod>();
                int mods = 0;
                if (type == "cars")
                {
                    modList = modCarList;
                }
                else if (type == "tracks")
                {
                    modList = modTrackList;
                }
                else if (type == "skins")
                {
                    modList = modSkinList;
                }
                else if (type == "misc")
                {
                    modList = modMiscList;
                }

                foreach (Mod mod in modList)
                {
                    Panel modPanel = new Panel();
                    modPanel.Size = new Size(860, 61);
                    modPanel.Location = new Point(0, 1 + (modPanel.Height - 1) * mods);
                    modPanel.BorderStyle = BorderStyle.FixedSingle;
                    if (type == "cars")
                    {
                        carsTabPage.Invoke((MethodInvoker)delegate { carsTabPage.Controls.Add(modPanel); });
                        modPanel.MouseHover += delegate { carsTabPage.Focus(); };
                    }
                    else if (type == "tracks")
                    {
                        tracksTabPage.Invoke((MethodInvoker)delegate { tracksTabPage.Controls.Add(modPanel); });
                        modPanel.MouseHover += delegate { tracksTabPage.Focus(); };
                    }
                    else if (type == "skins")
                    {
                        skinsTabPage.Invoke((MethodInvoker)delegate { skinsTabPage.Controls.Add(modPanel); });
                        modPanel.MouseHover += delegate { skinsTabPage.Focus(); };
                    }
                    else if (type == "misc")
                    {
                        skinsTabPage.Invoke((MethodInvoker)delegate { miscTabPage.Controls.Add(modPanel); });
                        modPanel.MouseHover += delegate { miscTabPage.Focus(); };
                    }

                    Label modNameLabel = new Label();
                    modNameLabel.Text = mod.name.ToUpper();
                    modNameLabel.ForeColor = Color.Black;
                    modNameLabel.Location = new Point(0, 0);
                    modNameLabel.Padding = new Padding(4, 10, 0, 0);
                    modNameLabel.AutoSize = true;
                    modNameLabel.Dock = DockStyle.Left;
                    modNameLabel.Font = new Font("Arimo", 12, FontStyle.Bold);
                    modPanel.Invoke((MethodInvoker)delegate { modPanel.Controls.Add(modNameLabel); });

                    Label modVersionLabel = new Label();
                    modVersionLabel.Text = mod.version;
                    modVersionLabel.ForeColor = Color.FromArgb(64, 64, 64);
                    modVersionLabel.Location = new Point(modNameLabel.Width, 0);
                    modVersionLabel.Padding = new Padding(4, 10, 0, 0);
                    modVersionLabel.AutoSize = true;
                    modVersionLabel.Font = new Font("Arimo", 12, FontStyle.Regular);
                    modPanel.Invoke((MethodInvoker)delegate { modPanel.Controls.Add(modVersionLabel); });

                    Label modAuthorLabel = new Label();
                    modAuthorLabel.Text = mod.author;
                    modAuthorLabel.ForeColor = Color.FromArgb(64, 64, 64);
                    modAuthorLabel.Location = new Point(5, modPanel.Height - 20);
                    modAuthorLabel.AutoSize = true;
                    modAuthorLabel.Font = new Font("DejaVu Sans Condensed", 8, FontStyle.Regular);
                    modPanel.Invoke((MethodInvoker)delegate { modPanel.Controls.Add(modAuthorLabel); });

                    Label modDateLabel = new Label();
                    modDateLabel.Text = mod.date;
                    modDateLabel.ForeColor = Color.FromArgb(64, 64, 64);
                    modDateLabel.Location = new Point(20 + modAuthorLabel.Width, modPanel.Height - 20);
                    modDateLabel.AutoSize = true;
                    modDateLabel.Font = new Font("DejaVu Sans Condensed", 8, FontStyle.Regular);
                    modPanel.Invoke((MethodInvoker)delegate { modPanel.Controls.Add(modDateLabel); });

                    Button modDownloadButton = new Button();
                    modDownloadButton.Size = new Size(100, 61);
                    modDownloadButton.ForeColor = Color.Black;
                    modDownloadButton.BackColor = Color.WhiteSmoke;
                    modDownloadButton.UseVisualStyleBackColor = true;
                    modDownloadButton.FlatStyle = FlatStyle.Flat;
                    //modDownloadButton.Dock = DockStyle.Right;
                    modDownloadButton.Location = new Point(759, -1);
                    modDownloadButton.Text = mod.size + " MB";
                    modDownloadButton.Font = new Font("DejaVu Sans Condensed", 10, FontStyle.Regular);
                    modPanel.Invoke((MethodInvoker)delegate { modPanel.Controls.Add(modDownloadButton); });

                    ProgressBar modProgressBar = new ProgressBar();
                    modProgressBar.Size = new Size(modDownloadButton.Width - 12, 8);
                    modProgressBar.Location = new Point(6, modDownloadButton.Height - modProgressBar.Height - 6);
                    modProgressBar.Visible = false;
                    modDownloadButton.Invoke((MethodInvoker)delegate { modDownloadButton.Controls.Add(modProgressBar); });
                    if (!File.Exists(Application.StartupPath + "\\Packages\\" + mod.fileName))
                    {
                        modDownloadButton.Click += delegate { Task.Run(() => DownloadFile(true, modDownloadButton, modProgressBar, mod, type)); };
                    }
                    else if (type == "cars" || type == "tracks")
                    {
                        if (ModIsInstalled(mod))
                        {
                            modDownloadButton.Invoke((MethodInvoker)delegate { modDownloadButton.Text = "Uninstall"; });
                            //modDownloadButton.Invoke((MethodInvoker)delegate { modDownloadButton.UseVisualStyleBackColor = false; });
                            modDownloadButton.Invoke((MethodInvoker)delegate { modDownloadButton.BackColor = Color.Salmon; });
                            modDownloadButton.Click += delegate { Task.Run(() => UninstallMod(modDownloadButton, modProgressBar, mod, type)); };
                        }
                        else
                        {
                            modDownloadButton.Invoke((MethodInvoker)delegate { modDownloadButton.Text = "Install"; });
                            //modDownloadButton.Invoke((MethodInvoker)delegate { modDownloadButton.UseVisualStyleBackColor = false; });
                            modDownloadButton.Invoke((MethodInvoker)delegate { modDownloadButton.BackColor = Color.LightGreen; });
                            modDownloadButton.Click += delegate {
                                modDownloadButton.Invoke((MethodInvoker)delegate { modDownloadButton.Text = "Queued"; });
                                modProgressBar.Invoke((MethodInvoker)delegate { modProgressBar.Visible = true; });
                                Task.Run(() => Extract(modDownloadButton, modProgressBar, mod, type));
                            };
                        }
                    }
                    else
                    {
                        modDownloadButton.Invoke((MethodInvoker)delegate { modDownloadButton.Text = "Open"; });
                        modDownloadButton.Invoke((MethodInvoker)delegate { modDownloadButton.UseVisualStyleBackColor = false; });
                        modDownloadButton.Click += delegate { Process.Start(Application.StartupPath + "\\Packages\\" + mod.fileName); };
                    }
                    mods++;
                }
            }
        }
Exemplo n.º 15
0
        // Populate news panel 
        public void PopulateNews()
        {
            newsPage.Invoke((MethodInvoker)delegate { newsPage.Controls.Remove(loadingNewsLabel); });

            int news = 0;
            foreach (News n in newsList)
            {
                Panel newsPanel = new Panel();
                newsPanel.Size = new Size(865, 61);
                newsPanel.Location = new Point(-1, -1 + (newsPanel.Height - 1) * news);
                newsPanel.BorderStyle = BorderStyle.FixedSingle;
                newsPage.Invoke((MethodInvoker)delegate { newsPage.Controls.Add(newsPanel); });
                newsPanel.MouseHover += delegate { newsPage.Focus(); };

                Label newsTitleLabel = new Label();
                newsTitleLabel.Text = n.title.ToUpper();
                newsTitleLabel.ForeColor = Color.Black;
                newsTitleLabel.Location = new Point(0, 0);
                newsTitleLabel.Padding = new Padding(4, 10, 0, 0);
                newsTitleLabel.AutoSize = true;
                newsTitleLabel.Dock = DockStyle.Left;
                newsTitleLabel.Font = new Font("Arimo", 12, FontStyle.Bold);
                newsPanel.Invoke((MethodInvoker)delegate { newsPanel.Controls.Add(newsTitleLabel); });

                Label newsAuthorLabel = new Label();
                newsAuthorLabel.Text = n.author;
                newsAuthorLabel.ForeColor = Color.FromArgb(64, 64, 64);
                newsAuthorLabel.Location = new Point(5, newsPanel.Height - 20);
                newsAuthorLabel.AutoSize = true;
                newsAuthorLabel.Font = new Font("DejaVu Sans Condensed", 8, FontStyle.Regular);
                newsPanel.Invoke((MethodInvoker)delegate { newsPanel.Controls.Add(newsAuthorLabel); });

                Label newsDateLabel = new Label();
                newsDateLabel.Text = n.date.ToShortDateString();
                newsDateLabel.ForeColor = Color.FromArgb(64, 64, 64);
                newsDateLabel.Location = new Point(20 + newsAuthorLabel.Width, newsPanel.Height - 20);
                newsDateLabel.AutoSize = true;
                newsDateLabel.Font = new Font("DejaVu Sans Condensed", 8, FontStyle.Regular);
                newsPanel.Invoke((MethodInvoker)delegate { newsPanel.Controls.Add(newsDateLabel); });

                Button newsLinkButton = new Button();
                newsLinkButton.Size = new Size(100, 50);
                newsLinkButton.ForeColor = Color.Black;
                newsLinkButton.BackColor = Color.WhiteSmoke;
                newsLinkButton.UseVisualStyleBackColor = false;
                newsLinkButton.Dock = DockStyle.Right;
                newsLinkButton.Text = "Read more...";
                newsLinkButton.Font = new Font("DejaVu Sans Condensed", 10, FontStyle.Regular);
                newsPanel.Invoke((MethodInvoker)delegate { newsPanel.Controls.Add(newsLinkButton); });

                newsLinkButton.Click += delegate { Process.Start(n.link); };



                news++;
            }
        }
Exemplo n.º 16
0
        public static void loadDeckFromFile(Action<string> buttonClickedCallBack)
        {
            var deckNames = Directory.GetFiles(".").Where(x => x.EndsWith(".jas")).Select(x => x.Substring(2)).ToArray();
            Panel deckAsker = new Panel();

            deckAsker.Size = new Size(500, 200);
            //deckAsker.Location = new Point(Size.Width / 2, (Size.Height / 3) * 2);
            int Y = 0;
            int X = 0;
            int c = 0;
            var g = GUI.showWindow(deckAsker);
            foreach (string name in deckNames)
            {
                c++;
                var xd = new Button();
                xd.Text = name;
                xd.Location = new Point(X, Y);
                Y += xd.Height;
                if (c%8 == 0)
                {
                    X += 80;
                    Y = 0;
                }
                var name1 = name;
                xd.MouseDown += (_, __) =>
                {
                    buttonClickedCallBack(name1);
                    g.close();
                };

                if (deckAsker.InvokeRequired)
                {
                    deckAsker.Invoke(new Action(() =>
                    {
                        deckAsker.Controls.Add(xd);
                    }));
                }
                else
                {
                    deckAsker.Controls.Add(xd);
                }
            }
        }