当前位置:网站首页 / vs2015 / 正文

[ay vs2015 sdk 开发][7]-Custom Tool Window跑不起来?AY可以

时间:2016年07月14日 | 作者 : aaronyang | 分类 : vs2015 | 浏览: 2571次 | 评论 0

新建一个vsix项目,AyFirstWindowProject项目

然后添加项,Custom Tool Window

取名:AyFirstWindow.cs


====================www.ayjs.net       杨洋    wpfui.com        ayui      ay  aaronyang=======请不要转载谢谢了。=========


我当前的vs2015 是update2版本,惊天bug

blob.png

vs自带的Custom Tool Window 模板有bug,因为图片是坏的。我们拿出以前建命令的图片替换,名字换成AyFirstWindowCommand.png

OK了。马蛋,我是vs2015开发国内算是第一人了。这个问题查了太久了。3个小时,也就上面一句话的事情。。不用谢



修改页面代码和后台

<UserControl x:Class="AyFirstWindowProject.AyFirstWindowControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             Background="{DynamicResource VsBrush.Window}"
             Foreground="{DynamicResource VsBrush.WindowText}"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300"
             Name="MyToolWindow">
    <Grid>
        <StackPanel Orientation="Vertical">
            <TextBlock Margin="10" HorizontalAlignment="Center">杨洋 第一个拓展窗口</TextBlock>
            <Button Content="单击AY的按钮" Click="button1_Click" Width="140" Height="80" Name="button1"/>
        </StackPanel>
    </Grid>
</UserControl>


后台如下:

//------------------------------------------------------------------------------
// <copyright file="AyFirstWindowControl.xaml.cs" company="Company">
//     Copyright (c) Company.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

namespace AyFirstWindowProject
{
    using System.Diagnostics.CodeAnalysis;
    using System.Windows;
    using System.Windows.Controls;

    /// <summary>
    /// Interaction logic for AyFirstWindowControl.
    /// </summary>
    public partial class AyFirstWindowControl : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AyFirstWindowControl"/> class.
        /// </summary>
        public AyFirstWindowControl()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Handles click on the button by displaying a message box.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        [SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions", Justification = "Sample code")]
        [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Default event handler naming pattern")]
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(
                 string.Format(System.Globalization.CultureInfo.CurrentUICulture, "触发了AY的按钮 '{0}'", this.ToString()),
                 "AYUI VS2015拓展");
        }
    }
}


打开FirstWindowPackage.vsct文件

    <Buttons>
      <!--To define a menu group you have to specify its ID, the parent menu and its display priority.
          The command is visible and enabled by default. If you need to change the visibility, status, etc, you can use
          the CommandFlag node.
          You can add more than one CommandFlag node e.g.:
              <CommandFlag>DefaultInvisible</CommandFlag>
              <CommandFlag>DynamicVisibility</CommandFlag>
          If you do not want an image next to your command, remove the Icon node /> -->
      <Button guid="guidAyFirstWindowPackageCmdSet" id="AyFirstWindowCommandId" priority="0x0100" type="Button">
        <Parent guid="guidSHLMainMenu" id="IDG_VS_WNDO_OTRWNDWS1"/>
        <Icon guid="guidImages" id="bmpPic1" />
        <Strings>
          <ButtonText>AYUI辅助窗口</ButtonText>
        </Strings>
      </Button>
    </Buttons>


Ok,运行项目,我们又找到了一个IDG_VS_WNDO_OTRWNDWS1这个菜单,视图-其他窗口

blob.png

效果图:


2.gif


OK了这篇文章看似很短,确是花了我很多时间,因为有bug

====================www.ayjs.net       杨洋    wpfui.com        ayui      ay  aaronyang=======请不要转载谢谢了。=========





推荐您阅读更多有关于“vs2015vsix开发,”的文章

猜你喜欢

额 本文暂时没人评论 来添加一个吧

发表评论

必填

选填

选填

必填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

  查看权限

抖音:wpfui 工作wpf,兴趣学习flutter

目前在合肥市某公司上班,已经厌弃,如果你的公司看的上我,加我QQ私聊

AYUI8全源码 Github地址:前往获取

杨洋(AaronYang简称AY,安徽六安人)AY唯一QQ:875556003和AY交流

高中学历,2010年开始web开发,2015年1月17日开始学习WPF

声明:AYUI7个人与商用免费,源码可购买。部分DEMO不免费

不是从我处购买的ayui7源码,我不提供任何技术服务,如果你举报从哪里买的,我可以帮你转正为我的客户,并送demo

查看捐赠

AYUI7.X MVC教程 更新如下:

第一课 第二课 程序加密教程

标签列表