Ejemplo n.º 1
0
 public void DrawSelf(Graphics g, CanvasContext context)
 {
     using (Pen p = new Pen(Color.Blue))
     {
         g.DrawRectangle(p, context.ToRectangle());
     }
 }
Ejemplo n.º 2
0
        private void DrawAll(Graphics g)
        {
            BlockOfFlats block = BlockOfFlats.GetKLadviBlockOfFlats();
            //CanvasContext context = new CanvasContext(0, 0, panelCanvas.Width, panelCanvas.Height);
            CanvasContext context = new CanvasContext(panelCanvas.ClientRectangle.Left, panelCanvas.ClientRectangle.Top, panelCanvas.ClientRectangle.Width, panelCanvas.ClientRectangle.Height);

            block.DrawSelf(g, context);
            //DrawEngine drawEngine = new DrawEngine(block, g, context);
            //drawEngine.DrawAllElements();
            Window window = Window.GetStandardWindow();

            window.DrawSelf(g, context);

            Door door = Door.GetSingleDoor();

            door.DrawSelf(g, context);
            //Window window = Window.GetStandardWindow();
            //CanvasContext context2 = new CanvasContext(0, 0, panelCanvas.Width, panelCanvas.Height);
            //window.DrawSelf(g, context2);



            ////Floor floor = Floor.GetGroundFloor();
            //Floor floor = Floor.GetFirstFloor();
            //CanvasContext context = new CanvasContext(panelCanvas.ClientRectangle.Left, panelCanvas.ClientRectangle.Top, panelCanvas.ClientRectangle.Width, panelCanvas.ClientRectangle.Height);
            ////floor.DrawSelf(g, context);
            //DrawEngine drawEngine = new DrawEngine(floor, g, context);
            //drawEngine.DrawAllElements();
        }
Ejemplo n.º 3
0
        private Rectangle GetRoofRectangle(CanvasContext context)
        {
            ////int roofHeight = 20;
            //int roofHeight = 40;
            //int livingPartHeight = context.Height - roofHeight;
            //// ***
            //Rectangle roofRectangle = new Rectangle(context.Left, context.Top, context.Width, roofHeight);
            //Rectangle livingRectangle = new Rectangle(context.Left, context.Top + roofHeight, context.Width, livingPartHeight);
            //// ***
            ////Rectangle roofRectangle = new Rectangle(context.Left, context.Top, context.Width - 1, roofHeight - 1);
            ////Rectangle livingRectangle = new Rectangle(context.Left, context.Top + roofHeight, context.Width - 1, livingPartHeight - 1);
            ////Rectangle roofRectangle = new Rectangle(context.Left, context.Top, context.Width - 2, roofHeight - 2);
            ////Rectangle livingRectangle = new Rectangle(context.Left, context.Top + roofHeight, context.Width - 2, livingPartHeight - 2);
            //// ***
            ////Rectangle roofRectangle = new Rectangle(context.Left + 2, context.Top + 2, context.Width - 4, roofHeight - 4);
            ////Rectangle livingRectangle = new Rectangle(context.Left + 2, context.Top + 2 + roofHeight, context.Width - 4, livingPartHeight - 4);
            //// ***
            int roofHeight = GetRoofHeight();
            //int livingPartHeight = GetLivingPartHeight(context);
            // ***
            Rectangle roofRectangle = new Rectangle(context.Left, context.Top, context.Width, roofHeight);

            //Rectangle livingRectangle = new Rectangle(context.Left, context.Top + roofHeight, context.Width, livingPartHeight);
            // ***
            return(roofRectangle);
        }
Ejemplo n.º 4
0
        private int GetLivingPartHeight(CanvasContext context)
        {
            //int livingPartHeight = context.Height - roofHeight;
            int livingPartHeight = context.Height - GetRoofHeight();

            return(livingPartHeight);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 将<see cref="ICanvasContext"/>中选中的绘制对象与<see cref="_copyEditDrawObjectCells"/>同步;
        /// </summary>
        /// <param name="canvasContext">对应的画布上下文</param>
        private void SyncSelectedDrawObjectsToCopiedCells()
        {
            //获取所有被选中的绘制对象;
            var selectedDrawObjects = CanvasContext.GetAllDrawObjects().Where(p => p.IsSelected).
                                      Union(_copiedDrawObjects.Where(p => p.IsSelected));

            //清除集合后重新填充;
            _copyEditDrawObjectCells.Clear();

            foreach (var drawObject in selectedDrawObjects)
            {
                var copiedObject = drawObject.Clone();

                if (copiedObject == null)
                {
                    continue;
                }

                copiedObject.IsSelected = false;

                var copyCell = new CopyEditDrawObjectCell {
                    CopiedDrawObject = copiedObject
                };

                copyCell.DrawObjectMoveTool = DrawObjectMoveTools.
                                              FirstOrDefault(p => p.CheckDrawObjectMoveable(drawObject));

                ///若找到了满足条件的工具项,则加入<see cref="_copyEditDrawObjectCells"/>
                if (copyCell.DrawObjectMoveTool != null)
                {
                    _copyEditDrawObjectCells.Add(copyCell);
                }
            }
        }
Ejemplo n.º 6
0
        public AudioResource(SpectrumVideoDemodConfig config, CanvasContext ctx)
        {
            //Set
            this.label = config.label;

            //Get demodulator
            switch (config.demodType)
            {
            case "WBFM": demodulator = new WbFmDemodulator(); break;

            default: throw new Exception("Unknown demodulator type.");
            }

            //Make buffers
            bufferSize            = ctx.BufferSize;
            generalBuffer         = UnsafeBuffer.Create(ctx.BufferSize, out generalBufferComplexPtr);
            generalBufferFloatPtr = (float *)generalBufferComplexPtr;
            audioABuffer          = UnsafeBuffer.Create(ctx.BufferSize, out audioABufferPtr);
            audioBBuffer          = UnsafeBuffer.Create(ctx.BufferSize, out audioBBufferPtr);

            //Init audio
            demodDecimator = ComplexDecimator.CalculateDecimator(ctx.DecimatedSampleRate, config.demodBandwidth, 20, config.demodBandwidth * 0.05f, out float demodSampleRate);
            float actualAudioRate = demodulator.Configure(ctx.BufferSize, demodSampleRate, config.outputSampleRate);

            audioResampler = new ArbitraryStereoResampler(actualAudioRate, config.outputSampleRate, ctx.BufferSize);

            //Create output
            output = ctx.OutputProvider.GetAudioOutput(config.outputFilename, config.outputSampleRate, bufferSize);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        protected override void OnPreviewInitialize()
        {
            Doc.DocModified += OnDocModified;

            AsciiFont = CanvasContext.CreateFont(_settings.fonts.asciiFont.name, _settings.fonts.asciiFont.height);
            JpFont    = CanvasContext.CreateFont(_settings.fonts.jpFont.name, _settings.fonts.jpFont.height);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        protected override void OnPreviewMouseWheel(MouseState mouseState, ref bool handled)
        {
            if (mouseState.IsCtrl)
            {
                _zoomLevel += mouseState.WheelNotchY;
#warning とりあえず
                _zoomLevel = MathUtil.Clamp(_zoomLevel, -10, 22);
                ZoomRate   = Math.Pow(1.1, _zoomLevel);

                AsciiFont.Dispose();
                AsciiFont = CanvasContext.CreateFont(_settings.fonts.asciiFont.name, _settings.fonts.asciiFont.height * ZoomRate);
                JpFont.Dispose();
                JpFont = CanvasContext.CreateFont(_settings.fonts.jpFont.name, _settings.fonts.jpFont.height * ZoomRate);

                UpdateLayout();

                FontChanged?.Invoke();
            }
            else
            {
                if (mouseState.IsShift)
                {
                    HScrollBar.Value += mouseState.WheelNotchY * _settings.scrollSpeed_horizontal * -1;
                }
                else
                {
                    VScrollBar.Value += mouseState.WheelNotchY * _settings.scrollSpeed_vertical * -1;
                }
            }

            handled = true;
        }
        public static SpectrumVideoComponent MakeComponent(CanvasContext ctx, SpectrumVideoComponentConfig cfg)
        {
            //Get info
            ComponentInfo info = GetComponentInfo(cfg.tag);

            //Construct
            return((SpectrumVideoComponent)Activator.CreateInstance(info.type, ctx, cfg.config));
        }
Ejemplo n.º 10
0
 public override void DrawSelf(Graphics g, CanvasContext context)
 {
     //base.DrawSelf(g, context);
     using (Pen pen = new Pen(Color.Blue, 5.0f))
     {
         g.DrawRectangle(pen, context.ToRectangle());
     }
 }
Ejemplo n.º 11
0
 public ComponentPadding(CanvasContext ctx, JObject cfg) : base(ctx)
 {
     height = UtilReadConfigValue(cfg, "height", 200);
     color  = new UnsafeColor(
         UtilReadConfigValue <byte>(cfg, "r", 0),
         UtilReadConfigValue <byte>(cfg, "g", 0),
         UtilReadConfigValue <byte>(cfg, "b", 0)
         );
 }
Ejemplo n.º 12
0
        protected override void OnPreviewCreated()
        {
            _scrollableOffscreen = new ScrollableOffscreen(this);

            _inputMethod = CanvasContext.GetInputMethod();
            var jsFontInfo = _textView._settings.fonts.jpFont;

            _inputMethod.SetFont(jsFontInfo.name, jsFontInfo.height * _textView.ZoomRate, _textView.GetLineHeight());
        }
Ejemplo n.º 13
0
 public ComponentWaterfall(CanvasContext ctx, JObject cfg) : base(ctx)
 {
     attack    = UtilReadConfigValue(cfg, "attack", 0.4f);
     decay     = UtilReadConfigValue(cfg, "decay", 0.3f);
     fftBins   = UtilReadConfigValue(cfg, "fftBins", 2048);
     fftOffset = UtilReadConfigValue(cfg, "fftOffset", 0);
     fftScale  = UtilReadConfigValue(cfg, "fftScale", 100);
     height    = UtilReadConfigValue(cfg, "height", 200);
 }
Ejemplo n.º 14
0
 public override void DrawSelf(Graphics g, CanvasContext context)
 {
     using (Pen pen = new Pen(Color.Black, 3.0f))
     {
         g.DrawRectangle(pen, context.Left + (context.Width / 3), context.Top + (context.Height / 3), ((context.Height + context.Width) / 2) / 6, ((context.Height + context.Width) / 2) / 6);
         g.DrawLine(pen, context.Left + (context.Width / 3), context.Top + (context.Height / 3) + (((context.Height + context.Width) / 2) / 6) / 2, context.Left + (context.Width / 3) + ((context.Height + context.Width) / 2) / 6, context.Top + (context.Height / 3) + (((context.Height + context.Width) / 2) / 6) / 2);
         g.DrawLine(pen, context.Left + (context.Width / 3) + (((context.Height + context.Width) / 2) / 6) / 2, context.Top + (context.Height / 3), context.Left + (context.Width / 3) + (((context.Height + context.Width) / 2) / 6) / 2, context.Top + (context.Height / 3) + ((context.Height + context.Width) / 2) / 6);
     }
 }
Ejemplo n.º 15
0
        //void DrawSelf(Graphics g, CanvasContext context);



        public virtual void DrawSelf(Graphics g, CanvasContext context)
        {
            //Pen pen = new Pen(Color.Magenta, 1.0f);
            //g.DrawRectangle(pen, context.Left, context.Top, context.Width, context.Height);
            //Brush brush = new Brush();
            using (Brush brush = new SolidBrush(Color.Magenta))
            {
                g.FillRectangle(brush, context.Left, context.Top, context.Width, context.Height);
            }
        }
 public ComponentMpxSpectrum(CanvasContext ctx, JObject cfg) : base(ctx)
 {
     attack           = UtilReadConfigValue(cfg, "attack", 0.4f);
     decay            = UtilReadConfigValue(cfg, "decay", 0.3f);
     fftBins          = UtilReadConfigValue(cfg, "fftBins", 2048);
     fftOffset        = UtilReadConfigValue(cfg, "fftOffset", 0);
     fftScale         = UtilReadConfigValue(cfg, "fftScale", 100);
     height           = UtilReadConfigValue(cfg, "height", 200);
     demodulatorLabel = UtilReadConfigValue <string>(cfg, "demodulator_label", null);
 }
Ejemplo n.º 17
0
        public override void DrawSelf(Graphics g, CanvasContext context)
        {
            float f = 6.9f;

            using (Pen pen = new Pen(Color.Red, f))
            {
                g.DrawRectangle(pen, context.Left + f, context.Top + f,
                                context.Width - 2 * f, context.Height - 2 * f);
            }
        }
Ejemplo n.º 18
0
 public override void DrawSelf(Graphics g, CanvasContext context)
 {
     using (Pen pen = new Pen(Color.Brown, 5.0f))
     {
         g.DrawRectangle(pen, context.Left + (context.Width / 3), context.Height - 60, (context.Width + context.Height) / 2 / 6, (context.Width + context.Height) / 2 / 5);
     }
     using (Pen pen2 = new Pen(Color.Black, 2.0f))
     {
         g.DrawLine(pen2, context.Left + (context.Width / 3) + (context.Width + context.Height) / 2 / 6 - 20, context.Height - 35, context.Left + (context.Width / 3) + (context.Width + context.Height) / 2 / 6, context.Height - 35);
     }
 }
Ejemplo n.º 19
0
 public ComponentSpectrum(CanvasContext ctx, JObject cfg) : base(ctx)
 {
     attack            = UtilReadConfigValue(cfg, "attack", 0.4f);
     decay             = UtilReadConfigValue(cfg, "decay", 0.3f);
     centerFreq        = UtilReadConfigValue(cfg, "centerFreq", 92500000);
     fftBins           = UtilReadConfigValue(cfg, "fftBins", 2048);
     fftOffset         = UtilReadConfigValue(cfg, "fftOffset", 0);
     fftScale          = UtilReadConfigValue(cfg, "fftScale", 100);
     height            = UtilReadConfigValue(cfg, "height", 200);
     horizFreqDivision = UtilReadConfigValue(cfg, "horizFreqDivision", 100000);
 }
Ejemplo n.º 20
0
 protected override void OnAfterRender(bool firstRender)
 {
     base.OnAfterRender(firstRender);
     this.designContext = new CanvasContext(DesignCanvas, JsRuntime);
     DsgnGraphics       = new DovDrawings(designContext);
     //
     this.sectionContext = new CanvasContext(SectionCanvas, JsRuntime);
     SecGraphics         = new DovDrawings(sectionContext);
     sectionChart        = new ChartStyle();
     designChart         = new ChartStyle();
 }
Ejemplo n.º 21
0
        public override CanvasContext GetContextForChildren(CanvasContext context)
        {
            Rectangle     livingRectangle    = GetLivingRectangle(context);
            CanvasContext contextForChildren = new CanvasContext(livingRectangle);

            // Make the space for children a little bit smaller.
            contextForChildren.Left   += 5;
            contextForChildren.Top    += 5;
            contextForChildren.Width  -= 10;
            contextForChildren.Height -= 10;
            return(contextForChildren);
        }
Ejemplo n.º 22
0
        public static FftResource GetFFT(CanvasContext ctx, string tag, int bins, bool isHalf)
        {
            //Try to find
            FftResource resource = ctx.FindComponentResource <FftResource>(x => x.Tag == tag && x.Bins == bins && x.IsHalf == isHalf);

            if (resource != null)
            {
                return(resource);
            }

            //Add
            return(ctx.AddResource(new FftResource(tag, bins, isHalf)));
        }
Ejemplo n.º 23
0
        public override void DrawSelf(Graphics g, CanvasContext context)
        {
            int       windowHeight = 100;
            int       widowWidth   = 200;
            Rectangle window       = new Rectangle(context.Left + 400, context.Height - 250, widowWidth, windowHeight);

            using (Pen pen = new Pen(Color.Black, 2.0f))
            {
                g.DrawRectangle(pen, window);
                g.DrawLine(pen, window.Left, window.Top + 50, window.Right, window.Top + 50);
                g.DrawLine(pen, window.Left + 100, window.Top, window.Left + 100, window.Bottom);
            }
        }
Ejemplo n.º 24
0
 protected override void OnAfterRender(bool firstRender)
 {
     this.diagramContext = new CanvasContext(DiagramCanvas, JsRuntime);
     DiagramGraphics     = new DovDrawings(diagramContext);
     //
     this.footingContext   = new CanvasContext(FootingCanvas, JsRuntime);
     FootingGraphics       = new DovDrawings(footingContext);
     this.detailingContext = new CanvasContext(DetailingCanvas, JsRuntime);
     DetailingGraphics     = new DovDrawings(detailingContext);
     footingChart          = new ChartStyle();
     diagramChart          = new ChartStyle();
     detailingChart        = new ChartStyle();
 }
Ejemplo n.º 25
0
        public override void DrawSelf(Graphics g, CanvasContext context)
        {
            Rectangle ladderRectangle = GetLadderRectangle(context);
            Rectangle flatsRectangle  = GetFlatsRectangle(context);

            // ***
            //using (Pen pen = new Pen(Color.Black, 1.0f))
            using (Pen pen = new Pen(Color.Black, 2.0f))
            {
                DrawLadder(g, pen, ladderRectangle);
                DrawFlatsArea(g, pen, flatsRectangle);
            }
        }
Ejemplo n.º 26
0
        /// <summary>Renders an arc from the previous point to this one.</summary>
        public override void RenderLine(CanvasContext context)
        {
            // Grab the raw drawing data:
            DynamicTexture data = context.ImageData;

            // Time to go polar!
            // We're going to rotate around the pole drawing one pixel at a time.
            // For the best accuracy, we first need to find out how much to rotate through per pixel.

            if (Length == 0f)
            {
                // Nothing to draw anyway.
                return;
            }

            // How much must we rotate through overall?
            float angleToRotateThrough = EndAngle - StartAngle;

            // So arc length is how many pixels long the arc is.
            // Thus to step that many times, our delta angle is..
            float deltaAngle = angleToRotateThrough / Length;

            // The current angle:
            float currentAngle = StartAngle;

            // The number of pixels:
            int pixelCount = (int)Mathf.Ceil(Length);

            if (pixelCount < 0)
            {
                // Going anti-clockwise. Invert deltaAngle and the pixel count:
                deltaAngle = -deltaAngle;
                pixelCount = -pixelCount;
            }

            // Step pixel count times:
            for (int i = 0; i < pixelCount; i++)
            {
                // Map from polar angle to coords:
                float x = Radius * (float)Math.Cos(currentAngle);
                float y = Radius * (float)Math.Sin(currentAngle);

                // Draw the pixel:
                data.DrawPixel((int)(CircleCenterX + x), data.Height - (int)(CircleCenterY + y), context.StrokeColour);

                // Rotate the angle:
                currentAngle += deltaAngle;
            }
        }
        /// <summary>Renders a straight line from the previous point to this one.</summary>
        public override void RenderLine(CanvasContext context)
        {
            // Grab the raw drawing data:
            DynamicTexture data = context.ImageData;

            // Invert y:
            int endY   = data.Height - (int)Y;
            int startY = data.Height - (int)Previous.Y;

            // Grab X:
            int endX   = (int)X;
            int startX = (int)Previous.X;

            data.DrawLine(startX, startY, endX, endY, context.StrokeColour);
        }
Ejemplo n.º 28
0
        protected override void OnBeginOperation()
        {
            base.OnBeginOperation();
            if (CanvasContext == null)
            {
                return;
            }

            var drawObjects = CanvasContext.GetAllDrawObjects();

            foreach (var drawObject in drawObjects)
            {
                drawObject.IsSelected = false;
            }
        }
Ejemplo n.º 29
0
        protected override void OnAfterRender(bool firstRender)
        {
            this.diagramContext = new CanvasContext(DiagramCanvas, JsRuntime);
            DiagramGraphics     = new DovDrawings(diagramContext);
            this.biaxialContext = new CanvasContext(BiaxialDiagramCanvas, JsRuntime);
            //
            this.sectionContext         = new CanvasContext(SectionCanvas, JsRuntime);
            SecGraphics                 = new DovDrawings(sectionContext);
            this.clmnNeutralAxisContext = new CanvasContext(ColumnNeutralAxisCanvas, JsRuntime);
            NeutralAxisGraphics         = new DovDrawings(clmnNeutralAxisContext);

            sectionChart     = new ChartStyle();
            diagramChart     = new ChartStyle();
            biaxialChart     = new ChartStyle();
            neutralAxisChart = new ChartStyle();
        }
Ejemplo n.º 30
0
        // 以下、トンネリングイベント(プレビューイベント)、バブリングイベントのルーティングを処理する。

        /// <summary>
        /// イベントルーティング(初期化)。
        /// </summary>
        private void RaiseCreated(Size2D size)
        {
            Verifier.Verify <InvalidOperationException>(size.Width > 0);
            Verifier.Verify <InvalidOperationException>(size.Height > 0);

            _lazySharedInfo.Value.Size = size;

            foreach (var target in Tnc.GetAllChildrenAndSelf())
            {
                target.OnPreviewInitialize();
            }
            foreach (var target in Tnc.GetAllChildrenAndSelfReverse())
            {
                target.OnInitialize();
            }

#warning このへん、あとで整理
            foreach (var target in Tnc.GetAllChildrenAndSelf())
            {
                target._relativeRect = target.ArrangeElement();
            }

            foreach (var target in Tnc.GetAllChildrenAndSelf())
            {
                target.OnPreviewCreated();
            }
            foreach (var target in Tnc.GetAllChildrenAndSelfReverse())
            {
                target.OnCreated();
            }

            _mainOffscreen = CanvasContext.CreateOffscreen(ClientSize);

#warning このへん、あとで整理
            RaiseResize(size);

            _lazySharedInfo.Value.CanvasContext.Resize      += size => RaiseResize(size);
            _lazySharedInfo.Value.CanvasContext.RenderFrame += rc => RaiseRender(rc);

            _lazySharedInfo.Value.CanvasContext.GotFocus  += RaiseGotFocus;
            _lazySharedInfo.Value.CanvasContext.LostFocus += RaiseLostFocus;

            _lazySharedInfo.Value.CanvasContext.MouseDown  += RaiseMouseDown;
            _lazySharedInfo.Value.CanvasContext.MouseUp    += RaiseMouseUp;
            _lazySharedInfo.Value.CanvasContext.MouseMove  += RaiseMouseMove;
            _lazySharedInfo.Value.CanvasContext.MouseWheel += RaiseMouseWheel;
        }