public override int Handle(IFrame frame, IList<IFrame> frames) { if (!CanHandle(frame)) return 0; int frameScore = Configuration.NumberOfPins; List<int> extraRolls = new List<int>(); var nextFrame = frames.FirstOrDefault(f => f.Sequence == frame.Sequence + 1); while(nextFrame != null && extraRolls.Count < Configuration.NumberOfRollsPerFrame) { if (IsStrike(nextFrame)) { extraRolls.Add(Configuration.NumberOfPins); nextFrame = frames.FirstOrDefault(f => f.Sequence == frame.Sequence + 1); } else { extraRolls.Add( nextFrame.Rolls .Where(r => r.Pins.HasValue) .Select(r => r.Pins.Value).ToArray()[extraRolls.Count] ); } } return frameScore + extraRolls.Sum(); }
/// <summary> /// Override method Move in classic game. /// </summary> /// <param name="tileLabel">Tile of type ITile.</param> /// <param name="frame">Frame of type IFrame.</param> /// <returns>True or false.</returns> public override bool Move(string tileLabel, IFrame frame) { if (!base.Move(tileLabel, frame)) { return false; } var tilePosition = this.FindTilePosition(tileLabel, frame); var nullTilePosition = this.FindTilePosition(string.Empty, frame); if (nullTilePosition.Row == tilePosition.Row) { if (nullTilePosition.Col == tilePosition.Col + 1 || nullTilePosition.Col == tilePosition.Col - 1) { this.SwapTwoTilesInFrameByPosition(frame, nullTilePosition, tilePosition); return true; } } if (nullTilePosition.Col == tilePosition.Col) { if (nullTilePosition.Row == tilePosition.Row + 1 || nullTilePosition.Row == tilePosition.Row - 1) { this.SwapTwoTilesInFrameByPosition(frame, nullTilePosition, tilePosition); return true; } } return false; }
public FrameLoadEndEventArgs(IBrowser browser, IFrame frame, int httpStatusCode) { Browser = browser; Frame = frame; Url = frame.Url; HttpStatusCode = httpStatusCode; }
bool IRequestHandler.OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, bool isRedirect) { if (!frame.IsMain || CommonUrls.IsWithSixUrl(request.Url) || IsAuthUrl(new Uri(request.Url))) return false; OpenInSystemBrowser(request.Url); return true; }
/// <summary> /// Override method GetCurrentMovableTileLabels in classic game. /// </summary> /// <param name="frame">Frame of type IFrame.</param> /// <returns>List of strings.</returns> protected override List<string> GetCurrentMovableTileLabels(IFrame frame) { var result = new List<string>(); var nullTilePosition = this.FindTilePosition(string.Empty, frame); if (this.NotFoundPosition == nullTilePosition) { return result; } if (0 <= nullTilePosition.Row - 1) { result.Add(frame.Tiles[nullTilePosition.Row - 1, nullTilePosition.Col].Label); } if (nullTilePosition.Row + 1 < frame.Rows) { result.Add(frame.Tiles[nullTilePosition.Row + 1, nullTilePosition.Col].Label); } if (0 <= nullTilePosition.Col - 1) { result.Add(frame.Tiles[nullTilePosition.Row, nullTilePosition.Col - 1].Label); } if (nullTilePosition.Col + 1 < frame.Cols) { result.Add(frame.Tiles[nullTilePosition.Row, nullTilePosition.Col + 1].Label); } return result; }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { if (CommonUrls.IsWithSixUrl(request.Url)) { var headers = request.Headers; headers[Common.ClientHeader] = DomainEvilGlobal.SecretData.UserInfo.ClientId.ToString(); headers[Common.ClientHeaderV] = Common.App.ProductVersion; request.Headers = headers; } return CefReturnValue.Continue; //Example of how to set Referer // Same should work when setting any header // For this example only set Referer when using our custom scheme var url = new Uri(request.Url); if (url.Scheme == "customscheme") // CefSharpSchemeHandlerFactory.SchemeName { var headers = request.Headers; headers["Referer"] = "http://google.com"; request.Headers = headers; } //NOTE: If you do not wish to implement this method returning false is the default behaviour // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource. //callback.Dispose(); //return false; //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { if (request.Method == "POST") { using (var postData = request.PostData) { if (postData != null) { var elements = postData.Elements; var charSet = request.GetCharSet(); foreach (var element in elements) { if (element.Type == PostDataElementType.Bytes) { var body = element.GetBody(charSet); } } } } } //Note to Redirect simply set the request Url //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase)) //{ // request.Url = "https://github.com/"; //} //Callback in async fashion //callback.Continue(true); //return CefReturnValue.ContinueAsync; } } return CefReturnValue.Continue; }
private IStompQueue GetQueue(IFrame request) { var destinationName = request.Headers["destination"]; if (string.IsNullOrEmpty(destinationName)) throw new BadRequestException(request, "'destination' header is empty."); return _queueRepository.Get(destinationName); }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { using (callback) { if (request.Method == "POST") { using (var postData = request.PostData) { var elements = postData.Elements; var charSet = request.GetCharSet(); foreach (var element in elements) { if (element.Type == PostDataElementType.Bytes) { var body = element.GetBody(charSet); } } } } //Note to Redirect simply set the request Url //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase)) //{ // request.Url = "https://github.com/"; //} //Callback in async fashion //callback.Continue(true); //return CefReturnValue.ContinueAsync; } return CefReturnValue.Continue; }
void IContextMenuHandler.OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model) { //Removing existing menu item model.Remove(CefMenuCommand.ViewSource); // Remove "View Source" option model.Remove(CefMenuCommand.Print); //Add new custom menu items model.AddItem((CefMenuCommand)ViewSource, "View Page Source"); if (parameters.TypeFlags.HasFlag(ContextMenuType.Media) && parameters.HasImageContents) { if(OsirtHelper.HasJpegExtension(parameters.SourceUrl)) { model.AddItem((CefMenuCommand)ViewImageExifData, "View image EXIF data"); } model.AddItem((CefMenuCommand)MenuSaveImage, "Save image"); model.AddItem((CefMenuCommand)CopyImgLocation, "Copy image location to clipboard"); model.AddItem((CefMenuCommand)ReverseImageSearch, "Reverse image search using TinEye"); } if(OsirtHelper.IsOnYouTube(browserControl.Address)) { model.AddItem((CefMenuCommand)SaveYouTubeVideo, "Extract YouTube video"); } if (OsirtHelper.IsOnFacebook(browserControl.Address)) { model.AddItem((CefMenuCommand)ViewFacebookId, "Show Facebook profile ID"); } if(!string.IsNullOrEmpty(parameters.UnfilteredLinkUrl)) { model.AddItem((CefMenuCommand)26501, "Open link in new tab"); } }
/// <summary> /// Are about to send a new message /// </summary> /// <param name="message">Message to send</param> /// <remarks> /// Can be used to prepare the next message. for instance serialize it etc. /// </remarks> /// <exception cref="NotSupportedException">Message is of a type that the encoder cannot handle.</exception> public void Prepare(object message) { if (!(message is IFrame)) throw new NotSupportedException("Only supports IFrame derived classes"); _frame = (IFrame) message; }
public IFrame Copy(IFrame srcFrame, Guid newFrameId, bool copyData) { if (!(srcFrame is SimpleFrame)) throw new ArgumentException("srcFrame"); SimpleFrame copy = null; if (copyData) return Copy(srcFrame, newFrameId); if (srcFrame is SimpleFrame) { SimpleFrame srcSimpleFrame = srcFrame as SimpleFrame; copy = new SimpleFrame(newFrameId); copy.MinimumCapacity = srcSimpleFrame.RowCount; foreach (DataColumn col in srcSimpleFrame.Columns) { DataColumn newCol = CopyColumn(col); copy.Columns.Add(newCol); } for (int i = 0; i < srcSimpleFrame.Rows.Count; i++) { copy.Rows.Add(copy.NewRow()); } copy.AcceptChanges(); } return copy; }
public IResourceHandler GetResourceHandler(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request) { // Every time we request the main GPM page allow another JS injection if (Regex.Match(request.Url, @"^http[s]?://play\.google\.com/music/listen", RegexOptions.IgnoreCase).Success) { firstJSOnly = true; } if (Regex.Match(request.Url, @"\.js", RegexOptions.IgnoreCase).Success && Regex.Match(request.Url, @"http", RegexOptions.IgnoreCase).Success && firstJSOnly) { firstJSOnly = false; using (WebClient webClient = new WebClient()) { // These are the JS files to inject into GPM string custom_interface = Properties.Resources.custom_interface; return ResourceHandler.FromStream(new MemoryStream(Encoding.UTF8.GetBytes( webClient.DownloadString(request.Url) + ";window.onload=function(){csharpinterface.showApp();};document.addEventListener('DOMContentLoaded', function () {" + "window.OBSERVER = setInterval(function() { if (document.getElementById('material-vslider')) { clearInterval(window.OBSERVER); " + Properties.Resources.gmusic_min + Properties.Resources.gmusic_theme_min + Properties.Resources.gmusic_mini_player_min + this.getInitCode() + custom_interface + "}}, 10);});")), webClient.ResponseHeaders["Content-Type"]); } } return null; }
public void SetCurrentFrame(IFrame currentFrame) { if (currentFrame == null || currentFrame.Function != _lastFunction) { instructionsListView.Items.Clear(); _lastFunction = null; } if (currentFrame != null) { if (currentFrame.Function == _lastFunction) { foreach (var item in instructionsListView.Items.Cast<MsilInstructionListViewItem>()) item.UpdateItem(currentFrame); } else { _lastFunction = currentFrame.Function; var bytes = ((RuntimeFunction)currentFrame.Function).IlCode.GetBytes(); var disassembler = new MsilDisassembler(new MemoryStreamReader(bytes), new DefaultOperandResolver()); foreach (var instruction in disassembler.Disassemble()) { var instructionBytes = new byte[instruction.Size]; Buffer.BlockCopy(bytes, instruction.Offset, instructionBytes, 0, instruction.Size); var item = new MsilInstructionListViewItem(instruction, instructionBytes); item.UpdateItem(currentFrame); instructionsListView.Items.Add(item); } } } }
/// <summary> /// Override method GetCurrentMovableTileLabels in RowCol game. /// </summary> /// <param name="frame">The Frame.</param> /// <returns>Result by selection of tile.</returns> protected override List<string> GetCurrentMovableTileLabels(IFrame frame) { var result = new List<string>(); var nullTilePosition = this.FindTilePosition(string.Empty, frame); if (this.NotFoundPosition == nullTilePosition) { return result; } for (int row = 0; row < frame.Rows; row++) { if (row == nullTilePosition.Row) { continue; } result.Add(frame.Tiles[row, nullTilePosition.Col].Label); } for (int col = 0; col < frame.Cols; col++) { if (col == nullTilePosition.Col) { continue; } result.Add(frame.Tiles[nullTilePosition.Row, col].Label); } return result; }
public IResourceHandler GetResourceHandler(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request) { // Every time we request the main GPM page allow another JS injection if (Regex.Match(request.Url, @"^http[s]?://play\.google\.com/music/listen", RegexOptions.IgnoreCase).Success) { firstJSOnly = true; } if (Regex.Match(request.Url, @"\.js", RegexOptions.IgnoreCase).Success && Regex.Match(request.Url, @"http", RegexOptions.IgnoreCase).Success && firstJSOnly) { firstJSOnly = false; using (WebClient webClient = new WebClient()) { // These are the JS files to inject into GPM string dark_theme = Google_Play_Music.Properties.Resources.dark_theme; string custom_interface = Google_Play_Music.Properties.Resources.custom_interface; string mini_player = Google_Play_Music.Properties.Resources.mini_player; Color c = Properties.Settings.Default.CustomColor; string RGB = "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2"); string custom_color = ";(function() {window.CustomColor = '" + RGB + "';})();"; bool controlsOnHover = Properties.Settings.Default.HoverControls; string controlsOnHoverJS = ";(function() {window.hoverControls = " + controlsOnHover.ToString().ToLower() + ";})();"; string setInitialZoomJS = ";(function() {csharpinterface.setInitialZoom();})();"; return ResourceHandler.FromStream(new MemoryStream(Encoding.UTF8.GetBytes(webClient.DownloadString(request.Url) + ";" + custom_color + controlsOnHoverJS + setInitialZoomJS + dark_theme + custom_interface + mini_player)), webClient.ResponseHeaders["Content-Type"]); } } return null; }
bool ILifeSpanHandler.OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser) { newBrowser = null; //browserControl.Load(targetUrl); OpenInNewTab?.Invoke(this, new NewTabEventArgs(targetUrl)); //this breaks when there are multiple window.open calls from JS. return true; }
public IFrame Process(IStompClient client, IFrame request) { var versions = request.Headers["accept-version"]; if (versions == null) { var error = request.CreateError("Missing the 'accept-version' header."); error.Headers["version"] = "2.0"; return error; } if (!versions.Contains("2.0")) { var error = request.CreateError("Only accepting stomp 2.0 clients."); error.Headers["version"] = "2.0"; return error; } IFrame frame; if (!CheckCredentials(client, request, out frame)) return frame; //TODO: Heartbeating. var response = new BasicFrame("CONNECTED"); response.Headers["version"] = "2.0"; response.Headers["server"] = _serverName; if (client.SessionKey != null) response.Headers["session"] = client.SessionKey; return response; }
public void PowerOptionChain(String CompanySymbol) { SearchPowerOptionChain(CompanySymbol); Frame1 = browser.Frame(Find.ById("ctl00_ctl00_uxMainContent_uxMainBodyColumnGrid3QM_OptionsAnalyticsTabs1_powserChainFrame")); Assert.AreEqual(CompanySymbol, Frame1.Span(Find.ByClass("ts2g")).Text); }
protected override bool CanHandle(IFrame frame) { return frame.Rolls .Where(r => r.Pins.HasValue) .Select(r => r.Pins.Value) .Sum() == Configuration.NumberOfPins; }
public FrameLoadStartEventArgs(IBrowser browser, IFrame frame) { Browser = browser; Frame = frame; Url = frame.Url; IsMainFrame = frame.IsMain; }
/// <summary> /// Testing constructor Only /// </summary> /// <param name="parent"></param> /// <param name="inPipe"></param> /// <param name="dataObj"></param> /// <param name="isValid"></param> public DummyInputDataPort(IElement parent, IDataPipe inPipe, IFrame dataObj, bool isValid) { _parent = parent; _inPipe = inPipe; _dataObj = dataObj; _IsValid = isValid; }
/// <summary> /// Initializes a new instance of the ProxyFrame class. /// </summary> /// <param name="frame">Frame of type IFrame.</param> public ProxyFrame(IFrame frame) { Validator.ValidateIsEqualOrGreaterThan(frame.Rows, Constants.FrameDimensionMin, "frame.Rows"); Validator.ValidateIsEqualOrGreaterThan(frame.Cols, Constants.FrameDimensionMin, "frame.Cols"); this.realFrame = frame; }
public void Send(IFrame frame) { if (frame == null) throw new ArgumentNullException("frame"); if (frame.Name != "MESSAGE") throw new InvalidOperationException("Only MESSAGE frames may be sent through a subscription."); _messagesSentThisSecond++; if (IsPending) throw new InvalidOperationException("Is either waiting on an ACK/NACK for the current message, or you've tried to send too many messages per second without acking them."); if (IsThrottled) throw new InvalidOperationException("You've tried to send too many messages per second. Adjust the MaxMessagesPerSecond property."); if (_pendingFrames.Count >= 20) throw new InvalidOperationException("Client already have more then 20 pending messages. Start ACK them."); // not 100% accurate, but should keep the throttling reasonable stable. if (DateTime.Now.Subtract(_startThrottle).TotalMilliseconds > 1000) { _messagesSentThisSecond = 0; _startThrottle = DateTime.Now; } if (AckType != "auto") _pendingFrames.Add(frame); Client.Send(frame); }
public LoadErrorEventArgs(IFrame frame, CefErrorCode errorCode, string errorText, string failedUrl) { Frame = frame; ErrorCode = errorCode; ErrorText = errorText; FailedUrl = failedUrl; }
public bool OnBeforePopup(IWebBrowser rpBrowserControl, IBlinkBrowser rpBrowser, IFrame rpFrame, string rpTargetUrl, string rpTargetFrameName, WindowOpenDisposition rpTargetDisposition, bool rpUserGesture, IPopupFeatures rpPopupFeatures, IWindowInfo rpWindowInfo, IBrowserSettings rpBrowserSettings, ref bool rrpNoJavascriptAccess, out IWebBrowser ropNewBrowser) { rpBrowserControl.Load(rpTargetUrl); ropNewBrowser = rpBrowserControl; return true; }
private static bool ValidateUserDefinedLink(IFrame frame) { var urlLinkFrame = FrameUtils.ConvertToUserDefinedURLLinkFrame(frame); var ok = ValidateTextEncoding(urlLinkFrame.TextEncoding); return ok; }
protected void EnqueueFrame(NetContext context, IFrame frame) { lock(this) { AddFrame(context, ref singleFrameOrList, frame); } }
public override int Handle(IFrame frame, IList<IFrame> frames) { return frame.Rolls .Where(r => r.Pins.HasValue) .Select(r => r.Pins.Value) .Sum(); }
private static bool ValidatePictureFrame(IFrame frame) { var pictureFrame = FrameUtils.ConvertToPictureFrame(frame); var ok = ValidateTextEncoding(pictureFrame.TextEncoding); return ok; }
public bool OnBeforeContextMenu(IWebBrowser browser, IFrame frame, IContextMenuParams parameters) { Console.WriteLine("Context menu opened"); Console.WriteLine(parameters.MisspelledWord); return true; }
IResponseFilter IRequestHandler.GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response) { var args = new GetResourceResponseFilterEventArgs(browserControl, browser, frame, request, response); GetResourceResponseFilterEvent?.Invoke(this, args); return(args.ResponseFilter); }
bool IRequestHandler.OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect) { var args = new OnBeforeBrowseEventArgs(browserControl, browser, frame, request, userGesture, isRedirect); OnBeforeBrowseEvent?.Invoke(this, args); return(args.CancelNavigation); }
public Score GetBonusScore(IFrame frame) { throw new NotImplementedException(); }
public IPropertyEntry GetPropertyEntry(IFrame frame) { return(new GroupProperty("ScaledSurface", new IPropertyEntry[0])); }
public MenuWithHandler[] GetContextMenuForParametrics(IFrame frame, Face face) { throw new NotImplementedException(); }
bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { var args = new GetAuthCredentialsEventArgs(browserControl, browser, frame, isProxy, host, port, realm, scheme, callback); GetAuthCredentialsEvent?.Invoke(this, args); EnsureCallbackDisposal(callback); return(args.ContinueAsync); }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { var args = new OnBeforeResourceLoadEventArgs(browserControl, browser, frame, request, callback); OnBeforeResourceLoadEvent?.Invoke(this, args); EnsureCallbackDisposal(callback); return(args.ContinuationHandling); }
bool IRequestHandler.OnOpenUrlFromTab(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture) { var args = new OnOpenUrlFromTabEventArgs(browserControl, browser, frame, targetUrl, targetDisposition, userGesture); OnOpenUrlFromTabEvent?.Invoke(this, args); return(args.CancelNavigation); }
public void AddNextFrame(IFrame nextFrame) => _nextFrame = nextFrame;
void IRequestHandler.OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength) { var args = new OnResourceLoadCompleteEventArgs(browserControl, browser, frame, request, response, status, receivedContentLength); OnResourceLoadCompleteEvent?.Invoke(this, args); }
public virtual void OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame) { Context = TweetDeckBridge.ContextInfo.Reset(); }
void IRequestHandler.OnResourceRedirect(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl) { var args = new OnResourceRedirectEventArgs(browserControl, browser, frame, request, response, newUrl); OnResourceRedirectEvent?.Invoke(this, args); if (!Equals(newUrl, args.NewUrl)) { newUrl = args.NewUrl; } }
bool IRequestHandler.CanGetCookies(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request) { var args = new CanGetCookiesEventArg(browserControl, browser, frame, request); CanGetCookiesEvent?.Invoke(this, args); return(args.GetCookies); }
bool IRequestHandler.OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response) { var args = new OnResourceResponseEventArgs(browserControl, browser, frame, request, response); OnResourceResponseEvent?.Invoke(this, args); return(args.RedirectOrRetry); }
public void OnContextReleased(IWebBrowser browserControl, IBrowser browser, IFrame frame) { }
bool IRequestHandler.CanSetCookie(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, Cookie cookie) { var args = new CanSetCookieEventArg(browserControl, browser, frame, request, cookie); CanSetCookieEvent?.Invoke(this, args); return(args.SetCookie); }
bool IContextMenuHandler.RunContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback) { return(false); }
public void OnFocusedNodeChanged(IWebBrowser browserControl, IBrowser browser, IFrame frame, IDomNode node) { }
bool IContextMenuHandler.OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags) { return(Application.ExecuteInExceptionCatcher <bool>(() => { string filePath = null; if (parameters.TypeFlags.HasFlag(ContextMenuType.Link) && new Uri(parameters.LinkUrl).Fragment.StartsWith("#FILE:")) { filePath = Uri.UnescapeDataString(new Uri(parameters.LinkUrl).Fragment.Replace("#FILE:", "")); } switch ((int)commandId) { case ShowDevTools: break; case ShowDebugForm: break; case OpenFile: OwnerForm.OpenFileByResultSelect(filePath); break; case OpenFolder: Process.Start(Path.GetDirectoryName(filePath)); break; } if ((int)commandId == ShowDevTools) { browser.ShowDevTools(); } if ((int)commandId == ShowDBBrowser) { OwnerForm.InvokeOnUIThread((f) => { var f2 = new DBBrowserForm(Application); f2.Show(f); }); } if ((int)commandId == GroongaDebug) { OwnerForm.InvokeOnUIThread((f) => { var f2 = new GroongaDebugForm() { GM = Application.GM }; f2.Show(f); }); } if ((int)commandId == ShowDebugForm) { OwnerForm.InvokeOnUIThread((f) => { var f2 = new DebugForm(Application); f2.Show(f); }); } if ((int)commandId == OpenFile) { } if ((int)commandId == OpenFolder) { } return false; })); }
public void OnContextCreated(IWebBrowser browserControl, IBrowser browser, IFrame frame) { }
/// <summary> /// When the ContextMenu is dismissed /// </summary> public void OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame) { }
void IContextMenuHandler.OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame) { }
/// <summary> /// Before the ContextMenu opens /// </summary> public void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model) { //Remove existing Menu Items bool r; r = model.Remove(CefMenuCommand.ViewSource); r = model.Remove(CefMenuCommand.Back); r = model.Remove(CefMenuCommand.Forward); r = model.Remove(CefMenuCommand.Print); Console.WriteLine(parameters.UnfilteredLinkUrl); //Initializing custom menu items if (parameters.LinkUrl != "") { model.AddItem((CefMenuCommand)OpenInNewTab, "Open In New Tab"); } if (parameters.LinkUrl != "" || parameters.SourceUrl != "") { model.AddItem((CefMenuCommand)Copy, "Copy link Address"); } }
void IContextMenuHandler.OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model) { //To disable the menu then call clear // model.Clear(); //Removing existing menu item //bool removed = model.Remove(CefMenuCommand.ViewSource); // Remove "View Source" option //Add new custom menu items model.Clear(); if (parameters.TypeFlags.HasFlag(ContextMenuType.Link) && new Uri(parameters.LinkUrl).Fragment.StartsWith("#FILE:")) { model.AddItem((CefMenuCommand)OpenFile, "開く"); model.AddSeparator(); model.AddItem((CefMenuCommand)OpenFolder, "フォルダを開く"); } else { if (Application.DebugMode) { model.AddItem((CefMenuCommand)ShowDevTools, "開発ツール"); model.AddItem((CefMenuCommand)ShowDBBrowser, "DBブラウザー(β版)"); model.AddItem((CefMenuCommand)GroongaDebug, "Groongaコマンド実行"); model.AddItem((CefMenuCommand)ShowDebugForm, "デバッグウインドウを開く"); model.AddSeparator(); model.AddItem(CefMenuCommand.ReloadNoCache, "更新"); } } }
protected static void DeselectAll(IFrame frame) { ScriptLoader.ExecuteScript(frame, "window.getSelection().removeAllRanges()", "gen:deselect"); }
/// <summary> /// When the user interacts with the context menu /// </summary> public bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags) { // Custom Commands // //Copy link Address if ((int)commandId == Copy) { //Save the link into windows clipboard if (parameters.LinkUrl != "") { Clipboard.SetText(parameters.LinkUrl); } } if ((int)commandId == OpenInNewTab) { //Validates that the LinkURL isn't null if (parameters.LinkUrl == "") { return(false); } //Getting the TabControl MaterialTabControl basedTabControl = (MaterialTabControl)mainTabPage.Parent; //Creating a new Tab MaterialTabPage newTab = new Igloo.Control.Browser.IBrowser().getIBrowserTab(parameters.LinkUrl, basedTabControl.Size); //Inovke on UI thread if (basedTabControl.InvokeRequired) { basedTabControl.Invoke(new Action(() => { //Add the new TabPage to the TabControl and then selects it basedTabControl.TabPages.Add(newTab); basedTabControl.SelectTab(newTab); })); } } return(false); }
public virtual bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags) { Control control = browserControl.AsControl(); switch (commandId) { case MenuOpenLinkUrl: OpenBrowser(control, Context.LinkUrl); break; case MenuCopyLinkUrl: SetClipboardText(control, Context.UnsafeLinkUrl); break; case MenuCopyUsername: { string url = Context.UnsafeLinkUrl; Match match = TwitterUtils.RegexAccount.Match(url); SetClipboardText(control, match.Success ? match.Groups[1].Value : url); control.InvokeAsyncSafe(analytics.AnalyticsFile.CopiedUsernames.Trigger); break; } case MenuOpenMediaUrl: OpenBrowser(control, TwitterUtils.GetMediaLink(Context.MediaUrl, ImageQuality)); break; case MenuCopyMediaUrl: SetClipboardText(control, TwitterUtils.GetMediaLink(Context.MediaUrl, ImageQuality)); break; case MenuViewImage: { string url = Context.MediaUrl; control.InvokeAsyncSafe(() => { TwitterUtils.ViewImage(url, ImageQuality); analytics.AnalyticsFile.ViewedImages.Trigger(); }); break; } case MenuSaveMedia: { bool isVideo = Context.Types.HasFlag(ContextInfo.ContextType.Video); string url = Context.MediaUrl; string username = Context.Chirp.Authors.LastOrDefault(); control.InvokeAsyncSafe(() => { if (isVideo) { TwitterUtils.DownloadVideo(url, username); analytics.AnalyticsFile.DownloadedVideos.Trigger(); } else { TwitterUtils.DownloadImage(url, username, ImageQuality); analytics.AnalyticsFile.DownloadedImages.Trigger(); } }); break; } case MenuSaveTweetImages: { string[] urls = Context.Chirp.Images; string username = Context.Chirp.Authors.LastOrDefault(); control.InvokeAsyncSafe(() => { TwitterUtils.DownloadImages(urls, username, ImageQuality); analytics.AnalyticsFile.DownloadedImages.Trigger(); }); break; } case MenuReadApplyROT13: string selection = parameters.SelectionText; control.InvokeAsyncSafe(() => FormMessage.Information("ROT13", StringUtils.ConvertRot13(selection), FormMessage.OK)); control.InvokeAsyncSafe(analytics.AnalyticsFile.UsedROT13.Trigger); return(true); case MenuSearchInBrowser: string query = parameters.SelectionText; control.InvokeAsyncSafe(() => BrowserUtils.OpenExternalSearch(query)); DeselectAll(frame); break; case MenuOpenDevTools: browserControl.ShowDevTools(); break; } return(false); }
public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model) { if (!TwitterUtils.IsTweetDeckWebsite(frame) || browser.IsLoading) { Context = TweetDeckBridge.ContextInfo.Reset(); } else { Context = TweetDeckBridge.ContextInfo.Create(parameters); } if (parameters.TypeFlags.HasFlag(ContextMenuType.Selection) && !parameters.TypeFlags.HasFlag(ContextMenuType.Editable)) { model.AddItem(MenuSearchInBrowser, "Search in browser"); model.AddSeparator(); model.AddItem(MenuReadApplyROT13, "Apply ROT13"); model.AddSeparator(); } string TextOpen(string name) => "Open " + name + " in browser"; string TextCopy(string name) => "Copy " + name + " address"; string TextSave(string name) => "Save " + name + " as..."; if (Context.Types.HasFlag(ContextInfo.ContextType.Link) && !Context.UnsafeLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal)) { if (TwitterUtils.RegexAccount.IsMatch(Context.UnsafeLinkUrl)) { model.AddItem(MenuOpenLinkUrl, TextOpen("account")); model.AddItem(MenuCopyLinkUrl, TextCopy("account")); model.AddItem(MenuCopyUsername, "Copy account username"); } else { model.AddItem(MenuOpenLinkUrl, TextOpen("link")); model.AddItem(MenuCopyLinkUrl, TextCopy("link")); } model.AddSeparator(); } if (Context.Types.HasFlag(ContextInfo.ContextType.Video)) { model.AddItem(MenuOpenMediaUrl, TextOpen("video")); model.AddItem(MenuCopyMediaUrl, TextCopy("video")); model.AddItem(MenuSaveMedia, TextSave("video")); model.AddSeparator(); } else if (Context.Types.HasFlag(ContextInfo.ContextType.Image) && Context.MediaUrl != TweetNotification.AppLogo.Url) { model.AddItem(MenuViewImage, "View image in photo viewer"); model.AddItem(MenuOpenMediaUrl, TextOpen("image")); model.AddItem(MenuCopyMediaUrl, TextCopy("image")); model.AddItem(MenuSaveMedia, TextSave("image")); if (Context.Chirp.Images.Length > 1) { model.AddItem(MenuSaveTweetImages, TextSave("all images")); } model.AddSeparator(); } }
public void OnDraggableRegionsChanged(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IList <DraggableRegion> regions) { // nop }
public virtual bool RunContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback) { return(false); }