Ejemplo n.º 1
0
 private void OpenAnimationTimer_Tick(object sender, object e)
 {
     _animationTimer.Stop();
     Opened?.Invoke(this, EventArgs.Empty);
     _animationTimer.Tick -= OpenAnimationTimer_Tick;
 }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        /// <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;
            }
        }
Ejemplo n.º 4
0
 private void handleOpened
     (Object sender,
     EventArgs eventArgs) =>
 Opened?.Invoke();
Ejemplo n.º 5
0
 public override void OnOpened(CameraDevice camera)
 {
     Opened?.Invoke(this, camera);
     Camera = camera;
     Debug.WriteLine("Camera opened");
 }
Ejemplo n.º 6
0
 public VideoPlayer(MediaElement mediaElement) : base(Kinds.Video)
 {
     MediaElement              = mediaElement;
     MediaElement.Loaded      += (s, args) => IsLoaded = true;
     MediaElement.MediaOpened += (s, args) => Opened?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Invokes the opened event
 /// </summary>
 protected void OnOpened(EventArgs args)
 {
     Opened?.Invoke(this, args);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Raises the <see cref="Opened"/> event.
 /// </summary>
 protected virtual void OnOpened() =>
 Opened?.Invoke(this);
Ejemplo n.º 9
0
 private void On(Opened @event)
 {
     Title = @event.Title;
     Description = @event.Description;
     ServiceCasePriority = @event.Priority;
 }
Ejemplo n.º 10
0
 protected virtual void OnOpened()
 {
     Opened?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 11
0
 private void Websocket_Opened(object sender, EventArgs e)
 {
     Opened?.Invoke(this, e);
 }
Ejemplo n.º 12
0
 /// <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);
 }
Ejemplo n.º 13
0
 private void AlertPointerExit()
 {
     Opened.Begin();
 }
 public virtual void Open()
 {
     gameObject.SetActive(true);
     isOpen = true;
     Opened.Invoke();
 }
Ejemplo n.º 15
0
 /// <inheritdoc />
 private void DoSetIsOpened()
 {
     Opened?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 16
0
 private void Websocket_OnOpen(object sender, EventArgs e)
 {
     Opened?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 17
0
 private void OnOpened()
 {
     Opened?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 18
0
 private void _ws_Opened(object sender, EventArgs e)
 {
     Opened?.Invoke(this, e);
 }
Ejemplo n.º 19
0
 public void Open()
 {
     Opened?.Invoke(this, System.EventArgs.Empty);
 }
Ejemplo n.º 20
0
        /// <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);
 }
Ejemplo n.º 22
0
 public virtual void Open()
 {
     Show();
     Opened.Invoke();
 }
Ejemplo n.º 23
0
 /// <inheritdoc />
 public void Open()
 {
     Opened?.Invoke(this);
     Close();
 }
Ejemplo n.º 24
0
 protected override void OnDocumentOpened(EditorDocument document)
 {
     Opened.Add(document);
 }
Ejemplo n.º 25
0
 private static void ConnectionOnOpened(object sender, EventArgs e)
 {
     Opened?.Invoke(sender, e);
 }
Ejemplo n.º 26
0
 private void Client_Opened(Object sender, EventArgs e)
 {
     Opened?.Invoke(this, e);
 }
Ejemplo n.º 27
0
 private void OnOpened(StateChangedEventArgs e) =>
 Opened?.Invoke(this, e);
Ejemplo n.º 28
0
 /// <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);
 }
Ejemplo n.º 29
0
 void onOpened(object s, StateChangedEventArgs e) => Opened?.Invoke(s, e);