internal void LoadImageFromFile(Triggernometry.RealPlugin plug, Graphics g, string ifn)
        {
            string fn = AuraImage.ResolveImageFilename(plug, ifn);

            byte[] data = File.ReadAllBytes(fn);
            LoadImageDataFromByte(plug, g, data);
        }
Exemple #2
0
        internal static string GetImageFilename(Triggernometry.RealPlugin plug, string ifn)
        {
            Uri u = new Uri(ifn);

            if (u.IsFile == true)
            {
                return(ifn);
            }
            else
            {
                string fn = Path.Combine(plug.path, "TriggernometryRemoteImages");
                if (Directory.Exists(fn) == false)
                {
                    Directory.CreateDirectory(fn);
                }
                string ext = Path.GetExtension(u.LocalPath);
                fn = Path.Combine(fn, plug.GenerateHash(u.AbsoluteUri) + Path.GetExtension(u.LocalPath));
                if (File.Exists(fn) == true)
                {
                    FileInfo fi = new FileInfo(fn);
                    DateTime dt = DateTime.Now.AddMinutes(0 - plug.cfg.CacheImageExpiry);
                    if (fi.LastWriteTime > dt)
                    {
                        return(fn);
                    }
                }
                using (WebClient wc = new WebClient())
                {
                    wc.Headers["User-Agent"] = "Triggernometry Image Retriever";
                    byte[] data = wc.DownloadData(u.AbsoluteUri);
                    File.WriteAllBytes(fn, data);
                    return(fn);
                }
            }
        }
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            Instance          = new Triggernometry.RealPlugin();
            Instance.mainform = ActGlobals.oFormActMain;
            Version iv = typeof(Triggernometry.RealPlugin).Assembly.GetName().Version;
            Version ip = typeof(ProxyPlugin).Assembly.GetName().Version;

            if (iv.CompareTo(ip) != 0)
            {
                ComplainAboutReload();
            }
            FailsafeRegisterHook("InCombatHook", "InCombat");
            FailsafeRegisterHook("EndCombatHook", "EndCombat");
            FailsafeRegisterHook("CurrentZoneHook", "GetCurrentZone");
            FailsafeRegisterHook("ActiveEncounterHook", "ExportActiveEncounter");
            FailsafeRegisterHook("LastEncounterHook", "ExportLastEncounter");
            FailsafeRegisterHook("EncounterDurationHook", "GetEncounterDuration");
            FailsafeRegisterHook("TtsPlaybackHook", "InvokeTtsMethod");
            FailsafeRegisterHook("SoundPlaybackHook", "InvokeSoundMethod");
            FailsafeRegisterHook("CustomTriggerCheckHook", "HasCustomTriggers");
            FailsafeRegisterHook("CustomTriggerHook", "GetCustomTriggers");
            FailsafeRegisterHook("CornerShowHook", "ShowCornerNotification");
            FailsafeRegisterHook("CornerHideHook", "HideCornerNotification");
            FailsafeRegisterHook("TabLocateHook", "LocateTab");
            FailsafeRegisterHook("InstanceHook", "GetInstance");
            GetPluginNameAndPath();
            ActGlobals.oFormActMain.OnLogLineRead += OFormActMain_OnLogLineRead;
            Instance.InitPlugin(pluginScreenSpace, pluginStatusText);
        }
Exemple #4
0
        internal void LoadImageData(Triggernometry.RealPlugin plug, Graphics g, string ifn)
        {
            Uri u = new Uri(ifn);

            if (u.IsFile == true)
            {
                LoadImageDataFromFile(plug, g, ifn);
            }
            else
            {
                string fn = Path.Combine(plug.path, "TriggernometryRemoteImages");
                if (Directory.Exists(fn) == false)
                {
                    Directory.CreateDirectory(fn);
                }
                string ext = Path.GetExtension(u.LocalPath);
                fn = Path.Combine(fn, plug.HashRepositoryAddress(u.AbsoluteUri) + Path.GetExtension(u.LocalPath));
                if (File.Exists(fn) == false)
                {
                    using (WebClient wc = new WebClient())
                    {
                        wc.Headers["User-Agent"] = "Triggernometry Image Retriever";
                        byte[] data = wc.DownloadData(u.AbsoluteUri);
                        File.WriteAllBytes(fn, data);
                    }
                }
                if (File.Exists(fn) == true)
                {
                    LoadImageDataFromFile(plug, g, fn);
                }
            }
        }
Exemple #5
0
 internal void LoadFontData(Triggernometry.RealPlugin plug)
 {
     TextFont = _graphics.CreateFont(
         FontName,
         FontSize,
         (FontStyle & System.Drawing.FontStyle.Bold) == System.Drawing.FontStyle.Bold,
         (FontStyle & System.Drawing.FontStyle.Italic) == System.Drawing.FontStyle.Italic,
         true
         );
 }
Exemple #6
0
 public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
 {
     Instance                               = new Triggernometry.RealPlugin();
     Instance.mainform                      = ActGlobals.oFormActMain;
     Instance.InCombatHook                  = InCombat;
     Instance.EndCombatHook                 = EndCombat;
     Instance.CurrentZoneHook               = GetCurrentZone;
     Instance.ActiveEncounterHook           = ExportActiveEncounter;
     Instance.LastEncounterHook             = ExportLastEncounter;
     Instance.EncounterDurationHook         = GetEncounterDuration;
     Instance.TtsPlaybackHook               = InvokeTtsMethod;
     Instance.SoundPlaybackHook             = InvokeSoundMethod;
     Instance.CustomTriggerCheckHook        = HasCustomTriggers;
     Instance.CustomTriggerHook             = GetCustomTriggers;
     Triggernometry.RealPlugin.InstanceHook = GetInstance;
     GetPluginNameAndPath();
     ActGlobals.oFormActMain.OnLogLineRead += OFormActMain_OnLogLineRead;
     Instance.InitPlugin(pluginScreenSpace, pluginStatusText);
 }
 internal void LoadImageDataFromByte(Triggernometry.RealPlugin plug, Graphics g, byte[] data)
 {
     /*
      * GifData gif = GetGifData(data);
      * using (MemoryStream ms = new MemoryStream(data))
      * {
      *  using (System.Drawing.Image i = System.Drawing.Image.FromStream(ms))
      *  {
      *      System.Drawing.Bitmap b = (System.Drawing.Bitmap)i;
      *      System.Drawing.Imaging.FrameDimension CurrentFd = new System.Drawing.Imaging.FrameDimension(i.FrameDimensionsList[0]);
      *      NumberOfFrames = i.GetFrameCount(CurrentFd);
      *      IsAnimated = (NumberOfFrames > 1);
      *      if (IsAnimated == true)
      *      {
      *          Frames = new List<Image>();
      *          FrameDelays = new List<int>();
      *          System.Drawing.Imaging.PropertyItem delay = i.GetPropertyItem(0x5100);
      *          Color tc;
      *          bool hastc = false;
      *          if (gif.TransparencyIndex >= 0)
      *          {
      *              tc = gif.Palette[gif.TransparencyIndex];
      *              hastc = true;
      *          }
      *          else
      *          {
      *              tc = gif.Palette[0];
      *          }
      *          for (int h = 0; h < NumberOfFrames; h++)
      *          {
      *              int delayn = (delay.Value[h * 4] + (delay.Value[(h * 4) + 1] * 256)) * 10;
      *              FrameDelays.Add(delayn);
      *              i.SelectActiveFrame(CurrentFd, h);
      *              System.Drawing.Image ifa = ((System.Drawing.Image)i.Clone());
      *              byte[] idata = ImageToByte(ifa);
      *              if (hastc == true)
      *              {
      *                  if (gif.TransparencyIndex != gif.BackgroundColor)
      *                  {
      *                      // hack in case transparency color is different from bgcolor (some gifs have this shit)
      *                      SetTransparencyIndex(idata, (byte)gif.BackgroundColor);
      *                  }
      *                  else
      *                  {
      *                      for (int j = 0; j < gif.TransparencyIndex; j++)
      *                      {
      *                          if ((gif.Palette[j].R == tc.R) && (gif.Palette[j].R == tc.G) && (gif.Palette[j].R == tc.B))
      *                          {
      *                              // net itself might have selected an earlier color as new transparency color
      *                              // hack to reset transparency index to match if so
      *                              SetTransparencyIndex(idata, (byte)j);
      *                              break;
      *                          }
      *                      }
      *                  }
      *              }
      *              Frames.Add(g.CreateImage(idata));
      *          }
      *          CurrentFrame = -1;
      *          AdvanceFrame();
      *      }
      *      else
      *      {
      *          OriginalImage = g.CreateImage(data);
      *      }
      *  }
      * }*/
 }
 internal void LoadImageDataFromFile(Triggernometry.RealPlugin plug, Graphics g, string fn)
 {
     byte[] data = File.ReadAllBytes(fn);
     LoadImageDataFromByte(plug, g, data);
 }
Exemple #9
0
        internal void LoadImageDataFromFile(Triggernometry.RealPlugin plug, Graphics g, string fn)
        {
            byte[]  data = File.ReadAllBytes(fn);
            GifData gif  = GetGifData(data);

            using (MemoryStream ms = new MemoryStream(data))
            {
                using (System.Drawing.Image i = System.Drawing.Image.FromStream(ms))
                {
                    System.Drawing.Bitmap b = (System.Drawing.Bitmap)i;
                    System.Drawing.Imaging.FrameDimension CurrentFd = new System.Drawing.Imaging.FrameDimension(i.FrameDimensionsList[0]);
                    NumberOfFrames = i.GetFrameCount(CurrentFd);
                    IsAnimated     = (NumberOfFrames > 1);
                    if (IsAnimated == true)
                    {
                        Frames      = new List <Image>();
                        FrameDelays = new List <int>();
                        System.Drawing.Imaging.PropertyItem delay = i.GetPropertyItem(0x5100);
                        Color tc;
                        bool  hastc = false;
                        if (gif.TransparencyIndex >= 0)
                        {
                            tc    = gif.Palette[gif.TransparencyIndex];
                            hastc = true;
                        }
                        else
                        {
                            tc = gif.Palette[0];
                        }
                        for (int h = 0; h < NumberOfFrames; h++)
                        {
                            int delayn = (delay.Value[h * 4] + (delay.Value[(h * 4) + 1] * 256)) * 10;
                            FrameDelays.Add(delayn);
                            i.SelectActiveFrame(CurrentFd, h);
                            System.Drawing.Image ifa = ((System.Drawing.Image)i.Clone());
                            byte[] idata             = ImageToByte(ifa);
                            if (hastc == true)
                            {
                                if (gif.TransparencyIndex != gif.BackgroundColor)
                                {
                                    // hack in case transparency color is different from bgcolor (some gifs have this shit)
                                    SetTransparencyIndex(idata, (byte)gif.BackgroundColor);
                                }
                                else
                                {
                                    for (int j = 0; j < gif.TransparencyIndex; j++)
                                    {
                                        if ((gif.Palette[j].R == tc.R) && (gif.Palette[j].R == tc.G) && (gif.Palette[j].R == tc.B))
                                        {
                                            // net itself might have selected an earlier color as new transparency color
                                            // hack to reset transparency index to match if so
                                            SetTransparencyIndex(idata, (byte)j);
                                            break;
                                        }
                                    }
                                }
                            }
                            Frames.Add(g.CreateImage(idata));
                        }
                        CurrentFrame = -1;
                        AdvanceFrame();
                    }
                    else
                    {
                        OriginalImage = g.CreateImage(data);
                    }
                }
            }
        }