<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>AutoCAD综合 - 中文论坛中的主题 回复： 使用RibbonPanelBreak创建Slide-Out Panel遇到的问题</title>
    <link>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9763946#M6513</link>
    <description>&lt;P&gt;You probably already know: for recent versions of AutoCAD (Acad2014, or 2015 and later), You can simply call&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Application.MainWindow.Focus()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;instead of Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView() (I guess Autodesk just added this functionality from Internal namespace to Application class).&lt;/P&gt;</description>
    <pubDate>Wed, 23 Sep 2020 15:41:26 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2020-09-23T15:41:26Z</dc:date>
    <item>
      <title>使用RibbonPanelBreak创建Slide-Out Panel遇到的问题</title>
      <link>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9760673#M6509</link>
      <description>&lt;P&gt;Win7 简体中文版&lt;/P&gt;
&lt;P&gt;Autocad civil 3d 2018简体中文版&lt;/P&gt;
&lt;P&gt;Visual studio 2015社区版&lt;/P&gt;
&lt;P&gt;C#语言&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;如下图，&lt;/P&gt;
&lt;P&gt;使用RibbonPanelBreak分隔，&lt;/P&gt;
&lt;P&gt;创建Slide-Out Panel（我不知道这个描述是否准确）。&lt;/P&gt;
&lt;DIV id="tinyMceEditor465340553_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tinyMceEditor465340553_1" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;按钮能够正常创建，&lt;/P&gt;
&lt;P&gt;命令也能正常发送。&lt;/P&gt;
&lt;P&gt;上图中的按钮“图形清理1”工作一切正常。&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;问题出在点击Slide-Out Panel部分的按钮时，&lt;/P&gt;
&lt;P&gt;例如上图中的“图形清理2”（调用的map 3d的命令mapclean），&lt;/P&gt;
&lt;P&gt;对话框弹出后，&lt;/P&gt;
&lt;P&gt;如果此时autocad失去焦点，&lt;/P&gt;
&lt;P&gt;比如切换到其他程序或者这桌面点击鼠标等，&lt;/P&gt;
&lt;P&gt;弹出的对话框会“消失”，&lt;/P&gt;
&lt;P&gt;从而造成AutoCAD被卡死。&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="02.png" style="width: 790px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/822116iCC91538CA70134A1/image-size/large?v=v2&amp;amp;px=999" role="button" title="02.png" alt="02.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;我注意到AutoCAD自带的Ribbon，&lt;/P&gt;
&lt;P&gt;其Slide-Out部分在鼠标点击后，&lt;/P&gt;
&lt;P&gt;会慢慢消失，&lt;/P&gt;
&lt;P&gt;而我创建的ribbon中的Slide-Out部分在鼠标点击并弹出对话框后，&lt;/P&gt;
&lt;P&gt;它一直在那里（如下图），&lt;/P&gt;
&lt;P&gt;直到对话框关闭，&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="03.png" style="width: 878px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/822117iFEBD35A9B04D538E/image-size/large?v=v2&amp;amp;px=999" role="button" title="03.png" alt="03.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;最初发现此问题是我自己设计的对话框工作不正常，&lt;/P&gt;
&lt;P&gt;以为自己的对话框语有问题，&lt;/P&gt;
&lt;P&gt;折腾了很长时间，&lt;/P&gt;
&lt;P&gt;后来对其他对话框进行测试，&lt;/P&gt;
&lt;P&gt;发现位于Slide-Out部分的按钮弹出的对话框有问题，&lt;/P&gt;
&lt;P&gt;才意识到问题不是出在对话框本身，&lt;/P&gt;
&lt;P&gt;而是我创建的ribbon有问题。&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;我不清楚应该怎样修改我的代码，&lt;/P&gt;
&lt;P&gt;麻烦指点一下。&lt;/P&gt;
&lt;P&gt;谢谢！&lt;/P&gt;
&lt;P&gt;下面是我的代码。&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;// (C) Copyright 2019 by  
//
using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Collections;
using System.Runtime.CompilerServices;
using Autodesk.Civil.DatabaseServices;
using Autodesk.Windows;

// This line is not mandatory, but improves loading performances
//[assembly: CommandClass(typeof(AutoCAD_CSharp_plug_in1.MyCommands))]

namespace AutoCAD_CSharp_plug_in1
{

    // This class is instantiated by AutoCAD for each document when
    // a command is called by the user the first time in the context
    // of a given document. In other words, non static data in this class
    // is implicitly per-document!
    public class MyCommands
    {
        // The CommandMethod attribute can be applied to any public  member 
        // function of any public class.
        // The function should take no arguments and return nothing.
        // If the method is an intance member then the enclosing class is 
        // intantiated for each document. If the member is a static member then
        // the enclosing class is NOT intantiated.
        //
        // NOTE: CommandMethod has overloads where you can provide helpid and
        // context menu.

        

        /// &amp;lt;summary&amp;gt;
        /// 2020年9月22日 UserName:Line
        /// 
        /// &amp;lt;/summary&amp;gt;
        [CommandMethod("RibbonTest", "RibbonTest", "RibbonTest", CommandFlags.Modal, null, "RibbonTest", "IDH_RibbonTest")]
        public void C_RibbonTest()
        {
            RibbonControl ribbon = ComponentManager.Ribbon;
            if (ribbon != null)
            {
                RibbonTab rtab = ribbon.FindTab("测试");
                if (rtab != null)
                {
                    ribbon.Tabs.Remove(rtab);
                }
                rtab = new RibbonTab();
                rtab.Title = "测试";
                rtab.Id = "测试ing";
                //Add the Tab
                ribbon.Tabs.Add(rtab);
                addContent(rtab);

            }
        }

        private void addContent(RibbonTab rtab)
        {
            rtab.Panels.Add(AddOnePanel());
        }

        private RibbonPanel AddOnePanel()
        {
            RibbonButton rb;
            RibbonPanelSource rps = new RibbonPanelSource();
            rps.Title = "测试1";
            RibbonPanel rp = new RibbonPanel();
            rp.Source = rps;
            


            rb = new RibbonButton();
            rb.Name = "图形清理1";
            rb.ShowText = true;
            rb.Text = "图形清理1";
            rb.CommandHandler= new RibbonbtnCmdHandle();
            rb.CommandParameter = "_.MapClean ";

            rps.Items.Add(rb);
            rps.Items.Add(new RibbonPanelBreak());

            RibbonRowPanel rrp = new RibbonRowPanel();
            rps.Items.Add(rrp);

            rb = new RibbonButton();
            rb.Name = "图形清理2";
            rb.ShowText = true;
            rb.Text = "图形清理2";
            rb.CommandHandler = new RibbonbtnCmdHandle();
            rb.CommandParameter = "_.MapClean ";

            rrp.Items.Add(rb);

            return rp;
        }
        class RibbonbtnCmdHandle : System.Windows.Input.ICommand
        {
            public event EventHandler CanExecuteChanged;
            public bool CanExecute(object parameter)
            {
                return true;
            }
            public void Execute(object parameter)
            {
                if (parameter is RibbonButton)
                {
                    RibbonButton rb = parameter as RibbonButton;
                    Application.DocumentManager.MdiActiveDocument.SendStringToExecute(
                        (string)rb.CommandParameter, true, false, false);
                }
            }
        }
    }
}

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 09:45:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9760673#M6509</guid>
      <dc:creator>465340553</dc:creator>
      <dc:date>2020-09-22T09:45:33Z</dc:date>
    </item>
    <item>
      <title>回复： 使用RibbonPanelBreak创建Slide-Out Panel遇到的问题</title>
      <link>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9762807#M6510</link>
      <description>&lt;P&gt;经过网友edata的测试，&lt;/P&gt;
&lt;P&gt;我被搞的更晕了，&lt;/P&gt;
&lt;P&gt;感觉问题远比想象的复杂。&lt;/P&gt;
&lt;P&gt;增加两个autocad的命令进行测试，&lt;/P&gt;
&lt;P&gt;style和insert，&lt;/P&gt;
&lt;P&gt;发现style命令没有问题，&lt;/P&gt;
&lt;P&gt;对话框弹出后，&lt;/P&gt;
&lt;P&gt;滑出面板会消失，&lt;/P&gt;
&lt;P&gt;对话框能正常工作，&lt;/P&gt;
&lt;P&gt;但insert命令仍存在问题，&lt;/P&gt;
&lt;P&gt;对话框弹出后，&lt;/P&gt;
&lt;P&gt;滑出面板不消失，&lt;/P&gt;
&lt;P&gt;autocad失去焦点后对话框消失，&lt;/P&gt;
&lt;P&gt;autocad卡死。&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="465340553_0-1600844089791.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/822516i38696E370AE0EFB3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="465340553_0-1600844089791.png" alt="465340553_0-1600844089791.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;下面是我增加button的代码：&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt; rrp.Items.Add(new RibbonRowBreak());
 rb = new RibbonButton();
 rb.Name = "样式";
 rb.ShowText = true;
 rb.Text = "样式";
 rb.CommandHandler = new RibbonbtnCmdHandle();
 rb.CommandParameter ="_.style ";

 rrp.Items.Add(rb);

 rrp.Items.Add(new RibbonRowBreak());

 rb = new RibbonButton();
 rb.Name = "插入";
 rb.ShowText = true;
 rb.Text = "插入";
 rb.CommandHandler = new RibbonbtnCmdHandle();
 rb.CommandParameter ="_.insert ";

 rrp.Items.Add(rb);
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tinyMceEditor_8cbf009812693465340553_1" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 07:22:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9762807#M6510</guid>
      <dc:creator>465340553</dc:creator>
      <dc:date>2020-09-23T07:22:20Z</dc:date>
    </item>
    <item>
      <title>回复： 使用RibbonPanelBreak创建Slide-Out Panel遇到的问题</title>
      <link>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9762847#M6511</link>
      <description>&lt;P&gt;补充：&lt;/P&gt;
&lt;P&gt;如果把滑出面板钉住，&lt;/P&gt;
&lt;P&gt;对话框就不会消失。&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="465340553_0-1600845849413.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/822530i72B1E46F35177C0E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="465340553_0-1600845849413.png" alt="465340553_0-1600845849413.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 07:24:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9762847#M6511</guid>
      <dc:creator>465340553</dc:creator>
      <dc:date>2020-09-23T07:24:35Z</dc:date>
    </item>
    <item>
      <title>回复： 使用RibbonPanelBreak创建Slide-Out Panel遇到的问题</title>
      <link>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9762969#M6512</link>
      <description>&lt;P&gt;网友edata帮我解决了问题，&lt;/P&gt;
&lt;P&gt;切换了一下焦点，&lt;/P&gt;
&lt;P&gt;问题解决！&lt;/P&gt;
&lt;P&gt;在此向edata表示感谢！&lt;/P&gt;
&lt;P&gt;他的博客地址&lt;A href="https://www.cnblogs.com/edata/" target="_blank" rel="noopener"&gt;在此&lt;/A&gt;。&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="图片.png" style="width: 839px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/822565i5427E059E3CAADCD/image-size/large?v=v2&amp;amp;px=999" role="button" title="图片.png" alt="图片.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 08:37:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9762969#M6512</guid>
      <dc:creator>465340553</dc:creator>
      <dc:date>2020-09-23T08:37:10Z</dc:date>
    </item>
    <item>
      <title>回复： 使用RibbonPanelBreak创建Slide-Out Panel遇到的问题</title>
      <link>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9763946#M6513</link>
      <description>&lt;P&gt;You probably already know: for recent versions of AutoCAD (Acad2014, or 2015 and later), You can simply call&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Application.MainWindow.Focus()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;instead of Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView() (I guess Autodesk just added this functionality from Internal namespace to Application class).&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 15:41:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9763946#M6513</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2020-09-23T15:41:26Z</dc:date>
    </item>
    <item>
      <title>回复： 使用RibbonPanelBreak创建Slide-Out Panel遇到的问题</title>
      <link>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9764758#M6514</link>
      <description>&lt;P&gt;谢谢！&lt;/P&gt;
&lt;P&gt;我试试看！&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 00:09:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-zong-he-zhong-wen-lun-tan/shi-yongribbonpanelbreak-chuang-jianslide-out-panel-yu-dao-de-wen-ti/m-p/9764758#M6514</guid>
      <dc:creator>465340553</dc:creator>
      <dc:date>2020-09-24T00:09:22Z</dc:date>
    </item>
  </channel>
</rss>

