private void OpenAnimationTimer_Tick(object sender, object e) { _animationTimer.Stop(); Opened?.Invoke(this, EventArgs.Empty); _animationTimer.Tick -= OpenAnimationTimer_Tick; }
public Task ReceiveAsync(string url, List<KeyValuePair<string, string>> cookies, string userAgent, string origin) { if (_ws != null) throw new InvalidOperationException("_ws is not null"); var tcs = new TaskCompletionSource<object>(); var subProtocol = ""; _ws = new WebSocket4Net.WebSocket(url, subProtocol, cookies, null, userAgent, origin, WebSocket4Net.WebSocketVersion.Rfc6455) { EnableAutoSendPing = false, AutoSendPingInterval = 0, ReceiveBufferSize = 8192, NoDelay = true }; _ws.MessageReceived += (s, e) => { Log("_ws.MessageReceived: " + e.Message); Received?.Invoke(this, e.Message); }; _ws.DataReceived += (s, e) => { //ここに来たことは今のところ一度もない。 Debug.WriteLine("Dataが送られてきた"); }; _ws.Opened += (s, e) => { Log("_ws.Opend"); Opened?.Invoke(this, EventArgs.Empty); }; _ws.Closed += (s, e) => { Log("_ws.Closed"); try { tcs.TrySetResult(null); } finally { if (_ws != null) { _ws.Dispose(); _ws = null; } } }; _ws.Error += (s, e) => { Log("_ws.Error"); try { tcs.SetException(e.Exception); } finally { if (_ws != null) { _ws.Dispose(); _ws = null; } } }; _ws.Open(); return tcs.Task; }
/// <summary> /// Команда "Открыть" /// </summary> public void Open() { try { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Файл карты (*.smf)|*.smf"; if (dialog.ShowDialog() == DialogResult.OK) { List <NetPoint> nplist = new List <NetPoint>(); FileStream fs = new FileStream(dialog.FileName, FileMode.Open, FileAccess.Read, FileShare.Read); XmlDocument xml = new XmlDocument(); xml.Load(fs); XmlNode doc = xml.DocumentElement; Dictionary <string, string> links = new Dictionary <string, string>(); foreach (XmlNode node in doc) { if (node.Name == "task") { NetPoint point = new NetPoint(); foreach (XmlNode param in node) { if (param.Name == "id") { point.InstallID(param.InnerText); } if (param.Name == "name") { point.Name = param.InnerText; } if (param.Name == "description") { point.Description = param.InnerText; } if (param.Name == "type") { switch (param.InnerText) { case "start": point.PointType = TaskType.start; break; case "end": point.PointType = TaskType.end; break; default: point.PointType = TaskType.center; break; } } if (param.Name == "time") { point.Time = Convert.ToInt32(param.InnerText); } if (param.Name == "location") { Point import = new Point(0, 0); foreach (XmlNode loc in param) { if (loc.Name == "X") { import.X = Convert.ToInt32(loc.InnerText); } if (loc.Name == "Y") { import.Y = Convert.ToInt32(loc.InnerText); } } point.Location = import; } if (param.Name == "connections") { string cons = ""; foreach (XmlNode tsk in param) { if (tsk.Name == "taskID") { cons += tsk.InnerText + '|'; } } if (cons.Length > 0) { cons = cons.Substring(0, cons.Length - 1); } links.Add(point.ID, cons); } } nplist.Add(point); } } List <NetPoint> connections = new List <NetPoint>(); foreach (NetPoint point in nplist) { NetPoint np = point; foreach (string key in links.Keys) { if (key == np.ID) { List <string> cons = new List <string>(); cons = links[key].Split('|').ToList(); foreach (NetPoint pont in nplist) { if (cons.Contains(pont.ID)) { np.Connections.Add(pont); } } } } connections.Add(np); } fs.Close(); Opened?.Invoke(dialog.FileName, connections); } else { return; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void handleOpened (Object sender, EventArgs eventArgs) => Opened?.Invoke();
public override void OnOpened(CameraDevice camera) { Opened?.Invoke(this, camera); Camera = camera; Debug.WriteLine("Camera opened"); }
public VideoPlayer(MediaElement mediaElement) : base(Kinds.Video) { MediaElement = mediaElement; MediaElement.Loaded += (s, args) => IsLoaded = true; MediaElement.MediaOpened += (s, args) => Opened?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Invokes the opened event /// </summary> protected void OnOpened(EventArgs args) { Opened?.Invoke(this, args); }
/// <summary> /// Raises the <see cref="Opened"/> event. /// </summary> protected virtual void OnOpened() => Opened?.Invoke(this);
private void On(Opened @event) { Title = @event.Title; Description = @event.Description; ServiceCasePriority = @event.Priority; }
protected virtual void OnOpened() { Opened?.Invoke(this, EventArgs.Empty); }
private void Websocket_Opened(object sender, EventArgs e) { Opened?.Invoke(this, e); }
/// <summary> /// Handles the Opened event of the Solution control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="SolutionEventArgs" /> instance containing the event data.</param> private void Solution_Opened(object sender, SolutionEventArgs e) { Opened?.Invoke(this, e); }
private void AlertPointerExit() { Opened.Begin(); }
public virtual void Open() { gameObject.SetActive(true); isOpen = true; Opened.Invoke(); }
/// <inheritdoc /> private void DoSetIsOpened() { Opened?.Invoke(this, EventArgs.Empty); }
private void Websocket_OnOpen(object sender, EventArgs e) { Opened?.Invoke(this, EventArgs.Empty); }
private void OnOpened() { Opened?.Invoke(this, EventArgs.Empty); }
private void _ws_Opened(object sender, EventArgs e) { Opened?.Invoke(this, e); }
public void Open() { Opened?.Invoke(this, System.EventArgs.Empty); }
/// <summary>打开</summary> /// <returns>是否成功</returns> public virtual Boolean Open() { if (Disposed) { throw new ObjectDisposedException(GetType().Name); } if (Active) { return(true); } lock (this) { if (Active) { return(true); } LogPrefix = "{0}.".F((Name + "").TrimEnd("Server", "Session", "Client")); BufferSize = Setting.Current.BufferSize; // 估算完成时间,执行过长时提示 using (var tc = new TimeCost(GetType().Name + ".Open", 1500)) { tc.Log = Log; _RecvCount = 0; var rs = OnOpen(); if (!rs) { return(false); } if (Timeout > 0) { Client.ReceiveTimeout = Timeout; } if (!Local.IsUdp) { // 管道 var pp = Pipeline; pp?.Open(CreateContext(this)); } } Active = true; // 统计 if (StatSend == null) { StatSend = new PerfCounter(); } if (StatReceive == null) { StatReceive = new PerfCounter(); } ReceiveAsync(); // 触发打开完成的事件 Opened?.Invoke(this, EventArgs.Empty); } return(true); }
private void OnChannelOpened(object sender, EventArgs e) { Opened?.Invoke(this, e); }
public virtual void Open() { Show(); Opened.Invoke(); }
/// <inheritdoc /> public void Open() { Opened?.Invoke(this); Close(); }
protected override void OnDocumentOpened(EditorDocument document) { Opened.Add(document); }
private static void ConnectionOnOpened(object sender, EventArgs e) { Opened?.Invoke(sender, e); }
private void Client_Opened(Object sender, EventArgs e) { Opened?.Invoke(this, e); }
private void OnOpened(StateChangedEventArgs e) => Opened?.Invoke(this, e);
/// <summary> /// Raises the Opened event. /// </summary> /// <param name="e">An EventArgs containing the event data.</param> protected virtual void OnOpened(EventArgs e) { Opened?.Invoke(this, e); }
void onOpened(object s, StateChangedEventArgs e) => Opened?.Invoke(s, e);