Пример #1
0
        public Game()
        {
            InitializeComponent();
            _gameTime = new GameTime();
            Keyboard  = new Keyboard();

            _timer          = new Timer();
            _timer.Interval = 1000 / 30;
            _timer.Tick    += (sender, e) =>
            {
                var _now = DateTime.Now;
                _gameTime.FrameMilliseconds = (int)(_now - _gameTime.FrameDate).TotalMilliseconds;
                _gameTime.FrameDate         = _now;

                Application.DoEvents();
                this.Update(_gameTime);  //запустить логику
                this.Keyboard.Clear();

                using (DrawHandler drawHandler = new DrawHandler(this.Canvas.Width, this.Canvas.Height))
                {
                    this.Draw(drawHandler);               //обновить изображение в каждом кадре
                    Canvas.Image = drawHandler.BaseImage; // присваиваем изображение нового блока картинному блоку
                }
            };

            _timer.Start(); // начало игры
        }
        VisitStatus VisitPrimitive <TContainer, TValue, TElement>(
            IProperty <TContainer> property,
            ref TValue value,
            DrawHandler <TContainer, TValue, TElement> handler
            )
        {
            Visitor.AddToPath(property);
            try
            {
                var path = Visitor.GetCurrentPath();

                var inspector = AllowInspector ? GetPropertyDrawer <TValue>(property, Visitor.VisitorContext.Root, path) : null;
                NoReentrace = true;
                if (null == inspector)
                {
                    handler(property, ref value, path, VisitorContext);
                }
                else
                {
                    var customInspector = new CustomInspectorElement(path, inspector, Visitor.VisitorContext.Root);
                    Visitor.VisitorContext.Parent.contentContainer.Add(customInspector);
                }
            }
            finally
            {
                Visitor.RemoveFromPath(property);
                NoReentrace = false;
            }
            return(VisitStatus.Stop);
        }
Пример #3
0
        private bool draw_contour_first = false;        // First contour point coordinates

        private MainView()
        {
            instance       = this;
            imageHandler   = ImageHandler.Instance;
            drawHandler    = DrawHandler.Instance;
            contourHandler = ContourHandler.Instance;
            InitializeComponent();

            // Disable all buttons while no image is loaded
            saveFileButton.Enabled     = false;
            fishlineButton.Enabled     = false;
            zoomInButton.Enabled       = false;
            zoomOutButton.Enabled      = false;
            zoomWidthButton.Enabled    = false;
            contourButton.Enabled      = false;
            contourListButton.Enabled  = false;
            zoomOriginalButton.Enabled = false;
            openContourListToolStripMenuItem.Enabled = false;
            saveContourToolStripMenuItem.Enabled     = false;
            loadContourToolStripMenuItem.Enabled     = false;
            boneTypeBox.Visible          = false;
            customFishlineButton.Enabled = false;

            openFileDialog1 = new OpenFileDialog();
        }
Пример #4
0
 private void Start()
 {
     canvas          = transform.parent.gameObject;
     canvasDims      = canvas.GetComponent <RectTransform>().sizeDelta;
     digitCanvas     = GameObject.Find("DigitCanvas");
     digitCanvasDims = digitCanvas.GetComponent <RectTransform>().sizeDelta;
     instance        = this;
 }
Пример #5
0
        private void OnDrawEvent()
        {
            DrawHandler drawEvent = DrawEvent;

            if (drawEvent != null)
            {
                drawEvent();
            }
        }
Пример #6
0
        public override void Draw(DrawHandler drawHandler)
        {
            if (this.Selected)
            {
                drawHandler.Draw(this.SelectedImage, this.Position);
            }

            base.Draw(drawHandler);
        }
Пример #7
0
 public Square(Point point, int size, DrawHandler drawSquare) : base(point)
 {
     _size     = size;
     points    = new Point[4];
     points[0] = point;
     points[1] = point + new Vector2(size * 2, 0);
     points[2] = point + new Vector2(0, size);
     points[3] = point + new Vector2(size * 2, size);
     OnDraw   += drawSquare;
 }
Пример #8
0
 /// <summary>
 /// Initializes the handles with given values from map loaded
 /// </summary>
 private void InitHandlers()
 {
     _modeHandler   = new ModeHandler();
     _cameraHandler = new CameraHandler();
     _gridHandler   = new GridHandler(_cameraHandler);
     _tileHandler   = new TileHandler(_gridHandler);
     _tilesetLoader = new TilesetLoader();
     _mapLoader     = new MapLoader(_tileHandler, _gridHandler, _tilesetLoader, MapData);
     _drawHandler   = new DrawHandler(DrawCanvas, _gridHandler, _cameraHandler, _tilesetLoader, _tileHandler, _modeHandler);
     InputHandler   = new InputHandler(_gridHandler, _cameraHandler, _tileHandler, _modeHandler, DrawCanvas, Information, TileProperty);
 }
Пример #9
0
 public Rasterizer(int resolutionX, int resolutionY, DrawHandler drawHandler)
 {
     if (ReferenceEquals(null, drawHandler))
     {
         throw new ArgumentException("Draw handler must not equal null!");
     }
     this.drawHandler  = drawHandler;
     copyToFrameBuffer = new TextureToFrameBuffer();
     texRenderSurface  = Texture.Create(resolutionX, resolutionY);
     texRenderSurface.FilterNearest();
     renderToTexture = new FBO(texRenderSurface);
 }
Пример #10
0
        public override void Draw(DrawHandler drawHandler)
        {
            drawHandler.Draw(this.Image, this.Position);

            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    if (Cells[x, y].CanMove)
                    {
                        drawHandler.Draw(this.Move_Image, Cells[x, y].ScreenPosition);
                    }
                }
            }
        }
Пример #11
0
        private void pbPicture_MouseMove(object sender, MouseEventArgs e)
        {
            if (isMouseDown == true)
            {
                bSaveFile.Enabled = false;

                if (di.OX != -1)
                {
                    DrawHandler dh = new DrawHandler();
                    dh.toDraw(di, e.X, e.Y, pbPicture.Handle, tbPenSize.Value);
                }

                di.OX = e.X;
                di.OY = e.Y;
            }
        }
Пример #12
0
 /// <summary>
 /// Create a new UIItemSlot.
 /// </summary>
 /// <param name="position">position of slot in pixels</param>
 /// <param name="size">size of slot in pixels</param>
 /// <param name="context">context for slot</param>
 /// <param name="hoverText">hover text to show instead of context</param>
 /// <param name="parent">parent UIObject</param>
 /// <param name="conditions">checked before item is placed in slot; if null, all items are permitted</param>
 /// <param name="drawBackground">run when slot background is drawn; if null, slot is drawn with background texture</param>
 /// <param name="drawItem">run when item in slot is drawn; if null, item is drawn in center of slot</param>
 /// <param name="postDrawItem">run after item in slot is drawn; use to draw elements over the item</param>
 /// <param name="drawAsNormalSlot">draw as a normal inventory ItemSlot</param>
 /// <param name="scaleToInventory">whether to scale with the inventory</param>
 public UIItemSlot(Vector2 position, int size = 52, int context              = ItemSlot.Context.InventoryItem,
                   string hoverText           = "", UIObject parent          = null, ConditionHandler conditions = null,
                   DrawHandler drawBackground = null, DrawHandler drawItem   = null, DrawHandler postDrawItem = null,
                   bool drawAsNormalSlot      = false, bool scaleToInventory = false)
     : base(position, new Vector2(size), parent, false)
 {
     Item             = new Item();
     Context          = context;
     HoverText        = hoverText;
     Conditions       = conditions;
     DrawBackground   = drawBackground;
     DrawItem         = drawItem;
     PostDrawItem     = postDrawItem;
     DrawAsNormalSlot = drawAsNormalSlot;
     ScaleToInventory = scaleToInventory;
 }
Пример #13
0
    /// <summary>
    /// Creates the HP Bar Object
    /// </summary>
    /// <param name="targetCreature"></param>
    /// <param name="hpPercent"></param>
    /// <param name="hpBarColor"></param>
    public HPBar(GameObject targetCreature, float hpPercent, Color hpBarColor, object hpBarBackgroundColor = null)
    {
        this.targetCreature = targetCreature;
        this.hpPercent      = hpPercent;
        this.hpBarColor     = DrawHandler.getColor(hpBarColor);
        //Look at this dumb shit.
        if (hpBarBackgroundColor == null)
        {
            this.hpBarBackgroundColor = DrawHandler.getColor(Color.black);
        }
        else
        {
            this.hpBarBackgroundColor = DrawHandler.getColor((Color)hpBarBackgroundColor);
        }

        DrawHandler.itemsToDraw.Add(this);
    }
Пример #14
0
        protected void DrawScreen(MenuScreenUpdateEventArgs args, int maxLength, DrawHandler callback, RefreshHandler refreshCallback = null)
        {
            string showText;
            var    align = TextAlign.Left;

            switch (args.Reason)
            {
            case MenuScreenUpdateReason.Navigation:
                showText = CurrentScreen.Title;
                if (showText.Length < maxLength)
                {
                    showText = CharIcons.NetRect + showText;
                }
                if (showText.Length < Radio.DisplayTextMaxLength)
                {
                    showText += CharIcons.NetRect;
                }
                align = TextAlign.Center;
                if (refreshCallback != null)
                {
                    refreshCallback(MenuScreenUpdateReason.Scroll);
                }
                break;

            case MenuScreenUpdateReason.StatusChanged:
                if (CurrentScreen.Status == String.Empty)
                {
                    UpdateScreen(MenuScreenUpdateReason.Refresh);
                    return;
                }
                showText = CurrentScreen.Status;
                align    = TextAlign.Center;
                if (refreshCallback != null)
                {
                    refreshCallback(MenuScreenUpdateReason.Refresh);
                }
                break;

            default:
                showText = GetItemString(args.Reason, maxLength, refreshCallback);
                break;
            }

            callback(showText, align);
        }
Пример #15
0
        /*-------------------------------------------------------------------------
         * 그리기支援
         *
         * 最終的な그리기좌표は
         * GlobalPos2LocalPos();
         * で得ること
         * ---------------------------------------------------------------------------*/
        public void EnumDrawCallBack(DrawHandler handler, float outside_offset_x)
        {
            if (handler == null)
            {
                return;
            }

            ajust_draw_start_offset_x(outside_offset_x);

            Vector2 offset = GetDrawOffset();

            do
            {
                // 그리기コールバック呼び出し
                handler(offset, this);

                // オフセット조정
                offset.X += ImageSize.X;
            } while (offset.X < (((1f / ImageScale) * m_device.client_size.X) + outside_offset_x));
        }
Пример #16
0
        private async Task RefreshView()
        {
            await Task.Delay(1);

            _time += 0.016f;
            if (this.ImageView != null)
            {
                var handler = new DrawHandler();
                try
                {
                    this.ImageView.Image = handler.GenerateImage(_physics.Position(_time));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }

            await RefreshView();
        }
Пример #17
0
        VisitStatus VisitPrimitive <TProperty, TContainer, TValue, TElement>(
            TProperty property,
            ref TContainer container,
            ref TValue value,
            DrawHandler <TProperty, TContainer, TValue, TElement> handler
            )
            where TProperty : IProperty <TContainer, TValue>
        {
            // Regular value
            var propName = property.GetName();
            var path     = Visitor.GetCurrentPath();

            path.Push(propName);
            if (TryGetDrawer(ref value, property, path, propName,
                             InspectorVisitLevel.Field))
            {
                return(VisitStatus.Override);
            }

            handler(property, ref container, ref value, VisitorContext);
            return(VisitStatus.Handled);
        }
Пример #18
0
        public wTree()
        {
            InitializeComponent();

            _children = new wTreeNodeCollection(this, this);
            _children.E_TreeExpandChanged += _children_E_TreeExpandChanged;
            _children.E_TreeListChanged   += _children_E_TreeListChanged;
            _children.E_TreeNodeChanged   += _children_E_TreeNodeChanged;

            //this.BackgroundImage = _imageBufferToDraw;
            //this.BackgroundImageLayout = ImageLayout.None;
            this.SizeChanged += wTree_SizeChanged;

            B_FocusGetter.SetBounds(-1000, 0, 0, 0, BoundsSpecified.Location);

            _editorHandler = new EditorHandlerClass(this);
            _editorHandler.InitEditors();
            _drawHandler = new DrawHandler(this);
            _selHandler  = new wTreeSelections(this);
            _scrolls     = new wTreeScroll(this, Scroll_Vertical, Scroll_Horizontal);
            this.SetScrollState(0, true);
            _mouseHandler          = new wTreeMouseEventsHandler(this);
            B_FocusGetter.KeyDown += B_FocusGetter_KeyDown;
        }
Пример #19
0
 public static WindowAction CreateWindowActionButton(string id, ExecuteHandler executeHandler, string menuPath, float width, DrawHandler drawHandler)
 {
     return(new WindowAction(id, executeHandler, menuPath)
     {
         width = width,
         drawHandler = drawHandler
     });
 }
Пример #20
0
 /// <summary>
 /// Initialises a new instance of the <see cref="HomeController" /> class.
 /// </summary>
 ///
 /// <param name="logger"> The logger. </param>
 /// <param name="handler"> The I/O handler. </param>
 /// <param name="drawHandler"> The drawing handler. </param>
 public HomeController(ILogger <HomeController> logger, DbServiceHandler <PackIt.Pack.Pack> handler, DrawHandler drawHandler)
     : base(logger, handler)
 {
     this.drawHandler = drawHandler;
 }
Пример #21
0
 public HookScroll(IntPtr hWnd, DrawHandler draw)
 {
     this.hWnd = hWnd;
     this.draw = draw;
 }
Пример #22
0
        /*-------------------------------------------------------------------------
         * イメージとの合成
         * Begin()を読んだ直후に呼ぶこと
         * must_margeがtrueのとき必ず合成する
         * デバイスロスト時は必ず合成する
         * 合成しないときは handler にnullを지정できる
         *
         * デバイスロスト時の処理を含むため, 必ず呼び出す必要がある
         * ---------------------------------------------------------------------------*/
        public void MergeImage(DrawHandler handler, bool must_merge)
        {
            if (!m_device_lost && !must_merge)
            {
                return;
            }

            DateTimer d = new DateTimer();

            // 텍스쳐업데이트
            foreach (TextureUnit tex in m_textures)
            {
                tex.RefreshTexture();
            }
            // 合成대상がなければ返る
            if (handler == null)
            {
                m_device_lost = false;
                // 合成に掛かった시간
                MargeImageMS = d.GetSectionTimeMilliseconds();
                return;
            }

            // 合成
            // 렌더링 타겟を지정
            Surface depth      = m_device.device.DepthStencilSurface;
            Surface backbuffer = m_device.device.GetBackBuffer(0, 0, BackBufferType.Mono);

            m_device.device.DepthStencilSurface = null;                  // zバッファ없음

            try
            {
                foreach (TextureUnit tex in m_textures)
                {
                    // 렌더링 타겟を설정

                    if (tex.Texture == null)
                    {
                        continue;                                                 // 텍스쳐が作れていない
                    }
                    //					Surface	a	= ((Texture)null).GetSurfaceLevel(0);
                    m_device.device.SetRenderTarget(0, tex.Texture.GetSurfaceLevel(0));
                    m_device.UpdateClientSize();

                    // 그리기위치と스케일を退避
                    PushDrawParams();
                    m_offset = -tex.Offset;
                    SetScale(1, new Point(0, 0), false);

                    // 렌더링
                    handler(m_offset, this);

                    PopDrawParams();
                }
            }
            catch
            {
                // 保険
                PopDrawParams();
            }

            // 렌더링 타겟を元に戻す
            m_device.device.DepthStencilSurface = depth;
            m_device.device.SetRenderTarget(0, backbuffer);
            m_device.UpdateClientSize();

            backbuffer.Dispose();
            depth.Dispose();

            m_device_lost = false;
            // 合成に掛かった시간
            MargeImageMS = d.GetSectionTimeMilliseconds();
        }
Пример #23
0
 /// <summary>
 /// Updates the current hp percent and color.
 /// </summary>
 /// <param name="newHPPercent"></param>
 /// <param name="hpBarColor"></param>
 public void updateCreatureHP(float newHPPercent, Color hpBarColor)
 {
     hpPercent       = newHPPercent;
     this.hpBarColor = DrawHandler.getColor(hpBarColor);
 }
Пример #24
0
 public DrawComponent(DrawHandler draw)
 {
     _draw = draw;
 }
Пример #25
0
 public UIDyeItemSlot(Vector2 position, int size = 52, int context = 0, string hoverText = "", UIObject parent = null, ConditionHandler conditions = null, DrawHandler drawBackground = null, DrawHandler drawItem = null, DrawHandler postDrawItem = null, bool drawAsNormalSlot = false, bool scaleToInventory = false) : base(position, size, context, hoverText, parent, conditions, drawBackground, drawItem, postDrawItem, drawAsNormalSlot, scaleToInventory)
 {
 }
Пример #26
0
 public Circle(Point point, int radius, DrawHandler drawCircle) : base(point)
 {
     _radius = radius;
     OnDraw += drawCircle;
 }
Пример #27
0
            /// <summary>
            /// Обработать новые значения.
            /// </summary>
            /// <param name="time">Временная отметка формирования новых данных.</param>
            /// <param name="value">Значения индикатора.</param>
            /// <param name="draw">Метод отрисовки значения на графике.</param>
            /// <returns>Новые значения для отображения на графике.</returns>
            public override IEnumerable <decimal> ProcessValues(DateTimeOffset time, IIndicatorValue value, DrawHandler draw)
            {
                var newYValues = new List <decimal>();

                if (!value.IsFormed)
                {
                    draw(_pnl, 0, double.NaN, double.NaN);
                }
                else
                {
                    var pnl = value.GetValue <decimal>();

                    draw(_pnl, 0, (double)pnl, (double)0);
                    newYValues.Add(pnl);
                }

                return(newYValues);
            }
Пример #28
0
 public override void Draw(DrawHandler drawHandler)
 {
     this.Board.Draw(drawHandler);
     this.Pieces.ForEach(x => x.Draw(drawHandler));
 }
Пример #29
0
 public Point(int x, int y, DrawHandler drawPoint)
 {
     _x      = x;
     _y      = y;
     OnDraw += drawPoint;
 }
Пример #30
0
 public virtual void Draw(DrawHandler drawHandler)
 {
 }
Пример #31
0
            public override IEnumerable<decimal> ProcessValues(DateTimeOffset time, IIndicatorValue value, DrawHandler draw)
            {
                var newYValues = new List<decimal>();

                if (!value.IsFormed)
                {
                    draw(_pnl, 0, double.NaN, double.NaN);
                }
                else
                {
                    var pnl = value.GetValue<decimal>();

                    draw(_pnl, 0, (double)pnl, (double)0);
                    newYValues.Add(pnl);
                }

                return newYValues;
            }
Пример #32
0
        internal virtual void RaiseOnPaint(PaintEventArgs e)
        {
            uwfBatches = 0;

            if (uwfShadowBox)
            {
                if (uwfShadowHandler == null)
                {
                    uwfShadowHandler = (pArgs) =>
                    {
                        var psLoc       = PointToScreen(Point.Empty);
                        int shX         = psLoc.X + 6;
                        int shY         = psLoc.Y + 6;
                        var shadowColor = defaultShadowColor;
                        var localWidth  = Width;
                        var localHeight = Height;
                        var graphics    = pArgs.Graphics;
                        graphics.uwfFillRectangle(shadowColor, shX + 6, shY + 6, localWidth - 12, localHeight - 12);
                        graphics.uwfFillRectangle(shadowColor, shX + 5, shY + 5, localWidth - 10, localHeight - 10);
                        graphics.uwfFillRectangle(shadowColor, shX + 4, shY + 4, localWidth - 8, localHeight - 8);
                        graphics.uwfFillRectangle(shadowColor, shX + 3, shY + 3, localWidth - 6, localHeight - 6);
                        graphics.uwfFillRectangle(shadowColor, shX + 2, shY + 2, localWidth - 4, localHeight - 4);
                    };
                }

                uwfShadowHandler(e);
            }

            if (uwfAutoGroup)
            {
                e.Graphics.GroupBegin(this);
            }

            OnPaintBackground(e);
            OnPaint(e);

            if (controls != null)
            {
                for (int i = 0; i < controls.Count; i++)
                {
                    var childControl = controls[i];
                    if (Application.ControlIsVisible(childControl) == false)
                    {
                        continue;
                    }

                    var currentAbspos  = childControl.PointToScreen(Point.Empty);
                    var currentAbsposX = currentAbspos.X;
                    var currentAbsposY = currentAbspos.Y;

                    if (currentAbsposX + childControl.width < 0 ||
                        currentAbsposX > Screen.width ||
                        currentAbsposY + childControl.height < 0 ||
                        currentAbsposY > Screen.height)
                    {
                        continue;
                    }

                    childControl.RaiseOnPaint(e);
                }
            }

            uwfOnLatePaint(e);

            if (uwfAutoGroup)
            {
                e.Graphics.GroupEnd();
            }
        }