مشاركة عبر


كيفية القيام بما يلي: يربط الأمر إلى عدة اختصارات لوحة المفاتيح

يمكنك يربط المزيد مفتاح الاختصار لأمر. This can be useful when, for مثال, الثاني users who are working تشغيل a مشروع each prefer a different اختصار for the same الأمر. This ربط هو accomplished بواسطة passing the اختصارات كـ سلسلة عناصر في an مصفوفه من نوع Object.

ملاحظة

قد يعرض جهاز الكمبيوتر الخاص بك أسماء أو مواقع مختلفة لبعض عناصر واجهة مستخدم Visual Studio في الإرشادات التالية. يحدد كل من إصدار Visual Studio لديك والإعدادات المستخدمة هذه العناصر. لمزيد من المعلومات، راجع العمل مع إعدادات.

إلى يربط a الأمر إلى multiple لوحة المفاتيح اختصارات

  1. استخدم the ‏‫Visual Studio وظيفة إضافية لـ معالج إلى إنشاء a إضافة-في. اسم مشروع وانقر فوق ‏‏موافق إلى يبدأ معالج.

    For المزيد معلومات حول how إلى استخدم the ‏‫Visual Studio وظيفة إضافية لـ معالج, see كيفية القيام بما يلي: قم بإنشاء إضافة-في.

  2. تشغيل the تحديد a Programming اللغة الصفحة, تحديد either إنشاء an إضافة-في using Visual C#‎ إلى run the #Visual C مثال في this موضوع, أو إنشاء an إضافة-في Using Visual أساسى إلى run the Visual Basic مثال.

  3. لصق the مثال دالة في the Connect فئة of the تعليمات برمجية that هو generated بواسطة the ‏‫Visual Studio وظيفة إضافية لـ معالج.

  4. لإنشاء نسخة من إعدادات لوحة المفاتيح الافتراضية، انتقل إلى \برنامج ملفات\Microsoft ‏‫Visual Studio 10\Common7\IDE\. يمين-انقر واحد of the .vsk ملفات و then انقر نسخ. لصق the نسخ في the same مجلد. النسخة هو يسمى "نسخ اسم الملف.vsk .

  5. إعادة تسمية the نسخ of the ملف.

  6. إلى verify that the جديد .vsk ملف appears في the لوحة المفاتيح bindings list, في Visual Studio انقر خيارات تشغيل the أدوات قائمة.

  7. في الجزء الأيمن من خيارات مربع حوار وقم بتوسيع المجلد البيئة وحدد لوحة المفاتيح .

    Ensure that the اسم of the .vsk ملف that you تمت إعادة التسمية earlier appears في the يطبق the following إضافى مخطط تعيين لوحة المفاتيح قائمة.

  8. قبل you تشغيل the إضافة-في مثال, make sure that the لوحة المفاتيح bindings are التعيين إلى (الافتراضي). يمكنك القيام بذلك بالنقر فوق إعادة تعيين في الجزء لوحة المفاتيح من خيارات مربع حوار.

  9. في the prop.Value = "< Filename.vsk>" step of the إضافة-في مثال, استبدال <Filename.vsk> بواسطة using the جديد لوحة المفاتيح scheme اسم that you specified earlier.

  10. يتصل the دالة من the OnConnection أسلوب, كـ described في كيفية القيام بما يلي: ترجمة و تشغيل أمثلة تعليمات برمجية طراز كائن للتنفيذ التلقائي.

  11. بنية the إضافة-في, و then run it بواسطة clicking إضافة-في المدير تشغيل the أدوات قائمة, selecting the إضافة-في you تاريخ الإنشاء, و then clicking ‏‏موافق.

    The الأمر هو حدود إلى الثاني different اختصار مفاتيح. ضغط either زر'Ctrl'+Shift زر+زر زر Alt+Y أو زر'Ctrl'+Shift زر+زر زر Alt+X إلى عرض the جديد ملف حوار صندوق.

مثال

The following مثال replaces the موجود لوحة المفاتيح اختصار بواسطة using الثاني جديد ones.

Public Sub OnConnection(ByVal application As Object, ByVal _
connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    BindSingle(_applicationObject)
End Sub
Sub BindSingle(ByVal dte As DTE2)
    ' Adds two new keybindings to a command.
    Dim cmds As Commands
    Dim cmd As Command
    Dim props As EnvDTE.Properties = DTE.Properties("Environment", _"Keyboard")
    Dim prop As EnvDTE.Property
    Dim bindings(1) As Object

    ' Make a writeable copy of the default keymapping scheme.
    prop = props.Item("SchemeName")
    prop.Value = "<FileName.vsk>"
    ' Assign the two shortcut key combinations, CTRL+SHIFT+ALT+Y and 
    ' CTRL+SHIFT+ALT+X, to the two bindings array elements. 
    bindings(0) = "Global:: CTRL+SHIFT+ALT+Y"
    bindings(1) = "Global:: CTRL+SHIFT+ALT+X"
    ' Set references to the Commands collection and the File.NewFile
    ' command.
    cmds = DTE.Commands
    cmd = cmds.Item("File.NewFile")
    ' Assign the contents of the bindings array to the Bindings 
    ' property.
    cmd.Bindings = bindings
End Sub
public void OnConnection(object application,
 ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.
    BindMultiple(_applicationObject ); 
}

public void BindMultiple( DTE2 dte ) 
{ 
    // Adds two new keybindings to a command.
    Commands cmds = null; 
    Command cmd = null; 
    EnvDTE.Properties props = dte.get_Properties( "Environment",
 "Keyboard"); 
    EnvDTE.Property prop = null; 
    Object[] bindings = new Object[ 2 ]; 

    // Make a writeable copy of the default keymapping scheme.
    prop = props.Item( "SchemeName" ); 
    prop.Value = "<FileName.vsk>"; 
    // Assign the two shortcut key combinations, CTRL+SHIFT+ALT+Y and 
    // CTRL+SHIFT+ALT+X, to the two bindings array elements. 
    bindings[ 0 ] = "Global:: CTRL+SHIFT+ALT+Y"; 
    bindings[ 1 ] = "Global:: CTRL+SHIFT+ALT+X"; 
    // Set references to the Commands collection and the File.NewFile
    // command.
    cmds = dte.Commands; 
    cmd = cmds.Item( "File.NewFile", -1 ); 
    // Assign the contents of the bindings array to the Bindings 
    // property.
    cmd.Bindings = bindings; 
} 

راجع أيضًا:

المهام

كيفية القيام بما يلي: يربط الأمر إلى المفتاح اختصار مفرد

كيفية القيام بما يلي: المحافظة على اختصارات لوحة المفاتيح موجود

المبادئ

تنسيق معلمة خاصية الربط

موارد أخرى

ربط إضافة-في الأوامر إلى مفاتيح