Ejemplo n.º 1
0
        public void Save(string path, string[] commands, string[] results)
        {
            //build document
            Document document = new Document();

            for (int i = 0; i < commands.Length; ++i)
            {
                Document.Tuple commandBox = new Document.Tuple()
                {
                    Command = commands[i],
                    InterpreterTextOutput = results[i]
                };
                document.CommandAndResult.Add(commandBox);
            }

            //Save document
            document.Serialize(path);

            var fi = (new FileInfo(path));

            if (fi.Exists)
            {
                InteractiveShell._CurrentDocFile = fi.FullName;
            }
            else
            {
                InteractiveShell._CurrentDocFile = null;
            }
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
0
        public void Save(string path, string[] commands, string[] results)
        {
            //build document
            Document document = new Document();

            for (int i = 0; i < commands.Length; ++i)
            {
                Document.Tuple commandBox = new Document.Tuple()
                {
                    Command = commands[i],
                    InterpreterTextOutput = results[i]
                };
                document.CommandAndResult.Add(commandBox);
            }

            //Save document
            document.Serialize(path);
        }