コード例 #1
0
        public MainForm(string destinationFolder, string metaInformation, string minecraftServer, string minecraftRCONPassword)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            // Get the own version:
            var versionAttribute = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).FirstOrDefault() as AssemblyFileVersionAttribute;

            this.version = versionAttribute != null ? versionAttribute.Version : "0";

            // Write the title:
            this.Text = string.Format("[Mine]craft [Re]search [Obs]ervation v{0}: {1}", version, metaInformation);

            this.destinationFolder     = destinationFolder;
            this.metaInformation       = metaInformation;
            this.minecraftServer       = minecraftServer;
            this.minecraftRCONPassword = minecraftRCONPassword;

            Screenshot.setDestinationFolder(this.destinationFolder);
            Screenshot.setMetaInformation(this.metaInformation);
            CSVWriter.setMetaInfo(this.metaInformation);
            CSVWriter.setDestinationFolder(this.destinationFolder);
            RCONLogic.setMinecraftServer(this.minecraftServer);
            RCONLogic.setMinecraftRCONPassword(this.minecraftRCONPassword);

            new DebugWindow(string.Format("[Mine]craft [Re]search [Obs]ervation v{0}, Messages: {1}", version, metaInformation)).Show(this);

            // Redirect any outpout to the standard out also in the message i.e. debug window:
            Console.SetOut(new LineEventWriter(lineReceiver));
            DebugWindow.writeLine(string.Format("Init done: Ready.\n"));
        }
コード例 #2
0
        void ButtonStopClick(object sender, EventArgs e)
        {
            this.stateLock.EnterWriteLock();

            try
            {
                if (!this.isRunning)
                {
                    return;
                }

                Task.Run(() => {
                    //Screenshot.stopAutoScreenshot();
                    RCONLogic.stopLogic();
                    CSVWriter.stopWriter();

                    this.isRunning = false;
                    DebugWindow.writeLine(string.Format("Stop recording.\n"));
                });
            }
            catch
            {
            }
            finally
            {
                this.stateLock.ExitWriteLock();
            }
        }
コード例 #3
0
        private static void checkActiveServerConnection()
        {
            var answer = RCONLogic.rconClient.sendMessage(RCONMessageType.Command, @"help");

            if (answer == string.Empty)
            {
                try
                {
                    RCONLogic.rconClient.Dispose();
                }
                catch
                {
                }

                RCONLogic.connect2RCONServer();
            }
        }
コード例 #4
0
        public static void startLogic()
        {
            if (RCONLogic.isRunning)
            {
                return;
            }

            RCONLogic.isRunning = true;
            DebugWindow.writeLine(string.Format("Starting the RCONLogic now.\n"));
            RCONLogic.currentRunningTask = Task.Factory.StartNew(() =>
            {
                RCONLogic.connect2RCONServer();
                while (RCONLogic.isRunning)
                {
                    checkActiveServerConnection();
                    checkActivePlayers();
                    Thread.Sleep(TimeSpan.FromMilliseconds(100));
                }
                DebugWindow.writeLine(string.Format("The RCONLogic is stopped now.\n"));
            }, TaskCreationOptions.LongRunning);
        }
コード例 #5
0
        void ButtonStartClick(object sender, EventArgs e)
        {
            this.stateLock.EnterWriteLock();

            try
            {
                if (this.isRunning)
                {
                    return;
                }

                this.isRunning        = true;
                this.buttonState.Text = "State: Running";

                DebugWindow.writeLine(string.Format("Start recording.\n"));

                //Screenshot.startAutoScreenshot(8);
                CSVWriter.startWriter();
                RCONLogic.startLogic();
                Task.Factory.StartNew(() =>
                {
                    while (this.isRunning)
                    {
                        animation();
                        Thread.Sleep(500);
                    }

                    resetAnimation();
                }, TaskCreationOptions.LongRunning);
            }
            catch
            {
            }
            finally
            {
                this.stateLock.ExitWriteLock();
            }
        }