/// <summary>
 /// Tests if <c>propertyValue</c> of property named <c>propertyName</c>
 /// meets the requirements. Requirements are given by
 /// <see cref="T:Ferda.Modules.Serializer.BoxSerializer.Restriction">restrictions</see>.
 /// Iff <c>propertyValue</c> doesn`t meet the requirements than 
 /// <see cref="T:Ferda.Modules.BadValueError"/> is thrown.
 /// </summary>
 /// <param name="boxInfo">The box info</param>
 /// <param name="propertyName">Name of property.</param>
 /// <param name="propertyValue">A double value of property.</param>
 /// <exception cref="T:Ferda.Modules.BadValueError">
 /// This execption is thrown iff <c>propertyValue</c> doesn`t satisfy restrictions.
 /// </exception>
 public static void TryIsFloatingPropertyCorrect(IBoxInfo boxInfo, string propertyName, double propertyValue)
 {
     List<Restriction> restrictions = boxInfo.GetPropertyRestrictions(propertyName);
     BadValueError possibleException = new BadValueError();
     foreach (Restriction restriction in restrictions)
     {
         if (restriction.floating.Length == 0)
             continue;
         if (restriction.min)
         {
             if (restriction.including)
             {
                 if (!(restriction.floating[0] <= propertyValue))
                 {
                     possibleException.restrictionType = restrictionTypeEnum.Minimum;
                     throw possibleException;
                 }
             }
             else
             {
                 if (!(restriction.floating[0] < propertyValue))
                 {
                     possibleException.restrictionType = restrictionTypeEnum.Minimum;
                     throw possibleException;
                 }
             }
         }
         else
         {
             if (restriction.including)
             {
                 if (!(restriction.floating[0] >= propertyValue))
                 {
                     possibleException.restrictionType = restrictionTypeEnum.Maximum;
                     throw possibleException;
                 }
             }
             else
             {
                 if (!(restriction.floating[0] > propertyValue))
                 {
                     possibleException.restrictionType = restrictionTypeEnum.Maximum;
                     throw possibleException;
                 }
             }
         }
     }
 }
 /// <summary>
 /// Sets the <see cref="T:Ferda.Modules.BoxModuleI">box module</see>
 /// and the <see cref="T:Ferda.Modules.Boxes.IBoxInfo">box info</see>.
 /// </summary>
 /// <param name="boxModule">The box module.</param>
 /// <param name="boxInfo">The box info.</param>
 public void setBoxModuleInfo(BoxModuleI boxModule, IBoxInfo boxInfo)
 {
     this.boxModule = boxModule;
     //this.boxInfo = boxInfo;
 }
Пример #3
0
 public void SelectedItemChanged(IBoxInfo item)
 {
     Functions.Draw(currentPreProcessing, currentParser.yoloV5Boxes, item);
     OutputSource = currentPreProcessing.outputBitmap.ToBitmapSource();
 }
 /// <summary>
 /// Tests if <c>propertyValue</c> of property named <c>propertyName</c>
 /// meets the requirements. Requirements are given by
 /// <see cref="T:Ferda.Modules.Serializer.BoxSerializer.Restriction">restrictions</see>.
 /// Iff <c>propertyValue</c> doesn`t meet the requirements than 
 /// <see cref="T:Ferda.Modules.BadValueError"/> is thrown.
 /// </summary>
 /// <param name="boxInfo">The box info</param>
 /// <param name="propertyName">Name of property.</param>
 /// <param name="propertyValue">A <see cref="T:Ferda.Modules.DateTimeT"/> value of property.</param>
 /// <exception cref="T:Ferda.Modules.BadValueError">
 /// This execption is thrown iff <c>propertyValue</c> doesn`t satisfy restrictions.
 /// </exception>
 public static void TryIsDateTimePropertyCorrect(IBoxInfo boxInfo, string propertyName, DateTimeT propertyValue)
 {
     //TODO BODY (BoxInfo.TryIsDateTimePropertyCorrect())
 }
 /// <summary>
 /// Tests if <c>propertyValue</c> of property named <c>propertyName</c>
 /// meets the requirements. Requirements are given by
 /// <see cref="T:Ferda.Modules.Serializer.BoxSerializer.Restriction">restrictions</see>.
 /// Iff <c>propertyValue</c> doesn`t meet the requirements than 
 /// <see cref="T:Ferda.Modules.BadValueError"/> is thrown.
 /// </summary>
 /// <param name="boxInfo">The box info</param>
 /// <param name="propertyName">Name of property.</param>
 /// <param name="propertyValue">A string value of property.</param>
 /// <exception cref="T:Ferda.Modules.BadValueError">
 /// This execption is thrown iff <c>propertyValue</c> doesn`t satisfy restrictions.
 /// </exception>
 public static void TryIsStringPropertyCorrect(IBoxInfo boxInfo, string propertyName, string propertyValue)
 {
     string regexp = boxInfo.GetPropertyRegexp(propertyName);
     if (!String.IsNullOrEmpty(regexp))
     {
         if (!
             System.Text.RegularExpressions.Regex.IsMatch(propertyValue,
                                                         regexp))
         {
             BadValueError possibleException = new BadValueError();
             possibleException.restrictionType = restrictionTypeEnum.Regexp;
             throw possibleException;
         }
     }
     SelectString[] selectValues = boxInfo.GetPropertyFixedOptions(propertyName);
     if (selectValues.Length > 0)
     {
         bool inOptions = false;
         foreach (SelectString selectString in selectValues)
         {
             if (selectString.name == propertyValue)
             {
                 inOptions = true;
                 break;
             }
         }
         if (!inOptions)
         {
             BadValueError possibleException = new BadValueError();
             possibleException.restrictionType = restrictionTypeEnum.NotInSelectOptions;
             throw possibleException;
         }
     }
 }
        /// <summary>
        /// Initializes a new instance of the 
        /// <see cref="T:Ferda.Modules.BoxModuleI"/> class.
        /// </summary>
        /// <param name="boxInfo">The box info.</param>
        /// <param name="myIdentity">My identity.</param>
        /// <param name="myFactoryProxy">My factory proxy.</param>
        /// <param name="manager">The manager.</param>
        /// <param name="adapter">The adapter.</param>
        /// <param name="localePrefs">The localization preferences.</param>
        public BoxModuleI(IBoxInfo boxInfo,
            Ice.Identity myIdentity,
            BoxModuleFactoryPrx myFactoryProxy,
            Ferda.ModulesManager.ManagersEnginePrx manager,
            Ice.ObjectAdapter adapter,
            string[] localePrefs)
        {
            System.Diagnostics.Debug.WriteLine("BoxModuleI Constructor (entering): " + boxInfo.Identifier);

            // initializes inner fields by specified parameters
            this.boxInfo = boxInfo;
            this.iceIdentity = myIdentity;
            this.stringIceIdentity = Ice.Util.identityToString(IceIdentity);
            this.myFactoryProxy = myFactoryProxy;
            this.manager = manager;
            this.adapter = adapter;
            this.localePrefs = localePrefs;

            // add the new box module to the specified adapter
            adapter.add(this, this.iceIdentity);
            // get my proxy
            this.myProxy = BoxModulePrxHelper.uncheckedCast(adapter.createProxy(myIdentity));

            // initializes box module`s functions object
            this.boxInfo.CreateFunctions(this, out this.functionsIceObj, out this.functionsIObj);
            this.functionsIObj.setBoxModuleInfo(this, this.boxInfo);
            this.functionsObjPrx = Ice.ObjectPrxHelper.uncheckedCast(adapter.addWithUUID(this.functionsIceObj));

            // initializes properties
            this.properties = new Dictionary<string, PropertyValue>();
            foreach (string propertyName in boxInfo.GetPropertiesNames())
            {
                if (!boxInfo.IsPropertyReadOnly(propertyName))
                {
                    this.setProperty(propertyName, boxInfo.GetPropertyDefaultValue(propertyName));
                }
            }

            // initializes sockets (connections and functions)
            this.connections = new Dictionary<string, Dictionary<string, BoxModulePrx>>();
            foreach (string socketName in boxInfo.GetSocketNames())
            {
                connections[socketName] = new Dictionary<string, BoxModulePrx>();
            }

            System.Diagnostics.Debug.WriteLine("BoxModuleI Constructor (leaving): " + this.boxInfo.Identifier);
        }
        //private ModulesManager.OutputPrx output;
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Ferda.Modules.BoxModuleFactoryI"/> class.
        /// </summary>
        /// <param name="boxInfo">The box info.</param>
        /// <param name="myFactoryCreatorProxy">The proxy of this factory`s creator.</param>
        /// <param name="localePrefs">The localization preferences.</param>
        /// <param name="manager">The modules manager engine.</param>
        public BoxModuleFactoryI(IBoxInfo boxInfo,
            BoxModuleFactoryCreatorPrx myFactoryCreatorProxy,
            string[] localePrefs,
            ModulesManager.ManagersEnginePrx manager)
        {
            this.boxInfo = boxInfo;
            this.localePrefs = localePrefs;
            this.myFactoryCreatorProxy = myFactoryCreatorProxy;
            this.manager = manager;

            //this.output = this.manager.getOutputInterface();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Ferda.Modules.BoxModuleFactoryCreatorI"/> class.
 /// </summary>
 /// <param name="boxInfo">The box info.</param>
 /// <param name="reapThread">The reap thread.</param>
 public BoxModuleFactoryCreatorI(IBoxInfo boxInfo, ReapThread reapThread)
 {
     this.boxInfo = boxInfo;
     this.reaper = reapThread;
 }
Пример #9
0
 public static void Draw(PreProcessing preProcessing, IEnumerable <IBoxInfo> yoloBoxes, IBoxInfo selected)
 {
     if (selected is not null)
     {
         preProcessing.outputBitmap = (Bitmap)preProcessing.originalBitmap.Clone();
         using var g = Graphics.FromImage(preProcessing.outputBitmap);
         var boxes = yoloBoxes.Where(b => b.Position == selected.Position && b.Title == selected.Title);
         foreach (var box in boxes)
         {
             var pen = new Pen(box.Color, (float)Settings.Params.PenWidth);
             g.DrawRectangle(pen, box.Position);
         }
     }
 }