Exemplo n.º 1
0
 void IItemAcceptable <AnnoPictureBox> .Cancel(object sender, AnnoPictureBox item)
 {
     if (AnnoPicture == item)
     {
         AnnoPicture = null;
     }
 }
Exemplo n.º 2
0
        private void 标注ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            annoFileDialog.Title = "载入标注文本文件";
            if (annoFileDialog.ShowDialog() == DialogResult.OK)
            {
                using (AnnoLoaderForm annoLoaderForm = new AnnoLoaderForm(annoFileDialog.FileName))
                {
                    if (annoLoaderForm.ShowDialog() == DialogResult.Yes)
                    {
                        Annotations = annoLoaderForm.Annotations;
                        void ItemAdd(object _sender, AnnoPictureBox _item, EventArgs _e)
                        {
                            string filePath = _item.FilePath;

                            _ = Process.Async.Now(() =>
                            {
                                for (int i = 0; i < Annotations.Length; i++)
                                {
                                    if (AnnoPictureBox.CheckAnnotation(Annotations[i], filePath))
                                    {
                                        _item.Annotations.Add(Annotations[i]);
                                        Annotations[i] = null;
                                    }
                                }
                            }, () => _item.Invalidate());
                        }

                        GlobalMessage.Progress progress = new GlobalMessage.Progress(annoPictureListPanel.Count)
                        {
                            ProgressingFormatString = "正在处理第{1}项,共{2}项",
                            Print = PrintStatus
                        };
                        (annoPictureListPanel as ListPanel <AnnoPictureBox>).ForEachItem((item) =>
                        {
                            ItemAdd(null, item, null);
                            progress.IncReport();
                        });
                        annoPictureListPanel.ItemAdded += ItemAdd;
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void 工作区ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            worksapceFolderDialog.Description = "选择标注工作区,加载其中.png|.gif|.jpg|.bmp|.jpeg|.wmf图像文件";
            if (worksapceFolderDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    GlobalMessage.Apply("status", "加载中");
                    workspace = worksapceFolderDialog.SelectedPath;
                    DirectoryInfo   wkDir   = new DirectoryInfo(workspace);
                    List <FileInfo> wkFiles = new List <FileInfo>();

                    wkFiles.AddRange(wkDir.GetFiles());
                    foreach (DirectoryInfo subDir in wkDir.GetDirectories("*", SearchOption.AllDirectories))
                    {
                        wkFiles.AddRange(subDir.GetFiles());
                    }

                    List <FileInfo> files = new List <FileInfo>();
                    foreach (FileInfo file in wkFiles)
                    {
                        switch (file.Extension.ToLower())
                        {
                        case ".png":
                        case ".gif":
                        case ".jpg":
                        case ".bmp":
                        case ".jpeg":
                        case ".wmf":
                            files.Add(file);
                            break;

                        default:
                            break;
                        }
                    }
                    GlobalMessage.Apply("status", $"共{files.Count}张图像");

                    annoPictureListPanel.Clear(true);
                    collect.ForEach((ctl) => { ctl.Image?.Dispose(); ctl.Dispose(); });
                    annoPictureListPanel.IsDynamicAdd     = files.Count > 100;
                    annoPictureListPanel.IsDynamicDispose = files.Count > 100;

                    //虚加载所有图像,并发送进度消息。
                    GlobalMessage.Progress progress = new GlobalMessage.Progress(files.Count)
                    {
                        ProgressingFormatString = "已加载{1}",
                        ProgressedString        = $"就绪,共{files.Count}张图像",
                        Print = PrintStatus
                    };
                    AnnoPictureBox[] annoPictures = new AnnoPictureBox[files.Count];
                    for (int i = 0; i < files.Count; i++)
                    {
                        annoPictures[i] = new AnnoPictureBox(files[i].FullName);
                        progress.Report(i + 1);
                    }
                    annoPictureListPanel.AddRange(annoPictures);
                    collect.AddRange(annoPictures);

                    annoPictureListPanel.ForEachItem((item) => item.paintIndexFont = new Font("微软雅黑", 15));
                }
                catch (Exception ex)
                {
                    GlobalMessage.Add("exception", ex.Message);
                }
            }
        }
Exemplo n.º 4
0
 void IItemAcceptable <AnnoPictureBox> .Accept(object sender, AnnoPictureBox item)
 {
     AnnoPicture = item;
     FreshAnnoLinkItem();
 }