مشاركة عبر


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

بشكل عام، عندما تقوم بتغيير مفاتيح الاختصار أمر، فإن الاختصار exهوting هو مفقودة. يوضح المثال التالي كيفية إلى يربط اختصارين جديدة إلى أمر وما زال الاحتفاظ بها موجودة.

إذا كنت تريد إلى عرض قائمة أوامر إلى gether اختصارات الحالي الخاصة بها، قم بتشغيل المثال ListKeyBindings كما في كيفية القيام بما يلي: عرض الروابط المفتاح موجود.

ملاحظة

قد تختلف مربعات الحوار وأوامر القائمة التى تشاهدها الان عن تلك الموصوفة في التعليمات اعتماداً على الإعدادات النشطة أو الإصدار الخاص بك. تم تطوير هذه الإجراءات من خلال "إعدادات تطوير عام" النشط. To change your settings, click Import and Export Settings on the Tools menu. لمزيد من المعلومات، راجع العمل مع إعدادات.

إلى إضافة اختصارات لوحة المفاتيح الجديدة وحفظ ملفات موجودة

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

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

  2. في الصفحة تحديد "اللغة برمجة" ، حدد أما إنشاء إضافة-باستخدام Visual C#‎ تشغيل #Visual Cالمثال التالي، أو إنشاء إضافة-باستخدام Visual أساسى ليعمل في Visual Basicالمثال.

  3. قم بلصق دالة المثال (تظهر لاحقاً في هذا الموضوع) في فئة اتصال التعليمة البرمجية التي تم إنشاؤها بواسطة Studio Visual Basic الوظيفة الإضافية معالج.

  4. إلى إنشاء نسخ من الافتراضي إعدادات لوحة المفاتيح، حدد موقع 10\Common7\IDE\C:\برنامج ملفات\Microsoft ‏‫Visual Studio.

  5. يمين-انقر واحد of the .vsk ملفات و then انقر نسخ.

  6. لصق النسخة في نفس المجلد، ومن ثم إعادة تسميته.

  7. للتحقق من.vsk الجديد ملف يظهر في قائمة اختصارات لوحة المفاتيح، في Visual Studioانقر فوق خيارات أدوات .

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

    تأكد من ظهور اسم الملف.vsk المحدد مسبقاً في القائمة يطبق مخطط تعيين لوحة المفاتيح الإضافية التالية.

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

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

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

  12. بنية the إضافة-في.

  13. إلى run the إضافة-في, انقر إضافة-في المدير تشغيل the أدوات قائمة, تحديد the إضافة-في you تاريخ الإنشاء, و انقر ‏‏موافق.

    The File.NewFile الأمر هو حدود إلى the جديد لوحة المفاتيح اختصارات, زر'Ctrl'+زر زر Alt+Shift زر+Y و زر'Ctrl'+زر زر Alt+Shift زر+U, و also إلى the الأصلي اختصارات.

مثال

The following إضافة-في مثال demonstrates how إلى يربط الثاني جديد لوحة المفاتيح اختصارات إلى a الأمر, و also preserve its موجود ones.

Sub PreserveBindings()
    ' Adds two new key bindings while preserving the existing ones.
    Dim cmds As Commands
    Dim cmd As Command
    Dim props As EnvDTE.Properties = DTE.Properties("Environment", _
    "Keyboard")
    Dim prop As EnvDTE.Property
    Dim bindings() As Object
    Dim bindingNumber As Integer

    ' Set references to the Commands collection and the File.NewFile
    ' command.
    cmds = DTE.Commands
    cmd = cmds.Item("File.NewFile")
    ' Make a writeable copy of the default keymapping scheme.
    prop = props.Item("SchemeName")
    prop.Value = "<FileName.vsk>"
    ' Retrieve the current bindings for the command.
    bindings = cmd.Bindings
    ' Get the number of bindings for the command.
    bindingNumber = bindings.Length
    ' Add two more elements to the array to accomodate two
    ' new commands.
    ReDim Preserve bindings(bindingNumber + 1)
    ' Add the new bindings to the existing ones in the array.
    bindings(bindingNumber) = "Global::CTRL+ALT+SHIFT+Y"
    bindings(bindingNumber + 1) = "Global::CTRL+ALT+SHIFT+U"
    ' Assign the contents of the bindings array to the Bindings 
    ' property.
    cmd.Bindings = bindings
End Sub
public void OnConnection(object application,
 Extensibility.ext_ConnectMode connectMode, object addInInst, ref
 System.Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.
    PreserveBindings((_applicationObject); 
}

// Add-in example for TextSelection.FindPattern.
// Also shows usage of these methods and properties:
//    TextSelection.SelectLine
public void PreserveBindings( DTE dte ) 
{ 
    // Adds two new key bindings while preserving the existing ones.
    Commands cmds = null; 
    Command cmd = null; 
    EnvDTE.Properties props = dte.get_Properties( "Environment",
 "Keyboard"); 
    EnvDTE.Property prop = null; 
    Object[] bindings = null; 
    int bindingNumber = 0; 

    //  Set references to the Commands collection and the File.NewFile
    //  command.
    cmds = dte.Commands; 
    cmd = cmds.Item( "File.NewFile", -1 ); 
    // Make a writeable copy of the default keymapping scheme.
    prop = props.Item( "SchemeName" ); 
    prop.Value = "<FileName.vsk>"; 
    // Retrieve the current bindings for the command.
    bindings = ( ( System.Object[] )( cmd.Bindings ) ); 
    // Get the number of bindings for the command.
    bindingNumber = bindings.Length; 
    // Add two more elements to the array to accomodate two
    // new commands.
    // Create temp variable for copying values. 
    // Arrays are zero-based in C#‎.
    object[] temp = new object[ bindingNumber + 2 ]; 
    System.Array.Copy( bindings, temp, Math.Min( bindings.Length,
 temp.Length ) ); 
    bindings = temp; 
    // Add the new bindings to the existing ones in the array.
    bindings[ bindingNumber ] = "Global::CTRL+ALT+SHIFT+Y"; 
    bindings[ bindingNumber+1 ] = "Global::CTRL+ALT+SHIFT+U"; 
    // Assign the contents of the bindings array to the Bindings 
    // property.
    cmd.Bindings = bindings; 
}

راجع أيضًا:

المهام

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

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

المبادئ

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

موارد أخرى

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