Beispiel #1
0
        ///// <summary>
        ///// 设置容器元素的可见性
        ///// </summary>
        ///// <param name="visible">新的可见性</param>
        ///// <returns>操作是否成功</returns>
        //public bool EditorSetVisible(bool visible)
        //{
        //    bool result = false;
        //    bool oldVisible = this.Visible;
        //    if( oldVisible != visible )
        //    {
        //        this.Visible = visible;
        //        bool visible2 = this.Visible;
        //        if (visible2 == visible)
        //        {
        //            // 成功的修改了元素的可见性
        //            if (visible)
        //            {
        //                this.OwnerDocument.HighlightManager.InvalidateHighlightInfo(this);
        //            }
        //            else
        //            {
        //                this.OwnerDocument.HighlightManager.Remove(this);
        //            }
        //            result = true;
        //            XTextElement fc = this.FirstContentElement;
        //            XTextElement lc = this.LastContentElement;
        //            XTextContentElement content = this.ContentElement;
        //            int startIndex = 0;
        //            if (oldVisible)
        //            {
        //                startIndex = content.PrivateContent.IndexOf(fc);
        //            }
        //            this.UpdateContentVersion();
        //            content.UpdateContentElements(true);
        //            if (oldVisible == false)
        //            {
        //                startIndex = content.PrivateContent.IndexOf(fc);
        //            }
        //            content.RefreshPrivateContent(startIndex, -1, false);
        //        }
        //    }
        //    return result;
        //}

        /// <summary>
        /// 声明容器元素内容无效,需要重新排版
        /// </summary>
        public void EditorInvalidateContent()
        {
            DomContentElement ce = this.ContentElement;

            DomElement currentElementBack = this.DocumentContentElement.CurrentElement;
            //XTextElementList contentElements = new XTextElementList();
            //this.AppendContent(contentElements , true );

            DomElement firstElement = ce.PrivateContent.GetPreElement(this.FirstContentElement);

            if (firstElement == null)
            {
                firstElement = this.FirstContentElement;
            }
            DomElement lastElement = ce.PrivateContent.GetNextElement(this.LastContentElement);

            if (lastElement == null)
            {
                lastElement = ce.PrivateContent.LastElement;
            }
            // 声明所经过的文本行无效
            int endIndex = ce.PrivateContent.IndexOf(lastElement);

            for (int iCount = ce.PrivateContent.IndexOf(firstElement); iCount <= endIndex; iCount++)
            {
                if (ce.PrivateContent[iCount].OwnerLine != null)
                {
                    ce.PrivateContent[iCount].OwnerLine.InvalidateState = true;
                }
            }
            this.UpdateContentVersion();
            ce.UpdateContentElements(true);
            ce.RefreshPrivateContent(
                ce.PrivateContent.IndexOf(firstElement),
                ce.PrivateContent.IndexOf(lastElement),
                false);
            // 确认新的插入点的位置
            DomDocumentContentElement dce = this.DocumentContentElement;

            dce.RefreshGlobalLines();
            if (currentElementBack != null)
            {
                dce.Content.AutoClearSelection = true;
                dce.Content.LineEndFlag        = false;

                int newSelectionPosition = currentElementBack.ViewIndex;
                dce.Content.MoveSelectStart(newSelectionPosition);
            }
        }
Beispiel #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.SourceEventArgs != null && this.SourceEventArgs.Element is DomImageElement)
            {
                DomDocument     document = this.SourceEventArgs.Document;
                DomImageElement element  = (DomImageElement)this.SourceEventArgs.Element;
                element.OwnerDocument = document;
                bool   logUndo  = this.SourceEventArgs.LogUndo && document.CanLogUndo;
                bool   modified = false;
                string txt      = txtID.Text.Trim();
                if (txt.Length == 0)
                {
                    txt = null;
                }
                if (txt != element.ID)
                {
                    if (logUndo)
                    {
                        document.UndoList.AddProperty("ID", element.ID, txt, element);
                    }
                    element.ID = txt;
                    modified   = true;
                }

                txt = txtTitle.Text.Trim();
                if (txt.Length == 0)
                {
                    txt = null;
                }
                if (txt != element.Title)
                {
                    if (logUndo)
                    {
                        document.UndoList.AddProperty("Title", element.Title, txt, element);
                    }
                    element.Title = txt;
                    modified      = true;
                }

                txt = txtAlt.Text.Trim();
                if (txt.Length == 0)
                {
                    txt = null;
                }
                if (txt != element.Alt)
                {
                    if (logUndo)
                    {
                        document.UndoList.AddProperty("Alt", element.Alt, txt, element);
                    }
                    element.Alt = txt;
                    modified    = true;
                }

                txt = txtSource.Text.Trim();
                if (txt.Length == 0)
                {
                    txt = null;
                }
                if (txt != element.Source)
                {
                    if (logUndo)
                    {
                        document.UndoList.AddProperty("Source", element.Source, txt, element);
                    }
                    element.Source = txt;
                    modified       = true;
                    element.UpdateImageContent();
                }

                if (chkKeepWidthHeightRate.Checked != element.KeepWidthHeightRate)
                {
                    if (logUndo)
                    {
                        document.UndoList.AddProperty(
                            "KeepWidthHeightRate",
                            element.KeepWidthHeightRate,
                            chkKeepWidthHeightRate.Checked,
                            element);
                    }
                    element.KeepWidthHeightRate = chkKeepWidthHeightRate.Checked;
                    modified = true;
                }

                if (chkSaveContentInFile.Checked != element.SaveContentInFile)
                {
                    if (logUndo)
                    {
                        document.UndoList.AddProperty(
                            "SaveContentInFile",
                            element.SaveContentInFile,
                            chkSaveContentInFile.Checked,
                            element);
                    }
                    element.SaveContentInFile = chkSaveContentInFile.Checked;
                    modified = true;
                }

                if (picImage.Tag != element.Image)
                {
                    XImageValue img = (XImageValue)picImage.Tag;
                    if (img == null)
                    {
                        img = new XImageValue();
                    }
                    if (img.HasContent)
                    {
                        if (logUndo)
                        {
                            document.UndoList.AddProperty(
                                "Image",
                                element.Image,
                                img,
                                element);
                        }
                        element.Image = img;
                        modified      = true;
                    }
                }
                if (modified)
                {
                    SizeF oldSize = new SizeF(element.Width, element.Height);
                    element.UpdateSize();
                    SizeF newSize = new SizeF(element.Width, element.Height);
                    if (logUndo)
                    {
                        document.UndoList.AddProperty("Width", oldSize.Width, element.Width, element);
                        document.UndoList.AddProperty("Height", oldSize.Height, element.Height, element);
                    }
                }
                if (this.SourceEventArgs.Method == ElementEditMethod.Edit)
                {
                    if (modified)
                    {
                        element.UpdateContentVersion();
                        DomContentElement ce = element.ContentElement;
                        ce.SetLinesInvalidateState(
                            element.OwnerLine,
                            element.OwnerLine);
                        ce.UpdateContentElements(true);
                        element.SizeInvalid = true;
                        ce.RefreshPrivateContent(element.ViewIndex);
                        ContentChangedEventArgs args = new ContentChangedEventArgs();
                        args.Document        = element.OwnerDocument;
                        args.Element         = element;
                        args.LoadingDocument = false;
                        element.Parent.RaiseBubbleOnContentChanged(args);
                    }
                }
                else
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                this.Close();
            }
        }
Beispiel #3
0
        /// <summary>
        /// 设置容器元素的可见性
        /// </summary>
        /// <param name="visible">新的可见性</param>
        /// <param name="fastMode">是否启用快速模式,当使用快速模式时,
        /// 只更新DOM结构,不更新用户界面视图</param>
        /// <returns>操作是否成功</returns>
        public virtual bool EditorSetVisible(bool visible, bool fastMode)
        {
            bool result     = false;
            bool oldVisible = this.Visible;

            if (oldVisible != visible)
            {
                this.Visible = visible;
                bool visible2 = this.Visible;
                if (visible2 == visible)
                {
                    this.InvalidateView();
                    // 成功的修改了元素的可见性
                    if (visible)
                    {
                        this.OwnerDocument.HighlightManager.InvalidateHighlightInfo(this);
                    }
                    else
                    {
                        this.OwnerDocument.HighlightManager.Remove(this);
                    }
                    result = true;
                    DomElement        fc      = this.FirstContentElement;
                    DomElement        lc      = this.LastContentElement;
                    DomContentElement content = this.ContentElement;
                    int        startIndex     = 0;
                    DomElement preElement     = content.PrivateContent.GetPreElement(fc);
                    if (oldVisible)
                    {
                        startIndex = content.PrivateContent.IndexOf(fc);
                    }
                    this.UpdateContentVersion();
                    DomDocumentContentElement dce = this.DocumentContentElement;
                    DomElement currentElementBack = dce.CurrentElement;
                    content.UpdateContentElements(true);
                    if (oldVisible == false)
                    {
                        startIndex = content.PrivateContent.IndexOf(fc);
                    }
                    else
                    {
                        if (preElement != null && content.PrivateContent.Contains(preElement))
                        {
                            startIndex = content.PrivateContent.IndexOf(preElement);
                        }
                    }
                    content.RefreshPrivateContent(startIndex, -1, fastMode);
                    if (fastMode == false)
                    {
                        if (currentElementBack != null)
                        {
                            int index = dce.Content.IndexOf(currentElementBack);
                            if (index >= 0)
                            {
                            }
                        }
                    }
                }
            }
            return(result);
        }