예제 #1
0
        public void Begin(Rect clippingRect)
        {
            if (this.currentClippingRect != clippingRect)
            {
                this.currentClippingRect = clippingRect;

                if (this.isBatchOpen)
                {
                    this.End();
                }

                if (clippingRect.IsEmpty)
                {
                    this.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
                }
                else
                {
                    this.spriteBatch.GraphicsDevice.ScissorRectangle = clippingRect.ToRectangle();

                    this.spriteBatch.Begin(
                        SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, ScissorTestingRasterizerState);
                }

                this.isBatchOpen = true;
            }
        }
예제 #2
0
 private async void OnVisibleBoundsChanged(ApplicationView sender, object args)
 {
     if (_lastVisibleBounds == null || _appView.VisibleBounds.Height != _lastVisibleBounds?.Height || _appView.VisibleBounds.Width != _lastVisibleBounds?.Width)
     {
         await UpdateTriggerAsync(_appView.VisibleBounds.Width < _appView.VisibleBounds.Height).ConfigureAwait(false);
     }
     _lastVisibleBounds = _appView.VisibleBounds;
 }
예제 #3
0
 public NTexture(Texture texture, Rect region)
 {
     root = this;
     nativeTexture = texture;
     _region = region;
     uvRect = new Rect(region.x / nativeTexture.width, 1 - region.yMax / nativeTexture.height,
         region.width / nativeTexture.width, region.height / nativeTexture.height);
 }
예제 #4
0
파일: GUILayout.cs 프로젝트: Joelone/FFWD
 public static bool Button(string text)
 {
     if (currentArea.HasValue)
     {
         Rect r = new Rect(currentArea.Value.x, currentArea.Value.y, currentArea.Value.width, GUI.skin.button.fixedHeight);
         int offset = GUI.skin.button.fixedHeight + GUI.skin.button.margin.bottom;
         currentArea = new Rect(currentArea.Value.x, currentArea.Value.y + offset, currentArea.Value.width, currentArea.Value.height - offset);
         return GUI.Button(r, text);
     }
     return false;
 }
예제 #5
0
파일: GUILayout.cs 프로젝트: Joelone/FFWD
 public static void BeginArea(Rect rect)
 {
     if (!currentArea.HasValue)
     {
         currentArea = rect;
     }
     else
     {
         throw new InvalidOperationException("We already have an area begun");
     }
 }
예제 #6
0
        public NTexture(NTexture root, Rect region)
        {
            this.root = root;
            nativeTexture = root.nativeTexture;

            if (root._region != null)
            {
                region.x += ((Rect)root._region).x;
                region.y += ((Rect)root._region).y;
            }
            _region = region;

            uvRect = new Rect(region.x * root.uvRect.width / nativeTexture.width, 1 - region.yMax * root.uvRect.height / nativeTexture.height,
                region.width * root.uvRect.width / nativeTexture.width, region.height * root.uvRect.height / nativeTexture.height);
        }
예제 #7
0
        /// <summary>
        /// Construct a layer style.
        /// </summary>
        /// <param name="blendFunction">Blend function to use when combining the result of this layer with the previous.</param>
        /// <param name="opacity">The opacity of the layer.</param>
        /// <param name="maskImageProviderResolver">A lazy resolve func that returns the <see cref="IImageProvider" /> based on context sensitive values such as source image size.</param>
        /// <param name="targetArea">If non-empty, positions and scales the layer within the bounds of the preceding one. See <see cref="Lumia.Imaging.Compositing.BlendEffect"/>.</param>
        /// <returns>A layer style.</returns>
        public LayerStyle(BlendFunction blendFunction, double opacity, Func<LayerContext, IImageProvider> maskImageProviderResolver, Rect? targetArea = null)
        {
            BlendFunction = blendFunction;
            Opacity = opacity;
            TargetArea = targetArea;

            if (maskImageProviderResolver != null)
            {
                MaskResolver = context => new MaybeTask<IImageProvider>(maskImageProviderResolver(context));
            }
            else
            {
                MaskResolver = null;
            }
        }
예제 #8
0
        private void CalculateRect()
        {
            if (!_point.HasValue)
            {
                _rect = null;

                return;
            }

            var offsetX = -GlobalData.ResizeRectEdgeLength / 2;
            var offsetY = -GlobalData.ResizeRectEdgeLength / 2;

            var point = _point.Value;

            point.Offset(offsetX, offsetY);

            _rect = new Rect(point, GlobalData.ResizeRectSize);
        }
예제 #9
0
        void DrawUvEditor()
        {
            if (chars == null || Texture == null)
                return;
            GUI.DrawTexture(TextureRect, Texture, ScaleMode.ScaleToFit);
            for (int i = 0; i < chars.Length; i++)
            {
                var c = chars[i];
                var uiRect = UvToUi(c.uv);

                // Handle move & resize
                if (c.index == selectedChar)
                {
                    selectedRect = uiRect;
                    DrawHandles(ref uiRect, ref dragging);
                    if (dragging != GrabCorner.None)
                    {
                        DrawUvSelection(uiRect, c.rotated);
                        // Write back to chars
                        c.uv = UiToUv(uiRect);
                        chars[i] = c;
                        changed = true;
                    }
                }

                // Draw highlight (mouse hover)
                if (dragging == GrabCorner.None)
                {
                    if (c.index == selectedChar || uiRect.Contains(Event.current.mousePosition, true))
                    {
                        DrawUvSelection(uiRect, c.rotated);
                        if (Event.current.type == EventType.mouseDown &&
                            !(selectedRect?.Contains(Event.current.mousePosition, true) ?? false))
                            selectedChar = c.index;
                    }
                    else if (showAll)
                    {
                        GUI.DrawTexture(uiRect, selection);
                    }
                }
            }
        }
예제 #10
0
        public override void OnGUI(Action guiCode, Vector2 padding)
        {
            var rect = GUILayoutUtility.GetRect(0f, 0f);

            if (Event.current.type == EventType.Repaint)
            {
                if (!validRect.HasValue || validRect.Value.y != rect.y)
                {
                    validRect            = rect;
                    pendingLayoutRequest = true;
                }
            }

            if (validRect.HasValue)
            {
                var start = new Rect(validRect.Value.x + padding.x, validRect.Value.y, EditorGUIUtility.currentViewWidth - padding.y, validRect.Value.height);
                using (Begin(start))
                {
                    guiCode();
                }
            }

            GUILayoutUtility.GetRect(width, height);
        }
예제 #11
0
        /// <summary>
        /// Given a chem model, calculates the bounding rectangle in screen space.
        /// </summary>
        /// <param name="model">the model to draw.</param>
        /// <returns>a rectangle in screen space.</returns>
        public Rect CalculateDiagramBounds(IChemModel model)
        {
            var          moleculeSet = model.MoleculeSet;
            IReactionSet reactionSet = model.ReactionSet;

            if ((moleculeSet == null && reactionSet == null))
            {
                return(new Rect());
            }

            Rect?moleculeBounds = null;
            Rect?reactionBounds = null;

            if (moleculeSet != null)
            {
                moleculeBounds = BoundsCalculator.CalculateBounds(moleculeSet);
            }
            if (reactionSet != null)
            {
                reactionBounds = BoundsCalculator.CalculateBounds(reactionSet);
            }

            if (moleculeBounds == null)
            {
                return(this.CalculateScreenBounds(reactionBounds.Value));
            }
            else if (reactionBounds == null)
            {
                return(this.CalculateScreenBounds(moleculeBounds.Value));
            }
            else
            {
                Rect allbounds = Rect.Union(moleculeBounds.Value, reactionBounds.Value);
                return(this.CalculateScreenBounds(allbounds));
            }
        }
예제 #12
0
            public void SetCursorRect(Rect rect)
            {
                var needEnqueue = _queuedCursorRect == null;

                _queuedCursorRect = rect;
                if (needEnqueue)
                {
                    Dispatcher.UIThread.Post(() =>
                    {
                        if (_queuedCursorRect == null)
                        {
                            return;
                        }
                        var rc            = _queuedCursorRect.Value;
                        _queuedCursorRect = null;

                        if (_parent._xic == IntPtr.Zero)
                        {
                            return;
                        }

                        rect *= _parent._scaling;

                        var pt = new XPoint
                        {
                            X = (short)Math.Min(Math.Max(rect.X, short.MinValue), short.MaxValue),
                            Y = (short)Math.Min(Math.Max(rect.Y + rect.Height, short.MinValue), short.MaxValue)
                        };

                        using var spotLoc = new Utf8Buffer(XNames.XNSpotLocation);
                        var list          = XVaCreateNestedList(0, spotLoc, ref pt, IntPtr.Zero);
                        XSetICValues(_parent._xic, XNames.XNPreeditAttributes, list, IntPtr.Zero);
                        XFree(list);
                    }, DispatcherPriority.Background);
                }
            }
예제 #13
0
        private void CentreMouseInsideLookToScrollDeadzone()
        {
            Log.Info("Moving mouse to centre of look to scroll deadzone.");

            Rect?bounds = GetCurrentLookToScrollBoundsRect();

            if (bounds.HasValue)
            {
                Action reinstateModifiers = () => { };
                if (keyStateService.SimulateKeyStrokes &&
                    Settings.Default.SuppressModifierKeysForAllMouseActions)
                {
                    reinstateModifiers = keyStateService.ReleaseModifiers(Log);
                }

                mouseOutputService.MoveTo(GetCurrentLookToScrollCentrePoint(bounds.Value));

                reinstateModifiers();
            }
            else
            {
                Log.Warn("Could not get look to scroll bounds rect. Leaving mouse alone.");
            }
        }
예제 #14
0
        private void DeleteSelected_Clicked(object sender, RoutedEventArgs e)
        {
            inkManager.DeleteSelected();
            strokeList.Clear();

            var strokes = inkManager.GetStrokes();
            strokeList.AddRange(strokes);

            selectionBoundingRect = null;

            needsInkSurfaceValidation = true;

            canvasControl.Invalidate();
        }
예제 #15
0
        internal void Draw(Func <Rect, T, int, int> onDrawCell,
                           Action <int, int, T> onReorder       = null,
                           Action <T, int> OnRightClick         = null,
                           Action <int, int, T> onBeforeReorder = null,
                           Rect?drawRect = null)
        {
            NeedRepaint = false;

            const float scrollW   = 16f;
            var         rect      = drawRect ?? GetGUILayoutViewRect();
            var         hasScroll = (rect.height > 2f) && (GuiRect.height > rect.height);
            var         counter   = 0;
            var         ch        = 0f;

            if (rect.width > 1f)
            {
                rect = rect.xAdd(Theme.RectOffset);

                GuiRect.x     = rect.x;
                GuiRect.y     = rect.y;
                GuiRect.width = rect.width;
            }

            var x = GuiRect.x;
            var y = GuiRect.y;
            var w = GuiRect.width;
            var h = GuiRect.height;

            MousePos = Event.current.mousePosition;

            if (hasScroll)
            {
                ScrollRect     = GuiRect.h(rect.height);
                ScrollPosition = GUI.BeginScrollView(ScrollRect, ScrollPosition, GuiRect.dw(-scrollW), false, true);
            }

            if (Drag.IsDropping)
            {
                HandleDrop(onReorder, onBeforeReorder);
            }
            else if (Drag.IsDragging)
            {
                HandleDrag();
            }
            if (CacheList == null)
            {
                return;
            }

            for (int i = 0; i < CacheList.Count; i++)               //layout
            {
                T   item  = CacheList[i];
                var info  = GetInfo(item).SetWidth(w - (hasScroll ? scrollW : 0)).SetX(x);
                var first = info.CurrentRect.height == 0;

                if (first)
                {
                    info.SetY(y);                    //.SetHeight(Theme.CellHeight);
                }
                info.AnimateStep();

                if (!Drag.IsDragging)
                {
                    if (Drag.IsDropping && counter == Drag.DropIdx)
                    {
                        if (item != Drag.Target)
                        {
                            LIInfo animx = Drag.Info;
                            animx.TweenY(y + ch);
                            ch += animx.CurrentRect.height;
                        }
                    }

                    if (item != Drag.Target)
                    {
                        if (Event.current.type == EventType.layout)
                        {
                            info.SetY(y + ch);
                        }
                        else
                        {
                            info.TweenY(y + ch);
                        }
                    }
                }

                if (item == Drag.Target)
                {
                    continue;
                }
                int newH = DrawCell(i != Drag.DragIdx ? onDrawCell : null,
                                    info.CurrentRect,
                                    item,
                                    (Drag.Target != null && counter >= Drag.DropIdx) ? counter + 1 : counter);                                     //!(info.Selected==true)
                if (newH > 0)
                {
                    if (first)
                    {
                        info.SetHeight(newH);
                    }
                    else
                    {
                        info.TweenH(newH);
                    }
                }

                if (info.IsAnimate && !NeedRepaint)
                {
                    NeedRepaint = true;
                }

                if (!Drag.IsDragging && !Drag.IsDropping)
                {
                    if (info.CanDrag && info.CurrentRect.w(30f).h(20f).xLMB_isDown().noModifier)
                    {
                        StartDrag(i);
                    }
                    else if (info.Selected != null && info.CurrentRect.xLMB_isDown().noModifier)
                    {
                        info.Selected = !info.Selected;
                    }

                    if (OnRightClick != null && info.CurrentRect.xRMB_isDown().noModifier)
                    {
                        OnRightClick(item, i);
                    }
                }

                ch += info.CurrentRect.height;
                counter++;
            }

            if (Drag.IsDragging)
            {
                ch += Drag.Info.CurrentRect.height;
            }

            if (ch != h && ch > 0)
            {
                GuiRect.height = ch;
                NeedRepaint    = true;
            }

            if (Drag.Target != null)
            {
                LIInfo dragRect = Drag.Info;
                int    newH     = DrawCell(onDrawCell,
                                           Drag.IsDragging ? MouseDragRect : dragRect.CurrentRect,
                                           (T)Drag.Target,
                                           Drag.DropIdx);
                if (newH > 0)
                {
                    dragRect.SetHeight(newH);
                }
            }

            if (hasScroll)
            {
                GUI.EndScrollView();
            }
        }
예제 #16
0
        private void DrawScrollContents(params GUILayoutOption[] options)
        {
            var eventType = Event.current.type;

            var isRepaintEvent = eventType == EventType.Repaint;

            var horizontalScrollBarStyle = HideHorizontalScrollBar ? GUIStyle.none : GetHorizontalScrollBarStyle();

            var verticalScrollBarStyle = HideVerticalScrollBar ? GUIStyle.none : GetVerticalScrollBarStyle();

            // スクロール領域計測用.
            using (var scrollViewLayoutScope = new EditorGUILayout.VerticalScope())
            {
                using (var scrollViewScope = new EditorGUILayout.ScrollViewScope(
                           ScrollPosition, AlwaysShowHorizontalScrollBar, AlwaysShowVerticalScrollBar,
                           horizontalScrollBarStyle, verticalScrollBarStyle, GUIStyle.none, options))
                {
                    var scrollPosition = scrollViewScope.scrollPosition;

                    if (eventType == EventType.Layout)
                    {
                        switch (Type)
                        {
                        case Direction.Horizontal:
                            LayoutHorizontal(scrollPosition);
                            break;

                        case Direction.Vertical:
                            LayoutVertical(scrollPosition);
                            break;
                        }
                    }

                    using (GetScrollDirectionScope())
                    {
                        GUILayout.Space(startSpace);

                        for (var i = 0; i < itemInfos.Length; i++)
                        {
                            if (startIndex.HasValue && i < startIndex.Value)
                            {
                                continue;
                            }

                            if (endIndex.HasValue && endIndex.Value < i)
                            {
                                continue;
                            }

                            var drawContent = true;

                            if (isRepaintEvent)
                            {
                                var prevItemInfo = itemInfos.ElementAtOrDefault(i - 1);

                                if (prevItemInfo != null && prevItemInfo.rect.HasValue)
                                {
                                    var contentArea = new Rect()
                                    {
                                        xMin = ScrollPosition.x - LayoutMargin,
                                        xMax = ScrollPosition.x + scrollViewLayoutScope.rect.width + LayoutMargin,
                                        yMin = ScrollPosition.y - LayoutMargin,
                                        yMax = ScrollPosition.y + scrollViewLayoutScope.rect.height + LayoutMargin,
                                    };

                                    var isContentAreaOver = contentArea.yMax < prevItemInfo.rect.Value.yMin;

                                    // 描画領域外は描画しない.
                                    if (isContentAreaOver)
                                    {
                                        drawContent = false;
                                    }
                                }
                            }

                            // リストアイテム領域計測用.
                            using (new EditorGUILayout.VerticalScope())
                            {
                                if (drawContent)
                                {
                                    DrawContent(i, itemInfos[i].content);
                                }
                            }

                            if (isRepaintEvent)
                            {
                                itemInfos[i].rect = GUILayoutUtility.GetLastRect();
                            }
                        }

                        GUILayout.Space(endSpace);
                    }

                    ScrollPosition = scrollPosition;
                }
            }

            if (isRepaintEvent)
            {
                scrollRect = GUILayoutUtility.GetLastRect();
            }
        }
예제 #17
0
        public static bool GetWindowProps(Window window)
        {
            try
            {
                var handle = window.Handle;

                window.Title = GetWindowTitle(handle);

                window.Class = GetClassName(handle);

                Rect?windowRect = null;

                if (Win32.GetWindowRect(handle, out Rect rect))
                {
                    windowRect = rect;
                }

                if (Win32.GetWindowPlacement(handle, out WindowPlacement windowPlacement))
                {
                    switch (windowPlacement.showCmd)
                    {
                    case SW.SHOWMINIMIZED:
                        window.OsVisibility     = Visibility.Minimized;
                        window.RectangleCurrent = null;
                        window.Rectangle        = windowPlacement.normalPosition.GetRectangleFromRect();
                        break;

                    case SW.SHOWMAXIMIZED:
                        window.OsVisibility = Visibility.Maximised;
                        if (windowRect.HasValue)
                        {
                            window.RectangleCurrent = windowRect.Value.GetRectangleFromRect();
                        }
                        window.Rectangle = windowPlacement.normalPosition.GetRectangleFromRect();
                        break;

                    default:
                        var isVisible = Win32.IsWindowVisible(handle);
                        if (isVisible)
                        {
                            window.OsVisibility = Visibility.Normal;
                            if (windowRect.HasValue)
                            {
                                window.RectangleCurrent = windowRect.Value.GetRectangleFromRect();
                            }
                            window.Rectangle = windowPlacement.normalPosition.GetRectangleFromRect();
                        }
                        else
                        {
                            window.OsVisibility = Visibility.None;
                            window.Rectangle    = null;
                        }
                        break;
                    }
                    if (window.OsVisibility == Visibility.Normal && (window.Rectangle == null || window.Rectangle.Width() <= 0 || window.Rectangle.Height() <= 0))
                    {
                        window.OsVisibility = Visibility.None;
                    }
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #18
0
 private void ClearSelection()
 {
     selectionPolylinePoints = null;
     selectionBoundingRect = null;
 }
        private static void CustomWidthLine(int width, int height, BitmapContext context, float x1, float y1, float x2, float y2, float lineWidth, Int32 color, Rect?clipRect = null)
        {
            // Perform cohen-sutherland clipping if either point is out of the viewport
            //if (!CohenSutherlandLineClip(clipRect ?? new Rect(0, 0, width, height), ref x1, ref y1, ref x2, ref y2)) return;

            if (lineWidth <= 0)
            {
                return;
            }

            var buffer = context.Pixels;

            if (y1 > y2)
            {
                Swap(ref x1, ref x2);
                Swap(ref y1, ref y2);
            }

            if (x1 == x2)
            {
                x1 -= (int)lineWidth / 2;
                x2 += (int)lineWidth / 2;

                if (x1 < 0)
                {
                    x1 = 0;
                }
                if (x2 < 0)
                {
                    return;
                }

                if (x1 >= width)
                {
                    return;
                }
                if (x2 >= width)
                {
                    x2 = width - 1;
                }

                if (y1 >= height || y2 < 0)
                {
                    return;
                }

                if (y1 < 0)
                {
                    y1 = 0;
                }
                if (y2 >= height)
                {
                    y2 = height - 1;
                }

                for (var x = (int)x1; x <= x2; x++)
                {
                    for (var y = (int)y1; y <= y2; y++)
                    {
                        var a = (byte)((color & 0xff000000) >> 24);
                        var r = (byte)((color & 0x00ff0000) >> 16);
                        var g = (byte)((color & 0x0000ff00) >> 8);
                        var b = (byte)((color & 0x000000ff) >> 0);

                        buffer[y * width + x] = (a << 24) | (r << 16) | (g << 8) | (b << 0);
                    }
                }

                return;
            }
            if (y1 == y2)
            {
                if (x1 > x2)
                {
                    Swap(ref x1, ref x2);
                }

                y1 -= (int)lineWidth / 2;
                y2 += (int)lineWidth / 2;

                if (y1 < 0)
                {
                    y1 = 0;
                }
                if (y2 < 0)
                {
                    return;
                }

                if (y1 >= height)
                {
                    return;
                }
                if (y2 >= height)
                {
                    y2 = height - 1;
                }

                if (x1 >= width || y2 < 0)
                {
                    return;
                }

                if (x1 < 0)
                {
                    x1 = 0;
                }
                if (x2 >= width)
                {
                    x2 = width - 1;
                }

                for (var x = (int)x1; x <= x2; x++)
                {
                    for (var y = (int)y1; y <= y2; y++)
                    {
                        var a = (byte)((color & 0xff000000) >> 24);
                        var r = (byte)((color & 0x00ff0000) >> 16);
                        var g = (byte)((color & 0x0000ff00) >> 8);
                        var b = (byte)((color & 0x000000ff) >> 0);


                        buffer[y * width + x] = (a << 24) | (r << 16) | (g << 8) | (b << 0);
                    }
                }

                return;
            }

            y1 += 1;
            y2 += 1;

            float slope  = (y2 - y1) / (x2 - x1);
            float islope = (x2 - x1) / (y2 - y1);

            float m = slope;
            float w = lineWidth;

            float dx = x2 - x1;
            float dy = y2 - y1;

            var xtot = (float)(w * dy / Math.Sqrt(dx * dx + dy * dy));
            var ytot = (float)(w * dx / Math.Sqrt(dx * dx + dy * dy));

            float sm = dx * dy / (dx * dx + dy * dy);

            // Center it.

            x1 += xtot / 2;
            y1 -= ytot / 2;
            x2 += xtot / 2;
            y2 -= ytot / 2;

            //
            //

            float sx = -xtot;
            float sy = +ytot;

            var ix1 = (int)x1;
            var iy1 = (int)y1;

            var ix2 = (int)x2;
            var iy2 = (int)y2;

            var ix3 = (int)(x1 + sx);
            var iy3 = (int)(y1 + sy);

            var ix4 = (int)(x2 + sx);
            var iy4 = (int)(y2 + sy);

            if (ix1 == ix2)
            {
                ix2++;
            }
            if (ix3 == ix4)
            {
                ix4++;
            }

            if (lineWidth == 2)
            {
                if (Math.Abs(dy) < Math.Abs(dx))
                {
                    if (x1 < x2)
                    {
                        iy3 = iy1 + 2;
                        iy4 = iy2 + 2;
                    }
                    else
                    {
                        iy1 = iy3 + 2;
                        iy2 = iy4 + 2;
                    }
                }
                else
                {
                    ix1 = ix3 + 2;
                    ix2 = ix4 + 2;
                }
            }

            int starty = Math.Min(Math.Min(iy1, iy2), Math.Min(iy3, iy4));
            int endy   = Math.Max(Math.Max(iy1, iy2), Math.Max(iy3, iy4));

            if (starty < 0)
            {
                starty = -1;
            }
            if (endy >= height)
            {
                endy = height + 1;
            }

            for (int y = starty + 1; y < endy - 1; y++)
            {
                leftEdgeX[y]  = -1 << 16;
                rightEdgeX[y] = 1 << 16 - 1;
            }


            AALineQ1(width, height, context, ix1, iy1, ix2, iy2, color, sy > 0, false);
            AALineQ1(width, height, context, ix3, iy3, ix4, iy4, color, sy < 0, true);

            if (lineWidth > 1)
            {
                AALineQ1(width, height, context, ix1, iy1, ix3, iy3, color, true, sy > 0);
                AALineQ1(width, height, context, ix2, iy2, ix4, iy4, color, false, sy < 0);
            }

            if (x1 < x2)
            {
                if (iy2 >= 0 && iy2 < height)
                {
                    rightEdgeX[iy2] = Math.Min(ix2, rightEdgeX[iy2]);
                }
                if (iy3 >= 0 && iy3 < height)
                {
                    leftEdgeX[iy3] = Math.Max(ix3, leftEdgeX[iy3]);
                }
            }
            else
            {
                if (iy1 >= 0 && iy1 < height)
                {
                    rightEdgeX[iy1] = Math.Min(ix1, rightEdgeX[iy1]);
                }
                if (iy4 >= 0 && iy4 < height)
                {
                    leftEdgeX[iy4] = Math.Max(ix4, leftEdgeX[iy4]);
                }
            }

            //return;

            for (int y = starty + 1; y < endy - 1; y++)
            {
                leftEdgeX[y]  = Math.Max(leftEdgeX[y], 0);
                rightEdgeX[y] = Math.Min(rightEdgeX[y], width - 1);

                for (int x = leftEdgeX[y]; x <= rightEdgeX[y]; x++)
                {
                    var a = (byte)((color & 0xff000000) >> 24);
                    var r = (byte)((color & 0x00ff0000) >> 16);
                    var g = (byte)((color & 0x0000ff00) >> 8);
                    var b = (byte)((color & 0x000000ff) >> 0);

                    buffer[y * width + x] = (a << 24) | (r << 16) | (g << 8) | (b << 0);
                }
            }
        }
예제 #20
0
		protected void SetScreenDetectionArea(Rect rect)
		{
			_screenDetectionArea = rect;
		}
예제 #21
0
파일: ReactDebugger.cs 프로젝트: s76/testAI
    void OnDrawWindows()
    {
        if (toolWindowRect == null) {
            toolWindowRect = new Rect (window.position.width - 340, 64, 0, 0);
        }
        if (toolWindowRect.Value.x > window.position.width - 10) {
            toolWindowRect = new Rect (window.position.width - 340, 64, 0, 0);
        }
        if (toolWindowRect.Value.yMax < 0) {
            toolWindowRect = new Rect (window.position.width - 340, 64, 0, 0);
        }

        toolWindowRect = GUILayout.Window (1, toolWindowRect.Value, DrawToolWindow, "Inspector", GUILayout.MinHeight (420), GUILayout.Width (256));
    }
예제 #22
0
        private void HoverPopupMouseMove(object sender, MouseEventArgs e)
        {
            Point currentPosition = e.GetPosition(this.Child);

            if (this.hoverRect == null)
            {
                Point p1 = new Point(Math.Min(0, currentPosition.X),
                    Math.Min(0, currentPosition.Y));

                Point p2 = new Point(Math.Max(this.layoutGrid.ActualWidth, currentPosition.X),
                    Math.Max(this.layoutGrid.ActualHeight, currentPosition.Y));

                this.hoverRect = new Rect(p1, p2);
            }
            else
            {
                bool mouseIsHovering = this.hoverRect.Value.Contains(currentPosition);

                if (!mouseIsHovering && this.awayStartTime == null)
                {
                    this.awayStartTime = DateTime.Now;
                    this.awayTimer.Start();
                }
                else if (mouseIsHovering)
                {
                    this.awayTimer.Stop();
                    this.awayStartTime = null;
                }
            }
        }
 /// <summary>
 /// Resets the clip rectangle.
 /// </summary>
 public void ResetClip()
 {
     clip = null;
 }
 /// <summary>
 /// Draws a normal line with a desired stroke thickness
 /// <param name="context">The context containing the pixels as int RGBA value.</param>
 /// <param name="x1">The x-coordinate of the start point.</param>
 /// <param name="y1">The y-coordinate of the start point.</param>
 /// <param name="x2">The x-coordinate of the end point.</param>
 /// <param name="y2">The y-coordinate of the end point.</param>
 /// <param name="color">The color for the line.</param>
 /// <param name="strokeThickness">The stroke thickness of the line.</param>
 /// </summary>
 public static void DrawLineCustom(BitmapContext context, int pixelWidth, int pixelHeight, int x1, int y1, int x2, int y2, int color, int strokeThickness, Rect?clipRect = null)
 {
     CustomWidthLine(pixelWidth, pixelHeight, context, x1, y1, x2, y2, strokeThickness, color, clipRect);
 }
        /// <summary>
        /// Draws a normal line with a desired stroke thickness
        /// <param name="context">The context containing the pixels as int RGBA value.</param>
        /// <param name="x1">The x-coordinate of the start point.</param>
        /// <param name="y1">The y-coordinate of the start point.</param>
        /// <param name="x2">The x-coordinate of the end point.</param>
        /// <param name="y2">The y-coordinate of the end point.</param>
        /// <param name="color">The color for the line.</param>
        /// <param name="strokeThickness">The stroke thickness of the line.</param>
        /// </summary>
        public static void DrawLineCustom(BitmapContext context, int pixelWidth, int pixelHeight, int x1, int y1, int x2, int y2, Color color, int strokeThickness, Rect?clipRect = null)
        {
            var col = ((color.A << 24) | (color.R << 16) | (color.G << 8) | color.B);

            CustomWidthLine(pixelWidth, pixelHeight, context, x1, y1, x2, y2, strokeThickness, col, clipRect);
        }
예제 #26
0
        private Rect? _exitTo; //null

        #endregion Fields

        #region Constructors

        public ChildExitingEventArgs( UIElement child, Rect? exitTo, Rect arrangeRect )
        {
            _child = child;
              _exitTo = exitTo;
              _arrangeRect = arrangeRect;
        }
예제 #27
0
        void GetPageSize(PaginateEventArgs e)
        {
            if (this.pageSize == null)
            {
                PrintPageDescription description = e.PrintTaskOptions.GetPageDescription(
                  (uint)e.CurrentPreviewPageNumber);

                this.pageSize = description.PageSize;
                this.imageableRect = description.ImageableRect;
            }
        }  
예제 #28
0
        public void CalculateBoundaries()
        {
            double topX = double.MaxValue;
            double topY = double.MaxValue;
            double bottomX = double.MinValue;
            double bottomY = double.MinValue;

            foreach (var node in _nodes)
            {
                node.GetBoundaries(ref topX, ref topY, ref bottomX, ref bottomY);
            }

            foreach (var edge in _edges)
            {
                edge.GetBoundaries(ref topX, ref topY, ref bottomX, ref bottomY);
            }

            _boundaries = new Rect(new Point(topX, topY), new Point(bottomX, bottomY));
        }
예제 #29
0
    public static async Task ResizeImage(Windows.Storage.Streams.IRandomAccessStream origin, Windows.Storage.Streams.IRandomAccessStream result, uint maxSize, Rect?croppedRegionRelative = null, Action extractAction = null)
    {
        var clop = croppedRegionRelative ?? new Rect(0, 0, 1, 1);

        var decoder = await BitmapDecoder.CreateAsync(origin);

        var softwareBitmap = await decoder.GetSoftwareBitmapAsync();

        double scale = (double)maxSize / Math.Max(decoder.PixelWidth * clop.Width, decoder.PixelHeight * clop.Height);

        var propset = new BitmapPropertySet
        {
            { "ImageQuality", new BitmapTypedValue(0.5, PropertyType.Single) }
        };
        var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, result);

        encoder.SetSoftwareBitmap(softwareBitmap);

        if (scale >= 1 && !croppedRegionRelative.HasValue)
        {
            extractAction?.Invoke();
            return;
        }
        scale = Math.Min(scale, 0.5);
        encoder.BitmapTransform.ScaledWidth  = (uint)(decoder.PixelWidth * scale);
        encoder.BitmapTransform.ScaledHeight = (uint)(decoder.PixelHeight * scale);
        if (croppedRegionRelative.HasValue)
        {
            encoder.BitmapTransform.Bounds = new BitmapBounds()
            {
                X      = (uint)(clop.X * decoder.PixelWidth * scale),
                Y      = (uint)(clop.Y * decoder.PixelHeight * scale),
                Width  = (uint)(clop.Width * decoder.PixelWidth * scale),
                Height = (uint)(clop.Height * decoder.PixelHeight * scale),
            };
        }
        encoder.IsThumbnailGenerated = false;
        try
        {
            await encoder.FlushAsync();
        }
        catch (Exception ex)
        {
#if DEBUG
            System.Diagnostics.Debug.WriteLine(ex.Message);
            System.Diagnostics.Debug.WriteLine(ex.StackTrace);
#endif
        }
    }
예제 #30
0
            public void DrawDopeSheet(IAnimatableData animatable, IKeyable keyable, Rect rect, float startTime, float length, bool highlightRange)
            {
                this.length     = length;
                this.rect       = rect;
                this.width      = rect.width;
                this.startTime  = startTime;
                this.animatable = animatable;
                this.allCurves  = animatable.GetCurves();
                this.keyable    = keyable;
                var e = Event.current;

                //no curves?
                if (allCurves == null || allCurves.Length == 0)
                {
                    GUI.Label(new Rect(rect.x, rect.y, rect.width, rect.height), "---");
                    return;
                }

                //if flag is true refresh all dopesheets of the same IKeyable
                if (refreshDopeKeys)
                {
                    refreshDopeKeys = false;
                    DopeSheetEditor.RefreshDopeKeysOf(animatable);
                }

                //range graphics
                if (highlightRange && currentTimes.Count > 0)
                {
                    var firstKeyPos = TimeToPos(currentTimes.FirstOrDefault());
                    var lastKeyPos  = TimeToPos(currentTimes.LastOrDefault());

                    if (Mathf.Abs(firstKeyPos - lastKeyPos) > 0)
                    {
                        var rangeRect = Rect.MinMaxRect(firstKeyPos - 8, rect.yMin, lastKeyPos + 8, rect.yMax);
                        rangeRect.xMin = Mathf.Max(rangeRect.xMin, rect.xMin);
                        rangeRect.xMax = Mathf.Min(rangeRect.xMax, rect.xMax);
                        if (rangeRect.width > 5)
                        {
                            GUI.color = EditorGUIUtility.isProSkin ? new Color(0f, 0.5f, 0.5f, 0.4f) : new Color(1, 1, 1, 0.5f);
                            GUI.Box(rangeRect, string.Empty, Slate.Styles.clipBoxStyle);
                            GUI.color = Color.white;
                        }

                        if (preWrapMode != WrapMode.ClampForever)
                        {
                            var r = Rect.MinMaxRect(rect.xMin, rect.yMin, firstKeyPos, rect.yMax);
                            if (r.width > 16)
                            {
                                GUI.color = new Color(1, 1, 1, 0.5f);
                                var r2 = new Rect(0, 0, 16, 16);
                                r2.center = r.center;
                                Texture2D icon = null;
                                if (preWrapMode == WrapMode.Loop)
                                {
                                    icon = Styles.loopIcon;
                                }
                                if (preWrapMode == WrapMode.PingPong)
                                {
                                    icon = Styles.pingPongIcon;
                                }
                                if (icon != null)
                                {
                                    GUI.Box(r2, icon, GUIStyle.none);
                                }
                                GUI.color = Color.white;
                            }
                        }

                        if (postWrapMode != WrapMode.ClampForever)
                        {
                            var r = Rect.MinMaxRect(lastKeyPos, rect.yMin, rect.xMax, rect.yMax);
                            if (r.width > 16)
                            {
                                GUI.color = new Color(1, 1, 1, 0.25f);
                                var r2 = new Rect(0, 0, 16, 16);
                                r2.center = r.center;
                                Texture2D icon = null;
                                if (postWrapMode == WrapMode.Loop)
                                {
                                    icon = Styles.loopIcon;
                                }
                                if (postWrapMode == WrapMode.PingPong)
                                {
                                    icon = Styles.pingPongIcon;
                                }
                                if (icon != null)
                                {
                                    GUI.Box(r2, icon, GUIStyle.none);
                                }
                                GUI.color = Color.white;
                            }
                        }
                    }
                }

                //bg graphics (just a horizontal line)
                GUI.color = new Color(0, 0, 0, 0.1f);
                var center   = rect.y + (rect.height / 2);
                var lineRect = Rect.MinMaxRect(rect.x, center - 1, rect.xMax, center + 1);

                GUI.DrawTexture(lineRect, Slate.Styles.whiteTexture);
                GUI.color = Color.white;

                //selection rect graphics
                if (timeSelectionRect != null)
                {
                    GUI.Box(pixelSelectionRect, string.Empty);
                    GUI.color = new Color(0.5f, 0.5f, 1, 0.25f);
                    GUI.DrawTexture(pixelSelectionRect, Slate.Styles.whiteTexture);
                    GUI.color = Color.white;
                }


                //draw the dopekeys
                var tangentMode = TangentMode.Editable;

                for (var t = 0; t < currentTimes.Count; t++)
                {
                    var time = currentTimes[t];
                    //ignore if out of view range (+- some extra offset)
                    if (time < startTime - 0.1f || time > startTime + length + 0.1f)
                    {
                        continue;
                    }

                    //DopeKey graphics/icon
                    var icon = Slate.Styles.dopeKey;
                    if (Prefs.keyframesStyle == Prefs.KeyframesStyle.PerTangentMode)
                    {
                        tangentMode = tangentModes[t];
                        if (tangentMode != TangentMode.Editable)
                        {
                            if (tangentMode == TangentMode.Smooth)
                            {
                                icon = Slate.Styles.dopeKeySmooth;
                            }
                            if (tangentMode == TangentMode.Constant)
                            {
                                icon = Slate.Styles.dopeKeyConstant;
                            }
                            if (tangentMode == TangentMode.Linear)
                            {
                                icon = Slate.Styles.dopeKeyLinear;
                            }
                        }
                    }

                    var dopeKeyRect = new Rect(0, 0, icon.width, icon.height);
                    dopeKeyRect.center = new Vector2(TimeToPos(time), rect.center.y);
                    var isSelected = t == pickIndex || (rectSelectedIndeces != null && rectSelectedIndeces.Contains(t));
                    GUI.color = isSelected ? new Color(0.6f, 0.6f, 1) : Color.white;
                    GUI.DrawTexture(dopeKeyRect, icon);
                    GUI.color = Color.white;


                    //key value label
                    if (Prefs.showDopesheetKeyValues)
                    {
                        var nextPos        = t < currentTimes.Count - 1 ? TimeToPos(currentTimes[t + 1]) : TimeToPos(length);
                        var valueLabelRect = Rect.MinMaxRect(dopeKeyRect.xMax, rect.yMin - 3, nextPos - dopeKeyRect.width / 2, rect.yMax);
                        if (valueLabelRect.width > 20)
                        {
                            GUI.Label(valueLabelRect, keyLabels[t], Slate.Styles.leftLabel);
                        }
                    }


                    //do the following only if we dont have a rect selection
                    if (timeSelectionRect == null)
                    {
                        //pick the key
                        if (e.type == EventType.MouseDown && dopeKeyRect.Contains(e.mousePosition))
                        {
                            prePickTimes = new List <float>(currentTimes);
                            pickIndex    = t;
                            if (e.clickCount == 2)
                            {
                                keyable.root.currentTime       = time + keyable.startTime;
                                CutsceneUtility.selectedObject = keyable;
                            }
                            e.Use();
                        }

                        //single key context menu
                        if (e.type == EventType.MouseUp && e.button == 1 && dopeKeyRect.Contains(e.mousePosition))
                        {
                            DoSingleKeyContextMenu(e, time, tangentMode);
                            e.Use();
                        }
                    }
                }


                //drag the picked key if any. Shift drags all next to it as well
                if (pickIndex != -1)
                {
                    var controlID = GUIUtility.GetControlID(FocusType.Passive);
                    var eventType = e.GetTypeForControl(controlID);
                    if (eventType == EventType.MouseDrag && e.button == 0)
                    {
                        GUIUtility.hotControl = controlID;
                        var lastTime = currentTimes[pickIndex];
                        var newTime  = PosToTime(e.mousePosition.x);
                        newTime = Mathf.Round(newTime / Prefs.snapInterval) * Prefs.snapInterval;
                        newTime = Mathf.Clamp(newTime, startTime, startTime + length);
                        if (e.shift)
                        {
                            var max = pickIndex > 0 ? currentTimes[pickIndex - 1] + Prefs.snapInterval : startTime;
                            newTime = Mathf.Max(newTime, max);
                            foreach (var time in currentTimes.Where(k => k > lastTime))
                            {
                                var index = currentTimes.IndexOf(time);
                                currentTimes[index] += newTime - lastTime;
                            }
                        }
                        currentTimes[pickIndex] = newTime;
                    }

                    //apply the changes when mouse up and deselect key
                    if (eventType == EventType.MouseUp)
                    {
                        GUIUtility.hotControl = 0;
                        pickIndex             = -1;
                        Apply();
                        e.Use();
                    }
                }



                //Multikey selection, dragging and retiming
                if (pickIndex == -1)
                {
                    var retimeInRect  = Rect.MinMaxRect(pixelSelectionRect.xMin, pixelSelectionRect.yMin, pixelSelectionRect.xMin + 4, pixelSelectionRect.yMax);
                    var retimeOutRect = Rect.MinMaxRect(pixelSelectionRect.xMax - 4, pixelSelectionRect.yMin, pixelSelectionRect.xMax, pixelSelectionRect.yMax);

                    var controlID = GUIUtility.GetControlID(FocusType.Passive);
                    var eventType = e.GetTypeForControl(controlID);

                    if (e.rawType == EventType.MouseDown && !rect.Contains(e.mousePosition))
                    {
                        ResetInteraction();
                    }

                    if (e.type == EventType.MouseDown && rect.Contains(e.mousePosition))
                    {
                        //if no rect selection, start one.
                        if (timeSelectionRect == null)
                        {
                            if (e.button == 0)
                            {
                                selectionStartPos = e.mousePosition.x;
                                e.Use();
                            }
                        }
                        else
                        {
                            //if we have a rect and mouse contains it, initialize original values and keys.
                            if (pixelSelectionRect.Contains(e.mousePosition))
                            {
                                prePickTimes          = new List <float>(currentTimes);
                                startDragTime         = (float)PosToTime(e.mousePosition.x);
                                preScaleSelectionRect = timeSelectionRect.Value;
                                rectSelectedIndeces   = new List <int>();
                                var temp = timeSelectionRect.Value;
                                for (var i = 0; i < currentTimes.Count; i++)
                                {
                                    if (currentTimes[i] >= temp.xMin && currentTimes[i] <= temp.xMax)
                                    {
                                        rectSelectedIndeces.Add(i);
                                    }
                                }

                                isRetiming = e.button == 0 && retimeInRect.Contains(e.mousePosition) || retimeOutRect.Contains(e.mousePosition);
                                e.Use();

                                //if we have a rect, but mouse is outside, clear all and reset values.
                            }
                            else
                            {
                                ResetInteraction();
                                e.Use();
                            }
                        }
                    }


                    //create the selection rect
                    if (eventType == EventType.MouseDrag && selectionStartPos != null)
                    {
                        GUIUtility.hotControl = controlID;
                        var a    = PosToTime(selectionStartPos.Value);
                        var b    = PosToTime(e.mousePosition.x);
                        var xMin = Mathf.Min(a, b);
                        var xMax = Mathf.Max(a, b);
                        xMin = Mathf.Max(xMin, startTime);
                        xMax = Mathf.Min(xMax, startTime + length);
                        timeSelectionRect = Mathf.Abs(a - b) >= 0.001f ? Rect.MinMaxRect(xMin, rect.yMin, xMax, rect.yMax) : (Rect?)null;
                    }

                    //draw the selection rect
                    if (timeSelectionRect != null)
                    {
                        EditorGUIUtility.AddCursorRect(retimeInRect, MouseCursor.ResizeHorizontal);
                        EditorGUIUtility.AddCursorRect(retimeOutRect, MouseCursor.ResizeHorizontal);
                        EditorGUIUtility.AddCursorRect(pixelSelectionRect, MouseCursor.Link);
                        GUI.Box(retimeInRect, string.Empty);
                        GUI.Box(retimeOutRect, string.Empty);
                    }

                    //move/retime the selection rect
                    if (eventType == EventType.MouseDrag && timeSelectionRect != null && e.button == 0 && (startDragTime != null || isRetiming))
                    {
                        GUIUtility.hotControl = controlID;
                        var temp        = timeSelectionRect.Value;
                        var pointerTime = PosToTime(e.mousePosition.x);

                        //retime
                        if (isRetiming)
                        {
                            var retimeIn = Mathf.Abs(pointerTime - temp.x) < Mathf.Abs(pointerTime - temp.xMax);
                            if (retimeIn)
                            {
                                temp.xMin = Mathf.Max(pointerTime, 0);
                            }
                            else
                            {
                                temp.xMax = pointerTime;
                            }

                            foreach (var index in rectSelectedIndeces)
                            {
                                var preTime = prePickTimes[index];
                                var norm    = Mathf.InverseLerp(preScaleSelectionRect.xMin, preScaleSelectionRect.xMax, preTime);
                                currentTimes[index] = Mathf.Lerp(temp.xMin, temp.xMax, norm);
                            }

                            //move
                        }
                        else
                        {
                            if (startDragTime != null)
                            {
                                var delta = pointerTime - (float)startDragTime;
                                if (temp.x + delta >= 0)
                                {
                                    foreach (var index in rectSelectedIndeces)
                                    {
                                        currentTimes[index] += delta;
                                    }
                                    temp.x       += delta;
                                    startDragTime = (float)pointerTime;
                                }
                            }
                        }

                        timeSelectionRect = temp;
                    }

                    //Apply all changes and reset values on MouseUp within or outside the rect
                    if (eventType == EventType.MouseUp)
                    {
                        //mouse up when making a selection
                        if (selectionStartPos != null)
                        {
                            GUIUtility.hotControl = 0;
                            selectionStartPos     = null;
                        }

                        //mouse up when dragging or retiming the existing selection
                        if (timeSelectionRect != null && (startDragTime != null || isRetiming))
                        {
                            GUIUtility.hotControl = 0;
                            Apply();
                            isRetiming    = false;
                            startDragTime = null;
                            if (e.button == 0)
                            {
                                rectSelectedIndeces = null;
                            }
                        }
                    }

                    //Context click
                    if (eventType == EventType.ContextClick && rect.Contains(e.mousePosition))
                    {
                        if (pixelSelectionRect.Contains(e.mousePosition))
                        {
                            DoMultiKeyContextMenu(e);
                            e.Use();
                        }
                        else
                        {
                            DoVoidContextMenu(e);
                            e.Use();
                        }
                    }
                }
            }
 /// <summary>
 /// Resets the clip rectangle.
 /// </summary>
 protected override void ResetClip()
 {
     clip = null;
 }
예제 #32
0
		protected virtual void StopZooming()
		{
			if (zoomRect.HasValue)
			{
				Rect output = Viewport.Output;

				Point p1 = zoomRect.Value.TopLeft.ScreenToViewport(Viewport.Transform);
				Point p2 = zoomRect.Value.BottomRight.ScreenToViewport(Viewport.Transform);
				Rect newVisible = new Rect(p1, p2);
				Viewport.Visible = newVisible;

				zoomRect = null;
				ReleaseMouseCapture();
				RemoveSelectionAdorner();
			}
		}
예제 #33
0
 public MoleculeVisual(Molecule molecule, Rect?bb = null)
 {
     _molecule    = molecule;
     _boundingBox = bb ?? molecule.BoundingBox;
 }
 /// <summary>
 /// Resets the clip rectangle.
 /// </summary>
 public void ResetClip()
 {
     this.clip = null;
 }
예제 #35
0
 public ItemInfo(T content)
 {
     this.content = content;
     rect         = null;
 }
예제 #36
0
		private void OnMouseUp(object sender, MouseButtonEventArgs e) {
			if (isDragging && e.ChangedButton == MouseButton.Left) {
				isDragging = false;
				ReleaseMouseCapture();
				Point endPoint = e.GetPosition(this).Transform(Viewport.Output, Viewport.Visible);

				// focusing on LMB click
				if (endPoint == dragStartPointInVisible) {
					//Keyboard.Focus(Parent as IInputElement);
				}
			}
			else if (isZooming && e.ChangedButton == MouseButton.Left) {
				isZooming = false;
				if (zoomRect.HasValue) {
					Rect output = Viewport.Output;

					Point p1 = zoomRect.Value.TopLeft.Transform(output, Viewport.Visible);
					Point p2 = zoomRect.Value.BottomRight.Transform(output, Viewport.Visible);
					Rect newVisible = new Rect(p1, p2);
					Viewport.Visible = newVisible;

					zoomRect = null;
					ReleaseMouseCapture();
					RemoveSelectionAdorner();
				}
			}
		}
예제 #37
0
        public void CalculateViewport()
        {
            Rect actualView = new Rect(0, 0, this.ActualWidth, this.ActualHeight);

            actualView.Scale(1 / Scale, 1 / Scale);
            actualView.Offset(-this.XViewOffset, -this.YViewOffset);

            _viewport = actualView;
        }
예제 #38
0
        public void End()
        {
            if (this.isBatchOpen)
            {
                this.spriteBatch.End();
                this.currentClippingRect = null;

                this.isBatchOpen = false;
            }
        }
예제 #39
0
파일: GUILayout.cs 프로젝트: Joelone/FFWD
 public static void EndArea()
 {
     currentArea = null;
 }
예제 #40
0
        public Diagram()
        {
            _nodes = new DiagramNodes(this);
            _edges = new DiagramEdges(this);
            _selection = new DiagramSelection(this);

            _itemsInDrawingOrder = new DiagramItemCollection<DiagramItem>(this);

            _nodes.CollectionChanged += NodeCollectionChanged;
            _edges.CollectionChanged += EdgeCollectionChanged;
            _selection.CollectionChanged += SelectionChanged;

            Background = new SolidColorBrush(Colors.Transparent);

            _defaultNodeDrawer = new RectangleNodeDrawer();
            _defaultEdgeDrawer = new LineEdgeDrawer();
            //DefaultLabelDrawer = new BaseLabelDrawer();

            _placedItems = new ObservableCollection<IDiagramPlacedItem>();
            _placedItems.CollectionChanged += new NotifyCollectionChangedEventHandler(CustomChilren_CollectionChanged);

            _mouseManager = new DiagramMouseManager(this);

            _mouseManager.LabelLButtonDblClick += new LabelEventHandler(OnLabelLButtonDblClick);
            _mouseManager.NodeLButtonDblClick += new NodeEventHandler(OnNodeLButtonDblClick);
            _mouseManager.EdgeLButtonDblClick += new EdgeEventHandler(OnEdgeLButtonDblClick);

            _viewport = null;
            _boundaries = null;

            CalculateBoundaries();

            LockRender = false;
            LockRecalc = false;

            _scrollViewer = null;
        }
예제 #41
0
        private void ChooseSubwindowLookToScrollBoundsTarget(Action <bool> callback)
        {
            Log.Info("Choosing a rectangular region of a window to use as the scroll bounds.");

            Action finishUp = () =>
            {
                ResetAndCleanupAfterMouseAction();
                callback(windowLookToScrollBoundsTarget != IntPtr.Zero && !rectLookToScrollBoundsTarget.IsEmpty);
            };

            SetupFinalClickAction(firstCorner =>
            {
                if (firstCorner.HasValue)
                {
                    Log.InfoFormat("User chose {0} as the first corner.", firstCorner.Value);

                    IntPtr firstHWnd = HideCursorAndGetHwndForFrontmostWindowAtPoint(firstCorner.Value);

                    if (firstHWnd == IntPtr.Zero)
                    {
                        Log.Warn("No window was found at the first corner.");
                        audioService.PlaySound(Settings.Default.ErrorSoundFile, Settings.Default.ErrorSoundVolume);
                        finishUp();
                    }
                    else
                    {
                        Log.InfoFormat("Window {0} found at the first corner.", firstHWnd);

                        SetupFinalClickAction(secondCorner =>
                        {
                            if (secondCorner.HasValue)
                            {
                                Log.InfoFormat("User chose {0} as the second corner.", secondCorner.Value);

                                IntPtr secondHWnd = HideCursorAndGetHwndForFrontmostWindowAtPoint(secondCorner.Value);
                                var rect          = new Rect(firstCorner.Value, secondCorner.Value);

                                if (secondHWnd == IntPtr.Zero)
                                {
                                    Log.Warn("No window was found at the second corner.");
                                    audioService.PlaySound(Settings.Default.ErrorSoundFile, Settings.Default.ErrorSoundVolume);
                                }
                                else if (secondHWnd != firstHWnd)
                                {
                                    Log.WarnFormat("Found a different window at the second corner: {0}.", secondHWnd);
                                    audioService.PlaySound(Settings.Default.ErrorSoundFile, Settings.Default.ErrorSoundVolume);
                                }
                                else if (!IsRectLargerThanDeadzone(rect))
                                {
                                    Log.Warn("The chosen rectangle is not large enough to accomodate the deadzone.");
                                    audioService.PlaySound(Settings.Default.ErrorSoundFile, Settings.Default.ErrorSoundVolume);
                                }
                                else
                                {
                                    Rect?windowBounds = GetWindowBounds(firstHWnd);
                                    if (windowBounds.HasValue)
                                    {
                                        // Express the rect relative to the top-left corner of the window so we can deal with possible
                                        // movement of the window later.
                                        rect.Offset(-windowBounds.Value.Left, -windowBounds.Value.Top);

                                        Log.InfoFormat("Selected rect {0} of window {1} as the look to scroll target.", rect, firstHWnd);

                                        windowLookToScrollBoundsTarget = firstHWnd;
                                        rectLookToScrollBoundsTarget   = rect;
                                    }
                                    else
                                    {
                                        Log.Warn("Could not retrieve the bounds of the chosen window.");
                                        audioService.PlaySound(Settings.Default.ErrorSoundFile, Settings.Default.ErrorSoundVolume);
                                    }
                                }
                            }

                            finishUp();
                        }, suppressMagnification: true);
                    }
                }
                else
                {
                    finishUp();
                }
            }, finalClickInSeries: false, suppressMagnification: true);
        }
예제 #42
0
 /// <summary>
 /// Resets the clip rectangle.
 /// </summary>
 public void ResetClip()
 {
     this.clip = null;
 }
 /// <summary>
 /// Sets the clip rectangle.
 /// </summary>
 /// <param name="clippingRect">The clipping rectangle.</param>
 /// <returns>True if the clip rectangle was set.</returns>
 public bool SetClip(OxyRect clippingRect)
 {
     this.clip = clippingRect.ToRect(false);
     return true;
 }
예제 #44
0
        ////////////////////////////////////////////////////////////////////////////////////////////
        private void AddSvgElementToDisplay(SvgElement element)
        {
            // Define the content for our tooltip
            StackPanel tooltipStackPanel = new StackPanel();
            TextBlock  toolTipText       = new TextBlock()
            {
                HorizontalAlignment = HorizontalAlignment.Center
            };

            toolTipText.SetBinding(TextBlock.TextProperty, new Binding(nameof(element.Description))
            {
                Source = element
            });
            tooltipStackPanel.Children.Add(toolTipText);
            element.ToolTipContent = tooltipStackPanel;

            foreach (RectangleElement rectangleElement in element.RectangleElements)
            {
                Rectangle rectangleControl = new Rectangle()
                {
                    Width = rectangleElement.Width, Height = rectangleElement.Height
                };
                rectangleElement.RectangleControl = rectangleControl;
                Canvas.SetLeft(rectangleControl, rectangleElement.PosX);
                Canvas.SetTop(rectangleControl, rectangleElement.PosY);
                rectangleControl.Fill   = rectangleElement.Fill;
                rectangleControl.Stroke = rectangleElement.Stroke;

                rectangleElement.RectangleControl.SetBinding(Shape.StrokeThicknessProperty, new Binding(nameof(StrokeThickness))
                {
                    Source = this
                });
                rectangleControl.MouseLeftButtonDown        += (sender, e) => HandleElementLocked(element);
                rectangleControl.IsMouseDirectlyOverChanged += (sender, e) =>
                {
                    if (!Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
                    {
                        HandleElementSelected(element);
                    }
                };

                // Add our tooltip to the control
                ToolTipService.SetInitialShowDelay(rectangleControl, 0);
                rectangleControl.ToolTip = element.ToolTipContent;

                Map.Children.Add(rectangleElement.RectangleControl);
            }

            foreach (PathElement pathElement in element.PathElements)
            {
                Path pathControl = new Path();
                pathElement.PathControl = pathControl;
                pathControl.Data        = pathElement.PathData;
                pathControl.Fill        = pathElement.Fill;
                pathControl.Stroke      = pathElement.Stroke;

                pathElement.PathControl.SetBinding(Shape.StrokeThicknessProperty, new Binding(nameof(StrokeThickness))
                {
                    Source = this
                });
                pathControl.MouseLeftButtonDown        += (sender, e) => HandleElementLocked(element);
                pathControl.IsMouseDirectlyOverChanged += (sender, e) =>
                {
                    if (!Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
                    {
                        HandleElementSelected(element);
                    }
                };

                // Add our tooltip to the control
                ToolTipService.SetInitialShowDelay(pathControl, 0);
                pathControl.ToolTip = element.ToolTipContent;

                Map.Children.Add(pathElement.PathControl);
            }

            if (!String.IsNullOrEmpty(element.TextData))
            {
                Rect?geometryExtent = element.PathElements.Select((x) => new Nullable <Rect>(x.PathData.Bounds)).FirstOrDefault();
                geometryExtent = geometryExtent ?? element.RectangleElements.Select((x) => new Nullable <Rect>(new Rect(x.PosX, x.PosY, x.Width, x.Height))).FirstOrDefault();
                foreach (PathElement pathElement in element.PathElements)
                {
                    geometryExtent.Value.Union(pathElement.PathData.Bounds);
                }
                foreach (RectangleElement rectangleElement in element.RectangleElements)
                {
                    geometryExtent.Value.Union(new Rect(rectangleElement.PosX, rectangleElement.PosY, rectangleElement.Width, rectangleElement.Height));
                }
                if (geometryExtent != null)
                {
                    double  minExtent = Math.Min(geometryExtent.Value.Width, geometryExtent.Value.Height);
                    Viewbox viewbox   = new Viewbox()
                    {
                        Stretch = Stretch.Uniform, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Width = minExtent, Height = minExtent
                    };
                    Canvas.SetLeft(viewbox, geometryExtent.Value.Left + ((geometryExtent.Value.Width - minExtent) / 2));
                    Canvas.SetTop(viewbox, geometryExtent.Value.Top + ((geometryExtent.Value.Height - minExtent) / 2));
                    TextBlock textBlock = new TextBlock()
                    {
                        Text = element.TextData
                    };
                    viewbox.Child                   = textBlock;
                    element.TextControl             = viewbox;
                    textBlock.RenderTransformOrigin = new Point(0.5, 0.5);
                    textBlock.SetBinding(FrameworkElement.RenderTransformProperty, new Binding(nameof(TextRotateTransform))
                    {
                        Source = this, Mode = BindingMode.OneWay
                    });
                    Map.Children.Add(element.TextControl);
                }
            }
        }
예제 #45
0
		private void UpdateZoomRect(Point zoomEndPoint) {
			Rect output = Viewport.Output;
			Rect tmpZoomRect = new Rect(zoomStartPoint, zoomEndPoint);
			tmpZoomRect = Rect.Intersect(tmpZoomRect, output);

			shouldKeepRatioWhileZooming = IsShiftPressed();
			if (shouldKeepRatioWhileZooming) {
				double currZoomRatio = tmpZoomRect.Width / tmpZoomRect.Height;
				double zoomRatio = output.Width / output.Height;
				if (currZoomRatio < zoomRatio) {
					double oldHeight = tmpZoomRect.Height;
					double height = tmpZoomRect.Width / zoomRatio;
					tmpZoomRect.Height = height;
					if (!tmpZoomRect.Contains(zoomStartPoint)) {
						tmpZoomRect.Offset(0, oldHeight - height);
					}
				}
				else {
					double oldWidth = tmpZoomRect.Width;
					double width = tmpZoomRect.Height * zoomRatio;
					tmpZoomRect.Width = width;
					if (!tmpZoomRect.Contains(zoomStartPoint)) {
						tmpZoomRect.Offset(oldWidth - width, 0);
					}
				}
			}

			zoomRect = tmpZoomRect;
			UpdateSelectionAdorner();
		}
예제 #46
0
 protected void SetScreenDetectionArea(Rect rect)
 {
     _screenDetectionArea = rect;
 }
예제 #47
0
 /// <summary>
 /// Determines if this draw operation equals another.
 /// </summary>
 /// <param name="clip">The clip of the other draw operation.</param>
 /// <returns>True if the draw operations are the same, otherwise false.</returns>
 /// <remarks>
 /// The properties of the other draw operation are passed in as arguments to prevent
 /// allocation of a not-yet-constructed draw operation object.
 /// </remarks>
 public bool Equals(Rect?clip) => Clip == clip;
예제 #48
0
 internal void Init()
 {
     _dataPoints = null;
     _cachedClip = null;
     _viewInfo.Reset();
 }
 /// <summary>
 /// Draws a normal line with a desired stroke thickness
 /// <param name="bmp">The WriteableBitmap.</param>
 /// <param name="x1">The x-coordinate of the start point.</param>
 /// <param name="y1">The y-coordinate of the start point.</param>
 /// <param name="x2">The x-coordinate of the end point.</param>
 /// <param name="y2">The y-coordinate of the end point.</param>
 /// <param name="color">The color for the line.</param>
 /// <param name="strokeThickness">The stroke thickness of the line.</param>
 /// </summary>
 public static void DrawLineCustom(this WriteableBitmap bmp, int x1, int y1, int x2, int y2, int color, int strokeThickness, Rect?clipRect = null)
 {
     using (var context = bmp.GetBitmapContext())
     {
         CustomWidthLine(bmp.PixelWidth, bmp.PixelHeight, context, x1, y1, x2, y2, strokeThickness, color, clipRect);
     }
 }
예제 #50
0
        static void WriteSheetData(MemoryStream target, string csv)
        {
            int numCells     = -1;
            int numUsedCells = -1;

            Rect?[] cellData = null;

            using (StreamReader reader = new StreamReader(csv))
            {
                string line;

                while (!reader.EndOfStream)
                {
                    line = reader.ReadLine();
                    if (string.IsNullOrEmpty(line) || line.StartsWith("#"))
                    {
                        continue;
                    }

                    string[] lineData = line.Trim().Split(';');

                    if (lineData.Length != 5)
                    {
                        Console.WriteLine("Error in csv line: \"" + line + "\"");

                        continue;
                    }

                    int index = Convert.ToInt32(lineData[0]);

                    int x = Convert.ToInt32(lineData[1]);
                    int y = Convert.ToInt32(lineData[2]);

                    int w = Convert.ToInt32(lineData[3]);
                    int h = Convert.ToInt32(lineData[4]);

                    if (index == -1)                     //Special case, contains cell data
                    {
                        numCells     = x;
                        numUsedCells = y;

                        cellData = new Rect?[numCells];
                    }
                    else
                    {
                        cellData[index] = new Rect(x, y, w, h);
                    }
                }
            }

            using (BinaryWriter w = new BinaryWriter(target, Encoding.ASCII, true))
            {
                w.Write((uint)numCells);
                w.Write((uint)numUsedCells);

                int cellsWritten = 0;
                for (int x = 0; x < cellData.Length; x++)
                {
                    Rect?cell = cellData[x];

                    if (cell.HasValue)
                    {
                        w.Write((uint)x);

                        w.Write((uint)cell.Value.X);
                        w.Write((uint)cell.Value.Y);

                        w.Write((uint)cell.Value.Width);
                        w.Write((uint)cell.Value.Height);

                        cellsWritten++;
                    }
                }

                if (cellsWritten != numUsedCells)
                {
                    Console.WriteLine("Invalid cell data! Used cells != Actual cell data");

                    throw new Exception();
                }
            }
        }
        /// <summary>
        /// Draws a normal line with a desired stroke thickness
        /// <param name="bmp">The WriteableBitmap.</param>
        /// <param name="x1">The x-coordinate of the start point.</param>
        /// <param name="y1">The y-coordinate of the start point.</param>
        /// <param name="x2">The x-coordinate of the end point.</param>
        /// <param name="y2">The y-coordinate of the end point.</param>
        /// <param name="color">The color for the line.</param>
        /// <param name="strokeThickness">The stroke thickness of the line.</param>
        /// </summary>
        public static void DrawLineCustom(this WriteableBitmap bmp, int x1, int y1, int x2, int y2, Color color, int strokeThickness, Rect?clipRect = null)
        {
            int intColor = ((color.A << 24) | (color.R << 16) | (color.G << 8) | color.B);

            using (var context = bmp.GetBitmapContext())
            {
                CustomWidthLine(bmp.PixelWidth, bmp.PixelHeight, context, x1, y1, x2, y2, strokeThickness, intColor, clipRect);
            }
        }
예제 #52
0
        static void Unpack(string iex, string dir)
        {
            using (FileStream fs = File.OpenRead(iex))
            {
                using (BinaryReader br = new BinaryReader(fs))
                {
                    while (br.ReadByte() == 0x01)
                    {
                        uint index = br.ReadUInt32();
                        Console.WriteLine("Extracting entry " + index.ToString());

                        uint entryLength     = br.ReadUInt32();
                        uint colorDataLength = br.ReadUInt32();

                        uint dataLengthNoColor = entryLength - colorDataLength - 4;                         //-4 is the color data length

                        //Read color data
                        string outPath = Path.Combine(dir, "Entry_" + index.ToString() + "_color.jpg");
                        using (FileStream cd = new FileStream(outPath, FileMode.Create))
                        {
                            byte[] buf = br.ReadBytes((int)colorDataLength);

                            cd.Write(buf, 0, buf.Length);
                        }

                        //Read middle data
                        uint middleDataLength;

                        outPath = Path.Combine(dir, "Entry_" + index.ToString() + "_spritesheet.csv");
                        using (StreamWriter mid = new StreamWriter(outPath))
                        {
                            uint len1 = br.ReadUInt32();                             //Cell count
                            uint len2 = br.ReadUInt32();                             //Used cells

                            mid.WriteLine("#Index,X,Y,Width,Height");
                            mid.WriteLine("#Cell slots " + len1.ToString());
                            mid.WriteLine("#Used cells " + len2.ToString());
                            mid.WriteLine("-1;" + len1.ToString() + ";" + len2.ToString() + ";-1;-1");

                            middleDataLength = 4 + 4 + (len2 * (4 * 5));

                            Rect?[] cells = new Rect?[len1];

                            for (uint idx = 0; idx < len2; idx++)
                            {
                                uint cellIndex = br.ReadUInt32();
                                uint x         = br.ReadUInt32();
                                uint y         = br.ReadUInt32();
                                uint w         = br.ReadUInt32();
                                uint h         = br.ReadUInt32();

                                cells[cellIndex] = new Rect((int)x, (int)y, (int)w, (int)h);
                            }

                            mid.WriteLine("#Cell data");
                            for (int x = 0; x < cells.Length; x++)
                            {
                                Rect?rv = cells[x];

                                if (!rv.HasValue)
                                {
                                    continue;
                                }

                                Rect r = rv.Value;

                                mid.WriteLine(x.ToString() + ";" + r.X.ToString() + ";" + r.Y.ToString() + ";" + r.Width.ToString() + ";" + r.Height.ToString());
                            }
                        }

                        //Alpha data stars here
                        uint alphaDataLength = dataLengthNoColor - middleDataLength;

                        //Read alpha data
                        outPath = Path.Combine(dir, "Entry_" + index.ToString() + "_alpha.jpg");
                        using (FileStream cd = new FileStream(outPath, FileMode.Create))
                        {
                            byte[] buf = br.ReadBytes((int)alphaDataLength);

                            cd.Write(buf, 0, buf.Length);
                        }
                    }
                }
            }
        }
예제 #53
0
 void OnPrintTaskCompleted(PrintTask sender, PrintTaskCompletedEventArgs args)
 {
     this.pageSize = null;
     this.imageableRect = null;
     this.document = null;
     this.pages = null;
 } 
예제 #54
0
        public void Draw(int windowID)
        {
            if (!this.backupRect.HasValue)
            {
                this.backupRect = new Rect?(this.rect);
            }
            if (this.isClose)
            {
                return;
            }
            this.CloseButton();
            GUIDrawer.Window.Type type = this.type;
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            GUIDrawer.Window.\u003CDraw\u003Ec__AnonStorey0 drawCAnonStorey0 = new GUIDrawer.Window.\u003CDraw\u003Ec__AnonStorey0();
            // ISSUE: reference to a compiler-generated field
            drawCAnonStorey0.\u0024this = this;
            switch (type)
            {
            case GUIDrawer.Window.Type.None:
                this.DoWindow(-1);
                break;

            case GUIDrawer.Window.Type.Normal:
            case GUIDrawer.Window.Type.Layout:
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated method
                drawCAnonStorey0.doWindow = new Action <int>(drawCAnonStorey0.\u003C\u003Em__0);
                if (this.type == GUIDrawer.Window.Type.Normal || this.isHide)
                {
                    if (this.isHide)
                    {
                        ((Rect) ref this.rect).set_height(50f);
                    }
                    // ISSUE: method pointer
                    this.rect = GUI.Window(windowID, this.rect, new GUI.WindowFunction((object)drawCAnonStorey0, __methodptr(\u003C\u003Em__1)), this.title);
                }
                else
                {
                    // ISSUE: method pointer
                    this.rect = GUILayout.Window(windowID, this.rect, new GUI.WindowFunction((object)drawCAnonStorey0, __methodptr(\u003C\u003Em__2)), this.title, (GUILayoutOption[])Array.Empty <GUILayoutOption>());
                }
                this.HideButton();
                break;

            case GUIDrawer.Window.Type.Custom:
                Rect rect = this.rect;
                using (new GUILayout.AreaScope(rect))
                {
                    GUIContent guiContent = new GUIContent(this.title);
                    using (new GUILayout.VerticalScope(GUIStyle.op_Implicit("box"), (GUILayoutOption[])Array.Empty <GUILayoutOption>()))
                    {
                        if (GUILayout.RepeatButton(guiContent, new GUILayoutOption[2]
                        {
                            GUILayout.ExpandWidth(true),
                            GUILayout.ExpandHeight(false)
                        }))
                        {
                            float y = (float)new GUIStyle().CalcSize(guiContent).y;
                            ((Rect) ref this.rect).set_x((float)(Input.get_mousePosition().x - (double)((Rect) ref rect).get_width() * 0.5));
                            ((Rect) ref this.rect).set_y((float)((double)Screen.get_height() - Input.get_mousePosition().y - (double)y * 0.5));
                        }
                        this.DoWindow(-1);
                        break;
                    }
                }
            }
        }
예제 #55
0
        private void UnprocessedInput_PointerReleased(InkUnprocessedInput sender, Windows.UI.Core.PointerEventArgs args)
        {
            selectionPolylinePoints.Add(args.CurrentPoint.RawPosition);

            selectionBoundingRect = inkManager.SelectWithPolyLine(selectionPolylinePoints);

            selectionPolylinePoints = null;

            canvasControl.Invalidate();
        }
예제 #56
0
        private Rect?GetViewSpanRect(ITrackingSpan viewSpan)
        {
            var view = WpfTextView;

            if (view == null || view.TextViewLines == null || view.IsClosed)
            {
                return(null);
            }

            SnapshotSpan visualSpan = viewSpan.GetSpan(view.TextSnapshot);

            Rect?spanRectangle = null;

            if (visualSpan.Length > 0)
            {
                double left   = double.MaxValue;
                double top    = double.MaxValue;
                double right  = double.MinValue;
                double bottom = double.MinValue;

                var bounds = view.TextViewLines.GetNormalizedTextBounds(visualSpan);
                foreach (var bound in bounds)
                {
                    left   = Math.Min(left, bound.Left);
                    top    = Math.Min(top, bound.TextTop);
                    right  = Math.Max(right, bound.Right);
                    bottom = Math.Max(bottom, bound.TextBottom + ToolTipVerticalOffset);
                }

                // If the start of the span lies within the view, use that instead of the left-bound of the span as a whole.
                // This will cause popups to be left-aligned with the start of their span, if at all possible.
                var startLine = view.TextViewLines.GetTextViewLineContainingBufferPosition(visualSpan.Start);
                if (startLine != null)
                {
                    var startPointBounds = startLine.GetExtendedCharacterBounds(visualSpan.Start);
                    if ((startPointBounds.Left < right) &&
                        (startPointBounds.Left >= view.ViewportLeft) &&
                        (startPointBounds.Left < view.ViewportRight))
                    {
                        left = startPointBounds.Left;
                    }
                }

                //Special case handling for when the end of the span is at the start of a line.
                ITextViewLine line = view.TextViewLines.GetTextViewLineContainingBufferPosition(visualSpan.End);
                if ((line != null) && (line.Start == visualSpan.End))
                {
                    bottom = Math.Max(bottom, line.TextBottom + ToolTipVerticalOffset);
                }

                if (left < right)
                {
                    spanRectangle = new Rect(left, top, right - left, bottom - top);
                }
            }
            else
            {
                // visualSpan is zero length so the default MarkerGeometry will be null. Create a custom marker geometry based on
                // the location.
                ITextViewLine line = view.TextViewLines.GetTextViewLineContainingBufferPosition(visualSpan.Start);
                if (line != null)
                {
                    TextBounds bounds = line.GetCharacterBounds(visualSpan.Start);
                    spanRectangle = new Rect(bounds.Left, bounds.TextTop, 0.0, bounds.TextHeight + ToolTipVerticalOffset);
                }
            }

            if (spanRectangle.HasValue && !spanRectangle.Value.IsEmpty)
            {
                //Get the portion of the span geometry that is inside the view.
                Rect viewRect = new Rect(view.ViewportLeft,
                                         view.ViewportTop,
                                         view.ViewportWidth,
                                         view.ViewportHeight);

                Rect spanRect = spanRectangle.Value;
                spanRect.Intersect(viewRect);

                Rect spanRectInScreenCoordinates =
                    new Rect(this.GetScreenPointFromTextXY(spanRect.Left, spanRect.Top),
                             this.GetScreenPointFromTextXY(spanRect.Right, spanRect.Bottom));

                return(spanRectInScreenCoordinates);
            }

            return(null);
        }
예제 #57
0
        private void DeleteSelected_Clicked(object sender, RoutedEventArgs e)
        {
            inkManager.DeleteSelected();

            selectionBoundingRect = null;

            needToRedrawInkSurface = true;

            canvasControl.Invalidate();
        }
예제 #58
0
 public ChildExitingEventArgs(UIElement child, Rect?exitTo, Rect arrangeRect)
 {
     Child       = child;
     ExitTo      = exitTo;
     ArrangeRect = arrangeRect;
 }
예제 #59
0
        public static void NamedConstantGroupMaskPopup(SerializedObject serializedObject, string label, string propertyName, NamedConstants constants, string groupName, Rect?position)
        {
            if (constants == null)
            {
                EditorGUILayout.LabelField(label, "<missing constants>");
                return;
            }

            var property = serializedObject.FindProperty(propertyName);
            var values   = constants.GetGroup(groupName);
            var labels   = values.Select(x => x.Name).ToArray();

            if (position == null)
            {
                property.intValue = EditorGUILayout.MaskField(label, property.intValue, labels);
            }
            else
            {
                property.intValue = EditorGUI.MaskField(position.Value, label, property.intValue, labels);
            }
        }
 /// <summary>
 /// Sets the clipping rectangle.
 /// </summary>
 /// <param name="clippingRect">The clipping rectangle.</param>
 /// <returns><c>true</c> if the clip rectangle was set.</returns>
 protected override void SetClip(OxyRect clippingRect)
 {
     clip = ToRect(clippingRect);
 }