示例#1
0
        public void LoadBuddyList()
        {
            try
            {
                //m_DelJoin = new DelJoin(EntsvcJoin);
                //m_DelIamOnline = new DelIamOnline(EntsvcIamOnline);
                //m_DelReply = new DelReply(EntsvcReply);

                objBuddyReqCollection = ClsBuddyReqCollection.GetByUserID(VMuktiAPI.VMuktiInfo.CurrentPeer.ID);
                if (objBuddyReqCollection != null)
                {
                    for (int i = 0; i < objBuddyReqCollection.Count; i++)
                    {
                        Canvas cnvBuddy = new Canvas();
                        cnvBuddy.Width  = 150;
                        cnvBuddy.Height = 50;

                        Label lblHeader = new Label();
                        lblHeader.Height = 25;
                        lblHeader.Width  = 150;
                        lblHeader.SetValue(Canvas.TopProperty, 0.0);
                        lblHeader.SetValue(Canvas.LeftProperty, 0.0);
                        lblHeader.Content = objBuddyReqCollection[i].ReqDisplayName + " Wants to Join You!!";

                        cnvBuddy.Children.Add(lblHeader);

                        Label lblQuestion = new Label();
                        lblQuestion.Height  = 25;
                        lblQuestion.Width   = 50;
                        lblQuestion.Content = "Add ?";
                        lblQuestion.SetValue(Canvas.TopProperty, 25.0);
                        lblQuestion.SetValue(Canvas.LeftProperty, 0.0);

                        cnvBuddy.Children.Add(lblQuestion);

                        Button btnAccept = new Button();
                        btnAccept.Content = "Accept";
                        btnAccept.Width   = 50;
                        btnAccept.Tag     = i;
                        btnAccept.SetValue(Canvas.TopProperty, 25.0);
                        btnAccept.SetValue(Canvas.LeftProperty, 50.0);
                        btnAccept.Click += new RoutedEventHandler(ctlBuddyGrid_btnAcceptClicked);
                        cnvBuddy.Children.Add(btnAccept);

                        Button btnReject = new Button();
                        btnReject.Content = "Reject";
                        btnReject.Width   = 50;
                        btnReject.Tag     = i;
                        btnReject.SetValue(Canvas.TopProperty, 25.0);
                        btnReject.SetValue(Canvas.LeftProperty, 100.0);
                        btnReject.Click += new RoutedEventHandler(ctlBuddyGrid_btnRejectClicked);
                        cnvBuddy.Children.Add(btnReject);

                        ListBoxItem lstiBuddy = new ListBoxItem();
                        lstiBuddy.Content   = cnvBuddy;
                        lstiBuddy.AllowDrop = false;
                        lstiBuddy.Tag       = -1;

                        lstBuddies.Items.Add(lstiBuddy);
                    }
                }

                ClsBuddyCollection MyBuddies = ClsBuddyCollection.GetByMyUserID(VMuktiAPI.VMuktiInfo.CurrentPeer.ID);
                if (MyBuddies != null)
                {
                    //((ClsPeerCommunicationChannel)objPeerCommuChannel).EntsvcJoin += new ClsPeerCommunicationChannel.DelsvcJoin(CtlBuddyList_EntsvcJoin);
                    //((ClsPeerCommunicationChannel)objPeerCommuChannel).EntsvcIamOnline += new ClsPeerCommunicationChannel.DelsvcIamOnline(CtlBuddyList_EntsvcIamOnline);
                    //((ClsPeerCommunicationChannel)objPeerCommuChannel).EntsvcReply += new ClsPeerCommunicationChannel.DelsvcReply(CtlBuddyList_EntsvcReply);
                    //((ClsPeerCommunicationChannel)objPeerCommuChannel).EntsvcStartConference+=new ClsPeerCommunicationChannel.DelsvcStartConference(CtlBuddyList_EntsvcStartConference);
                    //npcPeerCommuServer = new NetPeerService.NetPeerClient();
                    //PeerCommuService = (IPeerCommunication)npcPeerCommuServer.OpenClient<IPeerCommunication>("net.tcp://"+App.CreMachName+":2500/PeerCommunication", VMuktiAPI.VMuktiInfo.CurrentPeer.MeshID, ref objPeerCommuChannel);
                    //PeerCommuService.svcJoin();

                    for (int i = 0; i < MyBuddies.Count; i++)
                    {
                        CtlExpanderItem objExpanderItem = new CtlExpanderItem();
                        objExpanderItem.HorizontalAlignment = HorizontalAlignment.Stretch;
                        objExpanderItem.VerticalAlignment   = VerticalAlignment.Stretch;
                        objExpanderItem.Image   = @"\Images\Buddy.Png";
                        objExpanderItem.Caption = MyBuddies[i].DisplayName;

                        ListBoxItem lstiBuddy = new ListBoxItem();
                        lstiBuddy.Content   = objExpanderItem;
                        lstiBuddy.AllowDrop = true;
                        lstiBuddy.Tag       = MyBuddies[i].ID.ToString() + "," + MyBuddies[i].DisplayName;

                        lstiBuddy.PreviewMouseDown += new MouseButtonEventHandler(lstiBuddy_PreviewMouseDown);
                        lstBuddies.Items.Add(lstiBuddy);
                    }
                }


                //ctlBuddyGrid.Bind(objBuddyReqCollection);

                //ctlBuddyGrid.btnAcceptClicked += new CtlBuddyGrid.ButtonClicked(ctlBuddyGrid_btnAcceptClicked);
                //ctlBuddyGrid.btnRejectClicked += new CtlBuddyGrid.ButtonClicked(ctlBuddyGrid_btnRejectClicked);
                // btnAdd.Click += new RoutedEventHandler(btnAdd_Click);
                //this.PreviewMouseDown += new MouseButtonEventHandler(CtlBuddyList_PreviewMouseDown);
            }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "LoadBuddyList()", "Controls\\CtlBuddyList.xaml.cs");
            }
        }
        public void LoadBuddyList()
        {
            try
            {
                //m_DelJoin = new DelJoin(EntsvcJoin);
                //m_DelIamOnline = new DelIamOnline(EntsvcIamOnline);
                //m_DelReply = new DelReply(EntsvcReply);

                objBuddyReqCollection = ClsBuddyReqCollection.GetByUserID(VMuktiAPI.VMuktiInfo.CurrentPeer.ID);
                if (objBuddyReqCollection != null)
                {
                    for (int i = 0; i < objBuddyReqCollection.Count; i++)
                    {
                        Canvas cnvBuddy = new Canvas();
                        cnvBuddy.Width = 150;
                        cnvBuddy.Height = 50;

                        Label lblHeader = new Label();
                        lblHeader.Height = 25;
                        lblHeader.Width = 150;
                        lblHeader.SetValue(Canvas.TopProperty, 0.0);
                        lblHeader.SetValue(Canvas.LeftProperty, 0.0);
                        lblHeader.Content = objBuddyReqCollection[i].ReqDisplayName + " Wants to Join You!!";

                        cnvBuddy.Children.Add(lblHeader);

                        Label lblQuestion = new Label();
                        lblQuestion.Height = 25;
                        lblQuestion.Width = 50;
                        lblQuestion.Content = "Add ?";
                        lblQuestion.SetValue(Canvas.TopProperty, 25.0);
                        lblQuestion.SetValue(Canvas.LeftProperty, 0.0);

                        cnvBuddy.Children.Add(lblQuestion);

                        Button btnAccept = new Button();
                        btnAccept.Content = "Accept";
                        btnAccept.Width = 50;
                        btnAccept.Tag = i;
                        btnAccept.SetValue(Canvas.TopProperty, 25.0);
                        btnAccept.SetValue(Canvas.LeftProperty, 50.0);
                        btnAccept.Click += new RoutedEventHandler(ctlBuddyGrid_btnAcceptClicked);
                        cnvBuddy.Children.Add(btnAccept);

                        Button btnReject = new Button();
                        btnReject.Content = "Reject";
                        btnReject.Width = 50;
                        btnReject.Tag = i;
                        btnReject.SetValue(Canvas.TopProperty, 25.0);
                        btnReject.SetValue(Canvas.LeftProperty, 100.0);
                        btnReject.Click += new RoutedEventHandler(ctlBuddyGrid_btnRejectClicked);
                        cnvBuddy.Children.Add(btnReject);

                        ListBoxItem lstiBuddy = new ListBoxItem();
                        lstiBuddy.Content = cnvBuddy;
                        lstiBuddy.AllowDrop = false;
                        lstiBuddy.Tag = -1;

                        lstBuddies.Items.Add(lstiBuddy);
                    }
                }

                ClsBuddyCollection MyBuddies = ClsBuddyCollection.GetByMyUserID(VMuktiAPI.VMuktiInfo.CurrentPeer.ID);
                if (MyBuddies != null)
                {
                    //((ClsPeerCommunicationChannel)objPeerCommuChannel).EntsvcJoin += new ClsPeerCommunicationChannel.DelsvcJoin(CtlBuddyList_EntsvcJoin);
                    //((ClsPeerCommunicationChannel)objPeerCommuChannel).EntsvcIamOnline += new ClsPeerCommunicationChannel.DelsvcIamOnline(CtlBuddyList_EntsvcIamOnline);
                    //((ClsPeerCommunicationChannel)objPeerCommuChannel).EntsvcReply += new ClsPeerCommunicationChannel.DelsvcReply(CtlBuddyList_EntsvcReply);
                    //((ClsPeerCommunicationChannel)objPeerCommuChannel).EntsvcStartConference+=new ClsPeerCommunicationChannel.DelsvcStartConference(CtlBuddyList_EntsvcStartConference);
                    //npcPeerCommuServer = new NetPeerService.NetPeerClient();
                    //PeerCommuService = (IPeerCommunication)npcPeerCommuServer.OpenClient<IPeerCommunication>("net.tcp://"+App.CreMachName+":2500/PeerCommunication", VMuktiAPI.VMuktiInfo.CurrentPeer.MeshID, ref objPeerCommuChannel);
                    //PeerCommuService.svcJoin();

                    for (int i = 0; i < MyBuddies.Count; i++)
                    {
                        CtlExpanderItem objExpanderItem = new CtlExpanderItem();
                        objExpanderItem.HorizontalAlignment = HorizontalAlignment.Stretch;
                        objExpanderItem.VerticalAlignment = VerticalAlignment.Stretch;
                        objExpanderItem.Image = @"\Images\Buddy.Png";
                        objExpanderItem.Caption = MyBuddies[i].DisplayName;

                        ListBoxItem lstiBuddy = new ListBoxItem();
                        lstiBuddy.Content = objExpanderItem;
                        lstiBuddy.AllowDrop = true;
                        lstiBuddy.Tag = MyBuddies[i].ID.ToString() + "," + MyBuddies[i].DisplayName;

                        lstiBuddy.PreviewMouseDown += new MouseButtonEventHandler(lstiBuddy_PreviewMouseDown);
                        lstBuddies.Items.Add(lstiBuddy);

                    }
                }


                //ctlBuddyGrid.Bind(objBuddyReqCollection);

                //ctlBuddyGrid.btnAcceptClicked += new CtlBuddyGrid.ButtonClicked(ctlBuddyGrid_btnAcceptClicked);
                //ctlBuddyGrid.btnRejectClicked += new CtlBuddyGrid.ButtonClicked(ctlBuddyGrid_btnRejectClicked);
                // btnAdd.Click += new RoutedEventHandler(btnAdd_Click);
                //this.PreviewMouseDown += new MouseButtonEventHandler(CtlBuddyList_PreviewMouseDown);
            }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "LoadBuddyList()", "Controls\\CtlBuddyList.xaml.cs");
            }
        }