private void SendButtonsInitialize()
        {
            this.sendButton           = new Button();
            this.sendButton.Image     = new Bitmap(FileResources.Icon("sendButton.png"), new Size(this.nuntiasTextBox.Height, this.nuntiasTextBox.Height));
            this.sendButton.Font      = this.nuntiasTextBox.Font;
            this.sendButton.Size      = this.sendButton.Image.Size;
            this.sendButton.Left      = this.nuntiasTextBox.Width + 15;
            this.sendButton.FlatStyle = FlatStyle.Flat;
            this.sendButton.FlatAppearance.BorderSize = 0;
            this.sendButton.Click += new EventHandler(this.OnClick);
            this.typingSpaceBar.Controls.Add(this.sendButton);

            this.chooseFileButton           = new Button();
            this.chooseFileButton.Image     = GraphicsStudio.ResizeImageByHeight(FileResources.Icon("choosefiles.png"), sendButton.Image.Height);
            this.chooseFileButton.Font      = this.nuntiasTextBox.Font;
            this.chooseFileButton.Size      = this.chooseFileButton.Image.Size;
            this.chooseFileButton.Left      = this.sendButton.Right + 15;
            this.chooseFileButton.FlatStyle = FlatStyle.Flat;
            this.chooseFileButton.FlatAppearance.BorderSize = 0;
            this.chooseFileButton.Click += new EventHandler(this.OnClick);
            this.typingSpaceBar.Controls.Add(this.chooseFileButton);

            this.snapshotButton           = new Button();
            this.snapshotButton.Image     = GraphicsStudio.ResizeImageByHeight(FileResources.Icon("snapshot.png"), sendButton.Image.Height);
            this.snapshotButton.Font      = this.nuntiasTextBox.Font;
            this.snapshotButton.Size      = this.snapshotButton.Image.Size;
            this.snapshotButton.Left      = this.chooseFileButton.Right + 15;
            this.snapshotButton.FlatStyle = FlatStyle.Flat;
            this.snapshotButton.FlatAppearance.BorderSize = 0;
            this.snapshotButton.Click += new EventHandler(this.OnClick);
            this.typingSpaceBar.Controls.Add(this.snapshotButton);
        }
Beispiel #2
0
 public static string ChangeProfileImage(Image gotImg)
 {
     using (Bitmap roundedBmp = new Bitmap(GraphicsStudio.ClipToCircle(gotImg), new Size(200, 200)))
     {
         JObject profileImgIdJson = null;
         byte[]  imgByteArray     = Universal.ImageToByteArray(roundedBmp, gotImg.RawFormat);
         ServerHub.WorkingInstance.ServerHubProxy.Invoke <JObject>("ChangeProfileImage", Consumer.LoggedIn.Id, imgByteArray).ContinueWith(task =>
         {
             if (!task.IsFaulted)
             {
                 profileImgIdJson = task.Result;
             }
         }).Wait();
         if (profileImgIdJson == null)
         {
             return(null);
         }
         try
         {
             string oldProfileImgId = profileImgIdJson["old_image_id"].ToString();
             if (oldProfileImgId != null && oldProfileImgId.Length > 5)
             {
                 LocalDataFileAccess.EraseOldProfileImageFromLocalData(oldProfileImgId);
             }
             string newImgId = profileImgIdJson["new_image_id"].ToString();
             LocalDataFileAccess.SaveProfileImageToLocal(roundedBmp, newImgId);
             return(newImgId);
         }
         catch (Exception e)
         {
             Console.WriteLine("Error occured in ChangeProfileImage() => " + e.Message);
             return(null);
         }
     }
 }
Beispiel #3
0
        public JObject ChangeProfileImage(long userId, byte[] imageArray)
        {
            Output.ShowLog("ChangeProfileImage() => " + userId);
            Image  img             = new Bitmap(GraphicsStudio.ClipToCircle(Universal.ByteArrayToImage(imageArray)), new Size(200, 200));
            string newProfileImgId = "DP_" + userId + "_" + Time.CurrentTime.TimeStampString;
            string oldProfileImgId = ConsumerRepository.Instance.ReassignConsumerProfileImgId(userId, newProfileImgId);

            if (oldProfileImgId != null && oldProfileImgId.Length >= 5)
            {
                ImageFileAccess.EraseProfileImage(oldProfileImgId);
            }
            JObject profileImgIdJson = new JObject();

            profileImgIdJson["old_image_id"] = null;
            profileImgIdJson["new_image_id"] = null;
            if (ImageFileAccess.SaveProfileImage(img, newProfileImgId))
            {
                profileImgIdJson["old_image_id"] = oldProfileImgId;
                profileImgIdJson["new_image_id"] = newProfileImgId;
                Output.ShowLog(profileImgIdJson);
            }
            return(profileImgIdJson);
        }
Beispiel #4
0
        private void UserViewPanelInitialize()
        {
            this.userViewPanel           = new Panel();
            this.userViewPanel.BackColor = Color.FromArgb(0, 0, 80);
            this.userViewPanel.Width     = this.Width - 4;
            this.userViewPanel.Location  = new Point(2, 2);

            this.AddIconsToUserView();

            userProfilePictureLabel                   = new Label();
            userProfilePictureLabel.Image             = this.ResizedProfileImage;
            userProfilePictureLabel.Location          = new Point((this.userViewPanel.Width - userProfilePictureLabel.Image.Width) / 2, userViewIcons[0].Bottom + 20);
            userProfilePictureLabel.Size              = userProfilePictureLabel.Image.Size;
            userProfilePictureLabel.MouseHover       += delegate(Object sender, EventArgs e) { userProfilePictureLabel.Image = GraphicsStudio.Overlap(userProfilePictureLabel.Image, new Bitmap(FileResources.Picture("pictureChangeHint.png"), userProfilePictureLabel.Image.Size)); };
            userProfilePictureLabel.MouseLeave       += delegate(Object sender, EventArgs e) { userProfilePictureLabel.Image = this.ResizedProfileImage; };
            userProfilePictureLabel.MouseDoubleClick += delegate(Object sender, MouseEventArgs e) { ((SlidebarPanel)this.parent).ChangeProfilePicture(); };
            this.userViewPanel.Controls.Add(userProfilePictureLabel);

            fullnameTextBox           = new TextBox();
            fullnameTextBox.Text      = this.UserProfileName;
            fullnameTextBox.Font      = CustomFonts.SmallBold;
            fullnameTextBox.Height    = fullnameTextBox.PreferredHeight;
            fullnameTextBox.TextAlign = HorizontalAlignment.Center;
            fullnameTextBox.Width     = this.Width * 3 / 4;
            fullnameTextBox.BackColor = Color.FromArgb(userViewPanel.BackColor.R + 50, userViewPanel.BackColor.G + 50, userViewPanel.BackColor.B + 50);
            fullnameTextBox.Location  = new Point((this.userViewPanel.Width - fullnameTextBox.Width) / 2, userProfilePictureLabel.Bottom + 20);
            fullnameTextBox.ForeColor = Color.FromArgb(240, 240, 240);
            this.userViewPanel.Controls.Add(fullnameTextBox);

            dragengerUsernameTextBox             = new TextBox();
            dragengerUsernameTextBox.Text        = "@" + User.LoggedIn.Username;
            dragengerUsernameTextBox.ReadOnly    = true;
            dragengerUsernameTextBox.Font        = CustomFonts.New(13.0f, 'i');
            dragengerUsernameTextBox.Width       = fullnameTextBox.Width;
            dragengerUsernameTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
            dragengerUsernameTextBox.TextAlign   = HorizontalAlignment.Center;
            dragengerUsernameTextBox.BackColor   = Color.FromArgb(userViewPanel.BackColor.R + 20, userViewPanel.BackColor.G + 20, userViewPanel.BackColor.B + 20);
            dragengerUsernameTextBox.Location    = new Point((this.userViewPanel.Width - dragengerUsernameTextBox.Width) / 2, fullnameTextBox.Bottom + 5);
            dragengerUsernameTextBox.ForeColor   = Color.FromArgb(240, 240, 240);
            this.userViewPanel.Controls.Add(dragengerUsernameTextBox);

            this.userViewPanel.Height = this.userViewPanel.PreferredSize.Height + 20;
            this.Controls.Add(this.userViewPanel);
        }
        private void UserViewPanelInitialize()
        {
            this.userViewPanel           = new Panel();
            this.userViewPanel.BackColor = Color.FromArgb(0, 0, 80);
            this.userViewPanel.Width     = this.Width - 4;
            this.userViewPanel.Location  = new Point(2, 2);

            this.AddIconsToUserView();

            userProfilePictureLabel                   = new Label();
            userProfilePictureLabel.Image             = this.ResizedProfileImage;
            userProfilePictureLabel.Location          = new Point((this.userViewPanel.Width - userProfilePictureLabel.Image.Width) / 2, userViewIcons[0].Bottom + 20);
            userProfilePictureLabel.Size              = userProfilePictureLabel.Image.Size;
            userProfilePictureLabel.MouseHover       += delegate(Object sender, EventArgs e) { userProfilePictureLabel.Image = GraphicsStudio.Overlap(userProfilePictureLabel.Image, new Bitmap(FileResources.Picture("pictureChangeHint.png"), userProfilePictureLabel.Image.Size)); };
            userProfilePictureLabel.MouseLeave       += delegate(Object sender, EventArgs e) { userProfilePictureLabel.Image = this.ResizedProfileImage; };
            userProfilePictureLabel.MouseDoubleClick += delegate(Object sender, MouseEventArgs e) { this.ChangeProfilePicture(); };
            this.userViewPanel.Controls.Add(userProfilePictureLabel);

            userFUllNameLabel           = new Label();
            userFUllNameLabel.Text      = this.UserProfileName;
            userFUllNameLabel.Font      = CustomFonts.SmallBold;
            userFUllNameLabel.Size      = userFUllNameLabel.PreferredSize;
            userFUllNameLabel.Location  = new Point((this.userViewPanel.Width - userFUllNameLabel.Width) / 2, userProfilePictureLabel.Bottom + 20);
            userFUllNameLabel.ForeColor = Color.FromArgb(240, 240, 240);
            this.userViewPanel.Controls.Add(userFUllNameLabel);

            Label dragengerEmailLabel = new Label();

            dragengerEmailLabel.Text      = this.FetchDragengerEmail;
            dragengerEmailLabel.Font      = CustomFonts.New(12.0f, 'i');
            dragengerEmailLabel.Size      = dragengerEmailLabel.PreferredSize;
            dragengerEmailLabel.Location  = new Point((this.userViewPanel.Width - dragengerEmailLabel.Width) / 2, userFUllNameLabel.Bottom + 5);
            dragengerEmailLabel.ForeColor = Color.FromArgb(240, 240, 240);
            this.userViewPanel.Controls.Add(dragengerEmailLabel);

            this.userViewPanel.Height = this.userViewPanel.PreferredSize.Height + 20;
            this.mainPanelInSidebar.Controls.Add(this.userViewPanel);
        }
        private void ShowNuntiasContentPreview(string choosenSafeFileName, string localPath)
        {
            this.nuntiasTextBox.Multiline = false;
            this.nuntiasTextBox.Multiline = true;
            this.nuntiasTextBox.Visible   = false;
            this.sendButton.Visible       = false;

            int    availableTop = 0;
            string extension    = Path.GetExtension(localPath).ToLower();

            if (extension == ".jpg" || extension == ".jpeg" || extension == ".png" || extension == ".gif" || extension == ".bmp")
            {
                int targetHeight = sendButton.Height * 5;
                imgPreview       = new Label();
                imgPreview.Image = GraphicsStudio.ResizeImageByHeight(Image.FromFile(localPath), targetHeight);
                imgPreview.Size  = imgPreview.Image.Size;
                FilePreviewPanelHeight(imgPreview.Height + 40);
                imgPreview.Location = new Point(10, 5);
                availableTop        = 5 + imgPreview.Height;
                this.filePreviewPanel.Controls.Add(imgPreview);
            }
            else
            {
                FilePreviewPanelHeight(40);
            }
            fileNameLabel           = new Label();
            fileNameLabel.Text      = this.ReformatFileNameString(choosenSafeFileName);
            fileNameLabel.Font      = CustomFonts.New(CustomFonts.SmallerSize, 'i');
            fileNameLabel.ForeColor = Color.FromArgb(102, 51, 0);
            fileNameLabel.Size      = fileNameLabel.PreferredSize;
            this.filePreviewPanel.Controls.Add(fileNameLabel);

            Label  attachmentLabel = new Label();
            Image  attachImg = FileResources.Icon("attachment.png");
            double attachHght = attachImg.Size.Height, targetHght = fileNameLabel.Height;

            attachmentLabel.Image    = new Bitmap(attachImg, new Size((int)((targetHght / attachHght) * attachImg.Size.Width), (int)targetHght));
            attachmentLabel.Size     = attachmentLabel.Image.Size;
            attachmentLabel.Location = new Point(10, availableTop + 5);
            fileNameLabel.Location   = new Point(attachmentLabel.Right + 5, availableTop + 5);
            this.filePreviewPanel.Controls.Add(attachmentLabel);

            Size fileButtonSize = new Size(filePreviewPanel.Height * 7 / 10, filePreviewPanel.Height * 7 / 10);

            if (imgPreview != null && imgPreview.Visible)
            {
                fileButtonSize = new Size(filePreviewPanel.Height * 2 / 5, filePreviewPanel.Height * 2 / 5);
            }

            sendFileButton           = FileButtonsDefine("sendfile", fileButtonSize);
            this.parent.AcceptButton = sendFileButton;
            sendFileButton.Location  = new Point(filePreviewPanel.Right - sendFileButton.Width - 30, (filePreviewPanel.Height - sendFileButton.Height) / 2);
            sendFileButton.Click    += (s, e) => { this.SendChoosenFile(choosenSafeFileName, localPath, extension); };

            cancelFileButton          = this.FileButtonsDefine("cancelfile", fileButtonSize);
            this.parent.CancelButton  = cancelFileButton;
            cancelFileButton.Location = new Point(sendFileButton.Left - cancelFileButton.Width, (filePreviewPanel.Height - cancelFileButton.Height) / 2);
            cancelFileButton.Click   += delegate(Object sender, EventArgs e)
            {
                this.FilePreviewPanelHeight(0);
            };
        }