public void SetMergeStyle(MergeStyle style) { if ((style & MergeStyle.ReserveSourceBiblio) != 0) { this.radioButton_biblio_reserveSource.Checked = true; this.radioButton_biblio_reserveTarget.Checked = false; } else { // TODO: 是否验证 MergeStyle.ReserveTargetBiblio ? this.radioButton_biblio_reserveSource.Checked = false; this.radioButton_biblio_reserveTarget.Checked = true; } if ((style & MergeStyle.CombineSubrecord) != 0) { this.radioButton_subrecord_combine.Checked = true; this.radioButton_subrecord_source.Checked = false; this.radioButton_subrecord_target.Checked = false; } else if ((style & MergeStyle.OverwriteSubrecord) != 0) { this.radioButton_subrecord_combine.Checked = false; this.radioButton_subrecord_source.Checked = true; this.radioButton_subrecord_target.Checked = false; } else { // missing this.radioButton_subrecord_combine.Checked = false; this.radioButton_subrecord_source.Checked = false; this.radioButton_subrecord_target.Checked = true; } }
public MergeStyle GetMergeStyle() { MergeStyle style = MergeStyle.None; if (radioButton_biblio_reserveSource.Checked) { style |= MergeStyle.ReserveSourceBiblio; } else { style |= MergeStyle.ReserveTargetBiblio; } if (radioButton_subrecord_combine.Checked) { style |= MergeStyle.CombineSubrecord; } else if (radioButton_subrecord_source.Checked) { style |= MergeStyle.OverwriteSubrecord; } else { style |= MergeStyle.MissingSourceSubrecord; } // 如果 missing 和 reservetarget 同时出现,表示没有必要操作了 return(style); }
private void button_OK_Click(object sender, EventArgs e) { string strError = ""; // 测试的时候不经过这个检查 if (this._autoMergeStyle == MergeStyle.None) { // 检查操作必要性 MergeStyle style = GetMergeStyle(); // 如果 missing 和 reservetarget 同时出现,表示没有必要操作了 if ((style & MergeStyle.MissingSourceSubrecord) != 0 && (style & MergeStyle.ReserveTargetBiblio) != 0) { strError = "若不采纳来自源记录的书目和子记录,意味着没有必要进行此次合并操作"; goto ERROR1; } } this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); return; ERROR1: MessageBox.Show(this, strError); }
private void toolStripButton_mergeTo_Click(object sender, EventArgs e) { // TODO: 出现合并对话框,选择保留源和目标中哪一条书目记录 GetMergeStyleDialog merge_dlg = new GetMergeStyleDialog(); MainForm.SetControlFont(merge_dlg, this.Font, false); merge_dlg.EnableSubRecord = false; merge_dlg.SourceRecPath = this.OriginRecPath; merge_dlg.TargetRecPath = this.SelectedRecPath; merge_dlg.MessageText = "请指定源书目记录(左侧)和目标书目记录(右侧)合并的方法"; merge_dlg.UiState = Program.MainForm.AppInfo.GetString( "BiblioDupDialog", "GetMergeStyleDialog_uiState", ""); { MergeStyle style = merge_dlg.GetMergeStyle(); // 去掉和 Subrecord 有关的 bit style = (style & (dp2Circulation.MergeStyle.ReserveSourceBiblio | dp2Circulation.MergeStyle.ReserveTargetBiblio)); // 设置为 合并下级记录 style |= dp2Circulation.MergeStyle.CombineSubrecord; merge_dlg.SetMergeStyle(style); } Program.MainForm.AppInfo.LinkFormState(merge_dlg, "entityform_GetMergeStyleDialog_state"); merge_dlg.ShowDialog(this); Program.MainForm.AppInfo.SetString( "BiblioDupDialog", "GetMergeStyleDialog_uiState", merge_dlg.UiState); if (merge_dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel) { return; } this.MergeStyle = merge_dlg.GetMergeStyle(); if ((this.MergeStyle & dp2Circulation.MergeStyle.ReserveTargetBiblio) == dp2Circulation.MergeStyle.ReserveTargetBiblio) { this.Action = "mergeTo"; // useTargetBiblio } else { this.Action = "mergeToUseSourceBiblio"; } this.Close(); }
// parameters: // public static Size Paint(PaintEventArgs e, Size bound, Font ref_font, string strSouceTitle, string strTargetTitle, MergeStyle style) { int x = SEP_X * 4; int y = SEP_Y * 4; // 不含有边距的整个尺寸 Size content_size = new Size(BIBLIO_WIDTH + PIC_SEP_X + BIBLIO_WIDTH, BIBLIO_HEIGHT + (SUBREC_HEIGHT + SEP_Y) * 3 + PIC_SEP_Y / 2 + BIBLIO_HEIGHT + (SUBREC_HEIGHT + SEP_Y) * 5); int x_blank = bound.Width - content_size.Width; int y_blank = bound.Height - content_size.Height; if (x_blank > 0) { x = Math.Max(x_blank / 2, SEP_X * 4); } if (y_blank > 0) { y = Math.Max(y_blank / 2, SEP_Y * 4); } Size total_size = new Size(content_size.Width + x + SEP_X * 4, content_size.Height + y + SEP_Y * 4); // testing // e.Graphics.ScaleTransform(2.0F, 2.0F); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; // 绘制左边一个书目记录 Size size = PaintRecord(e.Graphics, x, y, ref_font, strSouceTitle, leftColor, 3, new Color[] { leftColor, leftColor, leftColor }); // 绘制右边一个书目记录 int x2 = x + size.Width + PIC_SEP_X; int y2 = y; PaintRecord(e.Graphics, x2, y2, ref_font, strTargetTitle, rightColor, 2, new Color[] { rightColor, rightColor }); // 绘制下边一个 int x3 = x + (size.Width * 2 + PIC_SEP_X) / 2 - size.Width / 2; int y3 = y + size.Height + PIC_SEP_Y / 2; Color biblio_color = leftColor; if ((style & MergeStyle.ReserveSourceBiblio) != 0) { biblio_color = leftColor; } if ((style & MergeStyle.ReserveTargetBiblio) != 0) { biblio_color = rightColor; } if ((style & MergeStyle.CombineSubrecord) != 0) { PaintRecord(e.Graphics, x3, y3, ref_font, "最终保存效果", biblio_color, 5, new Color[] { leftColor, leftColor, leftColor, rightColor, rightColor }); } if ((style & MergeStyle.OverwriteSubrecord) != 0) { PaintRecord(e.Graphics, x3, y3, ref_font, "最终保存效果", biblio_color, 3, new Color[] { leftColor, leftColor, leftColor }); } if ((style & MergeStyle.MissingSourceSubrecord) != 0) { PaintRecord(e.Graphics, x3, y3, ref_font, "最终保存效果", biblio_color, 2, new Color[] { rightColor, rightColor }); } int nFontHeight = ref_font.Height; if ((style & MergeStyle.ReserveSourceBiblio) != 0) { // 1--> 3 biblio PaintCurve(e.Graphics, x + size.Width / 2, y + nFontHeight + (BIBLIO_HEIGHT - nFontHeight) / 2, x3 + size.Width / 2, y3 + nFontHeight + (BIBLIO_HEIGHT - nFontHeight) / 2, "right"); } if ((style & MergeStyle.ReserveTargetBiblio) != 0) { // 2--> 3 biblio PaintCurve(e.Graphics, x2 + size.Width / 2, y2 + nFontHeight + (BIBLIO_HEIGHT - nFontHeight) / 2, x3 + size.Width / 2, y3 + nFontHeight + (BIBLIO_HEIGHT - nFontHeight) / 2, "left"); } if ((style & MergeStyle.CombineSubrecord) != 0) { // 1 --> 3 subrecord PaintCurve(e.Graphics, x + SUBREC_WIDTH / 2 + SEP_X * 2, y + BIBLIO_HEIGHT + 3 * (SUBREC_HEIGHT + SEP_Y) / 2, x3 + SUBREC_WIDTH / 2 + SEP_X * 2, y3 + BIBLIO_HEIGHT + 3 * (SUBREC_HEIGHT + SEP_Y) / 2, "left"); // 2 --> 3 cubrecord PaintCurve(e.Graphics, x2 + SUBREC_WIDTH / 2 + SEP_X * 2, y2 + BIBLIO_HEIGHT + 0 * (SUBREC_HEIGHT + SEP_Y) + 2 * (SUBREC_HEIGHT + SEP_Y) / 2, x3 + SUBREC_WIDTH / 2 + SEP_X * 2, y3 + BIBLIO_HEIGHT + 3 * (SUBREC_HEIGHT + SEP_Y) + 2 * (SUBREC_HEIGHT + SEP_Y) / 2, "right"); } if ((style & MergeStyle.OverwriteSubrecord) != 0) { // 1 --> 3 subrecord PaintCurve(e.Graphics, x + SUBREC_WIDTH / 2 + SEP_X * 2, y + BIBLIO_HEIGHT + 3 * (SUBREC_HEIGHT + SEP_Y) / 2, x3 + SUBREC_WIDTH / 2 + SEP_X * 2, y3 + BIBLIO_HEIGHT + 3 * (SUBREC_HEIGHT + SEP_Y) / 2, "left"); } if ((style & MergeStyle.MissingSourceSubrecord) != 0) { // 2 --> 3 cubrecord PaintCurve(e.Graphics, x2 + SUBREC_WIDTH / 2 + SEP_X * 2, y2 + BIBLIO_HEIGHT + 0 * (SUBREC_HEIGHT + SEP_Y) + 2 * (SUBREC_HEIGHT + SEP_Y) / 2, x3 + SUBREC_WIDTH / 2 + SEP_X * 2, y3 + BIBLIO_HEIGHT + 0 * (SUBREC_HEIGHT + SEP_Y) + 2 * (SUBREC_HEIGHT + SEP_Y) / 2, "right"); } return(total_size); }
public void SetMergeStyle(MergeStyle style) { if ((style & MergeStyle.ReserveSourceBiblio) != 0) { this.radioButton_biblio_reserveSource.Checked = true; this.radioButton_biblio_reserveTarget.Checked = false; } else { // TODO: 是否验证 MergeStyle.ReserveTargetBiblio ? this.radioButton_biblio_reserveSource.Checked = false; this.radioButton_biblio_reserveTarget.Checked = true; } if ((style & MergeStyle.CombinSubrecord) != 0) { this.radioButton_subrecord_combin.Checked = true; this.radioButton_subrecord_source.Checked = false; this.radioButton_subrecord_target.Checked = false; } else if ((style & MergeStyle.OverwriteSubrecord) != 0) { this.radioButton_subrecord_combin.Checked = false; this.radioButton_subrecord_source.Checked = true; this.radioButton_subrecord_target.Checked = false; } else { // missing this.radioButton_subrecord_combin.Checked = false; this.radioButton_subrecord_source.Checked = false; this.radioButton_subrecord_target.Checked = true; } }
// parameters: // public static Size Paint(PaintEventArgs e, Size bound, Font ref_font, string strSouceTitle, string strTargetTitle, MergeStyle style) { int x = SEP * 4; int y = SEP * 4; // 不含有边距的整个尺寸 Size content_size = new Size(BIBLIO_WIDTH + PIC_SEP + BIBLIO_WIDTH, BIBLIO_HEIGHT + (SUBREC_HEIGHT + SEP) * 3 + PIC_SEP / 2 + BIBLIO_HEIGHT + (SUBREC_HEIGHT + SEP) * 5); int x_blank = bound.Width - content_size.Width; int y_blank = bound.Height - content_size.Height; if (x_blank > 0) x = Math.Max(x_blank / 2, SEP * 4); if (y_blank > 0) y = Math.Max(y_blank / 2, SEP * 4); Size total_size = new Size(content_size.Width + x + SEP * 4, content_size.Height + y + SEP * 4); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; // 绘制左边一个书目记录 Size size = PaintRecord(e.Graphics, x, y, ref_font, strSouceTitle, leftColor, 3, new Color[] { leftColor, leftColor, leftColor}); // 绘制右边一个书目记录 int x2 = x + size.Width + PIC_SEP; int y2 = y; PaintRecord(e.Graphics, x2, y2, ref_font, strTargetTitle, rightColor, 2, new Color[] { rightColor, rightColor }); // 绘制下边一个 int x3 = x + (size.Width*2 + PIC_SEP)/2 - size.Width / 2; int y3 = y + size.Height + PIC_SEP / 2; Color biblio_color = leftColor; if ((style & MergeStyle.ReserveSourceBiblio) != 0) biblio_color = leftColor; if ((style & MergeStyle.ReserveTargetBiblio) != 0) biblio_color = rightColor; if ((style & MergeStyle.CombinSubrecord) != 0) { PaintRecord(e.Graphics, x3, y3, ref_font, "最终保存效果", biblio_color, 5, new Color[] { leftColor, leftColor, leftColor, rightColor, rightColor }); } if ((style & MergeStyle.OverwriteSubrecord) != 0) { PaintRecord(e.Graphics, x3, y3, ref_font, "最终保存效果", biblio_color, 3, new Color[] { leftColor, leftColor, leftColor }); } if ((style & MergeStyle.MissingSourceSubrecord) != 0) { PaintRecord(e.Graphics, x3, y3, ref_font, "最终保存效果", biblio_color, 2, new Color[] { rightColor, rightColor }); } int nFontHeight = ref_font.Height; if ((style & MergeStyle.ReserveSourceBiblio) != 0) { // 1--> 3 biblio PaintCurve(e.Graphics, x + size.Width / 2, y + nFontHeight + (BIBLIO_HEIGHT - nFontHeight) / 2, x3 + size.Width / 2, y3 + nFontHeight + (BIBLIO_HEIGHT - nFontHeight) / 2, "right"); } if ((style & MergeStyle.ReserveTargetBiblio) != 0) { // 2--> 3 biblio PaintCurve(e.Graphics, x2 + size.Width / 2, y2 + nFontHeight + (BIBLIO_HEIGHT - nFontHeight) / 2, x3 + size.Width / 2, y3 + nFontHeight + (BIBLIO_HEIGHT - nFontHeight) / 2, "left"); } if ((style & MergeStyle.CombinSubrecord) != 0) { // 1 --> 3 subrecord PaintCurve(e.Graphics, x + SUBREC_WIDTH / 2 + SEP * 2, y + BIBLIO_HEIGHT + 3 * (SUBREC_HEIGHT + SEP) / 2, x3 + SUBREC_WIDTH / 2 + SEP * 2, y3 + BIBLIO_HEIGHT + 3 * (SUBREC_HEIGHT + SEP) / 2, "left"); // 2 --> 3 cubrecord PaintCurve(e.Graphics, x2 + SUBREC_WIDTH / 2 + SEP * 2, y2 + BIBLIO_HEIGHT + 0 * (SUBREC_HEIGHT + SEP) + 2 * (SUBREC_HEIGHT + SEP) / 2, x3 + SUBREC_WIDTH / 2 + SEP * 2, y3 + BIBLIO_HEIGHT + 3 * (SUBREC_HEIGHT + SEP) + 2 * (SUBREC_HEIGHT + SEP) / 2, "right"); } if ((style & MergeStyle.OverwriteSubrecord) != 0) { // 1 --> 3 subrecord PaintCurve(e.Graphics, x + SUBREC_WIDTH / 2 + SEP * 2, y + BIBLIO_HEIGHT + 3 * (SUBREC_HEIGHT + SEP) / 2, x3 + SUBREC_WIDTH / 2 + SEP * 2, y3 + BIBLIO_HEIGHT + 3 * (SUBREC_HEIGHT + SEP) / 2, "left"); } if ((style & MergeStyle.MissingSourceSubrecord) != 0) { // 2 --> 3 cubrecord PaintCurve(e.Graphics, x2 + SUBREC_WIDTH / 2 + SEP * 2, y2 + BIBLIO_HEIGHT + 0 * (SUBREC_HEIGHT + SEP) + 2 * (SUBREC_HEIGHT + SEP) / 2, x3 + SUBREC_WIDTH / 2 + SEP * 2, y3 + BIBLIO_HEIGHT + 0 * (SUBREC_HEIGHT + SEP) + 2 * (SUBREC_HEIGHT + SEP) / 2, "right"); } return total_size; }