private void InitUI() { Debug.WriteLine("Initializing UI objects."); #region Canvas Debug.WriteLine("Loading canvas..."); this.canvas = new DefaultCanvas(); this.toolStripContainer1.ContentPanel.Controls.Add((Control)this.canvas); #endregion #region Commands BlackCanvasBgCommands blackCanvasBgCommands = new BlackCanvasBgCommands(this.canvas); WhiteCanvasBgCommands whiteCanvasBgCommands = new WhiteCanvasBgCommands(this.canvas); #endregion #region Menubar Debug.WriteLine("Loading menubar..."); this.menubar = new DefaultMenubar(); this.Controls.Add((Control)this.menubar); DefaultMenuItem fileMenuItem = new DefaultMenuItem("File"); this.menubar.AddMenuItem(fileMenuItem); DefaultMenuItem newMenuItem = new DefaultMenuItem("New"); fileMenuItem.AddMenuItem(newMenuItem); DefaultMenuItem editMenuItem = new DefaultMenuItem("Edit"); this.menubar.AddMenuItem(editMenuItem); DefaultMenuItem changeToBlackMenuItem = new DefaultMenuItem("Change to Black"); changeToBlackMenuItem.SetCommand(blackCanvasBgCommands); editMenuItem.AddMenuItem(changeToBlackMenuItem); DefaultMenuItem changeToWhiteMenuItem = new DefaultMenuItem("Change to White"); changeToWhiteMenuItem.SetCommand(whiteCanvasBgCommands); editMenuItem.AddMenuItem(changeToWhiteMenuItem); #endregion #region Toolbox // Initializing toolbox Debug.WriteLine("Loading toolbox..."); this.toolbox = new DefaultToolbox(); this.toolStripContainer1.LeftToolStripPanel.Controls.Add((Control)this.toolbox); #endregion #region Tools // Initializing tools Debug.WriteLine("Loading tools..."); this.toolbox.AddTool(new SelectionTool()); this.toolbox.AddSeparator(); this.toolbox.AddTool(new LineTool()); this.toolbox.AddTool(new RectangleTool()); this.toolbox.AddTool(new TextTool()); this.toolbox.AddTool(new ConnectorTool()); this.toolbox.ToolSelected += Toolbox_ToolSelected; #endregion #region Toolbar // Initializing toolbar Debug.WriteLine("Loading toolbar..."); this.toolbar = new DefaultToolbar(); this.toolStripContainer1.TopToolStripPanel.Controls.Add((Control)this.toolbar); ExampleToolbarItem whiteBackgroundTool = new ExampleToolbarItem(); whiteBackgroundTool.SetCommand(whiteCanvasBgCommands); ExampleToolbarItem blackBackgroundTool = new ExampleToolbarItem(); blackBackgroundTool.SetCommand(blackCanvasBgCommands); this.toolbar.AddToolbarItem(whiteBackgroundTool); this.toolbar.AddSeparator(); this.toolbar.AddToolbarItem(blackBackgroundTool); #endregion }
public AddItemToSelectedNodeCommand(IToolbox toolbox) { _toolbox = toolbox; }
public CourseLoader(IToolbox toolbox, IValueFactory vf, string id) { this.toolbox = toolbox; _vf = vf; this.id = id; }
public DeleteActiveToolbarCategoryCommand(IToolbox toolbox, IToolboxService service) { _toolbox = toolbox; _service = service; }
/// <summary> /// Populates Azure Storage with the required files, and /// submits the work item to the Azure Batch service. /// </summary> public async Task RunAsync() { Console.WriteLine("Running with the following settings: "); Console.WriteLine("----------------------------------------"); Console.WriteLine(this.configurationSettings.ToString()); //Upload resources if required. if (this.configurationSettings.ShouldUploadResources) { Console.WriteLine("Splitting file: {0} into {1} subfiles", Constants.TextFilePath, this.configurationSettings.NumberOfMapperTasks); //Split the text file into the correct number of files for consumption by the mapper tasks. FileSplitter splitter = new FileSplitter(); List <string> mapperTaskFiles = await splitter.SplitAsync( Constants.TextFilePath, this.configurationSettings.NumberOfMapperTasks); await this.UploadResourcesAsync(mapperTaskFiles); } //Generate a SAS for the container. string containerSasUrl = Helpers.ConstructContainerSas( this.configurationSettings.StorageAccountName, this.configurationSettings.StorageAccountKey, this.configurationSettings.StorageServiceUrl, this.configurationSettings.BlobContainer); //Set up the Batch Service credentials used to authenticate with the Batch Service. BatchCredentials batchCredentials = new BatchCredentials( this.configurationSettings.BatchAccountName, this.configurationSettings.BatchAccountKey); using (IBatchClient batchClient = BatchClient.Connect(this.configurationSettings.BatchServiceUrl, batchCredentials)) { using (IWorkItemManager workItemManager = batchClient.OpenWorkItemManager()) { //Create the unbound work item in local memory. An object which exists only in local memory (and not on the Batch Service) is "unbound". string workItemName = Environment.GetEnvironmentVariable("USERNAME") + DateTime.UtcNow.ToString("yyyyMMdd-HHmmss"); ICloudWorkItem unboundWorkItem = workItemManager.CreateWorkItem(workItemName); // // Construct the work item properties in local memory before commiting them to the Batch Service. // //Allow enough VMs in the pool to run each mapper task, and 1 extra to run the job manager. int numberOfPoolVMs = 1 + this.configurationSettings.NumberOfMapperTasks; //Define the pool specification for the pool which the work item will run on. IPoolSpecification poolSpecification = new PoolSpecification() { TargetDedicated = numberOfPoolVMs, VMSize = "small", //You can learn more about os families and versions at: //http://msdn.microsoft.com/en-us/library/azure/ee924680.aspx OSFamily = "4", TargetOSVersion = "*" }; //Use the auto pool feature of the Batch Service to create a pool when the work item is created. //This creates a new pool for each work item which is added. IAutoPoolSpecification autoPoolSpecification = new AutoPoolSpecification() { AutoPoolNamePrefix = "TextSearchPool", KeepAlive = false, PoolLifeTimeOption = PoolLifeTimeOption.WorkItem, PoolSpecification = poolSpecification }; //Define the execution environment for this work item -- it will run on the pool defined by the auto pool specification above. unboundWorkItem.JobExecutionEnvironment = new JobExecutionEnvironment() { AutoPoolSpecification = autoPoolSpecification }; //Define the job manager for this work item. This job manager will run when any job is created and will submit the tasks for //the work item. The job manager is the executable which manages the lifetime of the job //and all tasks which should run for the job. In this case, the job manager submits the mapper and reducer tasks. string jobManagerCommandLine = string.Format("{0} -JobManagerTask", Constants.TextSearchExe); List <IResourceFile> jobManagerResourceFiles = Helpers.GetResourceFiles(containerSasUrl, Constants.RequiredExecutableFiles); const string jobManagerTaskName = "JobManager"; unboundWorkItem.JobSpecification = new JobSpecification() { JobManager = new JobManager() { ResourceFiles = jobManagerResourceFiles, CommandLine = jobManagerCommandLine, //Determines if the job should terminate when the job manager process exits KillJobOnCompletion = false, Name = jobManagerTaskName } }; try { //Commit the unbound work item to the Batch Service. Console.WriteLine("Adding work item: {0} to the Batch Service.", unboundWorkItem.Name); await unboundWorkItem.CommitAsync(); //Issues a request to the Batch Service to add the work item which was defined above. // // Wait for the job manager task to complete. // //An object which is backed by a corresponding Batch Service object is "bound." ICloudWorkItem boundWorkItem = await workItemManager.GetWorkItemAsync(workItemName); //Wait for the job to be created automatically by the Batch Service. string boundJobName = await Helpers.WaitForActiveJobAsync(boundWorkItem); ICloudTask boundJobManagerTask = await workItemManager.GetTaskAsync( workItemName, boundJobName, jobManagerTaskName); TimeSpan maxJobCompletionTimeout = TimeSpan.FromMinutes(30); IToolbox toolbox = batchClient.OpenToolbox(); ITaskStateMonitor monitor = toolbox.CreateTaskStateMonitor(); bool timedOut = await monitor.WaitAllAsync(new List <ICloudTask> { boundJobManagerTask }, TaskState.Completed, maxJobCompletionTimeout); Console.WriteLine("Done waiting for job manager task."); await boundJobManagerTask.RefreshAsync(); //Check to ensure the job manager task exited successfully. await Helpers.CheckForTaskSuccessAsync(boundJobManagerTask, dumpStandardOutOnTaskSuccess : true); if (timedOut) { throw new TimeoutException(string.Format("Timed out waiting for job manager task to complete.")); } } catch (AggregateException e) { e.Handle( (innerE) => { //We print all the inner exceptions for debugging purposes. Console.WriteLine(innerE.ToString()); return(false); }); throw; } catch (Exception e) { Console.WriteLine("Hit unexpected exception: {0}", e.ToString()); throw; } finally { //Delete the work item. //This will delete the auto pool associated with the work item as long as the pool //keep alive property is set to false. if (this.configurationSettings.ShouldDeleteWorkItem) { Console.WriteLine("Deleting work item {0}", workItemName); workItemManager.DeleteWorkItem(workItemName); } //Note that there were files uploaded to a container specified in the //configuration file. This container will not be deleted or cleaned up by this sample. } } } }
/// <summary> /// Runs the job manager task. /// </summary> public async Task RunAsync() { Console.WriteLine("JobManager for account: {0}, work item: {1}, job: {2} has started...", this.accountName, this.workItemName, this.jobName); Console.WriteLine(); Console.WriteLine("JobManager running with the following settings: "); Console.WriteLine("----------------------------------------"); Console.WriteLine(this.configurationSettings.ToString()); //Set up the Batch Service credentials used to authenticate with the Batch Service. BatchCredentials batchCredentials = new BatchCredentials( this.configurationSettings.BatchAccountName, this.configurationSettings.BatchAccountKey); using (IBatchClient batchClient = BatchClient.Connect(this.configurationSettings.BatchServiceUrl, batchCredentials)) { using (IWorkItemManager workItemManager = batchClient.OpenWorkItemManager()) { IToolbox toolbox = batchClient.OpenToolbox(); //Construct a container SAS to provide the Batch Service access to the files required to //run the mapper and reducer tasks. string containerSas = Helpers.ConstructContainerSas( this.configurationSettings.StorageAccountName, this.configurationSettings.StorageAccountKey, this.configurationSettings.StorageServiceUrl, this.configurationSettings.BlobContainer); // // Submit mapper tasks. // Console.WriteLine("Submitting {0} mapper tasks.", this.configurationSettings.NumberOfMapperTasks); //The collection of tasks to add to the Batch Service. List <ICloudTask> tasksToAdd = new List <ICloudTask>(); for (int i = 0; i < this.configurationSettings.NumberOfMapperTasks; i++) { string taskName = Helpers.GetMapperTaskName(i); string fileBlobName = Helpers.GetSplitFileName(i); string fileBlobPath = Helpers.ConstructBlobSource(containerSas, fileBlobName); string commandLine = string.Format("{0} -MapperTask {1}", Constants.TextSearchExe, fileBlobPath); ICloudTask unboundMapperTask = new CloudTask(taskName, commandLine); //The set of files (exe's, dll's and configuration files) required to run the mapper task. IReadOnlyList <string> mapperTaskRequiredFiles = Constants.RequiredExecutableFiles; List <IResourceFile> mapperTaskResourceFiles = Helpers.GetResourceFiles(containerSas, mapperTaskRequiredFiles); unboundMapperTask.ResourceFiles = mapperTaskResourceFiles; tasksToAdd.Add(unboundMapperTask); } //Submit the unbound task collection to the Batch Service. //Use the AddTask method which takes a collection of ICloudTasks for the best performance. await workItemManager.AddTaskAsync(this.workItemName, this.jobName, tasksToAdd); // // Wait for the mapper tasks to complete. // Console.WriteLine("Waiting for the mapper tasks to complete..."); //List all the mapper tasks using a name filter. DetailLevel mapperTaskNameFilter = new ODATADetailLevel() { FilterClause = string.Format("startswith(name, '{0}')", Constants.MapperTaskPrefix) }; List <ICloudTask> tasksToMonitor = workItemManager.ListTasks( this.workItemName, this.jobName, detailLevel: mapperTaskNameFilter).ToList(); //Use the task state monitor to wait for the tasks to complete. ITaskStateMonitor taskStateMonitor = toolbox.CreateTaskStateMonitor(); bool timedOut = await taskStateMonitor.WaitAllAsync(tasksToMonitor, TaskState.Completed, TimeSpan.FromMinutes(5)); //Get the list of mapper tasks in order to analyze their state and ensure they completed successfully. IEnumerableAsyncExtended <ICloudTask> asyncEnumerable = workItemManager.ListTasks( this.workItemName, this.jobName, detailLevel: mapperTaskNameFilter); IAsyncEnumerator <ICloudTask> asyncEnumerator = asyncEnumerable.GetAsyncEnumerator(); //Dump the status of each mapper task. while (await asyncEnumerator.MoveNextAsync()) { ICloudTask cloudTask = asyncEnumerator.Current; Console.WriteLine("Task {0} is in state: {1}", cloudTask.Name, cloudTask.State); await Helpers.CheckForTaskSuccessAsync(cloudTask, dumpStandardOutOnTaskSuccess : false); Console.WriteLine(); } //If not all the tasks reached the desired state within the timeout then the job manager //cannot continue. if (timedOut) { const string errorMessage = "Mapper tasks did not complete within expected timeout."; Console.WriteLine(errorMessage); throw new TimeoutException(errorMessage); } // // Create the reducer task. // string reducerTaskCommandLine = string.Format("{0} -ReducerTask", Constants.TextSearchExe); Console.WriteLine("Adding the reducer task: {0}", Constants.ReducerTaskName); ICloudTask unboundReducerTask = new CloudTask(Constants.ReducerTaskName, reducerTaskCommandLine); //The set of files (exe's, dll's and configuration files) required to run the reducer task. List <IResourceFile> reducerTaskResourceFiles = Helpers.GetResourceFiles(containerSas, Constants.RequiredExecutableFiles); unboundReducerTask.ResourceFiles = reducerTaskResourceFiles; //Send the request to the Batch Service to add the reducer task. await workItemManager.AddTaskAsync(this.workItemName, this.jobName, unboundReducerTask); // //Wait for the reducer task to complete. // //Get the bound reducer task and monitor it for completion. ICloudTask boundReducerTask = await workItemManager.GetTaskAsync(this.workItemName, this.jobName, Constants.ReducerTaskName); timedOut = await taskStateMonitor.WaitAllAsync(new List <ICloudTask> { boundReducerTask }, TaskState.Completed, TimeSpan.FromMinutes(2)); //Refresh the reducer task to get the most recent information about it from the Batch Service. await boundReducerTask.RefreshAsync(); //Dump the reducer tasks exit code and scheduling error for debugging purposes. await Helpers.CheckForTaskSuccessAsync(boundReducerTask, dumpStandardOutOnTaskSuccess : true); //Handle the possibilty that the reducer task did not complete in the expected timeout. if (timedOut) { const string errorMessage = "Reducer task did not complete within expected timeout."; Console.WriteLine("Task {0} is in state: {1}", boundReducerTask.Name, boundReducerTask.State); Console.WriteLine(errorMessage); throw new TimeoutException(errorMessage); } //The job manager has completed. Console.WriteLine("JobManager completed successfully."); } } }
public ToggleShowAllItemsCommand(IToolbox toolbox) { _toolbox = toolbox; }
public PlatformUserServcie(IToolbox toolbox) { this.toolbox = toolbox; }
private void InitForm() { Debug.WriteLine("Initializing UI objects."); #region Toolbox //tempat2 nya tool //Initialize toolbox Debug.WriteLine("Loading toolbox..."); //inisialisasi toolbox this.toolbox = new DefaultToolbox(); this.toolStripContainer1.LeftToolStripPanel.Controls.Add((Control)this.toolbox); #endregion #region Tools //tool tool yang di keluarkan ////Initialize tools Debug.WriteLine("Loading tools..."); this.toolbox.AddTool(new SelectionTool()); //state this.toolbox.AddTool(new StateLineTool()); this.toolbox.AddTool(new StateRectangleTool()); this.toolbox.AddTool(new StateCircleTool()); this.toolbox.AddTool(new ConnectorTool()); this.toolbox.ToolSelected += Toolbox_ToolSelected; #endregion #region Toolbar // Initializing toolbar Debug.WriteLine("Loading toolbar..."); this.toolbar = new DefaultToolbar(); this.toolStripContainer1.TopToolStripPanel.Controls.Add((Control)this.toolbar); this.toolbar.AddToolbarItem(new ExampleToolbarItem()); this.toolbar.AddSeparator(); this.toolbar.AddToolbarItem(new ExampleToolbarItem()); #endregion #region Menubar Debug.WriteLine("Loading menubar..."); this.menubar = new DefaultMenubar(); this.Controls.Add((Control)this.menubar); DefaultMenuitem exampleMenuItem1 = new DefaultMenuitem("File"); this.menubar.AddMenuItem(exampleMenuItem1); DefaultMenuitem exampleMenuItem11 = new DefaultMenuitem("New"); exampleMenuItem1.AddMenuItem(exampleMenuItem11); DefaultMenuitem exampleMenuItem2 = new DefaultMenuitem("Edit"); this.menubar.AddMenuItem(exampleMenuItem2); DefaultMenuitem exampleMenuItem21 = new DefaultMenuitem("Cut"); exampleMenuItem2.AddMenuItem(exampleMenuItem21); DefaultMenuitem exampleMenuItem22 = new DefaultMenuitem("Copy"); exampleMenuItem2.AddMenuItem(exampleMenuItem22); #endregion #region Canvas Debug.WriteLine("Loading canvas..."); this.canvas = new DefaultCanvas(); this.toolStripContainer1.ContentPanel.Controls.Add((Control)this.canvas); #endregion }
public SortItemsAlphabeticallyCommand(IToolbox toolbox) { _toolbox = toolbox; }
/// <summary> /// This is the client that creates workitem and submits tasks. /// </summary> /// <param name="args"></param> public static void SubmitTasks(string[] args) { config = Config.ParseConfig(); //Upload resources if specified if (config.UploadResources) { //Upload ImgProc.exe, Batch.dll and the Storage Client ImgProcUtils.UploadFileToBlob(Constants.StorageClientDllName, config.ResourceContainerSAS); ImgProcUtils.UploadFileToBlob(Constants.ImgProcExeName, config.ResourceContainerSAS); ImgProcUtils.UploadFileToBlob(Constants.BatchClientDllName, config.ResourceContainerSAS); Console.WriteLine("Done uploading files to blob"); } try { using (IWorkItemManager wm = config.Client.OpenWorkItemManager()) { IToolbox toolbox = config.Client.OpenToolbox(); //Use the task submission helper to ease creation of workitem and addition of tasks, as well as management of resource file staging. ITaskSubmissionHelper taskSubmissionHelper = toolbox.CreateTaskSubmissionHelper(wm, config.PoolName); taskSubmissionHelper.WorkItemName = config.WorkitemName; //Compute the number of images each task should process int numImgsPerTask = (int)Math.Round(config.NumInputBlobs / (decimal)config.NumTasks); for (int i = 0; i < config.NumTasks; i++) { ICloudTask task = new CloudTask( name: "task_no_" + i, commandline: string.Format("{0} --Task {1} thumb{2}", Constants.ImgProcExeName, config.OutputContainerSAS, i)); Console.WriteLine("Generating task: {0}", task.Name); task.FilesToStage = new List <IFileStagingProvider>(); int start = i * numImgsPerTask; int end; if (i < config.NumTasks - 1) { end = ((i + 1) * numImgsPerTask) - 1; } else { end = config.NumInputBlobs - 1; } //Generate and set up the list of files to be processed by this task for (int j = start; j < end; j++) { string input = GetTempFilePath(j); ImgProcUtils.GenerateImages(input, string.Format("{0}", j)); task.FilesToStage.Add(new FileToStage(input, new StagingStorageAccount(config.StorageAccount, config.StorageKey, config.StorageBlobEndpoint))); } task.ResourceFiles = ImgProcUtils.GetResourceFiles(config.ResourceContainerSAS); taskSubmissionHelper.AddTask(task); } IJobCommitUnboundArtifacts artifacts = null; try { Console.WriteLine("Submitting {0} tasks to the Batch Service", config.NumTasks); //Submit the tasks to the Batch Service artifacts = taskSubmissionHelper.Commit() as IJobCommitUnboundArtifacts; } catch (AggregateException ae) { // Go through all exceptions and dump useful information ae.Handle(x => { if (x is BatchException) { BatchException be = x as BatchException; if (null != be.RequestInformation && null != be.RequestInformation.AzureError) { // Write the server side error information Console.Error.WriteLine(be.RequestInformation.AzureError.Code); Console.Error.WriteLine(be.RequestInformation.AzureError.Message.Value); if (null != be.RequestInformation.AzureError.Values) { foreach (var v in be.RequestInformation.AzureError.Values) { Console.Error.WriteLine(v.Key + " : " + v.Value); } } } } // Indicate that the error has been handled return(true); }); } DateTime starttime = DateTime.Now; //Wait for the job to complete if (config.WaitForCompletion) { ICloudJob job = wm.GetJob(artifacts.WorkItemName, artifacts.JobName); Console.WriteLine("Waiting for tasks to complete..."); // Wait up to 15 minutes for all tasks to reach the completed state config.Client.OpenToolbox().CreateTaskStateMonitor().WaitAll(job.ListTasks(), TaskState.Completed, new TimeSpan(0, 15, 0)); DateTime endtime = DateTime.Now; Console.WriteLine("Time taken for processing the images : {0} sec", endtime.Subtract(starttime).TotalSeconds); } } } finally { //Delete the workitem that we created if (config.DeleteWorkitem && config.WaitForCompletion) { Console.WriteLine("Press any key to delete the workitem . . ."); Console.ReadKey(); config.Client.OpenWorkItemManager().DeleteWorkItem(config.WorkitemName); } } }
public PartnerService(IToolbox tools) { _tools = tools; }
public static void JobMain(string[] args) { //Load the configuration TopNWordsConfiguration configuration = TopNWordsConfiguration.LoadConfigurationFromAppConfig(); StagingStorageAccount stagingStorageAccount = new StagingStorageAccount( configuration.StorageAccountName, configuration.StorageAccountKey, configuration.StorageAccountBlobEndpoint); IBatchClient client = BatchClient.Connect(configuration.BatchServiceUrl, new BatchCredentials(configuration.BatchAccountName, configuration.BatchAccountKey)); string stagingContainer = null; //Create a pool (if user hasn't provided one) if (configuration.ShouldCreatePool) { using (IPoolManager pm = client.OpenPoolManager()) { //OSFamily 4 == OS 2012 R2 //You can learn more about os families and versions at: //http://msdn.microsoft.com/en-us/library/azure/ee924680.aspx ICloudPool pool = pm.CreatePool(configuration.PoolName, targetDedicated: configuration.PoolSize, osFamily: "4", vmSize: "small"); Console.WriteLine("Adding pool {0}", configuration.PoolName); pool.Commit(); } } try { using (IWorkItemManager wm = client.OpenWorkItemManager()) { IToolbox toolbox = client.OpenToolbox(); //Use the TaskSubmissionHelper to help us create a WorkItem and add tasks to it. ITaskSubmissionHelper taskSubmissionHelper = toolbox.CreateTaskSubmissionHelper(wm, configuration.PoolName); taskSubmissionHelper.WorkItemName = configuration.WorkItemName; FileToStage topNWordExe = new FileToStage(TopNWordsExeName, stagingStorageAccount); FileToStage storageDll = new FileToStage(StorageClientDllName, stagingStorageAccount); string bookFileUri = UploadBookFileToCloudBlob(configuration, configuration.BookFileName); Console.WriteLine("{0} uploaded to cloud", configuration.BookFileName); for (int i = 1; i <= configuration.NumberOfTasks; i++) { ICloudTask task = new CloudTask("task_no_" + i, String.Format("{0} --Task {1} {2} {3} {4}", TopNWordsExeName, bookFileUri, configuration.NumberOfTopWords, configuration.StorageAccountName, configuration.StorageAccountKey)); //This is the list of files to stage to a container -- for each TaskSubmissionHelper one container is created and //files all resolve to Azure Blobs by their name (so two tasks with the same named file will create just 1 blob in //the TaskSubmissionHelper's container). task.FilesToStage = new List <IFileStagingProvider> { topNWordExe, storageDll }; taskSubmissionHelper.AddTask(task); } //Commit all the tasks to the Batch Service. IJobCommitUnboundArtifacts artifacts = taskSubmissionHelper.Commit() as IJobCommitUnboundArtifacts; foreach (var fileStagingArtifact in artifacts.FileStagingArtifacts) { SequentialFileStagingArtifact stagingArtifact = fileStagingArtifact.Value as SequentialFileStagingArtifact; if (stagingArtifact != null) { stagingContainer = stagingArtifact.BlobContainerCreated; Console.WriteLine("Uploaded files to container: {0} -- you will be charged for their storage unless you delete them.", stagingArtifact.BlobContainerCreated); } } //Get the job to monitor status. ICloudJob job = wm.GetJob(artifacts.WorkItemName, artifacts.JobName); Console.Write("Waiting for tasks to complete ..."); // Wait 1 minute for all tasks to reach the completed state client.OpenToolbox().CreateTaskStateMonitor().WaitAll(job.ListTasks(), TaskState.Completed, TimeSpan.FromMinutes(20)); Console.WriteLine("Done."); foreach (ICloudTask task in job.ListTasks()) { Console.WriteLine("Task " + task.Name + " says:\n" + task.GetTaskFile(Constants.StandardOutFileName).ReadAsString()); Console.WriteLine(task.GetTaskFile(Constants.StandardErrorFileName).ReadAsString()); } } } finally { //Delete the pool that we created if (configuration.ShouldCreatePool) { using (IPoolManager pm = client.OpenPoolManager()) { Console.WriteLine("Deleting pool: {0}", configuration.PoolName); pm.DeletePool(configuration.PoolName); } } //Delete the workitem that we created if (configuration.ShouldDeleteWorkItem) { using (IWorkItemManager wm = client.OpenWorkItemManager()) { Console.WriteLine("Deleting work item: {0}", configuration.WorkItemName); wm.DeleteWorkItem(configuration.WorkItemName); } } //Delete the containers we created if (configuration.ShouldDeleteContainer) { DeleteContainers(configuration, stagingContainer); } } }
private void InitUI() { Debug.WriteLine("Initializing UI objects."); IPanel canvas1 = new DefaultPanel(); #region Toolbar // Initializing toolbar Debug.WriteLine("Loading toolbar..."); this.toolbar = new DefaultToolbar(); this.toolStripContainer1.TopToolStripPanel.Controls.Add((Control)this.toolbar); UnDoRedo undoredo = new UnDoRedo(); ToolbarItem toolItem1 = new ToolbarItem("undo", IconSet.undo, canvas1); toolItem1.UnDoObject = undoredo; //toolItem1.SetCommand(whiteCanvasBgCmd); ToolbarItem toolItem2 = new ToolbarItem("redo", IconSet.redo, canvas1); toolItem2.UnDoObject = undoredo; //toolItem2.SetCommand(blackCanvasBgCmd); this.toolbar.AddToolbarItem(toolItem1); this.toolbar.AddSeparator(); this.toolbar.AddToolbarItem(toolItem2); #endregion #region Editor and Panel Debug.WriteLine("Loading panel..."); this.editor = new DefaultEditor(); this.toolStripContainer1.ContentPanel.Controls.Add((Control)this.editor); canvas1.Name = "Untitled-1"; canvas1.UnDoObject = undoredo; this.editor.AddCanvas(canvas1); /*IPanel canvas2 = new DefaultPanel(); * canvas2.Name = "Untitled-2"; * this.editor.AddCanvas(canvas2);*/ #endregion #region Menubar Debug.WriteLine("Loading menubar..."); this.menubar = new DefaultMenubar(); this.Controls.Add((Control)this.menubar); DefaultMenuItem exampleMenuItem1 = new DefaultMenuItem("File"); this.menubar.AddMenuItem(exampleMenuItem1); DefaultMenuItem exampleMenuItem11 = new DefaultMenuItem("New Mindmap"); exampleMenuItem1.AddMenuItem(exampleMenuItem11); DefaultMenuItem exampleMenuItem12 = new DefaultMenuItem("Open Mindmap"); exampleMenuItem1.AddMenuItem(exampleMenuItem12); DefaultMenuItem exampleMenuItem13 = new DefaultMenuItem("Close"); exampleMenuItem1.AddMenuItem(exampleMenuItem13); DefaultMenuItem exampleMenuItem2 = new DefaultMenuItem("Edit"); this.menubar.AddMenuItem(exampleMenuItem2); DefaultMenuItem exampleMenuItem21 = new DefaultMenuItem("Add Proccess"); exampleMenuItem2.AddMenuItem(exampleMenuItem21); DefaultMenuItem exampleMenuItem3 = new DefaultMenuItem("Export"); this.menubar.AddMenuItem(exampleMenuItem3); DefaultMenuItem exampleMenuItem31 = new DefaultMenuItem("Image"); exampleMenuItem3.AddMenuItem(exampleMenuItem31); DefaultMenuItem exampleMenuItem311 = new DefaultMenuItem("JPEG"); exampleMenuItem31.AddMenuItem(exampleMenuItem311); DefaultMenuItem exampleMenuItem312 = new DefaultMenuItem("PNG"); exampleMenuItem31.AddMenuItem(exampleMenuItem312); DefaultMenuItem exampleMenuItem32 = new DefaultMenuItem("PDF"); exampleMenuItem3.AddMenuItem(exampleMenuItem32); #endregion #region Toolbox // Initializing toolbox Debug.WriteLine("Loading toolbox..."); this.toolbox = new DefaultToolbox(); this.toolStripContainer1.LeftToolStripPanel.Controls.Add((Control)this.toolbox); //this.editor.Toolbox = toolbox; #endregion #region Tools // Initializing tools Debug.WriteLine("Loading tools..."); ITool selectionTool = new SelectionTool(); selectionTool.UnDoObject = undoredo; this.toolbox.AddTool(selectionTool); this.toolbox.AddSeparator(); this.toolbox.AddTool(new LineTool()); this.toolbox.AddTool(new RectangleTool()); this.toolbox.AddTool(new TextTool()); this.toolbox.ToolSelected += Toolbox_ToolSelected; #endregion }
public void LoadToolbox(IToolbox toolbox) { IToolboxTab tabWindowsForms = toolbox.CreateToolboxTab("WindowsForms", "Windows Forms"); IToolboxTab tabComponents = toolbox.CreateToolboxTab("Components", "Components"); IToolboxTab tabData = toolbox.CreateToolboxTab("Data", "Data"); IToolboxTab tabUserControls = toolbox.CreateToolboxTab("UserControls", "User Controls"); FillToolboxTab(tabWindowsForms, windowsFormsTypes); FillToolboxTab(tabComponents, componentsTypes); FillToolboxTab(tabData, dataTypes); FillToolboxTab(tabUserControls, userControlsTypes); toolbox.RefreshLayout(); }
public RenameToolboxItemCommand(IToolbox toolbox) { _toolbox = toolbox; }
public App(ILogger <App> logger, AppSettings settings, IMenu menu, IScribe scribe, IToolbox toolbox) { _logger = logger; _settings = settings; _menu = menu; _scribe = scribe; _toolbox = toolbox; }
static public GraphicsEditor ShowGraphicsEditor(Size size, IProject project, IToolbox toolbox, GraphicTypes type, object[] plusParams) { return(ShowGraphicsEditor(size, project, toolbox, type, StandardLog, StandardNotificator, plusParams)); }
private void InitUI() { Debug.WriteLine("Initializing UI objects."); #region Editor and Canvas Debug.WriteLine("Loading canvas..."); this.editor = new DefaultEditor(); this.toolStripContainer1.ContentPanel.Controls.Add((Control)this.editor); ICanvas canvas1 = new DefaultCanvas(); canvas1.Name = "Untitled-1"; this.editor.AddCanvas(canvas1); #endregion #region Commands //BlackCanvasBgCommand blackCanvasBgCmd = new BlackCanvasBgCommand(this.canvas); //WhiteCanvasBgCommand whiteCanvasBgCmd = new WhiteCanvasBgCommand(this.canvas); #endregion #region Menubar Debug.WriteLine("Loading menubar..."); this.menubar = new DefaultMenubar(); this.Controls.Add((Control)this.menubar); DefaultMenuItem fileMenuItem = new DefaultMenuItem("File"); this.menubar.AddMenuItem(fileMenuItem); DefaultMenuItem newMenuItem = new DefaultMenuItem("New"); fileMenuItem.AddMenuItem(newMenuItem); fileMenuItem.AddSeparator(); DefaultMenuItem exitMenuItem = new DefaultMenuItem("Exit"); fileMenuItem.AddMenuItem(exitMenuItem); DefaultMenuItem editMenuItem = new DefaultMenuItem("Edit"); this.menubar.AddMenuItem(editMenuItem); DefaultMenuItem undoMenuItem = new DefaultMenuItem("Undo"); editMenuItem.AddMenuItem(undoMenuItem); DefaultMenuItem redoMenuItem = new DefaultMenuItem("Redo"); editMenuItem.AddMenuItem(redoMenuItem); //DefaultMenuItem viewMenuItem = new DefaultMenuItem("View"); //this.menubar.AddMenuItem(viewMenuItem); //DefaultMenuItem helpMenuItem = new DefaultMenuItem("Help"); //this.menubar.AddMenuItem(helpMenuItem); //DefaultMenuItem aboutMenuItem = new DefaultMenuItem("About"); //helpMenuItem.AddMenuItem(aboutMenuItem); #endregion #region Toolbox // Initializing toolbox Debug.WriteLine("Loading toolbox..."); this.toolbox = new DefaultToolbox(); this.toolStripContainer1.LeftToolStripPanel.Controls.Add((Control)this.toolbox); this.editor.Toolbox = toolbox; #endregion #region Tools // Initializing tools Debug.WriteLine("Loading tools..."); this.toolbox.AddTool(new SelectionTool()); this.toolbox.AddSeparator(); this.toolbox.AddTool(new LineTool()); this.toolbox.AddTool(new RectangleTool()); this.toolbox.AddTool(new CircleTool()); this.toolbox.AddTool(new AddTextTool()); if (plugins != null) { for (int i = 0; i < this.plugins.Length; i++) { this.toolbox.Register(plugins[i]); } } this.toolbox.ToolSelected += Toolbox_ToolSelected; #endregion #region Toolbar // Initializing toolbar Debug.WriteLine("Loading toolbar..."); this.toolbar = new DefaultToolbar(); this.toolStripContainer1.TopToolStripPanel.Controls.Add((Control)this.toolbar); ExampleToolbarItem toolItem1 = new ExampleToolbarItem(); //toolItem1.SetCommand(whiteCanvasBgCmd); ExampleToolbarItem toolItem2 = new ExampleToolbarItem(); //toolItem2.SetCommand(blackCanvasBgCmd); this.toolbar.AddToolbarItem(toolItem1); this.toolbar.AddSeparator(); this.toolbar.AddToolbarItem(toolItem2); #endregion }
/// <summary> /// Submit a work item with tasks which have dependant files. /// The files are automatically uploaded to Azure Storage using the FileStaging feature of the Azure.Batch client library. /// </summary> /// <param name="client"></param> private static void AddWorkWithFileStaging(IBatchClient client) { using (IWorkItemManager wm = client.OpenWorkItemManager()) { IToolbox toolbox = client.OpenToolbox(); ITaskSubmissionHelper taskSubmissionHelper = toolbox.CreateTaskSubmissionHelper(wm, Program.PoolName); taskSubmissionHelper.WorkItemName = Environment.GetEnvironmentVariable("USERNAME") + DateTime.Now.ToString("yyyyMMdd-HHmmss"); Console.WriteLine("Creating work item: {0}", taskSubmissionHelper.WorkItemName); ICloudTask taskToAdd1 = new CloudTask("task_with_file1", "cmd /c type *.txt"); ICloudTask taskToAdd2 = new CloudTask("task_with_file2", "cmd /c dir /s"); //Set up a collection of files to be staged -- these files will be uploaded to Azure Storage //when the tasks are submitted to the Azure Batch service. taskToAdd1.FilesToStage = new List <IFileStagingProvider>(); taskToAdd2.FilesToStage = new List <IFileStagingProvider>(); // generate a local file in temp directory Process cur = Process.GetCurrentProcess(); string path = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), cur.Id.ToString() + ".txt"); System.IO.File.WriteAllText(path, "hello from " + cur.Id.ToString()); // add file as task dependency so it'll be uploaded to storage before task // is submitted and download onto the VM before task starts execution FileToStage file = new FileToStage(path, new StagingStorageAccount(Program.StorageAccount, Program.StorageKey, Program.StorageBlobEndpoint)); taskToAdd1.FilesToStage.Add(file); taskToAdd2.FilesToStage.Add(file); // filetostage object can be reused taskSubmissionHelper.AddTask(taskToAdd1); taskSubmissionHelper.AddTask(taskToAdd2); IJobCommitUnboundArtifacts artifacts = null; bool errors = false; try { //Stage the files to Azure Storage and add the tasks to Azure Batch. artifacts = taskSubmissionHelper.Commit() as IJobCommitUnboundArtifacts; } catch (AggregateException ae) { errors = true; // Go through all exceptions and dump useful information ae.Handle((x) => { if (x is BatchException) { BatchException be = x as BatchException; if (null != be.RequestInformation && null != be.RequestInformation.AzureError) { // Write the server side error information Console.Error.WriteLine(be.RequestInformation.AzureError.Code); Console.Error.WriteLine(be.RequestInformation.AzureError.Message.Value); if (null != be.RequestInformation.AzureError.Values) { foreach (var v in be.RequestInformation.AzureError.Values) { Console.Error.WriteLine(v.Key + " : " + v.Value); } } } } else { Console.WriteLine(x); } // Indicate that the error has been handled return(true); }); } // if there is no exception, wait for job response if (!errors) { List <ICloudTask> tasksToMonitorForCompletion = wm.ListTasks(artifacts.WorkItemName, artifacts.JobName).ToList(); Console.WriteLine("Waiting for all tasks to complete on work item: {0}, Job: {1} ...", artifacts.WorkItemName, artifacts.JobName); client.OpenToolbox().CreateTaskStateMonitor().WaitAll(tasksToMonitorForCompletion, TaskState.Completed, TimeSpan.FromMinutes(30)); foreach (ICloudTask task in wm.ListTasks(artifacts.WorkItemName, artifacts.JobName)) { Console.WriteLine("Task " + task.Name + " says:\n" + task.GetTaskFile(Constants.StandardOutFileName).ReadAsString()); Console.WriteLine(task.GetTaskFile(Constants.StandardErrorFileName).ReadAsString()); } } Console.WriteLine("Deleting work item: {0}", artifacts.WorkItemName); wm.DeleteWorkItem(artifacts.WorkItemName); //Don't forget to delete the work item before you exit } }
public CopySelectedItemCommand(IToolbox toolbox) { _toolbox = toolbox; }
public RenameToolboxCategoryCommand(IToolbox toolbox) { _toolbox = toolbox; }
private void InitUI() { //parent dari canvas editor = new DefaultEditor(); //genereate menu bar MenuStrip MenuBar = new MenuStrip(); ToolStripMenuItem file = new ToolStripMenuItem("File"); ToolStripMenuItem edit = new ToolStripMenuItem("Edit"); ToolStripMenuItem arrange = new ToolStripMenuItem("Arrange"); ToolStripMenuItem sendToBack = new ToolStripMenuItem("Send to back"); sendToBack.Click += SendToBack_Click; ToolStripMenuItem sendToFront = new ToolStripMenuItem("Send to front"); sendToFront.Click += SendToFront_Click; ToolStripMenuItem newFile = new ToolStripMenuItem("New"); newFile.Click += NewFile_Click; ToolStripMenuItem removeFile = new ToolStripMenuItem("Remove current canvas"); removeFile.Click += RemoveFile_Click; ToolStripMenuItem newplugin = new ToolStripMenuItem("Add Plugin"); newplugin.Click += Newplugin_Click; ToolStripMenuItem exportToImages = new ToolStripMenuItem("Export to Images"); exportToImages.Click += ExportToImages_Click; ToolStripMenuItem groupObject = new ToolStripMenuItem("Group current and previous object"); groupObject.Click += GroupObject_Click; ToolStripMenuItem unGroupObject = new ToolStripMenuItem("Ungroup Object"); unGroupObject.Click += UnGroupObject_Click; ToolStripMenuItem deleteObject = new ToolStripMenuItem("Delete seleceted object"); deleteObject.Click += DeleteObject_Click; ToolStripMenuItem exit = new ToolStripMenuItem("Exit"); exit.Click += Exit_Click; ToolStripMenuItem undo = new ToolStripMenuItem("Undo"); ToolStripMenuItem redo = new ToolStripMenuItem("Redo"); ToolStripMenuItem resizecanvas = new ToolStripMenuItem("Resize Canvas"); resizecanvas.Click += Resizecanvas_Click; ToolStripContainer toolContainer = new ToolStripContainer(); toolContainer.ContentPanel.Controls.Add((System.Windows.Forms.Control)editor); curCanvas = new DefaultCanvas(undoRedo); curCanvas.Name = "Main"; editor.AddCanvas(curCanvas); // Generate Toolbar toolbar = new DefaultToolbar(); ToolStripContainer toolStripContainer = new ToolStripContainer(); toolStripContainer.Height = 32; toolStripContainer.TopToolStripPanel.Controls.Add((System.Windows.Forms.Control) this.toolbar); UndoToolbarItem undoItem = new UndoToolbarItem(undoRedo, curCanvas); RedoToolbarItem redoItem = new RedoToolbarItem(undoRedo, curCanvas); toolbar.AddToolbarItem(undoItem); toolbar.AddToolbarItem(redoItem); toolbar.AddSeparator(); toolStripContainer.Dock = DockStyle.Top; //meyusun menu bar MenuBar.Items.Add(file); MenuBar.Items.Add(edit); MenuBar.Items.Add(arrange); edit.DropDown.Items.Add(undo); edit.DropDown.Items.Add(redo); edit.DropDown.Items.Add(resizecanvas); edit.DropDown.Items.Add(deleteObject); file.DropDown.Items.Add(newFile); file.DropDown.Items.Add(newplugin); file.DropDown.Items.Add(exportToImages); file.DropDown.Items.Add(removeFile); file.DropDown.Items.Add(exit); arrange.DropDown.Items.Add(sendToBack); arrange.DropDown.Items.Add(sendToFront); arrange.DropDown.Items.Add(groupObject); arrange.DropDown.Items.Add(unGroupObject); MenuBar.Dock = DockStyle.Top; //set size form this.Height = this.tinggi; this.Width = this.lebar; //deklarasi accordion form Accordion acc = new Accordion(); acc.CheckBoxMargin = new Padding(2); acc.ContentMargin = new Padding(5, 5, 5, 5); acc.ContentPadding = new Padding(1); acc.Insets = new Padding(5); acc.ControlBackColor = System.Drawing.Color.White; acc.Width = 200; //deklarasi panel pertama //deklarasi size button int tinggi = 100; int lebar = 100; tlp = new DefaultToolbox(); tlp.TabStop = true; tlp.MaximumSize = new Size(new Point(300)); Tools.SelectionTool pilih = new Tools.SelectionTool(undoRedo); pilih.Height = tinggi; pilih.Width = lebar; pilih.Image = null; pilih.BackgroundImage = Resources.Assets.cursor; pilih.BackgroundImageLayout = ImageLayout.Zoom; tlp.AddTool(pilih); Tools.TextTool txtTool = new Tools.TextTool(); txtTool.Height = tinggi; txtTool.Width = lebar; txtTool.Image = null; txtTool.BackgroundImage = Resources.Assets.font; txtTool.BackgroundImageLayout = ImageLayout.Zoom; tlp.AddTool(txtTool); if (plugins != null) { for (int i = 0; i < this.plugins.Length; i++) { this.tlp.Register(plugins[i]); } } acc.Add((System.Windows.Forms.Control)tlp, "Wireframes", "Enter the client's information.", 0, true);//memasukkan panel pertama acc.Add(new System.Windows.Forms.TextBox { Dock = DockStyle.Fill, Multiline = true, BackColor = Color.White }, "Memo", "Additional Client Info", 1, true, contentBackColor: Color.Transparent); //menambahkan panel kedua acc.Dock = DockStyle.Fill; mainPanel.Dock = DockStyle.Fill; mainPanel.Panel1.Controls.Add(acc); mainPanel.FixedPanel = FixedPanel.Panel1; mainPanel.MinimumSize = new Size(300, 200); mainPanel.Panel2.BackColor = System.Drawing.Color.White; toolContainer.Dock = DockStyle.Fill; mainPanel.Panel2.Controls.Add(toolContainer); mainPanel.SplitterWidth = 15; mainPanel.SplitterDistance = 300; Controls.Add(mainPanel); Controls.Add(toolStripContainer); Controls.Add(MenuBar); this.tlp.ToolSelected += Toolbox_ToolSelected; newSVGToolPhone("phone-line.svg"); newSVGToolWireframe("chatting.svg"); newSVGToolWireframe("image-feed.svg"); newSVGToolWireframe("insta-feed.svg"); newSVGToolWireframe("list.svg"); newSVGToolWireframe("login.svg"); newSVGToolWireframe("modal-popup.svg"); newSVGToolWireframe("product-detail.svg"); newSVGToolWireframe("user-feed.svg"); newSVGToolWireframe("video-detail.svg"); newSVGToolWireframe("post-with-image.svg"); }
internal ToolboxSearchTask(uint cookie, ISearchQuery query, ISearchCallback callback, IToolbox toolbox) : base(cookie, query, callback) { _toolbox = toolbox; }
private void InitUI() { Debug.WriteLine("Initializing UI objects."); #region Editor and Canvas Debug.WriteLine("Loading canvas..."); this.editor = new DefaultEditor(); this.toolStripContainer1.ContentPanel.Controls.Add((Control)this.editor); ICanvas canvas = new DefaultCanvas(); canvas.Name = "Pattern Design"; this.editor.AddCanvas(canvas); #endregion #region Commands //command di menubar file GenerateFile addGenerateFile = new GenerateFile(canvas); Save save = new Save(canvas); OpenFile open = new OpenFile(canvas); Exit exit = new Exit(); //command di menubar edit undo = new Undo(canvas); redo = new Redo(canvas); copy = new Copy(canvas); paste = new Paste(canvas); //command di menubar generate AddPattern1 addPattern1 = new AddPattern1(canvas); AddFactoryPattern addFactoryPattern = new AddFactoryPattern(canvas); AddCommandPattern addCommandPattern = new AddCommandPattern(canvas); AddCompositePattern addCompositePattern = new AddCompositePattern(canvas); AddFacadePattern addFacadePattern = new AddFacadePattern(canvas); AddMementoPattern addMementroPattern = new AddMementoPattern(canvas); AddSingletonPattern addSingletonPattern = new AddSingletonPattern(canvas); #endregion #region Menubar Debug.WriteLine("Loading menubar..."); this.menubar = new DefaultMenubar(); this.Controls.Add((Control)this.menubar); //menubar file DefaultMenuItem fileMenuItem = new DefaultMenuItem("File"); this.menubar.AddMenuItem(fileMenuItem); DefaultMenuItem generateFile = new DefaultMenuItem("Generate Class File"); generateFile.SetCommand(addGenerateFile); fileMenuItem.AddMenuItem(generateFile); DefaultMenuItem openItem = new DefaultMenuItem("Open"); openItem.SetCommand(open); fileMenuItem.AddMenuItem(openItem); DefaultMenuItem saveItem = new DefaultMenuItem("Save"); saveItem.SetCommand(save); fileMenuItem.AddMenuItem(saveItem); fileMenuItem.AddSeparator(); DefaultMenuItem exitMenuItem = new DefaultMenuItem("Exit"); exitMenuItem.SetCommand(exit); fileMenuItem.AddMenuItem(exitMenuItem); //menubar edit DefaultMenuItem editMenuItem = new DefaultMenuItem("Edit"); this.menubar.AddMenuItem(editMenuItem); DefaultMenuItem undoItem = new DefaultMenuItem("Undo"); undoItem.SetCommand(undo); editMenuItem.AddMenuItem(undoItem); DefaultMenuItem redoItem = new DefaultMenuItem("Redo"); redoItem.SetCommand(redo); editMenuItem.AddMenuItem(redoItem); DefaultMenuItem copyItem = new DefaultMenuItem("Copy"); copyItem.SetCommand(copy); editMenuItem.AddMenuItem(copyItem); DefaultMenuItem pasteItem = new DefaultMenuItem("Paste"); pasteItem.SetCommand(paste); editMenuItem.AddMenuItem(pasteItem); //menubar generate DefaultMenuItem generateMenuItem = new DefaultMenuItem("Generate"); this.menubar.AddMenuItem(generateMenuItem); DefaultMenuItem creationalSubMenu = new DefaultMenuItem("Creational Pattern"); generateMenuItem.AddMenuItem(creationalSubMenu); DefaultMenuItem structuralSubMenu = new DefaultMenuItem("Structural Pattern"); generateMenuItem.AddMenuItem(structuralSubMenu); DefaultMenuItem behavioralSubMenu = new DefaultMenuItem("Behavioral Pattern"); generateMenuItem.AddMenuItem(behavioralSubMenu); DefaultMenuItem factoryMenuItem = new DefaultMenuItem("Factory Pattern"); factoryMenuItem.SetCommand(addFactoryPattern); creationalSubMenu.AddMenuItem(factoryMenuItem); DefaultMenuItem singletonMenuItem = new DefaultMenuItem("Singleton Pattern"); singletonMenuItem.SetCommand(addSingletonPattern); creationalSubMenu.AddMenuItem(singletonMenuItem); DefaultMenuItem compositeMenuItem = new DefaultMenuItem("Composite Pattern"); compositeMenuItem.SetCommand(addCompositePattern); structuralSubMenu.AddMenuItem(compositeMenuItem); DefaultMenuItem facadeMenuItem = new DefaultMenuItem("Facade Pattern"); facadeMenuItem.SetCommand(addFacadePattern); structuralSubMenu.AddMenuItem(facadeMenuItem); DefaultMenuItem commandMenuItem = new DefaultMenuItem("Command Pattern"); commandMenuItem.SetCommand(addCommandPattern); behavioralSubMenu.AddMenuItem(commandMenuItem); DefaultMenuItem mementoMenuItem = new DefaultMenuItem("Memento Pattern"); mementoMenuItem.SetCommand(addMementroPattern); behavioralSubMenu.AddMenuItem(mementoMenuItem); #endregion #region Toolbox // Initializing toolbox Debug.WriteLine("Loading toolbox..."); this.toolbox = new DefaultToolbox(); this.toolStripContainer1.LeftToolStripPanel.Controls.Add((Control)this.toolbox); this.editor.Toolbox = toolbox; #endregion #region Tools // Initializing tools Debug.WriteLine("Loading tools..."); this.toolbox.AddTool(new SelectionTool()); this.toolbox.AddSeparator(); //this.toolbox.AddTool(new LineTool()); this.toolbox.AddTool(new ClassTool()); this.toolbox.AddSeparator(); this.toolbox.AddTool(new AssociationTool()); this.toolbox.AddTool(new DirectedTool()); this.toolbox.AddTool(new GeneralizationTool()); this.toolbox.AddTool(new DependencyTool()); this.toolbox.AddTool(new RealizationTool()); this.toolbox.AddSeparator(); //this.toolbox.AddTool(new DeleteTool()); this.toolbox.ToolSelected += Toolbox_ToolSelected; #endregion #region Toolbar // Initializing toolbar Debug.WriteLine("Loading toolbar..."); this.toolbar = new DefaultToolbar(); this.toolStripContainer1.TopToolStripPanel.Controls.Add((Control)this.toolbar); UndoToolItem undoToolItem = new UndoToolItem(canvas); undoToolItem.SetCommand(undo); RedoToolItem redoToolItem = new RedoToolItem(canvas); redoToolItem.SetCommand(redo); SaveToolbarItem saveToolItem = new SaveToolbarItem(canvas); saveToolItem.SetCommand(save); OpenToolbarItem openToolItem = new OpenToolbarItem(canvas); openToolItem.SetCommand(open); CopyToolbarItem copyToolItem = new CopyToolbarItem(canvas); copyToolItem.SetCommand(copy); PasteToolbarItem pasteToolItem = new PasteToolbarItem(canvas); pasteToolItem.SetCommand(paste); this.toolbar.AddToolbarItem(openToolItem); this.toolbar.AddToolbarItem(saveToolItem); this.toolbar.AddSeparator(); this.toolbar.AddToolbarItem(undoToolItem); this.toolbar.AddToolbarItem(redoToolItem); this.toolbar.AddSeparator(); this.toolbar.AddToolbarItem(copyToolItem); this.toolbar.AddToolbarItem(pasteToolItem); #endregion }
public ToolboxService(IInternalToolboxStateProvider stateProvider, IToolbox toolbox) { _stateProvider = stateProvider; _toolbox = toolbox; Instance = this; }