private void btnConnect_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; WcfClientHelper.FaultMessage = null; if (_loadingControl == null) { _loadingControl = new LoadingControl(); int loadingControlX = (this.Width / 2) - (_loadingControl.Width / 2); int loadingControlY = ((this.Height / 2) - (_loadingControl.Height / 2)) - 20; _loadingControl.Location = new Point(loadingControlX, loadingControlY); this.Controls.Add(_loadingControl); } _loadingControl.BringToFront(); _loadingControl.Visible = true; Task connectingTask = Task.Factory.StartNew <bool>(() => { ServiceRemotingCallback callback = new ServiceRemotingCallback(); WcfClientHelper.ConnectIpc(callback); ((ICommunicationObject)WcfClientHelper.PipeFactory).Closing += PipeFactory_Closing; ((ICommunicationObject)WcfClientHelper.PipeFactory).Faulted += PipeFactory_Faulted; return(WcfClientHelper.IsConnected); }).ContinueWith(x => { HandleConnectionResult(x.Result); }); }
public static void Mask(this Control control) { if (FindMaskPanel(control) == null) { var panel = new LoadingControl { Dock = DockStyle.Fill, IsAnimating = true, BackColor = SystemColors.AppWorkspace }; control.Controls.Add(panel); panel.BringToFront(); } }
public static bool BeginLoadDate(this Control c) { if (!lst.ContainsKey(c)) { LoadingControl lc = new LoadingControl(); lc.Location = Point.Empty; lc.Size = c.Size; c.Controls.Add(lc); lc.BringToFront(); //当大小改变的时候重置大小 c.SizeChanged += (object sender, EventArgs e) => { lc.Size = c.Size; }; lst.Add(c, lc); return(true); } else { return(false); } }