protected override void OnMouseDown(MouseEventArgs e) { FCaptureToolBar = null; if (!this.ReadOnly) { if (FUseTableTool && FTableToolBar.Visible && TableMouseDown(e)) { FCaptureToolBar = FTableToolBar; return; } if (FUseImageTool && FImageToolBar.Visible && ImageMouseDown(e)) { FCaptureToolBar = FImageToolBar; return; } } base.OnMouseDown(e); FTopData = this.ActiveSectionTopLevelData(); HCCustomItem vTopItem = FTopData.GetActiveItem(); SetActiveToolItem(vTopItem); HCCustomData vData = null; while (FActiveItem == null) { vData = FTopData.GetRootData(); if (vData == FTopData) { break; } FTopData = vData; vTopItem = FTopData.GetActiveItem(); SetActiveToolItem(vTopItem); } }
private void mniDeleteProtect_Click(object sender, EventArgs e) { HCCustomData vTopData = FEmrView.ActiveSectionTopLevelData(); if (vTopData.SelectExists()) { string vS = vTopData.GetSelectText(); vS = vS.Replace("\n", "").Replace("\t", "").Replace("\r", ""); DeItem vDeItem = FEmrView.NewDeItem(vS); vDeItem.EditProtect = true; FEmrView.InsertDeItem(vDeItem); } else { DeItem vDeItem = vTopData.GetActiveItem() as DeItem; if (vDeItem.EditProtect) { vDeItem.EditProtect = false; FEmrView.ReAdaptActiveItem(); } } }
private void pmHCView_Opening(object sender, CancelEventArgs e) { if (FHCView.AnnotatePre.ActiveDrawAnnotateIndex >= 0) { for (int i = 0; i <= pmHCView.Items.Count - 1; i++) { pmHCView.Items[i].Visible = false; } mniModAnnotate.Visible = true; mniDelAnnotate.Visible = true; return; } else { for (int i = 0; i <= pmHCView.Items.Count - 1; i++) { pmHCView.Items[i].Visible = true; } mniModAnnotate.Visible = false; mniDelAnnotate.Visible = false; } HCCustomData vActiveData = FHCView.ActiveSection.ActiveData; HCCustomItem vActiveItem = vActiveData.GetActiveItem(); HCCustomData vTopData = null; HCCustomItem vTopItem = vActiveItem; while (vTopItem is HCCustomRectItem) { if ((vTopItem as HCCustomRectItem).GetActiveData() != null) { if (vTopData != null) { vActiveData = vTopData; vActiveItem = vTopItem; } vTopData = (vTopItem as HCCustomRectItem).GetTopLevelData(); vTopItem = vTopData.GetActiveItem(); } else { break; } } if (vTopData == null) { vTopData = vActiveData; } mniTable.Enabled = vActiveItem.StyleNo == HCStyle.Table; if (mniTable.Enabled) { HCTableItem vTableItem = vActiveItem as HCTableItem; mniInsertRowTop.Enabled = vTableItem.GetEditCell() != null; mniInsertRowBottom.Enabled = mniInsertRowTop.Enabled; mniInsertColLeft.Enabled = mniInsertRowTop.Enabled; mniInsertColRight.Enabled = mniInsertRowTop.Enabled; mniSplitRow.Enabled = mniInsertRowTop.Enabled; mniSplitCol.Enabled = mniInsertRowTop.Enabled; mniDeleteCurRow.Enabled = vTableItem.CurRowCanDelete(); mniDeleteCurCol.Enabled = vTableItem.CurColCanDelete(); mniMerge.Enabled = vTableItem.SelectedCellCanMerge(); if (vTableItem.BorderVisible) { mniDisBorder.Text = "隐藏边框"; } else { mniDisBorder.Text = "显示边框"; } } mniCut.Enabled = (!FHCView.ActiveSection.ReadOnly && vTopData.SelectExists()); mniCopy.Enabled = mniCut.Enabled; IDataObject vIData = Clipboard.GetDataObject(); mniPaste.Enabled = ((!FHCView.ActiveSection.ReadOnly) && ((vIData.GetDataPresent(HC.View.HC.HC_EXT)) || (vIData.GetDataPresent(DataFormats.Text)) || (vIData.GetDataPresent(DataFormats.Bitmap)) )); mniControlItem.Visible = ((!FHCView.ActiveSection.ReadOnly) && (!vTopData.SelectExists()) && (vTopItem is HCControlItem) && vTopItem.Active ); if (mniControlItem.Visible) { mniControlItem.Text = "属性(" + (vTopItem as HCControlItem).GetType().Name + ")"; } }
protected override void DoCaretChange() { base.DoCaretChange(); if (!FInputHelper.EnableEx) { return; } if (!this.Style.UpdateInfo.ReStyle) { return; } string vsBefor = ""; string vsAfter = ""; HCCustomData vTopData = this.ActiveSectionTopLevelData(); int vCurItemNo = vTopData.SelectInfo.StartItemNo; HCCustomItem vCurItem = vTopData.GetActiveItem(); if (vCurItem.StyleNo < HCStyle.Null) { if (vTopData.SelectInfo.StartItemOffset == HC.View.HC.OffsetBefor) { GetBeforString(vTopData, vCurItemNo - 1, ref vsBefor); } else { GetAfterString(vTopData, vCurItemNo + 1, ref vsAfter); } } else { // 取光标前 string vText = vCurItem.Text; if (GetCharBefor(vTopData.SelectInfo.StartItemOffset, ref vText)) { vsBefor = vText; } else { vsBefor = vText.Substring(0, vTopData.SelectInfo.StartItemOffset); GetBeforString(vTopData, vCurItemNo - 1, ref vsBefor); } // 取光标后 vText = vCurItem.Text; if (GetCharAfter(vTopData.SelectInfo.StartItemOffset + 1, ref vText)) { vsAfter = vText; } else { vsAfter = vText.Substring(vTopData.SelectInfo.StartItemOffset + 1 - 1, vText.Length - vTopData.SelectInfo.StartItemOffset); GetAfterString(vTopData, vCurItemNo + 1, ref vsAfter); } } FInputHelper.SetCaretString(vsBefor, vsAfter); }
private void pmView_Opening(object sender, CancelEventArgs e) { HCCustomData vActiveData = FEmrView.ActiveSection.ActiveData; HCCustomItem vActiveItem = vActiveData.GetActiveItem(); HCCustomData vTopData = null; HCCustomItem vTopItem = vActiveItem; while (vTopItem is HCCustomRectItem) { if ((vTopItem as HCCustomRectItem).GetActiveData() != null) { if (vTopData != null) { vActiveData = vTopData; vActiveItem = vTopItem; } vTopData = (vTopItem as HCCustomRectItem).GetActiveData(); vTopItem = vTopData.GetActiveItem(); } else { break; } } if (vTopData == null) { vTopData = vActiveData; } mniTable.Enabled = vActiveItem.StyleNo == HCStyle.Table; if (mniTable.Enabled) { DeTable vTable = vActiveItem as DeTable; mniInsertRowTop.Enabled = vTable.GetEditCell() != null; mniInsertRowBottom.Enabled = mniInsertRowTop.Enabled; mniInsertColLeft.Enabled = mniInsertRowTop.Enabled; mniInsertColRight.Enabled = mniInsertRowTop.Enabled; mniSplitRow.Enabled = mniInsertRowTop.Enabled; mniSplitCol.Enabled = mniInsertRowTop.Enabled; mniDeleteCurRow.Enabled = vTable.CurRowCanDelete(); mniDeleteCurCol.Enabled = vTable.CurColCanDelete(); mniMerge.Enabled = vTable.SelectedCellCanMerge(); } mniCut.Enabled = (!FEmrView.ActiveSection.ReadOnly) && vTopData.SelectExists(); mniCopy.Enabled = mniCut.Enabled; IDataObject vIData = Clipboard.GetDataObject(); mniPaste.Enabled = ((!(vTopData as HCRichData).ReadOnly) && ((vIData.GetDataPresent(HC.View.HC.HC_EXT)) || vIData.GetDataPresent(DataFormats.Text) || (vIData.GetDataPresent(DataFormats.Bitmap)))); mniControlItem.Visible = ((!(vTopData as HCRichData).ReadOnly) && (!vTopData.SelectExists()) && (vTopItem is HCControlItem) && (vTopItem.Active)); if (mniControlItem.Visible) { mniControlItem.Text = "属性(" + (vTopItem as HCControlItem).GetType().Name + ")"; } mniDeItem.Visible = false; mniDeleteProtect.Visible = false; if (vTopItem is DeItem) { if ((vTopItem as DeItem).IsElement) { mniDeItem.Visible = true; mniDeItem.Text = (vTopItem as DeItem)[DeProp.Name]; } if (FEmrView.DesignModeEx) // 文档设计模式 { if (vTopData.SelectExists()) { mniDeleteProtect.Text = "只读"; mniDeleteProtect.Visible = true; } else if ((vTopItem as DeItem).EditProtect) { mniDeleteProtect.Text = "取消只读"; mniDeleteProtect.Visible = true; } } } if ((vTopData as HCViewData).ActiveDomain.BeginNo >= 0) { mniDeGroup.Visible = true; mniDeGroup.Text = (vTopData.Items[(vTopData as HCViewData).ActiveDomain.BeginNo] as DeGroup)[DeProp.Name]; } else { mniDeGroup.Visible = false; } mniSplit.Visible = mniControlItem.Visible || mniDeItem.Visible || mniDeGroup.Visible; }