コード例 #1
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            data = new MyDataSource();
            memberView.DataSource = data;

            inputTextField.Delegate = new MyNSTextFieldDelegate((control) => {
                if (control != null && control.StringValue.Length > 0)
                {
                    cc.SendMSG(control.StringValue);
                    ShowChatMSG(cc.MyName, control.StringValue);
                    control.StringValue = "";
                }
            });

            cc.ReceiveAssignID += (newID) => this.InvokeOnMainThread(() => Window.Title = cc.MyName + " - " + newID);
            cc.ConnectionClose += () => memberDrawer.InvokeOnMainThread(() => {
                StartupWindowController s = new StartupWindowController();
                s.Window.MakeKeyAndOrderFront(this);
                this.Close();
            });
            cc.ReceiveIntroduce += (name, senderID) => mainTextField.InvokeOnMainThread(() => {
                JoinMember(name);
                data.members.Add(new ConnectionMember(name, senderID));
                memberView.ReloadData();
            });
            cc.ReceiveChatMessage += (name, msg, senderID) => mainTextField.InvokeOnMainThread(() => ShowChatMSG(name, msg));
            cc.ReceiveDirectMessage += (name, msg, senderID) => mainTextField.InvokeOnMainThread(()=>{
                ShowDMSG(cc.MyName, name, msg);
            });
            cc.ReceiveMemberList += () => memberDrawer.InvokeOnMainThread(() => {
                var e = cc.GetPeopleList();
                foreach (var n in e)
                    data.members.Add(new ConnectionMember(n.Name, n.ID));
                memberView.ReloadData();
            });
            cc.ReceiveLeave += (leaveID) => memberDrawer.InvokeOnMainThread(() => {
                var item = data.members.FirstOrDefault(c=>c.ID == leaveID);
                if (item != null)
                {
                    data.members.Remove(item);
                    memberView.ReloadData();
                }
            });

            cc.Start();
        }
コード例 #2
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            tabledata = new MyDataSource();
            connectionView.DataSource = tabledata;

            cc.ReceiveIntroduce += (name, senderID) => {
                tabledata.members.Add(new ConnectionMember(name, senderID));
                connectionView.InvokeOnMainThread(()=>connectionView.ReloadData());
            };
            cc.ConnectionClose += () => connectionView.InvokeOnMainThread(()=>{
                tabledata.members.Clear();
                var e = cc.GetPeopleList();
                foreach (var n in e)
                    tabledata.members.Add(new ConnectionMember(n.Name, n.ID));
                connectionView.ReloadData();
            });
            cc.Start();
        }