Exemplo n.º 1
0
        private void BeforeQueryStatus(object sender, EventArgs e)
        {
            OleMenuCommand button = (OleMenuCommand)sender;

            button.Enabled = button.Visible = false;

            var item = ProjectHelpers.GetSelectedItems().FirstOrDefault();

            if (item == null || item.FileCount == 0)
            {
                return;
            }

            string file = item.FileNames[1];

            button.Enabled = button.Visible = CommandHelpers.IsFileSupported(file);
        }
Exemplo n.º 2
0
        public bool IsDropEnabled(DragDropInfo dragDropInfo)
        {
            _fileName = GetImageFilename(dragDropInfo);

            if (string.IsNullOrEmpty(_fileName) || !CommandHelpers.IsFileSupported(_fileName) || VSPackage._dte.ActiveDocument == null)
            {
                return(false);
            }

            string activeFile = Path.GetFileName(VSPackage._dte.ActiveDocument.FullName);

            if (Constants.FILENAME.Equals(activeFile, StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public DragDropPointerEffects HandleDataDropped(DragDropInfo dragDropInfo)
        {
            ITextDocument document;

            if (!_documentFactory.TryGetTextDocument(_view.TextDataModel.DocumentBuffer, out document))
            {
                return(DragDropPointerEffects.None);
            }

            var    snapshot      = _view.TextBuffer.CurrentSnapshot;
            string bufferContent = snapshot.GetText();
            var    json          = CommandHelpers.GetJsonContent(document.FilePath, _fileName, bufferContent);

            using (var edit = _view.TextBuffer.CreateEdit())
            {
                edit.Replace(0, snapshot.Length, json.ToString());
                edit.Apply();
            }

            return(DragDropPointerEffects.Link);
        }