Ejemplo n.º 1
0
        public async Task <PictureResponse> SetPicture(PictureForm form)
        {
            var response = new PictureResponse();

            var(system, error) = await GetPrepare(form.Id);

            if (error != null)
            {
                response.Error = error;
                return(response);
            }
            response.Picture = system.Picture;

            if (form.Picture != null)
            {
                if (form.Picture.Length > 5 * 1024 * 1024)
                {
                    response.Error = "Картинка слишком большая";
                    return(response);
                }
                var path = "/systems/" + form.Id;
                switch (form.Picture.ContentType)
                {
                case "image/gif":
                    path += ".gif";
                    break;

                case "image/jpeg":
                    path += ".jpg";
                    break;

                case "image/png":
                    path += ".png";
                    break;

                default:
                    response.Error = "Картинка неизвестного формата";
                    return(response);
                }
                using (var stream = new FileStream(_hostingEnvironment.WebRootPath + path, FileMode.Create))
                {
                    await form.Picture.CopyToAsync(stream);
                }
                var oldPath = system.Picture.Split("?").First();
                if (oldPath != path && !oldPath.StartsWith("/default/"))
                {
                    System.IO.File.Delete(_hostingEnvironment.WebRootPath + oldPath);
                }
                path          += "?d=" + DateTimeOffset.Now.ToUnixTimeMilliseconds();
                system.Picture = path;
            }

            response.Succeded = true;
            response.Picture  = system.Picture;

            await _db.SaveChangesAsync();

            return(response);
        }
Ejemplo n.º 2
0
        private void imageButton_Click(object sender, EventArgs e)
        {
            PictureForm pictureForm = new PictureForm(DataContext);

            if (pictureForm.ShowDialog() == DialogResult.OK)
            {
                AddTag("img src=\"/Images/" + pictureForm.SelectedPicture.PictureId + "\"", false);
            }
        }
Ejemplo n.º 3
0
        private void pictureBox_Click(object sender, EventArgs e)
        {
            PictureForm pictureForm = new PictureForm(DataContext);

            if (pictureForm.ShowDialog() == DialogResult.OK)
            {
                School.Picture   = pictureForm.SelectedPicture;
                pictureBox.Image = System.Drawing.Image.FromStream(new MemoryStream(School.Picture.Data.ToArray()));
            }
        }
Ejemplo n.º 4
0
        private void pictureBox_DoubleClick(object sender, EventArgs e)
        {
            if (SelectedNews != null)
            {
                PictureForm pictureForm = new PictureForm(DataContext);

                if (pictureForm.ShowDialog() == DialogResult.OK)
                {
                    SelectedNews.Picture = pictureForm.SelectedPicture;
                    pictureBox.Image     = new Bitmap(new MemoryStream(SelectedNews.Picture.Data.ToArray()));
                }
            }
        }
Ejemplo n.º 5
0
 protected override void DefWndProc(ref Message m)
 {
     if (m.Msg == WM_CLIPBOARDUPDATE && this.WindowState == FormWindowState.Normal && !this.checkBox1.Checked)
     {
         if (Clipboard.ContainsImage())
         {
             Image img = Clipboard.GetImage();
             if (img != null)
             {
                 PictureForm.AddPicture(img);
             }
         }
     }
     base.DefWndProc(ref m);
 }
Ejemplo n.º 6
0
        private void editFlagToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedCountry != null)
            {
                PictureForm pictureForm = new PictureForm(DataContext);

                if (pictureForm.ShowDialog() == DialogResult.OK)
                {
                    SelectedCountry.Picture = pictureForm.SelectedPicture;
                    DataContext.SubmitChanges();

                    countryImageList.Images.RemoveByKey(SelectedCountry.Name);
                    countryImageList.Images.Add(SelectedCountry.Name, new Bitmap(new MemoryStream(SelectedCountry.Picture.Data.ToArray())));
                }
            }
        }
Ejemplo n.º 7
0
        private void VerticalPicture_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || VerticalPicture.ImageLocation == null)
                return;

            PictureForm form = new PictureForm();
            form.ImageLocation = VerticalPicture.ImageLocation;
            form.Title = VerticalPictureTitleLabel.Text;
            form.ShowDialog();
        }
Ejemplo n.º 8
0
        //绘图
        private void PaintButton(object sender, EventArgs e)
        {
            //Task.Run(new Action(async () => { await RePaintDGV(); }));
            if (_Data.HZCount < 10)
            {
                _DataForm.ShowToast("提示", "测量数据不足10条不能绘图", 1);
                return;
            }

            pointNum = _DataRepository.getPointCount(_DataForm.InfoName).Result;
            if (SQLiteHelper.IsRePaint(_DataForm.InfoName))
            {
                #region 查询当前蓝牙的型号   &&  档位
                string    fet = "";
                string    sql = "select fet from info where name = '" + _DataForm.InfoName + "'";
                DataTable dt1 = SQLiteHelper.ExecuteDataTable(sql, null);
                if (dt1.Rows.Count != 0)
                {
                    fet = dt1.Rows[0].ItemArray[0].ToString();
                }

                string    sql1 = "select gears from info where name = '" + _DataForm.InfoName + "'";
                DataTable dt   = SQLiteHelper.ExecuteDataTable(sql1, null);
                if (dt.Rows.Count == 0)
                {
                    return;
                }

                string gears = dt.Rows[0].ItemArray[0].ToString();
                if (gears.Contains("wt"))
                {
                    gears = gears.Split(new char[] { 'w', 't', 'a' })[2];
                }
                else if (gears.Contains("g"))
                {
                    gears = gears.Split(new char[] { 'g', 'p' })[1];
                }
                #endregion
                //_DataForm.ShowToast("提示", "正在成图中,请稍后。。。", 2);

                #region 新增progressbar进度条显示
                //_DataForm.Visable();
                //显示绘图过程进度条
                ThreadPool.QueueUserWorkItem((obj) =>
                {
                    for (int i = 0; i < 100; i++)
                    {
                        Thread.Sleep(50);
                        _DataForm.PaintProgressBar(i);
                    }
                });
                #endregion

                ThreadPool.QueueUserWorkItem((obj) =>
                {
                    if (!GEOHelper.Surfer(_Data.Name, pointNum, fet, gears))
                    {
                        _DataForm.ShowToast("提示", "成图失败", 2);
                        return;
                    }
                });
                //修改是否重新成图的状态
                //isRePaintPic = true;
                _DataForm.SetPaintButtonText("查看");
                SQLiteHelper.UpdateRePaint(_DataForm.InfoName, "0");
                //_DataForm.ShowToast("提示", "成图成功!", 1);
                return;
            }

            _DataForm.SetPaintButtonText("查看");
            PictureForm _pictureForm = new PictureForm();
            _pictureForm.PictureName = _Data.Name;
            //_pictureForm.InfoSite = _DataForm.Site;
            _pictureForm.Show();
        }
        private void pb_Click(object sender, EventArgs e)
        {
            PictureForm pf = new PictureForm((sender as PictureBox).Image, true);

            pf.ShowDialog();
        }