Esempio n. 1
0
        private void browse_btn_Click(object sender, EventArgs e)
        {
            using var OFD = new OpenFileDialog();
            if (OFD.ShowDialog() == DialogResult.OK) // Test result.
            {
                targetFileName = OFD.FileName;
                using (Image tmpImg = Image.FromFile(targetFileName))
                {
                    var destRect  = new Rectangle(0, 0, 502, 325);
                    var destImage = new Bitmap(502, 325);

                    destImage.SetResolution(tmpImg.HorizontalResolution, tmpImg.VerticalResolution);

                    using (var graphics = Graphics.FromImage(destImage))
                    {
                        graphics.CompositingMode    = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                        graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                        graphics.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                        graphics.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                        graphics.PixelOffsetMode    = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

                        using var wrapMode = new System.Drawing.Imaging.ImageAttributes();
                        wrapMode.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY);
                        graphics.DrawImage(tmpImg, destRect, 0, 0, tmpImg.Width, tmpImg.Height, GraphicsUnit.Pixel, wrapMode);
                    }

                    pictureBox.Image = destImage;
                }

                this.Height = maxHeight;
                GF.enableBtn(save_btn, Color.Green);
                this.CenterToScreen();
            }
        }
        void newBill()
        {
            print_btn.Visible = false;

            product_DGV.Rows.Clear();
            product_DGV.Enabled = true;
            calculateGrandTotal();

            payment_DGV.Rows.Clear();
            payment_DGV.Enabled = true;
            calculatePaid();

            bill_search_btn.Text = "ค้นหาใบเสร็จ";
            product_code.Enabled = true;
            GF.enableBtn(add_product_btn, Color.FromArgb(255, 128, 0));
            GF.enableBtn(add_payment_btn, Color.FromArgb(255, 128, 0));
            GF.enableBtn(manage_btn, Color.Green);

            void_btn.Visible = false;
            void_txt.Visible = false;
        }