示例#1
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            PropertyDescriptor property = context.DataContext.GetProperties()[WordCreate.GetWordAppTag];
            Application        wordApp  = property.GetValue(context.DataContext) as Application;

            try
            {
                string linkName = LinkName.Get(context);
                string linkMark = LinkMark.Get(context);
                string linkAddr = LinkAddr.Get(context);
                string bookMark = BookMark.Get(context);
                string pic      = Pic.Get(context);

                if (linkName != null)
                {
                    Hyperlinks links = wordApp.Selection.Hyperlinks;
                    links.Add(wordApp.Selection.Range, linkAddr, linkMark, "", linkName, linkMark);
                }
                if (bookMark != null)
                {
                    Bookmarks bookmarks = wordApp.Selection.Bookmarks;
                    bookmarks.Add(bookMark);
                }
                if (pic != null)
                {
                    InlineShapes lineshapes = wordApp.Selection.InlineShapes;
                    InlineShape  lineshape  = lineshapes.AddPicture(pic);
                }
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "Word执行过程出错", e.Message);
                CommonVariable.realaseProcessExit(wordApp);
            }

            m_Delegate = new runDelegate(Run);
            return(m_Delegate.BeginInvoke(callback, state));
        }