示例#1
0
        GuiAction readMode; // for distinguishing between various ways of reading input

        public MainForm()
        {
            InitializeComponent();
            Text = "C# Prolog -- basic Windows version";
            persistentSettings = new PrologEngine.ApplicationStorage();
            stop         = null;
            semaGetInput = new ManualResetEvent(false);
            charBuffer   = new Queue <int> ();
            winIO        = new WinIO(bgwExecuteQuery, semaGetInput, tbInput, charBuffer);
            bgwExecuteQuery.DoGuiAction(GuiAction.BtnsOff);
            pe       = new PrologEngine(winIO);
            readMode = GuiAction.None;
        }
        private ConsoleAction readMode; // for distinguishing between various ways of reading input

        public DiagnosticConsole()
        {
            InitializeComponent();

            Text = "Prolog diagnostic console";

            stop         = null;
            semaGetInput = new ManualResetEvent(false);
            charBuffer   = new Queue <int>();
            winIO        = new WinIO(this, charBuffer);
            bgwExecuteQuery.ReportProgress((int)ConsoleAction.BtnsOff);
            service  = new LogicService(winIO);
            readMode = ConsoleAction.None;
        }
 public MainForm()
 {
     InitializeComponent ();
       Text = "C# Prolog -- basic Windows version";
       persistentSettings = new PrologEngine.ApplicationStorage ();
       stop = null;
       semaGetInput = new ManualResetEvent (false);
       charBuffer = new Queue<int> ();
       winIO = new WinIO (bgwExecuteQuery, semaGetInput, tbInput, charBuffer);
       bgwExecuteQuery.DoGuiAction (GuiAction.BtnsOff);
       pe = new PrologEngine (winIO);
       readMode = GuiAction.None;
 }
示例#4
0
        //--------------------------------------------------------
        //--------------------------------------------------------
        public static void PrintTextWin32(TextBox textIn)
        {
            IntPtr hPort;

            string strPort;

            // strPort = @"\\Server\HP5si_PCL";
            // strPort = @"COM1:";
            strPort = @"\My Documents\TextPrint.dat";

            hPort = WinIO.CreateFile(strPort,
                                     WinIO.ACCESS.WRITE, WinIO.FILE_SHARE.WRITE, 0,
                                     WinIO.FILE_ACTION.OPEN_ALWAYS, WinIO.FILE_ATTRIBUTE.NORMAL, 0);

            // ?? Need to call SetCommState to set baud rate, etc. ??
            if (hPort == WinIO.INVALID_FILE_HANDLE)
            {
                MessageBox.Show("Error opening port", "PrintDirect");
            }
            else
            {
                // Split input data into separate lines of text.
                char []   achNewLine = new char[] { '\n' };
                String [] astrSplit;
                astrSplit = textIn.Text.Split(achNewLine);

                int i;
                int cstr = astrSplit.Length;

                // Check for largest string in document.
                int cchMax = 0;
                for (i = 0; i < cstr; i++)
                {
                    if (astrSplit[i].Length > cchMax)
                    {
                        cchMax = astrSplit[i].Length;
                    }
                }
                cchMax = cchMax + 5; // Add some padding.

                // Allocate conversion buffers.
                byte[] byteData       = new Byte[cchMax];
                char[] chData         = new Char[cchMax];
                int    cbWritten      = 0;
                System.Text.Encoder d = System.Text.Encoding.UTF8.GetEncoder();

                for (i = 0; i < cstr; i++)
                {
                    int cch = astrSplit[i].Length;
                    if (cch > 0)
                    {
                        //MessageBox.Show(i.ToString() + " " + astrSplit[i]);
                        chData = astrSplit[i].ToCharArray();
                        int charLen = d.GetBytes(chData, 0, cch, byteData, 0, true);
                        WinIO.WriteFile(hPort, byteData, charLen, ref cbWritten, IntPtr.Zero);
                    }

                    // Put a <CR><LF> at the end of the line.
                    byte[] byteCrLf = new byte[] { CR };
                    WinIO.WriteFile(hPort, byteCrLf, 2, ref cbWritten, IntPtr.Zero);
                }
                // Put a <FF> at the end of the document.
                byte[] byteFF = new byte[] { 0x0c };
                WinIO.WriteFile(hPort, byteFF, 1, ref cbWritten, IntPtr.Zero);
                WinIO.CloseHandle(hPort);
            }
        }