Exemple #1
0
        CGSize SaveThumbnailGetSize(PDFDocument pdfDocument, int pdfPage, string filename)
        {
            CGSize size = pdfDocument.GetPageSize(pdfPage);
            nfloat K    = 750f / size.Width < 1 ? 750f / size.Width : 1;

            MuPDFLib.Cookie cookie = new MuPDFLib.Cookie();

            using (NativeBitmap img = pdfDocument.RenderToBitmap(PDFDocument.context, new CGRect(0, 0, (int)Math.Round(size.Width * K), (int)Math.Round(size.Height * K)), K, pdfPage, 0, ref cookie))
            {
                NSError err = null;
                using (var uimg = ((UIImage)img))
                {
                    using (NSData data = uimg.AsJPEG(0.4f))
                    {                     // Memory leak occurs only with this line. If comment this, memory leak will no occur.
                    }
                }

                if (err != null)
                {
                    Console.WriteLine("Could not save thumbnail: {0}", err);
                }
            }

            return(size);
        }
Exemple #2
0
 /// <noinspection>UnusedDeclaration</noinspection>
 internal Bitmap(NativeBitmap nativeBitmap)
 {
     if ((nativeBitmap == null) || nativeBitmap.IsInvalid)
     {
         throw new java.lang.RuntimeException("internal error: native bitmap is null");
     }
     mNativeBitmap = nativeBitmap;
 }
Exemple #3
0
        protected override void InitControls()
        {
            this.Width           = 400;
            this.Height          = 200;
            this.Text            = "Message";
            this.StartUpPosition = WindowsStartupPosition.CenterScreen;
            NativeLabel frameLabel = new NativeLabel
            {
                Location  = new Point(0, 0),
                Width     = this.Width,
                Height    = 110,
                BackColor = ColorTool.White
            };

            this._LblMessage = new NativeLabel
            {
                Location = new Point(80, 20),
                Width    = this.Width - 110,
                Height   = this.Height - 110,
                Text     = "Enter your text\nEnter your Text",
                //BackColor = ColorTool.Gray,
                //ForeColor = ColorTool.White,
            };
            this._LblIcon = new NativeBitmap
            {
                BitMap   = "asset\\Question.bmp",
                Location = new Point(10, this._LblMessage.Height / 2 - 25),
                Width    = 50,
                Height   = 50,
            };
            this._BnOk = new NativeButton
            {
                Location = new Point(this.Width - 30 - 80, 120),
                Width    = 80,
                Height   = 25,
                Text     = "&Ok"
            };
            this._BnOk.Clicked += Ok_Clicked;
            this._BnCancel      = new NativeButton
            {
                Location = new Point(this._BnOk.Left - 10 - 80, 120),
                Width    = 80,
                Height   = 25,
                Text     = "&Cancel"
            };

            this._BnCancel.Clicked += Cancel_Clicked;
            this.Controls.Add(frameLabel);
            this.Controls.Add(this._LblIcon);
            this.Controls.Add(this._LblMessage);
            this.Controls.Add(this._BnOk);
            this.Controls.Add(this._BnCancel);
        }
Exemple #4
0
        public virtual void Dispose()
        {
            if (Disposed)
            {
                return;
            }

            Timer.Stop();
            NativeBitmap.Dispose();

            GC.SuppressFinalize(this);
        }
Exemple #5
0
        protected void RedrawBitmap()
        {
            using (Graphics g = Graphics.FromImage(NativeBitmap))
            {
                g.Clear(System.Drawing.Color.Transparent);

                if (ActualWidth > 0.0 && ActualHeight > 0.0)
                {
                    Draw(g);
                }
            }

            var bitmapLock = NativeBitmap.LockBits(new Rectangle(new System.Drawing.Point(), NativeBitmap.Size), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            Bitmap.WritePixels(new Int32Rect(0, 0, NativeBitmap.Width, NativeBitmap.Height), bitmapLock.Scan0, DataLength, NativeBitmap.Width * 4);
            NativeBitmap.UnlockBits(bitmapLock);
        }
Exemple #6
0
		/// <noinspection>UnusedDeclaration</noinspection>
		internal Bitmap (NativeBitmap nativeBitmap)
		{
			if ((nativeBitmap == null) || nativeBitmap.IsInvalid)
				throw new java.lang.RuntimeException ("internal error: native bitmap is null");
			mNativeBitmap = nativeBitmap;
		}
        protected override void InitControls()
        {


            this.Text = CAPTION;
            this.Name = "Window1";
            //this.StatusBar = false;
            // this.Left = 100;
            //this.Top = 100;
            this.Width = 600;
            this.Height = 400;
            
            this._ControlTest = new ControlTest();
            this._ControlTest.Width = 200;
            this._ControlTest.Height = 30;
            this._ControlTest.Left = 300;
            this._ControlTest.Top = 80;
            this._ControlTest.Name = "TEST_CONTAINER";
            
            //this.BackColor = ColorTool.LightGray;
            this.StartUpPosition = WindowsStartupPosition.CenterScreen;
            this.BackColor = ColorTool.White;
            this._Timer = new NativeTimer();
            this._Timer.Interval = 100;
            //this._Timer.ControlId = 700;
            this._Timer.Tick += Timer_OnTick;
            this._Button = new NativeButton
            {
                Left = 10,
                Top = 10,
                Width = 100,
                Height = 30,
                Text = "Test",
                Name = "bnTest",
                BackColor = ColorTool.Blue,
                ForeColor = ColorTool.Green

            };

            this._Button1 = new NativeButton
            {
                Left = 150,
                Top = 10,
                Width = 100,
                Height = 30,
                Text = "Test",
                Name = "bnTest"//,
                //ControlId = 505
            };
            this._Button.Clicked += button_OnClicked;
            this._Button.DblClicked += button_OnDblClicked;
            this._Button1.Clicked += button1_OnClicked;
            this._Button1.DblClicked += button1_OnDblClicked;

            this._Button3 = new NativeButton
            {
                Location = new Point(300, 10),
                Width = 20,
                Height = 30,
                Name = "SelectFolder",
                Text = "…"
            };

            this._Button3.Clicked += Button3_Click;
            this._ComboBox = new NativeComboBox();
            this._ComboBox.Location = new Point(350, 10);
            
            this._ComboBox.Height = 30;
            this._ComboBox.Width = 200;
            this._ComboBox.Name = "cbbTest";
            this._ComboBox.ForeColor = ColorTool.Blue;
            this._ComboBox.BackColor = ColorTool.Green;
            this._ComboBox.Font = new Font() { Name = "Arial", Size = 10 };
            this._ComboBox.SelChange += ComboBox_SelChange;


            this._TextBox = new NativeTextBox
            {
                Left = 10,
                Top = 50,
                Width = 100,
                Height = 30,
                Text = "ATEST",
                Name = "txtTest",
                Font = new Font() { Name = "Arial", Size = 14 },
                ForeColor = ColorTool.Read
                //ControlId = 502
            };
            this._TextBox.Change += TextBox_Change;

            this._TextBox2 = new NativeTextBox
            {
                Left = 10,
                Top = 150,
                Width = 100,
                Height = 30,
                Text = "",
                Name = "txt2Test",
                //ControlId = 503,
                BackColor = ColorTool.Black,
                ForeColor = ColorTool.White

            };

            this._Label1 = new NativeLabel
            {
                Left = 10,
                Top = 200,
                Width = 100,
                Height = 30,
                Text = "Dies ist ein Label"//,
                                           //BackColor=ColorTool.Read,
                                           //ForeColor = ColorTool.Green,
                                           //ControlId = 504

            };
            this._Label1.Clicked += Label1_Click;
            this._Label1.DblClicked += Label1_DblClick;

            this._Bitmap = new NativeBitmap();
            this._Bitmap.BitMap = "Skype.bmp";
            this._Bitmap.Left = 150;
            this._Bitmap.Top = 50;
            this._Bitmap.Width = 100;
            this._Bitmap.Height = 100;

            this._CheckBox = new NativeCheckBox();
            this._CheckBox.Left = 300;
            this._CheckBox.Top = 50;
            this._CheckBox.Width = 200;
            this._CheckBox.Height = 30;
            this._CheckBox.Text = "TEST CHECKBOX";
            this._CheckBox.BackColor = ColorTool.White;
            this._CheckBox.Checked = true;

            this._ListBox = new NativeListBox();
            this._ListBox.Left = 300;
            this._ListBox.Top = 200;
            this._ListBox.Width = 400;
            this._ListBox.Height = 400;
            this._ListBox.BackColor = ColorTool.Yellow;
            this._ListBox.ForeColor = ColorTool.Read;
            this._ListBox.Font = new Font() { Name = "Arial", Size = 16 };
            this._ListBox.MultiSelect = true;
            this._ListBox.DblClicked+=ListBox_DblClicked;
            
            this._ListBox.SelChange+=ListBox_SelChange;

            this._ProgressBar = new NativeProgress
            {
                Left = 10,
                Top = 250,
                Width = 150,
                Height = 30//,
                //ControlId = 507
            };



            this._TextBox.Clicked += TextBox_Click;
            
            this.Controls.Add(this._Button);
            this.Controls.Add(this._Button1);
            this.Controls.Add(this._Button3);
            this.Controls.Add(this._ComboBox);
            this.Controls.Add(this._TextBox);
            this.Controls.Add(this._TextBox2);
            this.Controls.Add(this._Label1);
            this.Controls.Add(this._Bitmap);
            this.Controls.Add(this._CheckBox);
            this.Controls.Add(this._ListBox);
            this.Controls.Add(this._ProgressBar);
            this.Controls.Add(this._Timer);
            this.Controls.Add(this._ControlTest);
            Click += Window1_Click;
            DoubleClick += Window1_DblClick;
            Create += Window1_Create;
            this.MouseMove += Window1_MoseMove;
        }