コード例 #1
0
        public DropFileData(PrinterArea eArea, LabelTypes eType)
        {
            ePrinterArea = eArea;
            eLabelType   = eType;

            // ja - convert printer area and type of label to public strings

            //if (ConfigValues.LabelOverride == LabelOverrides.none)
            if (ConfigValues.ConfigLabelName == "none")
            {
                LabelTypeString = Enum.GetName(typeof(LabelTypes), eLabelType);
            }
            else
            {
                //LabelTypeString = Enum.GetName(typeof(LabelOverrides), ConfigValues.LabelOverride);
                LabelTypeString = ConfigValues.ConfigLabelName;
            }

            PrinterAreaString = Enum.GetName(typeof(PrinterArea), ePrinterArea);

            // ja - get the filename and printer from the config file
            ReadConfigFile();

            // ja - create the header for the printer file
            DropFileHeaderObj = new DropFileHeader(_sBtwFileName, _sPrinterName);
        }
コード例 #2
0
        public static void ReadConfigFile(PrinterArea ePrinterArea, LabelTypes eLabelType)
        {
            try
            {
                // ja - get all the types of labels we need to print from the config
                XmlDocument doc = new XmlDocument();
                doc.Load(ConfigFilePath);

                // ja - global printer area
                string sArea = Enum.GetName(typeof(PrinterArea), ePrinterArea);

                // ja - get the list of labels
                string sLabelTypeString = Enum.GetName(typeof(LabelTypes), eLabelType);

                XmlNode LabelTypeNode = doc.SelectSingleNode("/configuration/printerStations/" + sArea + "//" + sLabelTypeString);

                string sPrinterName = LabelTypeNode.Attributes.GetNamedItem("printer_name").Value;
                string sBtwFileName = LabelTypeNode.Attributes.GetNamedItem("bt_filename").Value;

                // TODO: change this to Customer in config file
                string sCustomer = LabelTypeNode.Attributes.GetNamedItem("customer").Value;
            }
            catch (System.Exception ex)
            {
                TheLog.WriteInfo(ex.Message);
            }
        }
コード例 #3
0
        // ja - for single label type
        public AssignedLabelTypes(LabelTypes eLabelType, PrinterArea eArea)
        {
            ePrinterArea = eArea;

            // ja - here we are only going to print a single label type and it is passed in
            AssignedLabels.Add(GetDefaultLabelProperity(eLabelType));
        }
        public string GetChassisNumRawValueByLabel(string label, LabelTypes labelType)
        {
            string value = string.Empty;

            var matchedLabel = wordMatcher.GetMatchedLabel(label);

            if (matchedLabel == null)
            {
                //TO DO add log info
                return(value);
            }

            var words = chassisNumFinder.FindWords(matchedLabel, labelType);

            if (words.Count == 0)
            {
                //TO DO add log info
            }
            else
            {
                value = ConcatinateWordsText(words);
            }

            return(value);
        }
コード例 #5
0
        // ja - for WCF Service used for Inv labels
        public int AddPrintJob(PrinterArea ePrinterArea, LabelTypes eLabelType, List <string> sColumns)
        {
            ConfigValues.TheLog.WriteInfo("AddPrintJob");

            ConfigValues.UseNewLabelCodes = false;

            return(printJobs.AddPrintJobWithColumns(ePrinterArea, eLabelType, sColumns));
        }
コード例 #6
0
        public DevIssueViewModel(DevIssue issue)
        {
            ID      = issue.ID;
            Name    = issue.Name;
            Content = issue.Content;

            PlayerType       = SessionHelper.LoggedCitizen.GetPlayerType();
            Day              = issue.Day;
            Time             = issue.Time.ToShortTimeString();
            Avatar           = new SmallEntityAvatarViewModel(issue.Citizen.Entity);
            Avatar.Classname = "avatar";

            Files = issue.DevIssueUploadedFiles.ToList()
                    .Select(f => new DevIssueUploadedFileViewModel(f)).ToList();



            var actualLabels = issue.DevIssueLabelTypes.ToList();


            foreach (var label in Enum.GetValues(typeof(DevIssueLabelTypeEnum)).Cast <DevIssueLabelTypeEnum>())
            {
                var item = new SelectListItem()
                {
                    Text     = label.ToString(),
                    Value    = ((int)label).ToString(),
                    Selected = actualLabels.Any(l => l.ID == (int)label)
                };

                LabelTypes.Add(item);
            }

            foreach (var visibility in Enum.GetValues(typeof(VisibilityOptionEnum)).Cast <VisibilityOptionEnum>())
            {
                var item = new SelectListItem()
                {
                    Text     = visibility.ToString(),
                    Value    = ((int)visibility).ToString(),
                    Selected = issue.VisibilityOptionID == (int)visibility
                };

                VisiblityOptions.Add(item);
            }

            foreach (var label in actualLabels)
            {
                labelIDs.Add(label.ID);
                Labels.Add(new DevIssueLabelViewModel(label));
            }

            Score     = ScoreHelper.ToString(issue.DevIssueVotes.Sum(v => v.Score));
            CanVote   = issue.DevIssueVotes.Any(v => v.CitizenID == SessionHelper.LoggedCitizen.ID) == false;
            CanUnvote = !CanVote;

            loadComments(issue);
        }
コード例 #7
0
        private LabelProperitys GetDefaultLabelProperity(LabelTypes type)
        {
            LabelProperitys lp = new LabelProperitys();

            lp.AssingedLabel = type;
            lp.CustomerName  = "AMC";
            lp.LabelQuanity  = 1;

            return(lp);
        }
コード例 #8
0
        private void ChangeGetAnimalLabels()
        {
            LabelTypes labelType  = this.LabelType;
            LabelTypes labelTypes = this.IsNeutralCommand ? (this.IsCapturable ? LabelTypes.GetAnimal : LabelTypes.GiveFood) : LabelTypes.None;

            if (labelTypes == labelType)
            {
                return;
            }
            this.LabelType = labelTypes;
        }
コード例 #9
0
        public virtual string ToLabel(Type type)
        {
            ImportNewAssemblies();

            if (!LabelTypes.ContainsKey(type))
            {
                ManageType(GetLabel(type), type);
            }

            return(LabelTypes[type]);
        }
コード例 #10
0
        // ja - new way ....
        // TODO: ja - move to new class?
        private void AssignLabelTypesFromDataBase()
        {
            string ConnectionString = ConfigValues.GetConnectionString();

            SqlDataReader myReader      = null;
            SqlConnection TheConnection = null;

            try
            {
                TheConnection = new SqlConnection(ConnectionString);

                TheConnection.Open();

                // ja - get the label information from the database view
                SqlCommand myCommand = new SqlCommand("select * from label_Data where Part_Number = '" + PartNumber + "' and Part_Version = '" + PartVersion + "'", TheConnection);
                myReader = myCommand.ExecuteReader();

                // ja - loop through all of the assigned label types
                while (myReader.Read())
                {
                    // ja - get the information from the database
                    string sLocation     = myReader["Location_Name"].ToString();
                    string sType         = myReader["Label_Type_Name"].ToString();
                    string sQty          = myReader["Print_Qty"].ToString();
                    string sCustomerName = myReader["Customer_Name"].ToString();

                    LabelTypes  type = (LabelTypes)Enum.Parse(typeof(LabelTypes), sType);
                    PrinterArea area = (PrinterArea)Enum.Parse(typeof(PrinterArea), sLocation);

                    // ja - if the printer area matches the passed in area (Physical Printer) add to queue
                    if (area == ePrinterArea)
                    {
                        LabelProperitys lp = new LabelProperitys
                        {
                            CustomerName  = sCustomerName,
                            LabelQuanity  = Convert.ToInt32(sQty),
                            AssingedLabel = type
                        };

                        AssignedLabels.Add(lp);
                    }
                }

                myReader.Close();
                TheConnection.Close();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.ToString());
                myReader.Close();
                TheConnection.Close();
            }
        }
コード例 #11
0
        // ja - constructor with known column names
        public int AddPrintJobWithColumns(PrinterArea eArea, LabelTypes eLabelType, List <string> sColumns)
        {
            // ja - create data class (container for 3 other classes)
            DropFileData df = new DropFileData(eArea, eLabelType);

            // ja - set the columns names
            df.SetColumnNames(sColumns);

            DropFileDataList.Add(df);

            return(DropFileDataList.Count);
        }
コード例 #12
0
        private void foo()
        {
            SqlDataReader myReader      = null;
            SqlConnection TheConnection = null;

            try
            {
                TheConnection = new SqlConnection(ConnectionString);

                TheConnection.Open();

                string sSql = "select * from label_Data where Part_Number = '" + partNumberTB.Text + "' and Part_Version = '" + versionTB.Text + "'";

                SqlCommand myCommand = new SqlCommand(sSql, TheConnection);
                myReader = myCommand.ExecuteReader();

                while (myReader.Read())
                {
                    string sLocation = myReader["Location_Name"].ToString();
                    string sType     = myReader["Label_Type_Name"].ToString();
                    string sQty      = myReader["Print_Qty"].ToString();

                    LabelTypes  type = (LabelTypes)Enum.Parse(typeof(LabelTypes), sType);
                    PrinterArea area = (PrinterArea)Enum.Parse(typeof(PrinterArea), sLocation);

                    if (area == PrinterArea.smt)
                    {
                        smtListView.Items.Add(allLabelsListView.Items[0]);
                    }
                }

                myReader.Close();
                TheConnection.Close();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.ToString());
                myReader.Close();
                TheConnection.Close();
            }
        }
コード例 #13
0
        public IList <Word> FindWords(Word word, LabelTypes labelType)
        {
            IList <Word> words = new List <Word>();

            double wordHeight = word.BoundingBox.Vertices[3].Y - word.BoundingBox.Vertices[0].Y;
            double wordLenght = word.BoundingBox.Vertices[1].X - word.BoundingBox.Vertices[0].X;
            double Y1         = 0;
            double Y2         = 0;
            double X          = word.BoundingBox.Vertices[1].X;

            switch (labelType)
            {
            //Set "Marke" label coordinates range.
            case LabelTypes.Label_1_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 0.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 3);
                X  = X + Math.Round(wordLenght * 3.1);
                break;

            //Set "Typ" label coordinates range.
            case LabelTypes.Label_1_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 0.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 3);
                X  = X + Math.Round(wordLenght * 2.3);
                break;

            //Set "Marque" label coordinates range.
            case LabelTypes.Label_2_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 1.2);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 1.6);
                X  = X + Math.Round(wordLenght * 2.1);
                break;

            //Set "type" label coordinates range.
            case LabelTypes.Label_2_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 1.2);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 1.6);
                X  = X + Math.Round(wordLenght * 1.6);
                break;

            //Set "Marca" label coordinates range.
            case LabelTypes.Label_3_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 2);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 1.15);
                X  = X + Math.Round(wordLenght * 3.2);
                break;

            //Set "tipo" label coordinates range.
            case LabelTypes.Label_3_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 2);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 1.15);
                X  = X + Math.Round(wordLenght * 3.1);
                break;

            //Set "Marca" label coordinates range.
            case LabelTypes.Label_4_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 3.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 0.3);
                X  = X + Math.Round(wordLenght * 5);
                break;

            //Set "tig" label coordinates range.
            case LabelTypes.Label_4_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 3.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 0.3);;
                X  = X + Math.Round(wordLenght * 9);
                break;

            default:
                // TODO Add log information
                return(words);
            }

            foreach (var block in annotationContext.Pages[0].Blocks)
            {
                foreach (var paragraph in block.Paragraphs)
                {
                    foreach (var w in paragraph.Words)
                    {
                        int blokY1 = w.BoundingBox.Vertices[0].Y;
                        int blokY2 = w.BoundingBox.Vertices[3].Y;
                        int blokX1 = w.BoundingBox.Vertices[0].X;
                        int blokX2 = w.BoundingBox.Vertices[1].X;
                        if (blokY1 > Y1 && blokY2 < Y2 && blokX2 > X)
                        {
                            words.Add(w);
                        }
                    }
                }
            }

            return(words);
        }
コード例 #14
0
 private static bool IsValid(List <bool> query, int numberToGenerate, int offset, LabelTypes numberOfLabels)
 {
     return(query.All(x => x == true) ||
            offset < 0 ||
            numberToGenerate <= 0 ||
            offset > (int)numberOfLabels - 1 ||
            numberToGenerate > (int)numberOfLabels);
 }
コード例 #15
0
        public IList <Word> FindWords(Word word, LabelTypes labelType)
        {
            IList <Word> words = new List <Word>();

            double wordHeight = word.BoundingBox.Vertices[3].Y - word.BoundingBox.Vertices[0].Y;
            double wordLenght = word.BoundingBox.Vertices[1].X - word.BoundingBox.Vertices[0].X;
            double Y1         = 0;
            double Y2         = 0;
            double X          = word.BoundingBox.Vertices[1].X;

            switch (labelType)
            {
            //Set "Fahrgestell" label coordinates range.
            case LabelTypes.Label_1_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 0.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 3);
                X  = X + Math.Round(wordLenght * 1.1);
                break;

            //Set "Nr." label coordinates range.
            case LabelTypes.Label_1_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 0.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 3);
                X  = X + Math.Round(wordLenght * 3.3);
                break;

            //Set "Chassis" label coordinates range.
            case LabelTypes.Label_2_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 1.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 2);
                X  = X + Math.Round(wordLenght * 2.2);
                break;

            //Set "Telaio" label coordinates range.
            case LabelTypes.Label_3_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 2.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 1);
                X  = X + Math.Round(wordLenght * 2.75);
                break;

            //Set "Schassis" label coordinates range.
            case LabelTypes.Label_4_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 3);
                Y2 = word.BoundingBox.Vertices[3].Y;
                X  = X + Math.Round(wordLenght * 1.48);
                break;

            //Set "nr." label coordinates range.
            case LabelTypes.Label_4_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 3);
                Y2 = word.BoundingBox.Vertices[3].Y;
                X  = X + Math.Round(wordLenght * 4.8);
                break;

            default:
                // TODO Add log information
                return(words);
            }

            foreach (var block in annotationContext.Pages[0].Blocks)
            {
                foreach (var paragraph in block.Paragraphs)
                {
                    foreach (var w in paragraph.Words)
                    {
                        int blokY1 = w.BoundingBox.Vertices[0].Y;
                        int blokY2 = w.BoundingBox.Vertices[3].Y;
                        int blokX1 = w.BoundingBox.Vertices[0].X;
                        int blokX2 = w.BoundingBox.Vertices[1].X;
                        if (blokY1 > Y1 && blokY2 < Y2 && blokX2 > X)
                        {
                            words.Add(w);
                        }
                    }
                }
            }

            return(words);
        }
        public IList <Word> FindWords(Word word, LabelTypes labelType)
        {
            IList <Word> words = new List <Word>();

            double wordHeight = word.BoundingBox.Vertices[3].Y - word.BoundingBox.Vertices[0].Y;
            double wordLenght = word.BoundingBox.Vertices[1].X - word.BoundingBox.Vertices[0].X;
            double Y1         = 0;
            double Y2         = 0;
            double X1         = word.BoundingBox.Vertices[1].X;
            double X2         = X1;

            switch (labelType)
            {
            //Set "Inverkehrsetzung" label coordinates range.
            case LabelTypes.Label_1_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 0.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 2.2);
                X1 = X1 + Math.Round(wordLenght * 0.3);
                X2 = X2 + Math.Round(wordLenght * 2.75);
                break;

            //Set "mise" label coordinates range.
            case LabelTypes.Label_2_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 1.3);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 1.2);
                X1 = X1 + Math.Round(wordLenght * 4.3);
                X2 = X2 + Math.Round(wordLenght * 15.2);
                break;

            //Set "circulation" label coordinates range.
            case LabelTypes.Label_2_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 1.3);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 1.2);
                X1 = X1 + Math.Round(wordLenght * 0.3);
                X2 = X2 + Math.Round(wordLenght * 4.8);
                break;

            //Set "messa" label coordinates range.
            case LabelTypes.Label_3_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 1.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 0.7);
                X1 = X1 + Math.Round(wordLenght * 3);
                X2 = X2 + Math.Round(wordLenght * 10.9);
                break;

            //Set "circolazione" label coordinates range.
            case LabelTypes.Label_3_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 1.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 0.7);
                X1 = X1 + Math.Round(wordLenght * 0.2);
                X2 = X2 + Math.Round(wordLenght * 4.1);
                break;

            //Set "entrada" label coordinates range.
            case LabelTypes.Label_4_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 2.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 0.2);
                X1 = X1 + Math.Round(wordLenght * 2.2);
                X2 = X2 + Math.Round(wordLenght * 8.3);
                break;

            //Set "circulaziun" label coordinates range.
            case LabelTypes.Label_4_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 2.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 0.2);
                X1 = X1 + Math.Round(wordLenght * 0.2);
                X2 = X2 + Math.Round(wordLenght * 4.8);
                break;

            default:
                // TODO Add log information
                return(words);
            }

            foreach (var block in annotationContext.Pages[0].Blocks)
            {
                foreach (var paragraph in block.Paragraphs)
                {
                    foreach (var w in paragraph.Words)
                    {
                        int blokY1 = w.BoundingBox.Vertices[0].Y;
                        int blokY2 = w.BoundingBox.Vertices[3].Y;
                        int blokX1 = w.BoundingBox.Vertices[0].X;
                        int blokX2 = w.BoundingBox.Vertices[1].X;
                        if (blokY1 > Y1 && blokY2 < Y2 && blokX1 > X1 && blokX2 < X2)
                        {
                            words.Add(w);
                        }
                    }
                }
            }

            return(words);
        }
コード例 #17
0
 private void SetLabelType(string _lt)
 {
     switch (_lt)
     {
         case "PLDR":
             _labelType = LabelTypes.PLDR;
             break;
         case "CLDR":
             _labelType = LabelTypes.CLDR;
             break;
         case "AQS":
             _labelType = LabelTypes.AQS;
             break;
         case "LEGACY":
             _labelType = LabelTypes.LEGACY;
             break;
         default:
             throw (new Exception("Error: Unknown Lable Type"));
     }
 }
コード例 #18
0
        public IList <Word> FindWords(Word word, LabelTypes labelType)
        {
            IList <Word> words = new List <Word>();

            double wordHeight = word.BoundingBox.Vertices[3].Y - word.BoundingBox.Vertices[0].Y;
            double wordLenght = word.BoundingBox.Vertices[1].X - word.BoundingBox.Vertices[0].X;
            double Y1         = 0;
            double Y2         = 0;
            double X1         = word.BoundingBox.Vertices[1].X;
            double X2         = X1;

            switch (labelType)
            {
            //Set "Typengenehmigung" label coordinates range.
            case LabelTypes.Label_1_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 0.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 3);
                X1 = X1 + Math.Round(wordLenght * 0.14);
                X2 = X2 + Math.Round(wordLenght * 2.1);
                break;

            //Set "Reception" label coordinates range.
            case LabelTypes.Label_2_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 1.3);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 2.3);
                X1 = X1 + Math.Round(wordLenght * 1.15);
                X2 = X2 + Math.Round(wordLenght * 4.7);
                break;

            //Set "Approvazione" label coordinates range.
            case LabelTypes.Label_3_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 2.3);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 1.3);
                X1 = X1 + Math.Round(wordLenght * 0.73);
                X2 = X2 + Math.Round(wordLenght * 3.8);
                break;

            //Set "Approvaziun" label coordinates range.
            case LabelTypes.Label_4_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 3);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 0.5);
                X1 = X1 + Math.Round(wordLenght * 0.83);
                X2 = X2 + Math.Round(wordLenght * 4.1);
                break;

            default:
                // TODO Add log information
                return(words);
            }

            foreach (var block in annotationContext.Pages[0].Blocks)
            {
                foreach (var paragraph in block.Paragraphs)
                {
                    foreach (var w in paragraph.Words)
                    {
                        int blokY1 = w.BoundingBox.Vertices[0].Y;
                        int blokY2 = w.BoundingBox.Vertices[3].Y;
                        int blokX1 = w.BoundingBox.Vertices[0].X;
                        int blokX2 = w.BoundingBox.Vertices[1].X;
                        if (blokY1 > Y1 && blokY2 < Y2 && blokX1 > X1 && blokX2 < X2)
                        {
                            words.Add(w);
                        }
                    }
                }
            }

            return(words);
        }
コード例 #19
0
        public IList <Word> FindWords(Word word, LabelTypes labelType)
        {
            IList <Word> words = new List <Word>();

            double wordHeight = word.BoundingBox.Vertices[3].Y - word.BoundingBox.Vertices[0].Y;
            double wordLenght = word.BoundingBox.Vertices[1].X - word.BoundingBox.Vertices[0].X;
            double Y1         = 0;
            double Y2         = 0;
            double X          = word.BoundingBox.Vertices[1].X;

            switch (labelType)
            {
            //Set "Art" label coordinates range.
            case LabelTypes.Label_1_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 0.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 3.2);
                X  = X + Math.Round(wordLenght * 10);
                break;

            //Set "Fahrzeugs" label coordinates range.
            case LabelTypes.Label_1_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 0.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 3.2);
                X  = X + Math.Round(wordLenght * 2.2);
                break;

            //Set "Genre" label coordinates range.
            case LabelTypes.Label_2_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 1.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 2.2);
                X  = X + Math.Round(wordLenght * 2.5);
                break;

            //Set "véhicule" label coordinates range.
            case LabelTypes.Label_2_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 1.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 2.2);
                X  = X + Math.Round(wordLenght * 0.6);
                break;

            //Set "Genere" label coordinates range.
            case LabelTypes.Label_3_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 2.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 1.2);
                X  = X + Math.Round(wordLenght * 2.3);
                break;

            //Set "veicolo" label coordinates range.
            case LabelTypes.Label_3_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 2.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 1.2);
                X  = X + Math.Round(wordLenght * 0.8);
                break;

            //Set "Gener" label coordinates range.
            case LabelTypes.Label_4_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 3.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 0.2);
                X  = X + Math.Round(wordLenght * 2.5);
                break;

            //Set "vehichel" label coordinates range.
            case LabelTypes.Label_4_2:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 3.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 0.2);
                X  = X + Math.Round(wordLenght * 0.4);
                break;

            default:
                // TODO Add log information
                return(words);
            }

            foreach (var block in annotationContext.Pages[0].Blocks)
            {
                foreach (var paragraph in block.Paragraphs)
                {
                    foreach (var w in paragraph.Words)
                    {
                        int blokY1 = w.BoundingBox.Vertices[0].Y;
                        int blokY2 = w.BoundingBox.Vertices[3].Y;
                        int blokX1 = w.BoundingBox.Vertices[0].X;
                        int blokX2 = w.BoundingBox.Vertices[1].X;
                        if (blokY1 > Y1 && blokY2 < Y2 && blokX2 > X)
                        {
                            words.Add(w);
                        }
                    }
                }
            }

            return(words);
        }
コード例 #20
0
        public IList <Word> FindWords(Word word, LabelTypes labelType)
        {
            IList <Word> words = new List <Word>();

            double wordHeight = word.BoundingBox.Vertices[3].Y - word.BoundingBox.Vertices[0].Y;
            double wordLenght = word.BoundingBox.Vertices[1].X - word.BoundingBox.Vertices[0].X;
            double Y1         = 0;
            double Y2         = 0;
            double X1         = word.BoundingBox.Vertices[1].X;
            double X2         = X1;

            switch (labelType)
            {
            //Set "Stammnummer" label coordinates range.
            case LabelTypes.Label_1_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 0.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 2.6);
                X1 = X1 + Math.Round(wordLenght * 0.45);
                X2 = X2 + Math.Round(wordLenght * 3);
                break;

            //Set "matricule" label coordinates range.
            case LabelTypes.Label_2_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 1.5);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 1.8);
                X1 = X1 + Math.Round(wordLenght * 1.35);
                X2 = X2 + Math.Round(wordLenght * 6.2);
                break;

            //Set "matricola" label coordinates range.
            case LabelTypes.Label_3_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 2);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 0.9);
                X1 = X1 + Math.Round(wordLenght * 1.1);
                X2 = X2 + Math.Round(wordLenght * 6.05);
                break;

            //Set "matricla" label coordinates range.
            case LabelTypes.Label_4_1:
                Y1 = word.BoundingBox.Vertices[0].Y - Math.Round(wordHeight * 3);
                Y2 = word.BoundingBox.Vertices[3].Y + Math.Round(wordHeight * 0.3);
                X1 = X1 + Math.Round(wordLenght * 1.2);
                X2 = X2 + Math.Round(wordLenght * 7.1);
                break;

            default:
                // TODO Add log information
                return(words);
            }

            foreach (var block in annotationContext.Pages[0].Blocks)
            {
                foreach (var paragraph in block.Paragraphs)
                {
                    foreach (var w in paragraph.Words)
                    {
                        int blokY1 = w.BoundingBox.Vertices[0].Y;
                        int blokY2 = w.BoundingBox.Vertices[3].Y;
                        int blokX1 = w.BoundingBox.Vertices[0].X;
                        int blokX2 = w.BoundingBox.Vertices[1].X;
                        if (blokY1 > Y1 && blokY2 < Y2 && blokX1 > X1 && blokX2 < X2)
                        {
                            words.Add(w);
                        }
                    }
                }
            }

            return(words);
        }