示例#1
0
        public static void StartActivator(
            Action callback)
        {
            SetTLSProtocol();

            if (!isStarted)
            {
                ActivationManager.Instance.ActivationDeniedCallback += () =>
                {
                    AppLog.DefaultLogger.Fatal(ActivationDenyMessage);

                    WPFHelper.Invoke(() =>
                    {
                        foreach (var callback in ActivationDeniedCallbackList)
                        {
                            callback.Invoke();
                        }
                    });
                };
            }

            isStarted = true;

            ActivationDeniedCallbackList.Add(callback);
            ActivationManager.Instance.Start();
        }
示例#2
0
        /// <summary>
        /// NLogから呼ばれるUI向けログ出力
        /// </summary>
        /// <param name="dateTime">日付</param>
        /// <param name="level">ログレベル</param>
        /// <param name="callsite">callsite</param>
        /// <param name="message">メッセージ</param>
        public static void AppendLog(
            string dateTime,
            string level,
            string callsite,
            string message)
        {
            DateTime d;

            DateTime.TryParse(dateTime, out d);

            var entry = new AppLogEntry()
            {
                DateTime = d,
                Level    = level,
                CallSite = callsite,
                Message  = message,
            };

            lock (AppLog.locker)
            {
                if (AppLog.logBuffer.Count > LogBufferSize)
                {
                    AppLog.logBuffer.RemoveRange(0, LogBufferMargin);
                }

                AppLog.logBuffer.Add(entry);
            }

            WPFHelper.BeginInvoke(() =>
                                  AppLog.OnAppendedLog(new AppendedLogEventArgs(entry)));
        }
示例#3
0
        public async void Load()
        {
            var dir = DirectoryHelper.FindSubDirectory(
                @"resources\icon\job");

            if (!Directory.Exists(dir))
            {
                return;
            }

            await WPFHelper.InvokeAsync(() =>
            {
                foreach (var job in (JobIDs[])Enum.GetValues(typeof(JobIDs)))
                {
                    var png = Path.Combine(dir, $"{job}.png");
                    if (!File.Exists(png))
                    {
                        continue;
                    }

                    var bmp = default(WriteableBitmap);
                    using (var ms = new WrappingStream(new MemoryStream(File.ReadAllBytes(png))))
                    {
                        bmp = new WriteableBitmap(BitmapFrame.Create(ms));
                    }

                    bmp.Freeze();
                    this.Icons[job] = bmp;
                }
            });

            this.isLoaded = true;
        }
示例#4
0
        private static void OnActivationDenied()
        {
            AppLog.DefaultLogger.Fatal(ActivationDenyMessage);

            WPFHelper.Invoke(() =>
            {
                foreach (var callback in ActivationDeniedCallbackList)
                {
                    callback.Invoke();
                }
            });
        }
示例#5
0
        public static bool IsValidPluginLoadOrder()
        {
            lock (LockObject)
            {
                if (isCheckedLoadOrder)
                {
                    return(isLastValidPluginLoadOrder);
                }

                var isExistsXIVPlugin = false;

                foreach (var plugin in ActGlobals.oFormActMain.ActPlugins)
                {
                    if (plugin.pluginFile.Name.ContainsIgnoreCase("FFXIV_ACT_Plugin"))
                    {
                        isExistsXIVPlugin = true;
                    }

                    if (plugin.pluginFile.Name.ContainsIgnoreCase("ACT.SpecialSpellTimer") ||
                        plugin.pluginFile.Name.ContainsIgnoreCase("ACT.TTSYukkuri") ||
                        plugin.pluginFile.Name.ContainsIgnoreCase("ACT.UltraScouter"))
                    {
                        isLastValidPluginLoadOrder = isExistsXIVPlugin;
                        break;
                    }
                }

                isCheckedLoadOrder = true;
            }

            if (!isLastValidPluginLoadOrder)
            {
                WPFHelper.InvokeAsync(() =>
                {
                    ModernMessageBox.ShowDialog(
                        "Plugin load order is wrong.\n" +
                        "Please load FFXIV_ACT_Plugin before Hojoring.\n\n" +
                        "ex.\n" +
                        "1. FFXIV_ACT_Plugin\n" +
                        "2. ACT.TTSYukkuri\n" +
                        "3. ACT.SpecialSpellTimer\n" +
                        "4. ACT.UltraScouter\n",
                        "Plugin Load Error");
                });
            }

            return(isLastValidPluginLoadOrder);
        }
        public static bool IsAvailableWindows()
        {
            const string prompt1 = "Unsupported Operating System.";
            const string prompt2 = "Windows 10 or Later is Required.";

            var result = false;

            if (IsWindows10Later)
            {
                result = true;
            }
            else
            {
                if (Config.Instance.SupportWin7)
                {
                    result = true;

                    if (!shownWindowsIsOld)
                    {
                        shownWindowsIsOld = true;
                        Logger.Warn($"{prompt1} {prompt2}");
                        Logger.Warn($"Support Win7 manualy, but you'd better update to Windows 10. https://www.microsoft.com/software-download/windows10");
                    }
                }
                else
                {
                    if (!shownWindowsIsOld)
                    {
                        shownWindowsIsOld = true;
                        Logger.Error($"{prompt1} {prompt2}");
                        WPFHelper.BeginInvoke(
                            () => ModernMessageBox.ShowDialog(
                                $"{prompt1}\n{prompt2}",
                                "ACT.Hojoring"),
                            DispatcherPriority.Normal);
                    }
                }
            }

            return(result);
        }
示例#7
0
        public async void Load()
        {
            var dir = DirectoryHelper.FindSubDirectory(
                @"resources\icon\job");

            if (!Directory.Exists(dir))
            {
                return;
            }

            await WPFHelper.InvokeAsync(() =>
            {
                foreach (var job in (JobIDs[])Enum.GetValues(typeof(JobIDs)))
                {
                    var png = Path.Combine(dir, $"{job}.png");
                    if (!File.Exists(png))
                    {
                        continue;
                    }

                    using (var fs = new FileStream(png, FileMode.Open))
                    {
                        var decoder = PngBitmapDecoder.Create(
                            fs,
                            BitmapCreateOptions.None,
                            BitmapCacheOption.OnLoad);
                        var bmp = new WriteableBitmap(decoder.Frames[0]);
                        bmp.Freeze();

                        this.Icons[job] = bmp;
                    }
                }
            });

            this.isLoaded = true;
        }