Exemplo n.º 1
0
		public void InsertFile(IMainForm mainForm, Project project, string path, 
			string textToInsert)
		{
			bool isInjectionTarget = (project.UsesInjection && 
				path == project.GetAbsolutePath(project.InputPath));

			if (!project.IsLibraryAsset(path) && !isInjectionTarget)
			{
				string caption = "Insert Resource";
				string message = "In order to use this file in your project, "
					+ "you must first embed it as a resource.  "
					+ "Would you like to do this now?";

				DialogResult result = MessageBox.Show(owner, message, caption,
					MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

				if (result == DialogResult.OK)
					ToggleLibraryAsset(project,new string[]{path});
				else
					return; // cancel
			}

			if (textToInsert == null)
				textToInsert = project.GetAsset(path).ID;

			if (mainForm.CurSciControl != null)
			{
				mainForm.CurSciControl.AddText(textToInsert.Length, textToInsert);
				mainForm.CurSciControl.Focus();
			}
			else ErrorHandler.ShowInfo("You must have a document open to insert a resource string.");
		}
Exemplo n.º 2
0
		public void AddLibraryAsset(Project project, string inDirectory)
		{
			OpenFileDialog dialog = new OpenFileDialog();
			dialog.Title = "Add Library Asset";
			dialog.Filter = "All files (*.*)|*.*";
			dialog.Multiselect = false;
			
			if (dialog.ShowDialog() == DialogResult.OK)
			{
				string filePath = CopyFile(dialog.FileName,inDirectory);

				// null means the user cancelled
				if (filePath == null) return;

				// add as an asset
				project.SetLibraryAsset(filePath,true);

				// ask if you want to keep this file updated
				string caption = "FlashDevelop";
				string message = "Would you like to keep this file updated from the source "
					+ "location?  (You can always change this in the 'Options' context menu)";

				DialogResult result = MessageBox.Show(owner,message,caption,
					MessageBoxButtons.YesNo,MessageBoxIcon.Question);

				if (result == DialogResult.Yes)
				{
					LibraryAsset asset = project.GetAsset(filePath);
					asset.UpdatePath = project.GetRelativePath(dialog.FileName);
				}

				project.Save();
				OnProjectModified(new string[]{filePath});
			}
		}