public MainScreen()
 {
     InitializeComponent();
     Debug_.PrepairDebug(true);
     Variables.richTextBox = richTextBox1;
     timeout.Interval      = 15000;
     timeout.Tick         += Timeout_Tick;
 }
Пример #2
0
 /// <summary>
 /// Script log for showing
 /// </summary>
 /// <param name="log">The log</param>
 /// <param name="color">The color of log</param>
 /// <param name="lineNumber"></param>
 /// <param name="caller"></param>
 public static void ScriptLog(string log, Color color, [CallerLineNumber] int lineNumber = 0, [CallerMemberName] string caller = null)
 {
     if (richTextBox != null)
     {
         try
         {
             richTextBox.Invoke((MethodInvoker) delegate
             {
                 richTextBox.SelectionColor = color;
                 richTextBox.AppendText("[" + DateTime.Now.ToLongTimeString() + "]:" + log + "\n");
             });
             Debug_.WriteLine("ScriptLog: " + log, lineNumber, caller);
         }
         catch
         {
         }
     }
 }
Пример #3
0
 /// <summary>
 /// The advanced log which might not show, except enabled for debuging...
 /// </summary>
 /// <param name="log"></param>
 /// <param name="lineNumber"></param>
 /// <param name="caller"></param>
 public static void AdvanceLog(string log, [CallerLineNumber] int lineNumber = 0, [CallerMemberName] string caller = null)
 {
     if (richTextBox != null)
     {
         try
         {
             if (AdvanceLogShow)
             {
                 richTextBox.Invoke((MethodInvoker) delegate
                 {
                     richTextBox.SelectionColor = Color.Red;
                     richTextBox.AppendText("[" + DateTime.Now.ToLongTimeString() + "]:" + log + "\n");
                 });
             }
             Debug_.WriteLine(log, lineNumber, caller);
         }
         catch
         {
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Read emulators dll
        /// </summary>
        public static void LoadEmulatorInterface([CallerLineNumber] int lineNumber = 0, [CallerMemberName] string caller = null)
        {
            if (!new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator))
            {
                MessageBox.Show("Admin needed to run this framework!");
                Environment.Exit(0);
            }
            List <EmulatorInterface> emulators = new List <EmulatorInterface>();

            if (!Directory.Exists("Emulators"))
            {
                Directory.CreateDirectory("Emulators");
            }
            var dlls = Directory.GetFiles("Emulators", "*.dll");

            if (dlls != null)
            {
                foreach (var dll in dlls)
                {
                    try
                    {
                        Assembly a = Assembly.LoadFrom(dll);
                        foreach (var t in a.GetTypes())
                        {
                            if (t.GetInterface("EmulatorInterface") != null)
                            {
                                emulators.Add(Activator.CreateInstance(t) as EmulatorInterface);
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
            bool[] installed = new bool[emulators.Count];
            for (int x = 0; x < emulators.Count; x++)
            {
                try
                {
                    installed[x] = emulators[x].LoadEmulatorSettings();
                    if (installed[x])
                    {
                        Variables.AdvanceLog("[" + DateTime.Now.ToLongTimeString() + "]:Detected emulator " + emulators[x].EmulatorName(), lineNumber, caller);
                        EmuSelection_Resource.emu.Add(emulators[x]);
                    }
                }
                catch
                {
                }
            }
            Variables.AdbIpPort          = "";
            Variables.AndroidSharedPath  = "";
            Variables.SharedPath         = "";
            Variables.VBoxManagerPath    = "";
            Variables.ForceWinApiCapt    = false;
            Variables.ClickPointMultiply = 1;
Emulator:
            if (EmuSelection_Resource.emu.Count() > 1) //More than one installed
            {
                if (!File.Exists("Emulators\\Use_Emulator.ini"))
                {
                    Emulator_Selection em = new Emulator_Selection();
                    em.ShowDialog();
                    if (em.DialogResult == DialogResult.OK)
                    {
                        foreach (var e in emulators)
                        {
                            if (e.GetType().Name == EmuSelection_Resource.selected)
                            {
                                Variables.emulator = e;
                                e.LoadEmulatorSettings();
                                CheckSharedPath();
                                File.WriteAllText("Emulators\\Use_Emulator.ini", "use=" + e.GetType().Name);
                                Debug_.WriteLine("[" + DateTime.Now.ToLongTimeString() + "]:Emulator used: " + Variables.emulator.GetType().Name);
                                return;
                            }
                        }
                    }
                    else //No selection
                    {
                        for (int x = 0; x < emulators.Count(); x++)
                        {
                            if (installed[x])
                            {
                                Variables.emulator = emulators[x];
                                emulators[x].LoadEmulatorSettings();
                                CheckSharedPath();
                                File.WriteAllText("Emulators\\Use_Emulator.ini", "use=" + emulators[x].EmulatorName());
                                Debug_.WriteLine("[" + DateTime.Now.ToLongTimeString() + "]:Emulator used: " + Variables.emulator.GetType().Name);
                                return;
                            }
                        }
                    }
                }
                else
                {
                    var line = File.ReadAllLines("Emulators\\Use_Emulator.ini")[0].Replace("use=", "");
                    foreach (var e in emulators)
                    {
                        if (e.GetType().Name == line)
                        {
                            Variables.emulator = e;
                            e.LoadEmulatorSettings();
                            CheckSharedPath();
                            Debug_.WriteLine("[" + DateTime.Now.ToLongTimeString() + "]:Emulator used: " + Variables.emulator.GetType().Name);
                            return;
                        }
                    }
                    if (Variables.emulator == null)
                    {
                        File.Delete("Emulators\\Use_Emulator.ini");
                        goto Emulator;
                    }
                }
            }
            else if (EmuSelection_Resource.emu.Count() < 1) //No installed
            {
                Debug_.WriteLine("[" + DateTime.Now.ToLongTimeString() + "]:However none of this are usable!");
                MessageBox.Show("Please install any supported emulator first or install extentions to support your current installed emulator!", "No supported emulator found!");
                Environment.Exit(0);
            }
            else
            {
                Variables.emulator = EmuSelection_Resource.emu[0];
                Variables.emulator.LoadEmulatorSettings();
                Debug_.WriteLine("[" + DateTime.Now.ToLongTimeString() + "]:Emulator used: " + Variables.emulator.GetType().Name);
                CheckSharedPath();
            }
        }