public delegate void UpdateTaskList( );//声明一个更新主线程的委托 public void UpdateCleanCardListview() { if (ListCleanedCard.InvokeRequired) { UpdateTaskList updatedelegate = new UpdateTaskList(UpdateCleanCardListview); ParentForm.Invoke(updatedelegate, new object[] { }); } else { ListCleanedCard.Items.Clear(); List <CleanListView> ul = new List <CleanListView>(); DataInfo.GetCleanListInfo(ref ul); foreach (var i in ul) { ListViewItem col = ListCleanedCard.Items.Add(i.Sequence.ToString()); col.SubItems.Add(i.time.ToString()); string cardname = ""; string workName = i.WorkCard; if (cm.Cardlist.ContainsKey(i.CleanCard)) { cardname = cm.Cardlist[i.CleanCard]; } if (cm.Cardlist.ContainsKey(i.WorkCard)) { workName = cm.Cardlist[i.WorkCard]; } col.SubItems.Add(i.CleanCard); col.SubItems.Add(cardname); col.SubItems.Add(workName); col.SubItems.Add(i.cleanprc); } } }
/// <summary> /// 更新数据总数和页总数 /// </summary> /// <param name="dataCount"></param> public void SetDataCount(int dataCount) { if (!DesignMode) { DataCount = dataCount; PageTotal = DataCount % PageSize == 0 ? DataCount / PageSize : (DataCount / PageSize) + 1; if (PageIndex > PageTotal) { PageIndex = 1; } if (PageTotal == 0) { PageTotal = 1; } if (!ParentForm.IsDisposed) { ParentForm.Invoke(new Action(() => { //调整控件展示界面(第几页,共几页) LBPageDesc.Text = string.Format("第 {0} 页,共 {1} 页", PageIndex, PageTotal); })); } } }
private void SetCheckbox(bool Val) { if (chkReconnectWhenReady.InvokeRequired) { SetCheckboxCB d = new SetCheckboxCB(SetCheckbox); ParentForm.Invoke(d, new object[] { Val }); } else { chkReconnectWhenReady.Checked = Val; } }
private void SetStatusImage(Image Img) { if (pbServerStatus.InvokeRequired) { SetStatusImageCB d = new SetStatusImageCB(SetStatusImage); ParentForm.Invoke(d, new object[] { Img }); } else { pbServerStatus.Image = Img; } }
public void DisposeReconnectGroup() { if (this.InvokeRequired) { DisposeReconnectGroupCB d = new DisposeReconnectGroupCB(DisposeReconnectGroup); ParentForm.Invoke(d); } else { this.Dispose(); } }
public void DisposeReconnectGroup() { if (InvokeRequired) { var d = new DisposeReconnectGroupCB(DisposeReconnectGroup); ParentForm?.Invoke(d); } else { Dispose(); } }
private void VcdPerPixelAlphaForm_MouseDown(object sender, MouseEventArgs e) { switch (e.Button) { case MouseButtons.Left: Win32.ReleaseCapture(); Win32.SendMessage(Handle, Win32.WM_NCLBUTTONDOWN, Win32.HT_CAPTION, 0); break; case MouseButtons.Right: //Console.WriteLine("Right Click detected, bye!"); parentForm.Invoke(parentForm.quitProgramDelegate); break; } }
void Redraw() { if (ParentForm != null) { bool exit = false; ParentForm.Invoke((Action)(() => { if (Program.MainForm.ActiveMdiChild != ParentForm) { exit = true; } })); if (exit) { return; } } textBrush = Brushes.Black; lock (DrawingContext.lock1) { ctx.Update(); ctx.Graphics.Clear(Color.White); ctx.Graphics.SmoothingMode = SmoothingMode.AntiAlias; ctx.Graphics.ResetTransform(); ///axis //ctx.Graphics.DrawLine(Pens.Red, ctx.Transform(new PointF(0, 0)), ctx.Transform(new PointF(1000, 0))); //ctx.Graphics.DrawLine(Pens.Blue, ctx.Transform(new PointF(0, 0)), ctx.Transform(new PointF(0, 1000))); if (Model != null && drawEnabled) { drawEdges(ctx); drawNodes(ctx); drawLabels(ctx); } } ctx.Box.Invoke((Action)(() => { ctx.Swap(); //ctx.Box.Refresh(); })); }
private void PreviewEvent(ParsedEvent parsedEvent) { var data = _connectionInfo.GetEventBytes(parsedEvent); packetPreview.Invoke((MethodInvoker) delegate { packetPreview.ByteProvider = new DynamicByteProvider(data); }); if (parsedEvent.ParseMode == ParseMode.Root && _templateParser != null) { parsedEvent.Data = new TemplateReader(_templateParser).ParseBuffer(data, ParseMode.Complete); parsedEvent.ParseMode = ParseMode.Complete; } ParentForm.Invoke((MethodInvoker) delegate { ParentForm.PreviewFlowData(parsedEvent.Data); }); }
private void btnCancel_Click(object sender, EventArgs e) { BackgroundWorker currentBGW = (ProcessActiveState == ProcessState.Export) ? bgw : (ProcessActiveState == ProcessState.Import) ? bgw1 : bgw2; Thread currentThread; try { currentThread = (ProcessActiveState == ProcessState.Export) ? (ParentForm as Form1).CancelableThread : (ProcessActiveState == ProcessState.Import) ? (ParentForm as Form1).CancelableThread1 : (ParentForm as Form1).CancelableThread2; } catch { currentThread = (ParentForm as FormSIMW).CancelableThread; } Action d = new Action(() => currentBGW.CancelAsync()); ParentForm.Invoke(d); d = new Action(() => currentThread.Abort()); ParentForm.Invoke(d); Visible = false; MessageBox.Show("Thread was canceled!", "Thread Status", MessageBoxButtons.OK, MessageBoxIcon.Information); }
/// <summary> /// Handler method that's called when the connection is lost. Sets <see cref="IsConnected"/> to false and calls the <see cref="LoggedOff"/> /// event. /// </summary> /// <param name="sender">Object from which this event originated.</param> /// <param name="e">Arguments associated with this event.</param> protected virtual void OnLoggedOff(object sender, EventArgs e) { if (IsClosing || Parent == null) { return; } Invoke( new Action( () => { IsConnected = false; ConnectionWindow.Visible = false; connectingLabel.Visible = false; })); if (LoggedOff != null) { LoggedOff(sender, e); } IsClosing = true; ParentForm.Invoke(new Action(() => ParentForm.Close())); }
private void OnStateChanged(bool newState) { PendingRefresh = true; /* NP Jan-20-2012: * Check if the form is running in another thread, if so then marshall to other thread */ if (ParentForm.InvokeRequired) { ParentForm.Invoke(new stateChangedDelegate(OnStateChanged), newState); } else { if (newState) { ovsState.FillColor = Color.Green; btnPlay.Enabled = false; } else { ovsState.FillColor = Color.Red; btnPlay.Enabled = true; } } }
public bool LoadModel(string path, bool _fitAll = true) { if (ParentForm != null) { ParentForm.FormClosing += ParentForm_FormClosing; } _lastPath = path; var fr = Providers.FirstOrDefault(z => z.IsSuitableFile(path)); if (fr == null) { MessageBox.Show("Unsupported file format.", WindowCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } Stopwatch sw = new Stopwatch(); WaitDialog wd = new WaitDialog(); timer1.Enabled = false; Action loadAct = () => { sw.Start(); var model = fr.LoadFromFile(path); Model = model; if (!loadedModels.Any(z => z.ToLower() == path.ToLower())) { loadedModels.Add(path); } listView1.Items.Clear(); foreach (var item in model.Nodes) { //listView1.Items.Add(new ListViewItem(new string[] { item.Name, ss, item.Output[0] }) { Tag = nodes[i] }); } //var cnt2 = res2.Graph.Output[0].Name; //nodes.InsertRange(0, res2.Graph.Input.Select(z => outs[z.Name])); updateNodesSizes(); CurrentLayout.GetRenderTextWidth = renderTextWidth; CurrentLayout.Layout(Model); //Text = $"{WindowCaption}: {Path.GetFileName(path)}"; if (ParentForm != null) { ParentForm.Invoke((Action)(() => { ParentForm.Text = Path.GetFileName(path); })); } drawEnabled = true; reset.Set(); if (_fitAll) { fitAll(); } sw.Stop(); }; drawEnabled = false; wd.Init(loadAct); wd.ShowDialog(); timer1.Enabled = true; if (wd.Exception != null) { Helpers.ShowError(wd.Exception.Message, Program.MainForm.Text); } Program.MainForm.SetStatusMessage($"Load time: {sw.ElapsedMilliseconds} ms"); return(true); }
public void Log(string l, params object[] args) { ParentForm.Invoke(new MethodInvoker(delegate() { ParentForm.tb_console.AppendText(string.Format(l, args) + Environment.NewLine); })); }
public void RunLoop() { RunLoopCreated = true; mRunThread = new System.Threading.Thread(() => { ParentForm.Visible = true; ParentForm.Visible = false; var ctrl = mRenderWindow; mDriver = new Direct3D(); mDevice = new Device(mDriver, 0, DeviceType.Hardware, ctrl.Handle, CreateFlags.HardwareVertexProcessing | CreateFlags.Multithreaded, new PresentParameters() { Windowed = true, BackBufferFormat = Format.A8R8G8B8, BackBufferHeight = ctrl.ClientSize.Height, BackBufferWidth = ctrl.ClientSize.Width, EnableAutoDepthStencil = true, AutoDepthStencilFormat = Format.D24S8, SwapEffect = SwapEffect.Discard, DeviceWindowHandle = ctrl.Handle, } ); mDevice.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH((45.0f * (float)Math.PI) / 180.0f, ctrl.ClientSize.Width / (float)ctrl.ClientSize.Height, 0.1f, 100000.0f)); mDevice.SetRenderState(RenderState.Lighting, false); mDevice.SetRenderState(RenderState.ZEnable, true); mDevice.SetRenderState(RenderState.CullMode, Cull.None); mDevice.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear); mDevice.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear); mDevice.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Linear); InputManager = new Video.Input.InputManager(); InputManager.InputWindow = ctrl; Camera = new ModelCamera(ctrl, this); TextureManager = new Video.TextureManager(mDevice); Application.Idle += (sender, args) => { if (ParentForm.Visible == false) { return; } MSG msg = new MSG(); while (!PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0)) { RenderFrame(); } }; if (LoadDone != null) { LoadDone(); } LoadEvent.Set(); ParentForm.Visible = true; Application.Run(ParentForm); } ); mRunThread.Start(); Game.GameManager.GameTerminated += () => { if (ParentForm.IsDisposed == false) { ParentForm.Invoke(new Action(ParentForm.Dispose)); } }; }