public GridMaker(TableLayoutPanel inputtable, CustomProgressBar progbar) { this.paneltable = inputtable; this.quickpics = new List <Label>(); this.fileNames = new List <String>(); this.progbar = progbar; }
private void InitializeComponent() { this.components = new Container(); ComponentResourceManager arg_57_0 = new ComponentResourceManager(typeof(UpdateFirmwareDownloadControl)); this.continueButton = new Button(); this.customProgressBar = new CustomProgressBar(); this.messageLabel = new CustomLabel(this.components); base.SuspendLayout(); this.continueButton.BackgroundImage = Resources.blue_background_1; arg_57_0.ApplyResources(this.continueButton, "continueButton"); this.continueButton.FlatAppearance.BorderSize = 0; this.continueButton.ForeColor = Color.White; this.continueButton.Name = "continueButton"; this.continueButton.UseVisualStyleBackColor = false; this.continueButton.Click += new EventHandler(this.continueButton_Click); this.customProgressBar.BackColor = Color.FromArgb(216, 216, 216); this.customProgressBar.ForeColor = Color.FromArgb(42, 173, 223); arg_57_0.ApplyResources(this.customProgressBar, "customProgressBar"); this.customProgressBar.Name = "customProgressBar"; arg_57_0.ApplyResources(this.messageLabel, "messageLabel"); this.messageLabel.LineDistance = 1; this.messageLabel.Name = "messageLabel"; arg_57_0.ApplyResources(this, "$this"); base.AutoScaleMode = AutoScaleMode.Font; this.BackColor = Color.White; base.Controls.Add(this.continueButton); base.Controls.Add(this.customProgressBar); base.Controls.Add(this.messageLabel); base.Name = "UpdateFirmwareDownloadControl"; base.ResumeLayout(false); }
public static void setValue(CustomProgressBar pb, int v, string text) { pb.Maximum = 100; pb.Minimum = 0; pb.Value = v; pb.Text = text; }
public override void Decrypt(FileInfo input, FileInfo output) { FileStream inputStream = input.OpenRead(); FileStream outputStream = output.OpenWrite(); int[] code = Key.Code(); byte[] bytes = new byte[code.Length]; long i = 0; int mx = 0; while (i < inputStream.Length) { mx = code.Length; if (inputStream.Length - i < mx) { mx = (int)(inputStream.Length - i); } inputStream.Read(bytes, 0, mx); for (int j = 0; j < mx; j++) { bytes[j] = (byte)ChangeByte(bytes[j], -code[j]); i++; CustomProgressBar.update((int)((i) * 100 / inputStream.Length)); } outputStream.Write(bytes, 0, mx); } inputStream.Close(); outputStream.Close(); }
private void Form_Load(object sender, EventArgs e) { Color backColor = Color.FromArgb(36, 36, 36); Color frontColor = Color.FromArgb(30, 30, 30); Color textColor = Color.White; Color barColor = Color.FromArgb(0, 255, 0); Control.BackColor = frontColor; progressBar = new CustomProgressBar(); progressBar.foreColor = barColor; progressBar.backColor = backColor; progressBar.Visable = true; progressBar.Location = new Point(10, 48); progressBar.Size = new Size(1102, 13); string variables = "public static int x;\npublic static int x = 5;\npublic int x;\npublic int x = 5;\nint x;\nint x = 5;"; string whileandif = "if ( true ) {\nwhile ( true ) {"; string function = "public static string x () {"; string sub = "public static void x () {"; string clas = "class x {"; string end = "if ( true ) {\n}"; string boundry = "\n---\n"; string all = variables + boundry + whileandif + boundry + function + boundry + sub + boundry + clas + boundry + end; Input.Text = whileandif; Start(); }
private void AssignControls(StatusLabel label, CustomProgressBar bar, State state) { label.UpdateContent(state); if (bar != null) { bar.Value = state.DownloadProgress; } }
public SuccessBox(string msg) { DialogResult result = MessageBox.Show(msg, "Успешно", MessageBoxButtons.OK, MessageBoxIcon.None); if (result == DialogResult.OK) { CustomProgressBar.update(0); } }
public override void Encrypt(FileInfo input, FileInfo output) { if (key == null) { Console.WriteLine("Hard key is null"); return; } FileStream inputStream = input.OpenRead(); FileStream outputStream = output.OpenWrite(); int j = 0; Random rnd = new Random(); long i = 0; while (j < key.MaxBadBytes) { int bd = key.getBadByte(j); CustomProgressBar.update((int)(j * 50 / key.MaxBadBytes)); if (j == 0 || (bd - key.getBadByte(j - 1)) == 1) { outputStream.WriteByte((byte)rnd.Next(1, 256)); j++; continue; } for (bd--; bd > key.getBadByte(j - 1); bd--) { Console.WriteLine(key.getCurByte((int)(i % key.MaxCryptoLength))); outputStream.WriteByte((byte)ChangeByte(inputStream.ReadByte(), key.getCurByte((int)(i % key.MaxCryptoLength)))); Console.WriteLine("Printed at " + i + " " + j); i++; } outputStream.WriteByte((byte)rnd.Next(1, 256)); j++; } for (; i < inputStream.Length; i++) { CustomProgressBar.update(50 + (int)(i * 50 / inputStream.Length)); outputStream.WriteByte((byte)ChangeByte(inputStream.ReadByte(), key.getCurByte((int)(i % key.MaxCryptoLength)))); } inputStream.Close(); outputStream.Close(); }
/// <summary> /// 更新滚动条 /// </summary> /// <param name="value"></param> public static void UpdatePrgBarValue(CustomProgressBar ctrl, int value, Color foreColor, string text) { if (ctrl.InvokeRequired) { UpdatePrgBarValueDelegate d = new UpdatePrgBarValueDelegate(UpdatePrgBarValue); ctrl.Invoke(d, ctrl, value, foreColor, text); } else { ctrl.Value = value; ctrl.ForeColor = foreColor; ctrl.Text = text; } }
protected override void OnElementChanged(ElementChangedEventArgs <ProgressBar> e) { base.OnElementChanged(e); //Control.ProgressDrawable.SetColorFilter(Color.FromRgb(182, 231, 233).ToAndroid(), Android.Graphics.PorterDuff.Mode.SrcIn); //Control.ProgressTintList = Android.Content.Res.ColorStateList.ValueOf(Color.Pink.ToAndroid()); Control.ScaleY = 10; // This changes the height if (e.NewElement != null) { DefaultTint(); progressBar = (CustomProgressBar)e.NewElement; progressBar.SpeedResetUpdate += ResetTint; progressBar.CurrentSpeedUpdate += ChangeTint; } }
public Form1() { InitializeComponent(); customProgressBar1 = new CustomProgressBar(); customProgressBar1.DisplayStyle = ProgressBarDisplayText.Percentage; customProgressBar1.Value = 0; customProgressBar1.SetBounds(23, 120, 505, 25); customProgressBar1.Visible = false; localization = new Localization(); button_exit.Text = localization.GetValueForItem(LocalizedItem.ButtonExit); button_decompose.Text = localization.GetValueForItem(LocalizedItem.ButtonDecompose); label_file.Text = localization.GetValueForItem(LocalizedItem.TextFile); label_destFolder.Text = localization.GetValueForItem(LocalizedItem.TextDestFolder); label_autor.Text = localization.GetValueForItem(LocalizedItem.TextAuthor); }
// Delete all other files, split up downloads into new threads and start them public static void sync(CustomProgressBar progbar, GridMaker displayController, MainDisplay me) { if (STOP || isSyncing) { return; } isSyncing = true; try { DirectoryInfo di = new DirectoryInfo(Properties.Settings.Default.runpath); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } foreach (DirectoryInfo dir in di.GetDirectories()) { dir.Delete(true); } } catch (IOException) { Thread.CurrentThread.Abort(); } AisUriProvider api = new AisUriProvider(); List <Uri> filesFromServer = api.Get().ToList(); if (progbar.InvokeRequired) { progbar.BeginInvoke((MethodInvoker) delegate() { progbar.Maximum = filesFromServer.Count(); }); } else { progbar.Maximum = filesFromServer.Count(); } for (int i = 0; i < filesFromServer.Count; i = i + (filesFromServer.Count / Properties.Settings.Default.n)) { int lowerBound = i; int upperBound = i + (filesFromServer.Count / Properties.Settings.Default.n); Thread t3 = new Thread(() => downloadPattern(filesFromServer, lowerBound, upperBound, progbar, displayController, me)); t3.Start(); } }
/// <summary> /// Method for setting up ProgressBar value (for cross threaded) /// </summary> /// <param name="value"></param> /// <param name="pb"></param> public void SetProgressBarValue(int value, string text, CustomProgressBar pb) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (pb.InvokeRequired) { SetProgressBarDelegate del = new SetProgressBarDelegate(SetProgressBarValue); this.Invoke(del, new object[] { value, text, pb }); } else { pb.Value = value; pb.CustomText = value == 0 ? "" : " - " + text; } #endregion }
//========================================================================================================================= // constr. //========================================================================================================================= public Bot(BotForm parentForm, Log log, Trajet trajet, Job job, Fight fight, System.Windows.Forms.Timer timer, Stopwatch stopWatch, Button runBotBtn, Button pauseBotBtn, PictureBox botStatePictureBox, PictureBox minimapPictureBox, Panel gamePanel, IntPtr gameHandle, CustomProgressBar podProgressBar) { ParentForm = parentForm; Log = log; Trajet = trajet; Job = job; Fight = fight; Timer = timer; StopWatch = stopWatch; RunBotBtn = runBotBtn; PauseBotBtn = pauseBotBtn; BotStatePictureBox = botStatePictureBox; MinimapPictureBox = minimapPictureBox; GamePanel = gamePanel; GameHandle = gameHandle; PodProgressBar = podProgressBar; }
protected override void OnElementChanged(ElementChangedEventArgs <ProgressBar> e) { base.OnElementChanged(e); if (e.NewElement != null) { DefaultTint(); progressBar = (CustomProgressBar)e.NewElement; //Control.TrackTintColor = Color.FromHex("E3E3E3").ToUIColor(); progressBar.SpeedResetUpdate += ResetTint; progressBar.CurrentSpeedUpdate += ChangeTint; } if (e.OldElement != null) { progressBar.SpeedResetUpdate -= ResetTint; progressBar.CurrentSpeedUpdate -= ChangeTint; } }
public override void LayoutSubviews() { base.LayoutSubviews(); try { CustomProgressBar customProgressBar = Element as CustomProgressBar; if (customProgressBar != null) { float scaleCoef = (float)customProgressBar.CustomScale; if ((scaleCoef > 1f) && ((Transform == null) || (Transform.yy != scaleCoef))) { Transform = CGAffineTransform.MakeScale(1.0f, scaleCoef); } } } catch { } }
public override void Decrypt(FileInfo input, FileInfo output) { if (key == null) { Console.WriteLine("Hard key is null"); return; } FileStream inputStream = input.OpenRead(); FileStream outputStream = output.OpenWrite(); int j = 0; long ks = 0; //todo переписать весь блок под чтение по байтам в одном цикле int bd = 0; for (long i = 0; i < inputStream.Length; i++) { //if(j < key.MaxBadBytes) bd = key.getBadByte(j); CustomProgressBar.update((int)(i * 100 / inputStream.Length)); while (bd < i && j < key.MaxBadBytes) { bd = key.getBadByte(j); j++; } if (bd == i) { inputStream.ReadByte(); continue; } Console.WriteLine(-key.getCurByte((int)(ks % key.MaxCryptoLength))); outputStream.WriteByte((byte)ChangeByte(inputStream.ReadByte(), -key.getCurByte((int)(ks % key.MaxCryptoLength)))); Console.WriteLine("Printed at " + i + " " + j + " " + bd + " " + ks); ks++; } inputStream.Close(); outputStream.Close(); }
public override void Encrypt(FileInfo input, FileInfo output) { if (Key == null) { throw new CryptException("Key File not founded!"); } FileStream inputStream = input.OpenRead(); FileStream outputStream = output.OpenWrite(); for (long i = 0; i < inputStream.Length; i++) { int Byte = inputStream.ReadByte(); Byte = ChangeByte(Byte, 1); outputStream.WriteByte((byte)Byte); CustomProgressBar.update((int)((i + 1) * 100 / inputStream.Length)); } inputStream.Close(); outputStream.Close(); }
// Fired when sync ends... either when complete or canceled public static void finishFile(CustomProgressBar bar, GridMaker displayController, MainDisplay me, bool onlyDisplayDownloaded) { Debug.WriteLine("done syncing!"); me.cancel = false; System.Threading.Thread.Sleep(1000); if (bar.InvokeRequired) { bar.BeginInvoke((MethodInvoker) delegate() { bar.Value = 0; }); bar.BeginInvoke((MethodInvoker) delegate() { bar.UpdateText(); }); bar.BeginInvoke((MethodInvoker) delegate() { bar.Refresh(); }); bar.BeginInvoke((MethodInvoker) delegate() { bar.UpdateText(); }); } else { bar.Value = 0; bar.UpdateText(); bar.Refresh(); bar.UpdateText(); } displayController.generateFromFolder(me, onlyDisplayDownloaded); isSyncing = false; }
public Form1() { InitializeComponent(); customProgressBar1 = new CustomProgressBar(); customProgressBar1.DisplayStyle = ProgressBarDisplayText.Percentage; customProgressBar1.Value = 0; customProgressBar1.SetBounds(23, 414, 505, 25); customProgressBar1.Visible = false; localization = new Localization(); button_exit.Text = localization.GetValueForItem(LocalizedItem.ButtonExit); button_clear.Text = localization.GetValueForItem(LocalizedItem.ButtonClear); button_search.Text = localization.GetValueForItem(LocalizedItem.ButtonSearch); label_folder.Text = localization.GetValueForItem(LocalizedItem.TextFolder); label_phrase.Text = localization.GetValueForItem(LocalizedItem.TextPhrase); label_results.Text = localization.GetValueForItem(LocalizedItem.TextResults); label_autor.Text = localization.GetValueForItem(LocalizedItem.TextAuthor); checkBox_foundOnly.Text = localization.GetValueForItem(LocalizedItem.TextShowFoundOnly); listView1.Columns[0].Text = localization.GetValueForItem(LocalizedItem.TextPdfDocument); listView1.Columns[1].Text = localization.GetValueForItem(LocalizedItem.TextPages); }
//private void ProcessFileArrayThread(string[] paths) //{ // var t = new Thread(() => ProcessFileArray(paths)); // t.Start(); //} private void ProcessFileArray(string[] paths) { if (mainForm.InvokeRequired) { mainForm.Invoke((MethodInvoker) delegate { ChangeGuiState(GUIState.FilesSelected); }); } //mainForm.Invoke((MethodInvoker)delegate { panel_SendFiles.Visible = false; }); //ChangeGuiState(GUIState.FilesSelected); CustomProgressBar progressBar = new CustomProgressBar() { Size = new Size(FileAreaPanel.Width, 20), Location = new Point(0, 0), }; progressBar.BackgroundBarColor = GUITools.COLOR_DarkMode_Light; progressBar.ProgressBarColor = Color.Green; progressBar.Percentage = 0; mainForm.Invoke((MethodInvoker) delegate { panel_ButtonsMain.Controls.Add(progressBar); panel_SendFiles.Visible = false; }); for (int i = 0; i < paths.Length; i++) { decimal pp = (decimal)i / (decimal)paths.Length; progressBar.Percentage = (int)Math.Round(pp * 100); LocalFileStructure fStruct = new LocalFileStructure(); fStruct.FileStatus = FileStatus.Inactive; FileInfo fInfo = new FileInfo(paths[i]); fStruct.FilePath = paths[i]; fStruct.FileExtension = Path.GetExtension(paths[i]); fStruct.FileName = Path.GetFileNameWithoutExtension(paths[i]); fStruct.FileSize = fInfo.Length; fStruct.FullName = fInfo.Name; fStruct.FileID = i; fStruct.FileSize = fInfo.Length; AddNewQueuedFile(fStruct); } mainForm.Invoke((MethodInvoker) delegate { panel_SendFiles.Visible = true; progressBar.Visible = false; }); //mainForm.Invoke((MethodInvoker)delegate { progressBar.Visible = false; }); //foreach (string file in paths) //{ // LocalFileStructure fStruct = new LocalFileStructure(); // fStruct.FileStatus = FileStatus.Inactive; // FileInfo fInfo = new FileInfo(file); // fStruct.FilePath = file; // fStruct.FileExtension = Path.GetExtension(file); // fStruct.FileName = Path.GetFileNameWithoutExtension(file); // fStruct.FileSize = fInfo.Length; // fStruct.FullName = fInfo.Name; // fStruct.FileID = id; // fStruct.FileSize = fInfo.Length; // AddNewQueuedFile(fStruct); // id++; //} }
public static void ZipThenFtp(MainWnd mainWnd, TextBox tb_selectedPublishItemFullPath, CustomProgressBar pb_ZIP, CustomProgressBar pb_FTP, string SiteName) { string directoryForZipFtp = tb_selectedPublishItemFullPath.Text; string currentUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name; currentUser = currentUser.Contains(@"\") == true?currentUser.Replace('\\', '_') : currentUser; string zipFileName_Path = directoryForZipFtp + "_" + SitesLogic.Frontend + "_" + currentUser + ".zip"; Compression.SimpleZip(directoryForZipFtp, zipFileName_Path, mainWnd, pb_ZIP); string fileName = zipFileName_Path.Substring(zipFileName_Path.LastIndexOf('\\') + 1); fileName = SiteName + "_" + fileName; using (WebClient client = new WebClient()) { CancellationTokenSource ts_FTP = new CancellationTokenSource(); CancellationToken ct_FTP = ts_FTP.Token; Task pbFtp_Task = new Task(() => { pb_FTP.SetProgressBarValueByTicks(mainWnd, 100, "Uploading...", ct_FTP); }, ct_FTP); pbFtp_Task.Start(); client.Credentials = new NetworkCredential(UserName, Password); client.UploadFile(FTP_URL + fileName, WebRequestMethods.Ftp.UploadFile, zipFileName_Path); ts_FTP.Cancel(); mainWnd.SetProgressBarValue(100, "Upload Finished", pb_FTP); } MessageBox.Show("upload finished !!"); File.Delete(zipFileName_Path); mainWnd.SetProgressBarValue(0, "", pb_ZIP); mainWnd.SetProgressBarValue(0, "", pb_FTP); }
private void InitializeComponent() { ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (FUMOProgressPanel)); this.FUMOProgressPanel_ProgressBar = new CustomProgressBar(); this.FUMOProgressPanel_HelpButtonLabelPair = new CustomHelpButtonLabelPair(); this.FUMOProgressPanel_HeaderLbl = new Label(); this.FUMOProgressPanel_CloseBtnBox = new CustomButtonPushHorizBox(); this.FUMOProgressPanel_CloseBtn = new CustomButtonPush(); this.FUMOProgressPanel_ButtonBarSeperator = new CustomLabelSeparator(); this.FUMOProgressPanel_InstructionsLbl = new Label(); this.FUMOProgressPanel_DownloadProgressLbl = new Label(); this.FUMOProgressPanel_StopDownloadBtnBox = new CustomButtonPushHorizBox(); this.FUMOProgressPanel_StopDownloadBtn = new CustomButtonPush(); this.FUMOProgressPanel_DownloadBeingStoppedLbl = new Label(); this.FUMOProgressPanel_CloseBtnBox.SuspendLayout(); this.FUMOProgressPanel_StopDownloadBtnBox.SuspendLayout(); this.SuspendLayout(); this.FUMOProgressPanel_ProgressBar.BackColor = Color.FromArgb(204, 204, 204); componentResourceManager.ApplyResources((object) this.FUMOProgressPanel_ProgressBar, "FUMOProgressPanel_ProgressBar"); this.FUMOProgressPanel_ProgressBar.ForeColor = Color.FromArgb(32, 87, 143); this.FUMOProgressPanel_ProgressBar.Name = "FUMOProgressPanel_ProgressBar"; this.FUMOProgressPanel_ProgressBar.TabStop = false; this.FUMOProgressPanel_ProgressBar.Value = 0; this.FUMOProgressPanel_HelpButtonLabelPair.AccessibleRole = AccessibleRole.None; this.FUMOProgressPanel_HelpButtonLabelPair.BackColor = Color.Transparent; componentResourceManager.ApplyResources((object) this.FUMOProgressPanel_HelpButtonLabelPair, "FUMOProgressPanel_HelpButtonLabelPair"); this.FUMOProgressPanel_HelpButtonLabelPair.Name = "FUMOProgressPanel_HelpButtonLabelPair"; this.FUMOProgressPanel_HeaderLbl.BackColor = Color.Transparent; componentResourceManager.ApplyResources((object) this.FUMOProgressPanel_HeaderLbl, "FUMOProgressPanel_HeaderLbl"); this.FUMOProgressPanel_HeaderLbl.Name = "FUMOProgressPanel_HeaderLbl"; this.FUMOProgressPanel_CloseBtnBox.Controls.Add((Control) this.FUMOProgressPanel_CloseBtn); componentResourceManager.ApplyResources((object) this.FUMOProgressPanel_CloseBtnBox, "FUMOProgressPanel_CloseBtnBox"); this.FUMOProgressPanel_CloseBtnBox.HorizontalJustification = HorizontalJustificationEnum.Right; this.FUMOProgressPanel_CloseBtnBox.Name = "FUMOProgressPanel_CloseBtnBox"; this.FUMOProgressPanel_CloseBtn.BackColor = Color.White; this.FUMOProgressPanel_CloseBtn.BtnColor = PushButtonColorEnum.BlueGrey; this.FUMOProgressPanel_CloseBtn.BtnDoubleEndCaps = false; this.FUMOProgressPanel_CloseBtn.BtnEnabled = true; componentResourceManager.ApplyResources((object) this.FUMOProgressPanel_CloseBtn, "FUMOProgressPanel_CloseBtn"); this.FUMOProgressPanel_CloseBtn.Name = "FUMOProgressPanel_CloseBtn"; this.FUMOProgressPanel_ButtonBarSeperator.BackColor = Color.White; componentResourceManager.ApplyResources((object) this.FUMOProgressPanel_ButtonBarSeperator, "FUMOProgressPanel_ButtonBarSeperator"); this.FUMOProgressPanel_ButtonBarSeperator.Name = "FUMOProgressPanel_ButtonBarSeperator"; this.FUMOProgressPanel_ButtonBarSeperator.TabStop = false; this.FUMOProgressPanel_InstructionsLbl.AccessibleRole = AccessibleRole.None; componentResourceManager.ApplyResources((object) this.FUMOProgressPanel_InstructionsLbl, "FUMOProgressPanel_InstructionsLbl"); this.FUMOProgressPanel_InstructionsLbl.Name = "FUMOProgressPanel_InstructionsLbl"; componentResourceManager.ApplyResources((object) this.FUMOProgressPanel_DownloadProgressLbl, "FUMOProgressPanel_DownloadProgressLbl"); this.FUMOProgressPanel_DownloadProgressLbl.Name = "FUMOProgressPanel_DownloadProgressLbl"; this.FUMOProgressPanel_StopDownloadBtnBox.Controls.Add((Control) this.FUMOProgressPanel_StopDownloadBtn); componentResourceManager.ApplyResources((object) this.FUMOProgressPanel_StopDownloadBtnBox, "FUMOProgressPanel_StopDownloadBtnBox"); this.FUMOProgressPanel_StopDownloadBtnBox.HorizontalJustification = HorizontalJustificationEnum.Right; this.FUMOProgressPanel_StopDownloadBtnBox.Name = "FUMOProgressPanel_StopDownloadBtnBox"; this.FUMOProgressPanel_StopDownloadBtn.BackColor = Color.White; this.FUMOProgressPanel_StopDownloadBtn.BtnColor = PushButtonColorEnum.BlueGrey; this.FUMOProgressPanel_StopDownloadBtn.BtnDoubleEndCaps = false; this.FUMOProgressPanel_StopDownloadBtn.BtnEnabled = true; componentResourceManager.ApplyResources((object) this.FUMOProgressPanel_StopDownloadBtn, "FUMOProgressPanel_StopDownloadBtn"); this.FUMOProgressPanel_StopDownloadBtn.Name = "FUMOProgressPanel_StopDownloadBtn"; componentResourceManager.ApplyResources((object) this.FUMOProgressPanel_DownloadBeingStoppedLbl, "FUMOProgressPanel_DownloadBeingStoppedLbl"); this.FUMOProgressPanel_DownloadBeingStoppedLbl.Name = "FUMOProgressPanel_DownloadBeingStoppedLbl"; this.AutoScaleMode = AutoScaleMode.None; this.BackColor = Color.White; this.Controls.Add((Control) this.FUMOProgressPanel_StopDownloadBtnBox); this.Controls.Add((Control) this.FUMOProgressPanel_DownloadProgressLbl); this.Controls.Add((Control) this.FUMOProgressPanel_InstructionsLbl); this.Controls.Add((Control) this.FUMOProgressPanel_CloseBtnBox); this.Controls.Add((Control) this.FUMOProgressPanel_ButtonBarSeperator); this.Controls.Add((Control) this.FUMOProgressPanel_HelpButtonLabelPair); this.Controls.Add((Control) this.FUMOProgressPanel_HeaderLbl); this.Controls.Add((Control) this.FUMOProgressPanel_ProgressBar); this.Controls.Add((Control) this.FUMOProgressPanel_DownloadBeingStoppedLbl); componentResourceManager.ApplyResources((object) this, "$this"); this.Name = "FUMOProgressPanel"; this.FUMOProgressPanel_CloseBtnBox.ResumeLayout(false); this.FUMOProgressPanel_StopDownloadBtnBox.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); }
public StackLayout loadBars(IDictionary <String, Double[]> items, List <String> names, List <Double> quantities, List <Double> dris, int dayMult) { StackLayout parentStack = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; foreach (var item in items) { try { //encompassing stack StackLayout subStack = new StackLayout { Padding = new Thickness(0, 0, 0, 25), HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; //OLD //using the threshold values to calculate progress bar ratio //var ratio = item.Value[0] / ((minT + maxT) * dayMult); //threshold values var minT = item.Value[2]; var maxT = item.Value[3]; //using the dri to calculate progress bar ratio //the dri to consumed nutrient ratio var ratio = item.Value[0] / (item.Value[1] * dayMult); //what the progress bar should be set to var progress = ratio; //button text String nutText = "Consumed: " + Math.Round(item.Value[0], 2) + "\nDaily Recommended Intake: " + item.Value[1] * dayMult + "\nMin Recommended amount: " + Math.Round(minT, 2) + "\nMax Recommended amount: " + Math.Round(maxT, 2) + "\nRatio: " + Math.Round((ratio * 100), 2).ToString() + "%"; //nutrient ratio info button Button button = new Button { Text = item.Key, Font = Font.SystemFontOfSize(NamedSize.Medium), WidthRequest = 185, Margin = 15, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand, Style = App.Current.Resources["BtnStyle"] as Style, FontAttributes = FontAttributes.Bold }; //give click event to button button.Clicked += OnClicked; //printing out nutrition info void OnClicked(object sender, EventArgs ea) { string[] dispText = { item.Key, nutText }; MessagingCenter.Send <IVisualize, string[]>(this, "NutrientText", dispText); } //create custom progress bar var lowThresh = Convert.ToSingle(minT / item.Value[1] * dayMult); var maxThresh = Convert.ToSingle(maxT / item.Value[1] * dayMult); var bar = new CustomProgressBar(lowThresh, maxThresh) { Progress = 0, WidthRequest = 130, HeightRequest = 15, Scale = 1, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Margin = 10 }; //create content view for bar var barContentView = new ContentView { Scale = 3, Content = bar }; //add button to stack subStack.Children.Add(button); //add contentView/bar to stack subStack.Children.Add(barContentView); //add stack to parenting stack parentStack.Children.Add(subStack); bar.ProgressTo(progress, 1000, Easing.Linear); bar.Progress = progress; //in order to re color the bar } catch (Exception e) { Console.WriteLine("An error occurred: '{0}'", e); } } return(parentStack); }
public DarkFileDisplay(int width, int height, Bitmap thumbnail, bool framed, string fileName, Control target) { MainSize = new Size(width, height); Thumbnail = thumbnail; Framed = framed; FileName = fileName; int thumbBottomY = height - (int)((decimal)height / 3.4M); panel_Background = new Panel(); panel_Background.Size = MainSize; panel_Background.Paint += PaintBackgroundPanel; //target.Controls.Add(panel_Background); if (framed) { panel_Background.BackgroundImage = Properties.Resources.file_cornice; panel_Background.BackgroundImageLayout = ImageLayout.Stretch; } TransparentControl panel_MouseEvents = new TransparentControl(); panel_MouseEvents.Size = panel_Background.Size; panel_MouseEvents.BackColor = Color.Transparent; panel_MouseEvents.MouseEnter += (sender, args) => { if (!IsSelected) { panel_Background.BackColor = MouseOverColor; } else { PaintBorder = true; panel_Background.Invalidate(); } }; panel_MouseEvents.MouseLeave += (sender, args) => { if (!IsSelected) { panel_Background.BackColor = Color.Transparent; } PaintBorder = false; panel_Background.Invalidate(); }; panel_MouseEvents.MouseClick += (sender, args) => { foreach (Action a in ClickActionsList) { a.Invoke(); } }; panel_Background.Controls.Add(panel_MouseEvents); // // Picturebox Thumbnail // pBox_Thumbnail = new PictureBox(); int p_width; int p_height; if (thumbnail.Width > thumbnail.Height) { p_width = (int)(((decimal)MainSize.Width / 100M) * 75); p_height = (int)(((decimal)MainSize.Height / 100M) * 40); } else if (thumbnail.Width < thumbnail.Height) { decimal newHeight = MainSize.Height - (MainSize.Height - thumbBottomY); //p_width = (int)(((decimal)MainSize.Width / 100M) * 40); //p_height = (int)(((decimal)MainSize.Height / 100M) * 60); p_width = (int)(((decimal)MainSize.Width / 100M) * 50); p_height = (int)((newHeight / 100M) * 85); } else { p_width = (int)(((decimal)MainSize.Width / 100M) * 60); p_height = (int)(((decimal)MainSize.Height / 100M) * 60); } pBox_Thumbnail.Size = new Size(p_width, p_height); pBox_Thumbnail.SizeMode = PictureBoxSizeMode.StretchImage; pBox_Thumbnail.Location = new Point((panel_Background.Width / 2) - p_width / 2, thumbBottomY - p_height); // Goal: The bottom of the image is always at the same Y coordinate. pBox_Thumbnail.Image = ImageEditing.DrawImageScaled(pBox_Thumbnail.Width, pBox_Thumbnail.Height, thumbnail); //pBox_Thumbnail.Image = ImageEditing.DrawImageScaled(pBox_Thumbnail.Width, pBox_Thumbnail.Height, thumbnail); // pBox_Thumbnail.Image = thumbnail; panel_Background.Controls.Add(pBox_Thumbnail); // // File name label // Label label_FileName = new Label(); label_FileName.Font = new Font("Arial", 11, FontStyle.Regular, GraphicsUnit.Pixel); label_FileName.ForeColor = GUITools.COLOR_DarkMode_Text_Bright; label_FileName.MaximumSize = new Size((int)(((decimal)MainSize.Width / 100M) * 80), MainSize.Height - thumbBottomY - 5); label_FileName.AutoSize = false; label_FileName.Text = GUITools.FitTextLenghtToLabelSize(fileName, label_FileName); label_FileName.BackColor = Color.Transparent; label_FileName.Location = new Point(MainSize.Width / 2 - label_FileName.Width / 2, thumbBottomY + 5); panel_Background.Controls.Add(label_FileName); progress_Download = new CustomProgressBar() { Size = new Size(width, 8), Location = new Point(0, 0), }; progress_Download.BackgroundBarColor = GUITools.COLOR_DarkMode_Light; progress_Download.ProgressBarColor = Color.Green; progress_Download.Percentage = 0; progress_Download.Visible = false; panel_Background.Controls.Add(progress_Download); panel_Check = new Panel(); panel_Check.Size = new Size(10, 10); panel_Check.Location = new Point(panel_Background.Width / 2 - panel_Check.Width / 2, 0); panel_Check.Visible = false; panel_Check.BackgroundImageLayout = ImageLayout.Stretch; panel_Background.Controls.Add(panel_Check); // Always as last thing panel_MouseEvents.BringToFront(); }
// pname: progress name public CustomProgressBar addProgressbar(string pname) { // Initialize variables CustomProgressBar pgb = new CustomProgressBar(); pgb.gpn.SuspendLayout(); int index = pbars.Count(); // // progress bar // pgb.Location = new System.Drawing.Point(0, 20); pgb.Name = "progressbar_" + index; pgb.Size = new System.Drawing.Size(300, 20); pgb.TabIndex = 1; // // button cancel // pgb.btn.Location = new System.Drawing.Point(310, 20); pgb.btn.Name = "btn_" + index; pgb.btn.Size = new System.Drawing.Size(60, 20); pgb.btn.TabIndex = 4; pgb.btn.Text = "Cancel"; pgb.btn.id = Download.id; pgb.btn.ctrl = ctrl; pgb.btn.Click += new EventHandler(pgb.btn.cancelDownload); // // label // pgb.lbn.AutoSize = true; pgb.lbn.Location = new System.Drawing.Point(0, 0); pgb.lbn.Name = "label_" + index; pgb.lbn.Size = new System.Drawing.Size(300, 15); pgb.lbn.TabIndex = 2; pgb.lbn.Text = pname; // // panel // pgb.gpn.Controls.Add(pgb); pgb.gpn.Controls.Add(pgb.lbn); pgb.gpn.Controls.Add(pgb.btn); int gph = pgb.ClientSize.Height + pgb.lbn.ClientSize.Height + 10; int gpw = pgb.ClientSize.Width + pgb.btn.ClientSize.Width + 20; pgb.gpn.Location = new System.Drawing.Point(10, gph * index + 10); pgb.gpn.Name = "panel_" + index; pgb.gpn.Size = new System.Drawing.Size(gpw, gph); pgb.gpn.TabIndex = 3; // // form // int w = pgb.gpn.ClientSize.Width + 10; int h = pgb.gpn.ClientSize.Height * (index + 1); FormDownloadCG.blkh = pgb.gpn.ClientSize.Height; gui.ClientSize = new System.Drawing.Size(w, h + 20); gui.ResumeLayout(false); gui.PerformLayout(); gui.Controls.Add(pgb.gpn); // add to existing controller pbars.Add(pgb); return(pgb); }
//Example 1 public static void SimpleZip(string dirToZip, string zipName, MainWnd mainWnd, CustomProgressBar pb_ZIP) { CancellationTokenSource ts_ZIP = new CancellationTokenSource(); CancellationToken ct_ZIP = ts_ZIP.Token; try { Task pbZip_Task = new Task(() => { pb_ZIP.SetProgressBarValueByTicks(mainWnd, 100, "Zipping...", ct_ZIP); }, ct_ZIP); pbZip_Task.Start(); ZipFile.CreateFromDirectory(dirToZip, zipName); ts_ZIP.Cancel(); mainWnd.SetProgressBarValue(100, "Zipping finished", pb_ZIP); } catch (IOException exc) { ts_ZIP.Cancel(); MessageBox.Show(exc.Message); DialogResult dialogResult = MessageBox.Show("Do you whant to delete existing file(zip) ?", "File exists !!", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { mainWnd.SetProgressBarValue(0, "", pb_ZIP); File.Delete(zipName); SimpleZip(dirToZip, zipName, mainWnd, pb_ZIP); } else { MessageBox.Show("Old version of file(zip) will be uploaded !!"); mainWnd.SetProgressBarValue(100, "Zipping finished", pb_ZIP); } } catch (Exception exc) { MessageBox.Show(exc.Message); throw; } }
// Used to download multiple files in list. Useful for threading (IE thread1 should download items 1-3, thread2 should download items 4-6, etc.) private static void downloadPattern(List <Uri> filesFromServer, int startIndex, int endIndex, CustomProgressBar bar, GridMaker displayController, MainDisplay me) { if (STOP) { return; } for (int i = startIndex; i < endIndex; i = i + 1) { if (i < filesFromServer.Count) { String file = filesFromServer.ElementAt(i).ToString(); String fileExtension = file.Substring(file.LastIndexOf("/") + 1); try { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(filesFromServer.ElementAt(i)); req.Timeout = 120000; req.ReadWriteTimeout = 120000; var w = (HttpWebResponse)req.GetResponse(); using (Stream filer = File.OpenWrite(Properties.Settings.Default.runpath + "\\" + fileExtension)) { w.GetResponseStream().CopyTo(filer); } } catch (System.Net.WebException e) { MessageBox.Show("Please check your internet connection. Heres what we know:\n" + e.Message, "An error was incurred", MessageBoxButtons.OK, MessageBoxIcon.Error); } Debug.WriteLine("file"); if (STOP) { FileInfo tfile = new FileInfo(Properties.Settings.Default.runpath + "\\" + fileExtension); Debug.WriteLine(tfile.Exists); tfile.Delete(); return; } if (bar.InvokeRequired) { bar.BeginInvoke((MethodInvoker) delegate() { bar.Step = 1; }); bar.BeginInvoke((MethodInvoker) delegate() { bar.PerformStep(); }); } else { bar.BeginInvoke((MethodInvoker) delegate() { bar.Step = 1; }); bar.BeginInvoke((MethodInvoker) delegate() { bar.PerformStep(); }); } if (bar.Value + 1 >= bar.Maximum) { finishFile(bar, displayController, me, false); } } } }