本文整理汇总了C#中IProgressMonitor类的典型用法代码示例。如果您正苦于以下问题:C# IProgressMonitor类的具体用法?C# IProgressMonitor怎么用?C# IProgressMonitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IProgressMonitor类属于命名空间,在下文中一共展示了IProgressMonitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTextureBitmaps
/// <summary>
/// Creates bitmaps for the texture
/// </summary>
private static Bitmap[] CreateTextureBitmaps( IProgressMonitor progressMonitor, ISpherePlanet planet )
{
Bitmap[] faceBitmaps = new Bitmap[ 6 ];
int width = 256;
int height = 256;
progressMonitor.UpdateProgress( 0 );
ISpherePlanetTerrainRenderer renderer = planet.Renderer.GetRenderer<ISpherePlanetTerrainRenderer>( );
if ( renderer == null )
{
throw new InvalidOperationException( "Expected a valid ISpherePlanetTerrainRenderer to be available" );
}
faceBitmaps[ ( int )CubeMapFace.PositiveX ] = renderer.CreateMarbleTextureFace( CubeMapFace.PositiveX, width, height ); progressMonitor.UpdateProgress( 1 / 6.0f );
faceBitmaps[ ( int )CubeMapFace.NegativeX ] = renderer.CreateMarbleTextureFace( CubeMapFace.NegativeX, width, height ); progressMonitor.UpdateProgress( 2 / 6.0f );
faceBitmaps[ ( int )CubeMapFace.PositiveY ] = renderer.CreateMarbleTextureFace( CubeMapFace.PositiveY, width, height ); progressMonitor.UpdateProgress( 3 / 6.0f );
faceBitmaps[ ( int )CubeMapFace.NegativeY ] = renderer.CreateMarbleTextureFace( CubeMapFace.NegativeY, width, height ); progressMonitor.UpdateProgress( 4 / 6.0f );
faceBitmaps[ ( int )CubeMapFace.PositiveZ ] = renderer.CreateMarbleTextureFace( CubeMapFace.PositiveZ, width, height ); progressMonitor.UpdateProgress( 5 / 6.0f );
faceBitmaps[ ( int )CubeMapFace.NegativeZ ] = renderer.CreateMarbleTextureFace( CubeMapFace.NegativeZ, width, height );
progressMonitor.UpdateProgress( 1 );
foreach ( object cubeMapFace in Enum.GetValues( typeof( CubeMapFace ) ) )
{
faceBitmaps[ ( int )cubeMapFace ].Save( "PlanetCubeMap" + cubeMapFace + ".png" );
}
return faceBitmaps;
}
示例2: WriteFile
public void WriteFile (string file, object obj, MSBuildFileFormat format, bool saveProjects, IProgressMonitor monitor)
{
Solution sol = (Solution) obj;
string tmpfilename = String.Empty;
try {
monitor.BeginTask (GettextCatalog.GetString ("Saving solution: {0}", file), 1);
try {
if (File.Exists (file))
tmpfilename = Path.GetTempFileName ();
} catch (IOException) {
}
string baseDir = Path.GetDirectoryName (file);
if (tmpfilename == String.Empty) {
WriteFileInternal (file, sol, baseDir, format, saveProjects, monitor);
} else {
WriteFileInternal (tmpfilename, sol, baseDir, format, saveProjects, monitor);
FileService.SystemRename (tmpfilename, file);
}
} catch (Exception ex) {
monitor.ReportError (GettextCatalog.GetString ("Could not save solution: {0}", file), ex);
LoggingService.LogError (GettextCatalog.GetString ("Could not save solution: {0}", file), ex);
if (!String.IsNullOrEmpty (tmpfilename) && File.Exists (tmpfilename))
File.Delete (tmpfilename);
throw;
} finally {
monitor.EndTask ();
}
}
示例3: RunImpl
protected internal override TestResult RunImpl(ITestCommand rootTestCommand, Model.Tree.TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
{
using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount))
{
// Note: We do not check options.SkipTestExecution here because we want to build up
// the tree of data-driven test steps. So we actually check it later on in the
// PatternTestExecutor. This is different from framework adapters
// at this time (because they do not generally support dynamically generated data-driven tests).
Sandbox sandbox = new Sandbox();
EventHandler canceledHandler = delegate { sandbox.Abort(TestOutcome.Canceled, "The user canceled the test run."); };
try
{
progressMonitor.Canceled += canceledHandler;
TestAssemblyExecutionParameters.Reset();
PatternTestExecutor executor = new PatternTestExecutor(options, progressMonitor, formatter, converter, environmentManager);
// Inlined to minimize stack depth.
var action = executor.CreateActionToRunTest(rootTestCommand, parentTestStep, sandbox, null);
action.Run();
return action.Result;
}
finally
{
progressMonitor.Canceled -= canceledHandler;
sandbox.Dispose();
}
}
}
示例4: FindReferences
public override IEnumerable<MemberReference> FindReferences (MonoDevelop.Projects.Project project, IProjectContent content, IEnumerable<FilePath> files, IProgressMonitor monitor, IEnumerable<object> searchedMembers)
{ // TODO: Type system conversion.
yield break;
// var editor = TextFileProvider.Instance.GetTextEditorData (fileName);
// AspNetAppProject project = dom.Project as AspNetAppProject;
// if (project == null)
// yield break;
//
// var unit = AspNetParserService.GetCompileUnit (project, fileName, true);
// if (unit == null)
// yield break;
// var refman = new DocumentReferenceManager (project);
//
// var parsedAspDocument = (AspNetParsedDocument)new AspNetParser ().Parse (dom, fileName, editor.Text);
// refman.Doc = parsedAspDocument;
//
// var usings = refman.GetUsings ();
// var documentInfo = new DocumentInfo (dom, unit, usings, refman.GetDoms ());
//
// var builder = new AspLanguageBuilder ();
//
//
// var buildDocument = new Mono.TextEditor.TextDocument ();
// var offsetInfos = new List<LocalDocumentInfo.OffsetInfo> ();
// buildDocument.Text = builder.BuildDocumentString (documentInfo, editor, offsetInfos, true);
// var parsedDocument = AspLanguageBuilder.Parse (dom, fileName, buildDocument.Text);
// foreach (var member in searchedMembers) {
// foreach (var reference in SearchMember (member, dom, fileName, editor, buildDocument, offsetInfos, parsedDocument)) {
// yield return reference;
// }
// }
}
示例5: Initialize1
internal void Initialize1(IProgressMonitor progressMonitor)
{
ICollection<ProjectItem> items = project.Items;
ProjectService.ProjectItemAdded += OnProjectItemAdded;
ProjectService.ProjectItemRemoved += OnProjectItemRemoved;
UpdateDefaultImports(items);
// TODO: Translate me
// progressMonitor.TaskName = "Resolving references for " + project.Name + "...";
AbstractProject abstractProject = project as AbstractProject;
if (abstractProject != null) {
foreach (var reference in abstractProject.ResolveAssemblyReferences(progressMonitor.CancellationToken)) {
if (!initializing) return; // abort initialization
AddReference(reference, false, progressMonitor.CancellationToken);
}
} else {
project.ResolveAssemblyReferences();
AddReferencedContent(AssemblyParserService.DefaultProjectContentRegistry.Mscorlib);
foreach (ProjectItem item in items) {
if (!initializing) return; // abort initialization
progressMonitor.CancellationToken.ThrowIfCancellationRequested();
if (ItemType.ReferenceItemTypes.Contains(item.ItemType)) {
ReferenceProjectItem reference = item as ReferenceProjectItem;
if (reference != null) {
AddReference(reference, false, progressMonitor.CancellationToken);
}
}
}
}
UpdateReferenceInterDependencies();
OnReferencedContentsChanged(EventArgs.Empty);
}
示例6: CustomToolContext
public CustomToolContext(IProject project, IProgressMonitor progressMonitor)
{
if (project == null)
throw new ArgumentNullException("project");
this.project = project;
this.ProgressMonitor = progressMonitor;
}
示例7: FindReferencesAsync
/// <summary>
/// Finds all references to the specified entity.
/// The results are reported using the callback.
/// FindReferences may internally use parallelism, and may invoke the callback on multiple
/// threads in parallel.
/// </summary>
public static async Task FindReferencesAsync(IEntity entity, IProgressMonitor progressMonitor, Action<SearchedFile> callback)
{
if (entity == null)
throw new ArgumentNullException("entity");
if (progressMonitor == null)
throw new ArgumentNullException("progressMonitor");
if (callback == null)
throw new ArgumentNullException("callback");
SD.MainThread.VerifyAccess();
if (SD.ParserService.LoadSolutionProjectsThread.IsRunning) {
progressMonitor.ShowingDialog = true;
MessageService.ShowMessage("${res:SharpDevelop.Refactoring.LoadSolutionProjectsThreadRunning}");
progressMonitor.ShowingDialog = false;
return;
}
double totalWorkAmount;
List<ISymbolSearch> symbolSearches = PrepareSymbolSearch(entity, progressMonitor.CancellationToken, out totalWorkAmount);
double workDone = 0;
ParseableFileContentFinder parseableFileContentFinder = new ParseableFileContentFinder();
foreach (ISymbolSearch s in symbolSearches) {
progressMonitor.CancellationToken.ThrowIfCancellationRequested();
using (var childProgressMonitor = progressMonitor.CreateSubTask(s.WorkAmount / totalWorkAmount)) {
await s.FindReferencesAsync(new SymbolSearchArgs(childProgressMonitor, parseableFileContentFinder), callback);
}
workDone += s.WorkAmount;
progressMonitor.Progress = workDone / totalWorkAmount;
}
}
示例8: ApplyPendingSettingsChanges
public override void ApplyPendingSettingsChanges(IElevationContext elevationContext, IProgressMonitor progressMonitor)
{
base.ApplyPendingSettingsChanges(elevationContext, progressMonitor);
optionsController.AutoSaveProject = autoSave.Checked;
optionsController.Save();
}
示例9: Execute
protected override void Execute(IntPtr bridgeFunc, IProgressMonitor subMonitor)
{
using (subMonitor.BeginTask("Exploring " + File.Name, 100))
{
BoostTestExploreDelegate bridge =
(BoostTestExploreDelegate)Marshal.GetDelegateForFunctionPointer(
bridgeFunc,
typeof(BoostTestExploreDelegate)
);
VisitorDelegate visitTestCase = new VisitorDelegate(VisitTestCase);
VisitorDelegate beginVisitTestSuite = new VisitorDelegate(BeginVisitTestSuite);
VisitorDelegate endVisitTestSuite = new VisitorDelegate(EndVisitTestSuite);
ErrorReporterDelegate errorReporter =
new ErrorReporterDelegate((text) => Logger.Log(LogSeverity.Error, text));
bridge(
File.FullName,
visitTestCase,
beginVisitTestSuite,
endVisitTestSuite,
errorReporter
);
TestModelSerializer.PublishTestModel(TestModel, MessageSink);
}
}
示例10: OnCancel
void OnCancel(IProgressMonitor m)
{
lock (list) {
foreach (IAsyncOperation operation in list)
operation.Cancel ();
}
}
示例11: InstallOrUninstallWithElevationContext
private static bool InstallOrUninstallWithElevationContext(IEnumerable<ComponentHandle<IInstaller, InstallerTraits>> installerHandles,
IElevationContext elevationContext, IProgressMonitor progressMonitor,
InstallerOperation operation)
{
foreach (var installerHandle in installerHandles)
{
if (progressMonitor.IsCanceled)
return false;
IProgressMonitor subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1);
if (elevationContext != null && installerHandle.GetTraits().RequiresElevation)
{
elevationContext.Execute(InstallerElevatedCommand.ElevatedCommandId,
new InstallerElevatedCommand.Arguments(installerHandle.Id, operation),
subProgressMonitor);
}
else
{
IInstaller installer = installerHandle.GetComponent();
if (operation == InstallerOperation.Install)
installer.Install(progressMonitor.CreateSubProgressMonitor(1));
else
installer.Uninstall(progressMonitor.CreateSubProgressMonitor(1));
}
}
return true;
}
示例12: RunImpl
protected override TestResult RunImpl( ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor )
{
using(progressMonitor.BeginTask( "Verifying Specifications", rootTestCommand.TestCount ) )
{
if( options.SkipTestExecution )
{
return SkipAll( rootTestCommand, parentTestStep );
}
else
{
ITestContext rootContext = rootTestCommand.StartPrimaryChildStep( parentTestStep );
TestStep rootStep = rootContext.TestStep;
TestOutcome outcome = TestOutcome.Passed;
foreach( ITestCommand command in rootTestCommand.Children )
{
NSpecAssemblyTest assemblyTest = command.Test as NSpecAssemblyTest;
if( assemblyTest == null )
continue;
var assemblyResult = this.RunAssembly( command, rootStep );
outcome = outcome.CombineWith( assemblyResult.Outcome );
}
return rootContext.FinishStep( outcome, null );
}
}
}
示例13: ReadFile
public object ReadFile(string file, IProgressMonitor monitor)
{
XmlTextReader reader = new XmlTextReader (new StreamReader (file));
reader.MoveToContent ();
string version = reader.GetAttribute ("version");
if (version == null) version = reader.GetAttribute ("fileversion");
DataSerializer serializer = new DataSerializer (Runtime.ProjectService.DataContext, file);
ICombineReader combineReader = null;
if (version == "1.0" || version == "1") {
combineReader = new CombineReaderV1 (serializer, monitor);
monitor.ReportWarning (string.Format (GettextCatalog.GetString ("The file '{0}' is using an old combine file format. It will be automatically converted to the current format."), file));
}
else if (version == "2.0")
combineReader = new CombineReaderV2 (serializer, monitor);
try {
if (combineReader != null)
return combineReader.ReadCombine (reader);
else
throw new UnknownProjectVersionException (file, version);
} finally {
reader.Close ();
}
}
示例14: GenerateInternal
static void GenerateInternal (IProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result)
{
if (file.Project.SupportedLanguages.All (l => l != "C#")) {
const string msg = "Razor templates are only supported in C# projects";
result.Errors.Add (new CompilerError (file.Name, -1, -1, null, msg));
monitor.Log.WriteLine (msg);
return;
}
var host = new PreprocessedRazorHost (file.FilePath);
var defaultOutputName = file.FilePath.ChangeExtension (".cs");
var ns = CustomToolService.GetFileNamespace (file, defaultOutputName);
host.DefaultNamespace = ns;
CompilerErrorCollection errors;
var code = host.GenerateCode (out errors);
result.Errors.AddRange (errors);
var writer = new MonoDevelop.DesignerSupport.CodeBehindWriter ();
writer.WriteFile (defaultOutputName, code);
writer.WriteOpenFiles ();
result.GeneratedFilePath = defaultOutputName;
foreach (var err in result.Errors) {
monitor.Log.WriteLine (err);
}
}
示例15: GetTypeUpdates
public Dictionary<string, List<NSObjectTypeInfo>> GetTypeUpdates (IProgressMonitor monitor, CodeDomProvider provider,
out Dictionary<string, NSObjectTypeInfo> newTypes,
out Dictionary<string, ProjectFile> newFiles)
{
Dictionary<string, List<NSObjectTypeInfo>> designerFiles = new Dictionary<string, List<NSObjectTypeInfo>> ();
string defaultNamespace;
// First, we need to name any new user-defined types.
foreach (var job in TypeSyncJobs) {
if (!job.IsFreshlyAdded) {
monitor.Log.WriteLine ("Found updated class: {0}", job.Type.CliName);
continue;
}
defaultNamespace = Project.GetDefaultNamespace (job.RelativePath);
job.Type.CliName = defaultNamespace + "." + provider.CreateValidIdentifier (job.Type.ObjCName);
monitor.Log.WriteLine ("Found newly-added class: {0}", job.Type.CliName);
ProjectInfo.InsertUpdatedType (job.Type);
}
// Next we can resolve base-types, outlet types, and action parameter types for each of our user-defined types.
foreach (var job in TypeSyncJobs) {
defaultNamespace = Project.GetDefaultNamespace (job.RelativePath);
ProjectInfo.ResolveObjcToCli (monitor, job.Type, provider, defaultNamespace);
}
AggregateTypeUpdates (monitor, provider, designerFiles, out newTypes, out newFiles);
MergeExistingTypes (designerFiles);
return designerFiles;
}