本文整理汇总了C#中IWorkspaceFileObject类的典型用法代码示例。如果您正苦于以下问题:C# IWorkspaceFileObject类的具体用法?C# IWorkspaceFileObject怎么用?C# IWorkspaceFileObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IWorkspaceFileObject类属于命名空间,在下文中一共展示了IWorkspaceFileObject类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RenameItem
public static void RenameItem (IWorkspaceFileObject item, string newName)
{
if (newName == item.Name)
return;
if (!NewProjectConfiguration.IsValidSolutionName (newName)) {
MessageService.ShowError (GettextCatalog.GetString ("Illegal project name.\nOnly use letters, digits, space, '.' or '_'."));
return;
}
FilePath oldFile = item.FileName;
string oldName = item.Name;
FilePath newFile = oldFile.ParentDirectory.Combine (newName + oldFile.Extension);
// Rename the physical file first as changing the name of an IWorkspaceFileObject
// can result in the filesystem being probed for a file with that name.
if (!RenameItemFile (oldFile, newFile))
return;
try {
item.Name = newName;
item.NeedsReload = false;
// We renamed it to the wrong thing...
if (item.FileName != newFile) {
LoggingService.LogError ("File {0} was renamed to {1} instead of {2}.", item.FileName, item.FileName.FileName, newFile.FileName);
// File name changed, rename the project file
if (!RenameItemFile (newFile, item.FileName)) {
RenameItemFile (newFile, oldFile);
item.Name = oldName;
item.NeedsReload = false;
return;
}
}
} catch (Exception ex) {
if (File.Exists (item.FileName))
FileService.RenameFile (item.FileName, oldFile);
else if (File.Exists (newFile))
FileService.RenameFile (newFile, oldFile);
item.Name = oldName;
MessageService.ShowError (GettextCatalog.GetString ("The project could not be renamed."), ex);
return;
}
item.NeedsReload = false;
}
开发者ID:riverans,项目名称:monodevelop,代码行数:44,代码来源:ProjectOptionsDialog.cs
示例2: SelectFileFormatDialog
public SelectFileFormatDialog (IWorkspaceFileObject item)
{
this.Build ();
string warning = "";
foreach (string msg in item.FileFormat.GetCompatibilityWarnings (item))
warning += msg + "\n";
if (warning.Length > 0)
warning = warning.Substring (0, warning.Length - 1);
labelWarnings.Text = warning;
labelMessage.Text = string.Format (labelMessage.Text, item.Name);
labelCurrentFormat.Text = item.FileFormat.Name;
foreach (FileFormat format in Services.ProjectService.FileFormats.GetFileFormatsForObject (item)) {
comboNewFormat.AppendText (format.Name);
formats.Add (format);
}
comboNewFormat.Active = 0;
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:19,代码来源:SelectFileFormatDialog.cs
示例3: RenameItem
public static void RenameItem (IWorkspaceFileObject item, string newName)
{
if (newName == item.Name)
return;
if (!FileService.IsValidFileName (newName)) {
MessageService.ShowError (GettextCatalog.GetString ("Illegal project name.\nOnly use letters, digits, space, '.' or '_'."));
return;
}
FilePath oldFile = item.FileName;
string oldName = item.Name;
try {
item.Name = newName;
item.NeedsReload = false;
if (oldFile != item.FileName) {
// File name changed, rename the project file
if (!RenameItemFile (oldFile, item.FileName)) {
item.Name = oldName;
item.NeedsReload = false;
return;
}
}
else if (oldFile.FileNameWithoutExtension == oldName) {
FilePath newFile = oldFile.ParentDirectory.Combine (newName + oldFile.Extension);
if (newFile != oldFile) {
if (!RenameItemFile (oldFile, newFile)) {
item.Name = oldName;
item.NeedsReload = false;
return;
}
item.FileName = newFile;
}
}
} catch (Exception ex) {
item.Name = oldName;
MessageService.ShowException (ex, GettextCatalog.GetString ("The project could not be renamed."));
return;
}
item.NeedsReload = false;
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:42,代码来源:ProjectOptionsDialog.cs
示例4: HasChanged
bool HasChanged (IWorkspaceFileObject item)
{
if (item.ItemFilesChanged)
return true;
if (item is WorkspaceItem) {
foreach (SolutionEntityItem eitem in ((WorkspaceItem)item).GetAllSolutionItems<SolutionEntityItem> ())
if (eitem.ItemFilesChanged)
return true;
}
return false;
}
开发者ID:nocache,项目名称:monodevelop,代码行数:11,代码来源:ProjectOperations.cs
示例5: AllowSave
bool AllowSave (IWorkspaceFileObject item)
{
if (HasChanged (item))
return MessageService.Confirm (
GettextCatalog.GetString ("Some project files have been changed from outside MonoDevelop. Do you want to overwrite them?"),
GettextCatalog.GetString ("Changes done in those files will be overwritten by MonoDevelop."),
AlertButton.OverwriteFile);
else
return true;
}
开发者ID:nocache,项目名称:monodevelop,代码行数:10,代码来源:ProjectOperations.cs
示例6: Save
public void Save (IWorkspaceFileObject item)
{
if (item is SolutionEntityItem)
Save ((SolutionEntityItem) item);
else if (item is Solution)
Save ((Solution)item);
if (!item.FileFormat.CanWrite (item)) {
IWorkspaceFileObject ci = GetContainer (item);
if (SelectValidFileFormat (ci))
Save (ci);
return;
}
if (!AllowSave (item))
return;
IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetSaveProgressMonitor (true);
try {
item.Save (monitor);
monitor.ReportSuccess (GettextCatalog.GetString ("Item saved."));
} catch (Exception ex) {
monitor.ReportError (GettextCatalog.GetString ("Save failed."), ex);
} finally {
monitor.Dispose ();
}
}
开发者ID:nocache,项目名称:monodevelop,代码行数:27,代码来源:ProjectOperations.cs
示例7: RenameItem
public void RenameItem (IWorkspaceFileObject item, string newName)
{
ProjectOptionsDialog.RenameItem (item, newName);
if (item is SolutionItem) {
Save (((SolutionItem)item).ParentSolution);
} else {
IdeApp.Workspace.Save ();
IdeApp.Workspace.SavePreferences ();
}
}
开发者ID:nocache,项目名称:monodevelop,代码行数:10,代码来源:ProjectOperations.cs
示例8: CopyFiles
bool CopyFiles (IProgressMonitor monitor, IWorkspaceFileObject obj, IEnumerable<FilePath> files, FilePath targetBasePath, bool ignoreExternalFiles)
{
FilePath baseDir = obj.BaseDirectory.FullPath;
foreach (FilePath file in files) {
if (!File.Exists (file)) {
monitor.ReportWarning (GettextCatalog.GetString ("File '{0}' not found.", file));
continue;
}
FilePath fname = file.FullPath;
// Can't export files from outside the root solution directory
if (!fname.IsChildPathOf (baseDir)) {
if (ignoreExternalFiles)
continue;
if (obj is Solution)
monitor.ReportError ("The solution '" + obj.Name + "' is referencing the file '" + Path.GetFileName (file) + "' which is located outside the root solution directory.", null);
else
monitor.ReportError ("The project '" + obj.Name + "' is referencing the file '" + Path.GetFileName (file) + "' which is located outside the project directory.", null);
return false;
}
FilePath rpath = fname.ToRelative (baseDir);
rpath = rpath.ToAbsolute (targetBasePath);
if (!Directory.Exists (rpath.ParentDirectory))
Directory.CreateDirectory (rpath.ParentDirectory);
File.Copy (file, rpath, true);
}
return true;
}
开发者ID:hduregger,项目名称:monodevelop,代码行数:32,代码来源:ProjectService.cs
示例9: ExcludeEntries
void ExcludeEntries (IWorkspaceFileObject obj, string[] includedChildIds)
{
Solution sol = obj as Solution;
if (sol != null && includedChildIds != null) {
// Remove items not to be exported.
Dictionary<string,string> childIds = new Dictionary<string,string> ();
foreach (string it in includedChildIds)
childIds [it] = it;
foreach (SolutionItem item in sol.GetAllSolutionItems<SolutionItem> ()) {
if (!childIds.ContainsKey (item.ItemId) && item.ParentFolder != null)
item.ParentFolder.Items.Remove (item);
}
}
}
开发者ID:hduregger,项目名称:monodevelop,代码行数:16,代码来源:ProjectService.cs
示例10: FillDirRec
ChildInfo FillDirRec (Gtk.TreeIter iter, IWorkspaceFileObject item, HashSet<string> itemFiles, HashSet<string> knownPaths, FilePath dir, bool forceSet)
{
ChildInfo cinfo = ChildInfo.AllSelected;
bool hasChildren = false;
foreach (string sd in knownSubdirs) {
if (dir == item.BaseDirectory.Combine (sd)) {
forceSet = true;
break;
}
}
TreeIter dit;
if (!iter.Equals (TreeIter.Zero)) {
dit = store.AppendValues (iter, false, DesktopService.GetPixbufForFile (dir, IconSize.Menu), dir.FileName.ToString (), dir.ToString ());
fileList.ExpandRow (store.GetPath (iter), false);
}
else
dit = store.AppendValues (false, DesktopService.GetPixbufForFile (dir, IconSize.Menu), dir.FileName.ToString (), dir.ToString ());
paths [dir] = dit;
foreach (string file in Directory.GetFiles (dir)) {
string path = System.IO.Path.GetFileName (file);
Gdk.Pixbuf pix = DesktopService.GetPixbufForFile (file, IconSize.Menu);
bool active = itemFiles.Contains (file);
string color = null;
if (!active) {
pix = ImageService.MakeTransparent (pix, 0.5);
color = "dimgrey";
} else
cinfo |= ChildInfo.HasProjectFiles;
active = active || forceSet || knownPaths.Contains (file);
if (!active)
cinfo &= ~ChildInfo.AllSelected;
else
cinfo |= ChildInfo.SomeSelected;
paths [file] = store.AppendValues (dit, active, pix, path, file, color);
if (!hasChildren) {
hasChildren = true;
fileList.ExpandRow (store.GetPath (dit), false);
}
}
foreach (string cdir in Directory.GetDirectories (dir)) {
hasChildren = true;
ChildInfo ci = FillDirRec (dit, item, itemFiles, knownPaths, cdir, forceSet);
if ((ci & ChildInfo.AllSelected) == 0)
cinfo &= ~ChildInfo.AllSelected;
cinfo |= ci & (ChildInfo.SomeSelected | ChildInfo.HasProjectFiles);
}
if ((cinfo & ChildInfo.AllSelected) != 0 && hasChildren)
store.SetValue (dit, 0, true);
if ((cinfo & ChildInfo.HasProjectFiles) == 0) {
Gdk.Pixbuf pix = DesktopService.GetPixbufForFile (dir, IconSize.Menu);
pix = ImageService.MakeTransparent (pix, 0.5);
store.SetValue (dit, 1, pix);
store.SetValue (dit, 4, "dimgrey");
}
if ((cinfo & ChildInfo.SomeSelected) != 0 && (cinfo & ChildInfo.AllSelected) == 0) {
fileList.ExpandRow (store.GetPath (dit), false);
} else {
fileList.CollapseRow (store.GetPath (dit));
}
return cinfo;
}
开发者ID:telebovich,项目名称:monodevelop,代码行数:67,代码来源:ConfirmProjectDeleteDialog.cs
示例11: AllowSave
bool AllowSave (IWorkspaceFileObject item)
{
if (HasChanged (item)) {
return MessageService.Confirm (
GettextCatalog.GetString (
"Some project files have been changed from outside {0}. Do you want to overwrite them?",
BrandingService.ApplicationName
),
GettextCatalog.GetString (
"Changes done in those files will be overwritten by {0}.",
BrandingService.ApplicationName
),
AlertButton.OverwriteFile);
} else {
return true;
}
}
开发者ID:lkalif,项目名称:monodevelop,代码行数:17,代码来源:ProjectOperations.cs
示例12: GetContainer
IWorkspaceFileObject GetContainer (IWorkspaceFileObject item)
{
SolutionItem si = item as SolutionItem;
if (si != null && si.ParentSolution != null)
return si.ParentSolution;
else
return item;
}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:8,代码来源:ProjectOperations.cs
示例13: SaveAsync
async Task SaveAsync (IWorkspaceFileObject item)
{
if (item is SolutionItem)
await SaveAsync ((SolutionItem) item);
else if (item is Solution)
await SaveAsync ((Solution)item);
var msf = item as IMSBuildFileObject;
if (msf != null && !msf.FileFormat.CanWriteFile (item)) {
var ci = (IMSBuildFileObject) GetContainer (item);
if (SelectValidFileFormat (ci))
await SaveAsync (ci);
return;
}
if (!AllowSave (item))
return;
ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetSaveProgressMonitor (true);
try {
await item.SaveAsync (monitor);
monitor.ReportSuccess (GettextCatalog.GetString ("Item saved."));
} catch (Exception ex) {
monitor.ReportError (GettextCatalog.GetString ("Save failed."), ex);
} finally {
monitor.Dispose ();
}
}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:28,代码来源:ProjectOperations.cs
示例14: RenameItem
public async void RenameItem (IWorkspaceFileObject item, string newName)
{
ProjectOptionsDialog.RenameItem (item, newName);
if (item is SolutionFolderItem) {
await SaveAsync (((SolutionFolderItem)item).ParentSolution);
} else {
await IdeApp.Workspace.SaveAsync ();
IdeApp.Workspace.SavePreferences ();
}
}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:10,代码来源:ProjectOperations.cs
示例15: ConfirmProjectDeleteDialog
public ConfirmProjectDeleteDialog (IWorkspaceFileObject item)
{
this.Build ();
this.item = item;
store = new TreeStore (typeof(bool), typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string));
fileList.Model = store;
TreeViewColumn col = new TreeViewColumn ();
CellRendererToggle crt = new CellRendererToggle ();
crt.Toggled += CrtToggled;
col.PackStart (crt, false);
col.AddAttribute (crt, "active", 0);
CellRendererPixbuf crp = new CellRendererPixbuf ();
col.PackStart (crp, false);
col.AddAttribute (crp, "pixbuf", 1);
CellRendererText cre = new CellRendererText ();
col.PackStart (cre, true);
col.AddAttribute (cre, "text", 2);
col.AddAttribute (cre, "foreground", 4);
fileList.AppendColumn (col);
store.SetSortColumnId (2, SortType.Ascending);
labelProjectDir.Text = item.BaseDirectory.FullPath;
HashSet<string> itemFiles = new HashSet<string> ();
HashSet<string> knownPaths = new HashSet<string> ();
foreach (FilePath file in item.GetItemFiles (true)) {
itemFiles.Add (file.FullPath);
knownPaths.Add (file.FullPath + "~");
}
foreach (string ext in knownExtensions)
knownPaths.Add (item.FileName.ChangeExtension (ext));
FillDirRec (TreeIter.Zero, item, itemFiles, knownPaths, item.BaseDirectory, false);
if (item.BaseDirectory != item.ItemDirectory) {
// If the project has a custom base directory, make sure the project files
// from the item directory are shown in the list
foreach (FilePath f in item.GetItemFiles (false)) {
if (!f.IsChildPathOf (item.BaseDirectory)) {
Gdk.Pixbuf pix = DesktopService.GetPixbufForFile (f, IconSize.Menu);
paths [f] = store.AppendValues (true, pix, f.FileName, f.ToString ());
}
}
}
if (item is SolutionItem) {
var sol = ((SolutionItem)item).ParentSolution;
var bdir = item.BaseDirectory;
if (sol.GetItemFiles (false).Any (f => f.IsChildPathOf (bdir)) || sol.GetAllSolutionItems<SolutionEntityItem> ().Any (it => it != item && it.GetItemFiles (true).Any (f => f.IsChildPathOf (bdir)))) {
radioDeleteAll.Sensitive = false;
labelProjectDir.Text = GettextCatalog.GetString ("Project directory can't be deleted since it contains files from other projects or solutions");
}
}
if (item.BaseDirectory.FileName == item.Name && radioDeleteAll.Sensitive) {
radioDeleteAll.Active = true;
fileList.Sensitive = false;
}
else {
radioDeleteSel.Active = true;
Focus = radioDeleteSel;
}
}
开发者ID:telebovich,项目名称:monodevelop,代码行数:71,代码来源:ConfirmProjectDeleteDialog.cs
示例16: GetContainer
IWorkspaceFileObject GetContainer (IWorkspaceFileObject item)
{
SolutionEntityItem si = item as SolutionEntityItem;
if (si != null && si.ParentSolution != null && !si.ParentSolution.FileFormat.SupportsMixedFormats)
return si.ParentSolution;
else
return item;
}
开发者ID:nocache,项目名称:monodevelop,代码行数:8,代码来源:ProjectOperations.cs
示例17: SelectValidFileFormat
bool SelectValidFileFormat (IWorkspaceFileObject item)
{
var dlg = new SelectFileFormatDialog (item);
try {
if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok && dlg.Format != null) {
item.ConvertToFormat (dlg.Format, true);
return true;
}
return false;
} finally {
dlg.Destroy ();
}
}
开发者ID:nocache,项目名称:monodevelop,代码行数:13,代码来源:ProjectOperations.cs
示例18: Export
string Export (IProgressMonitor monitor, IWorkspaceFileObject obj, string[] includedChildIds, string targetPath, FileFormat format)
{
string rootSourceFile = obj.FileName;
string sourcePath = Path.GetFullPath (Path.GetDirectoryName (rootSourceFile));
targetPath = Path.GetFullPath (targetPath);
if (sourcePath != targetPath) {
if (!CopyFiles (monitor, obj, obj.GetItemFiles (true), targetPath, true))
return null;
string newFile = Path.Combine (targetPath, Path.GetFileName (rootSourceFile));
if (IsWorkspaceItemFile (rootSourceFile))
obj = ReadWorkspaceItem (monitor, newFile);
else
obj = (SolutionEntityItem) ReadSolutionItem (monitor, newFile);
using (obj) {
List<FilePath> oldFiles = obj.GetItemFiles (true);
ExcludeEntries (obj, includedChildIds);
if (format != null)
obj.ConvertToFormat (format, true);
obj.Save (monitor);
List<FilePath> newFiles = obj.GetItemFiles (true);
foreach (FilePath f in newFiles) {
if (!f.IsChildPathOf (targetPath)) {
if (obj is Solution)
monitor.ReportError ("The solution '" + obj.Name + "' is referencing the file '" + f.FileName + "' which is located outside the root solution directory.", null);
else
monitor.ReportError ("The project '" + obj.Name + "' is referencing the file '" + f.FileName + "' which is located outside the project directory.", null);
}
oldFiles.Remove (f);
}
// Remove old files
foreach (FilePath file in oldFiles) {
if (File.Exists (file)) {
File.Delete (file);
// Exclude empty directories
FilePath dir = file.ParentDirectory;
if (Directory.GetFiles (dir).Length == 0 && Directory.GetDirectories (dir).Length == 0) {
try {
Directory.Delete (dir);
} catch (Exception ex) {
monitor.ReportError (null, ex);
}
}
}
}
return obj.FileName;
}
}
else {
using (obj) {
ExcludeEntries (obj, includedChildIds);
if (format != null)
obj.ConvertToFormat (format, true);
obj.Save (monitor);
return obj.FileName;
}
}
}
开发者ID:hduregger,项目名称:monodevelop,代码行数:63,代码来源:ProjectService.cs
注:本文中的IWorkspaceFileObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论