コード例 #1
0
        public ServerGUI(string name)
        {
            this.Size           = new Size(180, 240);
            this.Name           = name;
            this.DoubleBuffered = true;
            this.ImageDirectory = Path.GetTempPath() + @"\Moonbyte\ServerHosting\";

            if (!Directory.Exists(ImageDirectory))
            {
                Directory.CreateDirectory(ImageDirectory);
            }
            ImageDirectory += this.Name + "img.png";

            downloadImageProgress          = new MaterialProgressBar();
            downloadImageProgress.Width    = this.Width / 2;
            downloadImageProgress.Location = new Point((this.Width / 2) - (downloadImageProgress.Width / 2), (this.Height / 2) - (downloadImageProgress.Height / 2));

            this.Controls.Add(downloadImageProgress);

            downloadProgressLabel          = new MaterialLabel();
            downloadProgressLabel.Location = new Point((this.Width / 2) - (downloadProgressLabel.Width / 2), (this.Height / 2) + (downloadImageProgress.Height / 2) + (downloadProgressLabel.Height));
            downloadProgressLabel.Text     = "Downloading...";

            this.Controls.Add(downloadProgressLabel);

            SuspendDrawing();

            SaveImage();

            ResumeDrawing();
        }
コード例 #2
0
        public Form1()
        {
            InitializeComponent();
            Debug.WriteLine("HI");
            MaterialSkinManager materialSkinManager = MaterialSkinManager.Instance;

            materialSkinManager.AddFormToManage(this);
            materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT;
            MaterialProgressBar materialProgressBar1 = new MaterialProgressBar();

            materialSkinManager.ColorScheme = new ColorScheme(
                Primary.Blue400, Primary.Blue500,
                Primary.Blue500, Accent.LightBlue200,
                TextShade.BLACK
                );

            string sDirPath;

            sDirPath = Application.StartupPath + @"\out";
            DirectoryInfo di = new DirectoryInfo(sDirPath);

            if (di.Exists == false)// Preset 디렉토리가 없으면 새로 만듭니다.
            {
                di.Create();
            }
        }
コード例 #3
0
        public static async Task LoadMetaData(IProgress <int> progress, MaterialProgressBar dataLoadProgressBar, ComboBox qualityFormatComboBox, MaterialSingleLineTextField videoUrlTxtBox
                                              , Label titleLabel, MaterialLabel durationLabel, PictureBox thumbNailPictureBox)
        {
            for (int i = 0; i <= 100; i++)
            {
                Thread.Sleep(20);
                if (dataLoadProgressBar.Value == 25)
                {
                    ExtensionMethods.SynchronizedInvoke(qualityFormatComboBox, () => qualityFormatComboBox.Items.Clear());
                    progress.Report(i);
                }
                else if (dataLoadProgressBar.Value == 50)
                {
                    _id = YoutubeClient.ParseVideoId(videoUrlTxtBox.Text);
                    GetDownloadOptions(qualityFormatComboBox);
                    progress.Report(i);
                }
                else if (dataLoadProgressBar.Value == 75)
                {
                    var _metaData = await GetMetaData(_client, _id);

                    UpdateVideoInfoControls(_metaData, _id, titleLabel, durationLabel, thumbNailPictureBox);
                    progress.Report(i);
                }
                else if (dataLoadProgressBar.Value == 0 || dataLoadProgressBar.Value > 0)
                {
                    progress.Report(i);
                }
            }
        }
コード例 #4
0
 public UpdaterService(Label labelStatus, MaterialProgressBar materialProgressBar, Button mainButton, Label currentVersionNumber, Label newVersionNumber)
 {
     this.labelStatus          = labelStatus;
     this.materialProgressBar  = materialProgressBar;
     this.mainButton           = mainButton;
     this.currentVersionNumber = currentVersionNumber;
     this.newVersionNumber     = newVersionNumber;
 }
コード例 #5
0
        public static void CheckException(Exception ex, MaterialProgressBar dataLoadProgressBar)
        {
            Tuple <Type, string> type = ExceptionData.ExceptionList.Find(e => e.Item1.IsInstanceOfType(ex));

            ExceptionMessageBox exceptionMessage = new ExceptionMessageBox(type.Item2);

            exceptionMessage.ShowDialog();
            dataLoadProgressBar.Value = 0;
        }
コード例 #6
0
ファイル: WorkersControl.cs プロジェクト: kmataru/bean-cannon
        private void AddOrUpdateToListViewContent(IFlooder flooder)
        {
            if (flooder == null)
            {
                throw new ArgumentNullException(nameof(flooder));
            }

            if (flooder.State.ManagedThreadId == 0)
            {
                return;
            }

            ListViewItem currentListViewItem = listViewWorkers.Items.Cast <ListViewItem>()
                                               .FirstOrDefault(w => w.Text == $"W-{flooder.State.ManagedThreadId}");

            var listViewItemExists = null != currentListViewItem;

            listViewWorkers.BeginUpdate();

            if (!listViewItemExists)
            {
                var item = new ListViewItem($"W-{flooder.State.ManagedThreadId}");
                var data = new[] {
                    String.Empty,
                    String.Empty,
                    String.Empty,
                    String.Empty,
                    String.Empty
                };

                item.SubItems.AddRange(data);
                listViewWorkers.Items.Add(item);

                {
                    MaterialProgressBar progressBar = new MaterialProgressBar();
                    progressBar.Depth      = 0;
                    progressBar.Location   = new Point(834, 64);
                    progressBar.MouseState = MaterialSkin.MouseState.HOVER;
                    progressBar.Size       = new Size(157, 5);
                    progressBar.Maximum    = 100;
                    progressBar.Value      = 0;

                    listViewWorkers.Controls.Add(progressBar);

                    listViewWorkers.TriggerSizeChangedEvents();
                }

                currentListViewItem = item;
            }

            var currentIndex       = listViewWorkers.Items.IndexOf(currentListViewItem);
            var currentProgressBar = (listViewWorkers.Controls[currentIndex] as ProgressBar);

            UpdateWorkerData(currentListViewItem.SubItems, currentProgressBar, flooder);

            listViewWorkers.EndUpdate();
        }
コード例 #7
0
ファイル: main.cs プロジェクト: xHeaven/Krawk-Protector
 private void Progress()
 {
     for (int i = 0; i < this.materialProgressBar1.Maximum; i++)
     {
         MaterialProgressBar materialProgressBar = this.materialProgressBar1;
         int value = materialProgressBar.Value;
         materialProgressBar.Value = value + 1;
     }
 }
コード例 #8
0
        private void UpdateUI(Label label, MaterialProgressBar progress, long ping)
        {
            // Use UI thread
            Invoke((MethodInvoker) delegate
            {
                // Full update
                if (progress.Value + updateLimit < (int)ping || progress.Value - updateLimit > (int)ping)
                {
                    label.Text     = ping.ToString();
                    progress.Value = (ping >= progress.Maximum) ? progress.Maximum : (int)ping;
                }
                // Small increase
                else if (progress.Value < (int)ping && progress.Value != 0)
                {
                    label.Text = (int.Parse(label.Text) + 1).ToString();
                    progress.Value++;
                }
                // Small decrease
                else if (progress.Value > (int)ping)
                {
                    label.Text = (int.Parse(label.Text) - 1).ToString();
                    progress.Value--;
                }
                // Do nothing
                else if (progress.Value == (int)ping)
                {
                }

                if (progress.Value > extremePing)
                {
                    label.ForeColor = Color.Red;
                }
                else if (progress.Value > highPing)
                {
                    label.ForeColor = Color.Orange;
                }
                else
                {
                    label.ForeColor = SystemColors.ControlText;
                }
            });
        }
コード例 #9
0
        private void UpdateServer(Label label, MaterialProgressBar progress, int id)
        {
            try
            {
                Ping ping = new Ping();

                PingReply pingReply = ping.Send(addressesList[id, 0], 1000);
                var       timeout   = (pingReply.Status != IPStatus.Success) ? true : false;

                if (!timeout)
                {
                    // Update UI
                    UpdateUI(label, progress, pingReply.RoundtripTime);
                }

                Thread.Sleep(checkSleep);
            }
            catch
            { }
        }
コード例 #10
0
        public void AddToQueuePanel(DownloadInfo item)
        {
            Panel p = new Panel()
            {
                Size = new Size(764, 125),
                Location = new Point(3, 3),
                BackColor = Color.White
            };
            Label lblTitle = new Label()
            {
                Text = item.ContentTitle,
                AutoSize = true,
                Location = new Point(88, 4),
                Font = new Font(FontFamily.GenericSansSerif, 13),
                Visible = true
            };
            MaterialLabel lblSize = new MaterialLabel()
            {
                Text = Common.Methods.FormatBytes(item.ByteLength),
                AutoSize = true,
                Location = new Point(112, 29),
                Visible = true
            };
            MaterialLabel lblProgress = new MaterialLabel()
            {
                Text = "0B/" + Common.Methods.FormatBytes(item.ByteLength),
                AutoSize = true,
                Location = new Point(88, 88),
                Visible = true
            };
            MaterialLabel lblQueuePosition = new MaterialLabel()
            {
                Text = Queue.Count.ToString(),
                AutoSize = true,
                Visible = true
            };
            lblQueuePosition.Location = new Point(754 - lblQueuePosition.Width, 4);

            MaterialProgressBar pbDownloadProgress = new MaterialProgressBar()
            {
                AutoSize = false,
                Visible = true,
                Size = new Size(662, 5),
                Location = new Point(92, 110)
            };

            PictureBox titleThumb = new PictureBox()
            {
                Size = new Size(79, 119),
                Location = new Point(3, 3),
                BackgroundImageLayout = ImageLayout.Stretch,
                BackgroundImage = Common.Methods.getImageFromUrl(item.ContentThumbnailUri),
                Visible = true
            };
            MaterialFlatButton btnRemoveDownload = new MaterialFlatButton()
            {
                Location = new Point(710, 29),
                Visible = true,
                Icon = PlexDL.Properties.Resources.baseline_cancel_black_18dp,
                AutoSize = true,
            };
            btnRemoveDownload.Click += new System.EventHandler(this.btnRemoveDownload_Click);

            p.Controls.Add(lblTitle);
            p.Controls.Add(lblSize);
            p.Controls.Add(lblQueuePosition);
            p.Controls.Add(lblProgress);
            p.Controls.Add(titleThumb);
            p.Controls.Add(pbDownloadProgress);
            p.Controls.Add(btnRemoveDownload);

            flpDownloadQueue.Controls.Add(p);
        }
コード例 #11
0
        private void InitializeControls()
        {
            // Resize
            if ((addressesList.GetLength(0) != 0))
            {
                List <int> counter    = new List <int>();
                var        counterTmp = 0;

                // Find highest tab count
                for (int i = 0; i < tabsList.GetLength(0); i++)
                {
                    for (int j = 0; j < addressesList.GetLength(0); j++)
                    {
                        if (tabsList[i] == addressesList[j, 2])
                        {
                            counterTmp++;
                        }
                    }

                    counter.Add(counterTmp);
                    counterTmp = 0;
                }

                counter.Sort();
                counter.Reverse();

                // Fix size
                var increaseBy = ((counter[0] % 3) == 0) ? (counter[0] / 3) - 1 : (counter[0] / 3);

                // Lock size
                defaultWidth  = Width;
                defaultHeight = Size.Height + (increaseBy * (panelTemplate.Height + panelTemplate.Margin.Top));

                Size            = new Size(Size.Width, Size.Height + (increaseBy * (panelTemplate.Height + panelTemplate.Margin.Top)));
                tabControl.Size = new Size(tabControl.Width, tabControl.Height + (increaseBy * (panelTemplate.Height + panelTemplate.Margin.Top)));
            }
            else
            {
                // Lock size
                defaultWidth  = Width;
                defaultHeight = Height;
            }

            // Skip first tab
            for (int i = 1; i < tabsList.GetLength(0); i++)
            {
                // Create tabs
                tabControl.TabPages.Add(tabsList[i]);
            }

            var activeTabId = 0;

            foreach (var tab in tabControl.TabPages)
            {
                activeTabId++;

                // Modify tab
                var obj = tab as TabPage;
                obj.BackColor = Color.White;
                obj.Padding   = new Padding(3);

                // Change name of first tab
                if (activeTabId == 1)
                {
                    obj.Text = tabsList[0];
                }
                else
                {
                    // Create flow layout panel
                    var flowCntrl = new FlowLayoutPanel();

                    flowCntrl.Name      = Resources.flowPanelControl + activeTabId.ToString();
                    flowCntrl.Dock      = DockStyle.Fill;
                    flowCntrl.BackColor = Color.White;
                    obj.Controls.Add(flowCntrl);
                }

                for (int i = 0; i < addressesList.GetLength(0); i++)
                {
                    // Check location
                    if (addressesList[i, 2] == obj.Text)
                    {
                        var fixedId = i + 1;

                        // Create panel
                        var panelCntrl = new Panel();

                        panelCntrl.BackColor = Color.White;
                        panelCntrl.Size      = panelTemplate.Size;
                        panelCntrl.Margin    = panelTemplate.Margin;
                        panelCntrl.Visible   = true;

                        // Copy controls from template
                        foreach (Control control in panelTemplate.Controls)
                        {
                            if (control is Label)
                            {
                                var cntrl    = control as Label;
                                var newCntrl = new Label();

                                if (control.Text == "0") // Ping label
                                {
                                    newCntrl.Name = Resources.serverPingControl + fixedId.ToString();
                                    newCntrl.Text = Resources.calculatingText;
                                }
                                else // Name label
                                {
                                    newCntrl.Name = Resources.serverLabelControl + fixedId.ToString();
                                }

                                newCntrl.TextAlign = cntrl.TextAlign;
                                newCntrl.Location  = cntrl.Location;
                                newCntrl.Size      = cntrl.Size;
                                newCntrl.Font      = cntrl.Font;
                                newCntrl.Visible   = true;

                                panelCntrl.Controls.Add(newCntrl);
                            }
                            else if (control is MaterialProgressBar)
                            {
                                var cntrl    = control as MaterialProgressBar;
                                var newCntrl = new MaterialProgressBar();

                                newCntrl.Name     = Resources.serverProgressControl + fixedId.ToString();
                                newCntrl.Maximum  = cntrl.Maximum;
                                newCntrl.Location = cntrl.Location;
                                newCntrl.Size     = cntrl.Size;
                                newCntrl.Font     = cntrl.Font;
                                newCntrl.Visible  = true;

                                panelCntrl.Controls.Add(newCntrl);
                            }
                        }

                        // Apply to flow layout panel
                        var flowPanel = (FlowLayoutPanel)Controls.Find(Resources.flowPanelControl + activeTabId.ToString(), true)[0];
                        flowPanel.Controls.Add(panelCntrl);
                    }
                }
            }

            // Update labels
            for (int i = 0; i < addressesList.GetLength(0); i++)
            {
                try
                {
                    var fixedId = i + 1;
                    var label   = (Label)Controls.Find(Resources.serverLabelControl + fixedId.ToString(), true)[0];
                    label.Text = addressesList[i, 1];
                }
                catch
                {
                    // Exception
                    throw new Exception("Make sure that every address is connected to a tab!");
                }
            }
        }