public void Run() { _backgroundImageElement = Document.GetElementById("backgroundImage").As <ImageElement>(); _imageStripElement = Document.GetElementById("imageStrip").As <ImageElement>(); _tankCanvas = Document.GetElementById("fishTankCanvas").As <CanvasElement>(); _fishesCanvas = Document.GetElementById("fishesCanvas").As <CanvasElement>(); Debug.Assert(_backgroundImageElement != null); Debug.Assert(_imageStripElement != null); Debug.Assert(_tankCanvas != null); Debug.Assert(_fishesCanvas != null); _tankCanvasContext = (CanvasContext2D)_tankCanvas.GetContext(Rendering.Render2D); _fishesCanvasContext = (CanvasContext2D)_fishesCanvas.GetContext(Rendering.Render2D); _fishes = new List <Fish>(); for (int i = 0; i < FishTank.FishCount; i++) { double x = Math.Floor(Math.Random() * (_width - FishTank.FishWidth) + FishTank.FishWidth / 2); double y = Math.Floor(Math.Random() * (_height - FishTank.FishHeight) + FishTank.FishHeight / 2); double z = Math.Floor(Math.Random() * (FishTank.ZFar - FishTank.ZNear)); _fishes.Add(new Fish(this, x, y, z, _imageStripElement, _fishesCanvasContext)); } OnWindowResize(null); Window.AddEventListener("resize", OnWindowResize, false); _tickHandler = OnTick; QueueUpdate(); }
private void DrawMoveMovement(Move move, CanvasElement canvasElem) { foreach (var piece in move.BeatedPieces ?? new List <BeatedPiece>()) { foreach (var elem in BoardCanvasElements.Where(e => e.Geometry is EllipseGeometry && e.X == piece.Row && e.Y == piece.Column).ToList()) { BoardCanvasElements.Remove(elem); } } canvasElem.Row = skipSize * (Game.Board.Size - 1 - move.NewPiece.Row) + skipSize / 2; canvasElem.Column = skipSize * move.NewPiece.Column + skipSize / 2; canvasElem.X = move.NewPiece.Row; canvasElem.Y = move.NewPiece.Column; if (move.NewPiece.IsKing && !move.OldPiece.IsKing) { BoardCanvasElements.Add(new Model.CanvasElement { Row = skipSize * (Game.Board.Size - 1 - move.NewPiece.Row) + skipSize / 2, Column = skipSize * move.NewPiece.Column + skipSize / 2, Geometry = new EllipseGeometry { RadiusX = skipSize / 4, RadiusY = skipSize / 4 }, Thickness = 2, Stroke = move.NewPiece.Color == PieceColor.Black ? Brushes.White : Brushes.Black, X = move.NewPiece.Row, Y = move.NewPiece.Column }); } }
static MainView() { CanvasElement canvas = (CanvasElement)Document.GetElementById("canvas"); //Element body = Document.GetElementsByTagName("body")[0]; //body.AddEventListener("load", delegate(ElementEvent e) { WWTControl.InitControl(); }, false); //XmlHttpRequest xhr = new XmlHttpRequest(); //xhr.Open(HttpVerb.Get, "quakedata.txt?3"); //xhr.OnReadyStateChange = delegate() //{ // if (xhr.ReadyState == ReadyState.Loaded) // { // VizLayer layer = new VizLayer(); // layer.Load(xhr.ResponseText); // layer.Prepare(); // WWTControl.Singleton.Layers.Add(layer); // } //}; //xhr.Send(); //Wtml.GetWtmlFile("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?W=ExploreRoot"); //Wtml.GetWtmlFile("imagesets.xml"); }
private List <CanvasElement> AddCanvasElementsForAction( IMAction item, bool isLoadingFromFile = false) { List <CanvasElement> canvasElement1 = CanvasElement.GetCanvasElement(item, this, this.ParentWindow); foreach (CanvasElement canvasElement2 in canvasElement1) { canvasElement2.mIsLoadingfromFile = isLoadingFromFile; foreach (IMAction index in canvasElement2.ListActionItem) { this.dictCanvasElement[index] = canvasElement2; } if (canvasElement2.Parent == null) { this.mCanvas.Children.Add((UIElement)canvasElement2); canvasElement2.MouseLeftButtonDown -= new MouseButtonEventHandler(this.MoveIcon_PreviewMouseDown); canvasElement2.mResizeIcon.PreviewMouseDown -= new MouseButtonEventHandler(this.ResizeIcon_PreviewMouseDown); canvasElement2.MouseLeftButtonDown += new MouseButtonEventHandler(this.MoveIcon_PreviewMouseDown); canvasElement2.mResizeIcon.PreviewMouseDown += new MouseButtonEventHandler(this.ResizeIcon_PreviewMouseDown); } if (this.SidebarWindow == null) { canvasElement2.Visibility = Visibility.Hidden; } } KMManager.listCanvasElement.Add(canvasElement1); return(canvasElement1); }
public static WebGLRenderingContext Create3DContext(CanvasElement canvas) { string[] names = new string[] { "webgl", "experimental-webgl", "webkit-3d", "moz-webgl" }; WebGLRenderingContext context = null; foreach (string name in names) { try { context = canvas.GetContext(name).As <WebGLRenderingContext>(); } catch { } if (context != null) { break; } } return(context); }
public void MouseDown(ElementEvent e) { CanvasElement canvas = Document.GetElementById <CanvasElement>("graph"); int x = Mouse.OffsetX(canvas, e); int y = Mouse.OffsetY(canvas, e); if ((Math.Abs(x - center) < 10) && Math.Abs(y - 75) < 10) { dragType = DragType.Center; } else if (Math.Abs(x - lowPosition) < 3) { dragType = DragType.Low; } else if (Math.Abs(x - highPosition) < 3) { dragType = DragType.High; } else { dragType = DragType.Range; downPosition = Math.Min(255, Math.Max(0, x)); Draw(); } e.CancelBubble = true; }
public object EndRender() { var result = _canvas; _canvas = null; return(result); }
void ReadChar(int curChar) { if (ptCur.X >= rClip.Left && ptCur.X <= rClip.InnerRight) { canvas[ptCur] = new CanvasElement((byte)curChar, rgbAttribute); } ptCur.X++; lastLineHasData = true; if (ptCur.X > rClip.InnerRight) { if (ansiLineWrap ?? LineWrap) { ptCur.Y++; lastLineHasData = false; if (ptCur.Y > rClip.InnerBottom) { if (AnimateView) { canvas.ShiftUp(); ptCur.Y = rClip.InnerBottom; } else { throw new CanvasOverflowException(); } } ptCur.X = rClip.Left; } else { ptCur.X = rClip.InnerRight; } } }
public void SetImage(CanvasElement canvasElement, string filename, float width, float height) { switch (canvasElement) { case CanvasElement.NETWORK_LOGO: NetworkLogoFilename = filename; NetworkLogoRectangle = new RectF() { Left = 0, Top = 0, Right = width, Bottom = height }; break; case CanvasElement.SHARE_LOGO: ShareLogoFilename = filename; ShareLogoRectangle = new RectF() { Left = 0, Top = 0, Right = width, Bottom = height }; break; case CanvasElement.PROFILE_IMAGE: ProfileImageFilename = filename; ProfileImageRectangle = new RectF() { Left = 0, Top = 0, Right = width, Bottom = height }; break; default: throw new Exception($"{nameof(canvasElement)} is not an image element."); } }
void DrawCharacter(Canvas canvas, Point location, Attribute attribute, Character[] gradient, bool inverse, bool applyColour) { var cur = canvas [location]; var index = Array.LastIndexOf(gradient, cur.Character); Character character; if (inverse) { if (index > 0 && index <= gradient.Length - 1) { index--; character = gradient [index]; } else { character = CanvasElement.Default.Character; } } else { if (index >= 0 && index < gradient.Length - 1) { index++; } else if (index == -1) { index = 0; } character = gradient[index]; } canvas[location] = new CanvasElement(character, applyColour ? attribute : cur.Attribute); }
public bool SetElements(List <ElementBase> elements) { this.reportDesigner1.Elements.Clear(); if (elements == null || elements.Count <= 0) { return(false); } this.reportDesigner1.SuspendLayout(); CanvasElement canvas = elements[0] as CanvasElement; if (canvas != null) { this.reportDesigner1.CanvasElement.Width = canvas.Width; this.reportDesigner1.CanvasElement.Height = canvas.Height; elements.Remove(canvas); } foreach (ElementBase element in elements) { if (element is CanvasElement) { continue; } this.reportDesigner1.CanvasElement.Elements.Add(element); } this.reportDesigner1.CanvasElement.ShowGrid = false; this.reportDesigner1.PerformLayout(); return(true); }
public void Show(Vector2d position) { tile = (SkyImageTile)TileCache.GetTile(0, 0, 0, layer.ImageSet, null); DivElement picker = Document.GetElementById <DivElement>("histogram"); DivElement closeBtn = Document.GetElementById <DivElement>("histogramClose"); /////////////picker.ClassName = "histogram"; picker.Style.Display = "block"; picker.Style.Left = position.X.ToString() + "px"; picker.Style.Top = position.Y.ToString() + "px"; SelectedCurveStyle = (int)image.lastScale; dropDown = Document.GetElementById <SelectElement>("ScaleTypePicker"); dropDown.AddEventListener("change", CurveStyleSelected, false); dropDown.AddEventListener("click", IgnoreMe, true); CanvasElement canvas = Document.GetElementById <CanvasElement>("graph"); canvas.AddEventListener("mousedown", MouseDown, false); canvas.AddEventListener("mousemove", mousemove, false); canvas.AddEventListener("mouseup", mouseup, false); closeBtn.AddEventListener("click", Close, true); Draw(); }
public virtual void Add (CanvasElement element) { children.Add (element); element.PreferedSizeChanged += OnChildPreferedSizeChanged; element.Parent = this; QueueDraw (); }
public void Do(Point?cursorPosition, Point start, Point end, CanvasElement element, bool applyColour, bool applyCharacter) { var lines = new ScanLines(); lines.AddLine(start, end); var canvas = Handler.CurrentPage.Canvas; Handler.Undo.Save(cursorPosition, cursorPosition, new Rectangle(start, end)); foreach (var row in lines.Values) { var minx = row.Min(); var width = row.Max() - minx + 1; var rect = new Rectangle(minx, row.Row, width, 1); if (applyColour && applyCharacter) { canvas.Fill(rect, element); } else if (applyColour) { canvas.Fill(rect, element.Attribute); } else if (applyCharacter) { canvas.Fill(rect, element.Character); } } Handler.InvalidateCharacterRegion(new Rectangle(start, end), true, false); Handler.Document.IsModified = true; }
static void DrawNote() { CanvasElement canvas = Document.GetElementById <CanvasElement>("canvas"); if (canvas == Global.Undefined) { return; } var ctx = canvas.GetContext(CanvasTypes.CanvasContext2DType.CanvasRenderingContext2D); ctx.FillStyle = "rgb(255,255,255)"; ctx.FillRect(0, 0, 164, 164); ctx.DrawImage(staveImg, 50, 50); var noteY = 20 - note * 5; ctx.DrawImage(noteImg, 50, noteY); // lines above stave for (var lineY = 20; lineY >= noteY; lineY -= 10) { ctx.DrawImage(lineImg, 50, lineY); } // lines below stave for (var lineY = 80; lineY <= noteY; lineY += 10) { ctx.DrawImage(lineImg, 50, lineY); } }
public virtual void Remove (CanvasElement element) { if (children.Remove (element)) { element.Parent = null; element.PreferedSizeChanged -= OnChildPreferedSizeChanged; QueueDraw (); } }
protected void SetChild (CanvasElement child) { this.child = child; child.InputTransparent = true; Add (child); UpdateLayout (); child.PreferedSizeChanged += (sender, e) => UpdateLayout (); }
void Do(Rectangle rect, Point?pos, CanvasElement element) { rect.Normalize(); this.Handler.Undo.Save(pos, pos, rect); this.Handler.CurrentPage.Canvas.Fill(rect, element); this.Handler.InvalidateCharacterRegion(rect, true); }
private static void LoadCanvasContext() { // FIXME: Shouldn't it allow returning canvasElement without a cast?? BridgeTetris.Tetris.canvas = Get("canvas").As <CanvasElement>(); BridgeTetris.Tetris.upcomingPieceCanvas = Get("upcoming").As <CanvasElement>(); BridgeTetris.Tetris.canvasContext = canvas.GetContext(CanvasTypes.CanvasContext2DType.CanvasRenderingContext2D); BridgeTetris.Tetris.upcomingPieceCanvasContext = upcomingPieceCanvas.GetContext(CanvasTypes.CanvasContext2DType.CanvasRenderingContext2D); }
private static void Main(string[] args) { CanvasElement canvas = new CanvasElement("canvas", null, true); CanvasElement gameGUI = new CanvasElement("game-gui", canvas, true); var topGamePanel = new CanvasElement("top-game-panel", gameGUI, true); var menuButton = new CanvasElement("menu-button", topGamePanel, false); var menuButtonText = new CanvasElement("menu-button-text", menuButton, false); InputRaycast.Raycast(menuButtonText); }
public virtual void MakeTexture() { if (PrepDevice != null) { // PrepDevice.pixelStorei(GL.UNPACK_FLIP_Y_WEBGL, 1); try { texture2d = PrepDevice.createTexture(); if (dataset.Extension == ".fits" && RenderContext.UseGlVersion2) { PrepDevice.bindTexture(GL.TEXTURE_2D, texture2d); PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_S, GL.CLAMP_TO_EDGE); PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_T, GL.CLAMP_TO_EDGE); PrepDevice.texImage2D(GL.TEXTURE_2D, 0, GL.R32F, (int)fitsImage.SizeX, (int)fitsImage.SizeY, 0, GL.RED, GL.FLOAT, fitsImage.dataUnit); PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.NEAREST); PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MAG_FILTER, GL.NEAREST); } else { ImageElement image = texture; // Before we bind resize to a power of two if nessesary so we can MIPMAP if (!Texture.IsPowerOfTwo(texture.Height) | !Texture.IsPowerOfTwo(texture.Width)) { CanvasElement temp = (CanvasElement)Document.CreateElement("canvas"); temp.Height = Texture.FitPowerOfTwo(image.Height); temp.Width = Texture.FitPowerOfTwo(image.Width); CanvasContext2D ctx = (CanvasContext2D)temp.GetContext(Rendering.Render2D); ctx.DrawImage(image, 0, 0, temp.Width, temp.Height); //Substitute the resized image image = (ImageElement)(Element)temp; } PrepDevice.bindTexture(GL.TEXTURE_2D, texture2d); PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_S, GL.CLAMP_TO_EDGE); PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_T, GL.CLAMP_TO_EDGE); PrepDevice.texImage2D(GL.TEXTURE_2D, 0, GL.RGBA, GL.RGBA, GL.UNSIGNED_BYTE, image); PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.LINEAR_MIPMAP_NEAREST); PrepDevice.generateMipmap(GL.TEXTURE_2D); } PrepDevice.bindTexture(GL.TEXTURE_2D, null); } catch { errored = true; } } }
private void ResizeIcon_PreviewMouseDown(object sender, MouseButtonEventArgs e) { KMManager.CheckAndCreateNewScheme(); this.mCanvasElement = WpfUtils.FindVisualParent <CanvasElement>(sender as DependencyObject); this.mCanvasElement.mResizeIcon.Focus(); this.startPoint = e.GetPosition((IInputElement)this); this.mCanvas.PreviewMouseMove += new MouseEventHandler(this.CanvasResizeExistingElement_MouseMove); KeymapCanvasWindow.sIsDirty = true; e.Handled = true; Mouse.Capture((IInputElement)this.mCanvas); }
public void BeginRender(float width, float height) { _canvas = (CanvasElement)Browser.Document.CreateElement("canvas"); _canvas.Width = (int)width; _canvas.Height = (int)height; _canvas.Style.Width = width + "px"; _canvas.Style.Height = height + "px"; _context = (CanvasRenderingContext2D)_canvas.GetContext("2d"); _context.TextBaseline = "top"; _context.LineWidth = _lineWidth; }
internal void Init() { if (this.ParentWindow.SelectedConfig?.SelectedControlScheme == null) { return; } int num1 = this.ParentWindow.SelectedConfig?.SelectedControlScheme.GetHashCode().Value; if (this.mOldControlSchemeHashCode == num1) { return; } this.mOldControlSchemeHashCode = num1; this.ClearWindow(); IMConfig selectedConfig = this.ParentWindow.SelectedConfig; int num2; if (selectedConfig == null) { num2 = 0; } else { int?count = selectedConfig.SelectedControlScheme?.GameControls.Count; int num3 = 0; num2 = count.GetValueOrDefault() > num3 & count.HasValue ? 1 : 0; } if (num2 == 0) { return; } foreach (IMAction gameControl in this.ParentWindow.SelectedConfig.SelectedControlScheme.GameControls) { if (!this.IsInOverlayMode || gameControl.IsVisibleInOverlay) { this.AddCanvasElementsForAction(gameControl, true); if (gameControl.Type == KeyActionType.MOBADpad) { (gameControl as MOBADpad).mMOBAHeroDummy = new MOBAHeroDummy(gameControl as MOBADpad); this.AddCanvasElementsForAction((IMAction)(gameControl as MOBADpad).mMOBAHeroDummy, true); } } else if (!gameControl.IsVisibleInOverlay) { List <CanvasElement> canvasElement = CanvasElement.GetCanvasElement(gameControl, this, this.ParentWindow); foreach (UIElement uiElement in canvasElement) { uiElement.Visibility = Visibility.Hidden; } KMManager.listCanvasElement.Add(canvasElement); } } }
static void DrawTest() { CanvasElement canvas = (CanvasElement)Document.GetElementById("canvas"); CanvasContext2D ctx = (CanvasContext2D)canvas.GetContext(Rendering.Render2D); ctx.FillStyle = "rgb(80,0,0)"; ctx.FillRect(120, 120, 165, 160); ctx.FillStyle = "rgba(0, 0, 160, 0.5)"; ctx.FillRect(140, 140, 165, 160); }
public SkillIconToolTipPopup(CanvasElement canvasElement) { this.InitializeComponent(); if (canvasElement.ListActionItem.First <IMAction>().Type == KeyActionType.MOBASkill) { this.PlacementTarget = (UIElement)canvasElement?.mSkillImage; } else { this.PlacementTarget = (UIElement)canvasElement?.mSettingsIcon; } }
public override void Load(Stream fs, CharacterDocument doc, CharacterHandler handler) { Page page = doc.Pages[0]; BinaryReader br = new BinaryReader(fs); Canvas canvas = page.Canvas; ResizeCanvasWidth(fs, doc, canvas); Rectangle rClip = new Rectangle(0, 0, canvas.Width, canvas.Height); Point p = rClip.Location; try { //page.Palette = Palette.GetDefaultPalette (); //page.Font = BitFont.GetStandard8x16 (); CanvasElement ce = new CanvasElement(32, 7); p = rClip.Location; WaitEventArgs args = new WaitEventArgs(); while (true) { doc.OnWait(args); if (args.Exit) { break; } ce.Character = br.ReadByte(); ce.Attribute = br.ReadByte(); if (p.X < canvas.Size.Width && p.Y < canvas.Size.Height) { canvas[p] = ce; } p.X++; if (p.X > rClip.InnerRight) { p.X = rClip.Left; p.Y++; if (p.Y > rClip.InnerBottom) { canvas.ShiftUp(); p.Y = rClip.InnerBottom; } } } } catch (EndOfStreamException) { } ResizeCanvasHeight(doc, canvas, p.Y + 1); }
/// <summary> /// Performs pixel level collision between two masks /// </summary> /// <param name="mask1">The mask1.</param> /// <param name="mask2">The mask2.</param> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <returns></returns> public static bool Collision(string mask1, string mask2, float x, float y) { CanvasElement canvas1 = _masks[mask1]; if (x > canvas1.Width || y > canvas1.Height) { return(false); } CanvasElement canvas2 = _masks[mask2]; if (canvas2.Width + x < 0 || canvas2.Height + y < 0) { return(false); } int top = Math.Round(Math.Max(0, y)); int height = Math.Round(Math.Min(canvas1.Height, y + canvas2.Height) - top); int left = Math.Round(Math.Max(0, x)); int width = Math.Round(Math.Min(canvas1.Width, x + canvas2.Width) - left); if (width <= 0 || height <= 0) { return(false); } CanvasElement checkCanvas = (CanvasElement)Document.CreateElement("Canvas"); checkCanvas.Width = width; checkCanvas.Height = height; CanvasContext2D context = (CanvasContext2D)checkCanvas.GetContext(Rendering.Render2D); context.FillStyle = "white"; context.FillRect(0, 0, checkCanvas.Width, checkCanvas.Height); context.CompositeOperation = CompositeOperation.Xor; context.DrawImage(canvas1, left, top, width, height, 0, 0, width, height); context.DrawImage(canvas2, Math.Round(left - x), Math.Round(top - y), width, height, 0, 0, width, height); PixelArray data = context.GetImageData(0, 0, width, height).Data; for (int i = 0; i < data.Length; i += 4) { if ((int)data[i] > 0) { return(true); } } return(false); }
public SaveArgs(Canvas canvas, Palette palette, Stream stream) { this.canvas = canvas; this.palette = palette; this.stream = stream; x = 0; spacecount = 0; linelength = -1; xposition = 0; element = new CanvasElement(); element.Attribute.Set(7, 0); lastAttr = new Attribute(0, 0); }
private void ShowSvgsInViewPort() { var placeholders = CanvasElement.querySelectorAll("[data-lazy=true]"); foreach (var x in placeholders) { var placeholder = x.As <HtmlElement>(); if (IsElementInViewPort(placeholder)) { placeholder.outerHTML = placeholder.As <dynamic>().svg; } } }
public void InsertChar(int b) { var currentFont = font ?? handler.CurrentPage.Font; if (cursor.X < canvas.Width && b < currentFont.NumChars) { canvas[cursor] = new CanvasElement(b, canvas[cursor].Attribute); if (cursor.X < canvas.Width - 1) { cursor.X++; } OnCursorElementChanged(EventArgs.Empty); } }
public void Insert(CanvasElement ce) { var currentFont = font ?? handler.CurrentPage.Font; if (cursor.X < canvas.Width && ce.Character < currentFont.NumChars) { canvas[cursor] = ce; if (cursor.X < canvas.Width - 1) { cursor.X++; } OnCursorElementChanged(EventArgs.Empty); } }
public FontSettings GetFont(CanvasElement canvasElement) { return(canvasElement switch { CanvasElement.HEADER => HeaderFont, CanvasElement.SUBHEADER => SubHeaderFont, CanvasElement.DISPLAY_NAME => DisplayNameFont, CanvasElement.USERNAME => UsernameFont, CanvasElement.TEXT => MessageTextFont, CanvasElement.TIME => TimeFont, CanvasElement.SHARER_DISPLAY_NAME => SharerDisplayNameFont, CanvasElement.SHARER_USERNAME => SharerUsernameFont, _ => throw new Exception($"{nameof(canvasElement)} does not have settable font settings."), });
public abstract void TexImage2De(uint target, int level, uint internalformat, uint format, uint type, CanvasElement canvas);
public void RemoveElement (CanvasElement element) { rootElement.Remove (element); QueueDraw (); }
void SizeChild (CanvasElement element, double width, double height, bool animate) { if (animate) { element.SizeTo (width, height, 400, Easing.CubicOut); } else { element.SetSize (width, height); } }
public void TexImage2D(uint target, int level, uint internalformat, uint format, uint type, CanvasElement canvas) { }
// Use this for initialization void Awake() { main = this; root = new CanvasElement(transform); }
public void DrawImage(CanvasElement image, float dx, float dy) { }
Cairo.PointD TransformPoint (CanvasElement element, double x, double y) { element.InverseTransform.TransformPoint (ref x, ref y); return new Cairo.PointD (x, y); }
CanvasElement GetInputElementAt (Cairo.Context context, CanvasElement root, double x, double y) { if (root.InputTransparent) return null; var children = root.Children; if (children != null) { // Manual loop to avoid excessive creation of iterators for (int i = children.Count - 1; i >= 0; i--) { var result = GetInputElementAt (context, children[i], x, y); if (result != null) return result; } } context.Save (); root.LayoutOutline (context); var point = TransformPoint (root, x, y); if (context.InFill (point.X, point.Y)) { context.NewPath (); context.Restore (); return root; } context.NewPath (); context.Restore (); return null; }
public void FocusElement (CanvasElement element) { if (element.CanFocus) { FocusedElement = element; } }
public override void TexImage2De(uint target, int level, uint internalformat, uint format, uint type, CanvasElement canvas) { gl.TexImage2D(target, level, internalformat, format, type, canvas); CheckError("texImage2D"); }
void SetPosition (CanvasElement element, double x, double y, bool animate) { if (animate) { element.MoveTo (x, y, 400, Easing.CubicOut); } else { element.X = x; element.Y = y; } }
public Pattern CreatePattern(CanvasElement canvas, string repetition) { return null; }
protected override bool OnButtonReleaseEvent (Gdk.EventButton evnt) { int x = (int)evnt.X; int y = (int)evnt.Y; if (MouseGrabElement != null) { var element = GetInputElementAt (x, y); var point = TransformPoint (MouseGrabElement, x, y); MouseGrabElement.ButtonRelease (new ButtonEventArgs (point.X, point.Y, evnt.XRoot, evnt.YRoot, evnt.Button, evnt.State)); if (element == MouseGrabElement && !dragging) { element.Clicked (point.X, point.Y, evnt.State); if (element.CanFocus) FocusedElement = element; } } dragging = false; MouseGrabElement = null; return true; }
public void DrawImage(CanvasElement image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { }
protected override bool OnFocusInEvent (Gdk.EventFocus evnt) { if (LastFocusedElement != null) FocusedElement = LastFocusedElement; return base.OnFocusInEvent (evnt); }
public void TexSubImage2D(uint target, int level, int xoffset, int yoffset, uint format, uint type, CanvasElement canvas) { }
protected override bool OnFocusOutEvent (Gdk.EventFocus evnt) { if (FocusedElement != null) LastFocusedElement = FocusedElement; FocusedElement = null; return base.OnFocusOutEvent (evnt); }
public ButtonCanvasElement (CanvasElement child) : this () { SetChild (child); }
void RenderElement (Cairo.Context context, CanvasElement element) { element.Canvas = this; context.Transform (element.Transform); element.Render (context); }
void Build () { box = new HBoxCanvasElement (); image = new ImageCanvasElement (Gdk.Pixbuf.LoadFromResource ("searchbox-search-16.png")); image.WidthRequest = 24; image.XAlign = 0; image.NoChainOpacity = true; box.Add (image); searchLabel = new LabelCanvasElement ("Search"); searchLabel.XAlign = 0; searchLabel.YAlign = 0.5; box.Add (searchLabel); var upDownArrows = new CanvasElement (); upDownArrows.WidthRequest = 12; upDownArrows.HeightRequest = 24; upDownArrows.RenderEvent += (sender, e) => { var context = e.Context; double centerX = upDownArrows.Width - 3; double centerY = upDownArrows.Height / 2; context.MoveTo (centerX, centerY - 6); context.LineTo (centerX - 3, centerY - 2); context.LineTo (centerX + 3, centerY - 2); context.ClosePath (); context.MoveTo (centerX, centerY + 6); context.LineTo (centerX - 3, centerY + 2); context.LineTo (centerX + 3, centerY + 2); context.ClosePath (); context.Color = new Cairo.Color (0, 0, 0, 0.35 * upDownArrows.Opacity); context.Fill (); }; image.SizeChanged += (object sender, EventArgs e) => { image.AnchorX = 8; image.AnchorY = image.Height / 2; }; box.Add (upDownArrows); SetChild (box); }
public void AddElement (CanvasElement element) { rootElement.Add (element); QueueDraw (); }