Decompiled source of OnTogetherSchoolScreen v0.1.11
BepInEx/plugins/Microsoft.Web.WebView2.Core.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; using System.Net; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Security; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.Web.WebView2.Core.Raw; using Microsoft.Win32.SafeHandles; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: InternalsVisibleTo("Microsoft.Web.WebView2.WinForms, PublicKey=00240000048000009400000006020000002400005253413100040000010001005dba207a79aa19b084a6b574c6f8945bd211921eaefa27a8031dd74b31af8094b3945f00288bc93f0751ecc62d3f5ca42681f09ed4ff1716aefc600bee20b042828dd897db022a07459a20a1042d0fcdd4a19610e838f5cfd992bcad1499861e24a28e5884452ce638803b5fac55a9967d92794723d2f4a0b49cc1148ae03dc7")] [assembly: InternalsVisibleTo("Microsoft.Web.WebView2.Wpf, PublicKey=00240000048000009400000006020000002400005253413100040000010001005dba207a79aa19b084a6b574c6f8945bd211921eaefa27a8031dd74b31af8094b3945f00288bc93f0751ecc62d3f5ca42681f09ed4ff1716aefc600bee20b042828dd897db022a07459a20a1042d0fcdd4a19610e838f5cfd992bcad1499861e24a28e5884452ce638803b5fac55a9967d92794723d2f4a0b49cc1148ae03dc7")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyConfiguration("Release")] [assembly: Debuggable(false, false)] [assembly: AssemblyCopyright("Copyright ©2020")] [assembly: AssemblyProduct("WebView2 .NET Interop Wrapper")] [assembly: AssemblyTitle("Microsoft.Web.WebView2.Core")] [assembly: InternalsVisibleTo("dotNetAPIWrapperGeneratorTester, PublicKey=00240000048000009400000006020000002400005253413100040000010001005dba207a79aa19b084a6b574c6f8945bd211921eaefa27a8031dd74b31af8094b3945f00288bc93f0751ecc62d3f5ca42681f09ed4ff1716aefc600bee20b042828dd897db022a07459a20a1042d0fcdd4a19610e838f5cfd992bcad1499861e24a28e5884452ce638803b5fac55a9967d92794723d2f4a0b49cc1148ae03dc7")] [assembly: AssemblyFileVersion("1.0.4258.31")] [assembly: AssemblyVersion("1.0.4258.31")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Microsoft.Web.WebView2.Core { internal static class COMDotNetTypeConverter { public static IReadOnlyList<string> stringCollectionCOMToNet(ICoreWebView2StringCollection rawCollection) { if (rawCollection == null) { return null; } List<string> list = new List<string>(Convert.ToInt32(rawCollection.Count)); for (uint num = 0u; num < rawCollection.Count; num++) { list.Add(rawCollection.GetValueAtIndex(num)); } return new ReadOnlyCollection<string>(list); } public static IReadOnlyList<CoreWebView2ClientCertificate> CoreWebView2ClientCertificateCollectionCOMToNet(ICoreWebView2ClientCertificateCollection rawCollection) { if (rawCollection == null) { return null; } List<CoreWebView2ClientCertificate> list = new List<CoreWebView2ClientCertificate>(Convert.ToInt32(rawCollection.Count)); for (uint num = 0u; num < rawCollection.Count; num++) { list.Add(new CoreWebView2ClientCertificate(rawCollection.GetValueAtIndex(num))); } return new ReadOnlyCollection<CoreWebView2ClientCertificate>(list); } public static IReadOnlyList<Rectangle> RectangleCollectionCOMToNet(ICoreWebView2RegionRectCollectionView rawCollection) { if (rawCollection == null) { return null; } List<Rectangle> list = new List<Rectangle>(Convert.ToInt32(rawCollection.Count)); for (uint num = 0u; num < rawCollection.Count; num++) { list.Add(RectangleCOMToNet(rawCollection.GetValueAtIndex(num))); } return new ReadOnlyCollection<Rectangle>(list); } public static IReadOnlyList<CoreWebView2ProcessExtendedInfo> CoreWebView2ProcessExtendedInfoCollectionCOMToNet(ICoreWebView2ProcessExtendedInfoCollection rawCollection) { if (rawCollection == null) { return null; } List<CoreWebView2ProcessExtendedInfo> list = new List<CoreWebView2ProcessExtendedInfo>(Convert.ToInt32(rawCollection.Count)); for (uint num = 0u; num < rawCollection.Count; num++) { list.Add(new CoreWebView2ProcessExtendedInfo(rawCollection.GetValueAtIndex(num))); } return new ReadOnlyCollection<CoreWebView2ProcessExtendedInfo>(list); } public static IReadOnlyList<CoreWebView2ProcessInfo> CoreWebView2ProcessInfoCollectionCOMToNet(ICoreWebView2ProcessInfoCollection rawCollection) { if (rawCollection == null) { return null; } List<CoreWebView2ProcessInfo> list = new List<CoreWebView2ProcessInfo>(Convert.ToInt32(rawCollection.Count)); for (uint num = 0u; num < rawCollection.Count; num++) { list.Add(new CoreWebView2ProcessInfo(rawCollection.GetValueAtIndex(num))); } return new ReadOnlyCollection<CoreWebView2ProcessInfo>(list); } public static IReadOnlyList<CoreWebView2BrowserExtension> CoreWebView2BrowserExtensionCollectionCOMToNet(ICoreWebView2BrowserExtensionList rawCollection) { if (rawCollection == null) { return null; } List<CoreWebView2BrowserExtension> list = new List<CoreWebView2BrowserExtension>(Convert.ToInt32(rawCollection.Count)); for (uint num = 0u; num < rawCollection.Count; num++) { list.Add(new CoreWebView2BrowserExtension(rawCollection.GetValueAtIndex(num))); } return new ReadOnlyCollection<CoreWebView2BrowserExtension>(list); } public static IReadOnlyList<CoreWebView2ServiceWorkerRegistration> CoreWebView2ServiceWorkerRegistrationCollectionCOMToNet(ICoreWebView2ServiceWorkerRegistrationCollectionView rawCollection) { if (rawCollection == null) { return null; } List<CoreWebView2ServiceWorkerRegistration> list = new List<CoreWebView2ServiceWorkerRegistration>(Convert.ToInt32(rawCollection.Count)); for (uint num = 0u; num < rawCollection.Count; num++) { list.Add(new CoreWebView2ServiceWorkerRegistration(rawCollection.GetValueAtIndex(num))); } return new ReadOnlyCollection<CoreWebView2ServiceWorkerRegistration>(list); } public static IReadOnlyList<CoreWebView2SharedWorker> CoreWebView2SharedWorkerCollectionCOMToNet(ICoreWebView2SharedWorkerCollectionView rawCollection) { if (rawCollection == null) { return null; } List<CoreWebView2SharedWorker> list = new List<CoreWebView2SharedWorker>(Convert.ToInt32(rawCollection.Count)); for (uint num = 0u; num < rawCollection.Count; num++) { list.Add(new CoreWebView2SharedWorker(rawCollection.GetValueAtIndex(num))); } return new ReadOnlyCollection<CoreWebView2SharedWorker>(list); } public static Rectangle RectangleCOMToNet(tagRECT rect) { int x = rect.left; int y = rect.top; int width = rect.right - rect.left; int height = rect.bottom - rect.top; return new Rectangle(x, y, width, height); } public static tagRECT RectangleNetToCOM(Rectangle dotNetRect) { return new tagRECT { top = dotNetRect.Top, left = dotNetRect.Left, right = dotNetRect.Right, bottom = dotNetRect.Bottom }; } public static List<CoreWebView2Cookie> CoreWebView2CookieCollectionCOMToNet(ICoreWebView2CookieList rawCookieList) { List<CoreWebView2Cookie> list = new List<CoreWebView2Cookie>(Convert.ToInt32(rawCookieList.Count)); for (uint num = 0u; num < rawCookieList.Count; num++) { list.Add(new CoreWebView2Cookie(rawCookieList.GetValueAtIndex(num))); } return list; } public static IReadOnlyList<CoreWebView2FrameInfo> CoreWebView2FrameInfoCollectionCOMToNet(ICoreWebView2FrameInfoCollection rawFrameInfoCollection) { if (rawFrameInfoCollection == null) { return null; } List<CoreWebView2FrameInfo> list = new List<CoreWebView2FrameInfo>(); ICoreWebView2FrameInfoCollectionIterator iterator = rawFrameInfoCollection.GetIterator(); while (iterator.HasCurrent != 0) { list.Add(new CoreWebView2FrameInfo(iterator.GetCurrent())); iterator.MoveNext(); } return new ReadOnlyCollection<CoreWebView2FrameInfo>(list); } public static Color ColorCOMToNet(COREWEBVIEW2_COLOR color) { return Color.FromArgb(color.A, color.R, color.G, color.B); } public static COREWEBVIEW2_COLOR ColorNetToCOM(Color dotNetColor) { return new COREWEBVIEW2_COLOR { A = dotNetColor.A, R = dotNetColor.R, G = dotNetColor.G, B = dotNetColor.B }; } public static Point PointCOMToNet(tagPOINT point) { return new Point(point.x, point.y); } public static tagPOINT PointNetToCOM(Point dotNetPoint) { return new tagPOINT { x = Convert.ToInt32(dotNetPoint.X), y = Convert.ToInt32(dotNetPoint.Y) }; } public static TimeSpan ThrottlingIntervalCOMToNet(int intervalMs) { return new TimeSpan(0, 0, 0, 0, intervalMs); } public static int ThrottlingIntervalNetToCOM(TimeSpan timeSpan) { return timeSpan.Milliseconds; } public static IReadOnlyList<string> CoreWebView2StringCollectionCOMToNet(ICoreWebView2StringCollection rawStringCollection) { if (rawStringCollection == null) { return null; } List<string> list = new List<string>(Convert.ToInt32(rawStringCollection.Count)); for (uint num = 0u; num < rawStringCollection.Count; num++) { list.Add(rawStringCollection.GetValueAtIndex(num)); } return new ReadOnlyCollection<string>(list); } public static IReadOnlyList<object> objectCollectionCOMToNet(ICoreWebView2ObjectCollectionView rawObjectCollection) { if (rawObjectCollection == null) { return null; } List<object> list = new List<object>(Convert.ToInt32(rawObjectCollection.Count)); for (uint num = 0u; num < rawObjectCollection.Count; num++) { object obj = rawObjectCollection.GetValueAtIndex(num); if (obj != null) { if (!(obj is ICoreWebView2File rawCoreWebView2File)) { continue; } obj = new CoreWebView2File(rawCoreWebView2File); } list.Add(obj); } return new ReadOnlyCollection<object>(list); } public static IList<CoreWebView2ContextMenuItem> CoreWebView2ContextMenuItemCollectionCOMToNet(ICoreWebView2ContextMenuItemCollection rawContextMenuCollection) { if (rawContextMenuCollection == null) { return null; } List<CoreWebView2ContextMenuItem> list = new List<CoreWebView2ContextMenuItem>(Convert.ToInt32(rawContextMenuCollection.Count)); for (uint num = 0u; num < rawContextMenuCollection.Count; num++) { list.Add(new CoreWebView2ContextMenuItem(rawContextMenuCollection.GetValueAtIndex(num))); } ObservableCollection<CoreWebView2ContextMenuItem> collection = new ObservableCollection<CoreWebView2ContextMenuItem>(list); collection.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs args) { switch (args.Action) { case NotifyCollectionChangedAction.Remove: rawContextMenuCollection.RemoveValueAtIndex((uint)args.OldStartingIndex); break; case NotifyCollectionChangedAction.Add: rawContextMenuCollection.InsertValueAtIndex((uint)args.NewStartingIndex, ((CoreWebView2ContextMenuItem)args.NewItems[0])._nativeICoreWebView2ContextMenuItem); break; case NotifyCollectionChangedAction.Replace: rawContextMenuCollection.RemoveValueAtIndex((uint)args.OldStartingIndex); rawContextMenuCollection.InsertValueAtIndex((uint)args.NewStartingIndex, ((CoreWebView2ContextMenuItem)args.NewItems[0])._nativeICoreWebView2ContextMenuItem); break; case NotifyCollectionChangedAction.Move: case NotifyCollectionChangedAction.Reset: { uint count = rawContextMenuCollection.Count; for (uint num2 = 0u; num2 < count; num2++) { rawContextMenuCollection.RemoveValueAtIndex(0u); } for (int i = 0; i < collection.Count; i++) { rawContextMenuCollection.InsertValueAtIndex((uint)i, collection[i]._nativeICoreWebView2ContextMenuItem); } break; } } }; return collection; } public static IReadOnlyList<Rectangle> CoreWebView2RegionRectCollectionViewCOMToNet(ICoreWebView2RegionRectCollectionView regionList) { if (regionList == null) { return null; } List<Rectangle> list = new List<Rectangle>(Convert.ToInt32(regionList.Count)); for (uint num = 0u; num < regionList.Count; num++) { list.Add(RectangleCOMToNet(regionList.GetValueAtIndex(num))); } return new ReadOnlyCollection<Rectangle>(list); } public static COMStreamWrapper StreamCOMToNet(IStream stream) { if (stream == null) { return null; } return new COMStreamWrapper(stream); } public static IReadOnlyList<CoreWebView2PermissionSetting> CoreWebView2PermissionSettingCollectionCOMToNet(ICoreWebView2PermissionSettingCollectionView rawPermissionSettingCollectionView) { if (rawPermissionSettingCollectionView == null) { return null; } List<CoreWebView2PermissionSetting> list = new List<CoreWebView2PermissionSetting>(Convert.ToInt32(rawPermissionSettingCollectionView.Count)); for (uint num = 0u; num < rawPermissionSettingCollectionView.Count; num++) { list.Add(new CoreWebView2PermissionSetting(rawPermissionSettingCollectionView.GetValueAtIndex(num))); } return new ReadOnlyCollection<CoreWebView2PermissionSetting>(list); } public static ICoreWebView2ObjectCollectionView CoreWebView2WebObjectCollectionViewNetToCOM(List<object> dotNetObjectCollection) { return new CoreWebView2WebObjectCollectionView(dotNetObjectCollection); } } public enum CoreWebView2BoundsMode { UseRawPixels, UseRasterizationScale } public enum CoreWebView2BrowserProcessExitKind { Normal, Failed } [Flags] public enum CoreWebView2BrowsingDataKinds { FileSystems = 1, IndexedDb = 2, LocalStorage = 4, WebSql = 8, CacheStorage = 0x10, AllDomStorage = 0x20, Cookies = 0x40, AllSite = 0x80, DiskCache = 0x100, DownloadHistory = 0x200, GeneralAutofill = 0x400, PasswordAutosave = 0x800, BrowsingHistory = 0x1000, Settings = 0x2000, AllProfile = 0x4000, ServiceWorkers = 0x8000 } public enum CoreWebView2CapturePreviewImageFormat { Png, Jpeg } public enum CoreWebView2ChannelSearchKind { MostStable, LeastStable } public enum CoreWebView2ClientCertificateKind { SmartCard, Pin, Other } public enum CoreWebView2ContextMenuItemKind { Command, CheckBox, Radio, Separator, Submenu } public enum CoreWebView2ContextMenuTargetKind { Page, Image, SelectedText, Audio, Video } public enum CoreWebView2CookieSameSiteKind { None, Lax, Strict } public enum CoreWebView2DefaultDownloadDialogCornerAlignment { TopLeft, TopRight, BottomLeft, BottomRight } public enum CoreWebView2DownloadInterruptReason { None, FileFailed, FileAccessDenied, FileNoSpace, FileNameTooLong, FileTooLarge, FileMalicious, FileTransientError, FileBlockedByPolicy, FileSecurityCheckFailed, FileTooShort, FileHashMismatch, NetworkFailed, NetworkTimeout, NetworkDisconnected, NetworkServerDown, NetworkInvalidRequest, ServerFailed, ServerNoRange, ServerBadContent, ServerUnauthorized, ServerCertificateProblem, ServerForbidden, ServerUnexpectedResponse, ServerContentLengthMismatch, ServerCrossOriginRedirect, UserCanceled, UserShutdown, UserPaused, DownloadProcessCrashed } public enum CoreWebView2DownloadState { InProgress, Interrupted, Completed } public enum CoreWebView2FaviconImageFormat { Png, Jpeg } public enum CoreWebView2FileSystemHandleKind { File, Directory } public enum CoreWebView2FileSystemHandlePermission { ReadOnly, ReadWrite } public enum CoreWebView2FrameKind { Unknown, MainFrame, Iframe, Embed, Object } public enum CoreWebView2HostResourceAccessKind { Deny, Allow, DenyCors } public enum CoreWebView2KeyEventKind { KeyDown, KeyUp, SystemKeyDown, SystemKeyUp } public enum CoreWebView2MemoryUsageTargetLevel { Normal, Low } public enum CoreWebView2MouseEventKind { HorizontalWheel = 526, LeftButtonDoubleClick = 515, LeftButtonDown = 513, LeftButtonUp = 514, Leave = 675, MiddleButtonDoubleClick = 521, MiddleButtonDown = 519, MiddleButtonUp = 520, Move = 512, RightButtonDoubleClick = 518, RightButtonDown = 516, RightButtonUp = 517, Wheel = 522, XButtonDoubleClick = 525, XButtonDown = 523, XButtonUp = 524, NonClientRightButtonDown = 164, NonClientRightButtonUp = 165 } [Flags] public enum CoreWebView2MouseEventVirtualKeys { None = 0, LeftButton = 1, RightButton = 2, Shift = 4, Control = 8, MiddleButton = 0x10, XButton1 = 0x20, XButton2 = 0x40 } public enum CoreWebView2MoveFocusReason { Programmatic, Next, Previous } public enum CoreWebView2NavigationKind { Reload, BackOrForward, NewDocument } public enum CoreWebView2NonClientRegionKind { Nowhere = 0, Client = 1, Caption = 2, Minimize = 8, Maximize = 9, Close = 20 } [Flags] public enum CoreWebView2PdfToolbarItems { None = 0, Save = 1, Print = 2, SaveAs = 4, ZoomIn = 8, ZoomOut = 0x10, Rotate = 0x20, FitPage = 0x40, PageLayout = 0x80, Bookmarks = 0x100, PageSelector = 0x200, Search = 0x400, FullScreen = 0x800, MoreSettings = 0x1000 } public enum CoreWebView2PermissionKind { UnknownPermission, Microphone, Camera, Geolocation, Notifications, OtherSensors, ClipboardRead, MultipleAutomaticDownloads, FileReadWrite, Autoplay, LocalFonts, MidiSystemExclusiveMessages, WindowManagement, PersistentStorage } public enum CoreWebView2PermissionState { Default, Allow, Deny } public enum CoreWebView2PointerEventKind { Activate = 587, Down = 582, Enter = 585, Leave = 586, Up = 583, Update = 581 } public enum CoreWebView2PreferredColorScheme { Auto, Light, Dark } public enum CoreWebView2PrintCollation { Default, Collated, Uncollated } public enum CoreWebView2PrintColorMode { Default, Color, Grayscale } public enum CoreWebView2PrintDialogKind { Browser, System } public enum CoreWebView2PrintDuplex { Default, OneSided, TwoSidedLongEdge, TwoSidedShortEdge } public enum CoreWebView2PrintMediaSize { Default, Custom } public enum CoreWebView2PrintOrientation { Portrait, Landscape } public enum CoreWebView2PrintStatus { Succeeded, PrinterUnavailable, OtherError } public enum CoreWebView2ProcessFailedKind { BrowserProcessExited, RenderProcessExited, RenderProcessUnresponsive, FrameRenderProcessExited, UtilityProcessExited, SandboxHelperProcessExited, GpuProcessExited, PpapiPluginProcessExited, PpapiBrokerProcessExited, UnknownProcessExited } public enum CoreWebView2ProcessFailedReason { Unexpected, Unresponsive, Terminated, Crashed, LaunchFailed, OutOfMemory, ProfileDeleted, NormalExit, AbnormalExit, IntegrityFailure } public enum CoreWebView2ProcessKind { Browser, Renderer, Utility, SandboxHelper, Gpu, PpapiPlugin, PpapiBroker } [Flags] public enum CoreWebView2ReleaseChannels { None = 0, Stable = 1, Beta = 2, Dev = 4, Canary = 8 } public enum CoreWebView2SaveAsKind { Default, HtmlOnly, SingleFile, Complete } public enum CoreWebView2SaveAsUIResult { Success, InvalidPath, FileAlreadyExists, KindNotSupported, Cancelled } public enum CoreWebView2ScriptDialogKind { Alert, Confirm, Prompt, Beforeunload } public enum CoreWebView2ScrollbarStyle { Default, FluentOverlay } public enum CoreWebView2ServerCertificateErrorAction { AlwaysAllow, Cancel, Default } public enum CoreWebView2SharedBufferAccess { ReadOnly, ReadWrite } public enum CoreWebView2TextDirectionKind { Default, LeftToRight, RightToLeft } public enum CoreWebView2TrackingPreventionLevel { None, Basic, Balanced, Strict } public enum CoreWebView2WebErrorStatus { Unknown, CertificateCommonNameIsIncorrect, CertificateExpired, ClientCertificateContainsErrors, CertificateRevoked, CertificateIsInvalid, ServerUnreachable, Timeout, ErrorHttpInvalidServerResponse, ConnectionAborted, ConnectionReset, Disconnected, CannotConnect, HostNameNotResolved, OperationCanceled, RedirectFailed, UnexpectedError, ValidAuthenticationCredentialsRequired, ValidProxyAuthenticationRequired } public enum CoreWebView2WebResourceContext { All, Document, Stylesheet, Image, Media, Font, Script, XmlHttpRequest, Fetch, TextTrack, EventSource, Websocket, Manifest, SignedExchange, Ping, CspViolationReport, Other } [Flags] public enum CoreWebView2WebResourceRequestSourceKinds { None = 0, Document = 1, SharedWorker = 2, ServiceWorker = 4, All = -1 } public struct CoreWebView2Color { public byte A; public byte R; public byte G; public byte B; internal CoreWebView2Color(COREWEBVIEW2_COLOR rawStruct) { A = rawStruct.A; R = rawStruct.R; G = rawStruct.G; B = rawStruct.B; } } public class CoreWebView2 { internal object _rawNative; internal ICoreWebView2 _nativeICoreWebView2Value; private EventRegistrationToken _ContainsFullScreenElementChangedToken; private EventHandler<object> privateContainsFullScreenElementChanged; private EventRegistrationToken _ContentLoadingToken; private EventHandler<CoreWebView2ContentLoadingEventArgs> privateContentLoading; private EventRegistrationToken _DocumentTitleChangedToken; private EventHandler<object> privateDocumentTitleChanged; private EventRegistrationToken _FrameNavigationCompletedToken; private EventHandler<CoreWebView2NavigationCompletedEventArgs> privateFrameNavigationCompleted; private EventRegistrationToken _FrameNavigationStartingToken; private EventHandler<CoreWebView2NavigationStartingEventArgs> privateFrameNavigationStarting; private EventRegistrationToken _HistoryChangedToken; private EventHandler<object> privateHistoryChanged; private EventRegistrationToken _NavigationCompletedToken; private EventHandler<CoreWebView2NavigationCompletedEventArgs> privateNavigationCompleted; private EventRegistrationToken _NavigationStartingToken; private EventHandler<CoreWebView2NavigationStartingEventArgs> privateNavigationStarting; private EventRegistrationToken _NewWindowRequestedToken; private EventHandler<CoreWebView2NewWindowRequestedEventArgs> privateNewWindowRequested; private EventRegistrationToken _PermissionRequestedToken; private EventHandler<CoreWebView2PermissionRequestedEventArgs> privatePermissionRequested; private EventRegistrationToken _ProcessFailedToken; private EventHandler<CoreWebView2ProcessFailedEventArgs> privateProcessFailed; private EventRegistrationToken _ScriptDialogOpeningToken; private EventHandler<CoreWebView2ScriptDialogOpeningEventArgs> privateScriptDialogOpening; private EventRegistrationToken _SourceChangedToken; private EventHandler<CoreWebView2SourceChangedEventArgs> privateSourceChanged; private EventRegistrationToken _WebMessageReceivedToken; private EventHandler<CoreWebView2WebMessageReceivedEventArgs> privateWebMessageReceived; private EventRegistrationToken _WebResourceRequestedToken; private EventHandler<CoreWebView2WebResourceRequestedEventArgs> privateWebResourceRequested; private EventRegistrationToken _WindowCloseRequestedToken; private EventHandler<object> privateWindowCloseRequested; internal ICoreWebView2PrivatePartial _nativeICoreWebView2PrivatePartialValue; internal ICoreWebView2_10 _nativeICoreWebView2_10Value; private EventRegistrationToken _BasicAuthenticationRequestedToken; private EventHandler<CoreWebView2BasicAuthenticationRequestedEventArgs> privateBasicAuthenticationRequested; internal ICoreWebView2_11 _nativeICoreWebView2_11Value; private EventRegistrationToken _ContextMenuRequestedToken; private EventHandler<CoreWebView2ContextMenuRequestedEventArgs> privateContextMenuRequested; internal ICoreWebView2_12 _nativeICoreWebView2_12Value; private EventRegistrationToken _StatusBarTextChangedToken; private EventHandler<object> privateStatusBarTextChanged; internal ICoreWebView2_13 _nativeICoreWebView2_13Value; internal ICoreWebView2_14 _nativeICoreWebView2_14Value; private EventRegistrationToken _ServerCertificateErrorDetectedToken; private EventHandler<CoreWebView2ServerCertificateErrorDetectedEventArgs> privateServerCertificateErrorDetected; internal ICoreWebView2_15 _nativeICoreWebView2_15Value; private EventRegistrationToken _FaviconChangedToken; private EventHandler<object> privateFaviconChanged; internal ICoreWebView2_16 _nativeICoreWebView2_16Value; internal ICoreWebView2_17 _nativeICoreWebView2_17Value; internal ICoreWebView2_18 _nativeICoreWebView2_18Value; private EventRegistrationToken _LaunchingExternalUriSchemeToken; private EventHandler<CoreWebView2LaunchingExternalUriSchemeEventArgs> privateLaunchingExternalUriScheme; internal ICoreWebView2_19 _nativeICoreWebView2_19Value; internal ICoreWebView2_2 _nativeICoreWebView2_2Value; private EventRegistrationToken _DOMContentLoadedToken; private EventHandler<CoreWebView2DOMContentLoadedEventArgs> privateDOMContentLoaded; private EventRegistrationToken _WebResourceResponseReceivedToken; private EventHandler<CoreWebView2WebResourceResponseReceivedEventArgs> privateWebResourceResponseReceived; internal ICoreWebView2_20 _nativeICoreWebView2_20Value; internal ICoreWebView2_21 _nativeICoreWebView2_21Value; internal ICoreWebView2_22 _nativeICoreWebView2_22Value; internal ICoreWebView2_25 _nativeICoreWebView2_25Value; private EventRegistrationToken _SaveAsUIShowingToken; private EventHandler<CoreWebView2SaveAsUIShowingEventArgs> privateSaveAsUIShowing; internal ICoreWebView2_23 _nativeICoreWebView2_23Value; internal ICoreWebView2_27 _nativeICoreWebView2_27Value; private EventRegistrationToken _ScreenCaptureStartingToken; private EventHandler<CoreWebView2ScreenCaptureStartingEventArgs> privateScreenCaptureStarting; internal ICoreWebView2_28 _nativeICoreWebView2_28Value; internal ICoreWebView2_26 _nativeICoreWebView2_26Value; private EventRegistrationToken _SaveFileSecurityCheckStartingToken; private EventHandler<CoreWebView2SaveFileSecurityCheckStartingEventArgs> privateSaveFileSecurityCheckStarting; internal ICoreWebView2_24 _nativeICoreWebView2_24Value; private EventRegistrationToken _NotificationReceivedToken; private EventHandler<CoreWebView2NotificationReceivedEventArgs> privateNotificationReceived; internal ICoreWebView2_3 _nativeICoreWebView2_3Value; internal ICoreWebView2_29 _nativeICoreWebView2_29Value; private EventRegistrationToken _DedicatedWorkerCreatedToken; private EventHandler<CoreWebView2DedicatedWorkerCreatedEventArgs> privateDedicatedWorkerCreated; internal ICoreWebView2_4 _nativeICoreWebView2_4Value; private EventRegistrationToken _DownloadStartingToken; private EventHandler<CoreWebView2DownloadStartingEventArgs> privateDownloadStarting; private EventRegistrationToken _FrameCreatedToken; private EventHandler<CoreWebView2FrameCreatedEventArgs> privateFrameCreated; internal ICoreWebView2_5 _nativeICoreWebView2_5Value; private EventRegistrationToken _ClientCertificateRequestedToken; private EventHandler<CoreWebView2ClientCertificateRequestedEventArgs> privateClientCertificateRequested; internal ICoreWebView2_6 _nativeICoreWebView2_6Value; internal ICoreWebView2_7 _nativeICoreWebView2_7Value; internal ICoreWebView2_8 _nativeICoreWebView2_8Value; private EventRegistrationToken _IsDocumentPlayingAudioChangedToken; private EventHandler<object> privateIsDocumentPlayingAudioChanged; private EventRegistrationToken _IsMutedChangedToken; private EventHandler<object> privateIsMutedChanged; internal ICoreWebView2_9 _nativeICoreWebView2_9Value; private EventRegistrationToken _IsDefaultDownloadDialogOpenChangedToken; private EventHandler<object> privateIsDefaultDownloadDialogOpenChanged; internal ICoreWebView2 _nativeICoreWebView2 { get { if (_nativeICoreWebView2Value == null) { try { _nativeICoreWebView2Value = (ICoreWebView2)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2Value; } set { _nativeICoreWebView2Value = value; } } public uint BrowserProcessId { get { try { return _nativeICoreWebView2.BrowserProcessId; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public bool CanGoBack { get { try { return _nativeICoreWebView2.CanGoBack != 0; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public bool CanGoForward { get { try { return _nativeICoreWebView2.CanGoForward != 0; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public bool ContainsFullScreenElement { get { try { return _nativeICoreWebView2.ContainsFullScreenElement != 0; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public string DocumentTitle { get { try { return _nativeICoreWebView2.DocumentTitle; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public CoreWebView2Settings Settings { get { try { return (_nativeICoreWebView2.Settings == null) ? null : new CoreWebView2Settings(_nativeICoreWebView2.Settings); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public string Source { get { try { return _nativeICoreWebView2.Source; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } internal ICoreWebView2PrivatePartial _nativeICoreWebView2PrivatePartial { get { if (_nativeICoreWebView2PrivatePartialValue == null) { try { _nativeICoreWebView2PrivatePartialValue = (ICoreWebView2PrivatePartial)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2PrivatePartial.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2PrivatePartialValue; } set { _nativeICoreWebView2PrivatePartialValue = value; } } internal ICoreWebView2_10 _nativeICoreWebView2_10 { get { if (_nativeICoreWebView2_10Value == null) { try { _nativeICoreWebView2_10Value = (ICoreWebView2_10)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_10.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_10Value; } set { _nativeICoreWebView2_10Value = value; } } internal ICoreWebView2_11 _nativeICoreWebView2_11 { get { if (_nativeICoreWebView2_11Value == null) { try { _nativeICoreWebView2_11Value = (ICoreWebView2_11)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_11.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_11Value; } set { _nativeICoreWebView2_11Value = value; } } internal ICoreWebView2_12 _nativeICoreWebView2_12 { get { if (_nativeICoreWebView2_12Value == null) { try { _nativeICoreWebView2_12Value = (ICoreWebView2_12)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_12.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_12Value; } set { _nativeICoreWebView2_12Value = value; } } public string StatusBarText { get { try { return _nativeICoreWebView2_12.StatusBarText; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } internal ICoreWebView2_13 _nativeICoreWebView2_13 { get { if (_nativeICoreWebView2_13Value == null) { try { _nativeICoreWebView2_13Value = (ICoreWebView2_13)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_13.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_13Value; } set { _nativeICoreWebView2_13Value = value; } } public CoreWebView2Profile Profile { get { try { return (_nativeICoreWebView2_13.Profile == null) ? null : new CoreWebView2Profile(_nativeICoreWebView2_13.Profile); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } internal ICoreWebView2_14 _nativeICoreWebView2_14 { get { if (_nativeICoreWebView2_14Value == null) { try { _nativeICoreWebView2_14Value = (ICoreWebView2_14)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_14.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_14Value; } set { _nativeICoreWebView2_14Value = value; } } internal ICoreWebView2_15 _nativeICoreWebView2_15 { get { if (_nativeICoreWebView2_15Value == null) { try { _nativeICoreWebView2_15Value = (ICoreWebView2_15)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_15.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_15Value; } set { _nativeICoreWebView2_15Value = value; } } public string FaviconUri { get { try { return _nativeICoreWebView2_15.FaviconUri; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } internal ICoreWebView2_16 _nativeICoreWebView2_16 { get { if (_nativeICoreWebView2_16Value == null) { try { _nativeICoreWebView2_16Value = (ICoreWebView2_16)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_16.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_16Value; } set { _nativeICoreWebView2_16Value = value; } } internal ICoreWebView2_17 _nativeICoreWebView2_17 { get { if (_nativeICoreWebView2_17Value == null) { try { _nativeICoreWebView2_17Value = (ICoreWebView2_17)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_17.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_17Value; } set { _nativeICoreWebView2_17Value = value; } } internal ICoreWebView2_18 _nativeICoreWebView2_18 { get { if (_nativeICoreWebView2_18Value == null) { try { _nativeICoreWebView2_18Value = (ICoreWebView2_18)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_18.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_18Value; } set { _nativeICoreWebView2_18Value = value; } } internal ICoreWebView2_19 _nativeICoreWebView2_19 { get { if (_nativeICoreWebView2_19Value == null) { try { _nativeICoreWebView2_19Value = (ICoreWebView2_19)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_19.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_19Value; } set { _nativeICoreWebView2_19Value = value; } } public CoreWebView2MemoryUsageTargetLevel MemoryUsageTargetLevel { get { try { return (CoreWebView2MemoryUsageTargetLevel)_nativeICoreWebView2_19.MemoryUsageTargetLevel; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } set { try { _nativeICoreWebView2_19.MemoryUsageTargetLevel = (COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL)value; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } internal ICoreWebView2_2 _nativeICoreWebView2_2 { get { if (_nativeICoreWebView2_2Value == null) { try { _nativeICoreWebView2_2Value = (ICoreWebView2_2)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_2.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_2Value; } set { _nativeICoreWebView2_2Value = value; } } public CoreWebView2CookieManager CookieManager { get { try { return (_nativeICoreWebView2_2.CookieManager == null) ? null : new CoreWebView2CookieManager(_nativeICoreWebView2_2.CookieManager); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public CoreWebView2Environment Environment { get { try { return (_nativeICoreWebView2_2.Environment == null) ? null : new CoreWebView2Environment(_nativeICoreWebView2_2.Environment); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } internal ICoreWebView2_20 _nativeICoreWebView2_20 { get { if (_nativeICoreWebView2_20Value == null) { try { _nativeICoreWebView2_20Value = (ICoreWebView2_20)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_20.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_20Value; } set { _nativeICoreWebView2_20Value = value; } } public uint FrameId { get { try { return _nativeICoreWebView2_20.FrameId; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } internal ICoreWebView2_21 _nativeICoreWebView2_21 { get { if (_nativeICoreWebView2_21Value == null) { try { _nativeICoreWebView2_21Value = (ICoreWebView2_21)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_21.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_21Value; } set { _nativeICoreWebView2_21Value = value; } } internal ICoreWebView2_22 _nativeICoreWebView2_22 { get { if (_nativeICoreWebView2_22Value == null) { try { _nativeICoreWebView2_22Value = (ICoreWebView2_22)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_22.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_22Value; } set { _nativeICoreWebView2_22Value = value; } } internal ICoreWebView2_25 _nativeICoreWebView2_25 { get { if (_nativeICoreWebView2_25Value == null) { try { _nativeICoreWebView2_25Value = (ICoreWebView2_25)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_25.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_25Value; } set { _nativeICoreWebView2_25Value = value; } } internal ICoreWebView2_23 _nativeICoreWebView2_23 { get { if (_nativeICoreWebView2_23Value == null) { try { _nativeICoreWebView2_23Value = (ICoreWebView2_23)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_23.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_23Value; } set { _nativeICoreWebView2_23Value = value; } } internal ICoreWebView2_27 _nativeICoreWebView2_27 { get { if (_nativeICoreWebView2_27Value == null) { try { _nativeICoreWebView2_27Value = (ICoreWebView2_27)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_27.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_27Value; } set { _nativeICoreWebView2_27Value = value; } } internal ICoreWebView2_28 _nativeICoreWebView2_28 { get { if (_nativeICoreWebView2_28Value == null) { try { _nativeICoreWebView2_28Value = (ICoreWebView2_28)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_28.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_28Value; } set { _nativeICoreWebView2_28Value = value; } } public CoreWebView2Find Find { get { try { return (_nativeICoreWebView2_28.Find == null) ? null : new CoreWebView2Find(_nativeICoreWebView2_28.Find); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } internal ICoreWebView2_26 _nativeICoreWebView2_26 { get { if (_nativeICoreWebView2_26Value == null) { try { _nativeICoreWebView2_26Value = (ICoreWebView2_26)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_26.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_26Value; } set { _nativeICoreWebView2_26Value = value; } } internal ICoreWebView2_24 _nativeICoreWebView2_24 { get { if (_nativeICoreWebView2_24Value == null) { try { _nativeICoreWebView2_24Value = (ICoreWebView2_24)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_24.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_24Value; } set { _nativeICoreWebView2_24Value = value; } } internal ICoreWebView2_3 _nativeICoreWebView2_3 { get { if (_nativeICoreWebView2_3Value == null) { try { _nativeICoreWebView2_3Value = (ICoreWebView2_3)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_3.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_3Value; } set { _nativeICoreWebView2_3Value = value; } } public bool IsSuspended { get { try { return _nativeICoreWebView2_3.IsSuspended != 0; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } internal ICoreWebView2_29 _nativeICoreWebView2_29 { get { if (_nativeICoreWebView2_29Value == null) { try { _nativeICoreWebView2_29Value = (ICoreWebView2_29)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_29.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_29Value; } set { _nativeICoreWebView2_29Value = value; } } internal ICoreWebView2_4 _nativeICoreWebView2_4 { get { if (_nativeICoreWebView2_4Value == null) { try { _nativeICoreWebView2_4Value = (ICoreWebView2_4)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_4.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_4Value; } set { _nativeICoreWebView2_4Value = value; } } internal ICoreWebView2_5 _nativeICoreWebView2_5 { get { if (_nativeICoreWebView2_5Value == null) { try { _nativeICoreWebView2_5Value = (ICoreWebView2_5)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_5.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_5Value; } set { _nativeICoreWebView2_5Value = value; } } internal ICoreWebView2_6 _nativeICoreWebView2_6 { get { if (_nativeICoreWebView2_6Value == null) { try { _nativeICoreWebView2_6Value = (ICoreWebView2_6)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_6.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_6Value; } set { _nativeICoreWebView2_6Value = value; } } internal ICoreWebView2_7 _nativeICoreWebView2_7 { get { if (_nativeICoreWebView2_7Value == null) { try { _nativeICoreWebView2_7Value = (ICoreWebView2_7)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_7.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_7Value; } set { _nativeICoreWebView2_7Value = value; } } internal ICoreWebView2_8 _nativeICoreWebView2_8 { get { if (_nativeICoreWebView2_8Value == null) { try { _nativeICoreWebView2_8Value = (ICoreWebView2_8)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_8.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_8Value; } set { _nativeICoreWebView2_8Value = value; } } public bool IsDocumentPlayingAudio { get { try { return _nativeICoreWebView2_8.IsDocumentPlayingAudio != 0; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public bool IsMuted { get { try { return _nativeICoreWebView2_8.IsMuted != 0; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } set { try { _nativeICoreWebView2_8.IsMuted = (value ? 1 : 0); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } internal ICoreWebView2_9 _nativeICoreWebView2_9 { get { if (_nativeICoreWebView2_9Value == null) { try { _nativeICoreWebView2_9Value = (ICoreWebView2_9)_rawNative; } catch (Exception inner) { throw new NotImplementedException("Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_9.\nThis may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.\nFor instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.\nOr, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.\nFor more information about WebView2 versioning please visit the following: https://learn.microsoft.com/microsoft-edge/webview2/concepts/versioning", inner); } } return _nativeICoreWebView2_9Value; } set { _nativeICoreWebView2_9Value = value; } } public CoreWebView2DefaultDownloadDialogCornerAlignment DefaultDownloadDialogCornerAlignment { get { try { return (CoreWebView2DefaultDownloadDialogCornerAlignment)_nativeICoreWebView2_9.DefaultDownloadDialogCornerAlignment; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } set { try { _nativeICoreWebView2_9.DefaultDownloadDialogCornerAlignment = (COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT)value; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public Point DefaultDownloadDialogMargin { get { try { return COMDotNetTypeConverter.PointCOMToNet(_nativeICoreWebView2_9.DefaultDownloadDialogMargin); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } set { try { _nativeICoreWebView2_9.DefaultDownloadDialogMargin = COMDotNetTypeConverter.PointNetToCOM(value); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public bool IsDefaultDownloadDialogOpen { get { try { return _nativeICoreWebView2_9.IsDefaultDownloadDialogOpen != 0; } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<object> ContainsFullScreenElementChanged { add { if (privateContainsFullScreenElementChanged == null) { try { _nativeICoreWebView2.add_ContainsFullScreenElementChanged(new CoreWebView2ContainsFullScreenElementChangedEventHandler(OnContainsFullScreenElementChanged), out _ContainsFullScreenElementChangedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateContainsFullScreenElementChanged = (EventHandler<object>)Delegate.Combine(privateContainsFullScreenElementChanged, value); } remove { privateContainsFullScreenElementChanged = (EventHandler<object>)Delegate.Remove(privateContainsFullScreenElementChanged, value); if (privateContainsFullScreenElementChanged != null) { return; } try { _nativeICoreWebView2.remove_ContainsFullScreenElementChanged(_ContainsFullScreenElementChangedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2ContentLoadingEventArgs> ContentLoading { add { if (privateContentLoading == null) { try { _nativeICoreWebView2.add_ContentLoading(new CoreWebView2ContentLoadingEventHandler(OnContentLoading), out _ContentLoadingToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateContentLoading = (EventHandler<CoreWebView2ContentLoadingEventArgs>)Delegate.Combine(privateContentLoading, value); } remove { privateContentLoading = (EventHandler<CoreWebView2ContentLoadingEventArgs>)Delegate.Remove(privateContentLoading, value); if (privateContentLoading != null) { return; } try { _nativeICoreWebView2.remove_ContentLoading(_ContentLoadingToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<object> DocumentTitleChanged { add { if (privateDocumentTitleChanged == null) { try { _nativeICoreWebView2.add_DocumentTitleChanged(new CoreWebView2DocumentTitleChangedEventHandler(OnDocumentTitleChanged), out _DocumentTitleChangedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateDocumentTitleChanged = (EventHandler<object>)Delegate.Combine(privateDocumentTitleChanged, value); } remove { privateDocumentTitleChanged = (EventHandler<object>)Delegate.Remove(privateDocumentTitleChanged, value); if (privateDocumentTitleChanged != null) { return; } try { _nativeICoreWebView2.remove_DocumentTitleChanged(_DocumentTitleChangedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2NavigationCompletedEventArgs> FrameNavigationCompleted { add { if (privateFrameNavigationCompleted == null) { try { _nativeICoreWebView2.add_FrameNavigationCompleted(new CoreWebView2NavigationCompletedEventHandler(OnFrameNavigationCompleted), out _FrameNavigationCompletedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateFrameNavigationCompleted = (EventHandler<CoreWebView2NavigationCompletedEventArgs>)Delegate.Combine(privateFrameNavigationCompleted, value); } remove { privateFrameNavigationCompleted = (EventHandler<CoreWebView2NavigationCompletedEventArgs>)Delegate.Remove(privateFrameNavigationCompleted, value); if (privateFrameNavigationCompleted != null) { return; } try { _nativeICoreWebView2.remove_FrameNavigationCompleted(_FrameNavigationCompletedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2NavigationStartingEventArgs> FrameNavigationStarting { add { if (privateFrameNavigationStarting == null) { try { _nativeICoreWebView2.add_FrameNavigationStarting(new CoreWebView2NavigationStartingEventHandler(OnFrameNavigationStarting), out _FrameNavigationStartingToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateFrameNavigationStarting = (EventHandler<CoreWebView2NavigationStartingEventArgs>)Delegate.Combine(privateFrameNavigationStarting, value); } remove { privateFrameNavigationStarting = (EventHandler<CoreWebView2NavigationStartingEventArgs>)Delegate.Remove(privateFrameNavigationStarting, value); if (privateFrameNavigationStarting != null) { return; } try { _nativeICoreWebView2.remove_FrameNavigationStarting(_FrameNavigationStartingToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<object> HistoryChanged { add { if (privateHistoryChanged == null) { try { _nativeICoreWebView2.add_HistoryChanged(new CoreWebView2HistoryChangedEventHandler(OnHistoryChanged), out _HistoryChangedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateHistoryChanged = (EventHandler<object>)Delegate.Combine(privateHistoryChanged, value); } remove { privateHistoryChanged = (EventHandler<object>)Delegate.Remove(privateHistoryChanged, value); if (privateHistoryChanged != null) { return; } try { _nativeICoreWebView2.remove_HistoryChanged(_HistoryChangedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2NavigationCompletedEventArgs> NavigationCompleted { add { if (privateNavigationCompleted == null) { try { _nativeICoreWebView2.add_NavigationCompleted(new CoreWebView2NavigationCompletedEventHandler(OnNavigationCompleted), out _NavigationCompletedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateNavigationCompleted = (EventHandler<CoreWebView2NavigationCompletedEventArgs>)Delegate.Combine(privateNavigationCompleted, value); } remove { privateNavigationCompleted = (EventHandler<CoreWebView2NavigationCompletedEventArgs>)Delegate.Remove(privateNavigationCompleted, value); if (privateNavigationCompleted != null) { return; } try { _nativeICoreWebView2.remove_NavigationCompleted(_NavigationCompletedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2NavigationStartingEventArgs> NavigationStarting { add { if (privateNavigationStarting == null) { try { _nativeICoreWebView2.add_NavigationStarting(new CoreWebView2NavigationStartingEventHandler(OnNavigationStarting), out _NavigationStartingToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateNavigationStarting = (EventHandler<CoreWebView2NavigationStartingEventArgs>)Delegate.Combine(privateNavigationStarting, value); } remove { privateNavigationStarting = (EventHandler<CoreWebView2NavigationStartingEventArgs>)Delegate.Remove(privateNavigationStarting, value); if (privateNavigationStarting != null) { return; } try { _nativeICoreWebView2.remove_NavigationStarting(_NavigationStartingToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2NewWindowRequestedEventArgs> NewWindowRequested { add { if (privateNewWindowRequested == null) { try { _nativeICoreWebView2.add_NewWindowRequested(new CoreWebView2NewWindowRequestedEventHandler(OnNewWindowRequested), out _NewWindowRequestedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateNewWindowRequested = (EventHandler<CoreWebView2NewWindowRequestedEventArgs>)Delegate.Combine(privateNewWindowRequested, value); } remove { privateNewWindowRequested = (EventHandler<CoreWebView2NewWindowRequestedEventArgs>)Delegate.Remove(privateNewWindowRequested, value); if (privateNewWindowRequested != null) { return; } try { _nativeICoreWebView2.remove_NewWindowRequested(_NewWindowRequestedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2PermissionRequestedEventArgs> PermissionRequested { add { if (privatePermissionRequested == null) { try { _nativeICoreWebView2.add_PermissionRequested(new CoreWebView2PermissionRequestedEventHandler(OnPermissionRequested), out _PermissionRequestedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privatePermissionRequested = (EventHandler<CoreWebView2PermissionRequestedEventArgs>)Delegate.Combine(privatePermissionRequested, value); } remove { privatePermissionRequested = (EventHandler<CoreWebView2PermissionRequestedEventArgs>)Delegate.Remove(privatePermissionRequested, value); if (privatePermissionRequested != null) { return; } try { _nativeICoreWebView2.remove_PermissionRequested(_PermissionRequestedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2ProcessFailedEventArgs> ProcessFailed { add { if (privateProcessFailed == null) { try { _nativeICoreWebView2.add_ProcessFailed(new CoreWebView2ProcessFailedEventHandler(OnProcessFailed), out _ProcessFailedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateProcessFailed = (EventHandler<CoreWebView2ProcessFailedEventArgs>)Delegate.Combine(privateProcessFailed, value); } remove { privateProcessFailed = (EventHandler<CoreWebView2ProcessFailedEventArgs>)Delegate.Remove(privateProcessFailed, value); if (privateProcessFailed != null) { return; } try { _nativeICoreWebView2.remove_ProcessFailed(_ProcessFailedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2ScriptDialogOpeningEventArgs> ScriptDialogOpening { add { if (privateScriptDialogOpening == null) { try { _nativeICoreWebView2.add_ScriptDialogOpening(new CoreWebView2ScriptDialogOpeningEventHandler(OnScriptDialogOpening), out _ScriptDialogOpeningToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateScriptDialogOpening = (EventHandler<CoreWebView2ScriptDialogOpeningEventArgs>)Delegate.Combine(privateScriptDialogOpening, value); } remove { privateScriptDialogOpening = (EventHandler<CoreWebView2ScriptDialogOpeningEventArgs>)Delegate.Remove(privateScriptDialogOpening, value); if (privateScriptDialogOpening != null) { return; } try { _nativeICoreWebView2.remove_ScriptDialogOpening(_ScriptDialogOpeningToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2SourceChangedEventArgs> SourceChanged { add { if (privateSourceChanged == null) { try { _nativeICoreWebView2.add_SourceChanged(new CoreWebView2SourceChangedEventHandler(OnSourceChanged), out _SourceChangedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateSourceChanged = (EventHandler<CoreWebView2SourceChangedEventArgs>)Delegate.Combine(privateSourceChanged, value); } remove { privateSourceChanged = (EventHandler<CoreWebView2SourceChangedEventArgs>)Delegate.Remove(privateSourceChanged, value); if (privateSourceChanged != null) { return; } try { _nativeICoreWebView2.remove_SourceChanged(_SourceChangedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2WebMessageReceivedEventArgs> WebMessageReceived { add { if (privateWebMessageReceived == null) { try { _nativeICoreWebView2.add_WebMessageReceived(new CoreWebView2WebMessageReceivedEventHandler(OnWebMessageReceived), out _WebMessageReceivedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateWebMessageReceived = (EventHandler<CoreWebView2WebMessageReceivedEventArgs>)Delegate.Combine(privateWebMessageReceived, value); } remove { privateWebMessageReceived = (EventHandler<CoreWebView2WebMessageReceivedEventArgs>)Delegate.Remove(privateWebMessageReceived, value); if (privateWebMessageReceived != null) { return; } try { _nativeICoreWebView2.remove_WebMessageReceived(_WebMessageReceivedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2WebResourceRequestedEventArgs> WebResourceRequested { add { if (privateWebResourceRequested == null) { try { _nativeICoreWebView2.add_WebResourceRequested(new CoreWebView2WebResourceRequestedEventHandler(OnWebResourceRequested), out _WebResourceRequestedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateWebResourceRequested = (EventHandler<CoreWebView2WebResourceRequestedEventArgs>)Delegate.Combine(privateWebResourceRequested, value); } remove { privateWebResourceRequested = (EventHandler<CoreWebView2WebResourceRequestedEventArgs>)Delegate.Remove(privateWebResourceRequested, value); if (privateWebResourceRequested != null) { return; } try { _nativeICoreWebView2.remove_WebResourceRequested(_WebResourceRequestedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<object> WindowCloseRequested { add { if (privateWindowCloseRequested == null) { try { _nativeICoreWebView2.add_WindowCloseRequested(new CoreWebView2WindowCloseRequestedEventHandler(OnWindowCloseRequested), out _WindowCloseRequestedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } privateWindowCloseRequested = (EventHandler<object>)Delegate.Combine(privateWindowCloseRequested, value); } remove { privateWindowCloseRequested = (EventHandler<object>)Delegate.Remove(privateWindowCloseRequested, value); if (privateWindowCloseRequested != null) { return; } try { _nativeICoreWebView2.remove_WindowCloseRequested(_WindowCloseRequestedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw new InvalidOperationException("CoreWebView2 members cannot be accessed after the WebView2 control is disposed.", ex2); } throw ex2; } } } public event EventHandler<CoreWebView2BasicAuthenticationRequestedEventArgs> BasicAuthenticationRequested { add { if (privateBasicAuthenticationRequested == null) { try { _nativeICoreWebView2_10.add_BasicAuthenticationRequested(new CoreWebView2BasicAuthenticationRequestedEventHandler(OnBasicAuthenticationRequested), out _BasicAuthenticationRequestedToken); } catch (InvalidCastException ex) { if (ex.HResult == -2147467262) { throw new InvalidOperationException("CoreWebView2 members can only be accessed from the UI thread.", ex); } throw ex; } catch (COMException ex2) { if (ex2.HResult == -2147019873) { throw n
BepInEx/plugins/Microsoft.Web.WebView2.WinForms.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.Web.WebView2.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("Microsoft.Web.WebView2.WinForms.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001005dba207a79aa19b084a6b574c6f8945bd211921eaefa27a8031dd74b31af8094b3945f00288bc93f0751ecc62d3f5ca42681f09ed4ff1716aefc600bee20b042828dd897db022a07459a20a1042d0fcdd4a19610e838f5cfd992bcad1499861e24a28e5884452ce638803b5fac55a9967d92794723d2f4a0b49cc1148ae03dc7")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyConfiguration("Release Stable APIs")] [assembly: AssemblyCopyright("Copyright ©2020")] [assembly: AssemblyFileVersion("1.0.4258.31")] [assembly: AssemblyInformationalVersion("1.0.4258.31")] [assembly: AssemblyProduct("WebView2 Windows Forms Control")] [assembly: AssemblyTitle("Microsoft.Web.WebView2.WinForms")] [assembly: AssemblyVersion("1.0.4258.31")] namespace Microsoft.Web.WebView2.WinForms; public class CoreWebView2CreationProperties { private string _browserExecutableFolder; private string _userDataFolder; private string _language; private string _additionalBrowserArguments; private Task<CoreWebView2Environment> _task; public string BrowserExecutableFolder { get { return _browserExecutableFolder; } set { _browserExecutableFolder = value; _task = null; } } public string UserDataFolder { get { return _userDataFolder; } set { _userDataFolder = value; _task = null; } } public string Language { get { return _language; } set { _language = value; _task = null; } } public string ProfileName { get; set; } public string AdditionalBrowserArguments { get { return _additionalBrowserArguments; } set { _additionalBrowserArguments = value; _task = null; } } public bool? IsInPrivateModeEnabled { get; set; } internal Task<CoreWebView2Environment> CreateEnvironmentAsync() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown if (_task == null && (BrowserExecutableFolder != null || UserDataFolder != null || Language != null || AdditionalBrowserArguments != null)) { _task = CoreWebView2Environment.CreateAsync(BrowserExecutableFolder, UserDataFolder, new CoreWebView2EnvironmentOptions(AdditionalBrowserArguments, Language, (string)null, false, (List<CoreWebView2CustomSchemeRegistration>)null)); } return _task ?? Task.FromResult<CoreWebView2Environment>(null); } internal CoreWebView2ControllerOptions CreateCoreWebView2ControllerOptions(CoreWebView2Environment environment) { CoreWebView2ControllerOptions val = null; if (ProfileName != null || IsInPrivateModeEnabled.HasValue) { val = environment.CreateCoreWebView2ControllerOptions(); val.ProfileName = ProfileName; val.IsInPrivateModeEnabled = IsInPrivateModeEnabled == true; } return val; } } public class WebView2 : Control, ISupportInitialize { private static class NativeMethods { [Flags] public enum WS_EX : uint { None = 0u, TRANSPARENT = 0x20u } public enum WM : uint { PAINT = 15u } public struct Rect { public int left; public int top; public int right; public int bottom; } public struct PaintStruct { public IntPtr hdc; public bool fErase; public Rect rcPaint; public bool fRestore; public bool fIncUpdate; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] rgbReserved; } [DllImport("user32.dll", SetLastError = true)] public static extern IntPtr BeginPaint(IntPtr hwnd, out PaintStruct lpPaint); [DllImport("user32.dll", SetLastError = true)] public static extern bool EndPaint(IntPtr hwnd, ref PaintStruct lpPaint); } private const string _designText = "WebView2"; private const int _designBorderWidth = 2; private CoreWebView2CreationProperties _creationProperties; internal Task _initTask; private bool _browserHitTransparent; private bool _isExplicitEnvironment; private bool _isExplicitControllerOptions; private CoreWebView2MoveFocusReason _lastMoveFocusReason; private Form _parentForm; private CoreWebView2Controller _coreWebView2Controller; private double _zoomFactor = 1.0; private bool _allowExternalDrop = true; private bool _inInit; private Uri _source; private Color _defaultBackgroundColor = Color.White; private bool _browserCrashed; private IContainer components; [Browsable(false)] public CoreWebView2CreationProperties CreationProperties { get { return _creationProperties; } set { if (_initTask != null) { throw new InvalidOperationException("CreationProperties cannot be modified after the initialization of CoreWebView2 has begun."); } _creationProperties = value; } } private CoreWebView2Environment Environment { get; set; } private CoreWebView2ControllerOptions ControllerOptions { get; set; } protected override CreateParams CreateParams { get { CreateParams createParams = ((Control)this).CreateParams; createParams.ExStyle |= 0x20; return createParams; } } private bool IsInitialized { get; set; } private bool IsInDesignMode => GetSitedParentSite((Control)(object)this)?.DesignMode ?? false; public CoreWebView2 CoreWebView2 { get { try { CoreWebView2Controller coreWebView2Controller = _coreWebView2Controller; return (coreWebView2Controller != null) ? coreWebView2Controller.CoreWebView2 : null; } catch (Exception innerException) { if (((Control)this).InvokeRequired) { throw new InvalidOperationException("CoreWebView2 can only be accessed from the UI thread.", innerException); } throw; } } } public double ZoomFactor { get { if (_coreWebView2Controller != null) { return _coreWebView2Controller.ZoomFactor; } return _zoomFactor; } set { _zoomFactor = value; if (_coreWebView2Controller != null) { _coreWebView2Controller.ZoomFactor = value; } } } public bool AllowExternalDrop { get { if (_coreWebView2Controller != null) { return _coreWebView2Controller.AllowExternalDrop; } return _allowExternalDrop; } set { _allowExternalDrop = value; if (_coreWebView2Controller != null) { _coreWebView2Controller.AllowExternalDrop = value; } } } [Browsable(true)] public Uri Source { get { return _source; } set { if (value == null) { if (!(_source == null)) { throw new NotImplementedException("Setting Source to null is not implemented yet."); } return; } if (!value.IsAbsoluteUri) { throw new ArgumentException("Only absolute URI is allowed", "Source"); } if (IsInitialized && _source != null && _source.AbsoluteUri == value.AbsoluteUri) { return; } _source = value; if (!_inInit) { if (!IsInitialized) { EnsureCoreWebView2Async(); } else { CoreWebView2.Navigate(value.AbsoluteUri); } } } } [Browsable(false)] public bool CanGoForward { get { CoreWebView2 coreWebView = CoreWebView2; if (coreWebView == null) { return false; } return coreWebView.CanGoForward; } } [Browsable(false)] public bool CanGoBack { get { CoreWebView2 coreWebView = CoreWebView2; if (coreWebView == null) { return false; } return coreWebView.CanGoBack; } } public Color DefaultBackgroundColor { get { if (_coreWebView2Controller != null) { return _coreWebView2Controller.DefaultBackgroundColor; } return _defaultBackgroundColor; } set { if (_coreWebView2Controller != null) { _coreWebView2Controller.DefaultBackgroundColor = value; } else { _defaultBackgroundColor = value; } } } [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public Font Font => ((Control)this).Font; [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Text => ((Control)this).Text; [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public bool AllowDrop => ((Control)this).AllowDrop; [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public ContextMenuStrip ContextMenuStrip => ((Control)this).ContextMenuStrip; [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public ContextMenu ContextMenu => ((Control)this).ContextMenu; public event EventHandler<CoreWebView2InitializationCompletedEventArgs> CoreWebView2InitializationCompleted; public event EventHandler<CoreWebView2NavigationStartingEventArgs> NavigationStarting; public event EventHandler<CoreWebView2NavigationCompletedEventArgs> NavigationCompleted; public event EventHandler<CoreWebView2WebMessageReceivedEventArgs> WebMessageReceived; public event EventHandler<CoreWebView2SourceChangedEventArgs> SourceChanged; public event EventHandler<CoreWebView2ContentLoadingEventArgs> ContentLoading; public event EventHandler<EventArgs> ZoomFactorChanged; [ToolboxItem(true)] public WebView2() { InitializeComponent(); ((Control)this).SetStyle((ControlStyles)2, true); ((Control)this).SetStyle((ControlStyles)8192, true); } protected override void Dispose(bool disposing) { if (disposing && !((Control)this).IsDisposed) { if (IsInitialized) { UnsubscribeHandlersAndCloseController(); } if (components != null) { components.Dispose(); } ((Control)this).Dispose(disposing); } } private void UnsubscribeHandlersAndCloseController(bool browserCrashed = false) { IsInitialized = false; _browserCrashed = browserCrashed; ((Control)this).HandleDestroyed -= WebView2_HandleDestroyed; ((Control)this).HandleCreated -= WebView2_HandleCreated; if (_parentForm != null) { ((Control)_parentForm).LocationChanged -= WebView2_WindowPositionChanged; } if (!_browserCrashed) { CoreWebView2.NavigationCompleted -= CoreWebView2_NavigationCompleted; CoreWebView2.NavigationStarting -= CoreWebView2_NavigationStarting; CoreWebView2.SourceChanged -= CoreWebView2_SourceChanged; CoreWebView2.WebMessageReceived -= CoreWebView2_WebMessageReceived; CoreWebView2.ContentLoading -= CoreWebView2_ContentLoading; CoreWebView2.ProcessFailed -= CoreWebView2_ProcessFailed; try { CoreWebView2.Profile.Deleted -= Profile_Deleted; } catch (NotImplementedException) { } _coreWebView2Controller.ZoomFactorChanged -= _coreWebView2Controller_ZoomFactorChanged; _coreWebView2Controller.MoveFocusRequested -= CoreWebView2Controller_MoveFocusRequested; if (!_browserHitTransparent) { _coreWebView2Controller.AcceleratorKeyPressed -= _coreWebView2Controller_AcceleratorKeyPressed; } else { _coreWebView2Controller.KeyPressed -= _coreWebView2Controller_KeyPressed; } _coreWebView2Controller.Close(); } _coreWebView2Controller = null; } protected override void OnPaint(PaintEventArgs e) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown ((Control)this).OnPaint(e); if (IsInDesignMode) { e.Graphics.FillRectangle((Brush)new SolidBrush(((Control)this).BackColor), ((Control)this).ClientRectangle); e.Graphics.DrawRectangle(new Pen((Brush)new SolidBrush(((Control)this).ForeColor), 2f), ((Control)this).ClientRectangle); SizeF sizeF = e.Graphics.MeasureString("WebView2", Font); if (((Control)this).BackgroundImage != null) { e.Graphics.DrawImage(((Control)this).BackgroundImage, new Rectangle(Point.Empty, ((Control)this).ClientSize)); } e.Graphics.DrawString("WebView2", Font, (Brush)new SolidBrush(((Control)this).ForeColor), (float)(((Control)this).ClientSize.Width / 2) - sizeF.Width / 2f, (float)(((Control)this).ClientSize.Height / 2) - sizeF.Height / 2f); } } protected override void WndProc(ref Message m) { if (((Message)(ref m)).Msg == 15 && !IsInDesignMode) { NativeMethods.BeginPaint(((Message)(ref m)).HWnd, out var lpPaint); NativeMethods.EndPaint(((Message)(ref m)).HWnd, ref lpPaint); ((Message)(ref m)).Result = IntPtr.Zero; } else { ((Control)this).WndProc(ref m); } } public Task EnsureCoreWebView2Async(CoreWebView2Environment environment = null, CoreWebView2ControllerOptions controllerOptions = null) { if (IsInDesignMode) { return Task.FromResult(0); } VerifyNotClosedGuard(); VerifyBrowserNotCrashedGuard(); if (((Control)this).InvokeRequired) { throw new InvalidOperationException("The method EnsureCoreWebView2Async can be invoked only from the UI thread."); } if (_initTask == null || _initTask.IsFaulted) { _initTask = InitCoreWebView2Async(environment, controllerOptions); } else { if ((!_isExplicitEnvironment && environment != null) || (_isExplicitEnvironment && environment != null && Environment != environment)) { throw new ArgumentException("WebView2 was already initialized with a different CoreWebView2Environment. Check to see if the Source property was already set or EnsureCoreWebView2Async was previously called with different values."); } if ((!_isExplicitControllerOptions && controllerOptions != null) || (_isExplicitControllerOptions && controllerOptions != null && ControllerOptions != controllerOptions)) { throw new ArgumentException("WebView2 was already initialized with a different CoreWebView2ControllerOptions. Check to see if the Source property was already set or EnsureCoreWebView2Async was previously called with different values."); } } return _initTask; } public Task EnsureCoreWebView2Async(CoreWebView2Environment environment) { return EnsureCoreWebView2Async(environment, null); } private async Task InitCoreWebView2Async(CoreWebView2Environment environment = null, CoreWebView2ControllerOptions controllerOptions = null) { _ = 3; try { if (environment != null) { Environment = environment; _isExplicitEnvironment = true; } else if (CreationProperties != null) { Environment = await CreationProperties.CreateEnvironmentAsync(); } if (Environment == null) { Environment = await CoreWebView2Environment.CreateAsync((string)null, (string)null, (CoreWebView2EnvironmentOptions)null); } if (controllerOptions != null) { ControllerOptions = controllerOptions; _isExplicitControllerOptions = true; } else if (CreationProperties != null) { ControllerOptions = CreationProperties.CreateCoreWebView2ControllerOptions(Environment); } bool shouldSetBackgroundColor = _defaultBackgroundColor != Color.White; string backgroundColorEnvVar = null; if (shouldSetBackgroundColor) { backgroundColorEnvVar = System.Environment.GetEnvironmentVariable("WEBVIEW2_DEFAULT_BACKGROUND_COLOR"); System.Environment.SetEnvironmentVariable("WEBVIEW2_DEFAULT_BACKGROUND_COLOR", Color.FromArgb(DefaultBackgroundColor.ToArgb()).Name); } if (ControllerOptions != null) { _coreWebView2Controller = await Environment.CreateCoreWebView2ControllerAsync(((Control)this).Handle, ControllerOptions); } else { _coreWebView2Controller = await Environment.CreateCoreWebView2ControllerAsync(((Control)this).Handle); } if (shouldSetBackgroundColor) { System.Environment.SetEnvironmentVariable("WEBVIEW2_DEFAULT_BACKGROUND_COLOR", backgroundColorEnvVar); } try { _browserHitTransparent = _coreWebView2Controller.IsBrowserHitTransparent; } catch (NotImplementedException) { } _coreWebView2Controller.ZoomFactor = _zoomFactor; _coreWebView2Controller.DefaultBackgroundColor = _defaultBackgroundColor; _coreWebView2Controller.Bounds = new Rectangle(0, 0, ((Control)this).Width, ((Control)this).Height); _coreWebView2Controller.IsVisible = ((Control)this).Visible; try { _coreWebView2Controller.AllowExternalDrop = _allowExternalDrop; } catch (NotImplementedException) { } _coreWebView2Controller.MoveFocusRequested += CoreWebView2Controller_MoveFocusRequested; if (!_browserHitTransparent) { _coreWebView2Controller.AcceleratorKeyPressed += _coreWebView2Controller_AcceleratorKeyPressed; } else { _coreWebView2Controller.KeyPressed += _coreWebView2Controller_KeyPressed; } _coreWebView2Controller.ZoomFactorChanged += _coreWebView2Controller_ZoomFactorChanged; string environmentVariable = System.Environment.GetEnvironmentVariable("COREWEBVIEW2_FORCED_HOSTING_MODE"); if (environmentVariable != null && environmentVariable.Equals("COREWEBVIEW2_HOSTING_MODE_WINDOW_TO_VISUAL")) { _coreWebView2Controller.GotFocus += _coreWebView2Controller_GotFocus; _coreWebView2Controller.LostFocus += _coreWebView2Controller_LostFocus; } CoreWebView2.NavigationCompleted += CoreWebView2_NavigationCompleted; CoreWebView2.NavigationStarting += CoreWebView2_NavigationStarting; CoreWebView2.SourceChanged += CoreWebView2_SourceChanged; CoreWebView2.WebMessageReceived += CoreWebView2_WebMessageReceived; CoreWebView2.ContentLoading += CoreWebView2_ContentLoading; CoreWebView2.ProcessFailed += CoreWebView2_ProcessFailed; try { CoreWebView2.Profile.Deleted += Profile_Deleted; } catch (NotImplementedException) { } ((Control)this).HandleDestroyed += WebView2_HandleDestroyed; ((Control)this).HandleCreated += WebView2_HandleCreated; if (((Control)this).Focused) { _coreWebView2Controller.MoveFocus((CoreWebView2MoveFocusReason)0); } bool num = _source != null; if (_source == null) { _source = new Uri(CoreWebView2.Source); } IsInitialized = true; this.CoreWebView2InitializationCompleted?.Invoke(this, new CoreWebView2InitializationCompletedEventArgs((Exception)null)); if (num) { CoreWebView2.Navigate(_source.AbsoluteUri); } } catch (Exception ex4) { this.CoreWebView2InitializationCompleted?.Invoke(this, new CoreWebView2InitializationCompletedEventArgs(ex4)); throw; } } private void Profile_Deleted(object sender, object e) { UnsubscribeHandlersAndCloseController(); } private void WebView2_HandleCreated(object sender, EventArgs e) { _coreWebView2Controller.ParentWindow = ((Control)this).Handle; _coreWebView2Controller.IsVisible = ((Control)this).Visible; } private void WebView2_HandleDestroyed(object sender, EventArgs e) { _coreWebView2Controller.IsVisible = false; _coreWebView2Controller.ParentWindow = IntPtr.Zero; } private void WebView2_WindowPositionChanged(object sender, EventArgs e) { CoreWebView2Controller coreWebView2Controller = _coreWebView2Controller; if (coreWebView2Controller != null) { coreWebView2Controller.NotifyParentWindowPositionChanged(); } } private void _coreWebView2Controller_KeyPressed(object sender, CoreWebView2PrivateKeyPressedEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected I4, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown CoreWebView2KeyEventKind keyEventKind = e.KeyEventKind; switch ((int)keyEventKind) { case 0: case 2: { KeyEventArgs e3 = new KeyEventArgs((Keys)(e.VirtualKey | Control.ModifierKeys)); ((Control)this).OnKeyDown(e3); e.Handled = e3.Handled; break; } case 1: case 3: { KeyEventArgs e2 = new KeyEventArgs((Keys)(e.VirtualKey | Control.ModifierKeys)); ((Control)this).OnKeyUp(e2); e.Handled = e2.Handled; break; } } } private void _coreWebView2Controller_AcceleratorKeyPressed(object sender, CoreWebView2AcceleratorKeyPressedEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected I4, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown CoreWebView2KeyEventKind keyEventKind = e.KeyEventKind; switch ((int)keyEventKind) { case 0: case 2: { KeyEventArgs e3 = new KeyEventArgs((Keys)(e.VirtualKey | Control.ModifierKeys)); ((Control)this).OnKeyDown(e3); e.Handled = e3.Handled; break; } case 1: case 3: { KeyEventArgs e2 = new KeyEventArgs((Keys)(e.VirtualKey | Control.ModifierKeys)); ((Control)this).OnKeyUp(e2); e.Handled = e2.Handled; break; } } } private void CoreWebView2Controller_MoveFocusRequested(object sender, CoreWebView2MoveFocusRequestedEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) bool flag = (int)e.Reason == 1 || (int)e.Reason == 0; Control val = (Control)(((object)((Control)this).FindForm()) ?? ((object)((Control)this).Parent)); Control val2 = (Control)(object)((val.GetNextControl((Control)(object)this, flag) == ((Control)this).Parent && !flag) ? ((WebView2)(object)((Control)this).Parent) : this); e.Handled = val == null || val.SelectNextControl(val2, flag, true, true, true); if ((int)_lastMoveFocusReason != 0) { _coreWebView2Controller.MoveFocus(_lastMoveFocusReason); _lastMoveFocusReason = (CoreWebView2MoveFocusReason)0; } } protected override void OnVisibleChanged(EventArgs e) { ((Control)this).OnVisibleChanged(e); if (IsInitialized && !_browserCrashed) { _coreWebView2Controller.IsVisible = ((Control)this).Visible; } } protected override void OnSizeChanged(EventArgs e) { ((Control)this).OnSizeChanged(e); if (IsInitialized && !_browserCrashed) { _coreWebView2Controller.Bounds = new Rectangle(0, 0, ((Control)this).Width, ((Control)this).Height); } } protected override void Select(bool directed, bool forward) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (directed) { _lastMoveFocusReason = (CoreWebView2MoveFocusReason)(forward ? 1 : 2); } ((Control)this).Select(directed, forward); } protected override bool ProcessDialogKey(Keys keyData) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 if ((keyData & 0x60000) == 0) { Keys val = (Keys)(keyData & 0xFFFF); if ((int)val == 9 || val - 37 <= 3) { return false; } } return ((Control)this).ProcessDialogKey(keyData); } protected override void OnGotFocus(EventArgs e) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) ((Control)this).OnGotFocus(e); if (IsInitialized && !_browserCrashed) { try { _coreWebView2Controller.MoveFocus(_lastMoveFocusReason); } catch (InvalidOperationException ex) { if (ex.InnerException.HResult != -2147019873) { throw ex; } } } _lastMoveFocusReason = (CoreWebView2MoveFocusReason)0; } protected override void OnParentChanged(EventArgs e) { ((Control)this).OnParentChanged(e); Form val = ((Control)this).FindForm(); if (val != null && val != _parentForm) { ((Control)val).LocationChanged += WebView2_WindowPositionChanged; if (_parentForm != null) { ((Control)_parentForm).LocationChanged -= WebView2_WindowPositionChanged; } _parentForm = val; } } private ISite GetSitedParentSite(Control control) { if (control != null) { if (((Component)(object)control).Site == null && control.Parent != null) { return GetSitedParentSite(control.Parent); } return ((Component)(object)control).Site; } throw new ArgumentNullException("control"); } void ISupportInitialize.BeginInit() { _inInit = true; } void ISupportInitialize.EndInit() { _inInit = false; if (!(_source == null)) { if (!IsInitialized) { EnsureCoreWebView2Async(); } else { CoreWebView2.Navigate(_source.AbsoluteUri); } } } private bool ShouldSerializeSource() { return (_source?.AbsoluteUri?.Length).GetValueOrDefault() > 0; } private void ResetSource() { _source = null; } public async Task<string> ExecuteScriptAsync(string script) { VerifyInitializedGuard(); VerifyBrowserNotCrashedGuard(); return await CoreWebView2.ExecuteScriptAsync(script); } public void Reload() { VerifyInitializedGuard(); VerifyBrowserNotCrashedGuard(); CoreWebView2.Reload(); } public void GoForward() { CoreWebView2 coreWebView = CoreWebView2; if (coreWebView != null) { coreWebView.GoForward(); } } public void GoBack() { CoreWebView2 coreWebView = CoreWebView2; if (coreWebView != null) { coreWebView.GoBack(); } } public void NavigateToString(string htmlContent) { VerifyInitializedGuard(); VerifyBrowserNotCrashedGuard(); CoreWebView2.NavigateToString(htmlContent); } public void Stop() { CoreWebView2 coreWebView = CoreWebView2; if (coreWebView != null) { coreWebView.Stop(); } } private void VerifyInitializedGuard() { if (!IsInitialized) { throw new InvalidOperationException("The instance of CoreWebView2 is uninitialized and unable to complete this operation. See EnsureCoreWebView2Async."); } } private void VerifyNotClosedGuard() { if (((Control)this).IsDisposed) { throw new InvalidOperationException("The instance of CoreWebView2 is disposed and unable to complete this operation."); } } private void VerifyBrowserNotCrashedGuard() { if (_browserCrashed) { throw new InvalidOperationException("The instance of CoreWebView2 is no longer valid because the browser process crashed.To work around this, please listen for the ProcessFailed event to explicitly manage the lifetime of the WebView2 control in the event of a browser failure.https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.processfailed"); } } private void CoreWebView2_NavigationStarting(object sender, CoreWebView2NavigationStartingEventArgs e) { this.NavigationStarting?.Invoke(this, e); } private void CoreWebView2_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e) { this.NavigationCompleted?.Invoke(this, e); } private void CoreWebView2_WebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e) { this.WebMessageReceived?.Invoke(this, e); } private void CoreWebView2_SourceChanged(object sender, CoreWebView2SourceChangedEventArgs e) { _source = new Uri(CoreWebView2.Source); this.SourceChanged?.Invoke(this, e); } private void CoreWebView2_ContentLoading(object sender, CoreWebView2ContentLoadingEventArgs e) { this.ContentLoading?.Invoke(this, e); } private void CoreWebView2_ProcessFailed(object sender, CoreWebView2ProcessFailedEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)e.ProcessFailedKind == 0) { UnsubscribeHandlersAndCloseController(browserCrashed: true); } } private void _coreWebView2Controller_ZoomFactorChanged(object sender, object e) { _zoomFactor = _coreWebView2Controller.ZoomFactor; this.ZoomFactorChanged?.Invoke(this, EventArgs.Empty); } private void _coreWebView2Controller_GotFocus(object sender, object e) { ((Control)this).OnGotFocus(new EventArgs()); } private void _coreWebView2Controller_LostFocus(object sender, object e) { ((Control)this).OnLostFocus(new EventArgs()); } private void InitializeComponent() { this.components = new System.ComponentModel.Container(); } }
BepInEx/plugins/OnTogetherSchoolScreen.dll
Decompiled 2 hours agousing System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Pipes; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Threading; using System.Threading.Tasks; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using PurrNet; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("OnTogetherSchoolScreen")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+afcc261f7a7232e03fcc9be2b4299922b9fd567e")] [assembly: AssemblyProduct("OnTogetherSchoolScreen")] [assembly: AssemblyTitle("OnTogetherSchoolScreen")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace OnTogetherSchoolScreen { internal static class BoardPacketEnvelope { internal const bool IsErase = true; internal const bool IsBigErase = false; internal const int MaximumFirstGroup = 16777215; internal static float EncodeFirstGroup(float value) { if (float.IsNaN(value) || float.IsInfinity(value) || value < 0f || value > 16777215f || (double)value != Math.Truncate(value)) { throw new ArgumentOutOfRangeException("value", "A board payload group must be an unsigned 24-bit integer."); } return 0f - value - 1f; } internal static float DecodeFirstGroup(float value) { if (!(value < 0f)) { return value; } return 0f - value - 1f; } } internal sealed class PlaybackSession { private bool _hasPlayed; public int LoadId { get; private set; } public string VideoId { get; private set; } = ""; public bool HasEnded { get; private set; } public int Begin(string videoId) { LoadId = ((LoadId == int.MaxValue) ? 1 : (LoadId + 1)); VideoId = videoId ?? ""; _hasPlayed = false; HasEnded = false; return LoadId; } public void Clear() { Begin(""); } public void Resume() { if (HasEnded) { _hasPlayed = false; HasEnded = false; } } public bool Observe(string videoId, int loadId, int state) { if (string.IsNullOrEmpty(VideoId) || loadId != LoadId || !string.Equals(videoId, VideoId, StringComparison.Ordinal)) { return false; } if (state == 1) { _hasPlayed = true; HasEnded = false; } if (state == 0 && _hasPlayed) { HasEnded = true; } return true; } public bool ShouldAdvance(bool controlsPlayback, bool startRequested, bool hasQueuedVideos) { if (!controlsPlayback) { return false; } if (!string.IsNullOrEmpty(VideoId)) { return HasEnded; } return startRequested && hasQueuedVideos; } } [BepInPlugin("codex.ontogether.school-screen", "On-Together School Screen", "0.1.11")] public sealed class SchoolScreenPlugin : BaseUnityPlugin { private sealed class LobbyMember { public string Name; public int PeerToken; } private sealed class QueueEntry { public string VideoId; public string Title; public string AddedBy; } private const float BoardCommandMarker = 2f; private const float LegacyBoardCommandMarker = -2f; private const float PeerTokenScale = 1048576f; private const int PeerTokenMask = 1048575; private const int QueueEventSequenceMask = 1048575; private const float NearBoardDistance = 3f; private const float SilentDistance = 18f; private const string HostMemberKey = "__local_host__"; private static SchoolScreenPlugin _instance; private readonly ConcurrentQueue<string> _networkQueue = new ConcurrentQueue<string>(); private readonly ConcurrentQueue<string> _browserQueue = new ConcurrentQueue<string>(); private readonly Dictionary<string, LobbyMember> _moddedPlayers = new Dictionary<string, LobbyMember>(); private readonly HashSet<string> _blockedQueuePlayers = new HashSet<string>(); private readonly HashSet<int> _peerSkipVotes = new HashSet<int>(); private readonly Dictionary<int, float> _peerLastSeen = new Dictionary<int, float>(); private readonly Dictionary<int, string> _peerPlayerKeys = new Dictionary<int, string>(); private readonly HashSet<long> _processedQueueEvents = new HashSet<long>(); private readonly HashSet<long> _processedPlaybackEvents = new HashSet<long>(); private readonly PlaybackSession _playbackSession = new PlaybackSession(); private readonly HashSet<string> _queueTitleLookups = new HashSet<string>(StringComparer.Ordinal); private readonly Dictionary<string, string> _queueTitleCache = new Dictionary<string, string>(StringComparer.Ordinal); private readonly List<QueueEntry> _videoQueue = new List<QueueEntry>(); private readonly object _pipeWriteLock = new object(); private Harmony _harmony; private NamedPipeServerStream _pipe; private Process _browser; private Texture2D _videoTexture; private byte[] _pendingJpeg; private QuadPainterGPU _schoolBoard; private Renderer _schoolRenderer; private Material _schoolMaterial; private bool _panelOpen; private bool _guiInitialized; private volatile bool _pipeConnected; private bool _host; private bool _lobbyIdentityInitialized; private bool _lobbyStateObserved; private bool _observedLobbyActive; private string _observedLobbyCode; private string _status = "Looking for the school whiteboard…"; private string _url = ""; private string _videoId = ""; private Rect _windowRect; private bool _windowPositioned; private GUIStyle _windowStyle; private GUIStyle _titleStyle; private GUIStyle _subtitleStyle; private GUIStyle _sectionStyle; private GUIStyle _statusStyle; private GUIStyle _hintStyle; private GUIStyle _inputStyle; private GUIStyle _placeholderStyle; private GUIStyle _primaryButtonStyle; private GUIStyle _controlButtonStyle; private GUIStyle _seekButtonStyle; private GUIStyle _hostBadgeStyle; private GUIStyle _viewerBadgeStyle; private GUIStyle _closeButtonStyle; private GUIStyle _volumeSliderStyle; private GUIStyle _volumeThumbStyle; private Texture2D _windowTexture; private Texture2D _fieldTexture; private Texture2D _buttonTexture; private Texture2D _buttonHoverTexture; private Texture2D _accentTexture; private Texture2D _accentHoverTexture; private Texture2D _badgeTexture; private Texture2D _statusTexture; private Texture2D _meterBackgroundTexture; private float _videoTime; private int _playerState = -1; private float _nextSync; private float _lastFrameTime; private float _nextVolumeUpdate; private float _maximumVolume = 100f; private int _effectiveVolume; private int _lastSentVolume = -1; private bool _muted; private int _activeTab; private bool _localVotedSkip; private float _nextLobbyHeartbeat; private int _reportedModCount; private int _voteCount; private int _votesRequired; private int _localPeerToken; private int _queueEventSequence; private int _playbackControllerToken; private int _moddedHostPeerToken; private bool _queueStartRequested; private float _nextQueueStartAt; private int _playerVolume; private Vector2 _queueScroll; private Vector2 _accessScroll; private string _videoTitle = ""; private string _queueStatus = ""; private string _pipeName; private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown _instance = this; _localPeerToken = CreatePeerToken(); _harmony = new Harmony("codex.ontogether.school-screen"); bool num = TryPatch(AccessTools.Method(typeof(QuadPainterGPU), "LateUpdate", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(SchoolScreenPlugin), "AfterBoardUpdate", (Type[])null)); bool flag = TryPatch(AccessTools.Method(typeof(QuadPainterGPU), "FillTheBlanksRPC_Original_2", (Type[])null, (Type[])null), new HarmonyMethod(typeof(SchoolScreenPlugin), "ReceiveBoardCommand", (Type[])null)); if (num && flag) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Installed school screen board handlers."); } _videoTexture = new Texture2D(2, 2, (TextureFormat)4, false, false) { filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; _status = "Find the whiteboard in the school building."; ((BaseUnityPlugin)this).Logger.LogInfo((object)"On-Together School Screen loaded."); } private bool TryPatch(MethodBase original, HarmonyMethod prefix = null, HarmonyMethod postfix = null) { if (original == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find a game method required by the school screen mod; skipping that patch."); return false; } try { _harmony.Patch(original, prefix, postfix, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Skipped incompatible patch for " + original.DeclaringType.FullName + "." + original.Name + ": " + ex.GetBaseException().Message)); return false; } } private void Update() { if (Input.GetKeyDown((KeyCode)290)) { _panelOpen = !_panelOpen; } UpdateHostState(); if (_lobbyStateObserved && !_observedLobbyActive) { return; } FindSchoolBoard(); PumpQueues(); UpdateLobbyPresence(); UpdateQueuePlayback(); if (Time.unscaledTime >= _nextVolumeUpdate) { _nextVolumeUpdate = Time.unscaledTime + 0.25f; UpdateLocalVolume(force: false); } if (_pendingJpeg != null && Time.unscaledTime - _lastFrameTime >= 1f / 30f) { byte[] array = Interlocked.Exchange(ref _pendingJpeg, null); if (array != null && ImageConversion.LoadImage(_videoTexture, array, false)) { _lastFrameTime = Time.unscaledTime; ApplyTexture(); } } if ((Object)(object)_schoolBoard != (Object)null && !string.IsNullOrEmpty(_videoId) && IsLocalPlaybackCoordinator() && Time.unscaledTime >= _nextSync) { _nextSync = Time.unscaledTime + 10f; SendBoardCommand("SYNC", _videoId, _videoTime, _playerState); } } private void FindSchoolBoard() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_schoolRenderer != (Object)null && (Object)(object)((Component)_schoolRenderer).gameObject != (Object)null) { return; } QuadPainterGPU[] array = Resources.FindObjectsOfTypeAll<QuadPainterGPU>(); foreach (QuadPainterGPU val in array) { if ((Object)(object)val == (Object)null) { continue; } Scene scene = ((Component)val).gameObject.scene; if (!((Scene)(ref scene)).IsValid() || !((Component)val).gameObject.activeInHierarchy || !string.Equals(((Object)((Component)val).gameObject).name, "DrawingBoard", StringComparison.Ordinal)) { continue; } Transform val2 = ((Component)val).transform; bool flag = false; while ((Object)(object)val2 != (Object)null) { if (((Object)val2).name == "MD_SchoolInterior") { flag = true; break; } val2 = val2.parent; } if (flag) { _schoolBoard = val; _schoolRenderer = ((Component)val).GetComponent<Renderer>(); if (!((Object)(object)_schoolRenderer == (Object)null)) { _schoolMaterial = _schoolRenderer.material; _status = "School whiteboard found. Press F9 to open controls."; StartBrowser(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Attached to the DrawingBoard inside MD_SchoolInterior."); break; } } } } private void StartBrowser() { if (_browser != null || _pipe != null) { return; } string directoryName = Path.GetDirectoryName(typeof(SchoolScreenPlugin).Assembly.Location); string text = Path.Combine(directoryName, "SchoolScreenBrowser.exe"); if (!File.Exists(text)) { _status = "Browser helper is missing beside the plugin."; return; } _pipeName = "OTSchoolScreen_" + Guid.NewGuid().ToString("N"); _pipe = new NamedPipeServerStream(_pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 65536, 65536); Task.Run(delegate { PipeWorker(_pipe); }); try { _browser = Process.Start(new ProcessStartInfo(text, _pipeName) { UseShellExecute = false, CreateNoWindow = true, WorkingDirectory = directoryName }); _status = "Starting local browser…"; } catch (Exception ex) { _status = "Could not start browser: " + ex.Message; } } private void PipeWorker(NamedPipeServerStream pipe) { try { pipe.WaitForConnection(); _pipeConnected = true; _browserQueue.Enqueue("STATUS|WebView2 connected"); using BinaryReader binaryReader = new BinaryReader(pipe, Encoding.UTF8, leaveOpen: true); while (pipe.IsConnected) { byte b = binaryReader.ReadByte(); int num = binaryReader.ReadInt32(); if (num >= 0 && num <= 4194304) { byte[] array = binaryReader.ReadBytes(num); if (array.Length == num) { switch (b) { case 70: Interlocked.Exchange(ref _pendingJpeg, array); break; case 83: _browserQueue.Enqueue(Encoding.UTF8.GetString(array)); break; case 69: _browserQueue.Enqueue("ERROR|" + Encoding.UTF8.GetString(array)); break; } continue; } break; } break; } } catch (Exception ex) { _browserQueue.Enqueue("ERROR|" + ex.GetBaseException().Message); } finally { _pipeConnected = false; } } private void PumpQueues() { string result; while (_networkQueue.TryDequeue(out result)) { HandleNetworkCommand(result); } while (_browserQueue.TryDequeue(out result)) { HandleBrowserMessage(result); } } private void HandleBrowserMessage(string message) { if (message.StartsWith("ERROR|", StringComparison.Ordinal)) { _status = "WebView2 error: " + message.Substring(6); ((BaseUnityPlugin)this).Logger.LogError((object)_status); } else if (message.StartsWith("STATUS|", StringComparison.Ordinal)) { _status = message.Substring(7); if (!_pipeConnected) { return; } if (!string.IsNullOrEmpty(_videoId)) { OpenBrowserVideo(); if (_playerState == 2) { SendHelper("PAUSE"); } } UpdateLocalVolume(force: true); RequestTitlesForQueue(); } else if (message.StartsWith("STATE|", StringComparison.Ordinal)) { string[] array = message.Split('|'); if (array.Length < 6 || !float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || !int.TryParse(array[2], out var result2) || !int.TryParse(array[5], out var result3) || !_playbackSession.Observe(array[4], result3, result2)) { return; } _videoTime = result; _playerState = result2; if (array.Length >= 4) { _videoTitle = array[3].Trim(); if (!string.IsNullOrWhiteSpace(_videoTitle) && IsVideoId(_videoId)) { _queueTitleCache[_videoId] = _videoTitle; UpdateQueuedVideoTitle(_videoId, _videoTitle); } } } else { if (!message.StartsWith("TITLE|", StringComparison.Ordinal)) { return; } string[] array2 = message.Split('|'); if (array2.Length >= 3 && IsVideoId(array2[1])) { string text = array2[2].Trim(); if (!string.IsNullOrWhiteSpace(text)) { _queueTitleCache[array2[1]] = text; UpdateQueuedVideoTitle(array2[1], text); } } } } private void UpdateQueuedVideoTitle(string videoId, string title) { for (int i = 0; i < _videoQueue.Count; i++) { if (string.Equals(_videoQueue[i].VideoId, videoId, StringComparison.Ordinal)) { _videoQueue[i].Title = title; } } } private void RequestQueueTitle(string videoId) { if (_pipeConnected && IsVideoId(videoId) && !_queueTitleCache.ContainsKey(videoId) && _queueTitleLookups.Add(videoId)) { SendHelper("LOOKUP\t" + videoId); } } private void RequestTitlesForQueue() { for (int i = 0; i < _videoQueue.Count; i++) { RequestQueueTitle(_videoQueue[i].VideoId); } } private void UpdateHostState() { TextChannelManager val = null; bool flag = false; try { val = NetworkSingleton<TextChannelManager>.I; if ((Object)(object)val != (Object)null) { flag = ReadIsServer(val); } } catch { } string text = null; bool? flag2 = null; try { MultiplayerManager i = MonoSingleton<MultiplayerManager>.I; if ((Object)(object)i != (Object)null) { flag2 = i.LobbyStatus; text = i.LobbyCode ?? ""; } } catch { } bool flag3 = false; if (flag2.HasValue) { if (_lobbyStateObserved && _observedLobbyActive && !flag2.Value) { ResetLobbyState(); flag3 = true; } _observedLobbyActive = flag2.Value; _lobbyStateObserved = true; } if (text != null) { if (!flag3 && _lobbyIdentityInitialized && !string.Equals(_observedLobbyCode, text, StringComparison.Ordinal)) { ResetLobbyState(); } _observedLobbyCode = text; _lobbyIdentityInitialized = true; } _host = (Object)(object)val != (Object)null && flag && flag2 != false; if (_host) { _moddedHostPeerToken = _localPeerToken; } else if (_moddedHostPeerToken == _localPeerToken) { _moddedHostPeerToken = 0; } } private void ResetLobbyState() { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) SendHelper("CLEAR"); SendHelper("RESET_LOOKUPS"); Interlocked.Exchange(ref _pendingJpeg, null); _videoId = ""; _videoTitle = ""; _videoTime = 0f; _playerState = -1; _playbackSession.Clear(); _queueStartRequested = false; _nextQueueStartAt = 0f; _videoQueue.Clear(); _peerSkipVotes.Clear(); _peerLastSeen.Clear(); _peerPlayerKeys.Clear(); _processedQueueEvents.Clear(); _processedPlaybackEvents.Clear(); _moddedPlayers.Clear(); _blockedQueuePlayers.Clear(); _queueTitleLookups.Clear(); _localVotedSkip = false; _reportedModCount = 0; _voteCount = 0; _votesRequired = 0; _localPeerToken = CreatePeerToken(); _queueEventSequence = 0; _playbackControllerToken = 0; _moddedHostPeerToken = 0; _queueStatus = ""; _activeTab = 0; _queueScroll = Vector2.zero; _accessScroll = Vector2.zero; _peerLastSeen[_localPeerToken] = Time.unscaledTime; _nextSync = 0f; _nextLobbyHeartbeat = 0f; _schoolBoard = null; _schoolRenderer = null; _schoolMaterial = null; string result; while (_networkQueue.TryDequeue(out result)) { } _status = "Lobby changed. Previous video and queue cleared."; } private void UpdateLobbyPresence() { if ((Object)(object)_schoolBoard == (Object)null || Time.unscaledTime < _nextLobbyHeartbeat) { return; } _nextLobbyHeartbeat = Time.unscaledTime + 5f; BroadcastPeerPresence(); PruneStalePeers(); if (_host) { bool num = _moddedPlayers.ContainsKey("__local_host__"); EnsureHostMember(); if (!num) { BroadcastVoteStatus(); } } } private void EnsureHostMember() { if (!_moddedPlayers.TryGetValue("__local_host__", out var value)) { value = new LobbyMember(); _moddedPlayers.Add("__local_host__", value); } value.Name = GetLocalPlayerName(); value.PeerToken = _localPeerToken; _peerPlayerKeys[_localPeerToken] = "__local_host__"; _moddedHostPeerToken = _localPeerToken; } private void PruneStalePeers() { List<int> list = new List<int>(); foreach (KeyValuePair<int, float> item in _peerLastSeen) { if (item.Key != _localPeerToken && Time.unscaledTime - item.Value > 20f) { list.Add(item.Key); } } if (list.Count == 0) { return; } for (int i = 0; i < list.Count; i++) { _peerLastSeen.Remove(list[i]); _peerSkipVotes.Remove(list[i]); if (_peerPlayerKeys.TryGetValue(list[i], out var value)) { _peerPlayerKeys.Remove(list[i]); if (!_peerPlayerKeys.ContainsValue(value)) { _moddedPlayers.Remove(value); } } } if (!_peerLastSeen.ContainsKey(_playbackControllerToken)) { _playbackControllerToken = GetLowestActivePeerToken(); } if (!_peerLastSeen.ContainsKey(_moddedHostPeerToken)) { _moddedHostPeerToken = 0; } BroadcastVoteStatus(includeSnapshot: true); if (!string.IsNullOrEmpty(_videoId) && GetActiveVoteCount() >= GetRequiredVotes() && IsLocalPlaybackCoordinator()) { SkipCurrentVideo(); } } private string GetLocalPlayerName() { try { TextChannelManager i = NetworkSingleton<TextChannelManager>.I; if ((Object)(object)i != (Object)null && !string.IsNullOrWhiteSpace(i.UserName)) { return i.UserName.Trim(); } } catch { } return "Player"; } private static int CreatePeerToken() { int num = BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0) & 0xFFFFF; if (num != 0) { return num; } return 1; } private static float EncodeBoardMarker(int peerToken) { int num = peerToken & 0xFFFFF; return 2f + (float)num / 1048576f; } private static bool TryDecodeBoardMarker(float value, out int peerToken) { peerToken = 0; if (float.IsNaN(value) || float.IsInfinity(value)) { return false; } float num = ((value >= 2f) ? (value - 2f) : (-2f - value)); if (num < 0f || num > 0.99999905f) { peerToken = 0; return false; } peerToken = Mathf.Clamp(Mathf.RoundToInt(num * 1048576f), 0, 1048575); return true; } private int GetActivePeerCount() { int num = 1; foreach (KeyValuePair<int, float> item in _peerLastSeen) { if (item.Key != _localPeerToken && item.Value >= Time.unscaledTime - 20f) { num++; } } return num; } private int GetActiveVoteCount() { int num = 0; foreach (int peerSkipVote in _peerSkipVotes) { if (peerSkipVote == _localPeerToken || (_peerLastSeen.TryGetValue(peerSkipVote, out var value) && value >= Time.unscaledTime - 20f)) { num++; } } return num; } private int GetLowestActivePeerToken() { int num = _localPeerToken; foreach (KeyValuePair<int, float> item in _peerLastSeen) { if (item.Value >= Time.unscaledTime - 20f && item.Key < num) { num = item.Key; } } return num; } private void BroadcastPeerPresence() { if (!((Object)(object)_schoolBoard == (Object)null)) { _peerLastSeen[_localPeerToken] = Time.unscaledTime; SendPeerPacket(11, "PEER|" + _localPeerToken); } } private void SendPeerPacket(int packetType, string localMessage) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_schoolBoard == (Object)null)) { Vector2 uv = default(Vector2); ((Vector2)(ref uv))..ctor(EncodeBoardMarker(_localPeerToken), (float)packetType); SendBoardPayload(uv, Vector2.zero, 0); if (!string.IsNullOrEmpty(localMessage)) { HandleNetworkCommand(localMessage); } } } private static bool ReadIsServer(object instance) { Type type = instance.GetType(); while (type != null) { PropertyInfo property = type.GetProperty("isServer", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.PropertyType == typeof(bool)) { return (bool)property.GetValue(instance, null); } FieldInfo field = type.GetField("isServer", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.FieldType == typeof(bool)) { return (bool)field.GetValue(instance); } type = type.BaseType; } return false; } private void UpdateLocalVolume(bool force) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) float num = 0f; try { TextChannelManager i = NetworkSingleton<TextChannelManager>.I; if ((Object)(object)_schoolBoard != (Object)null && (Object)(object)i != (Object)null && (Object)(object)i.MainPlayer != (Object)null) { float num2 = Vector3.Distance(((Component)_schoolBoard).transform.position, i.MainPlayer.position); if (num2 <= 3f) { num = 1f; } else if (num2 < 18f) { num = Mathf.Pow(1f - (num2 - 3f) / 15f, 0.65f); } } } catch { num = 0f; } _effectiveVolume = ((!_muted) ? Mathf.Clamp(Mathf.RoundToInt(_maximumVolume * num), 0, 200) : 0); int num3 = (_playerVolume = Mathf.Clamp(_effectiveVolume, 0, 100)); if (force || _lastSentVolume < 0 || Math.Abs(num3 - _lastSentVolume) >= 2 || num3 == 0 != (_lastSentVolume == 0)) { _lastSentVolume = num3; SendHelper("VOLUME\t" + num3); } } private void ApplyTexture() { if (!((Object)(object)_schoolMaterial == (Object)null)) { if (_schoolMaterial.HasProperty("_MainTex")) { _schoolMaterial.SetTexture("_MainTex", (Texture)(object)_videoTexture); } else { _schoolMaterial.mainTexture = (Texture)(object)_videoTexture; } } } private void OnGUI() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (_panelOpen) { if (!_guiInitialized) { CreateGuiStyles(); _guiInitialized = true; } if (!_windowPositioned) { _windowRect = new Rect(24f, 86f, 456f, 478f); _windowPositioned = true; } _windowRect = GUI.Window(61429, _windowRect, new WindowFunction(DrawControlPanel), GUIContent.none, _windowStyle); } } private void DrawControlPanel(int windowId) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) GUI.DrawTexture(new Rect(0f, 0f, 456f, 3f), (Texture)(object)_accentTexture); GUI.Label(new Rect(20f, 12f, 310f, 26f), "Study screen", _titleStyle); GUI.Label(new Rect(20f, 37f, 310f, 16f), "SCHOOL WHITEBOARD · YOUTUBE", _subtitleStyle); GUI.Box(new Rect(344f, 18f, 72f, 24f), _host ? "HOST" : "VIEWER", _host ? _hostBadgeStyle : _viewerBadgeStyle); if (GUI.Button(new Rect(422f, 17f, 22f, 24f), "X", _closeButtonStyle)) { _panelOpen = false; } GUI.DrawTexture(new Rect(18f, 61f, 420f, 1f), (Texture)(object)_badgeTexture); float num = 134.66667f; if (GUI.Button(new Rect(20f, 69f, num, 27f), "SCREEN", (_activeTab == 0) ? _primaryButtonStyle : _controlButtonStyle)) { _activeTab = 0; } if (GUI.Button(new Rect(20f + num + 6f, 69f, num, 27f), "QUEUE", (_activeTab == 1) ? _primaryButtonStyle : _controlButtonStyle)) { _activeTab = 1; } if (GUI.Button(new Rect(20f + (num + 6f) * 2f, 69f, num, 27f), "ACCESS", (_activeTab == 2) ? _primaryButtonStyle : _controlButtonStyle)) { _activeTab = 2; } if (_activeTab == 0) { DrawScreenTab(); } else if (_activeTab == 1) { DrawQueueTab(); } else { DrawAccessTab(); } GUI.DragWindow(new Rect(0f, 0f, 336f, 60f)); } private void DrawScreenTab() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) bool flag = _status.StartsWith("WebView2 error", StringComparison.Ordinal) || _status.StartsWith("Could not start", StringComparison.Ordinal); string text = (flag ? _status : (((Object)(object)_schoolRenderer == (Object)null) ? "Whiteboard not found yet" : ((!_pipeConnected) ? "Starting video player…" : (string.IsNullOrEmpty(_videoId) ? "Ready to play a video" : (string.IsNullOrWhiteSpace(_videoTitle) ? "Loading video title…" : ("Now playing · " + ShortTitle(_videoTitle, 45))))))); GUI.DrawTexture(new Rect(21f, 111f, 8f, 8f), (Texture)(object)(flag ? _statusTexture : (_pipeConnected ? _accentTexture : _buttonHoverTexture))); GUI.Label(new Rect(37f, 102f, 400f, 25f), text, _statusStyle); GUI.Label(new Rect(20f, 132f, 420f, 18f), "YOUTUBE VIDEO", _sectionStyle); Rect val = default(Rect); ((Rect)(ref val))..ctor(20f, 153f, 416f, 36f); _url = GUI.TextField(val, _url, _inputStyle); if (string.IsNullOrEmpty(_url)) { GUI.Label(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 8f, ((Rect)(ref val)).width - 20f, 20f), "Paste a YouTube link or video ID", _placeholderStyle); } bool flag2 = !string.IsNullOrEmpty(_videoId) || _videoQueue.Count > 0; bool enabled = GUI.enabled; GUI.enabled = (Object)(object)_schoolBoard != (Object)null; if (GUI.Button(new Rect(20f, 197f, 416f, 38f), flag2 ? "ADD TO QUEUE" : "PLAY ON THE BOARD", _primaryButtonStyle)) { if (flag2) { AddVideoToQueue(); _activeTab = 1; } else { ShareVideo(); } } GUI.Label(new Rect(20f, 243f, 416f, 16f), "PLAYBACK", _sectionStyle); GUI.enabled = !string.IsNullOrEmpty(_videoId); float num = 134.66667f; if (GUI.Button(new Rect(20f, 262f, num, 33f), "Play", _controlButtonStyle)) { Control("PLAY"); } if (GUI.Button(new Rect(20f + num + 6f, 262f, num, 33f), "Pause", _controlButtonStyle)) { Control("PAUSE"); } GUI.enabled = _host && !string.IsNullOrEmpty(_videoId); if (GUI.Button(new Rect(20f + 2f * (num + 6f), 262f, num, 33f), "Stop", _controlButtonStyle)) { Control("CLEAR"); } if (GUI.Button(new Rect(20f, 302f, 205f, 30f), "−15 sec", _seekButtonStyle)) { Seek(-15f); } if (GUI.Button(new Rect(231f, 302f, 205f, 30f), "+15 sec", _seekButtonStyle)) { Seek(15f); } GUI.enabled = enabled; GUI.DrawTexture(new Rect(18f, 343f, 420f, 1f), (Texture)(object)_badgeTexture); GUI.Label(new Rect(20f, 350f, 300f, 18f), "VOLUME", _sectionStyle); GUI.Label(new Rect(326f, 350f, 110f, 18f), Mathf.RoundToInt(_maximumVolume) + "%", _hintStyle); float maximumVolume = _maximumVolume; _maximumVolume = GUI.HorizontalSlider(new Rect(20f, 376f, 300f, 18f), _maximumVolume, 0f, 200f, _volumeSliderStyle, _volumeThumbStyle); if (Mathf.Abs(maximumVolume - _maximumVolume) > 0.1f) { UpdateLocalVolume(force: true); } GUI.Label(new Rect(0f, 392f, 60f, 15f), "0%", _hintStyle); GUI.Label(new Rect(140f, 392f, 60f, 15f), "100%", _hintStyle); GUI.Label(new Rect(280f, 392f, 60f, 15f), "200%", _hintStyle); GUI.DrawTexture(new Rect(20f, 409f, 300f, 9f), (Texture)(object)_meterBackgroundTexture); GUI.DrawTexture(new Rect(20f, 409f, 300f * ((float)_playerVolume / 100f), 9f), (Texture)(object)_accentTexture); GUI.Label(new Rect(20f, 421f, 300f, 17f), (_playerVolume == 0) ? "Silent" : ("Current volume · " + _playerVolume + "%"), _hintStyle); if (GUI.Button(new Rect(340f, 372f, 96f, 42f), _muted ? "UNMUTE" : "MUTE", _controlButtonStyle)) { _muted = !_muted; UpdateLocalVolume(force: true); } } private void DrawQueueTab() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(20f, 103f, 416f, 20f), "ADD A VIDEO TO THE QUEUE", _sectionStyle); Rect val = default(Rect); ((Rect)(ref val))..ctor(20f, 128f, 296f, 36f); _url = GUI.TextField(val, _url, _inputStyle); if (string.IsNullOrEmpty(_url)) { GUI.Label(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 8f, ((Rect)(ref val)).width - 20f, 20f), "Paste a YouTube link or video ID", _placeholderStyle); } if (GUI.Button(new Rect(324f, 128f, 112f, 36f), "ADD VIDEO", _primaryButtonStyle)) { AddVideoToQueue(); } GUI.Label(new Rect(20f, 169f, 416f, 18f), _queueStatus, _hintStyle); GUI.Label(new Rect(20f, 196f, 210f, 18f), "UP NEXT · " + _videoQueue.Count, _sectionStyle); if (!string.IsNullOrEmpty(_videoId)) { string text = (_host ? "Host can skip now" : (_voteCount + "/" + _votesRequired + " votes · " + _reportedModCount + " modded players")); GUI.Label(new Rect(218f, 196f, 218f, 18f), text, _hintStyle); if (_host) { if (GUI.Button(new Rect(20f, 219f, 196f, 34f), "SKIP NOW", _primaryButtonStyle)) { SkipCurrentVideo(); } } else { string text2 = (_localVotedSkip ? "REMOVE MY VOTE" : "VOTE TO SKIP"); if (GUI.Button(new Rect(20f, 219f, 196f, 34f), text2, _controlButtonStyle)) { ToggleSkipVote(); } } } else if (_videoQueue.Count > 0) { if (GUI.Button(new Rect(20f, 219f, 196f, 34f), "PLAY NEXT", _primaryButtonStyle)) { RequestQueueStart(); } } else { GUI.Label(new Rect(20f, 219f, 416f, 34f), "Add a video to start watching.", _hintStyle); } GUI.DrawTexture(new Rect(18f, 262f, 420f, 1f), (Texture)(object)_badgeTexture); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(20f, 271f, 416f, 178f); float num = Mathf.Max(((Rect)(ref val2)).height, (float)_videoQueue.Count * 38f); _queueScroll = GUI.BeginScrollView(val2, _queueScroll, new Rect(0f, 0f, ((Rect)(ref val2)).width - 18f, num)); for (int i = 0; i < _videoQueue.Count; i++) { QueueEntry queueEntry = _videoQueue[i]; float num2 = (float)i * 38f; string value = (string.IsNullOrWhiteSpace(queueEntry.Title) ? queueEntry.VideoId : queueEntry.Title); GUI.Label(new Rect(2f, num2 + 6f, (float)(_host ? 220 : 391), 24f), i + 1 + ". " + ShortTitle(value, _host ? 26 : 52), _statusStyle); if (_host) { if (GUI.Button(new Rect(229f, num2 + 2f, 88f, 30f), "PLAY", _controlButtonStyle)) { PlayQueuedVideo(i); } if (GUI.Button(new Rect(323f, num2 + 2f, 68f, 30f), "REMOVE", _seekButtonStyle)) { RemoveQueuedVideo(i); } } } GUI.EndScrollView(); GUI.Label(new Rect(20f, 451f, 416f, 16f), _host ? "You can skip any time or play a queued video." : "Videos play in order. Vote to skip the current video.", _hintStyle); } private void DrawAccessTab() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) if (!_host) { GUI.Label(new Rect(20f, 110f, 416f, 40f), "Queue blocking is available when the game host has the mod installed.", _statusStyle); return; } GUI.Label(new Rect(20f, 105f, 416f, 20f), "QUEUE ACCESS", _sectionStyle); GUI.Label(new Rect(20f, 127f, 416f, 30f), "Block players here if they abuse the queue.", _hintStyle); Rect val = default(Rect); ((Rect)(ref val))..ctor(20f, 164f, 416f, 284f); float num = Mathf.Max(((Rect)(ref val)).height, (float)_moddedPlayers.Count * 42f); _accessScroll = GUI.BeginScrollView(val, _accessScroll, new Rect(0f, 0f, ((Rect)(ref val)).width - 18f, num)); List<string> list = new List<string>(_moddedPlayers.Keys); list.Sort(StringComparer.Ordinal); for (int i = 0; i < list.Count; i++) { string text = list[i]; LobbyMember lobbyMember = _moddedPlayers[text]; float num2 = (float)i * 42f; string text2 = ((text == "__local_host__") ? (lobbyMember.Name + " (you)") : lobbyMember.Name); GUI.Label(new Rect(2f, num2 + 7f, 258f, 25f), text2, _statusStyle); if (!(text != "__local_host__")) { continue; } bool flag = _blockedQueuePlayers.Contains(text); if (GUI.Button(new Rect(267f, num2 + 2f, 120f, 32f), flag ? "ALLOW QUEUE" : "BLOCK QUEUE", flag ? _seekButtonStyle : _controlButtonStyle)) { if (flag) { _blockedQueuePlayers.Remove(text); } else { _blockedQueuePlayers.Add(text); } } } GUI.EndScrollView(); } private void CreateGuiStyles() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown //IL_0165: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Expected O, but got Unknown //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Expected O, but got Unknown //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Expected O, but got Unknown //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Expected O, but got Unknown _windowTexture = MakeGuiTexture(Color32.op_Implicit(new Color32((byte)24, (byte)29, (byte)43, (byte)247))); _fieldTexture = MakeGuiTexture(Color32.op_Implicit(new Color32((byte)16, (byte)20, (byte)31, byte.MaxValue))); _buttonTexture = MakeGuiTexture(Color32.op_Implicit(new Color32((byte)39, (byte)47, (byte)65, byte.MaxValue))); _buttonHoverTexture = MakeGuiTexture(Color32.op_Implicit(new Color32((byte)54, (byte)64, (byte)86, byte.MaxValue))); _accentTexture = MakeGuiTexture(Color32.op_Implicit(new Color32((byte)133, (byte)119, byte.MaxValue, byte.MaxValue))); _accentHoverTexture = MakeGuiTexture(Color32.op_Implicit(new Color32((byte)153, (byte)141, byte.MaxValue, byte.MaxValue))); _badgeTexture = MakeGuiTexture(Color32.op_Implicit(new Color32((byte)54, (byte)64, (byte)85, byte.MaxValue))); _statusTexture = MakeGuiTexture(Color32.op_Implicit(new Color32((byte)240, (byte)105, (byte)112, byte.MaxValue))); _meterBackgroundTexture = MakeGuiTexture(Color32.op_Implicit(new Color32((byte)10, (byte)13, (byte)21, byte.MaxValue))); _windowStyle = new GUIStyle(GUI.skin.window) { padding = new RectOffset(0, 0, 0, 0), border = new RectOffset(1, 1, 1, 1) }; _windowStyle.normal.background = _windowTexture; _windowStyle.onNormal.background = _windowTexture; _windowStyle.normal.textColor = Color.white; _titleStyle = MakeLabelStyle(19, (FontStyle)1, Color32.op_Implicit(new Color32((byte)244, (byte)246, byte.MaxValue, byte.MaxValue)), (TextAnchor)3); _subtitleStyle = MakeLabelStyle(10, (FontStyle)1, Color32.op_Implicit(new Color32((byte)151, (byte)163, (byte)188, byte.MaxValue)), (TextAnchor)3); _sectionStyle = MakeLabelStyle(10, (FontStyle)1, Color32.op_Implicit(new Color32((byte)164, (byte)177, (byte)204, byte.MaxValue)), (TextAnchor)3); _statusStyle = MakeLabelStyle(12, (FontStyle)0, Color32.op_Implicit(new Color32((byte)221, (byte)227, (byte)241, byte.MaxValue)), (TextAnchor)3); _hintStyle = MakeLabelStyle(10, (FontStyle)0, Color32.op_Implicit(new Color32((byte)157, (byte)169, (byte)193, byte.MaxValue)), (TextAnchor)4); GUIStyle val = new GUIStyle(GUI.skin.textField) { fontSize = 13, alignment = (TextAnchor)3, padding = new RectOffset(10, 10, 4, 4) }; val.normal.background = _fieldTexture; val.normal.textColor = Color32.op_Implicit(new Color32((byte)242, (byte)245, byte.MaxValue, byte.MaxValue)); val.focused.background = _fieldTexture; val.focused.textColor = Color.white; _inputStyle = val; _placeholderStyle = MakeLabelStyle(12, (FontStyle)0, Color32.op_Implicit(new Color32((byte)117, (byte)129, (byte)152, byte.MaxValue)), (TextAnchor)3); _primaryButtonStyle = MakeButtonStyle(13, (FontStyle)1, _accentTexture, _accentHoverTexture, Color.white); _controlButtonStyle = MakeButtonStyle(13, (FontStyle)1, _buttonTexture, _buttonHoverTexture, Color32.op_Implicit(new Color32((byte)239, (byte)243, byte.MaxValue, byte.MaxValue))); _seekButtonStyle = MakeButtonStyle(12, (FontStyle)0, _buttonTexture, _buttonHoverTexture, Color32.op_Implicit(new Color32((byte)207, (byte)216, (byte)235, byte.MaxValue))); _hostBadgeStyle = MakeButtonStyle(10, (FontStyle)1, _accentTexture, _accentHoverTexture, Color.white); _viewerBadgeStyle = MakeButtonStyle(10, (FontStyle)1, _badgeTexture, _buttonHoverTexture, Color32.op_Implicit(new Color32((byte)206, (byte)216, (byte)237, byte.MaxValue))); _closeButtonStyle = MakeButtonStyle(11, (FontStyle)1, _windowTexture, _buttonHoverTexture, Color32.op_Implicit(new Color32((byte)175, (byte)185, (byte)205, byte.MaxValue))); _volumeSliderStyle = new GUIStyle(GUI.skin.horizontalSlider); _volumeSliderStyle.normal.background = _buttonTexture; _volumeSliderStyle.hover.background = _buttonHoverTexture; _volumeThumbStyle = new GUIStyle(GUI.skin.horizontalSliderThumb) { fixedWidth = 14f, fixedHeight = 14f }; _volumeThumbStyle.normal.background = _accentTexture; _volumeThumbStyle.hover.background = _accentHoverTexture; } private static GUIStyle MakeLabelStyle(int size, FontStyle fontStyle, Color color, TextAnchor alignment) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = size, fontStyle = fontStyle }; val.normal.textColor = color; val.alignment = alignment; return val; } private static GUIStyle MakeButtonStyle(int size, FontStyle fontStyle, Texture2D normal, Texture2D hover, Color color) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.button) { fontSize = size, fontStyle = fontStyle, alignment = (TextAnchor)4, padding = new RectOffset(8, 8, 4, 4), border = new RectOffset(3, 3, 3, 3) }; val.normal.background = normal; val.normal.textColor = color; val.hover.background = hover; val.hover.textColor = Color.white; val.active.background = hover; val.active.textColor = Color.white; val.focused.background = normal; val.focused.textColor = color; return val; } private static Texture2D MakeGuiTexture(Color color) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false) { hideFlags = (HideFlags)61, filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1 }; val.SetPixel(0, 0, color); val.Apply(); return val; } private void ShareVideo() { if (string.IsNullOrEmpty(ParseVideoId(_url))) { _status = "Paste a YouTube URL or an 11-character video ID."; } else if ((Object)(object)_schoolBoard == (Object)null) { _status = "The school whiteboard is not ready yet."; } else { AddVideoToQueue(); } } private void Control(string command) { if (command == "CLEAR") { if (_host) { _localVotedSkip = false; SendBoardCommand("CLEAR"); BroadcastVoteStatus(); } } else { SendBoardCommand(command); } } private void Seek(float amount) { if (_host) { SendBoardCommand("SEEK", null, Mathf.Max(0f, _videoTime + amount)); } } private void AddVideoToQueue() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) string text = ParseVideoId(_url); if (string.IsNullOrEmpty(text)) { _queueStatus = "Enter a valid YouTube link or video ID."; return; } if ((Object)(object)_schoolBoard == (Object)null) { _queueStatus = "The school whiteboard is not ready yet."; return; } int num = NextQueueEventSequence(); int num2 = (num << 4) | 0xA; Vector2 uv = default(Vector2); ((Vector2)(ref uv))..ctor(EncodeBoardMarker(_localPeerToken), (float)num2); Vector2 prevUV = default(Vector2); ((Vector2)(ref prevUV))..ctor((float)PackVideoIdGroup(text, 0, 4), (float)PackVideoIdGroup(text, 4, 4)); SendBoardPayload(uv, prevUV, PackVideoIdGroup(text, 8, 3)); HandleNetworkCommand("QUEUE_ADD|" + _localPeerToken + "|" + num + "|" + text); _queueStatus = "Added to the queue."; _url = ""; } private void ToggleSkipVote() { if (_host) { SkipCurrentVideo(); return; } bool flag = !_localVotedSkip; SendPeerPacket(flag ? 12 : 13, (flag ? "VOTE|" : "UNVOTE|") + _localPeerToken); } private void SkipCurrentVideo() { if ((_host || IsLocalPlaybackCoordinator()) && !string.IsNullOrEmpty(_videoId)) { AdvanceQueue(); } } private bool IsLocalPlaybackCoordinator() { if (_host) { return true; } if (IsActivePeerToken(_moddedHostPeerToken)) { return _moddedHostPeerToken == _localPeerToken; } return (IsActivePeerToken(_playbackControllerToken) ? _playbackControllerToken : GetLowestActivePeerToken()) == _localPeerToken; } private bool IsActivePeerToken(int peerToken) { if (peerToken == _localPeerToken) { return true; } if (peerToken > 0 && _peerLastSeen.TryGetValue(peerToken, out var value)) { return value >= Time.unscaledTime - 20f; } return false; } private bool CanAcceptQueueSnapshot(int peerToken) { if (peerToken <= 0 || peerToken > 1048575) { return false; } if (_host) { return peerToken == _localPeerToken; } if (IsActivePeerToken(_moddedHostPeerToken)) { return peerToken == _moddedHostPeerToken; } if (IsActivePeerToken(_playbackControllerToken)) { return peerToken == _playbackControllerToken; } if (_playbackControllerToken != 0) { return peerToken == GetLowestActivePeerToken(); } return true; } private bool CanAcceptPlaybackCommand(int peerToken, bool synchronization = false) { if (peerToken <= 0 || peerToken > 1048575) { return false; } if (_host) { return peerToken == _localPeerToken; } if (IsActivePeerToken(_moddedHostPeerToken)) { return peerToken == _moddedHostPeerToken; } if (IsActivePeerToken(_playbackControllerToken)) { return peerToken == _playbackControllerToken; } if (_playbackControllerToken != 0) { return peerToken == GetLowestActivePeerToken(); } if (!synchronization) { return peerToken == GetLowestActivePeerToken(); } return true; } private void UpdateQueuePlayback() { if (!((Object)(object)_schoolBoard == (Object)null) && (!string.IsNullOrEmpty(_videoId) || !(Time.unscaledTime < _nextQueueStartAt)) && _playbackSession.ShouldAdvance(IsLocalPlaybackCoordinator(), _queueStartRequested, _videoQueue.Count > 0)) { AdvanceQueue(); } } private void RequestQueueStart() { if (string.IsNullOrEmpty(_videoId) && _videoQueue.Count != 0) { SendPeerPacket(0, "QUEUE_START|" + _localPeerToken); } } private void ScheduleQueueStart() { if (string.IsNullOrEmpty(_videoId)) { _queueStartRequested = true; _nextQueueStartAt = Time.unscaledTime + 0.75f; } } private void AdvanceQueue() { if (_host || IsLocalPlaybackCoordinator()) { _queueStartRequested = false; _localVotedSkip = false; if (_videoQueue.Count > 0) { QueueEntry queueEntry = _videoQueue[0]; _videoQueue.RemoveAt(0); BroadcastQueueSnapshot(); SendBoardCommand("OPEN", queueEntry.VideoId); } else { SendBoardCommand("CLEAR"); } BroadcastVoteStatus(); } } private void PlayQueuedVideo(int index) { if (_host && index >= 0 && index < _videoQueue.Count && !((Object)(object)_schoolBoard == (Object)null)) { QueueEntry queueEntry = _videoQueue[index]; _videoQueue.RemoveAt(index); BroadcastQueueSnapshot(); SendBoardCommand("OPEN", queueEntry.VideoId); _activeTab = 0; } } private void RemoveQueuedVideo(int index) { if (_host && index >= 0 && index < _videoQueue.Count) { _videoQueue.RemoveAt(index); BroadcastQueueSnapshot(); } } private void BroadcastQueueSnapshot() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_schoolBoard == (Object)null)) { SendBoardPayload(new Vector2(EncodeBoardMarker(_localPeerToken), 7f), Vector2.zero, 0); for (int i = 0; i < _videoQueue.Count; i++) { string videoId = _videoQueue[i].VideoId; int num = PackVideoIdGroup(videoId, 0, 4); int num2 = PackVideoIdGroup(videoId, 4, 4); int colIndex = PackVideoIdGroup(videoId, 8, 3); int num3 = (i << 4) | 8; SendBoardPayload(new Vector2(EncodeBoardMarker(_localPeerToken), (float)num3), new Vector2((float)num, (float)num2), colIndex); } } } private void BroadcastVoteStatus(bool includeSnapshot = false, bool transferIdleState = false) { //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) _reportedModCount = GetActivePeerCount(); _voteCount = GetActiveVoteCount(); _votesRequired = GetRequiredVotes(); if (!(IsLocalPlaybackCoordinator() || transferIdleState) || !((Object)(object)_schoolBoard != (Object)null)) { return; } float num = EncodeBoardMarker(_localPeerToken); if (includeSnapshot) { SendBoardPayload(new Vector2(num, 25f), Vector2.zero, 0); foreach (KeyValuePair<int, float> item in _peerLastSeen) { if (item.Value >= Time.unscaledTime - 20f) { SendBoardPayload(new Vector2(num, 57f), new Vector2((float)item.Key, 0f), 0); } } foreach (int peerSkipVote in _peerSkipVotes) { if (peerSkipVote == _localPeerToken || (_peerLastSeen.TryGetValue(peerSkipVote, out var value) && value >= Time.unscaledTime - 20f)) { SendBoardPayload(new Vector2(num, 41f), new Vector2((float)peerSkipVote, 0f), 0); } } } SendBoardPayload(new Vector2(num, 9f), new Vector2((float)_reportedModCount, (float)_voteCount), _votesRequired); } private int GetRequiredVotes() { return Math.Max(1, (int)Math.Ceiling((double)GetActivePeerCount() * 0.3)); } private void SendBoardPayload(Vector2 uv, Vector2 prevUV, int colIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (uv.y == 0f) { uv.y = 16f; } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(BoardPacketEnvelope.EncodeFirstGroup(prevUV.x), prevUV.y); try { _schoolBoard.FillTheBlanksRPC(uv, val, colIndex, true, false, default(RPCInfo)); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not send lobby update: " + ex.GetBaseException().Message)); } } private static string ShortTitle(string value, int maxLength) { if (string.IsNullOrEmpty(value) || value.Length <= maxLength) { return value ?? ""; } return value.Substring(0, Math.Max(1, maxLength - 1)) + "…"; } private void SendHelper(string command) { if (_pipe == null || !_pipeConnected) { return; } byte[] bytes = Encoding.UTF8.GetBytes(command + "\n"); try { lock (_pipeWriteLock) { _pipe.Write(bytes, 0, bytes.Length); _pipe.Flush(); } } catch (Exception ex) { _status = "Browser command failed: " + ex.Message; } } private void OpenBrowserVideo() { int num = _playbackSession.Begin(_videoId); SendHelper("OPEN\t" + _videoId + "\t" + _videoTime.ToString("0.0", CultureInfo.InvariantCulture) + "\t" + num); } private int NextQueueEventSequence() { _queueEventSequence = (_queueEventSequence + 1) & 0xFFFFF; if (_queueEventSequence == 0) { _queueEventSequence = 1; } return _queueEventSequence; } private bool AcceptPlaybackEvent(int peerToken, int sequence) { if (peerToken <= 0 || peerToken > 1048575 || sequence <= 0 || sequence > 1048575) { return false; } return _processedPlaybackEvents.Add(((long)peerToken << 20) | (uint)sequence); } private void SendBoardCommand(string command, string videoId = null, float seconds = 0f, int state = 1) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_schoolBoard == (Object)null) { return; } int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; Vector2 zero = Vector2.zero; int num5; int num6; switch (command) { default: return; case "OPEN": if (!IsVideoId(videoId)) { return; } num = NextQueueEventSequence(); num5 = 1; num2 = PackVideoIdGroup(videoId, 0, 4); num3 = PackVideoIdGroup(videoId, 4, 4); num4 = PackVideoIdGroup(videoId, 8, 3); ((Vector2)(ref zero))..ctor((float)num2, (float)num3); goto IL_015b; case "PLAY": num5 = 2; goto IL_015b; case "PAUSE": num5 = 3; goto IL_015b; case "SEEK": num5 = 4; num4 = Mathf.Clamp(Mathf.RoundToInt(Mathf.Max(0f, seconds) * 10f), 0, 16777215); goto IL_015b; case "CLEAR": num5 = 5; num = NextQueueEventSequence(); goto IL_015b; case "SYNC": { if (!IsVideoId(videoId)) { return; } num5 = 6; num6 = (Mathf.Clamp(Mathf.RoundToInt(Mathf.Max(0f, seconds) * 10f), 0, 1048575) << 4) | num5 | ((state == 2) ? 8 : 0); num2 = PackVideoIdGroup(videoId, 0, 4); num3 = PackVideoIdGroup(videoId, 4, 4); num4 = PackVideoIdGroup(videoId, 8, 3); ((Vector2)(ref zero))..ctor((float)num2, (float)num3); break; } IL_015b: num6 = (num << 4) | num5; if (command != "SEEK" && command != "OPEN") { num4 = 0; } break; } Vector2 uv = default(Vector2); ((Vector2)(ref uv))..ctor(EncodeBoardMarker(_localPeerToken), (float)num6); HandleNetworkCommand(num5 switch { 1 => "OPEN|" + videoId + "|0|" + _localPeerToken + "|" + num, 2 => "PLAY|" + _localPeerToken, 3 => "PAUSE|" + _localPeerToken, 4 => "SEEK|" + ((float)num4 / 10f).ToString("0.0", CultureInfo.InvariantCulture) + "|" + _localPeerToken, 5 => "CLEAR|" + _localPeerToken + "|" + num, _ => "SYNC|" + videoId + "|" + ((float)(num6 >> 4) / 10f).ToString("0.0", CultureInfo.InvariantCulture) + "|" + (((num6 & 8) != 0) ? "2" : "1") + "|" + _localPeerToken, }); SendBoardPayload(uv, zero, num4); } private void HandleNetworkCommand(string message) { string[] array = message.Split('|'); if (array.Length == 0) { return; } string text = array[0]; switch (text) { case "QUEUE_REMOVE": return; case "OPEN": if (array.Length >= 5) { if (IsVideoId(array[1]) && int.TryParse(array[3], out var result) && CanAcceptPlaybackCommand(result) && int.TryParse(array[4], out var result2) && AcceptPlaybackEvent(result, result2)) { _peerLastSeen[result] = Time.unscaledTime; _videoId = array[1]; _videoTitle = ""; _videoTime = ParseFloat(array[2]); _playerState = 1; _playbackControllerToken = result; _queueStartRequested = false; _nextSync = Time.unscaledTime + 10f; _localVotedSkip = false; _peerSkipVotes.Clear(); OpenBrowserVideo(); UpdateLocalVolume(force: true); BroadcastVoteStatus(); } return; } break; } switch (text) { case "PLAY": case "PAUSE": if (!string.IsNullOrEmpty(_videoId)) { if (text == "PLAY") { _playbackSession.Resume(); } _playerState = ((text == "PLAY") ? 1 : 2); SendHelper(text); } return; case "SEEK": if (array.Length >= 2) { if (array.Length >= 3 && int.TryParse(array[2], out var result3) && CanAcceptPlaybackCommand(result3)) { _playbackSession.Resume(); _videoTime = ParseFloat(array[1]); SendHelper("SEEK\t" + _videoTime.ToString("0.0", CultureInfo.InvariantCulture)); } return; } break; } int result19; if (text == "CLEAR" && array.Length >= 3) { if (int.TryParse(array[1], out var result4) && CanAcceptPlaybackCommand(result4) && int.TryParse(array[2], out var result5) && AcceptPlaybackEvent(result4, result5)) { _videoId = ""; _videoTitle = ""; _playerState = -1; _videoTime = 0f; _playbackControllerToken = 0; _queueStartRequested = false; _playbackSession.Clear(); _localVotedSkip = false; _peerSkipVotes.Clear(); SendHelper("CLEAR"); BroadcastVoteStatus(); } } else if (text == "SYNC" && array.Length >= 4) { string text2 = array[1]; float num = ParseFloat(array[2]); int.TryParse(array[3], out var result6); int result7 = 0; if (array.Length >= 5) { int.TryParse(array[4], out result7); } if (IsVideoId(text2) && CanAcceptPlaybackCommand(result7, synchronization: true)) { _peerLastSeen[result7] = Time.unscaledTime; float videoTime = _videoTime; int playerState = _playerState; if (result7 != 0) { _playbackControllerToken = result7; } _playerState = result6; if (_videoId != text2) { _videoId = text2; _videoTitle = ""; _localVotedSkip = false; _peerSkipVotes.Clear(); _videoTime = num; _queueStartRequested = false; OpenBrowserVideo(); } else if (Math.Abs(videoTime - num) > 1.5f || _playbackSession.HasEnded) { _playbackSession.Resume(); _videoTime = num; SendHelper("SEEK\t" + num.ToString("0.0", CultureInfo.InvariantCulture)); } if (result6 == 2 && playerState != 2) { SendHelper("PAUSE"); } else if (result6 == 1 && playerState != 1) { SendHelper("PLAY"); } UpdateLocalVolume(force: true); } } else if (text == "PEER" && array.Length >= 2) { if (int.TryParse(array[1], out var result8)) { HandlePeerPresence(result8); } } else if (text == "QUEUE_START" && array.Length >= 2) { if (int.TryParse(array[1], out var result9) && result9 > 0 && result9 <= 1048575) { _peerLastSeen[result9] = Time.unscaledTime; if (_videoQueue.Count > 0) { ScheduleQueueStart(); } } } else if ((text == "VOTE" || text == "UNVOTE") && array.Length >= 2) { if (int.TryParse(array[1], out var result10)) { ApplyPeerVote(result10, text == "VOTE"); } } else if (text == "QUEUE_ADD" && array.Length >= 4) { if (int.TryParse(array[1], out var result11) && int.TryParse(array[2], out var result12)) { ApplyQueueAdd(result11, result12, array[3]); } } else if (text == "QUEUE_CLEAR") { if (array.Length >= 2 && int.TryParse(array[1], out var result13) && result13 != _localPeerToken && CanAcceptQueueSnapshot(result13)) { _videoQueue.Clear(); } } else if (text == "QUEUE_ITEM" && array.Length >= 3) { if (!int.TryParse(array[1], out var result14) || result14 < 0 || result14 >= 30 || !IsVideoId(array[2]) || array.Length < 4 || !int.TryParse(array[3], out var result15) || result15 == _localPeerToken || !CanAcceptQueueSnapshot(result15)) { return; } _queueTitleCache.TryGetValue(array[2], out var value); QueueEntry queueEntry = new QueueEntry { VideoId = array[2], Title = (string.IsNullOrWhiteSpace(value) ? array[2] : value), AddedBy = "" }; if (result14 < _videoQueue.Count) { _videoQueue[result14] = queueEntry; } else { if (result14 != _videoQueue.Count) { return; } _videoQueue.Add(queueEntry); } RequestQueueTitle(queueEntry.VideoId); if (string.IsNullOrEmpty(_videoId)) { ScheduleQueueStart(); } } else if (text == "VOTE_RESET" && array.Length >= 2) { if (int.TryParse(array[1], out var result16) && CanAcceptQueueSnapshot(result16)) { _peerSkipVotes.Clear(); _localVotedSkip = false; } } else if ((text == "VOTE_ENTRY" || text == "PEER_STATE") && array.Length >= 3) { if (!int.TryParse(array[1], out var result17) || !CanAcceptQueueSnapshot(result17) || !int.TryParse(array[2], out var result18) || result18 <= 0 || result18 > 1048575) { return; } _peerLastSeen[result18] = Time.unscaledTime; if (text == "VOTE_ENTRY") { _peerSkipVotes.Add(result18); if (result18 == _localPeerToken) { _localVotedSkip = true; } } } else if (text == "VOTE_STATUS" && array.Length >= 5 && int.TryParse(array[4], out result19) && CanAcceptQueueSnapshot(result19)) { int.TryParse(array[1], out _reportedModCount); int.TryParse(array[2], out _voteCount); int.TryParse(array[3], out _votesRequired); } } private void HandlePeerPresence(int peerToken) { if (peerToken > 0 && peerToken <= 1048575) { bool flag = !_peerLastSeen.ContainsKey(peerToken); int lowestActivePeerToken = GetLowestActivePeerToken(); _peerLastSeen[peerToken] = Time.unscaledTime; if (flag && peerToken != _localPeerToken && IsLocalPlaybackCoordinator() && !string.IsNullOrEmpty(_videoId) && !_playbackSession.HasEnded) { SendBoardCommand("SYNC", _videoId, _videoTime, _playerState); } bool flag2 = _host || (!IsActivePeerToken(_moddedHostPeerToken) && (IsActivePeerToken(_playbackControllerToken) ? (_playbackControllerToken == _localPeerToken) : (_localPeerToken == lowestActivePeerToken))); if (flag && peerToken != _localPeerToken && flag2 && _videoQueue.Count > 0) { BroadcastQueueSnapshot(); } BroadcastVoteStatus(flag && peerToken != _localPeerToken, flag && peerToken != _localPeerToken && flag2); } } private void ApplyPeerVote(int peerToken, bool vote) { if (peerToken > 0 && peerToken <= 1048575 && !string.IsNullOrEmpty(_videoId)) { _peerLastSeen[peerToken] = Time.unscaledTime; if (vote) { _peerSkipVotes.Add(peerToken); } else { _peerSkipVotes.Remove(peerToken); } if (peerToken == _localPeerToken) { _localVotedSkip = vote; } BroadcastVoteStatus(includeSnapshot: true); if (GetActiveVoteCount() >= GetRequiredVotes() && IsLocalPlaybackCoordinator()) { SkipCurrentVideo(); } } } private void ApplyQueueAdd(int peerToken, int sequence, string videoId) { if (peerToken <= 0 || peerToken > 1048575 || sequence <= 0 || sequence > 1048575 || !IsVideoId(videoId)) { return; } long item = ((long)peerToken << 20) | (uint)sequence; if (!_processedQueueEvents.Add(item)) { return; } _peerLastSeen[peerToken] = Time.unscaledTime; if (_host && _peerPlayerKeys.TryGetValue(peerToken, out var value) && _blockedQueuePlayers.Contains(value)) { BroadcastQueueSnapshot(); return; } if (_videoQueue.Count >= 30) { if (_host) { BroadcastQueueSnapshot(); } return; } _queueTitleCache.TryGetValue(videoId, out var value2); _videoQueue.Add(new QueueEntry { VideoId = videoId, Title = (string.IsNullOrWhiteSpace(value2) ? videoId : value2), AddedBy = "" }); RequestQueueTitle(videoId); ScheduleQueueStart(); if (_host) { BroadcastQueueSnapshot(); } } private static int PackVideoIdGroup(string videoId, int start, int count) { int num = 0; for (int i = 0; i < count; i++) { num = num * 64 + VideoIdCharacterValue(videoId[start + i]); } return num; } private static int VideoIdCharacterValue(char character) { if (character >= 'A' && character <= 'Z') { return character - 65; } if (character >= 'a' && character <= 'z') { return character - 97 + 26; } if (character >= '0' && character <= '9') { return character - 48 + 52; } return character switch { '_' => 62, '-' => 63, _ => -1, }; } private static string UnpackVideoId(int firstGroup, int secondGroup, int thirdGroup) { StringBuilder stringBuilder = new StringBuilder(11); AppendVideoIdGroup(stringBuilder, firstGroup, 4); AppendVideoIdGroup(stringBuilder, secondGroup, 4); AppendVideoIdGroup(stringBuilder, thirdGroup, 3); string text = stringBuilder.ToString(); if (!IsVideoId(text)) { return null; } return text; } private static void AppendVideoIdGroup(StringBuilder result, int packed, int count) { int num = 1 << (count - 1) * 6; for (int i = 0; i < count; i++) { int num2 = (packed / num) & 0x3F; result.Append((num2 < 26) ? ((char)(65 + num2)) : ((num2 < 52) ? ((char)(97 + num2 - 26)) : ((num2 < 62) ? ((char)(48 + num2 - 52)) : ((num2 == 62) ? '_' : '-')))); if (num > 1) { packed %= num; } num >>= 6; } } private unsafe bool BindPeerIdentity(int peerToken, PlayerID sender) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) string text = "player:" + ((object)(*(PlayerID*)(&sender))/*cast due to .constrained prefix*/).ToString(); if (_peerPlayerKeys.TryGetValue(peerToken, out var value) && !string.Equals(value, text, StringComparison.Ordinal)) { return false; } if (!_moddedPlayers.TryGetValue(text, out var value2)) { value2 = new LobbyMember(); _moddedPlayers.Add(text, value2); } if (value2.PeerToken != 0 && value2.PeerToken != peerToken) { _peerLastSeen.Remove(value2.PeerToken); _peerSkipVotes.Remove(value2.PeerToken); _peerPlayerKeys.Remove(value2.PeerToken); if (_playbackControllerToken == value2.PeerToken) { _playbackControllerToken = GetLowestActivePeerToken(); } if (_moddedHostPeerToken == value2.PeerToken) { _moddedHostPeerToken = 0; } } value2.PeerToken = peerToken; value2.Name = GetRemotePlayerName(sender); _peerPlayerKeys[peerToken] = text; if (IsLobbyHostSender(sender)) { _moddedHostPeerToken = peerToken; _peerLastSeen[peerToken] = Time.unscaledTime; } return true; } private unsafe static string GetRemotePlayerName(PlayerID sender) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) try { PlayerPanelController i = NetworkSingleton<PlayerPanelController>.I; if ((Object)(object)i != (Object)null && i.PlayerIDs != null && i.IDInfos != null) { int num = i.PlayerIDs.IndexOf(sender); if (num >= 0 && num < i.IDInfos.Count && i.IDInfos[num].Name != null) { string value = Encoding.Unicode.GetString(i.IDInfos[num].Name).TrimEnd('\0').Trim(); if (!string.IsNullOrWhiteSpace(value)) { return ShortTitle(value, 24); } } } } catch { } return "Player " + ((object)(*(PlayerID*)(&sender))/*cast due to .constrained prefix*/).ToString(); } private static bool IsLobbyHostSender(PlayerID sender) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) try { PlayerPanelController i = NetworkSingleton<PlayerPanelController>.I; if ((Object)(object)i == (Object)null || i.PlayerIDs == null || i.PlayerSteamIDs == null || string.IsNullOrEmpty(i.HostId)) { return false; } int num = i.PlayerIDs.IndexOf(sender); return num >= 0 && num < i.PlayerSteamIDs.Count && string.Equals(i.PlayerSteamIDs[num], i.HostId, StringComparison.Ordinal); } catch { return false; } } private static bool IsUnsignedPacketInteger(float value, int maximum) { if (!float.IsNaN(value) && !float.IsInfinity(value) && value >= 0f && value <= (float)maximum) { return (double)value == Math.Truncate(value); } return false; } private static bool IsValidBoardPacket(float operationValue, Vector2 payload, int colIndex) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) if (!IsUnsignedPacketInteger(operationValue, 16777215) || !IsUnsignedPacketInteger(payload.x, 16777215) || !IsUnsignedPacketInteger(payload.y, 16777215) || colIndex < 0 || colIndex > 16777215) { return false; } int num = (int)operationValue; int num2 = num & 0xF; int num3 = num >> 4; bool flag = payload.x == 0f && payload.y == 0f; switch (num2) { case 1: case 10: if (num3 > 0) { return colIndex <= 262143; } return false; case 6: case 14: return colIndex <= 262143; case 8: if (num3 < 30) { return colIndex <= 262143; } return false; case 9: switch (num3) { case 0: if (payload.x >= 1f && payload.y <= payload.x) { return colIndex == Math.Max(1, (int)Math.Ceiling((double)payload.x * 0.3)); } return false; case 1: if (flag) { return colIndex == 0; } return false; case 2: case 3: if (payload.x >= 1f && payload.x <= 1048575f && payload.y == 0f) { return colIndex == 0; } break; } return false; case 0: if (num3 <= 1 && flag) { return colIndex == 0; } return false; case 5: if (num3 > 0 && flag) { return colIndex == 0; } return false; case 4: return num3 == 0 && flag; case 2: case 3: case 7: case 11: case 12: case 13: if (num3 == 0 && flag) { return colIndex == 0; } return false; default: return false; } } private static bool ReceiveBoardCommand(QuadPainterGPU __instance, Vector2 uv, Vector2 prevUV, int colIndex, RPCInfo rpcInfo) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) SchoolScreenPlugin instance = _instance; if ((Object)(object)instance == (Object)null || (Object)(object)__instance != (Object)(object)instance._schoolBoard) { return true; } if (!TryDecodeBoardMarker(uv.x, out var peerToken)) { return true; } if (peerToken == instance._localPeerToken) { return false; } prevUV.x = BoardPacketEnvelope.DecodeFirstGroup(prevUV.x); if (peerToken <= 0 || !IsValidBoardPacket(uv.y, prevUV, colIndex)) { return false; } if (!instance.BindPeerIdentity(peerToken, rpcInfo.sender)) { return false; } int num = Mathf.RoundToInt(uv.y); int num2 = num & 0xF; switch (num2) { case 0: instance._networkQueue.Enqueue("QUEUE_START|" + peerToken); return false; case 7: instance._networkQueue.Enqueue("QUEUE_CLEAR|" + peerToken); return false; case 8: { int num6 = num >> 4; string text3 = UnpackVideoId(Mathf.RoundToInt(prevUV.x), Mathf.RoundToInt(prevUV.y), colIndex); if (text3 != null) { instance._networkQueue.Enqueue("QUEUE_ITEM|" + num6 + "|" + text3 + "|" + peerToken); } return false; } case 9: { int num5 = num >> 4; switch (num5) { case 0: instance._networkQueue.Enqueue("VOTE_STATUS|" + Mathf.RoundToInt(prevUV.x) + "|" + Mathf.RoundToInt(prevUV.y) + "|" + colIndex + "|" + peerToken); break; case 1: instance._networkQueue.Enqueue("VOTE_RESET|" + peerToken); break; default: instance._networkQueue.Enqueue(((num5 == 2) ? "VOTE_ENTRY|" : "PEER_STATE|") + peerToken + "|" + Mathf.RoundToInt(prevUV.x)); break; } return false; } case 10: { int num7 = num >> 4; string text4 = UnpackVideoId(Mathf.RoundToInt(prevUV.x), Mathf.RoundToInt(prevUV.y), colIndex); if (text4 != null) { instance._networkQueue.Enqueue("QUEUE_ADD|" + peerToken + "|" + num7 + "|" + text4); } return false; } case 11: instance._networkQueue.Enqueue("PEER|" + peerToken); return false; case 12: case 13: instance._networkQueue.Enqueue(((num2 == 12) ? "VOTE|" : "UNVOTE|") + peerToken); return false; case 15: return false; default: switch (num & 7) { case 1: { string text2 = UnpackVideoId(Mathf.RoundToInt(prevUV.x), Mathf.RoundToInt(prevUV.y), colIndex); if (text2 != null) { instance._networkQueue.Enqueue("OPEN|" + text2 + "|0|" + peerToken + "|" + (num >> 4)); } break; } case 2: instance._networkQueue.Enqueue("PLAY|" + peerToken); break; case 3: instance._networkQueue.Enqueue("PAUSE|" + peerToken); break; case 4: instance._networkQueue.Enqueue("SEEK|" + ((float)colIndex / 10f).ToString("0.0", CultureInfo.InvariantCulture) + "|" + peerToken); break; case 5: instance._networkQueue.Enqueue("CLEAR|" + peerToken + "|" + (num >> 4)); break; case 6: { string text = UnpackVideoId(Mathf.RoundToInt(prevUV.x), Mathf.RoundToInt(prevUV.y), colIndex); if (text != null) { float num3 = (float)(num >> 4) / 10f; int num4 = (((num & 8) == 0) ? 1 : 2); string item = "SYNC|" + text + "|" + num3.ToString("0.0", CultureInfo.InvariantCulture) + "|" + num4 + "|" + peerToken; instance._networkQueue.Enqueue(item); } break; } } return false; } } private static float ParseFloat(string value) { if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return 0f; } return Mathf.Max(0f, result); } private static string ParseVideoId(string input) { if (string.IsNullOrWhiteSpace(input)) { return null; } string text = input.Trim(); if (IsVideoId(text)) { return text; } if (!Uri.TryCreate(text, UriKind.Absolute, out Uri result)) { Uri.TryCreate("https://" + text, UriKind.Absolute, out result); } if (result == null) { return null; } string text2 = null; if (result.Host.Equals("youtu.be", StringComparison.OrdinalIgnoreCase) || result.Host.EndsWith(".youtu.be", StringComparison.OrdinalIgnoreCase)) { text2 = result.AbsolutePath.Trim('/').Split('/')[0]; } else if (result.Host.Equals("youtube.com", StringComparison.OrdinalIgnoreCase) || result.Host.EndsWith(".youtube.com", StringComparison.OrdinalIgnoreCase) || result.Host.Equals("youtube-nocookie.com", StringComparison.OrdinalIgnoreCase) || result.Host.EndsWith(".youtube-nocookie.com", StringComparison.OrdinalIgnoreCase)) { text2 = QueryValue(result.Query, "v"); if (string.IsNullOrEmpty(text2)) { string[] array = result.AbsolutePath.Trim('/').Split('/'); if (array.Length >= 2 && (array[0] == "embed" || array[0] == "shorts" || array[0] == "live")) { text2 = array[1]; } } } if (!IsVideoId(text2)) { return null; } return text2; } private static bool IsVideoId(string value) { if (value == null || value.Length != 11) { return false; } foreach (char c in value) { if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9') && c != '_' && c != '-') { return false; } } return true; } private static string QueryValue(string query, string key) { string[] array = (query ?? "").TrimStart('?').Split('&'); for (int i = 0; i < array.Length; i++) { int num = array[i].IndexOf('='); if (num >= 0 && string.Equals(Uri.UnescapeDataString(array[i].Substring(0, num).Replace('+', ' ')), key, StringComparison.OrdinalIgnoreCase)) { return Uri.UnescapeDataString(array[i].Substring(num + 1).Replace('+', ' ')); } } return null; } private void OnDestroy() { try { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } try { SendHelper("CLOSE"); } catch { } try { _pipe?.Dispose(); } catch { } try { if (_browser != null && !_browser.HasExited) { _browser.Kill(); } } catch { } if ((Object)(object)_videoTexture != (Object)null) { Object.Destroy((Object)(object)_videoTexture); } DestroyGuiTexture(_windowTexture); DestroyGuiTexture(_fieldTexture); DestroyGuiTexture(_buttonTexture); DestroyGuiTexture(_buttonHoverTexture); DestroyGuiTexture(_accentTexture); DestroyGuiTexture(_accentHoverTexture); DestroyGuiTexture(_badgeTexture); DestroyGuiTexture(_statusTexture); DestroyGuiTexture(_meterBackgroundTexture); } private static void DestroyGuiTexture(Texture2D texture) { if ((Object)(object)texture != (Object)null) { Object.Destroy((Object)(object)texture); } } private static void AfterBoardUpdate(QuadPainterGPU __instance) { SchoolScreenPlugin instance = _instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance._schoolRenderer == (Object)null) && !((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)instance._schoolRenderer).gameObject)) { instance.ApplyTexture(); } } } }
BepInEx/plugins/SchoolScreenBrowser.exe
Decompiled 2 hours agousing System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Globalization; using System.IO; using System.IO.Pipes; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.CodeAnalysis; using Microsoft.Web.WebView2.Core; using Microsoft.Web.WebView2.WinForms; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("SchoolScreenBrowser")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+afcc261f7a7232e03fcc9be2b4299922b9fd567e")] [assembly: AssemblyProduct("SchoolScreenBrowser")] [assembly: AssemblyTitle("SchoolScreenBrowser")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SchoolScreenBrowser { internal sealed class BrowserForm : Form { private readonly string _pipeName; private readonly WebView2 _webView; private NamedPipeClientStream _pipe; private BinaryWriter _writer; private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1, 1); private readonly CancellationTokenSource _cancel = new CancellationTokenSource(); private readonly ConcurrentQueue<string> _pendingCommands = new ConcurrentQueue<string>(); private bool _webReady; private bool _capturing; protected override bool ShowWithoutActivation => true; protected override CreateParams CreateParams { get { CreateParams createParams = ((Form)this).CreateParams; createParams.ExStyle |= 0x80; createParams.ExStyle |= 0x8000000; createParams.ExStyle &= -262145; return createParams; } } public BrowserForm(string pipeName) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown _pipeName = pipeName; ((Control)this).Text = "On-Together School Screen"; ((Form)this).FormBorderStyle = (FormBorderStyle)0; ((Form)this).ShowInTaskbar = false; ((Form)this).StartPosition = (FormStartPosition)0; ((Form)this).Location = new Point(-1200, -1200); ((Form)this).ClientSize = new Size(768, 384); _webView = new WebView2 { Dock = (DockStyle)5 }; ((Control)this).Controls.Add((Control)(object)_webView); ((Form)this).Shown += async delegate { await InitializeAsync(); }; ((Form)this).FormClosing += (FormClosingEventHandler)delegate { _cancel.Cancel(); }; } private async Task InitializeAsync() { _ = 2; try { _pipe = new NamedPipeClientStream(".", _pipeName, PipeDirection.InOut, PipeOptions.Asynchronous); await _pipe.ConnectAsync(15000); _writer = new BinaryWriter(_pipe, Encoding.UTF8, leaveOpen: true); Task.Run((Func<Task?>)ReadCommandsAsync); string www = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "www"); if (!File.Exists(Path.Combine(www, "index.html"))) { throw new FileNotFoundException("The school screen player page is missing. Reinstall the complete mod package."); } string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OnTogetherSchoolScreen", "WebView2"); Directory.CreateDirectory(text); CoreWebView2EnvironmentOptions val = new CoreWebView2EnvironmentOptions("--autoplay-policy=no-user-gesture-required --disable-background-timer-throttling", (string)null, (string)null, false, (List<CoreWebView2CustomSchemeRegistration>)null); CoreWebView2Environment val2 = await CoreWebView2Environment.CreateAsync((string)null, text, val); await _webView.EnsureCoreWebView2Async(val2); _webView.CoreWebView2.SetVirtualHostNameToFolderMapping("schoolvideo.local", www, (CoreWebView2HostResourceAccessKind)1); _webView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false; _webView.CoreWebView2.Settings.AreDevToolsEnabled = false; _webView.CoreWebView2.NavigationCompleted += delegate(object _, CoreWebView2NavigationCompletedEventArgs e) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) _webReady = e.IsSuccess; if (!_webReady) { SendPacket(69, Encoding.UTF8.GetBytes("The player page could not load: " + ((object)e.WebErrorStatus/*cast due to .constrained prefix*/).ToString())); } else { SendPacket(83, Encoding.UTF8.GetBytes("READY|page")); string result; while (_webReady && _pendingCommands.TryDequeue(out result)) { _ = ExecuteCommandAsync(result); } } }; _webView.CoreWebView2.WebMessageReceived += delegate(object _, CoreWebView2WebMessageReceivedEventArgs e) { try { SendPacket(83, Encoding.UTF8.GetBytes(e.TryGetWebMessageAsString())); } catch { } }; _webView.Source = new Uri("https://schoolvideo.local/index.html"); CaptureLoopAsync(); } catch (Exception ex) { try { SendPacket(69, Encoding.UTF8.GetBytes(ex.GetBaseException().Message)); } catch { } CloseAfterDelay(); } } private async void CloseAfterDelay() { await Task.Delay(10000); if (!((Control)this).IsDisposed) { ((Control)this).BeginInvoke((Delegate)new Action(base.Close)); } } private async Task ReadCommandsAsync() { _ = 1; try { using StreamReader reader = new StreamReader(_pipe, Encoding.UTF8, detectEncodingFromByteOrderMarks: false, 1024, leaveOpen: true); while (!_cancel.IsCancellationRequested && _pipe.IsConnected) { string text = await reader.ReadLineAsync(); if (text != null) { if (text == "CLOSE") { ((Control)this).BeginInvoke((Delegate)new Action(base.Close)); break; } await ExecuteCommandOnUiThreadAsync(text); continue; } break; } } catch { } } private Task ExecuteCommandOnUiThreadAsync(string command) { TaskCompletionSource<bool> completion = new TaskCompletionSource<bool>(); if (((Control)this).IsDisposed || !((Control)this).IsHandleCreated) { completion.TrySetResult(result: false); return completion.Task; } ((Control)this).BeginInvoke((Delegate)(Action)async delegate { try { if (_webReady) { await ExecuteCommandAsync(command); } else { _pendingCommands.Enqueue(command); } completion.TrySetResult(result: true); } catch (Exception exception) { completion.TrySetException(exception); } }); return completion.Task; } private async Task ExecuteCommandAsync(string command) { string[] array = command.Split(new char[1] { '\t' }); string text = array[0]; string text2; if (text == "OPEN" && array.Length >= 3) { text2 = "schoolScreenCommand('open'," + JsString(array[1]) + "," + Number(array[2]) + "," + ((array.Length >= 4) ? Number(array[3]) : "0") + ");"; } else { switch (text) { case "PLAY": text2 = "schoolScreenCommand('play');"; break; case "PAUSE": text2 = "schoolScreenCommand('pause');"; break; case "SEEK": if (array.Length >= 2) { text2 = "schoolScreenCommand('seek'," + Number(array[1]) + ");"; break; } goto default; default: if (text == "VOLUME" && array.Length >= 2) { text2 = "schoolScreenCommand('volume'," + Number(array[1]) + ");"; break; } if (text == "LOOKUP" && array.Length >= 2) { text2 = "schoolScreenLookupTitle(" + JsString(array[1]) + ");"; break; } if (text == "RESET_LOOKUPS") { text2 = "schoolScreenResetTitleLookups();"; break; } if (text == "CLEAR") { text2 = "schoolScreenCommand('clear');"; break; } return; } } if (_webView.CoreWebView2 != null) { await _webView.CoreWebView2.ExecuteScriptAsync(text2); } } private async Task CaptureLoopAsync() { long framePeriod = Stopwatch.Frequency / 30; long nextFrame = Stopwatch.GetTimestamp(); while (!_cancel.IsCancellationRequested && !((Control)this).IsDisposed) { try { if (!_capturing && _webView.CoreWebView2 != null && ((Control)_webView).IsHandleCreated) { _capturing = true; using (MemoryStream stream = new MemoryStream()) { await _webView.CoreWebView2.CapturePreviewAsync((CoreWebView2CapturePreviewImageFormat)1, (Stream)stream); SendPacket(70, stream.ToArray()); } _capturing = false; } } catch { _capturing = false; } nextFrame += framePeriod; long num = nextFrame - Stopwatch.GetTimestamp(); if (num <= 0) { nextFrame = Stopwatch.GetTimestamp(); } else { await Task.Delay(Math.Max(1, (int)Math.Ceiling((double)num * 1000.0 / (double)Stopwatch.Frequency)), _cancel.Token).ContinueWith(delegate { }); } } } private void SendPacket(byte type, byte[] payload) { if (_writer == null || payload == null || payload.Length > 4194304) { return; } _writeLock.Wait(); try { _writer.Write(type); _writer.Write(payload.Length); _writer.Write(payload); _writer.Flush(); } catch { } finally { _writeLock.Release(); } } private static string Number(string value) { if (!double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return "0"; } return result.ToString("0.0", CultureInfo.InvariantCulture); } private static string JsString(string value) { return "'" + value.Replace("\\", "\\\\").Replace("'", "\\'").Replace("\r", "") .Replace("\n", "") + "'"; } } internal static class Program { [STAThread] private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string text = ((args.Length != 0) ? args[0] : string.Empty); if (!string.IsNullOrWhiteSpace(text)) { Application.Run((Form)(object)new BrowserForm(text)); } } } }