private void tsmiPanelDelete(object sender, EventArgs e) { try { int id = (int)cmsMarkPanelMenu.Tag; markOperation = MarkOperation.Delete; //用户权限判断 if (IsUserLimited(id, MarkType.MarkPanel)) { Dialogs.Show("权限受限!", false); return; } MarkOperator op = new MarkOperator(); op.Type = MarkType.MarkPanel; op.Mark = markAreaDao.GetMarkAreaById(id); op.Operation = MarkOperation.Delete; stackMarkOperator.Push(op); DeleteMarkPanel(id); } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } }
private void tsmiAdd_Click(object sender, EventArgs e) { MarkAddForm frm = new MarkAddForm(); frm.IsAdd = true; while (true) { DialogResult result = frm.ShowDialog(); if (result == DialogResult.Cancel) { break; } else if (result == DialogResult.OK) { MarkCell mark = new MarkCell(); mark.SlideId = txtSlideId.Text; mark.SwathId = txtCurSwath.Text; mark.FieldId = txtCurSequence.Text; mark.ImageX = ConstDef.ImageX; mark.ImageY = ConstDef.ImageY; mark.TypeId = frm.TypeId; mark.UserId = ConstDef.UserID; mark.SlideFrom = ConstDef.ImagePath; mark.Remarks = frm.Remark; mark.CreateTime = DateTime.Now; if (markCellDao.Insert(mark)) { MessageBox.Show("保存成功!"); UpdateMarkGrid(); MarkCell temp = markCellDao.GetMarkCellByTime(mark.CreateTime); if (temp == null) { MessageBox.Show("读回新增标记失败!"); } else { DropMarkLabel(temp, true); } MarkOperator op = new MarkOperator(); op.Type = MarkType.MarkLabel; op.Mark = temp; op.Operation = MarkOperation.Add; stackMarkOperator.Push(op); break; } else { MessageBox.Show("保存失败!"); frm.TypeId = mark.TypeId; frm.Remark = mark.Remarks; } } } }
private void tsmiUpdate_Click(object sender, EventArgs e) { int id = (int)cmsMarkMenu.Tag; //用户权限判断 if (IsUserLimited(id, MarkType.MarkLabel)) { Dialogs.Show("权限受限!", false); return; } MarkAddForm frm = new MarkAddForm(); frm.IsAdd = false; MarkCell oldMark = markCellDao.GetMarkCellById(id); if (oldMark == null) { MessageBox.Show("获取标记信息失败!"); return; } frm.MarkId = oldMark.Id; frm.Remark = oldMark.Remarks; if (frm.ShowDialog() == DialogResult.OK) { MarkCell newMark = MarkCell.Copy(oldMark); newMark.TypeId = frm.TypeId; newMark.UserId = ConstDef.UserID; newMark.SlideFrom = ConstDef.ImagePath; newMark.Remarks = frm.Remark; if (ModifyMarkLabel(newMark)) { MarkOperator op = new MarkOperator(); op.Type = MarkType.MarkLabel; op.Mark = oldMark; op.Operation = MarkOperation.Modify; stackMarkOperator.Push(op); } } }
private void tsmiRect_Click(object sender, EventArgs e) { try { markOperation = MarkOperation.Add; //插入数据库 MarkArea area = new MarkArea(); area.SlideId = txtSlideId.Text; area.SwathId = txtCurSwath.Text; area.FieldId = txtCurSequence.Text; area.RectX = ConstDef.ImageX; area.RectY = ConstDef.ImageY; area.Width = Convert.ToInt32((double)MarkPanel.PanelDefaultSize / pbImageView.Width * pbImageView.Image.Width); area.Height = Convert.ToInt32((double)MarkPanel.PanelDefaultSize / pbImageView.Height * pbImageView.Image.Height); area.UserId = ConstDef.UserID; area.CreateTime = DateTime.Now; if (markAreaDao.Insert(area)) { MarkArea areaBack = markAreaDao.GetMarkAreaByTime(area.CreateTime); DropMarkPanel(areaBack); MarkOperator op = new MarkOperator(); op.Type = MarkType.MarkPanel; op.Mark = areaBack; op.Operation = MarkOperation.Add; stackMarkOperator.Push(op); } else { MessageBox.Show("插入区域失败!"); } } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } }
//标记区域 private void panel_MouseClick(object sender, MouseEventArgs e) { try { if (e.Button == MouseButtons.Right) { Point point = pbImageView.PointToScreen(((MarkPanel)sender).Location); Point newPoint = new Point(point.X + e.Location.X, point.Y + e.Location.Y); cmsMarkPanelMenu.Show(newPoint); } int id = (sender as MarkPanel).GetMarkId(); cmsMarkPanelMenu.Tag = id; MarkOperator op = new MarkOperator(); op.Type = MarkType.MarkPanel; op.Mark = MarkArea.Copy(markAreaDao.GetMarkAreaById(id)); op.Operation = MarkOperation.Modify; stackMarkOperator.Push(op); } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } }
private void tsmiDelete_Click(object sender, EventArgs e) { try { int id = (int)cmsMarkMenu.Tag; //用户权限判断 if (IsUserLimited(id, MarkType.MarkLabel)) { Dialogs.Show("权限受限!", false); return; } MarkCell mark = markCellDao.GetMarkCellById(id); if (markCellDao.Delete(id)) { markIdLabelMap[id].Hide(); //markIdLabelMap[id].Dispose(); markIdLabelMap.Remove(id); UpdateMarkGrid(); MarkOperator op = new MarkOperator(); op.Type = MarkType.MarkLabel; op.Mark = mark; op.Operation = MarkOperation.Delete; stackMarkOperator.Push(op); } else { MessageBox.Show("删除失败!"); } } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } }
public void btnMarkUndo_Click() { try { if (stackMarkOperator.Count > 0) { MarkOperator op = stackMarkOperator.Pop(); switch (op.Type) { case MarkType.MarkLabel: { MarkCell markcell = (MarkCell)op.Mark; if (op.Operation == MarkOperation.Add) { DeleteMarkLabel(markcell.Id); } else if (op.Operation == MarkOperation.Delete) { markCellDao.Insert(markcell); DropMarkLabel(markcell, true); UpdateMarkGrid(); } else if (op.Operation == MarkOperation.Modify) { ModifyMarkLabel(markcell); } } break; case MarkType.MarkPanel: { MarkArea markarea = (MarkArea)op.Mark; if (op.Operation == MarkOperation.Add) { markOperation = MarkOperation.Delete; DeleteMarkPanel(markarea.Id); } else if (op.Operation == MarkOperation.Delete) { markOperation = MarkOperation.Add; markAreaDao.Insert(markarea); DropMarkPanel(markarea); } else if (op.Operation == MarkOperation.Modify) { markOperation = MarkOperation.Modify; ModifyMarkPanel(markarea); } } break; default: break; } } } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } }