Example #1
0
 public ImageObject(Renderer.Image image, RectangleF rect)
 {
     Brush      = PBrush.CreateSolid(Color.White);
     this.image = image;
     AddPoint(rect.Left, rect.Top, 1);
     AddPoint(rect.Right, rect.Top, 1);
     AddPoint(rect.Right, rect.Bottom, 1);
     AddPoint(rect.Left, rect.Bottom, 1);
 }
Example #2
0
        public PageOverview(KDocument document, Form parent, KPage currentPage)
        {
            InitializeComponent();

            thumbnailSize = (int)(4 * Util.GetGUISize());

            int border = Util.GetGUISize();

            this.Bounds = new Rectangle(border, border,
                                        parent.ClientSize.Width - border * 2, parent.ClientSize.Height - border * 2);
            this.Anchor = AnchorStyles.Bottom | AnchorStyles.Left
                          | AnchorStyles.Right | AnchorStyles.Top;

            this.document  = document;
            pageThumbnails = new Renderer.Image[document.Pages.Count];
            for (int i = 0; i < pageThumbnails.Length; i++)
            {
                Bitmap bmp = document.Pages[i].GetThumbnail(thumbnailSize, thumbnailSize,
                                                            Color.White, Color.Silver, 4);
                pageThumbnails[i] = new Renderer.Image(bmp);
            }

            renderer = GPURenderer.Create(this);
            mPos     = Cursor.Position;

            tmDraw          = new System.Windows.Forms.Timer();
            tmDraw.Interval = 30;
            tmDraw.Start();
            tmDraw.Tick     += tmDraw_Tick;
            tmInput          = new System.Windows.Forms.Timer();
            tmInput.Interval = 200;
            tmInput.Start();
            tmInput.Tick += TmInput_Tick;

            bmpAdd = new Renderer.Image(ResManager.LoadIcon("add.svg", thumbnailSize / 2));

            if (currentPage == null)
            {
                currentPageIndex = -1;
            }
            else
            {
                currentPageIndex = document.Pages.IndexOf(currentPage);
            }

            this.Disposed   += PageOverview_Disposed;
            this.MouseDown  += PageOverview_MouseDown;
            this.MouseUp    += PageOverview_MouseUp;
            this.MouseClick += PageOverview_MouseClick;
            this.VScroll     = true;
        }
Example #3
0
        public TransformerRotate(KPage page, InkControl control)
        {
            rad   = (int)(42 * Util.GetScaleFactor());
            width = (int)(10 * Util.GetScaleFactor());

            this.page    = page;
            this.control = control;

            if (img == null)
            {
                imRect = new Rectangle(width * -2, -rad - width, width * 4, width * 2);
                Bitmap bmp = ResManager.LoadIcon("gui/rotator.svg", imRect.Width, imRect.Height);
                img = new Renderer.Image(bmp);
            }
        }
        public TransformerTranslate(KPage page, InkControl control, params Transformer[] transformer)
        {
            innerRad = (int)(20 * Util.GetScaleFactor());
            if (img == null || img.IsDisposed)
            {
                Bitmap bmp = ResManager.LoadIcon("gui/translator.svg", innerRad);
                img = new Renderer.Image(bmp);
            }

            this.control     = control;
            this.page        = page;
            this.pageVersion = page.Version;
            this.transformer = transformer;
            int   c = 0;
            float _x = 0, _y = 0;

            selectedLines = new bool[page.LineCount];
            for (int i = 0; i < page.LineCount; i++)
            {
                Line l = page.GetLine(i);
                if (l.Selected)
                {
                    PointF center = new PointF(l.Bounds.X + l.Bounds.Width / 2,
                                               l.Bounds.Y + l.Bounds.Height / 2);
                    _x += center.X;
                    _y += center.Y;
                    c++;
                }
                selectedLines[i] = l.Selected;
            }
            _x /= c;
            _y /= c;
            //control.GetTransform().Transform(ref _x, ref _y);
            //PointF pf = control.GetTransform().GetTranslation();
            x           = (int)(_x);
            y           = (int)(_y);
            this.Others = new List <Transformer>(this.transformer);
            this.Others.Add(this);
            foreach (Transformer trans in this.transformer)
            {
                trans.SetPosition(x, y);
                trans.Others = this.Others;
            }
        }
Example #5
0
        private void btnAddImage_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Images|*.jpg;*.jpeg;*.png;*.bmp";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                Renderer.Image img;
                using (var stream = File.OpenRead(ofd.FileName))
                {
                    img = new Renderer.Image(new Bitmap(stream));
                }
                float s1    = control.Page.Format.Width / img.GdiBitmap.Width;
                float s2    = control.Page.Format.Height / img.GdiBitmap.Height;
                float s     = Math.Min(s1, s2);
                var   imObj = new Forms.ImageObject(img, new RectangleF(0, 0, s * img.GdiBitmap.Width, s * img.GdiBitmap.Height));
                control.Page.AddLine(imObj);
                OnClose?.Invoke();
            }
        }