示例#1
0
        //保存
        protected void Submit1_ServerClick(object sender, EventArgs e)
        {
            ArticleDal ar = new ArticleDal();
            ar.classId = classId.Text;
            ar.title = ArticleTitle.Value.ToString();
            ar.content = content.Value.ToString();

            //保存图片
            string imgPath;
            Img img = new Img();
            img.savePathName = "article";
            imgPath = img.saveImage(filePath.Value);
            string err;
            if (img.error != "")
            {
                showMessage(img.error);
                return;
            }
            ar.imgPath = imgPath;
            if (app == "edit")
            {
                ar.edit(id);
                err = "修改成功";
                showMessage(err);
            }
            else
            {
                ar.add();
                err = "添加成功";
                showMessage(err, "gl_manage.aspx?classid=" + classid);
            }

        }
示例#2
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     this.timer1 = new System.Windows.Forms.Timer(this.components);
     this.img1 = new reSize.Img();
     this.SuspendLayout();
     //
     // timer1
     //
     this.timer1.Interval = 1000;
     this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
     //
     // img1
     //
     this.img1.BackColor = System.Drawing.Color.Transparent;
     this.img1.Location = new System.Drawing.Point(64, 32);
     this.img1.Name = "img1";
     this.img1.Size = new System.Drawing.Size(153, 192);
     this.img1.TabIndex = 1;
     this.img1.Text = "img1";
     this.img1.DoubleClick += new System.EventHandler(this.img1_DoubleClick);
     //
     // face
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
     this.ClientSize = new System.Drawing.Size(292, 273);
     this.Controls.Add(this.img1);
     this.Name = "face";
     this.Text = "双击选框进行裁剪";
     this.Load += new System.EventHandler(this.face_Load);
     this.ResumeLayout(false);
 }
示例#3
0
        protected void btn_ServerClick(object sender, EventArgs e)
        {
            Img img = new Img();
            img.savePathName = "files";
            string path = img.saveImage("");
            if (img.error == "")
            {
                AlbumInfo info = new AlbumInfo();
                info.album_name = path;
                info.imgUrl = path;
                info.showHome = false;
                info.linkUrl = "";

                AlbumDal al = new AlbumDal();
                int id = al.add(info);
                StringBuilder sb = new StringBuilder();
                sb.Append("<span style='font-size:12px;BACKGROUND: #F7F7F7;'>上传成功!");
                sb.Append("<a href=\"javascript:;\" onClick=\"parent.addContent(iname);\">插入</a> ");
                sb.Append("<a href=\"javascript:history.back();\">继续上传</a></span>");
                sb.Append("<script language=\"JavaScript\">");
                sb.Append("var iname=\""+gform("up_name")+"\";");
                sb.Append("parent.document.getElementById(iname).value=\"" + path + "\";</script>;");
                die(sb.ToString());
            }
            else
            {
                Response.Write(img.error+" <a href=\"javascript:history.back()\">返回</a>");
                Response.End();
            }
        }
示例#4
0
        protected void btn_ServerClick(object sender, EventArgs e)
        {
            Img img = new Img();
            img.savePathName = "album";
            string path = img.saveImage("");
            if (img.error == "")
            {
                AlbumInfo info = new AlbumInfo();
                info.album_name = path;
                info.imgUrl = path;
                if (showHome.Checked)
                    info.showHome = true;
                else
                    info.showHome = false;
                info.linkUrl = linkUrl.Value;

                AlbumDal al = new AlbumDal();
                int id = al.add(info);
                showMessage("上传成功<br/>图片地址:<a href=\"" + path + "\" target=\"_blank\">" + path + "</a>");
            }
            else
            {
                showMessage(img.error);
            }
            
        }
示例#5
0
 public async void AddImg(string file)
 {
     await IsLoaded.Task;
     if (string.IsNullOrEmpty(file)) return;
     var i = new Img(file);
     await i.Initialize(canvas);
     slideshow.Imgs.Add(i);
 }
示例#6
0
 public async void SetDefaultPic(string file)
 {
     await IsLoaded.Task;
     if (string.IsNullOrEmpty(file)) return;
     var i = new Img(file);
     await i.Initialize(canvas);
     slideshow.DefaultImg = i;
 }
        public (string headerName, string headerValue) ToString(ICspNonceService nonceService)
        {
            string headerName;

            if (ReportOnly)
            {
                headerName = "Content-Security-Policy-Report-Only";
            }
            else
            {
                headerName = "Content-Security-Policy";
            }
            var values = new List <string>
            {
                Default.ToString(nonceService),
                Script.ToString(nonceService),
                Style.ToString(nonceService),
#pragma warning disable CS0618 // Type or member is obsolete
                Child.ToString(nonceService),
#pragma warning restore CS0618 // Type or member is obsolete
                Connect.ToString(nonceService),
                Font.ToString(nonceService),
                FormAction.ToString(nonceService),
                Img.ToString(nonceService),
                Media.ToString(nonceService),
                Object.ToString(nonceService),
                FrameAncestors.ToString(),
                PluginTypes.ToString(),
                Frame.ToString(nonceService),
                Worker.ToString(nonceService),
                Prefetch.ToString(nonceService),
                BaseUri.ToString(nonceService)
            };

            if (BlockAllMixedContent)
            {
                values.Insert(0, "block-all-mixed-content");
            }
            if (UpgradeInsecureRequests)
            {
                values.Insert(0, "upgrade-insecure-requests");
            }
            if (EnableSandbox)
            {
                values.Add(Sandbox.ToString());
            }
            if (ReportUri != null)
            {
                values.Add("report-uri " + ReportUri);
            }

            string headerValue = string.Join(";", values.Where(s => s.Length > 0));

            return(headerName, headerValue);
        }
示例#8
0
        public void Merge(params DocumentStyle[] styles)
        {
            if (styles != null)
            {
                foreach (var style in styles)
                {
                    Section.Merge(style.Section);
                    Article.Merge(style.Article);
                    Header.Merge(style.Header);
                    Footer.Merge(style.Footer);
                    Main.Merge(style.Main);
                    Figure.Merge(style.Figure);
                    Details.Merge(style.Details);
                    Summary.Merge(style.Summary);
                    Div.Merge(style.Div);
                    Ul.Merge(style.Ul);
                    Ol.Merge(style.Ol);
                    Dl.Merge(style.Dl);
                    Td.Merge(style.Td);

                    Table.Merge(style.Table);

                    Img.Merge(style.Img);
                    YouTube.Merge(style.YouTube);
                    Channel9.Merge(style.Channel9);

                    H1.Merge(style.H1);
                    H2.Merge(style.H2);
                    H3.Merge(style.H3);
                    H4.Merge(style.H4);
                    H5.Merge(style.H5);
                    H6.Merge(style.H6);
                    BlockQuote.Merge(style.BlockQuote);
                    P.Merge(style.P);
                    FigCaption.Merge(style.FigCaption);
                    Pre.Merge(style.Pre);
                    Dt.Merge(style.Dt);
                    Dd.Merge(style.Dd);

                    Li.Merge(style.Li);

                    A.Merge(style.A);
                    Span.Merge(style.Span);
                    Label.Merge(style.Label);
                    Q.Merge(style.Q);
                    Cite.Merge(style.Cite);
                    I.Merge(style.I);
                    Em.Merge(style.Em);
                    Mark.Merge(style.Mark);
                    Time.Merge(style.Time);
                    Code.Merge(style.Code);
                    Strong.Merge(style.Strong);
                }
            }
        }
示例#9
0
        /// <summary>
        /// 上传图片(自定义保存路径),同时生成最小的缩略图
        /// </summary>
        /// <param name="uploadPath">保存路径(相对路径)</param>
        /// <param name="postedFile">HttpFile</param>
        /// <param name="picName">图片名称</param>
        /// <param name="width">宽度</param>
        /// <param name="height">高度</param>
        /// <returns></returns>
        public static Result SaveImg(String uploadPath, HttpFile postedFile, String picName, int width, int height)
        {
            logger.Info("uploadPath : " + uploadPath);
            logger.Info("picName : " + picName);
            Result result = new Result();

            checkUploadPic(postedFile, result);
            if (result.HasErrors)
            {
                return(result);
            }

            String str      = PathHelper.Map(uploadPath);
            String str2     = picName + "." + Img.GetImageExt(postedFile.ContentType);
            String filename = Path.Combine(str, str2);

            try {
                String oldFile = null;
                if (file.Exists(filename))
                {
                    oldFile = filename + "." + Guid.NewGuid() + Path.GetExtension(filename);
                    file.Move(filename, oldFile);
                }

                postedFile.SaveAs(filename);

                try {
                    saveThumbImagePrivate(filename, ThumbnailType.Small, width, height, SaveThumbnailMode.Cut);

                    if (strUtil.HasText(oldFile))
                    {
                        file.Delete(oldFile);
                    }
                }
                catch (OutOfMemoryException ex) {
                    file.Delete(filename);
                    if (strUtil.HasText(oldFile))
                    {
                        file.Move(oldFile, filename);
                    }

                    String msg = "file format error: " + picName;
                    logger.Error(msg);
                    result.Add(msg);
                    return(result);
                }
            }
            catch (Exception exception) {
                logger.Error(lang.get("exPhotoUploadError") + ":" + exception.Message);
                result.Add(lang.get("exPhotoUploadErrorTip"));
                return(result);
            }
            result.Info = Path.GetFileName(Img.GetThumbPath(filename));
            return(result);
        }
示例#10
0
 public void CompressEquallyOrBetter(string fileName, int expectLength) =>
 File.OpenRead($"kh2/res/{fileName}.dec").Using(stream =>
 {
     var compress = Img.Compress(stream.ReadAllBytes());
     File.WriteAllBytes($"D:\\{fileName}.openkh", compress);
     if (compress.Length > expectLength)
     {
         throw new XunitException($"Compressed file is {compress.Length} byte, but the official one is {expectLength}.\n" +
                                  "The compression algorithm is not performant enough.");
     }
 });
示例#11
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (NuevoPersonaje != null)
     {
         Img          personaje = Singleton.GetInstance().CrearPersonaje(NuevoPersonaje);
         ComboboxItem item      = new ComboboxItem();
         comboBox.Items.Add(Path.GetFileName(personaje.Referencia));
         NuevoPersonaje = null;
         Singleton.GetInstance().PreservarPersonajes(personaje);
     }
 }
示例#12
0
 Rectangle GetButtonRect(Img location)
 {
     for (int i = 0; i < decks.Length; i++)
     {
         if (decks[i].Icon == location)
         {
             return(iconPositions[i]);
         }
     }
     throw new ArgumentException("invalid card location");
 }
示例#13
0
 List <PowerCard> GetCardsForLocation(Img location)
 {
     foreach (var deck in decks)
     {
         if (deck.Icon == location)
         {
             return(deck.PowerCards);
         }
     }
     throw new ArgumentException("invalid card location");
 }
    public static void Add(this string object_model, Img img)
    {
        switch (object_model)
        {
        case "UserImage":
        { UserImage.Add(img); break; }

        case "CarImage":
        { CarImage.Add(img); break; }
        }
    }
示例#15
0
        public ActionResult generateCloudFiles()
        {
            var images = repository.GetImagesAll();

            foreach (var image in images)
            {
                Img.UploadImageSizes(image.url);
            }

            return(Content("Done"));
        }
示例#16
0
        protected override void writeCustomXml(XmlTextWriter writer)
        {
            writer.WriteStartElement("image");
            string    fileName = Path.GetTempPath() + "mazioPictureShape.png";
            PngFormat format   = new PngFormat();

            Img.Save(fileName, format.getCodecInfo(), format.getParameters());
            byte[] bytes = File.ReadAllBytes(fileName);
            writer.WriteBase64(bytes, 0, bytes.Length);
            writer.WriteEndElement();
        }
示例#17
0
        public Image GetImage(Img img)                   // !!! make this private
        {
            if (images.ContainsKey(img))
            {
                return(images[img]);
            }
            var image = ResourceImages.Singleton.GetImage(img);

            images.Add(img, image);
            return(image);
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (Img.Length != 0)
            {
                hash ^= Img.GetHashCode();
            }
            hash ^= targets_.GetHashCode();
            return(hash);
        }
示例#19
0
 public static UserBase ToBaseModel(this ioschools.DB.user row)
 {
     return(new UserBase()
     {
         name = row.name,
         id = row.id.ToString(),
         thumbnailString = row.photo.HasValue
                                          ? Img.by_size(row.user_image.url, Imgsize.USER_THUMB).ToHtmlImage()
                                          : Img.PHOTO_NO_THUMBNAIL.ToHtmlImage(),
     });
 }
        public void Reload()
        {
            this.BeginAnimation(FrameworkElement.OpacityProperty, null);
            Img.BeginAnimation(FrameworkElement.OpacityProperty, null);
            Visibility = Visibility.Visible;
            Opacity    = 1;
            Storyboard s = (Storyboard)TryFindResource("AnimationShow");

            s.Begin();  // Start animation
            this.Opacity = 1;
        }
示例#21
0
        public bool ActualizarImagen(string UidImagen, string Ruta, string Descripcon = "")
        {
            bool   Resultado = false;
            Imagen IMG       = new Imagen()
            {
                ID = new Guid(UidImagen), STRRUTA = Ruta, STRDESCRIPCION = Descripcon
            };

            Img.ACTUALIZAIMAGEN(IMG);
            return(Resultado);
        }
示例#22
0
        /// <summary>
        ///计算影像的协方差矩阵。使用前需先计算数据集的波段数、像素数和平均值。
        /// </summary>
        /// <param name="InputImg">输入的影像对象。</param>
        /// <param name="force">是否强制计算。</param>
        /// <returns>返回操作成功或失败。</returns>
        public static bool CalcCovarianceMatrix(Img InputImg, bool force)
        {
            try
            {
                if (force)
                {
                    InputImg.IsCovarianceMatrixCalculated = false;
                }
                if (InputImg.IsCovarianceMatrixCalculated)
                {
                    throw new Exception("已计算过该影像的协方差矩阵。");
                }
                InputImg.CovarianceMatrix = new double[InputImg.BandNum, InputImg.BandNum];
                int xSize = InputImg.Width;
                int ySize = InputImg.Height;

                for (int i = 0; i < InputImg.BandNum; i++)
                {
                    for (int j = 0; j < InputImg.BandNum; j++)
                    {
                        if (i > j)  //下三角阵直接对称。
                        {
                            continue;
                        }

                        //协方差两波段的平均值。
                        double IMean = InputImg.Mean[i], JMean = InputImg.Mean[j];
                        double sum = 0.0;
                        //按行读取计算减少压力。
                        for (int Row = 0; Row < ySize; Row++)
                        {
                            double[] IValues = new double[xSize];
                            double[] JValues = new double[xSize];

                            InputImg.GDALDataset.GetRasterBand(i + 1).ReadRaster(0, Row, xSize, 1, IValues, xSize, 1, 0, 0);
                            InputImg.GDALDataset.GetRasterBand(j + 1).ReadRaster(0, Row, xSize, 1, JValues, xSize, 1, 0, 0);
                            //对每一个值进行统计累加。
                            for (int Col = 0; Col < xSize; Col++)
                            {
                                sum += (IValues[Col] - IMean) * (JValues[Col] - JMean);
                            }
                        }
                        InputImg.CovarianceMatrix[i, j] = InputImg.CovarianceMatrix[j, i] = sum / InputImg.PixelCount;
                    }
                }
                InputImg.IsCovarianceMatrixCalculated = true;
                return(true);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
                return(false);
            }
        }
 /// <summary>
 /// Disposes of the object by clearing the collection
 /// </summary>
 public void Dispose()
 {   //Make sure each image is disposed of properly
     foreach (System.Drawing.Image Img in this)
     {
         Img.Dispose();
         GC.Collect();
         GC.WaitForPendingFinalizers();
     }
     this.m_Disposed = true;
     this.Clear();
 }
示例#24
0
 public void Dispose()
 {
     if (ms != null)
     {
         ms.Dispose();
     }
     if (Img != null)
     {
         Img.Dispose();
     }
 }
示例#25
0
        /// <summary>
        /// 保存导购分类
        /// </summary>
        /// <param name="sys_user_id"></param>
        /// <param name="entity"></param>
        /// <param name="imgmsg"></param>
        /// <returns></returns>
        public StateCode Save(long sys_user_id, GuideProductCatg entity, string imgmsg)
        {
            string p_path = ServiceIoc.Get <GuideProductCatgService>().GetParentPath(entity.parent_id);

            entity.parent_path = p_path;
            using (ISession s = SessionFactory.Instance.CreateSession())
            {
                s.StartTransaction();
                try
                {
                    if (entity.id == 0)
                    {
                        //创建用户ID
                        entity.created_user_id = sys_user_id;
                        //创建时间
                        entity.created_date = DateTime.Now;
                        s.Insert(entity);
                    }
                    else
                    {
                        //修改用户ID
                        entity.updated_user_id = sys_user_id;
                        //修改时间
                        entity.updated_date = DateTime.Now;
                        s.Update(entity);
                    }

                    //判断是否存在图片信息
                    if (!string.IsNullOrEmpty(imgmsg) && imgmsg.IndexOf("#") != -1)
                    {
                        //图片名称
                        string filename = imgmsg.Split('#')[0];
                        //图片类型
                        string biztype = imgmsg.Split('#')[1];
                        //去除重复图片
                        s.ExcuteUpdate("update tb_img set biz_id = 0 where biz_type = @0 and biz_id = @1  ", biztype, entity.id);
                        Img img = s.Get <Img>(" where file_name = @0 and biz_type = @1 ", filename, biztype);
                        if (img != null)
                        {
                            img.biz_id = entity.id;
                            s.Update <Img>(img);
                        }
                    }

                    s.Commit();
                    return(StateCode.State_200);
                }
                catch
                {
                    s.RollBack();
                    return(StateCode.State_500);
                }
            }
        }
示例#26
0
        public ActionResult DeletImg(string imgName)
        {
            album thisalbum = (album)Session["thisAlbum"];
            Img   ximg      = db.Images.Where(z => z.themb == imgName).FirstOrDefault();

            thisalbum.NoOFPics        = thisalbum.NoOFPics - 1;
            db.Entry(thisalbum).State = EntityState.Modified;
            db.Images.Remove(ximg);
            db.SaveChanges();
            return(RedirectToAction("ManageAlbum", "Admin", new { Id = thisalbum.Id }));
        }
 public void Dispose()
 {
     if (Img != null)
     {
         Img.Dispose();
     }
     if (BaseStream != null)
     {
         BaseStream.Close();
     }
     _attached = false;
 }
示例#28
0
        internal TimeLinePic Pic(int Id)
        {
            Img         pics    = db.Images.Find(Id);
            TimeLinePic thispic = new TimeLinePic();

            thispic.UserName = pics.UserName;
            thispic.Thumb    = pics.themb;
            thispic.Id       = pics.Id;
            thispic.PicThumb = db.ProPics.Where(x => x.username == pics.UserName).FirstOrDefault().proimg;

            return(thispic);
        }
示例#29
0
        public bool GuardaImagen(string Ruta, string UidUsuario, string StoreProcedure, string Descripcion = "")
        {
            bool   Resultado = false;
            Imagen IMG       = new Imagen()
            {
                ID = Guid.NewGuid(), STRRUTA = Ruta, STRDESCRIPCION = Descripcion
            };

            Resultado = Img.GUARDARIMAGEN(IMG, new Guid(UidUsuario), StoreProcedure);

            return(Resultado);
        }
示例#30
0
 public static IEnumerable <Photo> ToModel(this IEnumerable <blog_image> images, Imgsize size, Imgsize fullsize = Imgsize.MAX)
 {
     foreach (var image in images)
     {
         yield return(new Photo()
         {
             id = image.id,
             url = Img.by_size(image.url, size),
             url_fullsize = Img.by_size(image.url, fullsize)
         });
     }
 }
示例#31
0
        public bool Insert(Img img)
        {
            var obj = _appDBContent.img.FirstOrDefault(x => x.path == img.path);

            if (obj != null)
            {
                return(false);
            }
            _appDBContent.img.Add(img);
            _appDBContent.SaveChanges();
            return(true);
        }
示例#32
0
        public static void RunDetection()
        {
            var net      = YOLOV3.YOLO3_Darknet53_VOC(pretrained: true);
            var im_fname = Utils.Download("https://raw.githubusercontent.com/zhreshold/mxnet-ssd/master/data/demo/dog.jpg", "objdet.jpg");

            var(x, img) = Yolo.LoadTest(im_fname, @short: 512);
            Img.ImShow(x);
            Console.WriteLine("Shape of pre-processed image:" + x.Shape);
            var(class_IDs, scores, bounding_boxs) = net.Call(x.AsType(DType.Float32));
            img = Viz.PlotBBox(img, bounding_boxs[0], scores[0], class_IDs[0], class_names: net.Classes);
            Img.ImShow(img);
        }
示例#33
0
        public void ResetImage()
        {
            Rgba32 resetColor = new Rgba32(255, 0, 255);

            for (int x = 0; x < Img.Width; x++)
            {
                for (int y = 0; y < Img.Height; y++)
                {
                    Img.GetPixelReference(x, y) = resetColor;
                }
            }
        }
示例#34
0
        public async void AddImg(string file)
        {
            if (string.IsNullOrEmpty(file)) return;
            var i = new Img(file);
            ImgQueue.Add(i);

            foreach (var img in ImgQueue)
            {
                await img.Initialize(canvas);
            }
            slideshow.CreateResources(ref canvas, ref ImgQueue);
        }
示例#35
0
        public Form1()
        {
            _5pW   = _5pL = _5pD = 0;
            p5flag = drawflag = imgflag = whsflag = true;
            this.Hide();
            this.Location = new Point(150, 150);
            //this.ShowInTaskbar = true;
            InitializeComponent();


            //Gomoku a = new Gomoku();
            //a.ShowDialog();

            this.ShowInTaskbar = true;

            trackBar1.Hide();
            ColorBox.Hide();
            button2.Hide();

            Login log = new Login();

            log.ShowDialog();
            if (log.DialogResult == DialogResult.Cancel)
            {
                this.Close();
            }
            else
            {
                this.Show();
                //this.ShowInTaskbar = true;
                SetUpData init = log.Get();
                Username = init.UserName;


                MLabel.Hide();
                //Box.ForeColor = Bcolor;
                UserBox.DataSource = UserList;
                myGraphic          = DrawBox.CreateGraphics();
                DrawBox.BringToFront();

                c.Setup(init.IP, init.Port);


                //addMsg("2.成功連線");

                msgHandler = this.addMsg;
                dwHandler  = this.addDw;
                imgHandler = this.ShowPic;
                c.Recv(processMsgComeIn, processDwComeIn, processImgComeIn);

                //MessageBox.Show("歡迎加入~");
            }
        }
示例#36
0
 /// <summary>
 /// 添加图片信息并更新图片源状态
 /// </summary>
 public async Task AddImageInfos(IList <ImageInfo> infos, Img img)
 {
     if (infos == null && infos.Count == 0)
     {
         throw new ArgumentException(nameof(infos));
     }
     foreach (var info in infos)
     {
         await _imageInfoRepository.InsertAsync(info);
     }
     await UpdateImage(img);
 }
示例#37
0
        public async Task Update(Img img, byte[] data)
        {
            Album album   = null;
            Img   entity  = null;
            Img   prevImg = null;

            if (img.Id == Guid.Empty)
            {
                album = await db.Albums.Include(x => x.Imgs).SingleAsync(x => x.Id == img.AlbumId);

                prevImg = album.Imgs.SingleOrDefault(x => x.Next == null);

                entity = new Img
                {
                    AlbumId = img.AlbumId,
                    Created = DateTime.Now
                };

                if (prevImg != null)
                {
                    entity.Prev = prevImg.Id;
                }

                entity.ImgData = new ImgData
                {
                    Bytes = data
                };

                await db.Imgs.AddAsync(entity);
            }
            else
            {
                entity = await db.Imgs.SingleAsync(x => x.Id == img.Id);
            }

            entity.Title       = img.Title;
            entity.Description = img.Description;

            await db.SaveChangesAsync();

            if (prevImg != null)
            {
                prevImg.Next = entity.Id;
                await db.SaveChangesAsync();
            }

            if (album != null && album.PreviewImg == null)
            {
                album.PreviewImg = entity.Id;
                await db.SaveChangesAsync();
            }
        }
示例#38
0
文件: link.aspx.cs 项目: joleye/1.6
        protected void btn_ServerClick(object sender, EventArgs e)
        {
            LinksDal li = new LinksDal();
            LinkInfo info = new LinkInfo();
            info.linkName = linkName.Value;
            info.linkUrl = linkUrl.Value;

            Img img = new Img();
            img.savePathName = "links";

            string delimg = pform("delimg");
            if (delimg == "1")
            {
                img.dropimg(imgUrl.Value);
                info.imgUrl = "";
            }
            else
            {
                info.imgUrl = img.saveImage(imgUrl.Value);
                if (info.imgUrl == "1")
                {
                    img.dropimg(imgUrl.Value);
                }
            }

            

            if (img.error != "")
                showMessage(img.error);

            if (id.ToString() == "0")
            {
                li.addnew(info);
                showMessage("添加成功");
            }
            else
            {
                info.id = id;
                li.edit(info);
                showMessage("修改成功");
                Response.End();
            }
            
        }
示例#39
0
    protected void btn_ServerClick(object sender, EventArgs e)
    {
        Img img = new Img();
        int id = 0;
        gnum(ref id, "id");
        img.savePathName = "adver";
        string path = img.saveImage("");
        if (img.error == "")
        {
            AdverInfo info = new AdverInfo();
            info.imgurl = path;
            info.linkurl = linkUrl.Value;

            AdverDal al = new AdverDal();
            al.edit(info,id);
            showMessage("保存成功");
        }
        else
        {
            showMessage(img.error);
        }
    }
示例#40
0
 public void AddImg(Img img)
 {
     Imgs.Add(img);
 }
示例#41
0
文件: ProductDal.cs 项目: joleye/1.6
 /// <summary>
 /// 生成小图片
 /// </summary>
 /// <param name="Id"></param>
 /// <param name="size"></param>
 /// <param name="flg"></param>
 /// <returns></returns>
 public bool set_thumbs_img(int Id, int size, string flg)
 {
     Img img = new Img();
     ProductInfo info = read(Id);
     return img.MakeThumbnail(System.Web.HttpContext.Current.Server.MapPath(info.productImgUrl),
         cimg(System.Web.HttpContext.Current.Server.MapPath(info.productImgUrl), flg), size, size, "save");
 }
示例#42
0
        //保存
        protected void Submit1_ServerClick(object sender, EventArgs e)
        {
            ProductInfo proinfo = new ProductInfo();
            
            proinfo.productName = ProductName.Value.ToString();
            proinfo.title1 = title1.Value.ToString();
            proinfo.title2 = "";//title2.Value.ToString();
            proinfo.TypeId = Int32.Parse(typeId.Text);
            proinfo.content = content.Value.ToString();
            proinfo.content1 = content1.Value.ToString();
            proinfo.content2 = content2.Value.ToString();
            proinfo.content3 = content3.Value.ToString();

            Img im = new Img();
            im.savePathName = "products";

            proinfo.productImgUrl = im.saveImage(filePath.Value);


            if (string.IsNullOrEmpty(im.error))
            {
                ProductDal dal = new ProductDal();
                if (app == "edit")
                {
                    proinfo.Id = id;
                    dal.updateProduct(proinfo);
                    editProduct(id);
                }
                else
                {
                    
                    dal.createProduct(proinfo);
                }

                showMessage("保存成功", "manage.aspx");
            }
            else
            {
                showMessage("出现了错误:"+im.error);
            }
        }
示例#43
0
文件: ArticleDal.cs 项目: joleye/1.6
 //删除图片
 public void delImg(int id)
 {
     string ds = getInfo("defaultImgUrl","Article","id =" + id);
     if (ds != "")
     {
         ds = Server.MapPath(ds);
         
         //删除相关格式图片
         Img img = new Img();
         img.dropimg(ds);
         //File.Delete(ds);
     }
 }
示例#44
0
 public static Bitmap bmp( Img img )
 {
     return _bmp[(int)img];
 }
示例#45
0
        protected void save_ServerClick(object sender, EventArgs e)
        {
            string TypeName = ProductTypeName.Value.ToString();
            string err;
            if (TypeName != "")
            {
                ProductTypeInfo info = new ProductTypeInfo();
                ProductTypeDal ad = new ProductTypeDal();

                Img img = new Img();
                img.savePathName = "producttype";
                if (action == "edit")
                {
                    string delimg = pform("delimg");

                    if (delimg == "1")
                    {
                        img.dropimg(imgUrl.Value);
                        info.imgUrl = "";
                    }
                    else
                    {
                        info.imgUrl = img.saveImage(imgUrl.Value);
                    }

                    if (img.error != "")
                        showMessage(img.error);

                    info.typeName = ProductTypeName.Value;
                    info.orderId = int.Parse(orderId.Value);
                    info.id = getId("id");
                    info.content = pform("content");

                    ad.Update(info);
                    err = "修改成功";

                }
                else
                {
                    info.typeName = TypeName;
                    info.orderId = int.Parse(orderId.Value);
                    info.imgUrl = img.saveImage("");
                    info.content = pform("content");

                    if (img.error != "")
                        showMessage(img.error);

                    int id = 0;
                    gnum(ref id, "id");

                    info.parentId = id;
                    ad.AddType(info);
                    err = "添加成功";
                }
                showMessage(err, "pro_type.aspx");
            }
            else
            {
                labelErr.Text = "<font color=red>不能为空</font>";
            }
        }
示例#46
0
文件: Perceptron.cs 项目: JFFby/MRO
        private void AcceptIMage(Img<ClassType> img)
        {
            for (int i = 0; i < img.Pixels.Count; i++)
            {
                xElements[i].Value = img.Pixels[i].Value;
            }

            var rs = xElements.Where(x => x.IsExcited).ToList();
        }
示例#47
0
文件: Perceptron.cs 项目: JFFby/MRO
 public ClassType DefineImage(Img<ClassType> img)
 {
     AcceptIMage(img);
     var resul = GetBinaruCode();
     var imgClass = DefineClass(resul);
     xElements.ForEach(x => x.Value = 0);
     return imgClass;
 }