using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Threading;
using System.Diagnostics;
using Zeta;
using Zeta.Common;
using Zeta.Common.Plugins;
using Zeta.CommonBot;
using Demonbuddy;
namespace StopStart
{
public partial class StopStart : IPlugin
{
public string Author { get { return "sinterlkaas"; } }
public string Description { get { return ""; } }
public string Name { get { return "stopstart" + Version.ToString(); } }
public Version Version { get { return new Version(0, 1); } }
public Window DisplayWindow { get { return null; } }
Thread worker;
public void OnInitialize()
{
Thread worker = new Thread(new ThreadStart(StopStartWorker));
worker.Start();
}
void StopStartWorker()
{
while (!isClosing)
{
if (BotMain.IsRunning)
{
Logging.Write("Stop bot");
BotMain.Stop();
Logging.Write("wait 5 seconds");
Thread.Sleep(5000);
Logging.Write("Start bot");
BotMain.Start();
break;
}
Thread.Sleep(100);
}
}
bool isClosing
{
get {
IntPtr h = Process.GetCurrentProcess().MainWindowHandle;
return (h == IntPtr.Zero || h == null);
}
}
public void OnShutdown()
{
}
public void OnEnabled()
{
}
public void OnDisabled()
{
}
public bool Equals(IPlugin other)
{
return (other.Name == Name) && (other.Version == Version);
}
public void OnPulse()
{
}
}
}