Exemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                MessageBox.Show("Invalid argument length.");
                return;
            }
            log4net.GlobalContext.Properties["ImgName"] = args[0];
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(Environment.CurrentDirectory, "..", "DataSvr", "logging-config-game.xml")));

            IMGFilename = args[0];
            UnhandledExceptionHandler.Set(args, IMGFilename, LogFile);

            MasterThread.Load(IMGFilename);
            LogFile = new Logfile(IMGFilename);

            var mainForm = new GameMainForm();

            MainForm = mainForm;
            mainForm.InitializeServer();
#if FORMS
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(mainForm);
#else
            mainForm.ReadInput();
#endif
        }
Exemplo n.º 2
0
        public static ItemCanvas CreateItemCanvas(this WindowScreenContent ScreenContent,
                                                  ItemCanvas ParentItemCanvas, MasterThread MasterThread,
                                                  PaintThread PaintThread)
        {
            // create the canvas to drawn upon.
            var rv = ScreenContent.CreateWindowedItemCanvas(
                ParentItemCanvas, ParentItemCanvas.CanvasDefn.FontDefn.PointSize,
                MasterThread, PaintThread, ScreenContent.ContentNum);
            var border     = rv.Item1;
            var itemCanvas = rv.Item2;

            itemCanvas.ContentStart = ScreenContent.StartCharPoint;

            // add the canvas control ( actually the border control that contains the
            // canvas ) to the parent canvas.
            var canvasPos = ParentItemCanvas.AddItemToCanvas(
                ScreenContent.StartRowCol, itemCanvas.BorderControl);

            ScreenContent.WindowPos = canvasPos;

            ParentItemCanvas.RemoveCaret();
            itemCanvas.SetFocus();
            itemCanvas.HookBorderDrag();

            return(itemCanvas);
        }
Exemplo n.º 3
0
        public MySQL_Connection(MasterThread pMasterThread, string pUsername, string pPassword, string pDatabase, string pHost, ushort pPort = 3306)
        {
            if (pMasterThread == null)
            {
                throw new Exception("MasterThread shouldn't be NULL at this time!");
            }

            _logFile          = new Common.Logfile("Database", true, Path.Combine("Logs", pMasterThread.ServerName, "Database"));
            Stop              = false;
            _connectionString = "Server=" + pHost + "; Port=" + pPort + "; Database=" + pDatabase + "; Uid=" + pUsername + "; Pwd=" + pPassword;
            Connect();
        }
Exemplo n.º 4
0
 public void SetupPinger(MasterThread masterThread)
 {
     MasterThread.RepeatingAction.Start(
         "Database Pinger",
         (date) =>
     {
         if (!Ping())
         {
             _logFile.WriteLine("Failure pinging the server!!!!");
         }
     },
         5 * 1000, 5 * 1000);
 }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="PointSize"></param>
        /// <param name="MasterThread"></param>
        /// <returns></returns>
        public Tuple <Border, ItemCanvas> CreateWindowedItemCanvas(
            ItemCanvas ParentItemCanvas,
            double PointSize, MasterThread MasterThread, PaintThread PaintThread,
            int ContentNum)
        {
            Border border = null;

            System.Windows.Controls.Canvas canvas = null;

            border = new Border();
            border.BorderThickness = new Thickness(3);
            border.Margin          = new Thickness(5);
            border.BorderBrush     = Brushes.Aquamarine;
            border.CornerRadius    = new CornerRadius(3);

            canvas       = new System.Windows.Controls.Canvas();
            border.Child = canvas;

            var itemCanvas = new ItemCanvas(
                canvas, this.ScreenDim, PointSize, MasterThread, PaintThread,
                ContentNum);

//      this.ItemCanvas = itemCanvas;

            // add this itemCanvas to the Children of the parent ItemCanvas.
            ParentItemCanvas.AddChild(itemCanvas);

            // store reference to the Border in the ItemCanvas.  Used in the PaintThread
            // when adding the border and its contained canvas to the Telnet canvas.
            itemCanvas.BorderControl = border;

            var boxDim = itemCanvas.CanvasDefn.CharBoxDim;
            var dim    = this.ScreenDim.ToCanvasDim(boxDim);

            canvas.Width      = dim.Width;
            canvas.Height     = dim.Height;
            canvas.Background = Brushes.Black;

            canvas.Focusable = true;
            canvas.IsEnabled = true;
            canvas.Focus();

            return(new Tuple <Border, ItemCanvas>(border, itemCanvas));
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                MessageBox.Show("Invalid argument length.");
                return;
            }

            log4net.GlobalContext.Properties["ImgName"] = args[0];
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(Environment.CurrentDirectory, "..", "DataSvr", "logging-config-shop.xml")));

            IMGFilename = args[0];
            LogFile     = new Common.Logfile(IMGFilename);


            UnhandledExceptionHandler.Set(args, IMGFilename, LogFile);
            MasterThread.Load(IMGFilename);
            Pinger.Init();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(MainForm = new frmMain());
        }
Exemplo n.º 7
0
        public ItemCanvas(System.Windows.Controls.Canvas Canvas,
                          ScreenDim ScreenDim, double FontPointSize, MasterThread MasterThread,
                          PaintThread PaintThread, int ContentNum)
        {
            this.Canvas     = Canvas;
            this.CanvasDefn = new CanvasDefn(ScreenDim, FontPointSize);

            this.CaretLoc     = new ZeroRowCol(0, 0);
            this.VisualItems  = new ScreenVisualItems();
            this.CanvasCaret  = new CanvasCaret(this);
            this.MasterThread = MasterThread;
            this.PaintThread  = PaintThread;

            this.HoverBox = new HoverBox(true);
            this.HoverBox.HoverWindowMouseEnterLeave += HoverBox_HoverWindowMouseEnterLeave;
            this.HoverBox.HoverWindowChanged         += HoverBox_HoverWindowChanged;

            // the ContentNum of the ScreenContent associated with this ItemCanvas.
            this.ContentNum = ContentNum;

            HookUserInputEvents();
            // this.HoverTimer = new HoverTimer(650, this);
        }
Exemplo n.º 8
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            string itemText   = null;
            string tagText    = null;
            var    senderItem = sender as MenuItem;

            if (sender is MenuItem)
            {
                itemText = (sender as MenuItem).Header as string;
            }
            tagText = senderItem.Tag as string;

            if (itemText == "Telnet")
            {
                var devName  = "STEVE26";
                var termType = "IBM-3477-FC"; // IBM-3477-FC, IBM-3179-2
                TelnetInitialConnect(
                    this.Model.SystemName, this.Model.AutoConnect, this.Model.DeviceName, this.Model.TerminalType);
            }

            else if (itemText == "Printer")
            {
                TelnetPrinterConnect(this.Model.SystemName);
            }

            else if (itemText == "Exit")
            {
                this.canAutoClose = true;
                this.Close();
            }

            else if (itemText == "Test")
            {
                var s2 = this.Model.ScreenDefnPath;
                Debug.Print("ScreenDefnPath:" + s2);
            }

            else if (itemText == "Read xml")
            {
                string    xmlPath = "c:\\skydrive\\c#\\TextCanvasLib\\xmlfile1.xml";
                var       items   = ScreenDocReader.ReadDoc(xmlPath);
                OneRowCol caret   = null;
                this.Model.TelnetCanvas.PaintScreen(items, caret);
            }

            else if (itemText == "Print log")
            {
                LinePrinter.PrintLines(this.Model.RunLog);
            }
            else if (itemText == "Clear log")
            {
                MainWindow.LogFile.ClearFile();
                this.Model.RunLog.Clear();
                this.PaintThread.PostInputMessage(ThreadMessageCode.ClearLog);
                this.MasterThread.PostInputMessage(ThreadMessageCode.ClearLog);
                this.ToThread.PostInputMessage(ThreadMessageCode.ClearLog);
                this.FromThread.PostInputMessage(ThreadMessageCode.ClearLog);
            }
            else if (itemText == "view special")
            {
                var    specialPath = "c:\\downloads\\specialLog.txt";
                string exePath     =
                    Environment.ExpandEnvironmentVariables(@"%windir%\system32\notepad.exe");
                Process.Start(exePath, specialPath);
            }

            else if (itemText == "Report canvas items")
            {
                MasterThread.PostInputMessage(ThreadMessageCode.ReportVisualItems);
                var visualItems = this.Model.TelnetCanvas.VisualItems;
                var report      = wtdReportExt.PrintVisualItems(visualItems);
                this.Model.RunLog.AddRange(report);
            }

            else if (itemText == "Send data")
            {
                var dataBytes = new byte[] { 0x00, 0x0a, 0x12, 0xa0, 0x01, 0x02,
                                             0x04, 0x00, 0x00, 0x01, 0xff, 0xef };

                dataBytes = new byte[] { 0x00, 0x0A, 0x12, 0xA0, 0x01, 0x02,
                                         0x04, 0x00, 0x00, 0x01, 0xFF, 0xEF };

                var dataMessage = new SendDataMessage(dataBytes);
                this.ToThread.PostInputMessage(dataMessage);
            }

            // capture the currently matched screen.
            else if (tagText == "Capture")
            {
                if (this.Model.MatchScreenDefn == null)
                {
                    MessageBox.Show("no matched screen to capture");
                }
                else
                {
                    // send message to master thread to get the current screen content.
                    var msg = new ExchangeMessage(ThreadMessageCode.GetScreenContent);
                    this.MasterThread.PostInputMessage(msg);
                    msg.WaitReplyEvent();
                    var content = msg.ReplyMessage as ScreenContent;

                    // send message to capture thread telling it to capture the current
                    // screen.
                    var captureMessage = new CaptureContentMessage(
                        this.Model.CaptureFolderPath, this.Model.CaptureAuto,
                        this.Model.MatchScreenDefn, content);
                    this.CaptureThread.PostInputMessage(captureMessage);
                }
            }

            else if (tagText == "CaptureViewer")
            {
                var window = new CaptureViewerWindow();
                window.CaptureFolderPath = this.Model.CaptureFolderPath;
                window.Show();
            }
        }
Exemplo n.º 9
0
 public void Start(IProtocol protocol, IDeviceUpdatePolicy updatePolicy)
 {
     _log.AppendMessage(LogMessageType.Info, "Starting Master thread");
     _thread = MasterThread.Create(SlaveDevices, protocol, updatePolicy, _log);
     _thread.StartRoutine();
 }