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 FinishedLaunching(NSObject notification)
 {
     startupWindowController = new StartupWindowController();
     startupWindowController.Window.MakeKeyAndOrderFront(this);
 }