Example #1
0
        public Tuple <string, string> RunCommand(string command)
        {
            Document.Tuple singleCommandAndResult = new Document.Tuple {
                Command = command
            };
            singleCommandAndResult.Evaluate();
            String base64Result = null;

            if (singleCommandAndResult.Result != null &&
                singleCommandAndResult.Result as System.Drawing.Image != null)
            {
                Byte[] result            = null;
                System.Drawing.Image img = (System.Drawing.Image)singleCommandAndResult.Result;
                using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
                {
                    img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    result       = ms.ToArray();
                    base64Result = Convert.ToBase64String(result);
                };
            }

            return(new Tuple <string, string>(
                       singleCommandAndResult.InterpreterTextOutput,
                       base64Result));
        }
Example #2
0
        public Tuple <string, string> RunCommand(string command)
        {
            Document.Tuple singleCommandAndResult = new Document.Tuple {
                Command = command
            };
            singleCommandAndResult.Evaluate();
            String base64Result = TryConvertToBase64ImageString(singleCommandAndResult.Result);

            return(new Tuple <string, string>(
                       singleCommandAndResult.InterpreterTextOutput,
                       base64Result));
        }
Example #3
0
        /// <summary>
        /// Main-method of task/thread <see cref="m_ExecutorOfCommandQueue"/>;
        /// </summary>
        private void ExecutorOfCommandQueue()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            m_ExecutorOfCommandQueue_WorkInProgress = false;

            try {
                while (m_ExecutorOfCommandQueue_RegularTermination)
                {
                    WorksheetEntry nextCommand;
                    if (!m_CommandQueue.IsEmpty && m_CommandQueue.TryDequeue(out nextCommand))
                    {
                        m_ExecutorOfCommandQueue_WorkInProgress = true;

                        Document.Tuple nextCommand2 = (Document.Tuple) this.Invoke(new Func <Document.Tuple>(delegate() {
                            Document.Tuple ret;
                            if (nextCommand.Deleted)
                            {
                                ret = null;
                            }
                            else
                            {
                                int idx = nextCommand.Index;
                                nextCommand.GlowAnimationTimer.Start();
                                ret = this.currentDocument.CommandAndResult[idx];
                            }
                            return(ret);
                        }));

                        if (nextCommand2 != null)
                        {
                            nextCommand2.Evaluate();

                            this.Invoke(new Action(delegate() {
                                nextCommand.EvaluateCommand_Finished();
                            }));
                        }
                    }
                    m_ExecutorOfCommandQueue_WorkInProgress = false;
                    Thread.Sleep(300);
                }
            } catch (ThreadAbortException tae) {
                Console.WriteLine("Worker thread has been aborted!");
                Console.WriteLine(tae.Message);
                Console.WriteLine(tae.StackTrace);
            }
        }