123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605 |
- using OpenCvSharp;
- using Resources;
- using SmartCoalApplication.Annotation;
- using SmartCoalApplication.Annotation.FieldView;
- using SmartCoalApplication.Base.CommTool;
- using SmartCoalApplication.Base.FunctionModel;
- using SmartCoalApplication.Core;
- using SmartCoalApplication.Core.CustomControl;
- using SmartCoalApplication.Core.Param;
- using SmartCoalApplication.ParameterSet;
- using SmartCoalApplication.Resources;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using static SmartCoalApplication.AutomaticMeasurement.ImageTools;
- namespace SmartCoalApplication.AutomaticMeasurement
- {
- internal partial class ResultsViewRange : PdnBaseForm
- {
- /// <summary>
- /// 分析设置存储信息
- /// </summary>
- protected AnalyzeSettingModel analyzeSettingModel = new AnalyzeSettingModel();
- /// <summary>
- /// 图片名称对应关系
- /// </summary>
- Dictionary<string, string> pNames = new Dictionary<string, string>();
- private List<Bitmap> pictures = new List<Bitmap>();
- private List<Bitmap> originalPictures = new List<Bitmap>();
- private List<Bitmap> oldOriginalPictures = new List<Bitmap>();
- private List<string> pictureNames = new List<string>();
- private int index = new int();
- private AppWorkspace appWorkspace;
- private CommonControlButtons commonControlButtons;
- private Bitmap bitmap;
- /// <summary>
- /// hint 提示信息
- /// </summary>
- public ToolTip toolTip;
- /// <summary>
- /// 图像面板
- /// </summary>
- private DocumentWorkspaceWindow documentWorkspace;
- /// <summary>
- /// 图像面板
- /// </summary>
- private ResultsView resultsView;
- private Dictionary<int, GraphicsList> dataList = new Dictionary<int, GraphicsList>();
- private int selectedIndex = -1;
- /// <summary>
- /// 播放模式 1 从后播放 2 从前往后播
- /// </summary>
- private int playType = 2;
- /// <summary>
- /// 播放模式 是否循环播放
- /// </summary>
- private bool isLoop = false;
- /// <summary>
- /// 播放还是暂停
- /// </summary>
- private bool isPlay = false;
- public List<Bitmap> BitmapArray = new List<Bitmap>();
- public int OverlapWidth { get; set; }
- public int OverlapHeight { get; set; }
- private bool isNormal = false;
- private AutomaticMeasurementModel automaticMeasurement;
- private bool startSpin = false;
- private System.Drawing.PointF startPoint;
- private System.Drawing.PointF endPoint;
- Dictionary<int, List<bool>> boolList = new Dictionary<int, List<bool>>();
- private Dictionary<int, bool> dataBoolList = new Dictionary<int, bool>();
- private Dictionary<int, bool> dataFanweibuchangList = new Dictionary<int, bool>();
- private Dictionary<int, bool> dataErzhichuliList = new Dictionary<int, bool>();
- private Dictionary<int, bool> needShowDaoDianbu = new Dictionary<int, bool>();
- private Dictionary<int, bool> needShowFanweibuchang = new Dictionary<int, bool>();
- private Dictionary<int, bool> needShowErzhichuli = new Dictionary<int, bool>();
- Dictionary<int, int> correspondNum = new Dictionary<int, int>();
- private double hasAngle = 0;
- public ResultsViewRange(List<Bitmap> pictures, List<string> pictureNames, ResultsView resultsView, AppWorkspace appWorkspace, Dictionary<int, GraphicsList> GraphicsList, Dictionary<int, bool> boolList, Dictionary<int, bool> needShowDaoDianbu,
- Dictionary<int, bool> isFanweibuchangList, Dictionary<int, bool> needShowFanweibuchang, Dictionary<int, bool> isErzhichuliList, Dictionary<int, bool> needShowErzhichuli, Dictionary<int, int> correspondNum)
- {
- this.pictures = pictures;
- this.originalPictures.AddRange(pictures);
- this.oldOriginalPictures.AddRange(pictures);
- this.pictureNames = pictureNames;
- InitializeComponent();
- InitializeComponent2();
- #region [播放按钮初始化]
- //
- // 从后往前播放
- //
- this.button1.Image = PdnResources.GetImageResource("Icons.MultiFromAfterPlayIcon.png").Reference;
- this.button1.FlatStyle = FlatStyle.Flat;
- this.button1.FlatAppearance.BorderSize = 0;
- //
- // 从前往后播放
- //
- this.button2.Image = PdnResources.GetImageResource("Icons.MultiFromBehindPlayIcon.png").Reference;
- this.button2.FlatStyle = FlatStyle.Flat;
- this.button2.FlatAppearance.BorderSize = 0;
- this.button2.BackColor = Color.DarkGray;
- //
- // 循环播放
- //
- this.button3.Image = PdnResources.GetImageResource("Icons.MultiCirclePlayIcon.png").Reference;
- this.button3.FlatStyle = FlatStyle.Flat;
- this.button3.FlatAppearance.BorderSize = 0;
- //
- // 播放(暂停) 备注:这里需要判断显示播放/暂停
- //
- this.button4.Image = PdnResources.GetImageResource("Icons.MultiNowPlayIcon.png").Reference;
- this.button4.FlatStyle = FlatStyle.Flat;
- this.button4.FlatAppearance.BorderSize = 0;
- this.toolTip = new ToolTip();
- this.toolTip.SetToolTip(this.button1, PdnResources.GetString("Menu.Playitbackwards.text"));
- this.toolTip.SetToolTip(this.button2, PdnResources.GetString("Menu.Playbackandforth.text"));
- this.toolTip.SetToolTip(this.button3, PdnResources.GetString("Menu.Loopfor.text"));
- this.toolTip.SetToolTip(this.button4, PdnResources.GetString("Menu.Playpause.text"));
- #endregion
- this.Icon = PdnInfo.AppIcon;
- this.appWorkspace = appWorkspace;
- this.dataList = GraphicsList;
- this.dataBoolList = boolList;
- this.dataFanweibuchangList = isFanweibuchangList;
- this.dataErzhichuliList = isErzhichuliList;
- this.resultsView = resultsView;
- #region [图像面板相关]
- //
- //初始化图像控件
- //
- this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
- this.documentWorkspace.Cursor = Cursors.Default;
- this.documentWorkspace.Dock = DockStyle.Fill;
- this.documentWorkspace.HookMouseEvents();
- this.documentWorkspace.Visible = true;
- //this.documentWorkspace.panel.Click += new EventHandler(this.documentWorkspace_panel_Click);
- this.documentWorkspace.panel.MouseDown += new MouseEventHandler(this.documentWorkspace_panel_MouseDown);
- this.documentWorkspace.panel.MouseMove += new MouseEventHandler(this.documentWorkspace_panel_MouseMove);
- this.documentWorkspace.panel.MouseUp += new MouseEventHandler(this.documentWorkspace_panel_MouseUp);
- PdnBaseForm.RegisterFormHotKey(Keys.Delete, OnDeleteHotKeyPressed);
- PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Delete, OneDataOnDeleteHotKeyPressed);
- this.documentWorkspace.keepDraw = false;
- PdnBaseForm.RegisterFormHotKey(Keys.Left, lastPicture);
- PdnBaseForm.RegisterFormHotKey(Keys.Up, lastPicture);
- PdnBaseForm.RegisterFormHotKey(Keys.Down, nextPicture);
- PdnBaseForm.RegisterFormHotKey(Keys.Right, nextPicture);
- this.groupBoxZhangshu.Controls.Add(this.documentWorkspace);
- #endregion
- this.commonControlButtons = new CommonControlButtons();
- this.commonControlButtons.Dock = DockStyle.Top;
- this.commonControlButtons.Height = 30;
- this.commonControlButtons.HideZoomToWindowAndActualSize();
- this.needShowDaoDianbu = needShowDaoDianbu;
- this.needShowFanweibuchang = needShowFanweibuchang;
- this.needShowErzhichuli = needShowErzhichuli;
- this.correspondNum = correspondNum;
- if (this.needShowDaoDianbu.First().Value)
- {
- this.commonControlButtons.ShowCheckBox();
- if (dataBoolList.Count > 0)
- {
- this.commonControlButtons.isModeCheckBox.Checked = dataBoolList.First().Value;
- }
- }
- if (this.needShowFanweibuchang.First().Value)
- {
- this.commonControlButtons.ShowIsFanweibuchang();
- if (dataFanweibuchangList.Count > 0)
- {
- this.commonControlButtons.isModeCheckBox.Checked = dataFanweibuchangList.First().Value;
- }
- }
- if (this.needShowErzhichuli.First().Value)
- {
- this.commonControlButtons.ShowIsErzhichuli();
- if (dataErzhichuliList.Count > 0)
- {
- this.commonControlButtons.isModeCheckBox.Checked = dataErzhichuliList.First().Value;
- }
- }
- this.groupBoxZhangshu.Controls.Add(commonControlButtons);
- InitCommonButtonEvent();
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.ViewRectangle;
- //this.documentWorkspace.SetContinuousDrawingVoid(true);
- this.PlotTheMeasurementRange_Load();
- #region [播放事件初始化]
- this.triangleTrackBar1.Value = 1;
- this.triangleTrackBar1.Maximum = this.listPictureName.Items.Count;
- this.textBox1.Text = $"{this.listPictureName.SelectedIndex + 1}/{this.triangleTrackBar1.Maximum}";
- #endregion
- #region [默认叠加]
- this.button6_Click(null, null);
- #endregion
- this.getLastData();
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
- }
- private void InitializeComponent2()
- {
- this.Text = PdnResources.GetString("NewDrawMeasurementRange");
- this.button7.Text = PdnResources.GetString("ResultViewRange.button7");
- this.groupBox1.Text = PdnResources.GetString("NewOperation");
- this.checkBox1.Text = PdnResources.GetString("NewPauseDrawing");
- this.buttonOKDraw.Text = PdnResources.GetString("NewMakeSureDraw");
- this.groupBox2.Text = PdnResources.GetString("NewPictureList");
- this.button6.Text = PdnResources.GetString("NewSuperposition");
- this.button5.Text = PdnResources.GetString("NewNormal");
- this.label1.Text = PdnResources.GetString("NewTransparency") + ":";
- this.groupBoxZhangshu.Text = PdnResources.GetString("NewTheFirstNne");
- }
- #region [参数保存]
- /// <summary>
- /// 获取上次操作参数
- /// </summary>
- private void getLastData()
- {
- string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\AutomaticMeasurement.xml";
- if (!System.IO.File.Exists(filePath))
- {
- automaticMeasurement = new AutomaticMeasurementModel();
- automaticMeasurement.PlotTheMeasurementRangeModels = new PlotTheMeasurementRangeModel();
- string porosityInfoXml = XmlSerializeHelper.XmlSerialize<AutomaticMeasurementModel>(automaticMeasurement);
- Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
- FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
- }
- else
- {
- automaticMeasurement = XmlSerializeHelper.DESerializer<AutomaticMeasurementModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- if (automaticMeasurement.PlotTheMeasurementRangeModels == null)
- {
- automaticMeasurement.PlotTheMeasurementRangeModels = new PlotTheMeasurementRangeModel();
- }
- if (automaticMeasurement.PlotTheMeasurementRangeModels.hasUsed)
- {
- checkBox1.Checked = automaticMeasurement.PlotTheMeasurementRangeModels.parameter1;
- textBox2.Text = automaticMeasurement.PlotTheMeasurementRangeModels.parameter2.ToString();
- this.timer1.Interval = automaticMeasurement.PlotTheMeasurementRangeModels.parameter2;
- }
- }
- }
- /// <summary>
- /// 保存上次操作参数
- /// </summary>
- private void saveLastData(object sender, EventArgs e)
- {
- if (automaticMeasurement.PlotTheMeasurementRangeModels == null)
- {
- automaticMeasurement.PlotTheMeasurementRangeModels = new PlotTheMeasurementRangeModel();
- }
- int Interval = 1000;
- try
- {
- Interval = Convert.ToInt32(textBox2.Text);
- }
- catch (Exception)
- {
- }
- automaticMeasurement.PlotTheMeasurementRangeModels.hasUsed = true;
- automaticMeasurement.PlotTheMeasurementRangeModels.parameter1 = checkBox1.Checked;
- automaticMeasurement.PlotTheMeasurementRangeModels.parameter2 = Interval;
- string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\AutomaticMeasurement.xml";
- string porosityInfoXml = XmlSerializeHelper.XmlSerialize<AutomaticMeasurementModel>(automaticMeasurement);
- FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
- this.timer1.Stop();
- #region [清空内存]
- originalPictures.Clear();
- oldOriginalPictures.Clear();
- pictures.Clear();
- BitmapArray.Clear();
- GC.Collect();
- #endregion
- }
- #endregion
- private bool lastPicture(Keys keys)
- {
- if (this.listPictureName.SelectedIndex == 0)
- {
- this.listPictureName.SelectedIndex = this.listPictureName.Items.Count - 1;
- }
- else
- {
- this.listPictureName.SelectedIndex -= 1;
- }
- return true;
- }
- private bool nextPicture(Keys keys)
- {
- if (this.listPictureName.SelectedIndex == this.listPictureName.Items.Count - 1)
- {
- this.listPictureName.SelectedIndex = 0;
- }
- else
- {
- this.listPictureName.SelectedIndex += 1;
- }
- return true;
- }
- private void documentWorkspace_panel_MouseMove(object sender, MouseEventArgs e)
- {
- if (this.startSpin)
- {
- return;
- }
- }
- private bool OneDataOnDeleteHotKeyPressed(Keys keys)
- {
- if (this.listPictureName.SelectedItem != null)
- {
- this.documentWorkspace.GraphicsList.Clear();
- int duiyingIndex = -1;
- if (this.correspondNum.ContainsKey(this.listPictureName.SelectedIndex))
- {
- duiyingIndex = this.correspondNum[this.listPictureName.SelectedIndex];
- }
- if (this.dataList.ContainsKey(duiyingIndex))
- {
- this.dataList[duiyingIndex].Clear();
- }
- this.documentWorkspace.Refresh();
- }
- return true;
- }
- private bool OnDeleteHotKeyPressed(Keys keys)
- {
- this.documentWorkspace.GraphicsList.Clear();
- foreach (var item in dataList)
- {
- item.Value.Clear();
- }
- this.documentWorkspace.Refresh();
- if (this.startSpin)
- {
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.DrawLine;
- }
- else
- {
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.ViewRectangle;
- }
- return true;
- }
- // TODO:BUG
- private void documentWorkspace_panel_MouseUp(object sender, MouseEventArgs e)
- {
- #region [旋转]
- if (this.startSpin)
- {
- if (e.Button == MouseButtons.Left)
- {
- double angle = 0;
- int removeIndex = -1;
- for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
- {
- if (this.documentWorkspace.GraphicsList[i].objectType != Annotation.Enum.DrawClass.Label)
- {
- continue;
- }
- if (this.documentWorkspace.GraphicsList[i].startPoint.X <= this.documentWorkspace.GraphicsList[i].endPoint.X)
- {
- this.startPoint = this.documentWorkspace.GraphicsList[i].startPoint;
- this.endPoint = this.documentWorkspace.GraphicsList[i].endPoint;
- }
- else
- {
- this.startPoint = this.documentWorkspace.GraphicsList[i].endPoint;
- this.endPoint = this.documentWorkspace.GraphicsList[i].startPoint;
- }
- angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y));
- removeIndex = i;
- }
- angle = 0 - angle + this.hasAngle;
- this.hasAngle = angle;
- ParamObject action = new Data.Action.Action5017();
- for (int i = 0; i < action.Lists.Count; i++)
- {
- if (action.Lists[i] is DecimalNumber)
- {
- action.Lists[i].value = angle;
- }
- }
- Bitmap bitmap = (Bitmap)this.oldOriginalPictures[this.selectedIndex].Clone();
- Mat mat = action.PerformProcess(OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap));
- Bitmap newbitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat);
- pictures[this.selectedIndex] = newbitmap;
- this.originalPictures[this.selectedIndex] = newbitmap;
- if (removeIndex != -1)
- {
- this.documentWorkspace.GraphicsList.RemoveAt(removeIndex);
- this.documentWorkspace.Refresh();
- }
- #region [清空内存]
- if (bitmap != null)
- {
- bitmap.Dispose();
- }
- //if (newbitmap != null)
- //{
- // newbitmap.Dispose();
- //}
- //if (mat != null)
- //{
- // mat.Dispose();
- //}
- #endregion
- }
- else if (e.Button == MouseButtons.Right)
- {
- pictures[this.selectedIndex] = this.oldOriginalPictures[this.selectedIndex];
- this.originalPictures[this.selectedIndex] = this.oldOriginalPictures[this.selectedIndex];
- this.hasAngle = 0;
- }
- this.bitmap = pictures[this.selectedIndex];
- Document document = Document.FromImage(this.bitmap);
- this.documentWorkspace.Document = document;
- this.documentWorkspace.Visible = true;
- return;
- }
- #endregion
- GraphicsList graphicsList = new GraphicsList();
- int removeData = -1;
- for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
- {
- if (this.documentWorkspace.GraphicsList[i].Width <= 100 && this.documentWorkspace.GraphicsList[i].Height <= 100)
- {
- removeData = i;
- continue;
- }
- graphicsList.Add(this.documentWorkspace.GraphicsList[i].Clone(this.documentWorkspace));
- }
- if (removeData != -1)
- {
- this.documentWorkspace.GraphicsList.RemoveAt(removeData);
- this.documentWorkspace.SetContinuousDrawingVoid(true);
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.ViewRectangle;
- this.documentWorkspace.Refresh();
- return;
- }
- if (e.Button == MouseButtons.Left)
- {
- for (int i = 0; i < this.listPictureName.Items.Count; i++)
- {
- int duiyingIndex = -1;
- if (this.correspondNum.ContainsKey(i))
- {
- duiyingIndex = this.correspondNum[i];
- }
- if (this.dataList.ContainsKey(duiyingIndex))
- {
- this.dataList[duiyingIndex] = graphicsList;
- }
- else
- {
- this.dataList.Add(duiyingIndex, graphicsList);
- }
- }
- }
- else if (e.Button == MouseButtons.Right)
- {
- if (this.listPictureName.SelectedItem != null)
- {
- int duiyingIndex = -1;
- if (this.correspondNum.ContainsKey(this.listPictureName.SelectedIndex))
- {
- duiyingIndex = this.correspondNum[this.listPictureName.SelectedIndex];
- }
- if (this.dataList.ContainsKey(duiyingIndex))
- {
- this.dataList[duiyingIndex] = graphicsList;
- }
- else
- {
- this.dataList.Add(duiyingIndex, graphicsList);
- }
- }
- if (isPlay)
- {
- timer1.Start();
- }
- }
- if (this.checkBox1.Checked)
- {
- if (isPlay)
- {
- timer1.Start();
- }
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void documentWorkspace_panel_MouseDown(object sender, MouseEventArgs e)
- {
- if (this.startSpin)
- {
- this.documentWorkspace.tools[(int)(this.documentWorkspace.activeTool)].InvokeMember("OnMouseDown",
- BindingFlags.Public |
- BindingFlags.Static |
- BindingFlags.InvokeMethod,
- null,
- null,
- new object[2] { this.documentWorkspace, e });
- return;
- }
- if (this.documentWorkspace.GraphicsList.Count > 0)
- {
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.Pointer;
- this.documentWorkspace.SetContinuousDrawingVoid(false);
- this.documentWorkspace.tools[(int)(this.documentWorkspace.activeTool)].InvokeMember("OnMouseDown",
- BindingFlags.Public |
- BindingFlags.Static |
- BindingFlags.InvokeMethod,
- null,
- null,
- new object[2] { this.documentWorkspace, e });
- var baseData = (ViewRectangle)this.documentWorkspace.GraphicsList[this.documentWorkspace.GraphicsList.Count - 1];
- if (!baseData.isHitTest)
- {
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.ViewRectangle;
- this.documentWorkspace.SetContinuousDrawingVoid(true);
- this.documentWorkspace.GraphicsList.RemoveAt(this.documentWorkspace.GraphicsList.Count - 1);
- }
- }
- this.documentWorkspace.tools[(int)(this.documentWorkspace.activeTool)].InvokeMember("OnMouseDown",
- BindingFlags.Public |
- BindingFlags.Static |
- BindingFlags.InvokeMethod,
- null,
- null,
- new object[2] { this.documentWorkspace, e });
- if (isPlay)
- {
- if (this.checkBox1.Checked || e.Button == MouseButtons.Right)
- {
- timer1.Stop();
- }
- else
- {
- GraphicsList graphicsList = new GraphicsList();
- for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
- {
- graphicsList.Add(this.documentWorkspace.GraphicsList[i].Clone(this.documentWorkspace));
- }
- if (e.Button == MouseButtons.Left)
- {
- for (int i = 0; i < this.listPictureName.Items.Count; i++)
- {
- if (this.dataList.ContainsKey(i))
- {
- this.dataList[i] = graphicsList;
- }
- else
- {
- this.dataList.Add(i, graphicsList);
- }
- }
- }
- else if (e.Button == MouseButtons.Right)
- {
- if (this.listPictureName.SelectedItem != null)
- {
- if (this.dataList.ContainsKey(this.listPictureName.SelectedIndex))
- {
- this.dataList[this.listPictureName.SelectedIndex] = graphicsList;
- }
- else
- {
- this.dataList.Add(this.listPictureName.SelectedIndex, graphicsList);
- }
- }
- }
- }
- }
- }
- #region 公共按钮
- private void InitCommonButtonEvent()
- {
- this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
- this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
- this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
- this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
- this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
- this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
- this.commonControlButtons.isModeCheckBox.CheckedChanged += new EventHandler(isModeCheckBox_Click);
- }
- private void isModeCheckBox_Click(object sender, EventArgs e)
- {
- if (!this.isNormal)
- {//叠加
- foreach (int index in this.correspondNum.Keys)
- {
- int duiyingIndex = -1;
- if (this.correspondNum.ContainsKey(index))
- {
- duiyingIndex = this.correspondNum[index];
- }
- if (this.dataBoolList.ContainsKey(duiyingIndex))
- {
- this.dataBoolList[duiyingIndex] = this.commonControlButtons.isModeCheckBox.Checked;
- }
- else
- {
- this.dataBoolList.Add(duiyingIndex, this.commonControlButtons.isModeCheckBox.Checked);
- }
- if (this.dataFanweibuchangList.ContainsKey(duiyingIndex))
- {
- this.dataFanweibuchangList[duiyingIndex] = this.commonControlButtons.isModeCheckBox.Checked;
- }
- else
- {
- this.dataFanweibuchangList.Add(duiyingIndex, this.commonControlButtons.isModeCheckBox.Checked);
- }
- if (this.dataErzhichuliList.ContainsKey(duiyingIndex))
- {
- this.dataErzhichuliList[duiyingIndex] = this.commonControlButtons.isModeCheckBox.Checked;
- }
- else
- {
- this.dataErzhichuliList.Add(duiyingIndex, this.commonControlButtons.isModeCheckBox.Checked);
- }
- }
- return;
- }
- if (this.listPictureName.SelectedItem != null)
- {
- int index = listPictureName.SelectedIndex;
- int duiyingIndex = -1;
- if (this.correspondNum.ContainsKey(index))
- {
- duiyingIndex = this.correspondNum[index];
- }
- if (this.dataBoolList.ContainsKey(duiyingIndex))
- {
- this.dataBoolList[duiyingIndex] = this.commonControlButtons.isModeCheckBox.Checked;
- }
- else
- {
- this.dataBoolList.Add(duiyingIndex, this.commonControlButtons.isModeCheckBox.Checked);
- }
- if (this.dataFanweibuchangList.ContainsKey(duiyingIndex))
- {
- this.dataFanweibuchangList[duiyingIndex] = this.commonControlButtons.isModeCheckBox.Checked;
- }
- else
- {
- this.dataFanweibuchangList.Add(duiyingIndex, this.commonControlButtons.isModeCheckBox.Checked);
- }
- if (this.dataErzhichuliList.ContainsKey(duiyingIndex))
- {
- this.dataErzhichuliList[duiyingIndex] = this.commonControlButtons.isModeCheckBox.Checked;
- }
- else
- {
- this.dataErzhichuliList.Add(duiyingIndex, this.commonControlButtons.isModeCheckBox.Checked);
- }
- }
- }
- private void zoomInButton_Click(object sender, EventArgs e)
- {
- if (this.bitmap != null)
- this.documentWorkspace.ZoomIn();
- }
- private void zoomOutButton_Click(object sender, EventArgs e)
- {
- if (this.bitmap != null)
- this.documentWorkspace.ZoomOut();
- }
- private void zoomToWindowButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
- }
- private void actualSizeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
- this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
- }
- private void pointerButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
- }
- private void mobileModeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
- }
- #endregion
- private void PlotTheMeasurementRange_Load()
- {
- listPictureName.DataSource = null;
- listPictureName.DataSource = pictureNames;
- }
- // TODO:BUG
- private void listPictureName_MouseDown(object sender, EventArgs e)
- {
- if (this.listPictureName.SelectedItem != null)
- {
- if (this.selectedIndex == this.listPictureName.SelectedIndex)
- {
- return;
- }
- this.hasAngle = 0;
- GraphicsList graphicsList = new GraphicsList();
- index = listPictureName.SelectedIndex;
- selectedIndex = index;
- if (!this.isPlay)
- {
- if (index + 1 != this.triangleTrackBar1.Value)
- {
- this.listPictureName.SelectedValueChanged -= new System.EventHandler(this.listPictureName_MouseDown);
- this.triangleTrackBar1.Value = index + 1;
- this.textBox1.Text = this.triangleTrackBar1.Value + @"/" + this.triangleTrackBar1.Maximum;
- this.listPictureName.SelectedValueChanged += new System.EventHandler(this.listPictureName_MouseDown);
- }
- }
- int duiyingIndex = -1;
- if (this.correspondNum.ContainsKey(index)) {
- duiyingIndex = this.correspondNum[index];
- }
- if (this.needShowDaoDianbu.First().Value && this.needShowDaoDianbu.ContainsKey(duiyingIndex))
- {
- if (this.dataBoolList.ContainsKey(duiyingIndex))
- {
- bool isCheck;
- this.dataBoolList.TryGetValue(duiyingIndex, out isCheck);
- if (isCheck)
- {
- this.commonControlButtons.isModeCheckBox.Checked = true;
- }
- else
- {
- this.commonControlButtons.isModeCheckBox.Checked = false;
- }
- }
- if (this.needShowDaoDianbu[duiyingIndex])
- {
- this.commonControlButtons.ShowCheckBox();
- }
- }
- if (this.needShowFanweibuchang.First().Value && this.needShowFanweibuchang.ContainsKey(duiyingIndex))
- {
- if (this.dataFanweibuchangList.ContainsKey(duiyingIndex))
- {
- bool isCheck;
- this.dataFanweibuchangList.TryGetValue(duiyingIndex, out isCheck);
- if (isCheck)
- {
- this.commonControlButtons.isModeCheckBox.Checked = true;
- }
- else
- {
- this.commonControlButtons.isModeCheckBox.Checked = false;
- }
- }
- if (this.needShowFanweibuchang[duiyingIndex])
- {
- this.commonControlButtons.ShowIsFanweibuchang();
- }
- }
- if (this.needShowErzhichuli.First().Value && this.needShowErzhichuli.ContainsKey(duiyingIndex))
- {
- if (this.dataErzhichuliList.ContainsKey(duiyingIndex))
- {
- bool isCheck;
- this.dataErzhichuliList.TryGetValue(duiyingIndex, out isCheck);
- if (isCheck)
- {
- this.commonControlButtons.isModeCheckBox.Checked = true;
- }
- else
- {
- this.commonControlButtons.isModeCheckBox.Checked = false;
- }
- }
- if (this.needShowErzhichuli[duiyingIndex])
- {
- this.commonControlButtons.ShowIsErzhichuli();
- }
- }
- if (index < 0 || index >= pictures.Count)
- {
- return;
- }
- #region [判断透明度]
- if (this.isNormal)
- {
- int num = 255;
- try
- {
- num = Convert.ToInt32(textBox3.Text);
- if (num > 255)
- {
- num = 255;
- textBox3.Text = "255";
- }
- }
- catch (Exception)
- {
- }
- this.BitmapArray.Clear();
- var abc = (Bitmap)originalPictures[index].Clone();
- Bitmap map = MakeTransparent(abc, num);
- if (map != null)
- {
- this.BitmapArray.Add(map);
- this.BitmapArray.Add(map);
- this.OverlapHeight = this.BitmapArray[0].Height;
- this.OverlapWidth = this.BitmapArray[0].Width;
- pictures[index] = Overlap(OverlapType.CENTER);
- }
- if (abc != null)
- {
- abc.Dispose();
- }
- }
- #endregion
- if (this.startSpin)
- {
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.DrawLine;
- }
- else
- {
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.ViewRectangle;
- }
- this.bitmap = pictures[index];
- Document document = Document.FromImage(this.bitmap);
- this.documentWorkspace.Document = document;
- this.documentWorkspace.Visible = true;
- if (this.dataList.ContainsKey(duiyingIndex))
- {
- for (int i = 0; i < this.dataList[duiyingIndex].Count; i++)
- {
- graphicsList.Add(this.dataList[duiyingIndex][i].Clone(this.documentWorkspace));
- }
- this.documentWorkspace.GraphicsList = graphicsList;
- }
- else
- {
- this.documentWorkspace.GraphicsList = graphicsList;
- }
- this.documentWorkspace.Refresh();
- groupBoxZhangshu.Text = "第" + (index + 1).ToString() + PdnResources.GetString("NewZhang");
- }
- }
- /// <summary>
- /// 确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void buttonOKDraw_Click(object sender, EventArgs e)
- {
- if (this.listPictureName.SelectedItem != null)
- {
- index = listPictureName.SelectedIndex;
- int duiyingIndex = -1;
- if (this.correspondNum.ContainsKey(index))
- {
- duiyingIndex = this.correspondNum[index];
- }
- GraphicsList graphicsList = new GraphicsList();
- for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
- {
- graphicsList.Add(this.documentWorkspace.GraphicsList[i].Clone(this.documentWorkspace));
- }
- if (this.dataList.ContainsKey(duiyingIndex))
- {
- this.dataList[duiyingIndex] = graphicsList;
- }
- else
- {
- this.dataList.Add(duiyingIndex, graphicsList);
- }
- }
- Dictionary<int, Bitmap> bitmapData = new Dictionary<int, Bitmap>();
- for (int i = 0; i < this.listPictureName.Items.Count; i++)
- {
- int duiyingIndex = -1;
- if (this.correspondNum.ContainsKey(i))
- {
- duiyingIndex = this.correspondNum[i];
- }
- if (!this.dataList.ContainsKey(duiyingIndex))
- {
- this.dataList.Add(duiyingIndex, new GraphicsList());
- }
- if (!bitmapData.ContainsKey(duiyingIndex))
- {
- bitmapData.Add(duiyingIndex, this.pictures[i]);
- }
- else {
- bitmapData[duiyingIndex] = this.pictures[i];
- }
- }
- this.resultsView.getList(this.dataList);
- this.resultsView.getBoolList(this.dataBoolList);
- this.resultsView.getFanweibuchangList(this.dataFanweibuchangList);
- this.resultsView.getErzhichuliList(this.dataErzhichuliList);
- this.resultsView.getMatList(bitmapData);
- this.Close();
- }
- #region [播放相关]
- /// <summary>
- /// 图片选择改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void trackBar_Scroll(object sender, EventArgs e)
- {
- this.textBox1.Text = this.triangleTrackBar1.Value + @"/" + this.triangleTrackBar1.Maximum;
- try
- {
- //滚动到指定的行位置
- this.listPictureName.SelectedIndex = this.triangleTrackBar1.Value - 1;
- }
- catch (Exception ex)
- {
- this.listPictureName.SelectedIndex = 0;
- }
- }
- #endregion
- /// <summary>
- /// 从后往前播放按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- if (this.startSpin)
- {
- return;
- }
- if (this.button1.BackColor == Color.DarkGray)
- return;
- else
- {
- this.button1.BackColor = Color.DarkGray;
- this.button2.BackColor = Color.FromArgb(255, 240, 240, 240);
- this.playType = 1;
- }
- }
- /// <summary>
- /// 从前往后播放按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- if (this.startSpin)
- {
- return;
- }
- if (this.button2.BackColor == Color.DarkGray)
- return;
- else
- {
- this.button2.BackColor = Color.DarkGray;
- this.button1.BackColor = Color.FromArgb(255, 240, 240, 240);
- this.playType = 2;
- }
- }
- /// <summary>
- /// 是否循环播放
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- if (this.startSpin)
- {
- return;
- }
- if (this.button3.BackColor == Color.DarkGray)
- {
- this.button3.BackColor = Color.FromArgb(255, 240, 240, 240);
- this.isLoop = false;
- }
- else
- {
- this.button3.BackColor = Color.DarkGray;
- this.isLoop = true;
- }
- }
- /// <summary>
- /// 播放 暂停
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- if (this.startSpin)
- {
- MessageBox.Show("旋轉模式中,請勿播放!");
- return;
- }
- if (this.isPlay)
- {
- this.button4.Image = PdnResources.GetImageResource("Icons.MultiNowPlayIcon.png").Reference;
- this.isPlay = false;
- this.timer1.Stop();
- }
- else
- {
- this.button4.Image = PdnResources.GetImageResource("Icons.MultiNowPauseIcon.png").Reference;
- this.isPlay = true;
- this.timer1.Start();
- }
- }
- /// <summary>
- /// 开始播放
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (this.playType == 2)
- {
- if (this.selectedIndex < this.listPictureName.Items.Count - 1)
- {
- this.listPictureName.SelectedIndex = this.selectedIndex + 1;
- this.triangleTrackBar1.Value = this.selectedIndex + 1;
- }
- else
- {
- if (this.isLoop)
- {
- this.listPictureName.SelectedIndex = 0;
- this.triangleTrackBar1.Value = 1;
- }
- else
- {
- this.isPlay = false;
- this.timer1.Stop();
- this.button4.Image = PdnResources.GetImageResource("Icons.MultiNowPlayIcon.png").Reference;
- }
- }
- }
- else
- {
- if (this.selectedIndex > 0)
- {
- int index = this.selectedIndex;
- this.listPictureName.SelectedIndex = this.selectedIndex - 1;
- this.triangleTrackBar1.Value = index;
- }
- else
- {
- if (this.isLoop)
- {
- this.listPictureName.SelectedIndex = this.listPictureName.Items.Count - 1;
- this.triangleTrackBar1.Value = this.listPictureName.Items.Count;
- }
- else
- {
- this.isPlay = false;
- this.timer1.Stop();
- this.button4.Image = PdnResources.GetImageResource("Icons.MultiNowPlayIcon.png").Reference;
- }
- }
- }
- this.textBox1.Text = this.triangleTrackBar1.Value + @"/" + this.triangleTrackBar1.Maximum;
- }
- public Bitmap Overlap(OverlapType type)
- {
- Bitmap bmPhoto;
- try
- {
- Bitmap[] bitmaps = this.BitmapArray.ToArray();
- int width = this.OverlapWidth;
- int height = this.OverlapHeight;
- if (width == 0 || height == 0)
- {
- return null;
- }
- Mat mat = new Mat(height, width, MatType.CV_8UC4, new Scalar(240, 240, 240, 255));
- bmPhoto = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat);
- float x = 0;
- float y = 0;
- //load the Bitmap into a Graphics object
- Graphics grPhoto = Graphics.FromImage(bmPhoto);
- //Set the rendering quality for this Graphics object
- grPhoto.SmoothingMode = SmoothingMode.AntiAlias;//清除锯齿的呈现
- //haix
- for (int i = 0; i < bitmaps.Length; i++)
- {
- Bitmap img = bitmaps[i];
- if (img == null)
- {
- continue;
- }
- if (type == OverlapType.CENTER)
- {
- x = (width - img.Width) / 2.0f;
- y = (height - img.Height) / 2.0f;
- if (i == 1)
- {
- x += 1;
- y += 1;
- }
- }
- grPhoto.DrawImage(img, 0, 0, img.Width, img.Height);
- }
- if (mat != null)
- {
- mat.Dispose();
- }
- }
- catch (Exception)
- {
- return null;
- }
- return bmPhoto;
- }
- //定义图像透明度调整函数
- public Bitmap MakeTransparent(Bitmap src, int num)
- {
- return ImageTools.MakeTransparent(src, num);
- }
- /// <summary>
- /// 透明度修改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void textBox3_TextChanged(object sender, KeyEventArgs e)
- {
- if (this.startSpin)
- {
- return;
- }
- if (e.KeyCode == Keys.Control || e.KeyCode == Keys.Enter)
- {
- if (this.isNormal)
- {
- int num = 255;
- try
- {
- num = Convert.ToInt32(textBox3.Text);
- if (num > 255)
- {
- num = 255;
- textBox3.Text = "255";
- }
- }
- catch (Exception)
- {
- }
- this.BitmapArray.Clear();
- var abc = (Bitmap)originalPictures[this.selectedIndex].Clone();
- Bitmap map = MakeTransparent(abc, num);
- this.BitmapArray.Add(map);
- this.BitmapArray.Add(map);
- pictures[this.selectedIndex] = Overlap(OverlapType.CENTER);
- abc.Dispose();
- this.bitmap = pictures[this.selectedIndex];
- Document document = Document.FromImage(this.bitmap);
- this.documentWorkspace.Document = document;
- this.documentWorkspace.Visible = true;
- }
- else
- {
- int num = 255 / this.listPictureName.Items.Count;
- try
- {
- num = Convert.ToInt32(textBox3.Text);
- if (num > 255)
- {
- num = 255;
- textBox3.Text = "255";
- }
- }
- catch (Exception)
- {
- }
- this.BitmapArray.Clear();
- foreach (Bitmap item in originalPictures)
- {
- Bitmap cloneData = (Bitmap)item.Clone();
- Bitmap bitmap = MakeTransparent(cloneData, num);
- this.BitmapArray.Add(bitmap);
- cloneData.Dispose();
- }
- this.OverlapHeight = this.BitmapArray[0].Height;
- this.OverlapWidth = this.BitmapArray[0].Width;
- this.bitmap = Overlap(OverlapType.CENTER);
- Document document = Document.FromImage(this.bitmap);
- this.documentWorkspace.Document = document;
- this.documentWorkspace.Visible = true;
- }
- }
- }
- /// <summary>
- /// 时间间隔修改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void textBox2_TextChanged(object sender, KeyEventArgs e)
- {
- if (this.startSpin)
- {
- return;
- }
- if (e.KeyCode == Keys.Control || e.KeyCode == Keys.Enter)
- {
- int Interval = 1000;
- try
- {
- Interval = Convert.ToInt32(textBox2.Text);
- }
- catch (Exception)
- {
- }
- timer1.Interval = Interval;
- }
- }
- /// <summary>
- /// 正常
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button5_Click(object sender, EventArgs e)
- {
- if (this.startSpin)
- {
- this.startSpin = false;
- this.button7.Text = "旋转";
- }
- this.textBox3.Text = "255";
- this.listPictureName.Enabled = true;
- this.selectedIndex = -1;
- this.isNormal = true;
- this.BitmapArray.Clear();
- for (int i = 0; i <= originalPictures.Count - 1; i++)
- {
- var abc = (Bitmap)originalPictures[i].Clone();
- Bitmap map = MakeTransparent(abc, 255);
- this.BitmapArray.Add(map);
- abc.Dispose();
- this.OverlapHeight = this.BitmapArray[0].Height;
- this.OverlapWidth = this.BitmapArray[0].Width;
- pictures[i] = Overlap(OverlapType.CENTER);
- }
- this.listPictureName_MouseDown(null, null);
- }
- /// <summary>
- /// 叠加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button6_Click(object sender, EventArgs e)
- {
- if (this.startSpin)
- {
- this.startSpin = false;
- this.button7.Text = "旋转";
- }
- if (this.documentWorkspace.activeTool != Annotation.Enum.DrawToolType.ViewRectangle)
- {
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.ViewRectangle;
- this.documentWorkspace.SetContinuousDrawingVoid(true);
- }
- var num = Convert.ToInt32(255 / this.listPictureName.Items.Count);
- this.textBox3.Text = num.ToString();
- this.listPictureName.Enabled = false;
- this.BitmapArray.Clear();
- foreach (Bitmap item in originalPictures)
- {
- Bitmap cloneData = (Bitmap)item.Clone();
- Bitmap bitmap = MakeTransparent(cloneData, num);
- this.BitmapArray.Add(bitmap);
- cloneData.Dispose();
- }
- this.OverlapHeight = this.BitmapArray[0].Height;
- this.OverlapWidth = this.BitmapArray[0].Width;
- this.bitmap = Overlap(OverlapType.CENTER);
- if (this.bitmap != null)
- {
- Document document = Document.FromImage(this.bitmap);
- this.documentWorkspace.Document = document;
- this.documentWorkspace.Visible = true;
- }
- if (this.isPlay)
- {
- this.button4.Image = PdnResources.GetImageResource("Icons.MultiNowPlayIcon.png").Reference;
- this.isPlay = false;
- this.timer1.Stop();
- }
- this.isNormal = false;
- }
- /// <summary>
- /// 旋转开始
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button7_Click(object sender, EventArgs e)
- {
- if (this.isPlay)
- {
- return;
- }
- this.startSpin = !this.startSpin;
- if (this.startSpin)
- {
- this.button7.Text = "停止旋转";
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.DrawLine;
- #region []
- this.textBox3.Text = "255";
- this.listPictureName.Enabled = true;
- this.selectedIndex = -1;
- this.isNormal = true;
- this.BitmapArray.Clear();
- for (int i = 0; i <= originalPictures.Count - 1; i++)
- {
- var abc = (Bitmap)originalPictures[i].Clone();
- Bitmap map = MakeTransparent(abc, 255);
- this.BitmapArray.Add(map);
- abc.Dispose();
- this.OverlapHeight = this.BitmapArray[0].Height;
- this.OverlapWidth = this.BitmapArray[0].Width;
- pictures[i] = Overlap(OverlapType.CENTER);
- }
- this.listPictureName_MouseDown(null, null);
- #endregion
- }
- else
- {
- this.button7.Text = "旋转";
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.ViewRectangle;
- }
- }
- }
- }
|