当前位置: 首页>>代码示例>>C#>>正文


C# CommandId类代码示例

本文整理汇总了C#中CommandId的典型用法代码示例。如果您正苦于以下问题:C# CommandId类的具体用法?C# CommandId怎么用?C# CommandId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CommandId类属于命名空间,在下文中一共展示了CommandId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (TextView != null)
            {
                string content = TextView.Selection.SelectedSpans[0].GetText();
                string extension = Path.GetExtension(_dte.ActiveDocument.FullName).ToLowerInvariant();
                string result = MinifyFileMenu.MinifyString(extension, content);

                if (!string.IsNullOrEmpty(result))
                {
                    if (result != content)
                    {
                        using (EditorExtensionsPackage.UndoContext(("Minify")))
                            TextView.TextBuffer.Replace(TextView.Selection.SelectedSpans[0].Span, result);
                    }
                    else
                    {
                        _dte.StatusBar.Text = "The selection was already minified";
                    }
                }
                else
                {
                    _dte.StatusBar.Text = "Could not minify the selection. Unsupported file type.";
                }
            }

            return true;
        }
开发者ID:vikramgoudr,项目名称:WebEssentials2013,代码行数:28,代码来源:MinifySelectionCommandTarget.cs

示例2: Execute

        protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            SnapshotPoint? point = TextView.Caret.Position.Point.GetPoint(TextView.TextBuffer, PositionAffinity.Predecessor);

            if (point.HasValue)
            {
                TextExtent wordExtent = _navigator.GetExtentOfWord(point.Value - 1);
                string wordText = TextView.TextSnapshot.GetText(wordExtent.Span);

                Find2 find = (Find2)EditorExtensionsPackage.DTE.Find;
                string types = find.FilesOfType;
                bool matchCase = find.MatchCase;
                bool matchWord = find.MatchWholeWord;

                find.WaitForFindToComplete = false;
                find.Action = EnvDTE.vsFindAction.vsFindActionFindAll;
                find.Backwards = false;
                find.MatchInHiddenText = true;
                find.MatchWholeWord = true;
                find.MatchCase = true;
                find.PatternSyntax = EnvDTE.vsFindPatternSyntax.vsFindPatternSyntaxLiteral;
                find.ResultsLocation = EnvDTE.vsFindResultsLocation.vsFindResults1;
                find.SearchSubfolders = true;
                find.FilesOfType = "*.js";
                find.Target = EnvDTE.vsFindTarget.vsFindTargetSolution;
                find.FindWhat = wordText;
                find.Execute();

                find.FilesOfType = types;
                find.MatchCase = matchCase;
                find.MatchWholeWord = matchWord;
            }

            return true;
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:35,代码来源:JavaScriptFindReferencesCommandTarget.cs

示例3: Execute

        protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            HtmlEditorDocument document = HtmlEditorDocument.FromTextView(_view);
            var tree = document.HtmlEditorTree;

            int start = _view.Selection.Start.Position.Position;
            int end = _view.Selection.End.Position.Position;

            ElementNode tag = null;
            AttributeNode attr = null;

            tree.GetPositionElement(start + 1, out tag, out attr);

            if (tag == null)
                return false;

            if (tag.EndTag != null && tag.StartTag.Start == start && tag.EndTag.End == end)
            {
                Select(tag.InnerRange.Start, tag.InnerRange.Length);
            }
            else if (tag.Parent != null && tag.Children.Count > 0 && (tag.Start != start || tag.Parent.Children.Last().End != end))
            {
                Select(tag.Children.First().Start, tag.Children.Last().End - tag.Children.First().Start);
            }
            else if (tag.Parent != null && tag.Parent.Children.First().Start == start && tag.Parent.Children.Last().End == end)
            {
                SelectCaretNode(tree, tag.Parent);
            }
            else if (tag.Children.Count > 0)
            {
                SelectCaretNode(tree, tag);
            }

            return true;
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:35,代码来源:ContractSelectionTarget.cs

示例4: AddCommand

 /// <summary>
 /// Adds the command with the specified id and callback.
 /// </summary>
 /// <param name="cmdId">The command unique identifier.</param>
 /// <param name="cmdCallback">The command callback.</param>
 private void AddCommand(CommandId cmdId, Action cmdCallback)
 {
     var cmd = new CommandID(Guids.PublishCmdSet, (int)cmdId);
     var menuCmd = new OleMenuCommand((s, e) => cmdCallback(), cmd);
     menuCmd.BeforeQueryStatus += BeforeQueryStatus;
     mcs.AddCommand(menuCmd);
 }
开发者ID:ivan-korshun,项目名称:VS-PublishExtensions2013,代码行数:12,代码来源:PublishMenu.cs

示例5: Execute

        protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            BrowserSelector selector = new BrowserSelector();
            selector.ShowDialog();

            return true;
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:7,代码来源:CssSelectBrowsers.cs

示例6: TryConvertToCommandKeyBindings

        private static bool TryConvertToCommandKeyBindings(string text, out List<CommandKeyBinding> bindingsList)
        {
            bindingsList = null;
            var list = new List<CommandKeyBinding>();
            var items = ConvertToList(text);
            if (items.Count % 4 != 0)
            {
                return false;
            }

            for (int i = 0; i < items.Count; i += 4)
            {
                Guid group;
                uint id;
                KeyBinding keyBinding;
                if (!Guid.TryParse(items[i], out group) ||
                    !UInt32.TryParse(items[i + 1], out id) ||
                    !KeyBinding.TryParse(items[i + 3], out keyBinding))
                {
                    return false;
                }

                var commandId = new CommandId(group, id);
                list.Add(new CommandKeyBinding(commandId, items[i + 2], keyBinding));
            }

            bindingsList = list;
            return true;
        }
开发者ID:Yzzl,项目名称:VsVim,代码行数:29,代码来源:SettingSerializer.cs

示例7: Execute

        protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            var point = TextView.GetSelection("LESS");
            if (point == null)
                return false;

            ITextBuffer buffer = point.Value.Snapshot.TextBuffer;
            var doc = CssEditorDocument.FromTextBuffer(buffer);
            ParseItem item = doc.StyleSheet.ItemBeforePosition(point.Value);
            ParseItem rule = FindParent(item);

            string text = item.Text;
            string name = Microsoft.VisualBasic.Interaction.InputBox("Name of the variable", "Web Essentials");

            if (string.IsNullOrEmpty(name))
                return false;

            using (EditorExtensionsPackage.UndoContext(("Extract to variable")))
            {
                buffer.Insert(rule.Start, "@" + name + ": " + text + ";" + Environment.NewLine + Environment.NewLine);

                Span span = TextView.Selection.SelectedSpans[0].Span;
                TextView.TextBuffer.Replace(span, "@" + name);
            }

            return true;
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:27,代码来源:LessExtractVariableCommandTarget.cs

示例8: Execute

        protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            IDataObject data = Clipboard.GetDataObject();
            ProjectItem item = ProjectHelpers.GetActiveFile();

            if (!data.GetDataPresent(DataFormats.Bitmap) || string.IsNullOrEmpty(item.ContainingProject.FullName))
                return false;

            string fileName = null;

            using (var dialog = new SaveFileDialog())
            {
                dialog.FileName = "file.png";
                dialog.DefaultExt = ".png";
                dialog.Filter = "Images|*.png;*.gif;*.jpg;*.bmp;";
                dialog.InitialDirectory = ProjectHelpers.GetRootFolder();

                if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return true;

                fileName = dialog.FileName;
            }

            SaveClipboardImageToFile(data, fileName);
            UpdateTextBuffer(fileName);

            Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
            {
                ProjectHelpers.AddFileToActiveProject(fileName);

            }), DispatcherPriority.ApplicationIdle, null);

            return true;
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:34,代码来源:PasteImageCommandTarget.cs

示例9: Execute

        protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            var point = TextView.GetSelection("CSS");
            if (point == null)
                return false;
            ITextSnapshot snapshot = point.Value.Snapshot;
            var doc = CssEditorDocument.FromTextBuffer(snapshot.TextBuffer);

            StringBuilder sb = new StringBuilder(snapshot.GetText());
            int scrollPosition = TextView.TextViewLines.FirstVisibleLine.Extent.Start.Position;

            using (EditorExtensionsPackage.UndoContext("Remove Duplicate Properties"))
            {
                int count;
                string result = RemoveDuplicateProperties(sb, doc, out count);
                Span span = new Span(0, snapshot.Length);
                snapshot.TextBuffer.Replace(span, result);

                var selection = EditorExtensionsPackage.DTE.ActiveDocument.Selection as TextSelection;
                selection.GotoLine(1);

                EditorExtensionsPackage.ExecuteCommand("Edit.FormatDocument");
                TextView.ViewScroller.ScrollViewportVerticallyByLines(ScrollDirection.Down, TextView.TextSnapshot.GetLineNumberFromPosition(scrollPosition));
                EditorExtensionsPackage.DTE.StatusBar.Text = count + " duplicate properties removed";
            }

            return true;
        }
开发者ID:vikramgoudr,项目名称:WebEssentials2013,代码行数:28,代码来源:CssRemoveDuplicatesCommandTarget.cs

示例10: Execute

        protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            var point = TextView.GetSelection("css");
            if (point == null) return false;

            ITextBuffer buffer = point.Value.Snapshot.TextBuffer;
            CssEditorDocument doc = CssEditorDocument.FromTextBuffer(buffer);
            ICssSchemaInstance rootSchema = CssSchemaManager.SchemaManager.GetSchemaRoot(null);

            StringBuilder sb = new StringBuilder(buffer.CurrentSnapshot.GetText());

            using (EditorExtensionsPackage.UndoContext("Add Missing Standard Property"))
            {
                string result = AddMissingStandardDeclaration(sb, doc, rootSchema);
                Span span = new Span(0, buffer.CurrentSnapshot.Length);
                buffer.Replace(span, result);

                var selection = EditorExtensionsPackage.DTE.ActiveDocument.Selection as TextSelection;
                selection.GotoLine(1);

                EditorExtensionsPackage.ExecuteCommand("Edit.FormatDocument");
            }

            return true;
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:25,代码来源:CssAddMissingStandardCommandTarget.cs

示例11: Execute

        protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (_broker.IsCompletionActive(TextView))
                return false;

            int position = TextView.Caret.Position.BufferPosition.Position;

            if (position == 0 || position == TextView.TextBuffer.CurrentSnapshot.Length || TextView.Selection.SelectedSpans[0].Length > 0)
                return false;

            char before = TextView.TextBuffer.CurrentSnapshot.GetText(position - 1, 1)[0];
            char after = TextView.TextBuffer.CurrentSnapshot.GetText(position, 1)[0];

            if (before == '{' && after == '}')
            {
                Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
                {
                    using (EditorExtensionsPackage.UndoContext("Smart Indent"))
                    {
                        // HACK: A better way is needed. 
                        // We do this to get around the native TS formatter
                        SendKeys.Send("{TAB}{ENTER}{UP}");
                    }
                }), DispatcherPriority.Normal, null);
            }

            return false;
        }
开发者ID:Nangal,项目名称:WebEssentials2013,代码行数:28,代码来源:TypeScriptSmartIndentCommandTarget.cs

示例12: Execute

        protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            var point = TextView.GetSelection("css");
            if (point == null) return false;

            ITextBuffer buffer = point.Value.Snapshot.TextBuffer;
            CssEditorDocument doc = CssEditorDocument.FromTextBuffer(buffer);
            ICssSchemaInstance rootSchema = CssSchemaManager.SchemaManager.GetSchemaRoot(null);

            StringBuilder sb = new StringBuilder(buffer.CurrentSnapshot.GetText());
            int scrollPosition = TextView.TextViewLines.FirstVisibleLine.Extent.Start.Position;

            using (EditorExtensionsPackage.UndoContext("Add Missing Vendor Specifics"))
            {
                int count;
                string result = AddMissingVendorDeclarations(sb, doc, rootSchema, out count);
                Span span = new Span(0, buffer.CurrentSnapshot.Length);
                buffer.Replace(span, result);

                var selection = EditorExtensionsPackage.DTE.ActiveDocument.Selection as TextSelection;
                selection.GotoLine(1);

                EditorExtensionsPackage.ExecuteCommand("Edit.FormatDocument");
                TextView.ViewScroller.ScrollViewportVerticallyByLines(ScrollDirection.Down, TextView.TextSnapshot.GetLineNumberFromPosition(scrollPosition));
                EditorExtensionsPackage.DTE.StatusBar.Text = count + " missing vendor specific properties added";
            }

            return true;
        }
开发者ID:vikramgoudr,项目名称:WebEssentials2013,代码行数:29,代码来源:CssAddVendorStandardCommandTarget.cs

示例13: Execute

        protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            var point = TextView.GetSelection("LESS");
            if (point == null)
                return false;

            var buffer = point.Value.Snapshot.TextBuffer;
            var doc = CssEditorDocument.FromTextBuffer(buffer);
            ParseItem item = doc.StyleSheet.ItemBeforePosition(point.Value);

            ParseItem rule = LessExtractVariableCommandTarget.FindParent(item);
            int mixinStart = rule.Start;
            string name = Microsoft.VisualBasic.Interaction.InputBox("Name of the Mixin", "Web Essentials");

            if (!string.IsNullOrEmpty(name))
            {
                using (EditorExtensionsPackage.UndoContext(("Extract to mixin")))
                {
                    string text = TextView.Selection.SelectedSpans[0].GetText();
                    buffer.Insert(rule.Start, "." + name + "() {" + Environment.NewLine + text + Environment.NewLine + "}" + Environment.NewLine + Environment.NewLine);

                    var selection = TextView.Selection.SelectedSpans[0];
                    TextView.TextBuffer.Replace(selection.Span, "." + name + "();");

                    TextView.Selection.Select(new SnapshotSpan(TextView.TextBuffer.CurrentSnapshot, mixinStart, 1), false);
                    EditorExtensionsPackage.ExecuteCommand("Edit.FormatSelection");
                    TextView.Selection.Clear();
                }

                return true;
            }

            return false;
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:34,代码来源:LessExtractMixinCommandTarget.cs

示例14: EventDescriptor

 public EventDescriptor(CommandId commandId, EntityId id, IEvent eventData, int entityVersion)
 {
     CommandId = commandId;
     EventData = eventData;
     Version = entityVersion;
     EntityId = id;
 }
开发者ID:dgmachado,项目名称:EventSourcingAndCQRSLib,代码行数:7,代码来源:EventDescriptor.cs

示例15: Execute

        protected override bool Execute(CommandId commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (_broker.IsCompletionActive(TextView) || !IsValidTextBuffer() || !WESettings.GetBoolean(WESettings.Keys.EnableEnterFormat))
                return false;

            int position = TextView.Caret.Position.BufferPosition.Position;
            SnapshotPoint point = new SnapshotPoint(TextView.TextBuffer.CurrentSnapshot, position);
            IWpfTextViewLine line = TextView.GetTextViewLineContainingBufferPosition(point);

            ElementNode element = null;
            AttributeNode attr = null;

            _tree.GetPositionElement(position, out element, out attr);

            if (element == null ||
                _tree.IsDirty ||
                element.Parent == null ||
                element.StartTag.Contains(position) ||
                line.End.Position == position || // caret at end of line (TODO: add ignore whitespace logic)
                TextView.TextBuffer.CurrentSnapshot.GetText(element.InnerRange.Start, element.InnerRange.Length).Trim().Length == 0)
                return false;

            UpdateTextBuffer(element);

            return false;
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:26,代码来源:EnterFormatCommandTarget.cs


注:本文中的CommandId类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。