Пример #1
0
        private static void BwDoWork(object sender, DoWorkEventArgs e)
        {
            object[] threadParameter = e.Argument as object[];
            if (threadParameter == null)
            {
                return;
            }
            ITool        toolToExecute = threadParameter[0] as ITool;
            ToolProgress progForm      = threadParameter[1] as ToolProgress;

            if (progForm == null)
            {
                return;
            }
            if (toolToExecute == null)
            {
                return;
            }

            progForm.Progress(String.Empty, 0, "==================");
            progForm.Progress(String.Empty, 0, String.Format("Executing Tool: {0}", toolToExecute.Name));
            progForm.Progress(String.Empty, 0, "==================");
            toolToExecute.Execute(progForm);
            progForm.ExecutionComplete();
            progForm.Progress(String.Empty, 0, "==================");
            progForm.Progress(String.Empty, 0, String.Format("Done Executing Tool: {0}", toolToExecute.Name));
            progForm.Progress(String.Empty, 0, "==================");
        }
Пример #2
0
        private void DoDoubleClick(TreeNode theNode)
        {
            // Checks if the user double clicked a node and not a white spot
            if (theNode == null)
            {
                return;
            }

            // checks if the user clicked a tool or a category

            // Get an instance of the tool and dialog box to go with it
            toolToExecute = GetTool(theNode.Name);
            if (toolToExecute != null)
            {
                Extent ex = new Extent(-180, -90, 180, 90);

                // it wasn't a category?
                if (_legend != null)
                {
                    IMapFrame mf = _legend.RootNodes[0] as IMapFrame;
                    if (mf != null)
                    {
                        ex = mf.ViewExtents;
                    }
                }

                ToolDialog   td       = new ToolDialog(toolToExecute, DataSets, ex);
                DialogResult tdResult = td.ShowDialog(this);
                while (tdResult == DialogResult.OK && td.ToolStatus != ToolStatus.Ok)
                {
                    MessageBox.Show(MessageStrings.ToolSetupIncorectly);
                    tdResult = td.ShowDialog(this);
                }
                if (tdResult == DialogResult.OK && td.ToolStatus == ToolStatus.Ok)
                {
                    //This fires when the user clicks the "OK" button on a tool dialog
                    //First we create the progress form
                    ToolProgress progForm = new ToolProgress(1);

                    //We create a background worker thread to execute the tool
                    BackgroundWorker bw = new BackgroundWorker();
                    bw.DoWork             += BwDoWork;
                    bw.RunWorkerCompleted += executionComplete;

                    object[] threadParameter = new object[2];
                    threadParameter[0] = toolToExecute;
                    threadParameter[1] = progForm;

                    // Show the progress dialog and kick off the Async thread
                    progForm.Show(this);
                    bw.RunWorkerAsync(threadParameter);
                }
            }
        }
Пример #3
0
        private static void BwDoWork(object sender, DoWorkEventArgs e)
        {
            object[] threadParameter = e.Argument as object[];
            if (threadParameter == null)
            {
                return;
            }
            ITool        toolToExecute = threadParameter[0] as ITool;
            ToolProgress progForm      = threadParameter[1] as ToolProgress;

            if (progForm == null)
            {
                return;
            }
            if (toolToExecute == null)
            {
                return;
            }
            Thread.CurrentThread.CurrentCulture   = progForm.ToolProgressCulture;
            Thread.CurrentThread.CurrentUICulture = progForm.ToolProgressCulture;

            progForm.Progress(string.Empty, 0, "==================");
            progForm.Progress(string.Empty, 0, string.Format(MessageStrings.ToolManager_ExecutingTool, toolToExecute.Name));
            progForm.Progress(string.Empty, 0, "==================");
            bool result = false;

            try
            {
                result = toolToExecute.Execute(progForm);
            }
            catch (Exception ex)
            {
                progForm.Progress(string.Empty, 100, "Error: " + ex);
            }

            e.Result = result;
            progForm.ExecutionComplete();
            progForm.Progress(string.Empty, 100, "==================");
            progForm.Progress(string.Empty, 100, string.Format(MessageStrings.ToolManager_DoneExecutingTool, toolToExecute.Name));
            progForm.Progress(string.Empty, 100, "==================");
        }
        private static void BwDoWork(object sender, DoWorkEventArgs e)
        {
            object[] threadParameter = e.Argument as object[];
            if (threadParameter == null)
            {
                return;
            }
            IModelTool   toolToExecute = threadParameter[0] as IModelTool;
            ToolProgress progForm      = threadParameter[1] as ToolProgress;

            if (progForm == null)
            {
                return;
            }
            if (toolToExecute == null)
            {
                return;
            }
            progForm.Progress(String.Empty, 0, "==================");
            progForm.Progress(String.Empty, 0, String.Format("Executing Tool: {0}", toolToExecute.Name));
            progForm.Progress(String.Empty, 0, "==================");

            try
            {
                toolToExecute.Execute(progForm);
            }
            catch (Exception ex)
            {
                progForm.Progress(String.Empty, 100, "Failed to run. Errors:" + ex.Message);
            }
            finally
            {
                progForm.ExecutionComplete();
                progForm.Progress(String.Empty, 100, "==================");
                progForm.Progress(String.Empty, 100, String.Format("Done Executing Tool: {0}", toolToExecute.Name));
                progForm.Progress(String.Empty, 100, "==================");
            }
        }
Пример #5
0
        private static void BwDoWork(object sender, DoWorkEventArgs e)
        {
            object[] threadParameter = e.Argument as object[];
            if (threadParameter == null)
            {
                return;
            }
            ITool        toolToExecute = threadParameter[0] as ITool;
            ToolProgress progForm      = threadParameter[1] as ToolProgress;

            if (progForm == null)
            {
                return;
            }
            if (toolToExecute == null)
            {
                return;
            }
            progForm.Progress(String.Empty, 0, "==================");
            progForm.Progress(String.Empty, 0, String.Format("Executing Tool: {0}", toolToExecute.Name));
            progForm.Progress(String.Empty, 0, "==================");
            bool result = false;

            try
            {
                result = toolToExecute.Execute(progForm);
            }
            catch (Exception ex)
            {
                progForm.Progress(String.Empty, 100, "Error: " + ex);
            }
            e.Result = result;
            progForm.ExecutionComplete();
            progForm.Progress(String.Empty, 100, "==================");
            progForm.Progress(String.Empty, 100, String.Format("Done Executing Tool: {0}", toolToExecute.Name));
            progForm.Progress(String.Empty, 100, "==================");
        }