Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Word.Document dc     = W_Bkm.Application.ActiveDocument;
            Word.Range    tmpRng = dc.Application.Selection.Range;
            //object mkname = mkd.Data[num].BQname.ToString();
            //Word.Range tmpRng = W_Bkm.get_Item(ref mkname).Range;
            object oRng = tmpRng;

            W_Bkm.Add(txtnew.Text.ToString(), ref oRng);
        }
Esempio n. 2
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            BM_Word = FrmGHBZTLContents.W_Doc;
            W_Bkm   = BM_Word.Bookmarks;
            if (BM_Word.Application.Selection.Range.Text == null)
            {
                MessageBox.Show("请选择添加书签的文本!");
                return;
            }
            if (txtMarkName.Text.Length == 0)
            {
                MessageBox.Show("请输入书签名称!");
                txtMarkName.Focus();
                return;
            }
            LayoutBookMark lbm = new LayoutBookMark();

            lbm.UID      = "B_M_" + lbm.UID;
            lbm.LayoutID = FrmGHBZTLContents.LayoutID;
            lbm.MarkName = txtMarkName.Text;
            lbm.MarkDisc = txtMarkDisc.Text;
            if (chbType.Checked)
            {
                lbm.MarkType = "程序员";
            }
            else
            {
                lbm.MarkType = "用户";
            }
            Word.Range tmpRng = BM_Word.Application.Selection.Range;
            if (tmpRng.Bookmarks.Count > 0)
            {
                MessageBox.Show(tmpRng.Text + " 已是书签或包含已有书签!");
                return;
            }
            object oRng = tmpRng;

            W_Bkm.Add(lbm.UID.ToString(), ref oRng);
            object markid = lbm.UID.ToString();

            Word.Bookmark tempbk = W_Bkm.get_Item(ref markid);
            tempbk.Range.Font.Color = Word.WdColor.wdColorBlue;
            lbm.StartP = tempbk.Start;
            if (tempbk.Range.Text.Length > 140)
            {
                lbm.MarkText = tempbk.Range.Text.Substring(0, 140);
            }
            else
            {
                lbm.MarkText = tempbk.Range.Text;
            }
            try
            {
                Common.Services.BaseService.Create <LayoutBookMark>(lbm);
            }
            catch (Exception)
            {
                throw;
            }
            FrmBookMark.Parentfrm.InitGrid2();
            FrmBookMark.Parentfrm.Refresh();
            MessageBox.Show("书签添加成功!");
            //保存word
            FrmGHBZTLContents.ParentForm.SaveData_Word();
            txtMarkName.Text = "";
            txtMarkDisc.Text = "";
            txtMarkName.Focus();
        }
Esempio n. 3
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            BM_Word = FrmGHBZTLContents.W_Doc;
            W_Bkm = BM_Word.Bookmarks;
            if (BM_Word.Application.Selection.Range.Text == null)
            {
                MessageBox.Show("��ѡ�������ǩ���ı�!");
                return;
            }
            if (txtMarkName.Text.Length == 0)
            {
                MessageBox.Show("��������ǩ����!");
                txtMarkName.Focus();
                return;
            }
            LayoutBookMark lbm = new LayoutBookMark();
            lbm.UID = "B_M_" + lbm.UID;
            lbm.LayoutID = FrmGHBZTLContents.LayoutID;
            lbm.MarkName = txtMarkName.Text;
            lbm.MarkDisc = txtMarkDisc.Text;
            if (chbType.Checked)
            {
                lbm.MarkType = "����Ա";
            }
            else
            {
                lbm.MarkType = "�û�";
            }
            Word.Range tmpRng = BM_Word.Application.Selection.Range;
            if (tmpRng.Bookmarks.Count > 0)
            {
                MessageBox.Show(tmpRng.Text + " ������ǩ�����������ǩ!");
                return;
            }
            object oRng = tmpRng;
            W_Bkm.Add(lbm.UID.ToString(), ref oRng);
            object markid = lbm.UID.ToString();
            Word.Bookmark tempbk = W_Bkm.get_Item(ref markid);
            tempbk.Range.Font.Color = Word.WdColor.wdColorBlue;
            lbm.StartP = tempbk.Start;
            if (tempbk.Range.Text.Length > 140)
            {
                lbm.MarkText = tempbk.Range.Text.Substring(0, 140);
            }
            else
            {
                lbm.MarkText = tempbk.Range.Text;
            }
            try
            {
                Common.Services.BaseService.Create<LayoutBookMark>(lbm);
            }
            catch (Exception)
            {

                throw;
            }
            FrmBookMark.Parentfrm.InitGrid2();
            FrmBookMark.Parentfrm.Refresh();
            MessageBox.Show("��ǩ��ӳɹ���");
            //����word
            FrmGHBZTLContents.ParentForm.SaveData_Word();
            txtMarkName.Text = "";
            txtMarkDisc.Text = "";
            txtMarkName.Focus();
        }