public TimecycleTester()
        {
            GfxHelper.ClearCycle();
            Events.Tick += OnTick;

            _on = false;
        }
        private void OnTick(List <Events.TickNametagData> nametags)
        {
            if (Pad.IsControlJustPressed(0, (int)Control.ReplayStartStopRecordingSecondary))
            {
                if (!_on)
                {
                    _on = true;
                    GfxHelper.SetTimeCycleById(_index);
                }
                else
                {
                    GfxHelper.ClearCycle();
                    _on = false;
                }
            }

            if (Pad.IsControlJustPressed(0, (int)Control.PhoneLeft))
            {
                _index--;
                UpdateIndex();
            }
            else if (Pad.IsControlJustPressed(0, (int)Control.PhoneRight))
            {
                _index++;
                UpdateIndex();
            }
        }
        private void OnTick(List <Events.TickNametagData> nametags)
        {
            if (Pad.IsControlJustPressed(0, (int)Control.ReplayStartStopRecordingSecondary))
            {
                if (!_on)
                {
                    _on = true;
                    GfxHelper.ScreenFxStart(_currEffect);
                }
                else
                {
                    GfxHelper.ScreenFxStop(_currEffect);
                    _on = false;
                }

                UiHelper.ShowSubtitle($"ScreenFX On:{_on}", 1000);
            }

            if (Pad.IsControlJustPressed(0, (int)Control.PhoneLeft))
            {
                _index--;
                UpdateIndex();
            }
            else if (Pad.IsControlJustPressed(0, (int)Control.PhoneRight))
            {
                _index++;
                UpdateIndex();
            }
        }
Beispiel #4
0
        private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
        {
            Graphics  gfx          = e.Graphics;
            Rectangle marginBounds = e.MarginBounds;
            Rectangle pageBounds   = e.PageBounds;

            #if DEBUG_PRINT
            gfx.DrawRectangle(Pens.Gray, marginBounds);
            #endif

            var printable = GetPrintable();
            if (printable != null)
            {
                ImageHandler imgHandler = (ImageHandler)printable.GetPrintableImage();
                Image        img        = imgHandler.Handle;

                float imgW   = img.Width;
                float imgH   = img.Height;
                float factor = GfxHelper.ZoomToFit(imgW, imgH, marginBounds.Width, marginBounds.Height);
                if (factor > 1.0f)
                {
                    factor = 1.0f;
                }
                imgW = (imgW * factor);
                imgH = (imgH * factor);
                float x = (pageBounds.Width - imgW) / 2;
                float y = (pageBounds.Height - imgH) / 2;

                gfx.DrawImage(img, x, y, imgW, imgH);
            }

            e.HasMorePages = false;
        }
Beispiel #5
0
        public IColor Lighter(float fraction)
        {
            int   rgb        = Handle.ToArgb();
            Color lightColor = Color.FromArgb(GfxHelper.Lighter(rgb, fraction));

            return(new ColorHandler(lightColor));
        }
Beispiel #6
0
        public IColor Darker(float fraction)
        {
            int   rgb       = Handle.ToArgb();
            Color darkColor = Color.FromArgb(GfxHelper.Darker(rgb, fraction));

            return(new ColorHandler(darkColor));
        }
        private void UpdateIndex()
        {
            if (_index > 774)
            {
                _index = 1;
            }
            else if (_index < 1)
            {
                _index = 774;
            }

            UiHelper.ShowSubtitle($"Cycle: {GfxHelper.SetTimeCycleById(_index)}, ID:{_index}", 2500);
        }
Beispiel #8
0
        /// <summary>
        ///   Zooms to the maximum size for displaying the entire image within the bounds of the control.
        /// </summary>
        public void ZoomToFit()
        {
            if (fImageSize.IsEmpty)
            {
                return;
            }

            AutoScrollMinSize = Size.Empty;

            Rectangle innerRectangle = GetInsideViewport();
            double    aspectRatio    = GfxHelper.ZoomToFit(fImage.Width, fImage.Height, innerRectangle.Width, innerRectangle.Height);
            double    zoom           = aspectRatio * 100.0;

            Zoom = (int)Math.Round(Math.Floor(zoom));
        }
Beispiel #9
0
        public void CalcBounds(int lines, ChartRenderer renderer)
        {
            try
            {
                InitInfo(lines);
                DefineExpands();

                int maxwid = 0;
                for (int k = 0; k < lines; k++)
                {
                    int wt = renderer.GetTextWidth(Lines[k], fModel.DrawFont);
                    if (maxwid < wt)
                    {
                        maxwid = wt;
                    }
                }

                int pad2side = (fModel.NodePadding * 2);

                fWidth  = pad2side + maxwid;
                fHeight = pad2side + renderer.GetTextHeight(fModel.DrawFont) * lines;

                if (fPortrait != null)
                {
                    ExtRect portRt = ExtRect.Create(0, 0, fHeight - 1, fHeight - 1);
                    portRt.Inflate(-3, -3);

                    int   rtW   = portRt.GetWidth();
                    int   rtH   = portRt.GetHeight();
                    int   imgW  = fPortrait.Width;
                    int   imgH  = fPortrait.Height;
                    float ratio = GfxHelper.ZoomToFit(imgW, imgH, rtW, rtH);
                    imgW = (int)Math.Round(imgW * ratio);
                    imgH = (int)Math.Round(imgH * ratio);

                    PortraitArea   = ExtRect.CreateBounds(portRt.Left, portRt.Top, imgW, imgH);
                    fPortraitWidth = imgW;

                    fWidth += imgW;
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("TreeChartPerson.CalcBounds(): " + ex.Message);
            }
        }
Beispiel #10
0
        public IImage CreateImage(Stream stream, int thumbWidth, int thumbHeight, ExtRect cutoutArea)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            using (Bitmap bmp = new Bitmap(stream))
            {
                bool cutoutIsEmpty = cutoutArea.IsEmpty();
                int  imgWidth      = (cutoutIsEmpty) ? bmp.Width : cutoutArea.GetWidth();
                int  imgHeight     = (cutoutIsEmpty) ? bmp.Height : cutoutArea.GetHeight();

                if (thumbWidth > 0 && thumbHeight > 0)
                {
                    float ratio = GfxHelper.ZoomToFit(imgWidth, imgHeight, thumbWidth, thumbHeight);
                    imgWidth  = (int)(imgWidth * ratio);
                    imgHeight = (int)(imgHeight * ratio);
                }

                Bitmap newImage = new Bitmap(imgWidth, imgHeight, PixelFormat.Format24bppRgb);
                using (Graphics graphic = Graphics.FromImage(newImage)) {
                    graphic.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    graphic.SmoothingMode      = SmoothingMode.HighQuality;
                    graphic.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                    graphic.CompositingQuality = CompositingQuality.HighQuality;

                    if (cutoutIsEmpty)
                    {
                        graphic.DrawImage(bmp, 0, 0, imgWidth, imgHeight);
                    }
                    else
                    {
                        Rectangle destRect = new Rectangle(0, 0, imgWidth, imgHeight);
                        //Rectangle srcRect = cutoutArea.ToRectangle();
                        graphic.DrawImage(bmp, destRect,
                                          cutoutArea.Left, cutoutArea.Top,
                                          cutoutArea.GetWidth(), cutoutArea.GetHeight(),
                                          GraphicsUnit.Pixel);
                    }
                }

                return(new ImageHandler(newImage));
            }
        }
Beispiel #11
0
        /// <summary>
        ///   Zooms to the maximum size for displaying the entire image within the bounds of the control.
        /// </summary>
        public void ZoomToFit()
        {
            if (fImageSize.IsEmpty)
            {
                return;
            }

            //base.UpdateScrollSizes();
            Size viewportSize = base.Viewport.Size;

            viewportSize.Height -= 40;
            viewportSize.Width  -= 40;

            double aspectRatio = GfxHelper.ZoomToFit(fImage.Width, fImage.Height, viewportSize.Width, viewportSize.Height);
            double zoom        = aspectRatio * 100.0;

            Zoom = (int)Math.Round(Math.Floor(zoom));
        }
Beispiel #12
0
        public IImage CreateImage(Stream stream, int thumbWidth, int thumbHeight, ExtRect cutoutArea)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            using (Bitmap bmp = new Bitmap(stream))
            {
                bool cutoutIsEmpty = cutoutArea.IsEmpty();
                int  imgWidth      = (cutoutIsEmpty) ? bmp.Width : cutoutArea.GetWidth();
                int  imgHeight     = (cutoutIsEmpty) ? bmp.Height : cutoutArea.GetHeight();

                if (thumbWidth > 0 && thumbHeight > 0)
                {
                    float ratio = GfxHelper.ZoomToFit(imgWidth, imgHeight, thumbWidth, thumbHeight);
                    imgWidth  = (int)(imgWidth * ratio);
                    imgHeight = (int)(imgHeight * ratio);
                }

                Bitmap newImage = new Bitmap(imgWidth, imgHeight, PixelFormat.Format24bppRgb);
                using (Graphics graphic = new Graphics(newImage)) {
                    graphic.AntiAlias          = true;
                    graphic.ImageInterpolation = ImageInterpolation.High;
                    graphic.PixelOffsetMode    = PixelOffsetMode.Half;

                    if (cutoutIsEmpty)
                    {
                        graphic.DrawImage(bmp, 0, 0, imgWidth, imgHeight);
                    }
                    else
                    {
                        RectangleF sourRect = new RectangleF(cutoutArea.Left, cutoutArea.Top,
                                                             cutoutArea.GetWidth(), cutoutArea.GetHeight());
                        RectangleF destRect = new RectangleF(0, 0, imgWidth, imgHeight);

                        graphic.DrawImage(bmp, sourRect, destRect);
                    }
                }

                return(new ImageHandler(newImage));
            }
        }
        private void UpdateIndex()
        {
            if (_index > _effects.Length - 1)
            {
                _index = 0;
            }
            else if (_index < 0)
            {
                _index = _effects.Length - 1;
            }

            _currEffect = _effects[_index];

            if (_on)
            {
                GfxHelper.ScreenFxStart(_currEffect);
            }

            UiHelper.ShowSubtitle($"ScreenFX Effect:{_currEffect}", 1000);
        }
Beispiel #14
0
        private void TryRenderTreeSlice(ITreeChart treeBox, int index, GDMIndividualRecord currentPatriarch)
        {
            IndiObj indi = fIndiQueue[index];

            fProcessed.Add(indi.IRec.XRef);

            int         depthLimit  = 3;
            float       scaleFactor = 1.0f;
            int         tries       = 0;
            RenderStage stage       = RenderStage.Normal;

            while (true)
            {
                treeBox.Model.DepthLimit = depthLimit;
                treeBox.Model.Scale      = scaleFactor;
                treeBox.GenChart(indi.IRec, indi.TreeKind, false);
                tries += 1;

                ExtSize imageSize = treeBox.GetImageSize();
                var     sf        = GfxHelper.ZoomToFit(imageSize.Width, imageSize.Height, fPageSize.GetWidth(), fPageSize.GetHeight());

                if (sf < 1.0f)
                {
                    // need to reduce image's size
                    switch (stage)
                    {
                    case RenderStage.Normal:
                        depthLimit -= 1;
                        stage       = RenderStage.Shrink;
                        break;

                    case RenderStage.Grow:
                        depthLimit -= 1;
                        stage       = RenderStage.Break;
                        break;

                    case RenderStage.Shrink:
                        scaleFactor = sf;
                        stage       = RenderStage.Break;
                        break;
                    }
                }
                else if (sf > 1.0f)
                {
                    // need to increase image's size
                    switch (stage)
                    {
                    case RenderStage.Normal:
                    case RenderStage.Grow:
                        depthLimit += 1;
                        stage       = RenderStage.Grow;
                        break;

                    case RenderStage.Shrink:
                        scaleFactor = sf;
                        stage       = RenderStage.Break;
                        break;
                    }
                }

                if (stage == RenderStage.Break || tries > 10)
                {
                    break;
                }
            }

            scaleFactor = Math.Min(1.0f, scaleFactor);
            treeBox.Model.DepthLimit = depthLimit;
            treeBox.Model.Scale      = scaleFactor;
            treeBox.GenChart(indi.IRec, indi.TreeKind, false);
            treeBox.RenderImage(RenderTarget.Printer, true);

            var indiNums = new GKVarCache <GDMIndividualRecord, int>();

            for (int i = 0; i < treeBox.Model.Persons.Count; i++)
            {
                TreeChartPerson     person  = treeBox.Model.Persons[i];
                GDMIndividualRecord indiRec = person.Rec;
                if (indiRec == null)
                {
                    continue;
                }

                int iNum = indiNums[indiRec];

                var    offset = treeBox.Model.GetOffsets();
                int    ix     = offset.X + person.Rect.Left;
                int    iy     = offset.Y + person.Rect.Top - (int)fTextFont.Size;
                string iRef   = indiRec.XRef + "#" + iNum;
                fRenderer.DrawAnchor(iRef, iRef, fTextFont, null, ix, iy);

                iNum += 1;
                indiNums[indiRec] = iNum;

                if (!person.CanExpand)
                {
                    continue;
                }

                ix   = offset.X + person.Rect.Left;
                iy   = offset.Y + person.Rect.Bottom;
                iRef = indiRec.XRef + "#" + iNum;
                fRenderer.DrawHyperlink(iRef, iRef, fLinkFont, null, ix, iy);

                if (person.HasFlag(PersonFlag.pfAncWalk))
                {
                    if (person.HasFlag(PersonFlag.pfHasInvAnc) && !IsPatriarchsDescendant(indiRec, currentPatriarch))
                    {
                        CheckQueue(indiRec, TreeChartKind.ckAncestors);
                    }
                }
                else if (person.HasFlag(PersonFlag.pfDescWalk))
                {
                    if (person.HasFlag(PersonFlag.pfSpouse))
                    {
                        if (person.HasFlag(PersonFlag.pfHasInvAnc) && !IsPatriarchsDescendant(indiRec, currentPatriarch))
                        {
                            CheckQueue(indiRec, TreeChartKind.ckAncestors);
                        }
                    }
                    else
                    {
                        if (person.HasFlag(PersonFlag.pfHasInvDesc) && TreeTools.PL_SearchAnc(fTree, indiRec, currentPatriarch, true))
                        {
                            CheckQueue(indiRec, TreeChartKind.ckDescendants);
                        }
                    }
                }
            }
        }
Beispiel #15
0
        public static Color Lighter(Color color, float fraction)
        {
            int rgb = color.ToArgb();

            return(Color.FromArgb(GfxHelper.Lighter(rgb, fraction)));
        }
Beispiel #16
0
        public void CalcBounds(int lines, ChartRenderer renderer)
        {
            try {
                TreeChartOptions options = fModel.Options;

                InitInfo(lines);
                DefineExpands();

                int bh = renderer.GetTextHeight(fModel.BoldFont);
                int th = renderer.GetTextHeight(fModel.DrawFont);

                int maxwid = 0;
                int height = 0;
                for (int k = 0; k < lines; k++)
                {
                    IFont font;
                    if (options.BoldNames && k < NameLines)
                    {
                        height += bh;
                        font    = fModel.BoldFont;
                    }
                    else
                    {
                        height += th;
                        font    = fModel.DrawFont;
                    }

                    int wt = renderer.GetTextWidth(Lines[k], font);
                    if (maxwid < wt)
                    {
                        maxwid = wt;
                    }
                }

                int pad2side = (fModel.NodePadding * 2);

                fWidth  = pad2side + maxwid;
                fHeight = pad2side + height;

                if (fPortrait != null)
                {
                    ExtRect portRt = ExtRect.Create(0, 0, fHeight - 1, fHeight - 1);
                    portRt.Inflate(-3, -3);

                    int   rtW   = portRt.GetWidth();
                    int   rtH   = portRt.GetHeight();
                    int   imgW  = fPortrait.Width;
                    int   imgH  = fPortrait.Height;
                    float ratio = GfxHelper.ZoomToFit(imgW, imgH, rtW, rtH);
                    imgW = (int)Math.Round(imgW * ratio);
                    imgH = (int)Math.Round(imgH * ratio);

                    PortraitArea   = ExtRect.CreateBounds(portRt.Left, portRt.Top, imgW, imgH);
                    fPortraitWidth = imgW;

                    fWidth += imgW;
                }
            } catch (Exception ex) {
                Logger.WriteError("TreeChartPerson.CalcBounds()", ex);
            }
        }