public async void PageFresh() { var _movie_list = await APIService.Get_movie_list(); //一句话就内存溢出 //for (int j = 0; j < 20; j++) for (int i = 0; i < _movie_list.data.Count(); i++) { ImageCollection.Add(new MoviePageModel { wb = await ImageOperation.GetImage(_movie_list.data[i].cover), id = _movie_list.data[i].id, score = _movie_list.data[i].score }); } }
private RibbonStyle.RibbonMenuButton getRibbonBtn(String CTFolderPath, int numb) { ArrayList CTFileList = _dictionary[CTFolderPath]; DicomImage image = new DicomImage(Path.Combine(CTFolderPath, CTFileList[0].ToString())); image.WindowWidth = 1000; image.WindowCenter = -600; RibbonStyle.RibbonMenuButton btnTemp = new RibbonStyle.RibbonMenuButton(); // // btnTemp // btnTemp.AllowDrop = true; btnTemp.Arrow = RibbonStyle.RibbonMenuButton.e_arrow.None; btnTemp.BackColor = System.Drawing.Color.Transparent; btnTemp.ColorBase = System.Drawing.Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(4)))), ((int)(((byte)(4))))); btnTemp.ColorBaseStroke = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(153)))), ((int)(((byte)(122)))), ((int)(((byte)(122))))); btnTemp.ColorOn = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(214)))), ((int)(((byte)(78))))); btnTemp.ColorOnStroke = System.Drawing.Color.FromArgb(((int)(((byte)(196)))), ((int)(((byte)(177)))), ((int)(((byte)(118))))); btnTemp.ColorPress = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))); btnTemp.ColorPressStroke = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(64)))), ((int)(((byte)(0))))); btnTemp.FadingSpeed = 20; btnTemp.FlatAppearance.BorderSize = 0; btnTemp.FlatStyle = System.Windows.Forms.FlatStyle.Flat; btnTemp.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F); btnTemp.ForeColor = System.Drawing.Color.DarkBlue; btnTemp.GroupPos = RibbonStyle.RibbonMenuButton.e_groupPos.None; //btnTemp.Image = global::LungCare.Airway.WinformUIControls.Properties.Resources.Quit; btnTemp.Image = (Bitmap)ImageOperation.CloneImage(image.RenderImage()); btnTemp.ImageLocation = RibbonStyle.RibbonMenuButton.e_imagelocation.Top; btnTemp.ImageOffset = 5; btnTemp.IsPressed = false; btnTemp.KeepPress = false; btnTemp.MaxImageSize = new System.Drawing.Point(0, 0); btnTemp.MenuPos = new System.Drawing.Point(0, 0); btnTemp.Name = numb.ToString(); btnTemp.Radius = 8; btnTemp.ShowBase = RibbonStyle.RibbonMenuButton.e_showbase.Yes; btnTemp.Size = new System.Drawing.Size(150, 150); btnTemp.SplitButton = RibbonStyle.RibbonMenuButton.e_splitbutton.No; btnTemp.SplitDistance = 0; btnTemp.TabIndex = 95; btnTemp.Title = ""; btnTemp.UseVisualStyleBackColor = true; btnTemp.Click += btnTemp_Click; return(btnTemp); }
/// <summary> /// 初始化 CharmTextBox 类的新实例 /// </summary> public CharmTextBox() : base() { // * 初始化属性 * Size = new Size(160, 26); BackColor = Color.White; mStatusImages = new Image[2]; mStatusImages[0] = Resources.textbox_bkg_normal; // 去除常态背景空白部分 mStatusImages[0] = ImageOperation.GetPartOfImage(mStatusImages[0], mStatusImages[0].Width, mStatusImages[0].Height - 2, 0, 1); mStatusImages[1] = Resources.textbox_bkg_hover; // 重新设置文本框大小 mStatusImages[0] = ImageOperation.ResizeImageWithoutBorder(mStatusImages[0], 2, 1, 2, 1, base.Size); mStatusImages[1] = ImageOperation.ResizeImageWithoutBorder(mStatusImages[1], 2, 2, 2, 2, base.Size); // * 文本框外观样式设置 * mTextbox = new TextBox(); mTextbox.BorderStyle = BorderStyle.None; // 无边框 mTextbox.Font = new Font("微软雅黑", 9.75F); // 字体 mTextbox.Size = new Size(156, 20); // 大小 mTextbox.Location = new Point(2, (Height - mTextbox.Height) / 2); // 位置 mTextbox.ImeMode = ImeMode.NoControl; // 输入法设置 // 设置水印 if (mWatermark != null) { mTextbox.ForeColor = Color.DarkGray; mTextbox.Text = mWatermark; } // * 控件属性设置 * mInputMode = InputMode.Normal; // 输入模式 // * 关联控件事件 * mTextbox.MouseEnter += new EventHandler(TextBox_MouseEnter); mTextbox.MouseLeave += new EventHandler(TextBox_MouseLeave); mTextbox.KeyPress += new KeyPressEventHandler(TextBox_KeyPress); mTextbox.LostFocus += new EventHandler(TextBox_LostFocus); mTextbox.GotFocus += new EventHandler(TextBox_GotFocus); mTextbox.DoubleClick += new EventHandler(mTextbox_DoubleClick); mTextbox.TextChanged += new EventHandler(mTextbox_TextChanged); // * 加载控件到控件集合中 * Controls.Add(mTextbox); }
private async void FreshPage() { var _movie_story = await APIService.Get_movie_story(movieId); InfoTextBlock.Text = _movie_story.data.data.Count().ToString(); for (int i = 0; i < _movie_story.data.data.Count(); i++) { movieStoryPageData.Add(new MovieStoryPageModel { userName = _movie_story.data.data[i].user.user_name, userImage = await ImageOperation.GetImage(_movie_story.data.data[i].user.web_url), makeTime = _movie_story.data.data[i].input_date, praiseNum = _movie_story.data.data[i].praisenum.ToString(), title = _movie_story.data.data[i].title, content = _movie_story.data.data[i].content }); } }
private void dgvHasRowNumDetl_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { dgvHasRowNum num = (dgvHasRowNum)sender; if (e.RowIndex < 0) { return; } if (num.Rows[e.RowIndex].Cells[e.ColumnIndex].ValueType == typeof(byte[])) { string tag = ImageOperation.CrateImageFileByBytes((byte[])num.Rows[e.RowIndex].Cells[e.ColumnIndex].Value); if (tag != null) { new frmPreviewImage(tag) { MdiParent = base.ParentForm.MdiParent }.Show(); } } }
/// <summary> /// 抓取HomePage图片 /// </summary> public void HtmlImageCapture() { string url = System.Web.HttpContext.Current.Request.Url.AbsoluteUri; //AbsoluteUri = "http://localhost:58321/Journal/StaticHtml" int start = url.IndexOf("//"); int end = url.IndexOf("/", start + 2); string urlHead = url.Substring(0, end + 1); //返回的页面截屏二进制对象 Bitmap m_Bitmap = WebSiteThumbnail.GetWebSiteThumbnail(urlHead, 800, 960, 800, 960); //http://localhost:58321/ //m_Bitmap.Save("D:/XXX/" + "text.png", System.Drawing.Imaging.ImageFormat.Png); string outputDir = HttpContext.Server.MapPath(ConfigurationManager.AppSettings["HtmlOutput"]) + "\\" + currentJournalEntity.JournalName + "\\mail\\images\\"; if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } string targetFilePath = outputDir + "index.jpg"; //在这个页面上再绘制banner图片 using (Graphics gp = Graphics.FromImage(m_Bitmap)) { string bannerImg = HttpContext.Server.MapPath("~") + "\\images\\banner_4.jpg"; //banner_1~4.jpg 可以定期更换 gp.DrawImage(Image.FromFile(bannerImg), 47, 131, 702, 184); //必须设置比例,否则会失真 } using (FileStream fs = new FileStream(targetFilePath, FileMode.Create)) { ImageCodecInfo imageCodeInfo = ImageOperation.GetEncoderInfo("image/jpeg"); System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality; EncoderParameters myEncoderParameters = new EncoderParameters(1); myEncoderParameters.Param[0] = new EncoderParameter(myEncoder, 85L); m_Bitmap.Save(fs, imageCodeInfo, myEncoderParameters); } //MemoryStream ms = new MemoryStream(); //m_Bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);//JPG、GIF、PNG等均可 //byte[] buff = ms.ToArray(); //Response.BinaryWrite(buff); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { string hpId = (string)e.Parameter; if (!string.IsNullOrEmpty(hpId)) { homePageData.Clear(); var hp_detail = await APIService.Get_hp_detail(hpId); homePageData.Add( new HomePageModel { writeableBitmap = await ImageOperation.GetImage(hp_detail.data.hp_img_url), author = hp_detail.data.hp_author, date = hp_detail.data.hp_makettime, content = hp_detail.data.hp_content } ); } else { PageFresh(); } }
public async void PageFresh(string movieId) { var _movie_detail = await APIService.Get_movie_detail(movieId); movieDetailPageViewModel.video = _movie_detail.data.video; movieDetailPageViewModel.title = _movie_detail.data.title; movieDetailPageViewModel.keywords = _movie_detail.data.keywords; movieDetailPageViewModel.info = _movie_detail.data.info; movieDetailPageViewModel.detailcover = await ImageOperation.GetImage(_movie_detail.data.detailcover); for (int i = 0; i < _movie_detail.data.photo.Count(); i++) { slide.Add(new MovieDetailPageSlideModel { slide = await ImageOperation.GetImage(_movie_detail.data.photo[i]) }); } var _movie_story = await APIService.Get_movie_story(movieId); movieDetailPageViewModel.story_web_url = await ImageOperation.GetImage(_movie_story.data.data[0].user.web_url); movieDetailPageViewModel.story_input_date = _movie_story.data.data[0].input_date; movieDetailPageViewModel.story_user_name = _movie_story.data.data[0].user.user_name; movieDetailPageViewModel.story_content = _movie_story.data.data[0].content; }
/// <summary> /// 显示一个消息框,该消息框包含消息、标题栏标题、按钮和图标,并接受默认消息框结果和返回结果 /// </summary> /// <param name="messageBoxText">一个 String,用于指定要显示的文本</param> /// <param name="caption">一个 String,用于指定要显示的标题栏标题</param> /// <param name="button">一个 MessageBoxButton 值,用于指定要显示哪个按钮或哪些按钮</param> /// <param name="icon">一个 CharmMessageBoxIcon 值,用于指定要显示的图标</param> /// <param name="defaultResult">一个 DialogResult 值,用于指定消息框的默认结果</param> /// <returns>一个 DialogResult 值,用于指定用户单击了哪个消息框按钮</returns> public DialogResult Show( string messageBoxText, string caption, MessageBoxButtons button, CharmMessageBoxIcon icon, DialogResult defaultResult) { #region 旧版的文本换行写法 //using (Graphics g = Graphics.FromImage(base.BackgroundImage)) //{ // byte[] data = Encoding.Default.GetBytes(text); // int index = 0; // byte[] cache; // int minLength; // while (data.Length >= (index + 1) * _textWidth) // { // cache = new byte[_textWidth]; // minLength = data.Length > (index + 1) * _textWidth ? (index + 1) * _textWidth : data.Length - 1; // for (int i = index * _textWidth; i < minLength; i++) // { // cache[i - index * _textWidth] = data[i]; // } // g.DrawString(Encoding.Default.GetString(cache), new Font("微软雅黑", 12), Brushes.Black, // new Point(_textPoint.X, _textPoint.Y + index * 15)); // index++; // } // cache = new byte[_textWidth]; // minLength = data.Length > (index + 1) * _textWidth ? (index + 1) * _textWidth : data.Length - 1; // for (int i = index * _textWidth; i <= minLength; i++) // { // cache[i - index * _textWidth] = data[i]; // } // g.DrawString(Encoding.Default.GetString(cache), new Font("微软雅黑", 12), Brushes.Black, // new Point(_textPoint.X, _textPoint.Y + index * 15)); //} #endregion // 计算需要绘制的文本高度 Graphics g = CreateGraphics(); SizeF sf = g.MeasureString(messageBoxText, new Font("微软雅黑", 9), Width - 90); // 修改窗体高度 Height = (int)sf.Height + 120; // 根据消息框类型设置背景图像资源并修改尺寸 switch (MessageBoxType) { case MessageBoxType.BlueSky: BackgroundImage = Resources.messagebox_bluesky; BackgroundImage = ImageOperation.ResizeImageWithoutBorder(BackgroundImage, 2, 30, 2, 2, Size); break; case MessageBoxType.Customize: if (mCustomizeBackgourndImage == null) // 检查用户是否完成对消息框的初始化 { throw new ArgumentNullException( "CharmControlLibrary.CharmMessageBox:未指定自定义消息框类型的背景图像资源.\n" + "Name: " + Name); } BackgroundImage = new Bitmap(mCustomizeBackgourndImage, Size); break; } using (g = Graphics.FromImage(BackgroundImage)) { // 绘制标题栏文本 g.DrawString(caption, new Font("微软雅黑", 10, FontStyle.Bold), new SolidBrush(mTitleColor), new Point(8, 6)); // 绘制消息框图标 switch (icon) { case CharmMessageBoxIcon.None: break; case CharmMessageBoxIcon.Question: g.DrawImage(Resources.messageboxicon_question, new Rectangle(new Point(27, (int)sf.Height / 2 + 50), Resources.messageboxicon_question.Size)); break; case CharmMessageBoxIcon.Error: g.DrawImage(Resources.messageboxicon_error, new Rectangle(new Point(27, (int)sf.Height / 2 + 50), Resources.messageboxicon_error.Size)); break; case CharmMessageBoxIcon.Infomation: g.DrawImage(Resources.messageboxicon_info, new Rectangle(new Point(27, (int)sf.Height / 2 + 50), Resources.messageboxicon_info.Size)); break; case CharmMessageBoxIcon.Ok: g.DrawImage(Resources.messageboxicon_ok, new Rectangle(new Point(27, (int)sf.Height / 2 + 50), Resources.messageboxicon_ok.Size)); break; case CharmMessageBoxIcon.Warning: g.DrawImage(Resources.messageboxicon_warning, new Rectangle(new Point(27, (int)sf.Height / 2 + 50), Resources.messageboxicon_warning.Size)); break; } // 绘制消息文本 RectangleF rf = new RectangleF(75, 60, sf.Width, sf.Height); g.DrawString(messageBoxText, new Font("微软雅黑", 9), new SolidBrush(mTextColor), rf); } // 设置按钮类型及坐标 mButtonType = button; CharmControls[0].Location = new Point(89, (int)sf.Height + 85); CharmControls[1].Location = new Point(178, (int)sf.Height + 85); CharmControls[2].Location = new Point(265, (int)sf.Height + 85); // 设置检查框坐标 CharmControls[3].Location = new Point(30, (int)sf.Height + 84); // 显示消息框 ShowDialog(); return(mDialogResult); }
// 窗体可见性改变事件,用于重新设置窗体属性 private void CharmMenu_VisibleChanged(object sender, EventArgs e) { // 判断窗体是否变为可见 if (Visible) { // 窗体长度及宽度 int formWidth = 0; int formHeight = 0; // 根据菜单项数组长度决定窗体属性 Graphics g = CreateGraphics(); SizeF sf; MenuItem menuItem; // 轮询每个菜单项,确定窗体需要的长度和宽度 for (int i = 0; i < mItems.Count; i++) { menuItem = mItems[i]; // 判断菜单项类型 if (menuItem.MenuItemType == MenuItemType.Spliter) { // 判断当前菜单类型是否支持分割线 if (mMenuType != MenuType.QQ) { throw new ArgumentException( "CharmControlLibrary.CharmMenu:当前菜单类型不支持分割线.\n" + "Name: " + Name); } formHeight += 3; // 分割线 } else { // 文本项 formHeight += 22; // 计算绘制文本所需的像素 sf = g.MeasureString(menuItem.Text, Font); // 判断当前项文本所需像素是否大于之前项 if ((int)sf.Width > formWidth) { formWidth = (int)sf.Width; } } } Bitmap imgTemp = null; // 设置窗体长度及宽度 Width = formWidth + 28 + 18; Height = formHeight + 4; // 根据菜单类型设置窗体背景 switch (mMenuType) { case MenuType.QQ: imgTemp = new Bitmap(Resources.menu_bkg_qq); imgTemp = ImageOperation.ResizeImageWithoutBorder( imgTemp, 29, 2, 2, 2, new Size(Width, Height)); break; case MenuType.QQSoftMgr: imgTemp = new Bitmap(Resources.menu_bkg_qqsoftmgr); imgTemp = ImageOperation.ResizeImageWithoutBorder( imgTemp, 29, 2, 2, 2, new Size(Width, Height)); break; } BackgroundImage = new Bitmap(imgTemp); // 释放系统资源 g.Dispose(); imgTemp.Dispose(); // 设置窗体显示的位置 Rectangle rect = Screen.GetWorkingArea(this); // 判断是否有足够空间在光标右侧弹出菜单 if ((rect.Width - MousePosition.X) > Width) { Left = MousePosition.X; // 有足够空间 } else { Left = MousePosition.X - Width; // 没有足够空间 } // 判断是否有足够空间在光标下方弹出菜单 if ((rect.Height - MousePosition.Y) > Height) { Top = MousePosition.Y; // 有足够空间 } else { Top = MousePosition.Y - Height; // 没有足够空间 } } }
public void Update(ImageOperation updated) { throw new NotImplementedException(); }
public void Insert(ImageOperation inserted) { throw new NotImplementedException(); }
public void Delete(ImageOperation deleted) { throw new NotImplementedException(); }
private async Task <EditedImage> AttachEditedImage(MemoryStream stream, Domain.Image image, ImageOperation operation, int width, int height) { var physicalFile = await new StoreFileDto { File = stream, Filename = image.Filename }.CreatePhysicalFile(); var editedImage = new EditedImage { Width = width, Height = height, ImageId = image.Id, Operation = operation, Path = physicalFile.Path, }; context.Add(editedImage); await context.SaveChangesAsync(); return(editedImage); }