Esempio n. 1
0
        private async void btnAddPhoto_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            SetEnabledStatus(false);
            SetStatus("Uploading photo...");

            // get file size for pgoresss
            CurrentUploadingSize = new FileInfo(openFileDialog1.FileName).Length;

            var result = await TwitterApi.UploadMedia(openFileDialog1.FileName, UploadMedia_Processing);

            if (result.IsSuccessfully)
            {
                // add photo to uploaded list
                var image = new PictureBox();
                image.Height   = UploadedImages.Height;
                image.Width    = UploadedImages.Height;
                image.SizeMode = PictureBoxSizeMode.StretchImage;

                // save media_id to tag
                image.Tag = result["media_id"].ToString();

                using (var file = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read, FileShare.Inheritable))
                {
                    image.Image = Image.FromStream(file);
                }

                var delete = new Button();
                delete.BackColor = Color.Red;
                delete.Text      = "X";
                delete.ForeColor = Color.White;
                delete.Font      = new Font(delete.Font, FontStyle.Bold);
                delete.Padding   = new Padding(0);
                delete.Margin    = new Padding(0);
                delete.Width     = 24;
                delete.Height    = 24;
                delete.Top       = 0;
                delete.Left      = image.Width - delete.Width;
                delete.Visible   = false;

                delete.Click += (sss, eee) =>
                {
                    UploadedImages.Controls.Remove(((Button)sss).Parent);
                    btnAddPhoto.Enabled = (UploadedImages.Controls.Count < 4);
                };

                image.MouseEnter += (sss, eee) =>
                {
                    delete.Visible = true;
                };

                image.MouseLeave += (sss, eee) =>
                {
                    if (image.GetChildAtPoint(image.PointToClient(Cursor.Position)) == null)
                    {
                        delete.Visible = false;
                    }
                };

                image.Controls.Add(delete);

                UploadedImages.Controls.Add(image);

                SetEnabledStatus(true);
                SetStatus("Photo uploaded successfully!", Properties.Resources.success);

                btnAddPhoto.Enabled = (UploadedImages.Controls.Count < 4);
            }
            else
            {
                ErrorResult(result);
            }
        }
Esempio n. 2
0
        public void Pic_MouseEnter(object sender, EventArgs e)
        {

            PictureBox picBox_active = sender as PictureBox;
            Cursor Cursor = Cursors.Hand;
            if (fm1.lightTheme == true)
            {
                picBox_active.BackColor = Color.DodgerBlue;

                Point p = new Point(0, 65);
                picBox_active.HasChildren.Equals(true);
                var label = picBox_active.GetChildAtPoint(p);
                label.ForeColor = Color.Black;
            }
            else if (fm1.blueTheme == true)
            {
                picBox_active.BackColor = Color.LightBlue;

                Point p = new Point(0, 65);
                picBox_active.HasChildren.Equals(true);
                var label = picBox_active.GetChildAtPoint(p);
                label.ForeColor = Color.Black;
            }
            else if (fm1.yellowTheme == true)
            {
                picBox_active.BackColor = Color.Black;

                Point p = new Point(0, 65);
                picBox_active.HasChildren.Equals(true);
                var label = picBox_active.GetChildAtPoint(p);
                label.ForeColor = Color.Yellow;
            }
            else if (fm1.orangeTheme == true)
            {
                picBox_active.BackColor = Color.Black;

                Point p = new Point(0, 65);
                picBox_active.HasChildren.Equals(true);
                var label = picBox_active.GetChildAtPoint(p);
                label.ForeColor = Color.Orange;
            }
            else if (fm1.greenTheme == true)
            {
                picBox_active.BackColor = Color.LightGreen;

                Point p = new Point(0, 65);
                picBox_active.HasChildren.Equals(true);
                var label = picBox_active.GetChildAtPoint(p);
                label.ForeColor = Color.Black;
            }
            else if (fm1.redTheme == true)
            {
                picBox_active.BackColor = Color.Black;

                Point p = new Point(0, 65);
                picBox_active.HasChildren.Equals(true);
                var label = picBox_active.GetChildAtPoint(p);
                label.ForeColor = Color.Red;
            }
            else if (fm1.darkTheme == true)
            {
                picBox_active.BackColor = Color.Lime;

                Point p = new Point(0, 65);
                picBox_active.HasChildren.Equals(true);
                var label = picBox_active.GetChildAtPoint(p);
                label.ForeColor = Color.Black;


            }
            else if (fm1.purpleTheme == true)
            {
                picBox_active.BackColor = Color.White;

                Point p = new Point(0, 65);
                picBox_active.HasChildren.Equals(true);
                var label = picBox_active.GetChildAtPoint(p);
                label.ForeColor = Color.Purple;
            }
            else
            {


            }

        }