示例#1
0
        public DeviceInfo()
        {
            InitializeComponent();

            this.InfoStack.DataContext = infoVM;
            this.GuidesStack.DataContext = infoVM;

            browserHelper = new WebBrowserHelper(InfoBrowser);
            browserHelper.ScrollDisabled = true;
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPage"/> class.
        /// </summary>
        public MainPage()
        {
            this.InitializeComponent();

            this.StartButton.IsEnabled = false;

            this.DisplayedVersionNumber.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            var wbh = new WebBrowserHelper(this.embeddedBrowser) { ScrollDisabled = true };
        }
示例#3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            this.navigationHelper.OnNavigatedTo(e);
            dynamic parms = e.Parameter as DynamicNavigationParameters;

            IEnumerable <IAppVersion> appVersions = parms.appVersions;

            this.VM.NewestVersion = appVersions.First();

            this.AppIconImage.ImageFailed += (sender, ex) => {
                this.AppIconImage.Source = new BitmapImage(new Uri("ms-appx:///HockeyApp/Assets/windows_phone.png", UriKind.RelativeOrAbsolute));
            };
            this.AppIconImage.Source = new BitmapImage(new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + this.VM.NewestVersion.PublicIdentifier + ".png"));

            this.ReleaseNotesBrowser.NavigateToString(await WebBrowserHelper.WrapContentAsync(this.VM.NewestVersion.Notes));
            this.ReleaseNotesBrowser.NavigationStarting += async(sender, navEventArgs) => {
                if (navEventArgs.Uri != null)
                {
                    navEventArgs.Cancel = true;
                    await Launcher.LaunchUriAsync(navEventArgs.Uri);
                }
            };
        }
        /// <summary>
        /// Invoked when an item within the list is selected.
        /// </summary>
        /// <param name="sender">The GridView displaying the selected item.</param>
        /// <param name="e">Event data that describes how the selection was changed.</param>
        private void ItemListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Invalidate the view state when logical page navigation is in effect, as a change
            // in selection may cause a corresponding change in the current logical page.  When
            // an item is selected this has the effect of changing from displaying the item list
            // to showing the selected item's details.  When the selection is cleared this has the
            // opposite effect.
            if (this.UsingLogicalPageNavigation())
            {
                this.InvalidateVisualState();
            }

            if (this.UsingLogicalPageNavigation())
            {
                this.navigationHelper.GoBackCommand.RaiseCanExecuteChanged();
            }

            if (itemListView.SelectedItem != null)
            {
                DefaultViewModel.SelectedFeedItem = (RSSFeedItem)itemListView.SelectedItem;
                this.Browser.NavigateToString(WebBrowserHelper.WrapHtml(DefaultViewModel.SelectedFeedItem.Description, Browser.Width));
            }
        }
示例#5
0
        void OnCopy(object sender, EditingManagerEventArgs e)
        {
            System.Windows.Forms.WebBrowser webbrowser = FreeCL.Forms.Application.ActiveControl as System.Windows.Forms.WebBrowser;

            if (webbrowser == wBrowser)
            {
                WebBrowserHelper.ExecCopy(wBrowser);
                e.Handled = true;
                //replace rtf with simple text
                try
                {
                    string text = System.Windows.Forms.Clipboard.GetText();
                    if (!string.IsNullOrEmpty(text))
                    {
                        text = text.Trim().Replace("\r\n\r\n", "\r\n");
                        System.Windows.Forms.Clipboard.SetText(text);
                    }
                }
                catch (System.Runtime.InteropServices.ExternalException)
                {
                }
            }
        }
示例#6
0
        private string GetSummary(string content)
        {
            string lContent      = content.Trim('\"');
            int    contentLength = 800;

            if (lContent.Length < 800)
            {
                contentLength = lContent.Length;
            }
            string _localContent = "";

            try
            {
                _localContent = WebBrowserHelper.StripHtml(lContent.Substring(0, contentLength));
            }
            catch
            {
            }
            if (_localContent.Length > 150)
            {
                _localContent = _localContent.Substring(0, 150) + "...";
            }
            return(_localContent);
        }
 private void btnFixBrowserRegKey_Click(object sender, EventArgs e)
 {
     WebBrowserHelper.UpdateWebBrowserRegistryKey(webBrowser);
     MessageBox.Show(this, "Your Browser Registry Key value has been updated.\n\nRestart the PrimeTrader app and try displaying HTML charts on the 'Charts' tab.", "Browser Registry Key", MessageBoxButtons.OK);
 }
示例#8
0
        private App()
        {
            AppArguments.Set(AppFlag.SyncNavigation, ref ModernFrame.OptionUseSyncNavigation);
            AppArguments.Set(AppFlag.DisableTransitionAnimation, ref ModernFrame.OptionDisableTransitionAnimation);
            AppArguments.Set(AppFlag.RecentlyClosedQueueSize, ref LinkGroupFilterable.OptionRecentlyClosedQueueSize);

            AppArguments.Set(AppFlag.ForceSteamId, ref SteamIdHelper.OptionForceValue);

            AppArguments.Set(AppFlag.NoProxy, ref KunosApiProvider.OptionNoProxy);

            var proxy = AppArguments.Get(AppFlag.Proxy);

            if (!string.IsNullOrWhiteSpace(proxy))
            {
                try {
                    var s = proxy.Split(':');
                    WebRequest.DefaultWebProxy = new WebProxy(s[0], FlexibleParser.ParseInt(s.ElementAtOrDefault(1), 1080));
                } catch (Exception e) {
                    Logging.Error(e);
                }
            }

            // TODO: AppArguments.Set(AppFlag.ScanPingTimeout, ref RecentManagerOld.OptionScanPingTimeout);
            AppArguments.Set(AppFlag.LanSocketTimeout, ref KunosApiProvider.OptionLanSocketTimeout);
            AppArguments.Set(AppFlag.LanPollTimeout, ref KunosApiProvider.OptionLanPollTimeout);
            AppArguments.Set(AppFlag.WebRequestTimeout, ref KunosApiProvider.OptionWebRequestTimeout);
            AppArguments.Set(AppFlag.DirectRequestTimeout, ref KunosApiProvider.OptionDirectRequestTimeout);
            AppArguments.Set(AppFlag.CommandTimeout, ref GameCommandExecutorBase.OptionCommandTimeout);

            AppArguments.Set(AppFlag.DisableAcRootChecking, ref AcRootDirectory.OptionDisableChecking);
            AppArguments.Set(AppFlag.AcObjectsLoadingConcurrency, ref BaseAcManagerNew.OptionAcObjectsLoadingConcurrency);
            AppArguments.Set(AppFlag.SkinsLoadingConcurrency, ref CarObject.OptionSkinsLoadingConcurrency);
            AppArguments.Set(AppFlag.KunosCareerIgnoreSkippedEvents, ref KunosCareerEventsManager.OptionIgnoreSkippedEvents);
            AppArguments.Set(AppFlag.IgnoreMissingSkinsInKunosEvents, ref KunosEventObjectBase.OptionIgnoreMissingSkins);

            AppArguments.Set(AppFlag.ForceToastFallbackMode, ref Toast.OptionFallbackMode);

            AppArguments.Set(AppFlag.SmartPresetsChangedHandling, ref UserPresetsControl.OptionSmartChangedHandling);
            AppArguments.Set(AppFlag.EnableRaceIniRestoration, ref Game.OptionEnableRaceIniRestoration);
            AppArguments.Set(AppFlag.EnableRaceIniTestMode, ref Game.OptionRaceIniTestMode);
            AppArguments.Set(AppFlag.RaceOutDebug, ref Game.OptionDebugMode);

            AppArguments.Set(AppFlag.LiteStartupModeSupported, ref Pages.Windows.MainWindow.OptionLiteModeSupported);
            AppArguments.Set(AppFlag.NfsPorscheTribute, ref RaceGridViewModel.OptionNfsPorscheNames);
            AppArguments.Set(AppFlag.KeepIniComments, ref IniFile.OptionKeepComments);
            AppArguments.Set(AppFlag.AutoConnectPeriod, ref OnlineServer.OptionAutoConnectPeriod);

            LimitedSpace.Initialize();
            LimitedStorage.Initialize();

            DataProvider.Initialize();
            CountryIdToImageConverter.Initialize(
                FilesStorage.Instance.GetDirectory(FilesStorage.DataDirName, ContentCategory.CountryFlags),
                FilesStorage.Instance.GetDirectory(FilesStorage.DataUserDirName, ContentCategory.CountryFlags));
            FilesStorage.Instance.Watcher(ContentCategory.CountryFlags).Update += (sender, args) => {
                CountryIdToImageConverter.ResetCache();
            };

            TestKey();

            AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;

            if (!AppArguments.GetBool(AppFlag.PreventDisableWebBrowserEmulationMode) && (
                    ValuesStorage.GetInt(WebBrowserEmulationModeDisabledKey) < WebBrowserHelper.EmulationModeDisablingVersion ||
                    AppArguments.GetBool(AppFlag.ForceDisableWebBrowserEmulationMode)))
            {
                try {
                    WebBrowserHelper.DisableBrowserEmulationMode();
                    ValuesStorage.Set(WebBrowserEmulationModeDisabledKey, WebBrowserHelper.EmulationModeDisablingVersion);
                } catch (Exception e) {
                    Logging.Warning("Can’t disable emulation mode: " + e);
                }
            }

            JsonConvert.DefaultSettings = () => new JsonSerializerSettings {
                Formatting           = Formatting.None,
                NullValueHandling    = NullValueHandling.Ignore,
                DefaultValueHandling = DefaultValueHandling.Include,
                Culture = CultureInfo.InvariantCulture
            };

            AcToolsLogging.Logger = (s, m, p, l) => Logging.Write($"{s} (AcTools)", m, p, l);

            var ignoreControls = AppArguments.Get(AppFlag.IgnoreControls);

            if (!string.IsNullOrWhiteSpace(ignoreControls))
            {
                ControlsSettings.OptionIgnoreControlsFilter = Filter.Create(new StringTester(), ignoreControls);
            }

            var sseStart = AppArguments.Get(AppFlag.SseName);

            if (!string.IsNullOrWhiteSpace(sseStart))
            {
                SseStarter.OptionStartName = sseStart;
            }

            FancyBackgroundManager.Initialize();
            DpiAwareWindow.OptionScale = AppArguments.GetDouble(AppFlag.UiScale, 1d);

            if (!AppKeyHolder.IsAllRight)
            {
                AppAppearanceManager.OptionCustomThemes = false;
            }
            else
            {
                AppArguments.Set(AppFlag.CustomThemes, ref AppAppearanceManager.OptionCustomThemes);
            }

            AppAppearanceManager.OptionIdealFormattingModeDefaultValue = AppArguments.GetBool(AppFlag.IdealFormattingMode,
                                                                                              !Equals(DpiAwareWindow.OptionScale, 1d));
            AppAppearanceManager.Initialize();

            AcObjectsUriManager.Register(new UriProvider());

            {
                var uiFactory = new GameWrapperUiFactory();
                GameWrapper.RegisterFactory(uiFactory);
                ServerEntry.RegisterFactory(uiFactory);
            }

            GameWrapper.RegisterFactory(new DefaultAssistsFactory());
            LapTimesManager.Instance.SetListener();

            AcError.RegisterFixer(new AcErrorFixer());
            AcError.RegisterSolutionsFactory(new SolutionsFactory());

            InitializePresets();

            SharingHelper.Initialize();
            SharingUiHelper.Initialize();

            {
                var addonsDir  = FilesStorage.Instance.GetFilename("Addons");
                var pluginsDir = FilesStorage.Instance.GetFilename("Plugins");
                if (Directory.Exists(addonsDir) && !Directory.Exists(pluginsDir))
                {
                    Directory.Move(addonsDir, pluginsDir);
                }
                else
                {
                    pluginsDir = FilesStorage.Instance.GetDirectory("Plugins");
                }

                PluginsManager.Initialize(pluginsDir);
                PluginsWrappers.Initialize(
                    new MagickPluginWrapper(),
                    new AwesomiumPluginWrapper(),
                    new CefSharpPluginWrapper(),
                    new StarterPlus());
            }

            {
                var onlineMainListFile   = FilesStorage.Instance.GetFilename("Online Servers", "Main List.txt");
                var onlineFavouritesFile = FilesStorage.Instance.GetFilename("Online Servers", "Favourites.txt");
                if (File.Exists(onlineMainListFile) && !File.Exists(onlineFavouritesFile))
                {
                    Directory.Move(onlineMainListFile, onlineFavouritesFile);
                }
            }

            SteamIdHelper.Initialize(AppArguments.Get(AppFlag.ForceSteamId));
            Superintendent.Initialize();

            AppArguments.Set(AppFlag.OfflineMode, ref AppKeyDialog.OptionOfflineMode);

            PrepareUi();
            AppIconService.Initialize(this);
            Toast.SetDefaultAction(() => (Current.Windows.OfType <ModernWindow>().FirstOrDefault(x => x.IsActive) ??
                                          Current.MainWindow as ModernWindow)?.BringToFront());
            BbCodeBlock.ImageClicked             += BbCodeBlock_ImageClicked;
            BbCodeBlock.OptionEmojiProvider       = InternalUtils.GetEmojiProvider();
            BbCodeBlock.OptionImageCacheDirectory = FilesStorage.Instance.GetTemporaryFilename("Images");
            BbCodeBlock.OptionEmojiCacheDirectory = FilesStorage.Instance.GetTemporaryFilename("Emoji");

            AppArguments.SetSize(AppFlag.ImagesCacheLimit, ref BetterImage.OptionCacheTotalSize);
            AppArguments.Set(AppFlag.ImagesMarkCached, ref BetterImage.OptionMarkCached);
            AppArguments.Set(AppFlag.UseVlcForAnimatedBackground, ref DynamicBackground.OptionUseVlc);
            Filter.OptionSimpleMatching = SettingsHolder.Content.SimpleFiltering;

            StartupUri = new Uri(!Superintendent.Instance.IsReady || AcRootDirectorySelector.IsReviewNeeded() ?
                                 @"Pages/Dialogs/AcRootDirectorySelector.xaml" : @"Pages/Windows/MainWindow.xaml", UriKind.Relative);

            InitializeUpdatableStuff();
            BackgroundInitialization();

            FatalErrorMessage.Register(this);
            ImageUtils.SafeMagickWrapper = fn => {
                try {
                    return(fn());
                } catch (OutOfMemoryException e) {
                    NonfatalError.Notify(ToolsStrings.MagickNet_CannotLoad, ToolsStrings.MagickNet_CannotLoad_Commentary, e);
                } catch (Exception e) {
                    NonfatalError.Notify(ToolsStrings.MagickNet_CannotLoad, e);
                }
                return(null);
            };

            AbstractDataFile.ErrorsCatcher = new DataSyntaxErrorCatcher();
            AppArguments.Set(AppFlag.SharedMemoryLiveReadingInterval, ref AcSharedMemory.OptionLiveReadingInterval);
            AcSharedMemory.Initialize();

            AppArguments.Set(AppFlag.RunRaceInformationWebserver, ref PlayerStatsManager.OptionRunStatsWebserver);
            AppArguments.Set(AppFlag.RaceInformationWebserverFile, ref PlayerStatsManager.OptionWebserverFilename);
            PlayerStatsManager.Instance.SetListener();

            AppArguments.Set(AppFlag.RhmKeepAlive, ref RhmService.OptionKeepRunning);
            RhmService.Instance.SetListener();

            _hibernator = new AppHibernator();
            _hibernator.SetListener();

            AppArguments.Set(AppFlag.TrackMapGeneratorMaxSize, ref TrackMapRenderer.OptionMaxSize);
            CommonFixes.Initialize();

            // TODO: rearrange code!
            CmPreviewsSettings.SelectCarDialog    = SelectCarDialog.Show;
            CmPreviewsTools.MissingShowroomHelper = new CarUpdatePreviewsDialog.MissingShowroomHelper();
        }
示例#9
0
 public LogInPage()
 {
     InitializeComponent();
     WebBrowserHelper.FixBrowserVersion();
 }
 /// <summary>
 /// Ensure app storage is set to its previous state
 /// </summary>
 public override void OnClosing()
 {
     WebBrowserHelper.ToogleSilverlightAppStorage(_isSilverlightAppStorageEnabled);
     base.OnClosing();
 }
示例#11
0
 public static string GetSelection(WebBrowser wBrowser)
 {
     return(WebBrowserHelper.ObjectToString(
                WebBrowserHelper.InvokeScript(wBrowser, "GetCurrentSelection", new object[] {})
                ));
 }
示例#12
0
        public void Clear()
        {
            if (isClean)
            {
                return;
            }

            WebBrowserHelper.ResetBatch(wBrowser);

            if (UpdatesManager.IsNewVersion && !CommandLineHelper.IsCommandSwitchSet("skipchangelog"))
            {
                UpdatesManager.IsNewVersion = false;
                string url = Constants.ChangeLogPageUrlBase;
                if (FreeCL.RTL.LangPack.CurrentLanguage == "Ukrainian")
                {
                    url += "uk.html";
                }
                else if (FreeCL.RTL.LangPack.CurrentLanguage == "Russian")
                {
                    url += "ru.html";
                }
                else
                {
                    url += "en.html";
                }
                url          += "?ver=" + FreeCL.RTL.ApplicationInfo.ProductVersion;
                forceCleaning = true;
                wBrowser.Navigate(url);
                return;
            }

            if (WebBrowserHelper.GetDocument(wBrowser) != null && !forceCleaning)
            {
                Wait();

                if (WebBrowserHelper.GetDocument(wBrowser) != null)
                {
                    if (!HtmlHelper.ClearTranslations(wBrowser))
                    {                           //possible disabled javascript or error
                        forceCleaning = true;
                    }
                    else
                    {
                        WebBrowserHelper.StartBatch(wBrowser);
                        isClean = true;                         //avoid double cleaning
                    }
                }
                else
                {
                    forceCleaning = true;
                }
            }

            if (WebBrowserHelper.GetDocument(wBrowser) == null || forceCleaning)
            {
                //Console.WriteLine("Clear Result");
                forceCleaning  = false;
                navigateCalled = true;
                wBrowser.Navigate(new Uri(WebUI.ResultsWebServer.Uri, "Default.aspx"));
                WebBrowserHelper.StartBatch(wBrowser);
            }
            RecalcSizes();
            isClean = true;
        }
示例#13
0
 public static void CreateTable(WebBrowser wBrowser, string parentName, string name)
 {
     WebBrowserHelper.InvokeScript(wBrowser, "CreateTable",
                                   new object[] { parentName, name, DefaultTextFormat });
 }
示例#14
0
 public static bool ClearTranslations(WebBrowser wBrowser)
 {
     return(WebBrowserHelper.ObjectToBool(
                WebBrowserHelper.InvokeScript(wBrowser, "ClearTranslations", new object[] {})
                ));
 }
        void LoadStatus()
        {
            //Console.WriteLine("LoadStatus : " + status.Setting.ServiceItem.Service.FullName);

            Clear();
            while (!isClean)
            {
                Application.DoEvents();
            }
            Wait();

            string name = "";

            if (!string.IsNullOrEmpty(status.Setting.ServiceItem.Description))
            {
                name += LangPack.TranslateString(status.Setting.ServiceItem.Description) + " - ";
            }

            name += LangPack.TranslateString(status.Setting.ServiceItem.Service.FullName);

            string htmlString = string.Format(CultureInfo.InvariantCulture,
                                              HtmlHelper.ServiceNameFormat,
                                              status.Setting.ServiceItem.Service.Url,
                                              HttpUtility.HtmlEncode(name));

            htmlString += "<br><b>" + LangPack.TranslateString("Type") + "</b> : " + status.Type;

            if (!shortView)
            {
                if (status.Setting.Subject != SubjectConstants.Common)
                {
                    htmlString += "<br>" + "<b>" + LangPack.TranslateString("Subject") + "</b> : " + LangPack.TranslateString(status.Setting.Subject);
                }
            }
            else
            {
                htmlString += ", " + "<b>" + LangPack.TranslateString("Subject") + "</b> : " + LangPack.TranslateString(status.Setting.Subject);
            }

            if (showLanguage)
            {
                if (!shortView)
                {
                    htmlString += "<br>" + LangPack.TranslateLanguage(status.Setting.LanguagePair.From) +
                                  "->" +
                                  LangPack.TranslateLanguage(status.Setting.LanguagePair.To);
                }
                else
                {
                    htmlString += "<br><b>" + LangPack.TranslateString("Translation direction") +
                                  "</b> : " +
                                  LangPack.TranslateLanguage(status.Setting.LanguagePair.From) +
                                  "->" +
                                  LangPack.TranslateLanguage(status.Setting.LanguagePair.To);
                }
            }

            if (!shortView)
            {
                if (status.DisabledByUser)
                {
                    htmlString += "<br>" + LangPack.TranslateString("<b>Status</b> : Disabled");
                    htmlString += string.Format("<br><button id=\"btn\" type=\"button\"  align=\"top\" style=\"{0}\">{1}</button>",
                                                HtmlHelper.ButtonTextStyle, LangPack.TranslateString("Enable"));
                }
                else if (status.Enabled)
                {
                    htmlString += "<br>" + LangPack.TranslateString("<b>Status</b> : Enabled");
                    htmlString += string.Format("<br><button id=\"btn\" type=\"button\" align=\"top\" style=\"{0}\">{1}</button>",
                                                HtmlHelper.ButtonTextStyle, LangPack.TranslateString("Disable"));
                }
                else
                {
                    htmlString += "<br>" + LangPack.TranslateString("<b>Status</b> : Error");
                    htmlString += " - " + string.Format("<span style=\"" + HtmlHelper.ErrorTextStyle + "\">{0}</span>", status.Error);
                    htmlString += string.Format("<br><button id=\"btn\" type=\"button\" align=\"top\" style=\"{0}\">{1}</button>",
                                                HtmlHelper.ButtonTextStyle, LangPack.TranslateString("Disable"));
                }
            }

            if (status.Setting.ServiceItem.CharsLimit != -1)
            {
                htmlString += "<br>" + "<b>";
                htmlString += string.Format(LangPack.TranslateString("Limit {0} : {1} characters"),
                                            "</b>", status.Setting.ServiceItem.CharsLimit);
            }

            if (status.Setting.ServiceItem.LinesLimit != -1)
            {
                htmlString += "<br>" + "<b>";
                htmlString += string.Format(LangPack.TranslateString("Limit {0} : {1} lines"),
                                            "</b>", status.Setting.ServiceItem.LinesLimit);
            }

            if (status.Setting.ServiceItem.WordsLimit != -1)
            {
                htmlString += "<br>" + "<b>";
                htmlString += string.Format(LangPack.TranslateString("Limit {0} : {1} words"),
                                            "</b>", status.Setting.ServiceItem.WordsLimit);
            }

            if (status.IsAsteriskMaskSupported || status.IsQuestionMaskSupported)
            {
                htmlString += "<br>" + "<b>" + LangPack.TranslateString("Masks") + "</b> : ";
                if (status.IsAsteriskMaskSupported)
                {
                    htmlString += "'*'";
                }

                if (status.IsAsteriskMaskSupported && status.IsQuestionMaskSupported)
                {
                    htmlString += ",";
                }

                if (status.IsQuestionMaskSupported)
                {
                    htmlString += "'?'";
                }
            }



            //tableCell.InnerHtml = htmlString;
            Wait();
            HtmlHelper.AddTranslationCell(wbStatus, isClean, htmlString, status.Setting.ServiceItem);

            HtmlElement button = WebBrowserHelper.GetDocument(wbStatus).GetElementById("btn");

            if (button != null)
            {
                button.Click += OnButtonClick;
            }


            isClean = false;
            RealRecalcSizes();
        }
        void RealRecalcSizes()
        {
            if (inResize)
            {
                return;
            }

            //Console.WriteLine("RealRecalcSizes");

            inResize = true;
            bool isHeightChanged = false;

            try
            {
                int allowedWidth = Width + 6;

                if (wbStatus.Width != allowedWidth)
                {
                    wbStatus.Width = allowedWidth;
                }

                int allowedHeight = ClientSize.Height;

                if ((isClean) || (WebBrowserHelper.GetDocument(wbStatus) == null || WebBrowserHelper.GetDocument(wbStatus).Body == null))
                {
                    //Console.WriteLine("Set height client 1");
                    if (wbStatus.Height != allowedHeight)
                    {
                        //Console.WriteLine("Set height client");

                        wbStatus.Height = allowedHeight;
                        isHeightChanged = true;
                    }
                }
                else if (WebBrowserHelper.GetDocument(wbStatus) != null && WebBrowserHelper.GetDocument(wbStatus).Body != null && WebBrowserHelper.GetDocument(wbStatus).Body.ScrollRectangle.Height != 0)
                {
                    //Console.WriteLine("Set height client 2");
                    int height = WebBrowserHelper.GetDocument(wbStatus).Body.ScrollRectangle.Height;                     // + 2;
                    if (wbStatus.Height != height)
                    {
                        //wbStatus.Height = height;
                        //ClientSize = new Size(ClientSize.Width, height);]
                        //Console.WriteLine("Set height " + height);
                        wbStatus.Height = height;
                        Height          = height - 15;
                        isHeightChanged = true;
                    }
                }
            }
            finally
            {
                inResize = false;
            }
            if (isHeightChanged && IsHandleCreated)
            {
                needRecalcSize = true;
            }
            else
            {
                needRecalcSize = false;
            }
        }
        static void BuildFile(string fileName, string classFileName)
        {
            WebBrowser wBrowser = new WebBrowser();

            wBrowser.CreateControl();
            wBrowser.Navigate(new Uri(WebUI.ResultsWebServer.Uri, "ServicesList.aspx"));
            WebBrowserHelper.Wait(wBrowser);

            HtmlDocument doc      = WebBrowserHelper.GetDocument(wBrowser);
            string       template = wBrowser.DocumentText;

            GenerateDocument(wBrowser);
            int bodyidx = template.IndexOf("<body>");

            template = template.Substring(0, bodyidx);
            StringBuilder body = new StringBuilder(doc.Body.OuterHtml);

            body.Replace("FONT-SIZE: 8.25pt;", "");
            body.Replace("FONT-FAMILY: Tahoma;", "");
            body.Replace("MARGIN: -7px;", "");
            body.Replace("</BODY>", "<br><span style='color: gray;'>Generated by : " + FreeCL.RTL.ApplicationInfo.ProductName + ", version :" + FreeCL.RTL.ApplicationInfo.ProductVersion + "</span></body>");


            string       result = template + body.ToString() + "\r\n</html>";
            FileStream   fs     = new FileStream(fileName, FileMode.Create);
            StreamWriter sw     = new StreamWriter(fs, Encoding.UTF8);

            sw.Write(result);
            sw.Flush();
            sw.Dispose();
            wBrowser.Dispose();

            fs = new FileStream(classFileName, FileMode.Create);
            string className = Path.GetFileNameWithoutExtension(classFileName);

            sw = new StreamWriter(fs, Encoding.BigEndianUnicode);
            sw.Write("import java.applet.*;\r\n\r\n");
            sw.Write("public class ");
            sw.Write(className);
            sw.Write(" extends Applet{\r\npublic String d(){\r\n");
            int           i = 0;
            int           cnt;
            StringBuilder substr;
            int           var_num = 0;

            while (i < result.Length)
            {
                cnt = 16384;
                if (i + cnt > result.Length)
                {
                    cnt = result.Length - i;
                }
                substr = new StringBuilder(result.Substring(i, cnt));
                substr.Replace("\"", "\\\"");
                substr.Replace("\r", "\\r");
                substr.Replace("\n", "\\n");
                sw.Write("String s");
                sw.Write(var_num.ToString());
                var_num++;
                sw.Write(" = ");
                sw.Write("\"" + substr.ToString() + "\";\r\n");
                i += 16384;
            }
            sw.Write("return ");
            for (i = 0; i < var_num; i++)
            {
                sw.Write("s");
                sw.Write(i.ToString());
                if (i + 1 < var_num)
                {
                    sw.Write("+");
                }
            }
            sw.Write(";\r\n}\r\n}");
            sw.Flush();
            sw.Dispose();
            wBrowser.Dispose();
        }
 public WatchWizardDOMSelector()
 {
     InitializeComponent();
     m_BrowserHelper = new WebBrowserHelper(wbDOMSelector, TimeSpan.FromSeconds(15));
 }
示例#19
0
        void RealRecalcSizes()
        {
            if (inResize)
            {
                return;
            }

            inResize = true;
            bool isHeightChanged = false;

            try
            {
                Rectangle advertScrollRectangle;
                if (WebBrowserHelper.GetDocument(wAdvertBrowser) != null && WebBrowserHelper.GetDocument(wAdvertBrowser).Body != null)
                {
                    advertScrollRectangle = WebBrowserHelper.GetDocument(wAdvertBrowser).Body.ScrollRectangle;
                }
                else
                {
                    advertScrollRectangle = new Rectangle(0, 0, 0, 0);
                }

                Rectangle browserScrollRectangle;
                if (WebBrowserHelper.GetDocument(wBrowser) != null)
                {
                    HtmlElement body = WebBrowserHelper.GetDocument(wBrowser).Body;
                    if (body != null)
                    {
                        try
                        {
                            browserScrollRectangle = body.ScrollRectangle;
                        }
                        catch (NullReferenceException)
                        {
                            browserScrollRectangle = new Rectangle(0, 0, 0, 0);
                        }
                    }
                    else
                    {
                        browserScrollRectangle = new Rectangle(0, 0, 0, 0);
                    }
                }
                else
                {
                    browserScrollRectangle = new Rectangle(0, 0, 0, 0);
                }


                int allowedWidth = ClientSize.Width;
                if (vScrollBar.Visible)
                {
                    allowedWidth -= SystemInformation.VerticalScrollBarWidth;
                }



                if (wBrowser.Width != allowedWidth)
                {
                    wBrowser.Width = allowedWidth;
                }

                if (wAdvertBrowser.Width != allowedWidth)
                {
                    wAdvertBrowser.Width = allowedWidth;
                }


                if (!advertLoaded)
                {
                    if (wAdvertBrowser.Height != 0)
                    {
                        wAdvertBrowser.Height = 0;
                        isHeightChanged       = true;
                    }
                }
                else if (advertScrollRectangle.Height != 0)
                {
                    if (wAdvertBrowser.Height != advertScrollRectangle.Height + 2)
                    {
                        wAdvertBrowser.Height = advertScrollRectangle.Height + 2;
                        isHeightChanged       = true;
                    }
                }

                int allowedHeight = ClientSize.Height;

                if ((isClean && !advertLoaded) || (WebBrowserHelper.GetDocument(wBrowser) == null || WebBrowserHelper.GetDocument(wBrowser).Body == null))
                {
                    if (wBrowser.Height != allowedHeight)
                    {
                        wBrowser.Height = allowedHeight;
                        isHeightChanged = true;
                    }
                }
                else if (isClean)
                {
                    if (wBrowser.Height != allowedHeight - wAdvertBrowser.Height)
                    {
                        wBrowser.Height = allowedHeight - wAdvertBrowser.Height;
                    }
                }
                else if (browserScrollRectangle.Height != 0)
                {
                    int height = browserScrollRectangle.Height + 2;
                    if (wAdvertBrowser.Height + height < Height)
                    {
                        height = Height - wAdvertBrowser.Height;
                    }

                    if (wBrowser.Height != height)
                    {
                        wBrowser.Height = height;
                        isHeightChanged = true;
                    }
                }

                if (wAdvertBrowser.Top != wBrowser.Bottom)
                {
                    wAdvertBrowser.Top = wBrowser.Bottom;
                    isHeightChanged    = true;
                }

                if (wAdvertBrowser.Bottom < Height && !MonoHelper.IsMono)
                {
                    wBrowser.Top      += Height - wAdvertBrowser.Bottom;
                    wAdvertBrowser.Top = wBrowser.Bottom;
                    isHeightChanged    = true;
                }

                int FullHeight = wBrowser.Height + wAdvertBrowser.Height;
                if (FullHeight > Height)
                {
                    if (!vScrollBar.Visible)
                    {
                        allowedWidth        -= SystemInformation.VerticalScrollBarWidth;
                        wBrowser.Width       = allowedWidth;
                        wAdvertBrowser.Width = allowedWidth;
                        if (Height > 0)
                        {
                            vScrollBar.LargeChange = Height;
                        }
                        else
                        {
                            vScrollBar.LargeChange = 0;
                        }
                        vScrollBar.Maximum = FullHeight - Height + vScrollBar.LargeChange - 1;
                        vScrollBar.Value   = 0;
                        wBrowser.Top       = 0;
                        wAdvertBrowser.Top = wBrowser.Height;
                        vScrollBar.Visible = true;
                        vScrollBar.Enabled = true;
                        isHeightChanged    = true;
                    }
                    else if (vScrollBar.Maximum != FullHeight - Height + vScrollBar.LargeChange - 1)
                    {
                        vScrollBar.Maximum = FullHeight - Height + vScrollBar.LargeChange - 1;
                    }
                }
                else
                {
                    if (vScrollBar.Visible)
                    {
                        vScrollBar.Visible   = false;
                        vScrollBar.Enabled   = false;
                        wBrowser.Top         = 0;
                        wAdvertBrowser.Top   = wBrowser.Height;
                        wBrowser.Width       = Width;
                        wAdvertBrowser.Width = Width;
                        isHeightChanged      = true;
                    }
                }
            }
            finally
            {
                inResize = false;
            }
            if (isHeightChanged && IsHandleCreated)
            {
                needRecalcSize = true;
            }
            else
            {
                needRecalcSize = false;
            }
        }
示例#20
0
 public static void AddTranslationCell(WebBrowser wBrowser, string parentName, bool isClean, string dataCellHtml, string iconCellHtml)
 {
     WebBrowserHelper.InvokeScript(wBrowser, "AddTranslationCell",
                                   new object[] { parentName, isClean, DefaultTextFormat, iconCellHtml, dataCellHtml });
 }
示例#21
0
        private async void App_Startup(object sender, StartupEventArgs e)
        {
            var c = Config.Instance;

            c.SetStartup(c.IsStartupWithWindows);

            // WebBrowser のIEを最新版に指定する
            WebBrowserHelper.SetUseNewestWebBrowser();

            await Task.WhenAll(
                ChatOverlaysController.Instance.StartAsync(),
                SharlayanController.Instance.StartAsync(),
                DiscordBotController.Instance.StartAsync(),
                Task.Run(() =>
            {
                this.SetCredits();

                HelpViewModel.Instance.OfficialSiteUri = new Uri(@"https://github.com/anoyetta/RINGS");
                foreach (var asm in ReferenceAssemblies)
                {
                    HelpViewModel.Instance.AddVersionInfos(asm);
                }

                HelpViewModel.Instance.GetReleaseChannelCallback = () => c.UpdateChannel;
                HelpViewModel.Instance.SetReleaseChannelCallback = value => c.UpdateChannel = value;
            }));

            AppLogger.Write("RINGS is chat communication enhancer for FFXIV, developed by anoyetta and best friends.");
            AppLogger.Write($"{c.AppNameWithVersion} Start.");

#if DEBUG
            /*
             * new SandboxWindow().Show();
             * WebViewOverlay.Instance.ShowUrl(
             *  this.MainWindow,
             *  @"https://www.jma.go.jp/jp/gms/imgs/0/infrared/1/201902251650-00.png");
             */
#endif

            // アップデートを確認する
            UpdateChecker.ShutdownCallback        = () => WPFHelper.Dispatcher.Invoke(() => this.CloseMainWindowCallback?.Invoke());
            UpdateChecker.UpdateSourceUri         = Config.Instance.UpdateSourceUri;
            UpdateChecker.LastUpdateCheckCallback = (lastUpdateTimestamp) =>
            {
                Config.Instance.LastUpdateTimestamp = lastUpdateTimestamp;
                Config.Instance.Save(Config.FileName);
            };

            await this.Dispatcher.InvokeAsync(async() =>
            {
                await Task.Delay(TimeSpan.FromSeconds(0.1));

#if !DEBUG
                await UpdateChecker.IsUpdateAsync(
                    Config.Instance.LastUpdateTimestamp,
                    Config.Instance.UpdateChannel);
#else
#if false
                await UpdateChecker.IsUpdateAsync(
                    Config.Instance.LastUpdateTimestamp,
                    Config.Instance.UpdateChannel);
#else
                // デバッグ用
                // 強制的に最新バージョンを取得する
                await UpdateChecker.IsUpdateAsync(
                    Config.Instance.LastUpdateTimestamp,
                    Config.Instance.UpdateChannel,
                    UpdateChecker.DefaultUpdateCheckInterval,
                    true);
#endif
#endif
            },
                                              DispatcherPriority.ApplicationIdle);

            // グローバルキーフックをセットする
            SharlayanController.SubscribeKeyHook();
        }
示例#22
0
 public static void SetNodeInnerHtml(WebBrowser wBrowser, string nodeName, string nodeHTML)
 {
     WebBrowserHelper.InvokeScript(wBrowser, "SetNodeInnerHtml",
                                   new object[] { nodeName, nodeHTML });
 }
 /// <summary>
 /// Remove the specified files from temporary internet files
 /// </summary>
 /// <param name="fileNameStartsWith"></param>
 /// <param name="fileExtension"></param>
 public void RemoveFileFromTempInternetFiles(string fileNameStartsWith, string fileExtension)
 {
     WebBrowserHelper.ClearCache(fileNameStartsWith, fileExtension);
 }
示例#24
0
 public static bool RemoveElement(WebBrowser wBrowser, string elementName)
 {
     return(WebBrowserHelper.ObjectToBool(
                WebBrowserHelper.InvokeScript(wBrowser, "RemoveElement", new object[] { elementName })
                ));
 }
 public void CleanInternetExporerCache()
 {
     WebBrowserHelper.ClearCache();
 }
示例#26
0
 public static void InitDocument(WebBrowser wBrowser)
 {
     WebBrowserHelper.InvokeScript(wBrowser, "SetTableStyle", new object[] { DefaultTextFormat });
 }
示例#27
0
 public void Wait()
 {
     WebBrowserHelper.Wait(wBrowser);
 }
示例#28
0
        private App()
        {
            if (AppArguments.GetBool(AppFlag.IgnoreHttps))
            {
                ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
            }

            AppArguments.Set(AppFlag.SyncNavigation, ref ModernFrame.OptionUseSyncNavigation);
            AppArguments.Set(AppFlag.DisableTransitionAnimation, ref ModernFrame.OptionDisableTransitionAnimation);
            AppArguments.Set(AppFlag.RecentlyClosedQueueSize, ref LinkGroupFilterable.OptionRecentlyClosedQueueSize);

            AppArguments.Set(AppFlag.NoProxy, ref KunosApiProvider.OptionNoProxy);

            var proxy = AppArguments.Get(AppFlag.Proxy);

            if (!string.IsNullOrWhiteSpace(proxy))
            {
                try {
                    var s = proxy.Split(':');
                    WebRequest.DefaultWebProxy = new WebProxy(s[0], FlexibleParser.ParseInt(s.ArrayElementAtOrDefault(1), 1080));
                } catch (Exception e) {
                    Logging.Error(e);
                }
            }

            // TODO: AppArguments.Set(AppFlag.ScanPingTimeout, ref RecentManagerOld.OptionScanPingTimeout);
            AppArguments.Set(AppFlag.LanSocketTimeout, ref KunosApiProvider.OptionLanSocketTimeout);
            AppArguments.Set(AppFlag.LanPollTimeout, ref KunosApiProvider.OptionLanPollTimeout);
            AppArguments.Set(AppFlag.WebRequestTimeout, ref KunosApiProvider.OptionWebRequestTimeout);
            AppArguments.Set(AppFlag.DirectRequestTimeout, ref KunosApiProvider.OptionDirectRequestTimeout);
            AppArguments.Set(AppFlag.CommandTimeout, ref GameCommandExecutorBase.OptionCommandTimeout);

            AppArguments.Set(AppFlag.DisableAcRootChecking, ref AcPaths.OptionEaseAcRootCheck);
            AppArguments.Set(AppFlag.AcObjectsLoadingConcurrency, ref BaseAcManagerNew.OptionAcObjectsLoadingConcurrency);
            AppArguments.Set(AppFlag.SkinsLoadingConcurrency, ref CarObject.OptionSkinsLoadingConcurrency);
            AppArguments.Set(AppFlag.KunosCareerIgnoreSkippedEvents, ref KunosCareerEventsManager.OptionIgnoreSkippedEvents);
            AppArguments.Set(AppFlag.IgnoreMissingSkinsInKunosEvents, ref KunosEventObjectBase.OptionIgnoreMissingSkins);

            AppArguments.Set(AppFlag.CanPack, ref AcCommonObject.OptionCanBePackedFilter);
            AppArguments.Set(AppFlag.CanPackCars, ref CarObject.OptionCanBePackedFilter);

            AppArguments.Set(AppFlag.ForceToastFallbackMode, ref Toast.OptionFallbackMode);

            AppArguments.Set(AppFlag.SmartPresetsChangedHandling, ref UserPresetsControl.OptionSmartChangedHandling);
            AppArguments.Set(AppFlag.EnableRaceIniRestoration, ref Game.OptionEnableRaceIniRestoration);
            AppArguments.Set(AppFlag.EnableRaceIniTestMode, ref Game.OptionRaceIniTestMode);
            AppArguments.Set(AppFlag.RaceOutDebug, ref Game.OptionDebugMode);

            AppArguments.Set(AppFlag.NfsPorscheTribute, ref RaceGridViewModel.OptionNfsPorscheNames);
            AppArguments.Set(AppFlag.KeepIniComments, ref IniFile.OptionKeepComments);
            AppArguments.Set(AppFlag.AutoConnectPeriod, ref OnlineServer.OptionAutoConnectPeriod);
            AppArguments.Set(AppFlag.GenericModsLogging, ref GenericModsEnabler.OptionLoggingEnabled);
            AppArguments.Set(AppFlag.SidekickOptimalRangeThreshold, ref SidekickHelper.OptionRangeThreshold);
            AppArguments.Set(AppFlag.GoogleDriveLoaderDebugMode, ref GoogleDriveLoader.OptionDebugMode);
            AppArguments.Set(AppFlag.GoogleDriveLoaderManualRedirect, ref GoogleDriveLoader.OptionManualRedirect);
            AppArguments.Set(AppFlag.DebugPing, ref ServerEntry.OptionDebugPing);
            AppArguments.Set(AppFlag.DebugContentId, ref AcObjectNew.OptionDebugLoading);
            AppArguments.Set(AppFlag.JpegQuality, ref ImageUtilsOptions.JpegQuality);
            AppArguments.Set(AppFlag.FbxMultiMaterial, ref Kn5.OptionJoinToMultiMaterial);

            Acd.Factory       = new AcdFactory();
            Lazier.SyncAction = ActionExtension.InvokeInMainThreadAsync;
            KeyboardListenerFactory.Register <KeyboardListener>();

            LimitedSpace.Initialize();
            DataProvider.Initialize();
            SteamIdHelper.Initialize(AppArguments.Get(AppFlag.ForceSteamId));
            TestKey();

            AppDomain.CurrentDomain.ProcessExit += OnProcessExit;

            if (!AppArguments.GetBool(AppFlag.PreventDisableWebBrowserEmulationMode) && (
                    ValuesStorage.Get <int>(WebBrowserEmulationModeDisabledKey) < WebBrowserHelper.EmulationModeDisablingVersion ||
                    AppArguments.GetBool(AppFlag.ForceDisableWebBrowserEmulationMode)))
            {
                try {
                    WebBrowserHelper.DisableBrowserEmulationMode();
                    ValuesStorage.Set(WebBrowserEmulationModeDisabledKey, WebBrowserHelper.EmulationModeDisablingVersion);
                } catch (Exception e) {
                    Logging.Warning("Can’t disable emulation mode: " + e);
                }
            }

            JsonConvert.DefaultSettings = () => new JsonSerializerSettings {
                Formatting           = Formatting.None,
                NullValueHandling    = NullValueHandling.Ignore,
                DefaultValueHandling = DefaultValueHandling.Include,
                Culture = CultureInfo.InvariantCulture
            };

            AcToolsLogging.Logger = (s, m, p, l) => Logging.Write($"{s} (AcTools)", m, p, l);
            AcToolsLogging.NonFatalErrorHandler = (s, c, e, b) => {
                if (b)
                {
                    NonfatalError.NotifyBackground(s, c, e);
                }
                else
                {
                    NonfatalError.Notify(s, c, e);
                }
            };

            AppArguments.Set(AppFlag.ControlsDebugMode, ref ControlsSettings.OptionDebugControlles);
            AppArguments.Set(AppFlag.ControlsRescanPeriod, ref DirectInputScanner.OptionMinRescanPeriod);
            var ignoreControls = AppArguments.Get(AppFlag.IgnoreControls);

            if (!string.IsNullOrWhiteSpace(ignoreControls))
            {
                ControlsSettings.OptionIgnoreControlsFilter = Filter.Create(new StringTester(), ignoreControls);
            }

            var sseStart = AppArguments.Get(AppFlag.SseName);

            if (!string.IsNullOrWhiteSpace(sseStart))
            {
                SseStarter.OptionStartName = sseStart;
            }
            AppArguments.Set(AppFlag.SseLogging, ref SseStarter.OptionLogging);

            FancyBackgroundManager.Initialize();
            if (AppArguments.Has(AppFlag.UiScale))
            {
                AppearanceManager.Instance.AppScale = AppArguments.GetDouble(AppFlag.UiScale, 1d);
            }
            if (AppArguments.Has(AppFlag.WindowsLocationManagement))
            {
                AppearanceManager.Instance.ManageWindowsLocation = AppArguments.GetBool(AppFlag.WindowsLocationManagement, true);
            }

            if (!InternalUtils.IsAllRight)
            {
                AppAppearanceManager.OptionCustomThemes = false;
            }
            else
            {
                AppArguments.Set(AppFlag.CustomThemes, ref AppAppearanceManager.OptionCustomThemes);
            }

            AppArguments.Set(AppFlag.FancyHintsDebugMode, ref FancyHint.OptionDebugMode);
            AppArguments.Set(AppFlag.FancyHintsMinimumDelay, ref FancyHint.OptionMinimumDelay);
            AppArguments.Set(AppFlag.WindowsVerbose, ref DpiAwareWindow.OptionVerboseMode);
            AppArguments.Set(AppFlag.ShowroomUiVerbose, ref LiteShowroomFormWrapperWithTools.OptionAttachedToolsVerboseMode);
            AppArguments.Set(AppFlag.BenchmarkReplays, ref GameDialog.OptionBenchmarkReplays);

            // Shared memory, now as an app flag
            SettingsHolder.Drive.WatchForSharedMemory = !AppArguments.GetBool(AppFlag.DisableSharedMemory);

            /*AppAppearanceManager.OptionIdealFormattingModeDefaultValue = AppArguments.GetBool(AppFlag.IdealFormattingMode,
             *      !Equals(DpiAwareWindow.OptionScale, 1d));*/
            NonfatalErrorSolution.IconsDictionary = new Uri("/AcManager.Controls;component/Assets/IconData.xaml", UriKind.Relative);
            AppearanceManager.DefaultValuesSource = new Uri("/AcManager.Controls;component/Assets/ModernUI.Default.xaml", UriKind.Relative);
            AppAppearanceManager.Initialize(Pages.Windows.MainWindow.GetTitleLinksEntries());
            VisualExtension.RegisterInput <WebBlock>();

            ContentUtils.Register("AppStrings", AppStrings.ResourceManager);
            ContentUtils.Register("ControlsStrings", ControlsStrings.ResourceManager);
            ContentUtils.Register("ToolsStrings", ToolsStrings.ResourceManager);
            ContentUtils.Register("UiStrings", UiStrings.ResourceManager);

            AcObjectsUriManager.Register(new UriProvider());

            {
                var uiFactory = new GameWrapperUiFactory();
                GameWrapper.RegisterFactory(uiFactory);
                ServerEntry.RegisterFactory(uiFactory);
            }

            GameWrapper.RegisterFactory(new DefaultAssistsFactory());
            LapTimesManager.Instance.SetListener();
            RaceResultsStorage.Instance.SetListener();

            AcError.RegisterFixer(new AcErrorFixer());
            AcError.RegisterSolutionsFactory(new SolutionsFactory());

            InitializePresets();

            SharingHelper.Initialize();
            SharingUiHelper.Initialize(AppArguments.GetBool(AppFlag.ModernSharing) ? new Win10SharingUiHelper() : null);

            {
                var addonsDir  = FilesStorage.Instance.GetFilename("Addons");
                var pluginsDir = FilesStorage.Instance.GetFilename("Plugins");
                if (Directory.Exists(addonsDir) && !Directory.Exists(pluginsDir))
                {
                    Directory.Move(addonsDir, pluginsDir);
                }
                else
                {
                    pluginsDir = FilesStorage.Instance.GetDirectory("Plugins");
                }

                PluginsManager.Initialize(pluginsDir);
                PluginsWrappers.Initialize(
                    new AssemblyResolvingWrapper(KnownPlugins.Fmod, FmodResolverService.Resolver),
                    new AssemblyResolvingWrapper(KnownPlugins.Fann, FannResolverService.Resolver),
                    new AssemblyResolvingWrapper(KnownPlugins.Magick, ImageUtils.MagickResolver),
                    new AssemblyResolvingWrapper(KnownPlugins.CefSharp, CefSharpResolverService.Resolver));
            }

            {
                var onlineMainListFile   = FilesStorage.Instance.GetFilename("Online Servers", "Main List.txt");
                var onlineFavouritesFile = FilesStorage.Instance.GetFilename("Online Servers", "Favourites.txt");
                if (File.Exists(onlineMainListFile) && !File.Exists(onlineFavouritesFile))
                {
                    Directory.Move(onlineMainListFile, onlineFavouritesFile);
                }
            }

            CupClient.Initialize();
            Superintendent.Initialize();
            ModsWebBrowser.Initialize();

            AppArguments.Set(AppFlag.OfflineMode, ref AppKeyDialog.OptionOfflineMode);

            WebBlock.DefaultDownloadListener  = new WebDownloadListener();
            FlexibleLoader.CmRequestHandler   = new CmRequestHandler();
            ContextMenus.ContextMenusProvider = new ContextMenusProvider();
            PrepareUi();

            AppShortcut.Initialize("Content Manager", "Content Manager");

            // If shortcut exists, make sure it has a proper app ID set for notifications
            if (File.Exists(AppShortcut.ShortcutLocation))
            {
                AppShortcut.CreateShortcut();
            }

            AppIconService.Initialize(new AppIconProvider());

            Toast.SetDefaultAction(() => (Current.Windows.OfType <ModernWindow>().FirstOrDefault(x => x.IsActive) ??
                                          Current.MainWindow as ModernWindow)?.BringToFront());
            BbCodeBlock.ImageClicked             += OnBbImageClick;
            BbCodeBlock.OptionEmojiProvider       = new EmojiProvider();
            BbCodeBlock.OptionImageCacheDirectory = FilesStorage.Instance.GetTemporaryFilename("Images");
            BbCodeBlock.OptionEmojiCacheDirectory = FilesStorage.Instance.GetTemporaryFilename("Emoji");

            BbCodeBlock.AddLinkCommand(new Uri("cmd://findMissing/car"),
                                       new DelegateCommand <string>(
                                           id => {
                WindowsHelper.ViewInBrowser(SettingsHolder.Content.MissingContentSearch.GetUri(id, SettingsHolder.MissingContentType.Car));
            }));

            BbCodeBlock.AddLinkCommand(new Uri("cmd://findMissing/track"),
                                       new DelegateCommand <string>(
                                           id => {
                WindowsHelper.ViewInBrowser(SettingsHolder.Content.MissingContentSearch.GetUri(id, SettingsHolder.MissingContentType.Track));
            }));

            BbCodeBlock.AddLinkCommand(new Uri("cmd://downloadMissing/car"), new DelegateCommand <string>(id => {
                var s = id.Split('|');
                IndexDirectDownloader.DownloadCarAsync(s[0], s.ArrayElementAtOrDefault(1)).Forget();
            }));

            BbCodeBlock.AddLinkCommand(new Uri("cmd://downloadMissing/track"), new DelegateCommand <string>(id => {
                var s = id.Split('|');
                IndexDirectDownloader.DownloadTrackAsync(s[0], s.ArrayElementAtOrDefault(1)).Forget();
            }));

            BbCodeBlock.AddLinkCommand(new Uri("cmd://createNeutralLut"),
                                       new DelegateCommand <string>(id => NeutralColorGradingLut.CreateNeutralLut(id.As(16))));

            BbCodeBlock.DefaultLinkNavigator.PreviewNavigate += (sender, args) => {
                if (args.Uri.IsAbsoluteUri && args.Uri.Scheme == "acmanager")
                {
                    ArgumentsHandler.ProcessArguments(new[] { args.Uri.ToString() }, true).Forget();
                    args.Cancel = true;
                }
            };

            AppArguments.SetSize(AppFlag.ImagesCacheLimit, ref BetterImage.OptionCacheTotalSize);
            AppArguments.Set(AppFlag.ImagesMarkCached, ref BetterImage.OptionMarkCached);
            BetterImage.RemoteUserAgent      = CmApiProvider.UserAgent;
            BetterImage.RemoteCacheDirectory = BbCodeBlock.OptionImageCacheDirectory;
            GameWrapper.Started += (sender, args) => {
                BetterImage.CleanUpCache();
                GCHelper.CleanUp();
            };

            AppArguments.Set(AppFlag.UseVlcForAnimatedBackground, ref DynamicBackground.OptionUseVlc);
            Filter.OptionSimpleMatching = true;

            GameResultExtension.RegisterNameProvider(new GameSessionNameProvider());
            CarBlock.CustomShowroomWrapper   = new CustomShowroomWrapper();
            CarBlock.CarSetupsView           = new CarSetupsView();
            SettingsHolder.Content.OldLayout = AppArguments.GetBool(AppFlag.CarsOldLayout);

            var acRootIsFine = Superintendent.Instance.IsReady && !AcRootDirectorySelector.IsReviewNeeded();

            if (acRootIsFine && SteamStarter.Initialize(AcRootDirectory.Instance.Value))
            {
                if (SettingsHolder.Drive.SelectedStarterType != SettingsHolder.DriveSettings.SteamStarterType)
                {
                    SettingsHolder.Drive.SelectedStarterType = SettingsHolder.DriveSettings.SteamStarterType;
                    Toast.Show("Starter changed to replacement", "Enjoy Steam being included into CM");
                }
            }
            else if (SettingsHolder.Drive.SelectedStarterType == SettingsHolder.DriveSettings.SteamStarterType)
            {
                SettingsHolder.Drive.SelectedStarterType = SettingsHolder.DriveSettings.DefaultStarterType;
                Toast.Show($"Starter changed to {SettingsHolder.Drive.SelectedStarterType.DisplayName}", "Steam Starter is unavailable", () => {
                    ModernDialog.ShowMessage(
                        "To use Steam Starter, please make sure CM is taken place of the official launcher and AC root directory is valid.",
                        "Steam Starter is unavailable", MessageBoxButton.OK);
                });
            }

            InitializeUpdatableStuff();
            BackgroundInitialization();
            ExtraProgressRings.Initialize();

            FatalErrorMessage.Register(new AppRestartHelper());
            ImageUtils.SafeMagickWrapper = fn => {
                try {
                    return(fn());
                } catch (OutOfMemoryException e) {
                    NonfatalError.Notify(ToolsStrings.MagickNet_CannotLoad, ToolsStrings.MagickNet_CannotLoad_Commentary, e);
                } catch (Exception e) {
                    NonfatalError.Notify(ToolsStrings.MagickNet_CannotLoad, e);
                }
                return(null);
            };

            DataFileBase.ErrorsCatcher = new DataSyntaxErrorCatcher();
            AppArguments.Set(AppFlag.SharedMemoryLiveReadingInterval, ref AcSharedMemory.OptionLiveReadingInterval);
            AcSharedMemory.Initialize();

            AppArguments.Set(AppFlag.RunRaceInformationWebserver, ref PlayerStatsManager.OptionRunStatsWebserver);
            AppArguments.Set(AppFlag.RaceInformationWebserverFile, ref PlayerStatsManager.OptionWebserverFilename);

            PlayerStatsManager.Instance.SetListener();
            RhmService.Instance.SetListener();

            WheelOptionsBase.SetStorage(new WheelAnglesStorage());

            _hibernator = new AppHibernator();
            _hibernator.SetListener();

            VisualCppTool.Initialize(FilesStorage.Instance.GetDirectory("Plugins", "NativeLibs"));

            try {
                SetRenderersOptions();
            } catch (Exception e) {
                VisualCppTool.OnException(e, null);
            }

            CommonFixes.Initialize();

            CmPreviewsTools.MissingShowroomHelper = new CarUpdatePreviewsDialog.MissingShowroomHelper();

            // Paint shop+livery generator?
            LiteShowroomTools.LiveryGenerator = new LiveryGenerator();

            // Discord
            if (AppArguments.Has(AppFlag.DiscordCmd))
            {
                // Do not show main window and wait for futher instructions?
            }

            if (SettingsHolder.Integrated.DiscordIntegration)
            {
                AppArguments.Set(AppFlag.DiscordVerbose, ref DiscordConnector.OptionVerboseMode);
                DiscordConnector.Initialize(AppArguments.Get(AppFlag.DiscordClientId) ?? InternalUtils.GetDiscordClientId(), new DiscordHandler());
                DiscordImage.OptionDefaultImage = @"track_ks_brands_hatch";
                GameWrapper.Started            += (sender, args) => args.StartProperties.SetAdditional(new GameDiscordPresence(args.StartProperties, args.Mode));
            }

            // Reshade?
            var loadReShade = AppArguments.GetBool(AppFlag.ForceReshade);

            if (!loadReShade && string.Equals(AppArguments.Get(AppFlag.ForceReshade), "kn5only", StringComparison.OrdinalIgnoreCase))
            {
                loadReShade = AppArguments.Values.Any(x => x.EndsWith(".kn5", StringComparison.OrdinalIgnoreCase));
            }

            if (loadReShade)
            {
                var reshade = Path.Combine(MainExecutingFile.Directory, "dxgi.dll");
                if (File.Exists(reshade))
                {
                    Kernel32.LoadLibrary(reshade);
                }
            }

            // Auto-show that thing
            InstallAdditionalContentDialog.Initialize();

            // Let’s roll
            ShutdownMode = ShutdownMode.OnExplicitShutdown;
            new AppUi(this).Run();
        }
		private void StartTrackerItemGet(int maxItems)
		{
			_maxItems = maxItems;
			if (_browserHelper == null)
			{
				_browserHelper = new WebBrowserHelper();
			}
			AxSHDocVw.AxWebBrowser browser = _browserHelper.WebBrowser;
			browser.DocumentComplete += new AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(CompletedTrackerItemsGet);
			browser.Silent = true;
			browser.Navigate(_url.AbsoluteUri);
		}
 public GetSite()
 {
     InitializeComponent();
     WebBrowserHelper.ClearCache();
 }
示例#31
0
 void TransitionFrame_Loaded(object sender, RoutedEventArgs e)
 {
     WebBrowserHelper.DisableFrameNavigationSound();
 }
示例#32
0
 public void SetUserAgent(string userAgent)
 {
     WebBrowserHelper.SetUserAgent(userAgent);
 }
示例#33
0
 private void ClearCarche(object state)
 {
     WebBrowserHelper.ClearCache();
     MessageBox.Show("Temporary Internet files and cache cleared.");
 }