예제 #1
0
        public UserProfilForm(User client, bool readOnly)
        {
            InitializeComponent();
            //Un backup si on enregistre pas
            oldClient = client.Clone();

            this.ReadOnly = readOnly;

            //On assigne si on peut modifier
            buttonEditAvatar.Enabled = !readOnly;
            buttonConfirm.Enabled = !readOnly;

            //On assigne les sources de données
            this.ActualClient = client;
            this.userProfilFormBindingSource.DataSource = this;

            labelAvatar.Image = (Bitmap)Resources.ResourceManager.GetObject(!String.IsNullOrEmpty(ActualClient.Avatar) ? ActualClient.Avatar : "default");

            if (client.IsConnected)
            {
                labelConnected.Text = "CONNECTÉ";
                labelConnected.ForeColor = Color.Lime;
            }
            else
            {
                labelConnected.Text = "DÉCONNECTÉ";
                labelConnected.ForeColor = Color.Red;
            }
        }
예제 #2
0
        public RoomForm(DiscussionRoom room, User user)
        {
            lastRefresh = DateTime.Now;
            actualUser = user;
            actualRoom = room;

            InitializeComponent();
        }
예제 #3
0
        public HomeForm(User client)
        {
            actualClient = client;
            InitializeComponent();

            labelUserName.Text = client.UserName;

            DisplayConnect(client.IsConnected);

            labelAvatar.Image = (Bitmap)Resources.ResourceManager.GetObject(!String.IsNullOrEmpty(client.Avatar) ? client.Avatar : "default");
        }
예제 #4
0
        public AvatarForm(User client)
        {
            InitializeComponent();

            actualClient = client;

            switch (client.Avatar)
            {
                case "default":
                    radioButtonDefault.Checked = true;
                    break;
                case "homer":
                    radioButtonHomer.Checked = true;
                    break;
                case "ironman":
                    radioButtonIronMan.Checked = true;
                    break;
                case "minion":
                    radioButtonMinion.Checked = true;
                    break;
                default:
                    break;
            }
        }
예제 #5
0
        private int CallBackViewProfile(Data received)
        {
            if (received.Command == Data.DataType.ViewProfile)
            {
                User user = (User)received.Other;
                if (user == null)
                {
                    MessageBox.Show("Cet utilisateur n'existe plus sous ce nom.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    bool readOnly = user.UserName != actualClient.UserName;
                    UserProfilForm profilForm = new UserProfilForm(user, readOnly);
                    DialogResult result = DialogResult.None;
                    this.Invoke((MethodInvoker)delegate() { result = profilForm.ShowDialog(); });

                    if (!readOnly)
                    {
                        if (result == DialogResult.OK)
                        {
                            actualClient = user;
                        }
                        else
                        {
                            actualClient = profilForm.oldClient;
                        }

                        this.Invoke((MethodInvoker)delegate()
                        {
                            labelUserName.Text = actualClient.UserName;
                            labelAvatar.Image = (Bitmap)Resources.ResourceManager.GetObject(actualClient.Avatar);
                        });
                    }
                }

                Data listUserRequest = new Data();
                listUserRequest.Command = Data.DataType.ListClient;
                Program.callBackOnReceive.Enqueue(CallBackListClient);
                Program.client.Send(listUserRequest);
            }
            else
            {
                //MessageBox.Show("ERROR!!!.");
            }
            return 0;
        }
예제 #6
0
        public static void Add()
        {
            //  Load data from DB (XML files)
            string fileName = "Data.xml";
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            FileStream fs = new FileStream(fileName, FileMode.Create);
            User user1 = new User();
            User user2 = new User();
            User user3 = new User();
            User user4 = new User();
            User user5 = new User();
            User user6 = new User();

            user1.Id = 1;
            user1.FirstName = "Alexandre";
            user1.LastName = "Roy";
            user1.Avatar = "ironman";
            user1.DislikeNum = 0;
            user1.LikeNum = 0;
            user1.NumMessages = 0;
            user1.UserName = "******";
            user1.Password = "******";

            user2.Id = 2;
            user2.FirstName = "Alex";
            user2.LastName = "Nault";
            user2.Avatar = "homer";
            user2.DislikeNum = 0;
            user2.LikeNum = 0;
            user2.NumMessages = 0;
            user2.UserName = "******";
            user2.Password = "******";

            user3.Id = 3;
            user3.FirstName = "Johny";
            user3.LastName = "Forcier";
            user3.Avatar = "default";
            user3.DislikeNum = 0;
            user3.LikeNum = 0;
            user3.NumMessages = 0;
            user3.UserName = "******";
            user3.Password = "******";

            user4.Id = 4;
            user4.FirstName = "Vincent";
            user4.LastName = "Philippon";
            user4.Avatar = "minion";
            user4.DislikeNum = 0;
            user4.LikeNum = 0;
            user4.NumMessages = 0;
            user4.UserName = "******";
            user4.Password = "******";

            user5.Id = 5;
            user5.FirstName = "Francois";
            user5.LastName = "Genois";
            user5.Avatar = "homer";
            user5.DislikeNum = 0;
            user5.LikeNum = 0;
            user5.NumMessages = 0;
            user5.UserName = "******";
            user5.Password = "******";

            user6.Id = 6;
            user6.FirstName = "Tommy";
            user6.LastName = "Gregoire";
            user6.Avatar = "ironman";
            user6.DislikeNum = 0;
            user6.LikeNum = 0;
            user6.NumMessages = 0;
            user6.UserName = "******";
            user6.Password = "******";

            DiscussionRoom room1 = new DiscussionRoom();
            DiscussionRoom room2 = new DiscussionRoom();
            DiscussionRoom room3 = new DiscussionRoom();

            room1.Id = 1;
            room1.Name = "Salle1";
            room1.Description = "Premiere salle de discussion dans le monde!";

            room2.Id = 2;
            room2.Name = "Salle2";
            room2.Description = "Deuxieme salle de discussion dans le monde!";

            room3.Id = 3;
            room3.Name = "Salle3";
            room3.Description = "Troisieme salle de discussion dans le monde!";

            List<DiscussionRoom> rooms = new List<DiscussionRoom>();
            rooms.Add(room1);
            rooms.Add(room2);
            rooms.Add(room3);

            List<User> users = new List<User>();
            users.Add(user1);
            users.Add(user2);
            users.Add(user3);
            users.Add(user4);
            users.Add(user5);
            users.Add(user6);

            XMLData xmlData = new XMLData(rooms, users);

            DataContractSerializer serializer = new DataContractSerializer(xmlData.GetType(), null,
                0x7FFF, // maxItemsInObjectGraph
                false, // ignoreExtensionDataObject
                true, // preserveObjectReferences
                null // dataContractSurrogate
            );
            //Console.WriteLine("Testing for type: {0}", typeof(XMLData));
            serializer.WriteObject(fs, xmlData);
            fs.Close();
        }