Exemplo n.º 1
0
        public Frame <string, string> GetSymbology(IEnumerable <string> symbols,
                                                   SymbologyType fromSymbolType             = SymbologyType.RIC,
                                                   IEnumerable <SymbologyType> toSymbolType = null,
                                                   // uint? limit = null,
                                                   bool bestMatch = true)
        {
            var response    = GetSymbologyRaw(symbols, fromSymbolType, toSymbolType, bestMatch);
            var responseObj = JsonConvert.DeserializeObject <SymbologySearchResponse>(response, new JsonSerializerSettings
            {
                Error             = HandleDeserializationError,
                NullValueHandling = NullValueHandling.Ignore
            });


            if (bestMatch == true)
            {
                return(CreateBestMatchFrame(responseObj));
            }
            else
            {
                return(CreateFrame(responseObj));
            }

            // Frame.FromRecords()
        }
Exemplo n.º 2
0
 public Frame <string, string> GetSymbology(string symbol,
                                            SymbologyType fromSymbolType             = SymbologyType.RIC,
                                            IEnumerable <SymbologyType> toSymbolType = null,
                                            //  uint? limit = null,
                                            bool bestMatch = true)
 {
     return(SymbologySearch.GetSymbology(symbol, fromSymbolType, toSymbolType, bestMatch));
 }
 public string GetSymbologyRaw(IEnumerable <string> symbols,
                               SymbologyType fromSymbolType             = SymbologyType.RIC,
                               IEnumerable <SymbologyType> toSymbolType = null,
                               // uint? limit = null,
                               bool bestMatch = true)
 {
     return(SymbologySearch.GetSymbologyRaw(symbols, fromSymbolType, toSymbolType, bestMatch));
 }
Exemplo n.º 4
0
 public string GetSymbologyRaw(string symbol,
                               SymbologyType fromSymbolType             = SymbologyType.RIC,
                               IEnumerable <SymbologyType> toSymbolType = null,
                               //   uint? limit = null,
                               bool bestMatch = true)
 {
     return(GetSymbologyRaw(new List <string> {
         symbol
     }, fromSymbolType, toSymbolType, bestMatch));
 }
Exemplo n.º 5
0
        public static IHtmlString GetBarcode(this HtmlHelper helper,
                                             string value,
                                             SymbologyType symbology,
                                             bool addChecksum = false)
        {
            var base64ImageBytes = GetBase64Barcode(value, symbology, addChecksum);
            var str = string.Format("<img src=\"data:image/png;base64,{0}\">", base64ImageBytes);

            return(MvcHtmlString.Create(str));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Display selected options in the preview window
        /// </summary>
        private void dgv_CurrentCellChanged(object sender, EventArgs e)
        {
            if (!(listView1.SelectedItems.Count > 0))
            {
                return;
            }

            int           row    = listView1.SelectedItems[0].Index;
            int           handle = axMap1.Layers[0].Handle;
            string        name   = listView1.SelectedItems[0].Text;
            SymbologyType type   = (SymbologyType)listView1.SelectedItems[0].Tag;

            var layer = axMap1.Layers.ItemByHandle(handle);

            if (type == SymbologyType.Random)
            {
                lblDescription.Text = SymbologyType.Random.EnumToString();
                lblDescription.Refresh();
                var sf = layer.FeatureSet;
                if (!layer.Deserialize(_initState))
                {
                    MessageService.Current.Warn("Error while loading options");
                }
                else
                {
                    axMap1.Redraw();
                }
                return;
            }

            if (type == SymbologyType.Default)
            {
                name = "";
                lblDescription.Text = SymbologyType.Default.EnumToString();
                lblDescription.Refresh();
            }


            // previously saved options (.mwsymb or .mwsr file)
            string description = "";

            if (!layer.LoadOptions(name, ref description))
            {
                MessageService.Current.Warn("Error while loading options");
            }
            else
            {
                if (name != "")
                {
                    lblDescription.Text = description == "Enter description" ? "" :description;
                    lblDescription.Refresh();
                }
                axMap1.Redraw();
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Display selected options in the preview window
        /// </summary>
        private void dgv_CurrentCellChanged(object sender, EventArgs e)
        {
            if (!(listView1.SelectedItems.Count > 0))
            {
                return;
            }

            int           row    = listView1.SelectedItems[0].Index;
            int           handle = axMap1.get_LayerHandle(0);
            string        name   = listView1.SelectedItems[0].Text;
            SymbologyType type   = (SymbologyType)listView1.SelectedItems[0].Tag;

            if (type == SymbologyType.Random)
            {
                lblDescription.Text = Globals.GetSymbologyDescription(SymbologyType.Random);
                lblDescription.Refresh();
                var sf = axMap1.get_Shapefile(handle);
                if (!axMap1.DeserializeLayer(handle, m_initState))
                {
                    Globals.MessageBoxError("Error while loading options");
                }
                else
                {
                    axMap1.Redraw();
                }
                return;
            }
            else if (type == SymbologyType.Default)
            {
                name = "";
                lblDescription.Text = Globals.GetSymbologyDescription(SymbologyType.Default);
                lblDescription.Refresh();
            }


            // previously saved options (.mwsymb or .mwsr file)
            string description = "";

            if (!axMap1.LoadLayerOptions(handle, name, ref description))
            {
                Globals.MessageBoxError("Error while loading options");
            }
            else
            {
                if (name != "")
                {
                    this.lblDescription.Text = description == "Enter description" ? "" :description;
                    lblDescription.Refresh();
                }
                axMap1.Redraw();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Returns name and type of the currently selected row
        /// </summary>
        private bool get_CurrentNameAndType(out string name, out SymbologyType type)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                name = "";
                type = SymbologyType.Custom;
                return(false);
            }

            name = listView1.SelectedItems[0].Text;
            type = (SymbologyType)listView1.SelectedItems[0].Tag;
            return(true);
        }
Exemplo n.º 9
0
        public static string GetBase64Barcode(string value, SymbologyType symbology, bool addChecksum = false)
        {
            using (var barcode = new Barcode())
            {
                barcode.Symbology = symbology;
                barcode.Value     = value;

                barcode.AddChecksum = addChecksum;

                var imageBytes = barcode.GetImageBytesPNG();

                return(Convert.ToBase64String(imageBytes));
            }
        }
Exemplo n.º 10
0
        private void UpdateBarcode()
        {
            SymbologyType symbology = (SymbologyType)Enum.GetValues(typeof(SymbologyType)).GetValue(this.cboSymbologyType.SelectedIndex);

            txtSymbologyDescription.Text = ctrlBarcodeControl.GetValueRestrictions(symbology);

            try
            {
                if (symbology == SymbologyType.EAN13 || symbology == SymbologyType.ISBN || symbology == SymbologyType.UPCA)
                {
                    txtSupplementalValue.IsEnabled = true;
                    lblSupplementalValue.IsEnabled = true;
                    txtSymbologyDescription.Text  += " " + ctrlBarcodeControl.GetSupplementaryValueRestrictions();
                }
                else
                {
                    txtSupplementalValue.IsEnabled = false;
                    lblSupplementalValue.IsEnabled = false;
                }

                lblErrorMessage.Content                     = "";
                ctrlBarcodeControl.RegistrationKey          = "XXXXXXXXXXXXXXXXXXx";
                ctrlBarcodeControl.RegistrationName         = "YYYYYYYYYYYYYYYYYYYY";
                ctrlBarcodeControl.Symbology                = symbology;
                ctrlBarcodeControl.SupplementValue          = txtSupplementalValue.Text;
                ctrlBarcodeControl.Value                    = txtValueToEncode.Text;
                ctrlBarcodeControl.DrawCaptionFor2DBarcodes = chkDrawCaptionFor2D.IsChecked.Value;
                ctrlBarcodeControl.AutoFitToControlSize     = chkAutoFitToContainer.IsChecked.Value;
                ctrlBarcodeControl.Caption                  = "";

                if (symbology == SymbologyType.PDF417 || symbology == SymbologyType.PDF417Truncated ||
                    symbology == SymbologyType.MacroPDF417 || symbology == SymbologyType.DataMatrix ||
                    symbology == SymbologyType.GS1_DataMatrix)
                {
                    ctrlBarcodeControl.BarHeight = PdfBarHeight;
                }
                else if (symbology == SymbologyType.MicroPDF417)
                {
                    ctrlBarcodeControl.BarHeight = PdfBarHeight / 2;
                }
                else
                {
                    ctrlBarcodeControl.BarHeight = BarHeight;
                }
            }
            catch (Exception)
            {
                lblErrorMessage.Content = "Value is invalid for current symbology. Please review value restrictions above.";
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Returns descriptions of the standard types of symbology (random and default)
        /// </summary>
        internal static string GetSymbologyDescription(SymbologyType symbologyType)
        {
            string s = "";

            if (symbologyType == SymbologyType.Default)
            {
                s = "Default options stored in the .mwsymb or .mwsr files";
            }
            else if (symbologyType == SymbologyType.Random)
            {
                s = "Options set randomly by MapWinGIS ActiveX control";
            }
            return(s);
        }
Exemplo n.º 12
0
        public static IHtmlString EmbeddedBarcodeImage(this HtmlHelper helper,
                                                       string value,
                                                       SymbologyType symbology,
                                                       bool addChecksum = false)
        {
            using (var barcode = new Barcode())
            {
                barcode.Symbology = symbology;
                barcode.Value     = value;

                barcode.AddChecksum = addChecksum;

                var imageBytes = barcode.GetImageBytesPNG();
                var str        = string.Format("data:image/png;base64,{0}",
                                               Convert.ToBase64String(imageBytes));
                return(MvcHtmlString.Create(str));
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Removes all the available options for the layer
        /// </summary>
        private void btnClear_Click(object sender, EventArgs e)
        {
            if (listView1.Items.Count == 0)
            {
                return;
            }

            var map = _legend.Map;

            if (map != null)
            {
                if (MessageService.Current.Ask("Do you want to remove all option sets for the layer?"))
                {
                    int errorCount = 0;
                    for (int row = 0; row < listView1.Items.Count; row++)
                    {
                        string        name = listView1.Items[row].ToString();
                        SymbologyType type = (SymbologyType)listView1.Items[row].Tag;

                        if (type == SymbologyType.Default)
                        {
                            name = "";
                        }

                        if (!map.GetLayer(_layer.Handle).RemoveOptions(name))
                        {
                            errorCount++;
                        }
                    }

                    // redrawing
                    listView1.FillSymbologyList(_layer.Filename, true, ref _noEvents);
                    dgv_CurrentCellChanged(null, null);

                    if (errorCount > 0)
                    {
                        MessageService.Current.Warn("Failed to remove options: " + errorCount + Environment.NewLine +
                                                    "Reason: " + map.LastError);
                    }
                }
            }
            RefreshControlsState();
        }
Exemplo n.º 14
0
        public string GetSymbologyRaw(IEnumerable <string> symbols,
                                      SymbologyType fromSymbolType             = SymbologyType.RIC,
                                      IEnumerable <SymbologyType> toSymbolType = null,
                                      //     uint? limit = null,
                                      bool bestMatch = true)
        {
            SymbologySearchRequest request = new SymbologySearchRequest
            {
                symbols       = symbols.ToList(),
                from          = fromSymbolType,
                to            = toSymbolType?.ToList(),
                limit         = null,
                bestMatchOnly = bestMatch
            };

            var response = SerializeAndSendRequest <SymbologySearchRequest>(request);

            return(response);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Removes all the available options for the layer
        /// </summary>
        private void btnClear_Click(object sender, EventArgs e)
        {
            if (listView1.Items.Count == 0)
            {
                return;
            }

            MapWinGIS.Map map = m_legend.Map;
            if (map != null)
            {
                if (MessageBox.Show("Do you want to remove all option sets for the layer?", LegendControl.Legend.AppName,
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    int errorCount = 0;
                    for (int row = 0; row < listView1.Items.Count; row++)
                    {
                        string        name = listView1.Items[row].ToString();
                        SymbologyType type = (SymbologyType)listView1.Items[row].Tag;

                        if (type == SymbologyType.Default)
                        {
                            name = "";
                        }

                        if (!map.RemoveLayerOptions(m_layer.Handle, name))
                        {
                            errorCount++;
                        }
                    }

                    // redrawing
                    Globals.FillSymbologyList(listView1, m_layer.FileName, true, ref m_noEvents);
                    dgv_CurrentCellChanged(null, null);

                    if (errorCount > 0)
                    {
                        Globals.MessageBoxError("Failed to remove options: " + errorCount + Environment.NewLine + "Reason: " +
                                                map.get_ErrorMsg(map.LastErrorCode));
                    }
                }
            }
            RefreshControlsState();
        }
Exemplo n.º 16
0
        public void Print(SymbologyType type, string value, string caption, float widthInches, float heightInches)
        {
            m_barcode.Symbology = type;
            m_barcode.Value     = value;
            m_barcode.Caption   = caption;

            m_widthInches  = widthInches;
            m_heightInches = heightInches;

            PrintDocument printDoc = new PrintDocument();

            printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);

            PrintDialog dlgSettings = new PrintDialog();

            dlgSettings.Document = printDoc;

            if (dlgSettings.ShowDialog() == DialogResult.OK)
            {
                printDoc.Print();
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Applies a given set of options to the layer
        /// </summary>
        private void btnOk_Click(object sender, EventArgs e)
        {
            MapWinGIS.Map map = m_legend.Map;
            if (map != null)
            {
                if (listView1.SelectedItems.Count > 0)
                {
                    if (listView1.SelectedItems[0].Index > 0)    // otherwise that's random options
                    {
                        int           row  = listView1.SelectedItems[0].Index;
                        string        name = listView1.SelectedItems[0].Text;
                        SymbologyType type = (SymbologyType)listView1.SelectedItems[0].Tag;

                        if (type == SymbologyType.Default)
                        {
                            name = "";
                        }
                        string description = "";
                        bool   res         = map.LoadLayerOptions(m_handle, name, ref description);
                    }
                }
            }
        }
Exemplo n.º 18
0
 public Image DrawBarcode(SymbologyType symbologyType, string data)
 {
     this.SymbologyType = symbologyType;
     return(DrawBarcode());
 }
Exemplo n.º 19
0
 public Image DrawBarcode(SymbologyType symbologyType, string data, Color foreColor, Color backColor)
 {
     this.ForeColor = foreColor;
     this.BackColor = backColor;
     return(DrawBarcode(symbologyType, data));
 }
Exemplo n.º 20
0
 public Image DrawBarcode(SymbologyType symbologyType, string data, Color foreColor, Color backColor, float width, float height)
 {
     this.Width  = width;
     this.Height = height;
     return(DrawBarcode(symbologyType, data, foreColor, backColor));
 }
Exemplo n.º 21
0
 public Barcode(string data, SymbologyType iType)
 {
     this.data          = data;
     this.SymbologyType = iType;
 }
Exemplo n.º 22
0
 public BarcodeViewModel()
 {
     Value     = "12345";
     Symbology = SymbologyType.Code128;
 }
Exemplo n.º 23
0
 public Image DrawBarcode(SymbologyType symbologyType, string data, float width, float height)
 {
     this.Width  = width;
     this.Height = height;
     return(DrawBarcode(SymbologyType, data));
 }