コード例 #1
0
ファイル: FileManagement.cs プロジェクト: DinrusGroup/D-IDE
			/// <summary>
			/// Opens a new-source dialog
			/// </summary>
			public static bool AddNewSourceToProject(Project Project, string RelativeDir)
			{
				var sdlg = new NewSrcDlg();
				if (sdlg.ShowDialog().Value)
				{
					var file = (String.IsNullOrEmpty(RelativeDir) ? "" : (RelativeDir + "\\")) + sdlg.FileName;
					var absFile = Project.BaseDirectory + "\\" + file;

					if (File.Exists(absFile))
						return false;

					if (Project.Add(file)!=null)
					{
						// Set standard encoding to UTF8
						File.WriteAllText(absFile, "",Encoding.UTF8);
						Project.Save();
						Instance.UpdateGUI();
						return true;
					}
				}
				return false;
			}
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: DinrusGroup/D-IDE
		/// <summary>
		/// Create a source file that is unrelated to any open project or solution
		/// </summary>
		private void NewSource(object sender, RoutedEventArgs e)
		{
			var sdlg = new NewSrcDlg();
			if (sdlg.ShowDialog().Value)
			{
				foreach (var lang in LanguageLoader.Bindings)
					if (lang.CanHandleFile(sdlg.FileName))
					{
						var ed = lang.OpenFile(null, sdlg.FileName);

						// If language won't handle file anyway, just put it inside a neutral document
						if (ed == null)
							ed = new EditorDocument(sdlg.FileName);

						ed.Show(DockMgr);
						ed.Activate();
						return;
					}

				var _ed = new EditorDocument(sdlg.FileName);
				_ed.Show(DockMgr);
				_ed.Activate();
			}
		}