public void AddScrap(ScrapBaseInfo pInfo, bool pIsFirstInit = false) { ScrapBase newScrap = new ScrapBase(); newScrap.addScrapStyleEvent(this._mainform); newScrap.addScrapMenuEvent(this._mainform); if (!string.IsNullOrEmpty(pInfo.name)) { newScrap.Name = pInfo.name; } newScrap.Image = pInfo.image; newScrap.cacheInfo = pInfo; newScrap.SetBounds(0, 0, pInfo.imageWidth, pInfo.imageHeight, BoundsSpecified.All); var style = this._mainform.optSetuna.FindStyle(pInfo.styleID); if (style != null) { newScrap.isFirstInitCompactScrap = pIsFirstInit; style.Apply(ref newScrap, pInfo.stylePoint); } newScrap.Left = pInfo.posX; newScrap.Top = pInfo.posY; newScrap.Refresh(); newScrap.Show(); if (!pIsFirstInit) { newScrap.ApplyCache(); } this.AddScrap(newScrap, pInfo); }
public void AddScrap(ScrapBase newScrap, ScrapBaseInfo pInfo = null) { newScrap.cacheInfo = pInfo ?? new ScrapBaseInfo(newScrap.Image, newScrap.Left, newScrap.Top, newScrap.Width, newScrap.Height, System.DateTime.Now.Ticks.ToString()); newScrap.Manager = this; this._scraps.Add(newScrap); newScrap.OnScrapCreated(); if (this.ScrapAdded != null) { this.ScrapAdded(this, new ScrapEventArgs(newScrap)); } }
static public void DeleteCacheInfo(ScrapBaseInfo pInfo) { try { var tPath = pInfo.GetFullName(); if (File.Exists(tPath)) { File.Delete(tPath); } MyConsole.WriteLine("删除图片成功. {0}", pInfo.ToString()); } catch (Exception ex) { MyConsole.WriteLine("删除图片失败. {0}\n{1|", pInfo.ToString(), ex.ToString()); } }
static public void SaveCacheInfo(ScrapBaseInfo pInfo) { if (pInfo == null || pInfo.image == null) { return; } try { Serialize(pInfo, pInfo.GetFullName()); MyConsole.WriteLine("缓存图片成功. {0}", pInfo.ToString()); } catch (Exception ex) { MyConsole.WriteLine("缓存图片失败. {0}\n{1}", pInfo.ToString(), ex.ToString()); } }