public static void SetStatusBarLabel(this StatusStrip statusBar, ToolStripStatusLabel label, string text, Bitmap image = null) { try { if (statusBar.InvokeRequired) { statusBar.Invoke(new Action(() => label.Text = text)); if (image != null) { statusBar.Invoke(new Action(() => label.Image = image)); } } else { label.Text = text; if (image != null) { label.Image = image; } } } catch (ObjectDisposedException ex) { } }
public void setError(string txt, Exception e) { statusBar.Invoke(new MethodInvoker(delegate { targetLabel.BackColor = Color.LightPink; Exception inner = e.InnerException; targetLabel.Text = txt + ": " + (inner != null ? inner.Message : e.Message); })); }
/// <summary> /// Replaces current progress bar value and info label on 'percent', please round this input before calling))) /// </summary> /// <param name="percent"></param> public void UpdateProgressBar(double percent) { if (percent == 100) { _statusStrip.Invoke((MethodInvoker) delegate() { _statusStrip.Items[0].Text = "Completed successfully"; }); Close(); } if (percent >= 0 && percent <= 100) { progressBar1.Value = (int)percent; label2.Text = $"{percent}%"; } }
private void InvokeSetProgressType(StatusStrip sstrip, ToolStripProgressBar pbar, ProgressBarStyle pstyle) { if (sstrip.InvokeRequired) { sstrip.Invoke((MethodInvoker) delegate { pbar.Style = pstyle; }); } else { pbar.Style = pstyle; } }
private void InvokeSetStatusStripLblText(StatusStrip strip, ToolStripStatusLabel lbl, string text) { if (strip.InvokeRequired) { strip.Invoke((MethodInvoker) delegate { lbl.Text = text; }); } else { lbl.Text = text; } }
public static void invokeStatusInfo(StatusStrip stat, string text) { if (stat.InvokeRequired) { stat.Invoke(new Action <string>(s => stat.Items[1].Text = s), text); } else { stat.Items[1].Text = text; } }
private void InvokeSetVisibleState(StatusStrip strip, ToolStripStatusLabel lbl, bool isVisible) { if (strip.InvokeRequired) { strip.Invoke((MethodInvoker) delegate { lbl.Visible = isVisible; }); } else { lbl.Visible = isVisible; } }
private void setStatus(string text) { if (statusBar.InvokeRequired) { statusBar.Invoke(new Action <string>(setStatus), text); return; } statusText.Text = text; statusBar.Refresh(); }
private void InvokeSetProgress(StatusStrip sstrip, ToolStripProgressBar pbar, int value) { if (sstrip.InvokeRequired) { sstrip.Invoke((MethodInvoker) delegate { pbar.Value = value; }); } else { pbar.Value = value; } }
/// <summary> /// statusstrip¿¡ ¶óº§ º¯°æ ÇÑ´Ù /// </summary> /// <param name="st"></param> /// <param name="tl"></param> /// <param name="str"></param> /// <param name="img"></param> public static void Invoke_StatusStrip_LabelText(StatusStrip st, ToolStripLabel tl, string str, Image img) { if (st.InvokeRequired) { st.Invoke(new delInvoke_StatusStrip_LabelText(Invoke_StatusStrip_LabelText), new object[] { st, tl, str, img }); return; } tl.Text = str; tl.Image = img; }
internal static void HideProgressStatus() { if (!_disabled) { if (CurrentProcessProgressbar != null) { if (_statusbar.InvokeRequired) { _statusbar.Invoke(new MethodInvoker(delegate { CurrentProcessProgressbar.Visible = false; CurrentProcessProgressLabel.Visible = false; })); } else { CurrentProcessProgressbar.Visible = false; CurrentProcessProgressLabel.Visible = false; } } } }
public void SetStatusStripPropertyThreadSafe(StatusStrip statusStrip, ToolStripItem controlName, string propertyName, object propertyValue) { try { if (statusStrip.InvokeRequired) { statusStrip.Invoke(new SetStatusStripPropertyThreadSafeDelegate(SetStatusStripPropertyThreadSafe), new object[] { statusStrip, controlName, propertyName, propertyValue }); } else { controlName.GetType().InvokeMember(propertyName, BindingFlags.SetProperty, null, controlName, new object[] { propertyValue }); } } catch (Exception e) { } }
private void SetupForm_Load(object sender, EventArgs e) { new Thread(() => { Thread.CurrentThread.IsBackground = true; var devices = CaptureDeviceList.Instance; Devices = devices; cmbAdapter.Invoke(() => { cmbAdapter.Enabled = true; foreach (var dev in devices) { /* Description */ //Console.WriteLine("{0}) {1} {2}", i, dev.Name, dev.Description); cmbAdapter.Items.Add($"{((LibPcapLiveDevice)dev).Interface.FriendlyName}"); } if (devices.Count > 0) { cmbAdapter.SelectedIndex = 0; } }); StatusStrip.Invoke(() => { StatusLabel.Text = "Ready"; }); BtnSelect.Invoke(() => { BtnSelect.Enabled = true; }); }).Start(); }
async private void OnBtnPlayClick(object sender, EventArgs e) { if (playback.Renderer != null && playback.Renderer.IsPaused) { playback.Renderer.Resume(); return; } if (MusicList.FocusedItem == null) { if (MusicList.Items.Count > 0) { MusicList.FocusedItem = MusicList.Items[0]; } else { return; } } if (playback.Renderer != null && playback.Renderer.IsRendering && MusicList.FocusedItem.Index == playback.Track) { return; } Chart chart = null; try { BtnEditMeta.Enabled = GroupUtilities.Enabled = RenderToFileMenu.Enabled = RenderSelectedMenu.Enabled = true; if (playback.Renderer == null) { var renderer = new ChartRenderer(); renderer.Rendering += ((send, args) => { string offset = string.Format("{0} / {1}", renderer.Elapsed.ToString(@"mm\:ss"), renderer.Duration.ToString(@"mm\:ss")); string status = string.Format("{0} - {1}", offset, renderer.Chart.Title); lblPlayingOffset.SetTextAsync(offset); StatusStrip.Invoke(new Action(() => StatusLabel.Text = renderer.IsPaused ? "Paused - " + renderer.Chart.Title : status)); }); renderer.RenderComplete += OnRenderComplete; playback.Renderer = renderer; } else { playback.Renderer.Stop(); await renderTask; } OpenMenu.Enabled = GroupPlayback.Enabled = PlaybackMenu.Enabled = false; playback.Track = MusicList.FocusedItem.Index; var header = charts[playback.Track]; SetLayoutInfo(header, true); SetHighlightState(true); BtnSaveThumbnail.Enabled = header.ThumbnailData != null && header.ThumbnailData.Length > 0; BtnSaveCover.Enabled = header.CoverArtData != null && header.CoverArtData.Length > 0; chart = await ChartDecoder.DecodeAsync(header.Filename, DifficultyBox.SelectedIndex); if (chart == null) { throw new Exception("Invalid / unsupported chart file."); } //foreach (var ev in chart.Events) //{ // var sample = ev as Event.Sound; // if (sample != null) // sample.Payload = null; //} renderTask = playback.Renderer.RenderAsync(chart); } catch (Exception ex) { StatusLabel.Text = "Ready"; MessageBox.Show(ex.Message, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { OpenMenu.Enabled = GroupPlayback.Enabled = PlaybackMenu.Enabled = true; await renderTask; } }
private void DOStatusStrip(String s) { StatusStrip?.Invoke(this, s); }
private void MainForm_Load(object sender, EventArgs e) { InitProxies(); InitModes(); // 更新时间和状态 Task.Run(() => { while (true) { try { Invoke(new MethodInvoker(() => { Text = "v2tap - " + DateTime.Now.ToString(); })); StatusLabel.Invoke(new MethodInvoker(() => { StatusLabel.Text = "当前状态:" + Status; })); Thread.Sleep(100); } catch (Exception) { } } }); // 更新流量信息 Task.Run(() => { while (true) { try { if (isStarted) { var channel = new Grpc.Core.Channel("127.0.0.1:1020", Grpc.Core.ChannelCredentials.Insecure); var client = new v2ray.Core.App.Stats.Command.StatsService.StatsServiceClient(channel); var uplink = client.GetStats(new v2ray.Core.App.Stats.Command.GetStatsRequest { Name = "inbound>>>defaultInbound>>>traffic>>>uplink", Reset = true }); var downlink = client.GetStats(new v2ray.Core.App.Stats.Command.GetStatsRequest { Name = "inbound>>>defaultInbound>>>traffic>>>downlink", Reset = true }); UsedBandwidth += uplink.Stat.Value; UsedBandwidth += downlink.Stat.Value; StatusStrip.Invoke(new MethodInvoker(() => { BandwidthLabel.Text = "总流量:" + Utils.Util.ProcessBandwidth(UsedBandwidth); UplinkLabel.Text = "↑:" + Utils.Util.ProcessBandwidth(uplink.Stat.Value) + "/s"; DownlinkLabel.Text = "↓:" + Utils.Util.ProcessBandwidth(downlink.Stat.Value) + "/s"; })); } else { StatusStrip.Invoke(new MethodInvoker(() => { BandwidthLabel.Text = "总流量:0 KB"; UplinkLabel.Text = "↑:0 KB/s"; DownlinkLabel.Text = "↓:0 KB/s"; })); } Thread.Sleep(1000); } catch (Exception) { } } }); }
private async Task ExecuteFontCreation( string ttxPath, int startUniIndex, int maxGlyphWidth, int combinationCount, string[] textFiles, bool onlySmallLetters, double frequencyRatio, double totalWidthRatio) { await Task.Run(() => { var ttxManager = new TTXManager( ttxPath, startUniIndex, maxGlyphWidth ); var allCombinationProcessed = false; var excludedCombinations = new List <string>(); var symbolWidthsByUniIndexes = ttxManager.GetSymbolsWidth(_symbolsDictionary); var symbolWidthsBySymbols = new Dictionary <string, int>(); foreach (var uniWidthPair in symbolWidthsByUniIndexes) { var pairKey = _symbolsDictionary.First(x => x.Value == uniWidthPair.Key).Key; if (pairKey == "<пробел>") { pairKey = " "; } symbolWidthsBySymbols.Add(pairKey, uniWidthPair.Value); } var analyzer = new TextAnalyzer(textFiles, Encoding.UTF8, onlySmallLetters, frequencyRatio, totalWidthRatio); for (int customSymbolIndex = 0; customSymbolIndex < combinationCount; customSymbolIndex++) { var historyCombinations = new List <string>(); foreach (var dictPair in ttxManager.GlyphHistoryDictionary) { var historyCombination = string.Empty; for (int dictPairValueIndex = 0; dictPairValueIndex < dictPair.Value.Length; dictPairValueIndex++) { if (dictPair.Value[dictPairValueIndex] == "space") { historyCombination += " "; } else { historyCombination += _symbolsDictionary.First(x => x.Value == dictPair.Value[dictPairValueIndex]).Key; } } if (!string.IsNullOrEmpty(historyCombination)) { historyCombinations.Add(historyCombination); } } historyCombinations.AddRange(excludedCombinations); analyzer.Analyze(historyCombinations.ToArray(), symbolWidthsBySymbols, maxGlyphWidth); if (analyzer.CombinationInfos.Count == 0) { break; } var combinationProcessed = false; var combinationHistogramIndex = 0; do { var replacedCombination = analyzer.CombinationInfos.ElementAt(combinationHistogramIndex).Value; var combinedSymbols = new List <string>(); foreach (var sChar in replacedCombination) { if (sChar.ToString() != " ") { combinedSymbols.Add(_symbolsDictionary[sChar.ToString()]); } else { combinedSymbols.Add("space"); } } bool glyphCreated; string glyphUniIndex; (glyphCreated, glyphUniIndex) = ttxManager.AddСombinedGlyph(combinedSymbols.ToArray()); if (glyphCreated) { analyzer.ReplaceWithSymbol(replacedCombination, (char)(int.Parse(glyphUniIndex.Substring(3), System.Globalization.NumberStyles.HexNumber))); combinationProcessed = true; } else { if (combinationHistogramIndex == analyzer.CombinationInfos.Count - 1) { allCombinationProcessed = true; break; } combinationHistogramIndex++; excludedCombinations.Add(replacedCombination); } } while (!combinationProcessed); if (allCombinationProcessed) { break; } StatusStrip.Invoke((MethodInvoker) delegate { StatusProgressBar.Value = customSymbolIndex + 1; }); } ttxManager.SaveChanges(); var ttfFilePath = Path.Combine(Path.GetDirectoryName(ttxPath), Path.GetFileNameWithoutExtension(ttxPath) + ".ttf"); if (File.Exists(ttfFilePath)) { File.Delete(ttfFilePath); } TTXUtils.ExecuteTTXConversion(ttxPath); analyzer.SaveChanges(); StatusStrip.Invoke((MethodInvoker) delegate { StatusProgressBar.Value = StatusProgressBar.Maximum; }); }); }