예제 #1
0
 public static void ProcessClose()
 {
     Instance.Dispose();
     Instance = null;
     SetText("Nothing found");
     ProcessTimer.Start();
 }
예제 #2
0
 public static void SearchProcess()
 {
     if (ProcessTimer != null)
     {
         return;
     }
     ProcessTimer          = new Timer(3000);
     ProcessTimer.Elapsed += (sender, e) =>
     {
         if (Instance != null)
         {
             return;
         }
         foreach (Process proc in Process.GetProcesses())
         {
             if (Instance is null &&
                 proc.ProcessName.IndexOf("th") == 0)
             {
                 Type type = Type.GetType($"Touhou_Presence.Data.{proc.ProcessName}");
                 if (type is null)
                 {
                     proc.Dispose();
                 }
                 else
                 {
                     bool IsIncomplete = false;
                     foreach (Attribute attr in Attribute.GetCustomAttributes(type))
                     {
                         if (attr is Incomplete)
                         {
                             IsIncomplete = true;
                         }
                     }
                     if (IsIncomplete)
                     {
                         proc.Dispose();
                         continue;
                     }
                     Instance = (TouhouBase)Activator.CreateInstance(type, proc);
                     SetText(type.Name.ToUpper() + ": " + Instance.SubTitle);
                     ProcessOpen();
                 }
                 continue;
             }