示例#1
0
        public static void ConvertLineEndingsInAllFiles()
        {
            DefaultSourceEditorOptions.Instance.LineEndingConversion = LineEndingConversion.ConvertAlways;
            foreach (var doc in DocumentRegistry.OpenFiles)
            {
                if (DocumentRegistry.SkipView(doc))
                {
                    continue;
                }
                var view = doc.GetContent <SourceEditorView> ();
                if (!view.SourceEditorWidget.HasIncorrectEolMarker)
                {
                    continue;
                }

                view.SourceEditorWidget.ConvertLineEndings();
                view.SourceEditorWidget.RemoveMessageBar();
                view.WorkbenchWindow.ShowNotification = false;
                view.Save();
            }
        }
示例#2
0
		public static async Task<Document> DownloadAndOpenAsync (StackFrame frame)
		{
			var symbolCachePath = UserProfile.Current.CacheDir.Combine ("Symbols");
			var sourceLink = frame.SourceLocation.SourceLink;

			var pm = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (
				GettextCatalog.GetString ("Downloading {0}", sourceLink.Uri),
				Stock.StatusDownload,
				true
			);

			Document doc = null;
			try {
				var downloadLocation = sourceLink.GetDownloadLocation (symbolCachePath);
				Directory.CreateDirectory (Path.GetDirectoryName (downloadLocation));
				DocumentRegistry.SkipNextChange (downloadLocation);

				var client = HttpClientProvider.CreateHttpClient (sourceLink.Uri);

				using (var stream = await client.GetStreamAsync (sourceLink.Uri).ConfigureAwait (false)) {
					using (var fs = new FileStream (downloadLocation, FileMode.Create))
						await stream.CopyToAsync (fs).ConfigureAwait (false);
				}

				frame.UpdateSourceFile (downloadLocation);

				int line = frame.SourceLocation.Line;

				doc = await Runtime.RunInMainThread (() => IdeApp.Workbench.OpenDocument (downloadLocation, null, line, 1, OpenDocumentOptions.Debugger));
			} catch (Exception ex) {
				LoggingService.LogInternalError ("Error downloading SourceLink file", ex);
			} finally {
				pm.Dispose ();
			}

			return doc;
		}
示例#3
0
        private void treeView1_DoubleClick(object sender, EventArgs e)
        {
            TreeNode selectedNode = treeView1.SelectedNode;

            //The path of the file double clicked is stored in the treenode's tag
            string path = selectedNode.Tag as string;

            if (!CanOpenDocument(path))
            {
                return;
            }
            TreeNode root    = GetRootNode(selectedNode);
            bool     FromVPK = root.Name == "vpk";

            TextDocument document = DocumentRegistry.GetDocumentFor(path) as TextDocument;

            if (document == null)
            {
                document = new TextDocument(path, FromVPK);
                DocumentRegistry.OpenDocument(path, document);
            }

            document.OpenDefaultEditor();
        }
示例#4
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = SelectedNode();

            if (node == null)
            {
                return;
            }
            DotaDataObject ddo = node.Tag as DotaDataObject;

            if (ddo == null)
            {
                return;              //It's a folder, we cant delete this.
            }
            if (ddo.ObjectInfo.ObjectClass == DotaDataObject.DataObjectInfo.ObjectDataClass.Default)
            {
                return;                                                                                      //Can't delete default objects
            }
            if (MessageBox.Show("Are you sure?  This cannot be undone", "Delete Object", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                //Get the document for this and close the editors
                Document doc = DocumentRegistry.GetDocumentFor(ddo);
                if (doc != null)
                {
                    doc.CloseAllEditors(false);
                }


                IList list = DotaData.FindListThatHasObject(ddo);
                list.Remove(ddo);

                //remove this node from the tree view
                node.Parent.Nodes.Remove(node);
                //And it's gone!
            }
        }