コード例 #1
0
ファイル: SkladokUlaz.cs プロジェクト: Brumiko/MobTrenisIS
 public void SkeniranjeGotovo(string barkod, BarcodeSymbology simbologija)
 {
     if (simbologija == BarcodeSymbology.Code128)
     {
         for (int i = 0; i < brRedaka; i++)
         {
             if (dgLokacija[i, 0].ToString() == barkod)
             {
                 // Deselektiraj do sada selektirani redak (radi i za više redaka)...
                 for (int j = 0; j < brRedaka; j++)
                 {
                     if (dgLokacija.IsSelected(j))
                     {
                         dgLokacija.UnSelect(j);
                         break;
                     }
                 }
                 // ... pa selektiraj onaj pronaðen barkodom.
                 dgLokacija.Select(i);
                 dgLokacija.CurrentRowIndex = i;
                 break;
             }
         }
         txtLokacija.Text = barkod;
         txtKolicina.Focus();
     }
     else
     {
         Poruke.SvirajGresku();
         MessageBox.Show(Poruke.BarkodNijeLokacijski);
     }
 }
コード例 #2
0
ファイル: InvPregled.cs プロジェクト: Brumiko/MobTrenisIS
 public void SkeniranjeGotovo(string barkod, BarcodeSymbology simbologija)
 {
     if (simbologija == BarcodeSymbology.Code128)
     {
         txtLokacijaOznaka.Text = barkod;
     }
     else
     {
         txtRobaSifra.Text = barkod;
     }
 }
コード例 #3
0
ファイル: InvUpisnik.cs プロジェクト: Brumiko/MobTrenisIS
        public void SkeniranjeGotovo(string barkod, BarcodeSymbology simbologija)
        {
            ResetirajStilPoruke();

            if (!pnlRoba.Visible)
            {
                if (simbologija == BarcodeSymbology.Code128)
                {
                    txtLokacijaOznaka.Text = barkod;
                    btnLokacija.Focus();
                }
                else
                {
                    Poruke.SvirajGresku();
                    MessageBox.Show(Poruke.BarkodNijeLokacijski);
                }
            }
            else
            {
                DataSet ds = null;
                try
                {
                    ds = Config.MobTrenisWS.RobaDajPoBarkodu(barkod);
                    if (ds != null)
                    {
                        if (ds.Tables[0].Rows.Count == 1)
                        {
                            lblPoruka.Text = ds.Tables[0].Rows[0]["RobaSifra"].ToString() + ": " + ds.Tables[0].Rows[0]["RobaNaziv"].ToString() + ", dobavljaè: " + ds.Tables[0].Rows[0]["DobavljacSifra"].ToString();
                            txtRobaBarkod.Text = barkod;
                            txtRobaKolicina.Focus();
                        }
                        else
                        {
                            Poruke.SvirajGresku();
                            MessageBox.Show(Poruke.RobaNePostoji);
                        }
                    }
                    else
                    {
                        Poruke.SvirajGresku();
                        MessageBox.Show(Poruke.RobaGreska + "(conn) ");
                    }
                }
                catch (Exception ex)
                {
                    Poruke.SvirajGresku();
                    MessageBox.Show(Poruke.RobaGreska + "(WS) " + ex.Message);
                }
                finally
                {
                    ds.Dispose();
                }
            }
        }
コード例 #4
0
ファイル: NaljUpisnik.cs プロジェクト: Brumiko/MobTrenisIS
 public void SkeniranjeGotovo(string barkod, BarcodeSymbology simbologija)
 {
     if (simbologija == BarcodeSymbology.Code128)
     {
         txtLokacija.Text = barkod;
     }
     else
     {
         Poruke.SvirajGresku();
         MessageBox.Show(Poruke.BarkodNijeLokacijski);
     }
 }
コード例 #5
0
ファイル: SkladokOtprema.cs プロジェクト: Brumiko/MobTrenisIS
 /// <summary>
 /// 
 /// </summary>
 /// <param name="barkod"></param>
 /// <param name="simbologija"></param>
 public void SkeniranjeGotovo(string barkod, BarcodeSymbology simbologija)
 {
     if (simbologija == BarcodeSymbology.Code39)
     {
         txtDokument.Text = barkod;
     }
     else
     {
         Poruke.SvirajGresku();
         MessageBox.Show(Poruke.BarkodNijeDokumentni);
     }
 }
コード例 #6
0
        /// <summary>
        /// Generates a barcode URI.
        /// </summary>
        /// <param name="helper">The HTML helper.</param>
        /// <param name="text">The text to be encoded.</param>
        /// <param name="symbology">The barcode symbology to use.</param>
        /// <param name="height">The height.</param>
        /// <param name="scale">
        /// The scale factor to use (null = use default for symbology).
        /// </param>
        /// <param name="useExtensionlessUri">
        /// <c>true</c> to use extensionless URI; otherwise, <c>false</c>.
        /// </param>
        /// <returns></returns>
        public static string Barcode(
            this UrlHelper helper,
            string text,
            BarcodeSymbology symbology,
            int height = 30,
            int? scale = null,
            bool useExtensionlessUri = true)
        {
            BarcodeImageUriBuilder builder = null;

            // We cheat and get the default metrics
            var temp = BarcodeDrawFactory.GetSymbology(symbology);
            var metrics = temp.GetDefaultMetrics(height);
            if (scale != null)
            {
                metrics.Scale = scale.Value;
            }
            BarcodeMetrics1d metrics1d = metrics as BarcodeMetrics1d;
            if (metrics1d != null)
            {
                builder =
                    new BarcodeImageUriBuilder
                    {
                        EncodingScheme = symbology,
                        Text = text,
                        BarMaxHeight = metrics1d.MaxHeight,
                        BarMinHeight = metrics1d.MinHeight,
                        BarMaxWidth = metrics1d.MaxWidth,
                        BarMinWidth = metrics1d.MinWidth,
                        Scale = metrics.Scale,
                        UseExtensionlessUri = useExtensionlessUri
                    };
            }
            else
            {
                BarcodeMetricsQr metricsQr = metrics as BarcodeMetricsQr;
                if (metricsQr != null)
                {
                    builder =
                        new BarcodeImageUriBuilder
                        {
                            EncodingScheme = BarcodeSymbology.CodeQr,
                            Text = text,
                            QrEncodingMode = metricsQr.EncodeMode,
                            QrErrorCorrect = metricsQr.ErrorCorrection,
                            QrVersion = metricsQr.Version,
                            Scale = metrics.Scale,
                            UseExtensionlessUri = useExtensionlessUri
                        };
                }
            }
            return helper.Content(builder.ToString());
        }
コード例 #7
0
ファイル: SkladokIzlok.cs プロジェクト: Brumiko/MobTrenisIS
 public void SkeniranjeGotovo(string barkod, BarcodeSymbology simbologija)
 {
     lblPoruka.Text = String.Empty;
     if (simbologija == BarcodeSymbology.Code128)
     {
         txtIzlok.Text = barkod;
     }
     else
     {
         Poruke.SvirajGresku();
         lblPoruka.Text = Poruke.BarkodNijeLokacijski;
     }
 }
コード例 #8
0
        /// <summary>
        /// Gets the barcode drawing object for rendering the specified
        /// barcode symbology.
        /// </summary>
        /// <param name="symbology">
        /// A value from the <see cref="T:Zen.Barcode.BarcodeSymbology"/> enumeration.
        /// </param>
        /// <returns>
        /// A class derived from <see cref="T:Zen.Barcode.BarcodeDraw"/>.
        /// </returns>
        /// <exception cref="T:System.ArgumentException">
        /// Thrown if the specified symbology is invalid or unknown.
        /// </exception>
        public static BarcodeDraw GetSymbology(BarcodeSymbology symbology)
        {
            switch (symbology)
            {
            case BarcodeSymbology.Code39NC:
                return(Code39WithoutChecksum);

            case BarcodeSymbology.Code39C:
                return(Code39WithChecksum);

            case BarcodeSymbology.Code93:
                return(Code93WithChecksum);

            case BarcodeSymbology.Code128:
                return(Code128WithChecksum);

            case BarcodeSymbology.Code11NC:
                return(Code11WithoutChecksum);

            case BarcodeSymbology.Code11C:
                return(Code11WithChecksum);

            case BarcodeSymbology.CodeEan13:
                return(CodeEan13WithChecksum);

            case BarcodeSymbology.CodeEan8:
                return(CodeEan8WithChecksum);

            case BarcodeSymbology.Code25StandardNC:
                return(Code25StandardWithoutChecksum);

            case BarcodeSymbology.Code25StandardC:
                return(Code25StandardWithChecksum);

            case BarcodeSymbology.Code25InterleavedNC:
                return(Code25InterleavedWithoutChecksum);

            case BarcodeSymbology.Code25InterleavedC:
                return(Code25InterleavedWithChecksum);

            //case BarcodeSymbology.CodePdf417:
            //    return CodePdf417;
            case BarcodeSymbology.CodeQr:
                return(CodeQr);

            default:
                throw new NotSupportedException("Barcode Symbology Not Supported");
            }
        }
コード例 #9
0
        /// <summary>
        /// Gets the barcode drawing object for rendering the specified
        /// barcode symbology.
        /// </summary>
        /// <param name="symbology">
        /// A value from the <see cref="T:Zen.Barcode.BarcodeSymbology"/> enumeration.
        /// </param>
        /// <returns>
        /// A class derived from <see cref="T:Zen.Barcode.BarcodeDraw"/>.
        /// </returns>
        /// <exception cref="T:System.ArgumentException">
        /// Thrown if the specified symbology is invalid or unknown.
        /// </exception>
        public static BarcodeDraw GetSymbology(BarcodeSymbology symbology)
        {
            switch (symbology)
            {
            case BarcodeSymbology.Code39NC:
                return(Code39WithoutChecksum);

            case BarcodeSymbology.Code39C:
                return(Code39WithChecksum);

            case BarcodeSymbology.Code93:
                return(Code93WithChecksum);

            case BarcodeSymbology.Code128:
                return(Code128WithChecksum);

            case BarcodeSymbology.Code11NC:
                return(Code11WithoutChecksum);

            case BarcodeSymbology.Code11C:
                return(Code11WithChecksum);

            case BarcodeSymbology.CodeEan13:
                return(CodeEan13WithChecksum);

            case BarcodeSymbology.CodeEan8:
                return(CodeEan8WithChecksum);

            case BarcodeSymbology.Code25StandardNC:
                return(Code25StandardWithoutChecksum);

            case BarcodeSymbology.Code25StandardC:
                return(Code25StandardWithChecksum);

            case BarcodeSymbology.Code25InterleavedNC:
                return(Code25InterleavedWithoutChecksum);

            case BarcodeSymbology.Code25InterleavedC:
                return(Code25InterleavedWithChecksum);

            case BarcodeSymbology.CodePdf417:
                return(CodePdf417WithChecksum);

            default:
                throw new ArgumentException(
                          Resources.BarcodeSymbologyInvalid, "symbology");
            }
        }
コード例 #10
0
        protected void updateButton_Click(object sender, EventArgs e)
        {
            BarcodeSymbology symbology = BarcodeSymbology.Unknown;

            if (barcodeSymbology.SelectedIndex != -1)
            {
                symbology = (BarcodeSymbology)barcodeSymbology.SelectedIndex + 1;
            }
            string text = barcodeText.Text.Trim();

            if (!string.IsNullOrEmpty(text) && symbology != BarcodeSymbology.Unknown)
            {
                barcodeRender.BarcodeEncoding = symbology;
                barcodeRender.Text            = text;
            }
        }
コード例 #11
0
ファイル: Map.aspx.cs プロジェクト: Aseeraa/KCGameOn
        private static string getBarcode(string barcode)
        {
            BarcodeSymbology s          = BarcodeSymbology.Code39NC;
            BarcodeDraw      drawObject = BarcodeDrawFactory.GetSymbology(s);
            var metrics = drawObject.GetDefaultMetrics(45);

            metrics.Scale = 1;
            var barcodeImage = drawObject.Draw(barcode, metrics);

            using (MemoryStream ms = new MemoryStream())
            {
                barcodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                byte[] imageBytes = ms.ToArray();

                return(Convert.ToBase64String(imageBytes));
            }
        }
コード例 #12
0
        /// <summary>
        /// Generates an HTML image tag that contains a barcode representation
        /// of the specified text.
        /// </summary>
        /// <param name="helper">The HTML helper.</param>
        /// <param name="text">The text to render.</param>
        /// <param name="symbology">The barcode symbology to use.</param>
        /// <param name="height">The height (1D barcodes only).</param>
        /// <param name="scale">
        /// The scale factor to use (null = use default for symbology).
        /// </param>
        /// <param name="useExtensionlessUri">
        /// <c>true</c> to use extensionless URI; otherwise, <c>false</c>.
        /// </param>
        /// <param name="imageHtmlAttributes">Attributes for the image</param>
        /// <returns></returns>
        public static string BarcodeImage(
            this HtmlHelper helper,
            string text,
            BarcodeSymbology symbology,
            int height = 30,
            int?scale  = null,
            bool useExtensionlessUri   = true,
            object imageHtmlAttributes = null)
        {
            var urlHelper = new UrlHelper(helper.ViewContext.RequestContext);

            // Create image
            var imageTagBuilder = new TagBuilder("img");

            imageTagBuilder.MergeAttribute("src", urlHelper.Barcode(text, symbology, height, scale, useExtensionlessUri));
            imageTagBuilder.MergeAttribute("alt", urlHelper.Content(text));
            imageTagBuilder.MergeAttributes(new RouteValueDictionary(imageHtmlAttributes));
            return(imageTagBuilder.ToString(TagRenderMode.SelfClosing));
        }
コード例 #13
0
        /// <summary>
        /// Генерирует BarCode в формате Code128
        /// </summary>
        /// <param name="id">ID договора</param>
        /// <param name="contractNumber">Номер договора</param>
        /// <returns>BarCode в формате Base64</returns>
        public static string GetBarcode(string id, string contractNumber)
        {
            const BarcodeSymbology type = BarcodeSymbology.Code128;
            var drawObject = BarcodeDrawFactory.GetSymbology(type);
            var metrics    = drawObject.GetDefaultMetrics(60);

            metrics.Scale = 2;

            var endodedIdAndContractNumber = Encoder.BuildCode(id, contractNumber);
            var barcodeImage = drawObject.Draw(endodedIdAndContractNumber, metrics);

            using (var memoryStream = new MemoryStream())
            {
                barcodeImage.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
                var imageBytes = memoryStream.ToArray();

                return(Convert.ToBase64String(imageBytes));
            }
        }
        private void removeSelectedFromScanBarcodeTypeListButton_Click(object sender, EventArgs e)
        {
            // remove selected barcodes from reader settings
            List <BarcodeSymbology> symbologies = new List <BarcodeSymbology>();

            BarcodeSymbology[] scanSymbologies = new BarcodeSymbology[scanBarcodeTypesListBox.Items.Count];
            scanBarcodeTypesListBox.Items.CopyTo(scanSymbologies, 0);
            foreach (BarcodeSymbology symbology in scanSymbologies)
            {
                if (!scanBarcodeTypesListBox.SelectedItems.Contains(symbology))
                {
                    symbologies.Add(symbology);
                }
            }

            // clear barcode symbologies in the barcode reader settings
            BarcodeReaderSettings.ScanBarcodeTypes = BarcodeType.None;
            BarcodeReaderSettings.ScanBarcodeSubsets.Clear();
            // add barcode symbologies to the barcode reader settings
            AddBarcodeSymbologiesToBarcodeReaderSettings(symbologies.ToArray());
        }
コード例 #15
0
        /// <summary>
        /// Prepares the form for printing and testing of the symbology.
        /// </summary>
        /// <param name="symbology">Zero-based symbology index.</param>
        private void GenerateRandomTestCases(BarcodeSymbology symbology)
        {
            switch (symbology)
            {
            case BarcodeSymbology.Code39NC:
                GenerateTestDigit(symbology, 5, 10);
                break;

            case BarcodeSymbology.Code39C:
                GenerateTestDigit(symbology, 5, 10);
                break;

            case BarcodeSymbology.Code93:
                GenerateTestDigit(symbology, 5, 10);
                GenerateTestAlpha(symbology, 5, 10, true, false);
                break;

            case BarcodeSymbology.Code128:
                GenerateTestDigit(symbology, 5, 10);
                GenerateTestAlpha(symbology, 5, 10, true, true);
                break;

            case BarcodeSymbology.Code11NC:
            case BarcodeSymbology.Code11C:
            case BarcodeSymbology.Code25StandardNC:
            case BarcodeSymbology.Code25StandardC:
            case BarcodeSymbology.Code25InterleavedNC:
            case BarcodeSymbology.Code25InterleavedC:
                GenerateTestDigit(symbology, 5, 10);
                break;

            case BarcodeSymbology.CodeEan13:
                GenerateTestDigit(symbology, 5, 12);
                break;

            case BarcodeSymbology.CodeEan8:
                GenerateTestDigit(symbology, 5, 7);
                break;
            }
        }
 private void scanBarcodeTypesListBox_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     // if barcode symbology is selected
     if (scanBarcodeTypesListBox.SelectedItem != null)
     {
         // show information about barcode symbology
         BarcodeSymbology selectedBarcodeSymbology = (BarcodeSymbology)scanBarcodeTypesListBox.SelectedItem;
         StringBuilder    barcodeInfo = new StringBuilder();
         barcodeInfo.AppendLine(string.Format("Symbology name: {0}", selectedBarcodeSymbology));
         if (selectedBarcodeSymbology is BarcodeSymbologySubset)
         {
             barcodeInfo.AppendLine(string.Format("Base symbology type: {0}", selectedBarcodeSymbology.BarcodeType));
             BarcodeSymbologySubset selectedBarcodeSymbologySubset = (BarcodeSymbologySubset)selectedBarcodeSymbology;
             if (selectedBarcodeSymbologySubset.BaseSubset != null)
             {
                 barcodeInfo.AppendLine(string.Format("Base symbology subset: {0}", selectedBarcodeSymbologySubset.BaseSubset));
             }
         }
         barcodeInfo.AppendLine(string.Format("Attributes: {0}", selectedBarcodeSymbology.Attributes));
         MessageBox.Show(barcodeInfo.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #17
0
        public static System.IO.MemoryStream GetQRCodeImage(string serialNo)
        {
            //Code128BarcodeDraw bdf = BarcodeDrawFactory.Code128WithChecksum;
            //System.Drawing.Image img = bdf.Draw(serialNo, 55, 2);

            BarcodeSymbology s          = BarcodeSymbology.Code128;
            BarcodeDraw      drawObject = BarcodeDrawFactory.CodeQr;
            var metrics = drawObject.GetDefaultMetrics(50);

            metrics.Scale = 5;
            var img = drawObject.Draw(serialNo, metrics);

            ImageConverter ic = new ImageConverter();

            Byte[] ba = (Byte[])ic.ConvertTo(img, typeof(Byte[]));

            MemoryStream memoryStream = new MemoryStream(ba);

            memoryStream.Flush();
            memoryStream.Seek(0, SeekOrigin.Begin);

            return(memoryStream);
        }
コード例 #18
0
        public static Image ToImageWithCodeString(string barcode, BarcodeSymbology barcodeSymbology = BarcodeSymbology.Code128)
        {
            var generator = Lib.Barcode.BarcodeDrawFactory.GetSymbology(barcodeSymbology);
            var metrics   = generator.GetDefaultMetrics(60);

            metrics.Scale = 5;
            Image        imgBarcode = generator.Draw(barcode, metrics);
            Bitmap       image      = new Bitmap(imgBarcode.Width, imgBarcode.Height + 20);
            Graphics     g          = Graphics.FromImage(image);
            Rectangle    textBound  = new Rectangle(new Point(0, imgBarcode.Height + 1), new Size(imgBarcode.Width, 20));
            Rectangle    bound      = new Rectangle(new Point(0, 0), new Size(image.Width, image.Height));
            Rectangle    imageBound = new Rectangle(new Point(image.Width / 6, 10), new Size(image.Width / 3 * 2, imgBarcode.Height - 10));
            Font         font       = new Font(new FontFamily("宋体"), 15);
            StringFormat format     = new StringFormat();

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;
            g.FillRectangle(new SolidBrush(Color.White), bound);
            g.DrawImage(imgBarcode, imageBound);
            g.DrawString(barcode, font, new SolidBrush(Color.Black), textBound, format);

            return(image);
        }
コード例 #19
0
        /// <summary>
        /// Adds the test case.
        /// </summary>
        /// <param name="symbology">The symbology.</param>
        /// <param name="text">The text.</param>
        public void AddTestCase(BarcodeSymbology symbology, string text)
        {
            // We cannot add unknown symbology to test-case list
            if (symbology == BarcodeSymbology.Unknown)
            {
                throw new ArgumentException("symbology");
            }

            // Insert into existing group if we have one
            foreach (SymbologyTestGroup group in GroupTests)
            {
                if (group.Symbology == symbology)
                {
                    group.AddTestCase(text);
                    return;
                }
            }

            // Create new group as required.
            SymbologyTestGroup newGroup = new SymbologyTestGroup(symbology);

            newGroup.AddTestCase(text);
            GroupTests.Add(newGroup);
        }
コード例 #20
0
ファイル: Default.aspx.cs プロジェクト: fanda-india/prints
        protected void updateButton_Click(object sender, EventArgs e)
        {
            BarcodeSymbology symbology = BarcodeSymbology.Unknown;

            if (barcodeSymbology.SelectedIndex != -1)
            {
                symbology = (BarcodeSymbology)barcodeSymbology.SelectedIndex + 1;
            }
            string text = barcodeText.Text.Trim();

            string scaleText = barcodeScale.Text.Trim();
            int    scale;

            if (!int.TryParse(scaleText, out scale))
            {
                if (symbology == BarcodeSymbology.CodeQr)
                {
                    scale = 3;
                }
                else
                {
                    scale = 1;
                }
            }
            else if (scale < 1)
            {
                scale = 1;
            }

            if (!string.IsNullOrEmpty(text) && symbology != BarcodeSymbology.Unknown)
            {
                barcodeRender.BarcodeEncoding = symbology;
                barcodeRender.Scale           = scale;
                barcodeRender.Text            = text;
            }
        }
コード例 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SymbologyTestGroup"/> class.
 /// </summary>
 /// <param name="symbology">The symbology.</param>
 public SymbologyTestGroup(BarcodeSymbology symbology)
 {
     _symbology = symbology;
 }
コード例 #22
0
        private static string GetFileNameFromParams(
            string text, int scale, bool useExtensionUri,
            BarcodeSymbology encodingScheme, int barMinHeight, int barMaxHeight,
            int barMinWidth, int barMaxWidth)
        {
            // Build key string
            string fileName = string.Format(
                "Barcode[{0},{1},{2},{3},{4},{5}]:{6}",
                (int)encodingScheme, barMinHeight, barMaxHeight,
                barMinWidth, barMaxWidth, scale, text);

            // Return encoded filename based on key
            return BuildEncodedFileName(fileName, useExtensionUri);
        }
コード例 #23
0
 public static bool ToPrinterBarcodeSymbology(string value, out BarcodeSymbology output)
 {
     return(PrinterBarcodeSymbologyDictionary.TryGetKey(value, out output));
 }
コード例 #24
0
 /// <summary>
 /// Sets the symbology which will be used to encode the value of the barcode
 /// </summary>
 public BarcodeBuilder Encoding(BarcodeSymbology encoding)
 {
     Component.Encoding = encoding;
     return(this);
 }
コード例 #25
0
        public WriteBarcodeDialogBox(BarcodeEngine barcodeEngine, RasterImage sampleSymbologiesRasterImage, LeadRect bounds, int groupIndex, BarcodeSymbology symbology, WriteBarcodeDelegate writeBarcodeDelegate)
        {
            InitializeComponent();

            _availableSymbologyListBox.SampleSymbologiesRasterImage = sampleSymbologiesRasterImage;

            _barcodeEngine = barcodeEngine;
            _bounds        = bounds;

            _selectedGroupIndex = groupIndex;
            _selectedSymbology  = symbology;

            _writeBarcodeDelegate = writeBarcodeDelegate;
        }
コード例 #26
0
        private byte[] DrawImage()
        {
            // Determine barcode symbology
            BarcodeSymbology symbology     = BarcodeSymbology.Unknown;
            string           symbologyText = (string)GetCustomProperty("barcode:Symbology");

            symbology = (BarcodeSymbology)Enum.Parse(typeof(BarcodeSymbology), symbologyText);
            if (symbology != BarcodeSymbology.Unknown)
            {
                // Create draw object
                BarcodeDraw drawObject = BarcodeDrawFactory.GetSymbology(symbology);

                // Get default metrics and override with values specified in CRI
                // TODO: Need more elegant method for doing this...
                BarcodeMetrics metrics = drawObject.GetDefaultMetrics(30);
                metrics.Scale =
                    GetCustomPropertyInt32("barcode:Scale", metrics.Scale);

                BarcodeMetrics1d metrics1d = metrics as BarcodeMetrics1d;
                if (metrics1d != null)
                {
                    metrics1d.MaxHeight =
                        GetCustomPropertyInt32("barcode:MaximumBarHeight", metrics1d.MaxHeight);
                    metrics1d.MinHeight =
                        GetCustomPropertyInt32("barcode:MinimumBarHeight", metrics1d.MinHeight);
                    metrics1d.MinWidth =
                        GetCustomPropertyInt32("barcode:MinimumBarWidth", metrics1d.MinWidth);
                    metrics1d.MaxWidth =
                        GetCustomPropertyInt32("barcode:MaximumBarWidth", metrics1d.MaxWidth);
                    int interGlyphSpacing =
                        GetCustomPropertyInt32("barcode:InterGlyphSpacing", -1);
                    if (interGlyphSpacing >= 0)
                    {
                        metrics1d.InterGlyphSpacing = interGlyphSpacing;
                    }
                    metrics1d.RenderVertically =
                        GetCustomPropertyBool("barcode:RenderVertically", metrics1d.RenderVertically);
                }
                else if (symbology == BarcodeSymbology.CodeQr)
                {
                    BarcodeMetricsQr qrMetrics = (BarcodeMetricsQr)metrics;
                    qrMetrics.Version =
                        GetCustomPropertyInt32("barcode:QrVersion", qrMetrics.Version);
                    qrMetrics.EncodeMode = (QrEncodeMode)
                                           GetCustomPropertyInt32("barcode:QrEncodeMode", (int)qrMetrics.EncodeMode);
                    qrMetrics.ErrorCorrection = (QrErrorCorrection)
                                                GetCustomPropertyInt32("barcode:QrErrorCorrection", (int)qrMetrics.ErrorCorrection);
                }

                // Get the text to render
                string textToRender = (string)GetCustomProperty("barcode:Text");

                // Determine available space for rendering
                int criWidth  = (int)(_cri.Width.ToInches() * DPI);
                int criHeight = (int)(_cri.Height.ToInches() * DPI);

                // Create bitmap of the appropriate size
                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(
                    criWidth, criHeight, PixelFormat.Format32bppArgb);
                using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp))
                {
                    // Clear entire background
                    g.Clear(System.Drawing.Color.White);

                    // Get barcode image
                    System.Drawing.Image barcodeImage =
                        drawObject.Draw(textToRender, metrics);

                    // Centre the image
                    int x = (bmp.Width - barcodeImage.Width) / 2;
                    int y = (bmp.Height - barcodeImage.Height) / 2;
                    g.DrawImageUnscaled(barcodeImage, x, y);
                }

                // Create memory stream for new image
                using (MemoryStream stream = new MemoryStream())
                {
                    // Save image and setup CRI image
                    bmp.Save(stream, ImageFormat.Bmp);
                    return(stream.ToArray());
                }
            }
            return(null);
        }
コード例 #27
0
        private static BarcodeMetrics GetBarcodeMetricsFromContext(
            HttpContext context, BarcodeSymbology symbology)
        {
            BarcodeDraw    drawObject = BarcodeDrawFactory.GetSymbology(symbology);
            BarcodeMetrics metrics    = drawObject.GetDefaultMetrics(30);

            BarcodeMetrics1d metrics1d = metrics as BarcodeMetrics1d;

            if (metrics1d != null)
            {
                // Get query parameter strings
                string barHeightText        = context.Request.QueryString["bh"];
                string barWidthText         = context.Request.QueryString["bw"];
                string minimumBarHeightText = context.Request.QueryString["mbh"];
                string maximumBarHeightText = context.Request.QueryString["xbh"];
                string minimumBarWidthText  = context.Request.QueryString["mbw"];
                string maximumBarWidthText  = context.Request.QueryString["xbw"];
                string interGlyphSpaceText  = context.Request.QueryString["igs"];

                int value;
                if (int.TryParse(barWidthText, out value))
                {
                    metrics1d.MinWidth = metrics1d.MaxWidth = value;
                }
                if (int.TryParse(minimumBarWidthText, out value))
                {
                    metrics1d.MinWidth = value;
                }
                if (int.TryParse(maximumBarWidthText, out value))
                {
                    metrics1d.MaxWidth = value;
                }
                if (int.TryParse(barHeightText, out value))
                {
                    metrics1d.MinHeight = metrics1d.MaxHeight = value;
                }
                if (int.TryParse(minimumBarHeightText, out value))
                {
                    metrics1d.MinHeight = value;
                }
                if (int.TryParse(maximumBarHeightText, out value))
                {
                    metrics1d.MaxHeight = value;
                }
                if (int.TryParse(interGlyphSpaceText, out value))
                {
                    metrics1d.InterGlyphSpacing = value;
                }
            }
            else if (symbology == BarcodeSymbology.CodeQr)
            {
                BarcodeMetricsQr qrMetrics = (BarcodeMetricsQr)metrics;

                string encodeMode   = context.Request.QueryString["em"];
                string errorCorrect = context.Request.QueryString["ec"];
                string scale        = context.Request.QueryString["sca"];
                string version      = context.Request.QueryString["ver"];

                int value;
                if (int.TryParse(encodeMode, out value))
                {
                    qrMetrics.EncodeMode = (QrEncodeMode)value;
                }
                if (int.TryParse(errorCorrect, out value))
                {
                    qrMetrics.ErrorCorrection = (QrErrorCorrection)value;
                }
                if (int.TryParse(scale, out value))
                {
                    qrMetrics.Scale = value;
                }
                if (int.TryParse(version, out value))
                {
                    qrMetrics.Version = value;
                }
            }

            return(metrics);
        }
コード例 #28
0
        /// <summary>
        /// Generates an HTML image tag that contains a barcode representation
        /// of the specified text.
        /// </summary>
        /// <param name="helper">The HTML helper.</param>
        /// <param name="text">The text to render.</param>
        /// <param name="symbology">The barcode symbology to use.</param>
        /// <param name="height">The height (1D barcodes only).</param>
        /// <param name="scale">
        /// The scale factor to use (null = use default for symbology).
        /// </param>
        /// <param name="useExtensionlessUri">
        /// <c>true</c> to use extensionless URI; otherwise, <c>false</c>.
        /// </param>
        /// <param name="imageHtmlAttributes">Attributes for the image</param>
        /// <returns></returns>
        public static string BarcodeImage(
            this HtmlHelper helper,
            string text,
            BarcodeSymbology symbology,
            int height = 30,
            int? scale = null,
            bool useExtensionlessUri = true,
            object imageHtmlAttributes = null)
        {
            var urlHelper = new UrlHelper(helper.ViewContext.RequestContext);

            // Create image
            var imageTagBuilder = new TagBuilder("img");
            imageTagBuilder.MergeAttribute("src", urlHelper.Barcode(text, symbology, height, scale, useExtensionlessUri));
            imageTagBuilder.MergeAttribute("alt", urlHelper.Content(text));
            imageTagBuilder.MergeAttributes(new RouteValueDictionary(imageHtmlAttributes));
            return imageTagBuilder.ToString(TagRenderMode.SelfClosing);
        }
コード例 #29
0
ファイル: BarcodeTools.cs プロジェクト: rrossenbg/vprint
        /// <summary>
        ///
        /// </summary>
        /// <param name="voucherNumber">82620159918434718610</param>
        /// <param name="height">40</param>
        /// <param name="size">2</param>
        /// <returns></returns>
        public static Bitmap BinaryWritePicture(string voucherNumber, int height, int size, BarcodeSymbology type = BarcodeSymbology.Code25InterleavedNC)
        {
            Debug.Assert(!voucherNumber.IsNullOrEmpty());
            var barcode = BarcodeDrawFactory.GetSymbology(type);
            var image   = barcode.Draw(voucherNumber, height, size);

            return((Bitmap)image);
        }
コード例 #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SymbologyTestCase"/> class.
 /// </summary>
 /// <param name="symbology">The symbology.</param>
 /// <param name="barcodeText">The barcode text.</param>
 /// <param name="maxBarHeight">Height of the max bar.</param>
 public SymbologyTestCase(BarcodeSymbology symbology, string barcodeText, int maxBarHeight)
 {
     _symbology = symbology;
     _maxBarHeight = maxBarHeight;
     _barcodeText = barcodeText;
 }
コード例 #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SymbologyTestCase"/> class.
 /// </summary>
 /// <param name="symbology">The symbology.</param>
 /// <param name="barcodeText">The barcode text.</param>
 /// <param name="maxBarHeight">Height of the max bar.</param>
 public SymbologyTestCase(BarcodeSymbology symbology, string barcodeText, int maxBarHeight)
 {
     _symbology    = symbology;
     _maxBarHeight = maxBarHeight;
     _barcodeText  = barcodeText;
 }
コード例 #32
0
ファイル: BarkodDodjela.cs プロジェクト: Brumiko/MobTrenisIS
 public void SkeniranjeGotovo(string barkod, BarcodeSymbology simbologija)
 {
     txtBarkod.Text = barkod;
 }
コード例 #33
0
        private void DecodeFileName()
        {
            string fileName = Path.GetFileNameWithoutExtension(_fileName);

            // Remove file extension and convert from base64
            byte[] encryptedFileName = HttpServerUtility.UrlTokenDecode(
                fileName);

            // Create memory stream backed against encrypted form
            MemoryStream memStm = new MemoryStream(encryptedFileName);

            // Read from crypto-stream via stream reader in UTF8
            StreamReader reader = new StreamReader(memStm, Encoding.UTF8);
            fileName = reader.ReadToEnd();

            // Lets see if we can parse the string
            Match m = FileNameParser.Match(fileName);
            if (m.Success)
            {
                // Validate the hash-code.
                string originalFilename = m.Result("${OriginalFilename}");
                string hashCode = m.Result("${HashCode}");
                if (originalFilename.GetHashCode() != Int32.Parse(hashCode))
                {
                    throw new InvalidOperationException("Filename is not valid.");
                }

                // Determine encoding system
                string encoding = m.Result("${EncodingSystem}");
                if (!string.IsNullOrEmpty(encoding))
                {
                    _encodingScheme = (BarcodeSymbology)Int32.Parse(encoding);
                }

                // Determine barcode height
                string barMinHeight = m.Result("${BarMinHeight}");
                if (!string.IsNullOrEmpty(barMinHeight))
                {
                    _barMinHeight = Int32.Parse(barMinHeight);
                }
                string barMaxHeight = m.Result("${BarMaxHeight}");
                if (!string.IsNullOrEmpty(barMaxHeight))
                {
                    _barMaxHeight = Int32.Parse(barMaxHeight);
                }

                // Determine barcode width
                string barMinWidth = m.Result("${BarMinWidth}");
                if (!string.IsNullOrEmpty(barMinWidth))
                {
                    _barMinWidth = Int32.Parse(barMinWidth);
                }
                string barMaxWidth = m.Result("${BarMaxWidth}");
                if (!string.IsNullOrEmpty(barMaxWidth))
                {
                    _barMaxWidth = Int32.Parse(barMaxWidth);
                }

                // Determine scale
                string scale = m.Result("${Scale}");
                if (!string.IsNullOrEmpty(scale))
                {
                    _scale = Int32.Parse(scale);
                }

                // Parse the barcode off the end of this string
                _text = m.Result("${BarCodePayload}");
                return;
            }

            m = QrFileNameParser.Match(fileName);
            if (m.Success)
            {
                // Validate the hash-code.
                string originalFilename = m.Result("${OriginalFilename}");
                string hashCode = m.Result("${HashCode}");
                if (originalFilename.GetHashCode() != Int32.Parse(hashCode))
                {
                    throw new InvalidOperationException("Filename is not valid.");
                }

                // Determine encoding system
                _encodingScheme = BarcodeSymbology.CodeQr;
                string encoding = m.Result("${EncodeMode}");
                if (!string.IsNullOrEmpty(encoding))
                {
                    _qrEncodingMode = (QrEncodeMode)Int32.Parse(encoding);
                }

                // Determine error correction scheme
                string errorCorrect = m.Result("${ErrorCorrect}");
                if (!string.IsNullOrEmpty(errorCorrect))
                {
                    _qrErrorCorrect = (QrErrorCorrection)Int32.Parse(errorCorrect);
                }

                // Determine version
                string version = m.Result("${Version}");
                if (!string.IsNullOrEmpty(version))
                {
                    _qrVersion = Int32.Parse(version);
                }

                // Determine scale
                string scale = m.Result("${Scale}");
                if (!string.IsNullOrEmpty(scale))
                {
                    _scale = Int32.Parse(scale);
                }

                // Parse the barcode off the end of this string
                _text = m.Result("${BarCodePayload}");
                return;
            }

            throw new InvalidOperationException("Filename is not valid.");
        }
コード例 #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SymbologyTestGroup"/> class.
 /// </summary>
 /// <param name="symbology">The symbology.</param>
 public SymbologyTestGroup(BarcodeSymbology symbology)
 {
     _symbology = symbology;
 }
コード例 #35
0
 /// <summary>
 /// Gets the barcode drawing object for rendering the specified
 /// barcode symbology.
 /// </summary>
 /// <param name="symbology">
 /// A value from the <see cref="T:Zen.Barcode.BarcodeSymbology"/> enumeration.
 /// </param>
 /// <returns>
 /// A class derived from <see cref="T:Zen.Barcode.BarcodeDraw"/>.
 /// </returns>
 /// <exception cref="T:System.ArgumentException">
 /// Thrown if the specified symbology is invalid or unknown.
 /// </exception>
 public static BarcodeDraw GetSymbology(BarcodeSymbology symbology)
 {
     switch (symbology)
     {
         case BarcodeSymbology.Code39NC:
             return Code39WithoutChecksum;
         case BarcodeSymbology.Code39C:
             return Code39WithChecksum;
         case BarcodeSymbology.Code93:
             return Code93WithChecksum;
         case BarcodeSymbology.Code128:
             return Code128WithChecksum;
         case BarcodeSymbology.Code11NC:
             return Code11WithoutChecksum;
         case BarcodeSymbology.Code11C:
             return Code11WithChecksum;
         case BarcodeSymbology.CodeEan13:
             return CodeEan13WithChecksum;
         case BarcodeSymbology.CodeEan8:
             return CodeEan8WithChecksum;
         case BarcodeSymbology.Code25StandardNC:
             return Code25StandardWithoutChecksum;
         case BarcodeSymbology.Code25StandardC:
             return Code25StandardWithChecksum;
         case BarcodeSymbology.Code25InterleavedNC:
             return Code25InterleavedWithoutChecksum;
         case BarcodeSymbology.Code25InterleavedC:
             return Code25InterleavedWithChecksum;
         case BarcodeSymbology.CodePdf417:
             return CodePdf417WithChecksum;
         default:
             throw new ArgumentException (
                 Resources.BarcodeSymbologyInvalid, "symbology");
     }
 }
コード例 #36
0
ファイル: Skladok.cs プロジェクト: Brumiko/MobTrenisIS
 public void SkeniranjeGotovo(string barkod, BarcodeSymbology simbologija)
 {
     if (btnTrazi.Text == "Traži")
     {
         if (simbologija == BarcodeSymbology.Code39)
         {
             txtDokument.Text = barkod;
         }
         else
         {
             Poruke.SvirajGresku();
             MessageBox.Show(Poruke.BarkodNijeDokumentni);
         }
     }
     else if (btnTrazi.Text == "Izmjena")
     {
         DataSet ds = null;
         try
         {
             ds = Config.MobTrenisWS.RobaDajSifruPoBarkodu(barkod);
             if (ds != null)
             {
                 if (ds.Tables[0].Rows.Count == 1)
                 {
                     bool stavkaPostoji = false;
                     for (int i = 0; i < brRedaka; i++)
                     {
                         if (sgStavka.Cells[i, 2].Text == ds.Tables[0].Rows[0]["MobRoba_Sifra"].ToString())
                         {
                             sgStavka.ActiveRowIndex = i;
                             sgStavka.EnsureVisible(i, 0);
                             stavkaPostoji = true;
                             break;
                         }
                     }
                     if (!stavkaPostoji)
                     {
                         rBarkod = String.Empty;
                         Poruke.SvirajGresku();
                         MessageBox.Show(Poruke.SkladokRobaNiMedStavkami);
                     }
                     else
                     {
     /*!!!*/                         rBarkod = barkod;
                     }
                 }
                 else
                 {
                     Poruke.SvirajGresku();
                     MessageBox.Show(Poruke.SkladokBarkodBezRobe);
                 }
             }
             else
             {
                 Poruke.SvirajGresku();
                 MessageBox.Show(Poruke.RobaGreska);
             }
         }
         catch (Exception ex)
         {
             Poruke.SvirajGresku();
             MessageBox.Show(ex.Message);
         }
         finally
         {
             if (ds != null)
             {
                 ds.Dispose();
             }
         }
     }
 }
コード例 #37
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (_sampleSymbologiesRasterImage == null)
            {
                return;
            }

            if (e.Index == -1)
            {
                return;
            }

            Rectangle rc = new Rectangle(e.Bounds.X + _delta, e.Bounds.Y + _delta, e.Bounds.Width - 10, e.Bounds.Height - _delta);

            if (_stringFormat == null)
            {
                _stringFormat               = new StringFormat();
                _stringFormat.Alignment     = StringAlignment.Center;
                _stringFormat.LineAlignment = StringAlignment.Far;
            }

            BarcodeSymbology symbology = (BarcodeSymbology)Items[e.Index];
            string           name      = BarcodeEngine.GetSymbologyFriendlyName(symbology);

            _sampleSymbologiesRasterImage.Page = (int)symbology;

            if (_itemPen == null)
            {
                _itemPen = new Pen(Brushes.Black, 2);
            }

            e.Graphics.DrawRectangle(_itemPen, rc);
            e.Graphics.FillRectangle(Brushes.White, rc);

            RasterPaintProperties paintProperties = RasterPaintProperties.Default;

            if (RasterSupport.IsLocked(RasterSupportType.Document))
            {
                paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic;
            }
            else
            {
                paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.ScaleToGray;
            }

            LeadRect imageRect = new LeadRect(rc.X + 2, rc.Y + 2, rc.Width - 4, rc.Height * 2 / 3);

            imageRect = RasterImage.CalculatePaintModeRectangle(
                _sampleSymbologiesRasterImage.ImageWidth,
                _sampleSymbologiesRasterImage.ImageHeight,
                imageRect,
                RasterPaintSizeMode.FitAlways,
                RasterPaintAlignMode.CenterAlways,
                RasterPaintAlignMode.CenterAlways);

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.Graphics.FillRectangle(SystemBrushes.Highlight, rc);
                RasterImagePainter.Paint(_sampleSymbologiesRasterImage, e.Graphics, imageRect, paintProperties);
                e.Graphics.DrawRectangle(Pens.Black, imageRect.X, imageRect.Y, imageRect.Width, imageRect.Height);
                e.Graphics.DrawString(name, Font, SystemBrushes.HighlightText, rc, _stringFormat);
            }
            else
            {
                e.Graphics.FillRectangle(SystemBrushes.Control, rc);
                RasterImagePainter.Paint(_sampleSymbologiesRasterImage, e.Graphics, imageRect, paintProperties);
                e.Graphics.DrawRectangle(Pens.Black, imageRect.X, imageRect.Y, imageRect.Width, imageRect.Height);
                e.Graphics.DrawString(name, Font, SystemBrushes.ControlText, rc, _stringFormat);
            }
        }
コード例 #38
0
 /// <summary>
 /// Adds selected barcodes to scan barcodes.
 /// </summary>
 private void AddBarcodesToScanBarcodes()
 {
     BarcodeSymbology[] selectedSymbologies = new BarcodeSymbology[availableBarcodeTypesListBox.SelectedItems.Count];
     availableBarcodeTypesListBox.SelectedItems.CopyTo(selectedSymbologies, 0);
     AddBarcodesToScanBarcodes(selectedSymbologies);
 }
コード例 #39
0
ファイル: SkladokIzlaz.cs プロジェクト: Brumiko/MobTrenisIS
 public void SkeniranjeGotovo(string barkod, BarcodeSymbology simbologija)
 {
     if (simbologija == BarcodeSymbology.Code128)
     {
         bool stavkaPostoji = false;
         for (int i = 0; i < brRedaka; i++)
         {
             if (dgLokacija[i, 0].ToString() == barkod)
             {
                 // Deselektiraj do sada selektirani redak (radi i za više redaka)...
                 for (int j = 0; j < brRedaka; j++)
                 {
                     if (dgLokacija.IsSelected(j))
                     {
                         dgLokacija.UnSelect(j);
                         break;
                     }
                 }
                 // ... pa selektiraj onaj pronaðen barkodom.
                 dgLokacija.Select(i);
                 dgLokacija.CurrentRowIndex = i;
                 stavkaPostoji = true;
                 break;
             }
         }
         if (!stavkaPostoji)
         {
             Poruke.SvirajGresku();
             MessageBox.Show(Poruke.SkladokLokacijaNiMedStavkami);
         }
     }
     else
     {
         MessageBox.Show(Poruke.BarkodNijeLokacijski);
     }
 }
コード例 #40
0
ファイル: PllUpisnik.cs プロジェクト: Brumiko/MobTrenisIS
        public void SkeniranjeGotovo(string barkod, BarcodeSymbology simbologija)
        {
            decimal? stanje = null;
            if (simbologija == BarcodeSymbology.Code128)
            {
                txtLokacijaOznaka.Text = barkod;
                if (cboUI.SelectedItem.ToString() == "IZLAZ")
                {
                    #region Dohvat stanja robe na lokaciji
                    if (lblRoba.Tag != null)
                    {
                        try
                        {
                            stanje = Config.MobTrenisWS.RobaDajStanjeNaLokaciji(PLL.Skladiste, lblRoba.Tag.ToString(), txtLokacijaOznaka.Text);
                            if (stanje.HasValue)
                            {
                                lblRoba.Text = lblRobaBarkod.Tag.ToString() + ", kolièina: " + stanje.Value.ToString();
                            }
                            else
                            {
                                lblRoba.Text = lblRobaBarkod.Tag.ToString() + ", kolièina: nema!";
                            }
                        }
                        catch (Exception ex)
                        {
                            Poruke.SvirajGresku();
                            MessageBox.Show(Poruke.PllNeuspioDohvatStanja + ex.Message);
                        }
                    }
                    btnUpisi.Focus();
                    #endregion
                }
                else if (cboUI.SelectedItem.ToString() == "ULAZ")
                {
                    cboLokacijaOdabir.Focus();
                }
            }
            else
            {
                DataSet ds = null;
                try
                {
                    ds = Config.MobTrenisWS.RobaDajPoBarkodu(barkod);
                }
                catch (Exception ex)
                {
                    Poruke.SvirajGresku();
                    MessageBox.Show(Poruke.RobaGreska + "(WS) " + ex.Message);
                    return;
                }
                if (ds != null && ds.Tables[0].Rows.Count == 1)
                {
                    lblRoba.Tag = ds.Tables[0].Rows[0]["RobaSifra"].ToString().TrimEnd();
                    lblRobaBarkod.Tag = ds.Tables[0].Rows[0]["RobaSifra"].ToString().TrimEnd() + ": " + ds.Tables[0].Rows[0]["RobaNaziv"].ToString().TrimEnd() + ", dobavljaè: " + (String.IsNullOrEmpty(ds.Tables[0].Rows[0]["DobavljacSifra"].ToString()) ? "nepoznat" : ds.Tables[0].Rows[0]["DobavljacSifra"].ToString().TrimEnd());

                    if (cboUI.SelectedItem.ToString() == "IZLAZ")
                    {
                        #region Dohvat stanja robe na lokaciji
                        if (txtLokacijaOznaka.Text != String.Empty)
                        {
                            try
                            {
                                stanje = Config.MobTrenisWS.RobaDajStanjeNaLokaciji(PLL.Skladiste, lblRoba.Tag.ToString(), txtLokacijaOznaka.Text);
                                if (stanje.HasValue)
                                {
                                    lblRoba.Text = lblRobaBarkod.Tag.ToString() + ", kolièina: " + stanje;
                                }
                                else
                                {
                                    lblRoba.Text = lblRobaBarkod.Tag.ToString() + ", kolièina: nema!";
                                }
                            }
                            catch (Exception ex)
                            {
                                Poruke.SvirajGresku();
                                MessageBox.Show(Poruke.PllNeuspioDohvatStanja + ex.Message);
                            }
                        }
                        #endregion
                    }
                    else if (cboUI.SelectedItem.ToString() == "ULAZ")
                    {
                        #region Dohvat robnih lokacija
                        // Prikazati popis lokacija na kojima skenirana roba ima stanje > 0 i
                        // omoguæiti izbor lokacije za upis kolièine (MobLokacijaRoba).
                        cboLokacijaOdabir.DataSource = null;
                        cboLokacijaOdabir.DisplayMember = "Prikaz";
                        DataSet robaLokDS = null;
                        try
                        {
                            robaLokDS = Config.MobTrenisWS.RobaDajPozitivu(PLL.Skladiste, barkod, null);
                            if (robaLokDS.Tables.Count == 1 && robaLokDS.Tables[0].Rows.Count > 0)
                            {
                                cboLokacijaOdabir.DataSource = robaLokDS.Tables[0];
                                if (cboLokacijaOdabir.SelectedValue != null && cboLokacijaOdabir.SelectedValue.ToString() != "!")
                                {
                                    cboLokacijaOdabir.SelectedValue = "!";
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Poruke.SvirajGresku();
                            MessageBox.Show(Poruke.PllNeuspioDohvatLokacija + ex.Message);
                        }
                        finally
                        {
                            if (robaLokDS != null) { robaLokDS.Dispose(); }
                        }
                        #endregion
                    }
                    txtRobaBarkod.Text = barkod;
                    txtRobaKolicina.Focus();
                }
                else
                {
                    lblRoba.Tag = null;
                    lblRoba.Text = String.Empty;
                    lblRobaBarkod.Tag = null;
                    txtRobaBarkod.Text = barkod;
                    Poruke.SvirajGresku();
                    if (ds == null)
                    {
                        MessageBox.Show(Poruke.RobaGreska + "(conn) ");
                    }
                    else if (ds.Tables[0].Rows.Count != 1)
                    {
                        MessageBox.Show(Poruke.RobaNePostoji);
                    }
                }
                if (ds != null) { ds.Dispose(); }
            }
        }
コード例 #41
0
ファイル: GenerationBarcode.cs プロジェクト: Demertal/AagErp
        public static Image GetImageBarcode(string barcode)
        {
            BarcodeSymbology s          = BarcodeSymbology.CodeEan13;
            BarcodeDraw      drawObject = BarcodeDrawFactory.GetSymbology(s);
            var metrics = drawObject.GetDefaultMetrics(60);

            metrics.Scale = 2;
            string temp        = barcode.Remove(barcode.Length - 1, 1);
            var    img         = drawObject.Draw(temp, metrics);
            var    resultImage = new Bitmap(img.Width, img.Height + 20); // 20 is bottom padding, adjust to your text

            using (var graphics = Graphics.FromImage(resultImage))
                using (var font = new Font("Consolas", 10))
                    using (var brush = new SolidBrush(Color.Black))
                        using (var format = new StringFormat
                        {
                            Alignment = StringAlignment.Center, // Also, horizontally centered text, as in your example of the expected output
                            LineAlignment = StringAlignment.Far
                        })
                        {
                            graphics.Clear(Color.White);
                            graphics.DrawImage(img, 0, 0);
                            graphics.DrawString(barcode, font, brush, resultImage.Width / 2, resultImage.Height, format);
                        }
            //Image img = code.Draw(barcode, 20);
            //float scale = 120F/25.4F;
            //float widthImg = 37.29F;
            //float heightImg = 25.93F;
            //float heightLine = 22.85F * scale;
            //float widthLine = 0.33F* scale;
            //string encrypteBarcode = GrtEncryptBarcode(GetType(int.Parse(barcode[0].ToString())), barcode);
            ////Bitmap img = new Bitmap((int)(widthImg * scale), (int)(heightImg * scale));
            //Graphics drawing = Graphics.FromImage(img);
            //GraphicsState gs = drawing.Save();
            //drawing.PageUnit = GraphicsUnit.Pixel;
            //drawing.PageScale = 1;
            //RectangleF rect = new RectangleF(0, 0, widthImg * scale, heightImg * scale);
            //drawing.FillRectangle(new SolidBrush(Color.White), rect);
            //float curPosX = 11 * widthLine;
            //foreach (var enBar in encrypteBarcode)
            //{
            //    if (enBar == '1')
            //    {
            //        rect = new RectangleF(curPosX, 0, widthLine, heightLine);
            //        drawing.FillRectangle(new SolidBrush(Color.Black), rect);
            //    }
            //    else if (enBar == '2')
            //    {
            //        rect = new RectangleF(curPosX, 0, widthLine, heightLine + 5 * widthLine);
            //        drawing.FillRectangle(new SolidBrush(Color.Black), rect);
            //    }
            //    curPosX += widthLine;
            //}

            //curPosX = 11 * widthLine - 3.63F* scale;
            //for (int i = 0; i < barcode.Length; i++)
            //{
            //    drawing.DrawString(barcode[i].ToString(), new Font("Arial", 2.75F * scale), new SolidBrush(Color.Black), curPosX,
            //        heightLine + 0.5F * widthLine);
            //    if (i == 0)
            //    {
            //        curPosX = 14 * widthLine;
            //    }
            //    if(i != 0)
            //    {
            //        curPosX += drawing.MeasureString(barcode[i].ToString(),
            //            new Font("Arial", 2.75F * scale)).Width;
            //    }
            //}

            //drawing.Restore(gs);


            //Bitmap res = new Bitmap((int)Math.Round(widthImg), (int)Math.Round(heightImg));
            //Graphics rdrawing = Graphics.FromImage(res);
            //rdrawing.DrawImage(img, 0, 0, widthImg*scale, heightImg*scale);
            //drawing.Dispose();
            //img.Dispose();
            //rdrawing.Dispose();
            return(resultImage);
        }
コード例 #42
0
        private void DecodeFileName()
        {
            string fileName = Path.GetFileNameWithoutExtension(_fileName);

            // Remove file extension and convert from base64
            byte[] encryptedFileName = HttpServerUtility.UrlTokenDecode(
                fileName);

            // Create memory stream backed against encrypted form
            MemoryStream memStm = new MemoryStream(encryptedFileName);

            // Read from crypto-stream via stream reader in UTF8
            StreamReader reader = new StreamReader(memStm, Encoding.UTF8);

            fileName = reader.ReadToEnd();

            // Lets see if we can parse the string
            Match m = FileNameParser.Match(fileName);

            if (m.Success)
            {
                // Validate the hash-code.
                string originalFilename = m.Result("${OriginalFilename}");
                string hashCode         = m.Result("${HashCode}");
                if (originalFilename.GetHashCode() != Int32.Parse(hashCode))
                {
                    throw new InvalidOperationException("Filename is not valid.");
                }

                // Determine encoding system
                string encoding = m.Result("${EncodingSystem}");
                if (!string.IsNullOrEmpty(encoding))
                {
                    _encodingScheme = (BarcodeSymbology)Int32.Parse(encoding);
                }

                // Determine barcode height
                string barMinHeight = m.Result("${BarMinHeight}");
                if (!string.IsNullOrEmpty(barMinHeight))
                {
                    _barMinHeight = Int32.Parse(barMinHeight);
                }
                string barMaxHeight = m.Result("${BarMaxHeight}");
                if (!string.IsNullOrEmpty(barMaxHeight))
                {
                    _barMaxHeight = Int32.Parse(barMaxHeight);
                }

                // Determine barcode width
                string barMinWidth = m.Result("${BarMinWidth}");
                if (!string.IsNullOrEmpty(barMinWidth))
                {
                    _barMinWidth = Int32.Parse(barMinWidth);
                }
                string barMaxWidth = m.Result("${BarMaxWidth}");
                if (!string.IsNullOrEmpty(barMaxWidth))
                {
                    _barMaxWidth = Int32.Parse(barMaxWidth);
                }

                // Determine scale
                string scale = m.Result("${Scale}");
                if (!string.IsNullOrEmpty(scale))
                {
                    _scale = Int32.Parse(scale);
                }

                // Parse the barcode off the end of this string
                _text = m.Result("${BarCodePayload}");
                return;
            }

            m = QrFileNameParser.Match(fileName);
            if (m.Success)
            {
                // Validate the hash-code.
                string originalFilename = m.Result("${OriginalFilename}");
                string hashCode         = m.Result("${HashCode}");
                if (originalFilename.GetHashCode() != Int32.Parse(hashCode))
                {
                    throw new InvalidOperationException("Filename is not valid.");
                }

                // Determine encoding system
                _encodingScheme = BarcodeSymbology.CodeQr;
                string encoding = m.Result("${EncodeMode}");
                if (!string.IsNullOrEmpty(encoding))
                {
                    _qrEncodingMode = (QrEncodeMode)Int32.Parse(encoding);
                }

                // Determine error correction scheme
                string errorCorrect = m.Result("${ErrorCorrect}");
                if (!string.IsNullOrEmpty(errorCorrect))
                {
                    _qrErrorCorrect = (QrErrorCorrection)Int32.Parse(errorCorrect);
                }

                // Determine version
                string version = m.Result("${Version}");
                if (!string.IsNullOrEmpty(version))
                {
                    _qrVersion = Int32.Parse(version);
                }

                // Determine scale
                string scale = m.Result("${Scale}");
                if (!string.IsNullOrEmpty(scale))
                {
                    _scale = Int32.Parse(scale);
                }

                // Parse the barcode off the end of this string
                _text = m.Result("${BarCodePayload}");
                return;
            }

            throw new InvalidOperationException("Filename is not valid.");
        }
コード例 #43
0
 public BarcodeFriendlySymbology(BarcodeSymbology symbology, string friendlyName) : this()
 {
     this.ActualSymbology = symbology;
     this.FriendlyName    = friendlyName;
 }
コード例 #44
0
        /// <summary>
        /// Adds the test case.
        /// </summary>
        /// <param name="symbology">The symbology.</param>
        /// <param name="text">The text.</param>
        public void AddTestCase(BarcodeSymbology symbology, string text)
        {
            // We cannot add unknown symbology to test-case list
            if (symbology == BarcodeSymbology.Unknown)
            {
                throw new ArgumentException ("symbology");
            }

            // Insert into existing group if we have one
            foreach (SymbologyTestGroup group in GroupTests)
            {
                if (group.Symbology == symbology)
                {
                    group.AddTestCase (text);
                    return;
                }
            }

            // Create new group as required.
            SymbologyTestGroup newGroup = new SymbologyTestGroup (symbology);
            newGroup.AddTestCase (text);
            GroupTests.Add (newGroup);
        }