public override GeneralTransform ComputeTransformToVisual(IViewObject from, Visual to) { GeneralTransform generalTransform = this.ViewRootContainer.TransformToVisual(to); return((GeneralTransform) new MatrixTransform(this.platformSurface.TransformToVisual(from, (IViewObject)this.HitTestRoot) * VectorUtilities.GetMatrixFromTransform(generalTransform))); }
public override bool IsMatrixTransform(IViewObject from, IViewObject to) { return(this.platformSurface.IsMatrixTransform(from, to)); }
public override Rect TransformBounds(IViewObject from, IViewObject to, Rect bounds) { return(this.platformSurface.TransformBounds(from, to, bounds)); }
public void Update(Model model, IViewObject viewObj) { }
public override Matrix GetComputedTransformToRootVerified(IViewObject element) { return(this.platformSurface.TransformToVisualVerified(element, (IViewObject)this.HitTestRoot)); }
protected LabelBackend(IViewObject view) { View = view; }
/// <summary> /// <see cref="WebBrowser.Document"/> (<see cref="HTMLDocument"/>) から艦これの Flash 要素を特定し、指定したパスにスクリーンショットを保存します。 /// </summary> /// <remarks> /// 本スクリーンショット機能は、「艦これ 司令部室」開発者の @haxe さんより多大なご協力を頂き実装できました。 /// ありがとうございました。 /// </remarks> /// <param name="path"></param> private void SaveCore(string path) { const string notFoundMessage = "Cannot find the Kancolle flash element."; var document = this.AssociatedObject.Document as HTMLDocument; if (document == null) { throw new Exception(notFoundMessage); } if (document.url.Contains(".swf?")) { var viewObject = document.getElementsByTagName("embed").item(0, 0) as IViewObject; if (viewObject == null) { throw new Exception(notFoundMessage); } var width = ((HTMLEmbed)viewObject).clientWidth; var height = ((HTMLEmbed)viewObject).clientHeight; TakeScreenshot(width, height, viewObject, path); } else { var gameFrame = document.getElementById("game_frame").document as HTMLDocument; if (gameFrame == null) { throw new Exception(notFoundMessage); } var frames = document.frames; var find = false; for (var i = 0; i < frames.length; i++) { var item = frames.item(i); var provider = item as IServiceProvider; if (provider == null) { continue; } object ppvObject; provider.QueryService(typeof(IWebBrowserApp).GUID, typeof(IWebBrowser2).GUID, out ppvObject); var webBrowser = ppvObject as IWebBrowser2; if (webBrowser == null) { continue; } var iframeDocument = webBrowser.Document as HTMLDocument; if (iframeDocument == null) { continue; } //flash要素が<embed>である場合と<object>である場合を判別して抽出 IViewObject viewObject = null; int width = 0, height = 0; var swf = iframeDocument.getElementById("externalswf"); if (swf == null) { continue; } Func <dynamic, bool> function = target => { if (target == null) { return(false); } viewObject = target as IViewObject; if (viewObject == null) { return(false); } width = int.Parse(target.width); height = int.Parse(target.height); return(true); }; if (!function(swf as HTMLEmbed) && !function(swf as HTMLObjectElement)) { continue; } find = true; TakeScreenshot(width, height, viewObject, path); break; } if (!find) { throw new Exception(notFoundMessage); } } }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="viewObj"></param> /// <returns>クエリの優先順位が高いViewLayoutValueDictionaryが先頭の方にきます。</returns> public IEnumerable <IReadOnlyViewLayoutValueDictionary> MatchLayoutValueDicts(Model model, IViewObject viewObj) { return(_layoutValueDicts .Where(_t => _t.Key.DoMatch(model, viewObj)) .Select(_t => (viewLayoutDict: _t.Value, priority: model.GetQueryPathPriority(_t.Key.Query))) .Where(_t => !_t.priority.IsEmpty) .OrderByDescending(_t => _t.priority) .Select(_t => _t.viewLayoutDict) ); }
/// <summary> /// スクリーンショットを撮影します。 /// </summary> /// <param name="is32bpp"></param> /// <returns></returns> private Bitmap TakeScreenShot(bool is32bpp) { var wb = Browser; if (!IsKanColleLoaded) { AddLog(3, string.Format("艦これが読み込まれていないため、スクリーンショットを撮ることはできません。")); System.Media.SystemSounds.Beep.Play(); return(null); } try { IViewObject viewobj = null; //int width = 0, height = 0; if (wb.Document.Url.ToString().Contains(".swf?")) { viewobj = wb.Document.GetElementsByTagName("embed")[0].DomElement as IViewObject; if (viewobj == null) { throw new InvalidOperationException("embed 要素の取得に失敗しました。"); } //width = ( (HTMLEmbed)viewobj ).clientWidth; //height = ( (HTMLEmbed)viewobj ).clientHeight; } else { var swf = getFrameElementById(wb.Document, "externalswf"); if (swf == null) { throw new InvalidOperationException("対象の swf が見つかりませんでした。"); } Func <dynamic, bool> isvalid = target => { if (target == null) { return(false); } viewobj = target as IViewObject; if (viewobj == null) { return(false); } //if ( !int.TryParse( target.width, out width ) ) return false; //if ( !int.TryParse( target.height, out height ) ) return false; return(true); }; if (!isvalid(swf.DomElement as HTMLEmbed) && !isvalid(swf.DomElement as HTMLObjectElement)) { throw new InvalidOperationException("対象の swf が見つかりませんでした。"); } } if (viewobj != null) { var rect = new RECT { left = 0, top = 0, width = KanColleSize.Width, height = KanColleSize.Height }; // twitter の劣化回避を行う場合は32ビットの色深度で作業する var image = new Bitmap(rect.width, rect.height, is32bpp ? PixelFormat.Format32bppArgb : PixelFormat.Format24bppRgb); var device = new DVTARGETDEVICE { tdSize = 0 }; using (var g = Graphics.FromImage(image)) { var hdc = g.GetHdc(); viewobj.Draw(1, 0, IntPtr.Zero, device, IntPtr.Zero, hdc, rect, null, IntPtr.Zero, IntPtr.Zero); g.ReleaseHdc(hdc); } if (is32bpp) { // 不透明ピクセルのみだと jpeg 化されてしまうため、1px だけわずかに透明にする Color temp = image.GetPixel(image.Width - 1, image.Height - 1); image.SetPixel(image.Width - 1, image.Height - 1, Color.FromArgb(252, temp.R, temp.G, temp.B)); } return(image); } } catch (Exception ex) { SendErrorReport(ex.ToString(), "スクリーンショットの撮影時にエラーが発生しました。"); System.Media.SystemSounds.Beep.Play(); } return(null); }
protected virtual void OnPushed(IViewObject viewObj) { }
public static PropertyReference ResolvePropertyPath(ITypeResolver typeResolver, IViewObject propertyPath, SceneNode pathRoot) { if (propertyPath == null) { return((PropertyReference)null); } string path = (string)propertyPath.GetCurrentValue(typeResolver.ResolveProperty(typeResolver.PlatformMetadata.KnownProperties.PropertyPathPath)); if (path == null) { return((PropertyReference)null); } IProperty propertyKey = typeResolver.ResolveProperty(typeResolver.PlatformMetadata.KnownProperties.PropertyPathPathParameters); Collection <object> parameters = propertyKey == null ? new Collection <object>() : (Collection <object>)propertyPath.GetCurrentValue(propertyKey); return(TimelineSceneNode.ResolvePropertyPathParts(typeResolver, path, parameters, pathRoot)); }
protected virtual void OnPopOrCreated(ModelViewBinder.BindInfo bindInfo, IViewObject viewObj) { }
void OnViewObjectUnbinded(IViewObject viewObject) { ParentPool.Push(viewObject); }
/// <summary> /// Creates an instance with the specified values. /// </summary> /// <param name="oldParent">Old parent.</param> /// <param name="newParent">New parent.</param> public ViewObjectParentChangedEventArgs(IViewObject oldParent, IViewObject newParent) { OldParent = oldParent; NewParent = newParent; }
public static Bitmap TakeSnapshot(IViewObject obj, int width, int height) { // draw the view on a Bitmap IntPtr hBitmapDC = IntPtr.Zero; IntPtr hBitmap = IntPtr.Zero; IntPtr hPreviousObject = IntPtr.Zero; Bitmap bitmap = null; try { // create GDI objects used for drawing hBitmapDC = Gdi32.CreateCompatibleDC(User32.GetDC(IntPtr.Zero)); hBitmap = Gdi32.CreateCompatibleBitmap(User32.GetDC(IntPtr.Zero), width, height); hPreviousObject = Gdi32.SelectObject(hBitmapDC, hBitmap); RECT sourceRect = new RECT(); sourceRect.right = width; sourceRect.bottom = height; // draw the bitmap obj.Draw(DVASPECT.CONTENT, 1, IntPtr.Zero, IntPtr.Zero, User32.GetDC(IntPtr.Zero), hBitmapDC, ref sourceRect, IntPtr.Zero, IntPtr.Zero, 0); // convert to a managed bitmap bitmap = Bitmap.FromHbitmap(hBitmap); } finally { // restore previous object Gdi32.SelectObject(hBitmapDC, hPreviousObject); if (hBitmapDC != IntPtr.Zero) Gdi32.DeleteDC(hBitmapDC); if (hBitmap != IntPtr.Zero) Gdi32.DeleteObject(hBitmap); } return bitmap; }
/// <summary> /// 指定したmodel,viewObjectがIControllerObjectを作成できるか判定します。 /// </summary> /// <param name="model"></param> /// <param name="viewObject"></param> /// <returns></returns> public abstract bool IsCreatableControllerObject(Model model, IViewObject viewObject);
public override bool IsCreatableControllerObject(Model model, IViewObject viewObject) { return(model.Name == "Apple"); }
/// <summary> /// このIEventDispatcherと対応しているIControllerObjectを作成します。 /// /// 作成できない場合は例外を投げます。 /// そのため引数に渡すmodelとviewObjectがIControllerObjectを作成可能かどうかはIEventDispatcher#IsCreatableControllerObjectsで判定してください。 /// </summary> /// <param name="model"></param> /// <param name="viewObject"></param> /// <returns></returns> public abstract IEventDispatcherHelper CreateEventDispatcherHelpObject(Model model, IViewObject viewObject);
protected override IAutoViewLayoutObject CreateImpl(IViewObject viewObj) { return(new SiblingOrderAutoViewLayoutObject()); }
/// <summary> /// 指定されたkeyword,model,viewObjectに対応したEventDataを返します。 /// </summary> /// <param name="keyword"></param> /// <param name="model"></param> /// <param name="viewObject"></param> /// <param name="controllerInfo"></param> /// <returns></returns> protected abstract object GetEventData(Model model, IViewObject viewObject, ControllerInfo controllerInfo);
public void Update(Model model, IViewObject viewObj) { (viewObj as AppendViewObj).Value = Value; }
protected override IAutoViewLayoutObject CreateImpl(IViewObject viewObj) { return(new ViewLayoutObj()); }
public static IDrawingComponentObject GetDrawingComponent(IEntityObject IEntityinstance, IViewObject View) { return(new IDrawingComponentObject(IEntityinstance.IEntityInstance.GetDrawingComponent(View.IViewInstance as View))); }
private static Bitmap GetScreenshot(IViewObject viewObject, int width, int height) { var image = new Bitmap(width, height, PixelFormat.Format24bppRgb); var rect = new RECT { left = 0, top = 0, width = width, height = height, }; var tdevice = new DVTARGETDEVICE { tdSize = 0, }; using (var graphics = Graphics.FromImage(image)) { var hdc = graphics.GetHdc(); viewObject.Draw(1, 0, IntPtr.Zero, tdevice, IntPtr.Zero, hdc, rect, null, IntPtr.Zero, IntPtr.Zero); graphics.ReleaseHdc(hdc); } return image; }
public override Matrix GetComputedTransformFromRoot(IViewObject element) { return(this.platformSurface.TransformToVisual((IViewObject)this.HitTestRoot, element)); }
/// <summary> /// 截图游戏并保存 /// </summary> public static void ScreenShot() { if (!Directory.Exists("screenshot")) { Directory.CreateDirectory("screenshot"); } string path = @"screenshot\" + LogsHelper.GetServerName() + "_" + LogsHelper.GetFilePlayerName() + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff") + "." + DataUtil.Config.sysConfig.capFormat.ToString().ToLower(); var document = main.mainWeb.Document as HTMLDocument; if (document == null) { return; } if (document.url.Contains(".swf?")) { var viewObject = document.getElementsByTagName("embed").item(0, 0) as IViewObject; if (viewObject == null) { return; } var width = ((HTMLEmbed)viewObject).clientWidth; var height = ((HTMLEmbed)viewObject).clientHeight; TakeScreenshot(width, height, viewObject, path); } else { if (DataUtil.Game.gameServer == (int)GameInfo.ServersList.American || DataUtil.Game.gameServer == (int)GameInfo.ServersList.AmericanR18) { var gameFrame = document.getElementById("externalContainer").document as HTMLDocument; if (gameFrame == null) { return; } IViewObject viewObject = null; int width = 0, height = 0; var swf = gameFrame.getElementById("externalswf"); if (swf == null) { return; } Func <dynamic, bool> function = target => { if (target == null) { return(false); } viewObject = target as IViewObject; if (viewObject == null) { return(false); } width = int.Parse(target.width); height = int.Parse(target.height); return(true); }; if (!function(swf as HTMLEmbed) && !function(swf as HTMLObjectElement)) { return; } TakeScreenshot(width, height, viewObject, path); } else { var gameFrame = document.getElementById("game_frame").document as HTMLDocument; if (gameFrame == null) { return; } var frames = document.frames; for (var i = 0; i < frames.length; i++) { var item = frames.item(i); var provider = item as IServiceProvider; if (provider == null) { continue; } object ppvObject; provider.QueryService(typeof(IWebBrowserApp).GUID, typeof(IWebBrowser2).GUID, out ppvObject); var webBrowser = ppvObject as IWebBrowser2; var iframeDocument = webBrowser?.Document as HTMLDocument; if (iframeDocument == null) { continue; } IViewObject viewObject = null; int width = 0, height = 0; var swf = iframeDocument.getElementById("externalswf"); if (swf == null) { continue; } Func <dynamic, bool> function = target => { if (target == null) { return(false); } viewObject = target as IViewObject; if (viewObject == null) { return(false); } width = int.Parse(target.width); height = int.Parse(target.height); return(true); }; if (!function(swf as HTMLEmbed) && !function(swf as HTMLObjectElement)) { continue; } TakeScreenshot(width, height, viewObject, path); break; } } } }
public override Point TransformPoint(IViewObject from, IViewObject to, Point point) { return(this.platformSurface.TransformPoint(from, to, point)); }
/// <summary> /// 게임 화면 캡쳐 /// </summary> /// <param name="browser"></param> public static Image Capture(WebBrowser browser) { // Find swf element var document = browser.Document.DomDocument as HTMLDocument; if (document == null) { return(null); } IViewObject gameObject = null; // ~~~.swf?~~~ in URL if (document.url.Contains(".swf?")) { // This is flash object var viewObject = document.getElementsByTagName("embed").item(0, 0) as IViewObject; if (viewObject == null) { return(null); } var width = ((HTMLEmbed)viewObject).clientWidth; var height = ((HTMLEmbed)viewObject).clientHeight; gameObject = viewObject; } else { // #game_frame is parent of Flash object var gameFrame = document.getElementById("game_frame")?.document as HTMLDocument; if (gameFrame == null) { return(null); } var frames = document.frames; var find = false; for (var i = 0; i < frames.length; i++) { var item = frames.item(i); var provider = item as BeerViewer.Win32.IServiceProvider; if (provider == null) { continue; } object ppvObject; provider.QueryService(typeof(IWebBrowserApp).GUID, typeof(IWebBrowser2).GUID, out ppvObject); var webBrowser = ppvObject as IWebBrowser2; var iframeDocument = webBrowser?.Document as HTMLDocument; if (iframeDocument == null) { continue; } // flash 요소가 <embed>인 것과 <object>인 것을 판별하여 추출 IViewObject viewObject = null; var swf = iframeDocument.getElementById("externalswf"); if (swf == null) { continue; } Func <dynamic, bool> function = target => { if (target == null) { return(false); } viewObject = target as IViewObject; if (viewObject == null) { return(false); } return(true); }; if (!function(swf as HTMLEmbed) && !function(swf as HTMLObjectElement)) { continue; } find = true; gameObject = viewObject; break; } if (!find) { return(null); } } if (gameObject == null) { return(null); } var image = GetRealScreenshot(800, 480, gameObject); return(image); }
public override GeneralTransform ComputeTransformToVisual(IViewObject from, IViewObject to) { return((GeneralTransform) new MatrixTransform(this.platformSurface.TransformToVisual(from, to))); }
/// <summary> /// スクリーンショットを保存します。 /// </summary> /// <param name="path">保存先。</param> /// <param name="format">画像のフォーマット。</param> private void SaveScreenShot(string path, System.Drawing.Imaging.ImageFormat format) { var wb = Browser; if (!IsKanColleLoaded) { AddLog(3, string.Format("艦これが読み込まれていないため、スクリーンショットを撮ることはできません。")); System.Media.SystemSounds.Beep.Play(); return; } try { IViewObject viewobj = null; //int width = 0, height = 0; if (wb.Document.Url.ToString().Contains(".swf?")) { viewobj = wb.Document.GetElementsByTagName("embed")[0].DomElement as IViewObject; if (viewobj == null) { throw new InvalidOperationException("embed 要素の取得に失敗しました。"); } //width = ( (HTMLEmbed)viewobj ).clientWidth; //height = ( (HTMLEmbed)viewobj ).clientHeight; } else { var swf = getFrameElementById(wb.Document, "externalswf"); if (swf == null) { throw new InvalidOperationException("対象の swf が見つかりませんでした。"); } Func <dynamic, bool> isvalid = target => { if (target == null) { return(false); } viewobj = target as IViewObject; if (viewobj == null) { return(false); } //if ( !int.TryParse( target.width, out width ) ) return false; //if ( !int.TryParse( target.height, out height ) ) return false; return(true); }; if (!isvalid(swf.DomElement as HTMLEmbed) && !isvalid(swf.DomElement as HTMLObjectElement)) { throw new InvalidOperationException("対象の swf が見つかりませんでした。"); } } if (viewobj != null) { var rect = new RECT { left = 0, top = 0, width = KanColleSize.Width, height = KanColleSize.Height }; using (var image = new Bitmap(rect.width, rect.height, System.Drawing.Imaging.PixelFormat.Format24bppRgb)) { var device = new DVTARGETDEVICE { tdSize = 0 }; using (var g = Graphics.FromImage(image)) { var hdc = g.GetHdc(); viewobj.Draw(1, 0, IntPtr.Zero, device, IntPtr.Zero, hdc, rect, null, IntPtr.Zero, IntPtr.Zero); g.ReleaseHdc(hdc); } image.Save(path, format); } } _lastScreenShotPath = path; AddLog(2, string.Format("スクリーンショットを {0} に保存しました。", path)); } catch (Exception ex) { BrowserHost.AsyncRemoteRun(() => BrowserHost.Proxy.SendErrorReport(ex.ToString(), "スクリーンショットの保存時にエラーが発生しました。")); System.Media.SystemSounds.Beep.Play(); } }
public override double GetDefinitionActualSize(IViewObject definition) { return(this.platformSurface.GetDefinitionActualSize(definition.PlatformSpecificObject)); }
public virtual Matrix GetTransformMatrix(IViewObject targetViewObject) { return(this.ElementSet.GetTransformMatrix(targetViewObject)); }
private static void SaveScreenshot(int width, int height, IViewObject viewObject, string path) { using (var image = new Bitmap(width, height, PixelFormat.Format24bppRgb)) { var rect = new RECT { left = 0, top = 0, width = width, height = height }; var tdevice = new DVTARGETDEVICE { tdSize = 0 }; using (var graphics = Graphics.FromImage(image)) { var hdc = graphics.GetHdc(); viewObject.Draw(1, 0, IntPtr.Zero, tdevice, IntPtr.Zero, hdc, rect, null, IntPtr.Zero, IntPtr.Zero); graphics.ReleaseHdc(hdc); } var format = Path.GetExtension(path)?.ToLower() == ".jpg" ? ImageFormat.Jpeg : ImageFormat.Png; image.Save(path, format); } }
public ViewTreeNode(IViewObject obj) { this.obj = obj; this.classView = obj.GetClassView(); SetupFromView(); }