コード例 #1
0
        /// <summary>
        /// This method would create text field.
        /// </summary>
        /// <param name="alignmentAttribute">Alignment parameter</param>
        /// <param name="parentPanel">Stack panel, the field will be added to this stackpanel</param>
        /// <param name="tag">Tag of the control object</param>
        private void CreateTextField(
            AlignmentInfo alignmentAttribute,
            StackPanel parentPanel,
            string tag)
        {
            TextBlock block = new TextBlock {
                Margin       = new Thickness(0, 10, 0, 0),
                TextWrapping = TextWrapping.Wrap,
                Text         = alignmentAttribute.Name,
                Height       = 20
            };

            TextBox box = new TextBox {
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin       = new Thickness(0, 0, 0, 0),
                TextWrapping = TextWrapping.Wrap,
                Text         = alignmentAttribute.DefaultValue,
                Tag          = tag,
                Width        = 120,
                Height       = 20,
                ToolTip      = alignmentAttribute.Description
            };

            parentPanel.Children.Add(block);
            parentPanel.Children.Add(box);
        }
コード例 #2
0
ファイル: AlignerDialog.xaml.cs プロジェクト: slogen/bio
        /// <summary>
        /// This method would create combo field.
        /// </summary>
        /// <param name="alignmentAttribute">Alignment parameter</param>
        /// <param name="parentPanel">Stack panel, the field will be added to this stackpanel</param>
        /// <param name="tag">Tag of the control object</param>
        private void CreateComboField(
            AlignmentInfo alignmentAttribute,
            StackPanel parentPanel,
            string tag)
        {
            TextBlock block = new TextBlock();

            block.Margin       = new Thickness(0, 5, 0, 0);
            block.TextWrapping = TextWrapping.Wrap;
            block.Text         = alignmentAttribute.Name;
            block.Height       = 20;

            ComboBox combo = new ComboBox();

            combo.HorizontalAlignment           = HorizontalAlignment.Left;
            combo.IsSynchronizedWithCurrentItem = true;
            combo.Margin  = new Thickness(0, 0, 0, 0);
            combo.Tag     = tag;
            combo.Width   = 180;
            combo.Height  = 22;
            combo.ToolTip = alignmentAttribute.Description;
            StringListValidator validator = alignmentAttribute.Validator as StringListValidator;

            combo.ItemsSource   = validator.ValidValues;
            combo.SelectedIndex = validator.ValidValues.ToList().IndexOf(alignmentAttribute.DefaultValue);

            if (alignmentAttribute.Name == "Similarity Matrix")
            {
                combo.SelectedIndex = validator.ValidValues.ToList().IndexOf(this.defaultSM);
            }

            parentPanel.Children.Add(block);
            parentPanel.Children.Add(combo);
        }
コード例 #3
0
        public void ValidateNUCmerAttributes()
        {
            NUCmerAttributes nucAttrib = new NUCmerAttributes();
            Dictionary <string, AlignmentInfo> attributes = nucAttrib.Attributes;

            Assert.AreEqual(9, attributes.Count);

            // Validating all the NUCmer attributes
            AlignmentInfo similarityMatrixObj = attributes["SIMILARITYMATRIX"];
            AlignmentInfo gapOpenCostObj      = attributes["GAPOPENCOST"];
            AlignmentInfo gapExtensionCostObj = attributes["GAPEXTENSIONCOST"];

            AlignmentInfo lenOfMumObj = attributes["LENGTHOFMUM"];
            AlignmentInfo fixedSepObj = attributes["FIXEDSEPARATION"];
            AlignmentInfo maxSepObj   = attributes["MAXIMUMSEPARATION"];

            AlignmentInfo minScoreObj    = attributes["MINIMUMSCORE"];
            AlignmentInfo sepFactorObj   = attributes["SEPARATIONFACTOR"];
            AlignmentInfo breakLengthObj = attributes["BREAKLENGTH"];

            Assert.AreEqual("Similarity Matrix", similarityMatrixObj.Name);
            Assert.AreEqual("Gap Cost", gapOpenCostObj.Name);
            Assert.AreEqual("Gap Extension Cost", gapExtensionCostObj.Name);

            Assert.AreEqual("Length of MUM", lenOfMumObj.Name);
            Assert.AreEqual("Fixed Separation", fixedSepObj.Name);
            Assert.AreEqual("Maximum Separation", maxSepObj.Name);

            Assert.AreEqual("Minimum Score", minScoreObj.Name);
            Assert.AreEqual("Separation Factor", sepFactorObj.Name);
            Assert.AreEqual("Break Length", breakLengthObj.Name);

            ApplicationLog.WriteLine(
                "NUCmerAttributes BVT: Successfully validated all the attributes.");
        }
コード例 #4
0
ファイル: AlignerDialog.xaml.cs プロジェクト: slogen/bio
        /// <summary>
        /// This method would create text field.
        /// </summary>
        /// <param name="alignmentAttribute">Alignment parameter</param>
        /// <param name="parentPanel">Stack panel, the field will be added to this stack panel</param>
        /// <param name="tag">Tag of the control object</param>
        private void CreateTextField(
            AlignmentInfo alignmentAttribute,
            StackPanel parentPanel,
            string tag)
        {
            TextBlock block = new TextBlock();

            block.Margin       = new Thickness(0, 5, 0, 0);
            block.TextWrapping = TextWrapping.Wrap;
            block.Text         = alignmentAttribute.Name;
            block.Height       = 20;

            TextBox box = new TextBox();

            box.HorizontalAlignment = HorizontalAlignment.Left;
            box.Margin       = new Thickness(0, 0, 0, 0);
            box.TextWrapping = TextWrapping.Wrap;
            box.Text         = alignmentAttribute.DefaultValue;
            box.Tag          = tag;
            box.Width        = 120;
            box.Height       = 20;
            box.ToolTip      = alignmentAttribute.Description;

            parentPanel.Children.Add(block);
            parentPanel.Children.Add(box);
        }
コード例 #5
0
        /// <summary>
        /// This method would create combo field.
        /// </summary>
        /// <param name="alignmentAttribute">Alignment parameter</param>
        /// <param name="parentPanel">Stack panel, the field will be added to this stackpanel</param>
        /// <param name="tag">Tag of the control object</param>
        private void CreateComboField(
            AlignmentInfo alignmentAttribute,
            StackPanel parentPanel,
            string tag)
        {
            TextBlock block = new TextBlock {
                Margin       = new Thickness(0, 10, 0, 0),
                TextWrapping = TextWrapping.Wrap,
                Text         = alignmentAttribute.Name,
                Height       = 20
            };

            ComboBox combo = new ComboBox {
                HorizontalAlignment           = HorizontalAlignment.Left,
                IsSynchronizedWithCurrentItem = true,
                Margin  = new Thickness(0, 0, 0, 0),
                Tag     = tag,
                Width   = 180,
                Height  = 22,
                ToolTip = alignmentAttribute.Description
            };

            StringListValidator validator = alignmentAttribute.Validator as StringListValidator;

            combo.ItemsSource   = validator.ValidValues;
            combo.SelectedIndex = validator.ValidValues.ToList().IndexOf(alignmentAttribute.DefaultValue);

            if (alignmentAttribute.Name == "Similarity Matrix")
            {
                combo.SelectedIndex = validator.ValidValues.ToList().IndexOf(GetDefaultSM(this.sequenceAlphabet));
            }

            parentPanel.Children.Add(block);
            parentPanel.Children.Add(combo);
        }
コード例 #6
0
        /// <summary>
        /// Converts TextBox ContentAlignment to String Alignment
        /// </summary>
        /// <returns></returns>
        public static StringAlignment ContentAlignmentToStringAlignment(MgTextBox control)
        {
            AlignmentInfo alignmentInfo = GetAlignmentInfo(control.TextAlign);

            switch (alignmentInfo.HorAlign)
            {
            case AlignmentTypeHori.Center:
                return(StringAlignment.Center);

            case AlignmentTypeHori.Left:
                if (control.RightToLeft == RightToLeft.Yes)
                {
                    return(StringAlignment.Far);
                }
                else
                {
                    return(StringAlignment.Near);
                }

            case AlignmentTypeHori.Right:
                if (control.RightToLeft == RightToLeft.Yes)
                {
                    return(StringAlignment.Near);
                }
                else
                {
                    return(StringAlignment.Far);
                }

            default:
                return(StringAlignment.Near);
            }
        }
コード例 #7
0
        public void ValidatePairwiseAlignmentAttributes()
        {
            var pwAlignAttrib = new PairwiseAlignmentAttributes();
            Dictionary <string, AlignmentInfo> attributes = pwAlignAttrib.Attributes;

            AlignmentInfo similarityMatrixObj = attributes["SIMILARITYMATRIX"];
            AlignmentInfo gapOpenCostObj      = attributes["GAPOPENCOST"];
            AlignmentInfo gapExtensionCostObj = attributes["GAPEXTENSIONCOST"];

            Assert.AreEqual("Similarity Matrix", similarityMatrixObj.Name);

            var validator = new StringListValidator(
                "Diagonal (Match x Mismatch)",
                SimilarityMatrix.StandardSimilarityMatrix.AmbiguousDna.ToString(),
                SimilarityMatrix.StandardSimilarityMatrix.AmbiguousRna.ToString(),
                SimilarityMatrix.StandardSimilarityMatrix.Blosum45.ToString(),
                SimilarityMatrix.StandardSimilarityMatrix.Blosum50.ToString(),
                SimilarityMatrix.StandardSimilarityMatrix.Blosum62.ToString(),
                SimilarityMatrix.StandardSimilarityMatrix.Blosum80.ToString(),
                SimilarityMatrix.StandardSimilarityMatrix.Blosum90.ToString(),
                SimilarityMatrix.StandardSimilarityMatrix.DiagonalScoreMatrix.ToString(),
                SimilarityMatrix.StandardSimilarityMatrix.Pam250.ToString(),
                SimilarityMatrix.StandardSimilarityMatrix.Pam30.ToString());

            Assert.IsTrue(validator.IsValid(SimilarityMatrix.StandardSimilarityMatrix.AmbiguousDna.ToString()));
            validator.AddValidValues(SimilarityMatrix.StandardSimilarityMatrix.Pam70.ToString());
            Assert.AreEqual("Diagonal (Match x Mismatch)", validator.ValidValues[0]);
            Assert.AreEqual("Gap Cost", gapOpenCostObj.Name);
            Assert.AreEqual("Gap Extension Cost", gapExtensionCostObj.Name);

            ApplicationLog.WriteLine(
                "PairwiseAlignmentAttributes BVT: Successfully validated all the attributes.");
        }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Field" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="type">The type.</param>
 /// <param name="position">The position.</param>
 /// <param name="alignmentInfo">The alignment information.</param>
 /// <param name="isPaddingField">if set to <c>true</c> this is a padding field.</param>
 public Field(string name, Type type, int position, AlignmentInfo alignmentInfo, bool isPaddingField = false)
 {
     Name           = name;
     Position       = position;
     Type           = type;
     AlignmentInfo  = alignmentInfo;
     IsPaddingField = isPaddingField;
 }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the MUMmerAttributes class.
        /// </summary>
        public MUMmerAttributes()
        {
            AlignmentInfo alignmentAttribute = new AlignmentInfo(
                Properties.Resource.LENGTH_OF_MUM_NAME,
                Properties.Resource.LENGTH_OF_MUM_DESCRIPTION,
                true,
                "20",
                AlignmentInfo.IntType,
                null);

            Attributes.Add(LengthOfMUM, alignmentAttribute);
        }
コード例 #10
0
 public FieldDefinition(
     string name,
     TypeReference type,
     GeometrySemantic semanticType,
     int arrayElementCount,
     AlignmentInfo size)
 {
     Name              = name;
     Type              = type;
     GeometrySemantic  = semanticType;
     ArrayElementCount = arrayElementCount;
     Alignment         = size;
 }
コード例 #11
0
        /// <summary>
        /// in WebInfo.cpp we send the HorAligement property revers, because the control displays the text according to the RTL Property
        /// the printText() displays the text according to the send aligment so we need to reverse the org horisontal aligment
        /// </summary>
        /// <param name="rightToLeft"></param>
        /// <param name="AlignmentInfo"></param>
        /// <param name="TextAlign"></param>
        /// <returns></returns>
        public static ContentAlignment GetOrgContentAligment(RightToLeft rightToLeft, ContentAlignment TextAlign)
        {
            AlignmentInfo    alignmentInfo = GetAlignmentInfo(TextAlign);
            ContentAlignment NewTextAli    = TextAlign;

            if (rightToLeft == RightToLeft.Yes && alignmentInfo.HorAlign != AlignmentTypeHori.Center)
            {
                AlignmentTypeHori newTypeHor = (alignmentInfo.HorAlign == AlignmentTypeHori.Right ? AlignmentTypeHori.Left : AlignmentTypeHori.Right);
                NewTextAli = GetContentAligmentForHorAligmentAndVerAligment(newTypeHor, alignmentInfo.VerAlign);
            }

            return(NewTextAli);
        }
コード例 #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contentAlignment"></param>
        /// <param name="HorAligment"></param>
        /// <returns></returns>
        public static ContentAlignment GetContentAligmentForSetHorAligment(ContentAlignment contentAlignment, AlignmentTypeHori HorAligment)
        {
            ContentAlignment RetContentAlignment;

            //get the Current Content alignment info from the ContentAlignmentTable
            AlignmentInfo aligmentInfo = _contentAlignmentTable[contentAlignment];
            //get the current Vertical alignment
            AlignmentTypeVert CurrVerAligment = aligmentInfo.VerAlign;

            //get the new Contant alignment from the HorVerConversion;
            RetContentAlignment = _horVerTranslation[(int)(CurrVerAligment - 1), (int)(HorAligment - 1)];

            return(RetContentAlignment);
        }
コード例 #13
0
        /// <summary>return the display rect of the display size according to the contentAlignment</summary>
        /// <param name="ClientRect"></param>
        /// <param name="DisplaySize"></param>
        /// <param name="contentAlignment"></param>
        /// <returns></returns>
        public static Rectangle GetFocusRect(Control control, Rectangle displayRect,
                                             ContentAlignment contentAlignment, Size textSize)
        {
            AlignmentInfo aligmentInfo = GetAlignmentInfo(contentAlignment);
            //get the current vertical\horizontal aligment
            AlignmentTypeVert alignmentTypeVert = aligmentInfo.VerAlign;
            AlignmentTypeHori alignmentTypeHori = aligmentInfo.HorAlign;

            Rectangle focusRect = new Rectangle(displayRect.X, displayRect.Y, textSize.Width, textSize.Height);

            switch (alignmentTypeVert)
            {
            case AlignmentTypeVert.Top:
                break;

            case AlignmentTypeVert.Bottom:
                focusRect.Y = displayRect.Bottom - textSize.Height;
                break;

            case AlignmentTypeVert.Center:
                focusRect.Y += (displayRect.Height - textSize.Height) / 2;
                break;
            }

            switch (alignmentTypeHori)
            {
            case AlignmentTypeHori.Left:
                break;

            case AlignmentTypeHori.Right:
                focusRect.X = displayRect.Right - textSize.Width;
                break;

            case AlignmentTypeHori.Center:
                focusRect.X += (displayRect.Width - textSize.Width) / 2;
                break;
            }
            //check the rect focus that is not out the control
            focusRect.X     = Math.Max(1, focusRect.X);
            focusRect.Width = Math.Min(focusRect.Width, control.ClientRectangle.Width - focusRect.X);

            return(focusRect);
        }
コード例 #14
0
 public override bool Findcenter(Bitmap bmp, ref double dx, ref double dy, ref List <double> Array, bool MF)
 {
     if (ParamSetMgr.GetInstance().GetBoolParam("更换对心算法"))
     {
         return(false);
     }
     else
     {
         AlignmentInfo info = new AlignmentInfo();
         try
         {
             if (bmp == null)
             {
                 return(false);
             }
             Bitmap temp          = (Bitmap)bmp.Clone();
             bool   bRet          = false;
             int    nWidth        = temp.Width;
             int    nHeight       = temp.Height;
             byte[] byBuffer      = ImageChangeHelper.Instance.Rgb2Gray(bmp);
             int    collimatorNum = ParamSetMgr.GetInstance().GetIntParam("[SFR] CollimatorNum");
             bool   bCheckMode    = (collimatorNum == 2) ? true : false;
             unsafe
             {
                 fixed(byte *pbuffer = byBuffer)
                 {
                     bRet = ActiveAlignment.GetAlignmentValue_Collimators(pbuffer, nWidth, nHeight, bCheckMode, ref info);
                 }
             }
             temp.Dispose();
             dx = info.dSx;
             dy = info.dSy;
             return(bRet);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
コード例 #15
0
 public Creator(Type type, AlignmentInfo alignmentInfo)
 {
     Type          = type;
     AlignmentInfo = alignmentInfo;
 }
コード例 #16
0
        public override bool Findcenter(Bitmap bmp, ref double dx, ref double dy, ref List <double> Array, bool MF)
        {
            if (ParamSetMgr.GetInstance().GetBoolParam("更换对心算法"))
            {
                HObject ho_Image = null, ho_GrayImage = null; HTuple hv_Area0 = new HTuple();
                try
                {
                    ImageChangeHelper.Instance.Bitmap2HObject((Bitmap)bmp.Clone(), ref ho_Image);
                    if (ho_Image == null)
                    {
                        return(false);
                    }
                }
                catch
                {
                    return(false);
                }
                try
                {
                    HObject ho_SelectedRegions0 = null;
                    HTuple  hv_CenterROIR = null, hv_CenterROIC = null, hv_CenterMinArea = null;
                    HTuple  hv_CenterSFRThreshold = null;
                    HTuple  hv_CenterClosing = null, hv_Width = new HTuple(), hv_Height = new HTuple();
                    HTuple  hv_Row0 = new HTuple(), hv_Column0 = new HTuple();
                    hv_CenterROIR         = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCenterROIW");
                    hv_CenterROIC         = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCenterROIH");
                    hv_CenterMinArea      = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心最小面积");
                    hv_CenterSFRThreshold = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心阈值设置");
                    hv_CenterClosing      = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心膨胀系数");
                    double pixelSize = ParamSetMgr.GetInstance().GetDoubleParam("[Sensor] dPixelSize");
                    HOperatorSet.Rgb1ToGray(ho_Image, out ho_GrayImage);
                    HOperatorSet.GetImageSize(ho_GrayImage, out hv_Width, out hv_Height);
                    bool result = FindCenterRegions(ho_Image, hv_CenterROIR, hv_CenterROIC, 0, 0, hv_CenterMinArea, hv_CenterSFRThreshold, hv_CenterClosing, ref ho_SelectedRegions0);
                    if (!result)
                    {
                        return(false);
                    }
                    HOperatorSet.AreaCenter(ho_SelectedRegions0, out hv_Area0, out hv_Row0, out hv_Column0);
                    dx = (hv_Column0.D - hv_Width / 2) * pixelSize / 1000.0;
                    dy = (hv_Row0.D - hv_Height / 2) * pixelSize / 1000.0;

                    ////对心
                    //HObject ho_Rectangle0 = null;
                    //HObject ho_ImageReduced0 = null;
                    //HObject ho_Region0 = null;
                    //HObject ho_RegionClosing0 = null;
                    //HObject ho_ConnectedRegion0 = null;
                    //HObject ho_SelectedRegions0 = null;
                    //HObject ho_Circle0 = null;

                    //// Local control variables

                    //HTuple hv_XField = null, hv_YField = null;
                    //HTuple hv_CenterROIR = null, hv_CenterROIC = null, hv_CenterMinArea = null;
                    //HTuple hv_CenterSFRThreshold = null;
                    //HTuple hv_CenterClosing = null;
                    //HTuple hv_Width = new HTuple();
                    //HTuple hv_Height = new HTuple(), hv_del = new HTuple();
                    //HTuple hv_delX = new HTuple(), hv_delY = new HTuple();
                    //HTuple hv_Area0 = new HTuple(), hv_Row0 = new HTuple(), hv_Row4 = new HTuple(), hv_Column0 = new HTuple();
                    //// Initialize local and output iconic variables
                    //HOperatorSet.GenEmptyObj(out ho_GrayImage);
                    //HOperatorSet.GenEmptyObj(out ho_Rectangle0);
                    //HOperatorSet.GenEmptyObj(out ho_ImageReduced0);
                    //HOperatorSet.GenEmptyObj(out ho_Region0);
                    //HOperatorSet.GenEmptyObj(out ho_RegionClosing0);
                    //HOperatorSet.GenEmptyObj(out ho_ConnectedRegion0);
                    //HOperatorSet.GenEmptyObj(out ho_SelectedRegions0);
                    //HOperatorSet.GenEmptyObj(out ho_Circle0);

                    //hv_CenterROIR = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCenterROIW");
                    //hv_CenterROIC = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCenterROIH");
                    //hv_CenterMinArea = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心最小面积");
                    //hv_CenterSFRThreshold = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心阈值设置");
                    //hv_CenterClosing = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心膨胀系数");
                    //double pixelSize = ParamSetMgr.GetInstance().GetDoubleParam("[Sensor] dPixelSize");
                    //ho_GrayImage.Dispose();
                    //HOperatorSet.Rgb1ToGray(ho_Image, out ho_GrayImage);
                    //HOperatorSet.GetImageSize(ho_GrayImage, out hv_Width, out hv_Height);
                    //ho_Rectangle0.Dispose();
                    //HOperatorSet.GenRectangle2(out ho_Rectangle0, hv_Height / 2, hv_Width / 2, 0, hv_CenterROIR, hv_CenterROIC);
                    //ho_ImageReduced0.Dispose();
                    //HOperatorSet.ReduceDomain(ho_GrayImage, ho_Rectangle0, out ho_ImageReduced0);
                    //ho_Region0.Dispose();
                    //HOperatorSet.Threshold(ho_ImageReduced0, out ho_Region0, hv_CenterSFRThreshold, 255);
                    //ho_RegionClosing0.Dispose();
                    //HOperatorSet.ClosingCircle(ho_Region0, out ho_RegionClosing0, hv_CenterClosing);
                    //ho_ConnectedRegion0.Dispose();
                    //HOperatorSet.Connection(ho_RegionClosing0, out ho_ConnectedRegion0);
                    //HOperatorSet.AreaCenter(ho_ConnectedRegion0, out hv_Area0, out hv_Row0, out hv_Column0);
                    //ho_SelectedRegions0.Dispose();
                    //HOperatorSet.SelectShape(ho_ConnectedRegion0, out ho_SelectedRegions0, "area", "and", hv_Area0.TupleMax(), 9999999);
                    //HOperatorSet.AreaCenter(ho_SelectedRegions0, out hv_Area0, out hv_Row0, out hv_Column0);
                    //dx = (hv_Column0.D - hv_Width / 2) * pixelSize / 1000.0;
                    //dy = (hv_Row0.D - hv_Height / 2) * pixelSize / 1000.0;
                }
                catch (Exception e)
                {
                    return(false);
                }
                if (!MF)
                {
                    return(true);//不选择计算MF ,直接返回
                }
                try
                {
                    HObject ho_SelectedRegions1 = null;
                    HObject ho_SelectedRegions2 = null;
                    HObject ho_SelectedRegions3 = null;
                    HObject ho_SelectedRegions4 = null;
                    HTuple  hv_XField = null, hv_YField = null;
                    HTuple  hv_Corner1ROIR = null, hv_Corner1ROIC = null, hv_Corner1MinArea = null, hv_Corner1SFRThreshold = null, hv_Corner1Closing = null;
                    HTuple  hv_Area1 = new HTuple(), hv_Area2 = new HTuple(), hv_Area3 = new HTuple(), hv_Area4 = new HTuple();
                    HTuple  hv_Row1 = new HTuple(), hv_Row2 = new HTuple(), hv_Row3 = new HTuple(), hv_Row4 = new HTuple();
                    HTuple  hv_Column1 = new HTuple(), hv_Column2 = new HTuple(), hv_Column3 = new HTuple(), hv_Column4 = new HTuple();
                    hv_XField              = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dCorner1XField");
                    hv_YField              = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dCorner1YField");
                    hv_Corner1ROIR         = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCorner1ROIW");
                    hv_Corner1ROIC         = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCorner1ROIH");
                    hv_Corner1MinArea      = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1最小面积");
                    hv_Corner1SFRThreshold = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1阈值设置");
                    hv_Corner1Closing      = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1膨胀系数");

                    bool result = true;
                    result &= FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, -hv_XField, -hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions1);
                    result &= FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, hv_XField, -hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions2);
                    result &= FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, -hv_XField, hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions3);
                    result &= FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, hv_XField, hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions4);
                    if (!result)
                    {
                        return(false);
                    }
                    HOperatorSet.AreaCenter(ho_SelectedRegions1, out hv_Area1, out hv_Row1, out hv_Column1);
                    HOperatorSet.AreaCenter(ho_SelectedRegions2, out hv_Area2, out hv_Row2, out hv_Column2);
                    HOperatorSet.AreaCenter(ho_SelectedRegions3, out hv_Area3, out hv_Row3, out hv_Column3);
                    HOperatorSet.AreaCenter(ho_SelectedRegions4, out hv_Area4, out hv_Row4, out hv_Column4);

                    Array.Add(Math.Sqrt((hv_Row2.D - hv_Row1.D) * (hv_Row2.D - hv_Row1.D) + (hv_Column2.D - hv_Column1.D) * (hv_Column2.D - hv_Column1.D)));
                    Array.Add(Math.Sqrt((hv_Row4.D - hv_Row2.D) * (hv_Row4.D - hv_Row2.D) + (hv_Column4.D - hv_Column2.D) * (hv_Column4.D - hv_Column2.D)));
                    Array.Add(Math.Sqrt((hv_Row3.D - hv_Row4.D) * (hv_Row3.D - hv_Row4.D) + (hv_Column3.D - hv_Column4.D) * (hv_Column3.D - hv_Column4.D)));
                    Array.Add(Math.Sqrt((hv_Row1.D - hv_Row3.D) * (hv_Row1.D - hv_Row3.D) + (hv_Column1.D - hv_Column3.D) * (hv_Column1.D - hv_Column3.D)));
                    Array.Add(Math.Sqrt((hv_Row4.D - hv_Row1.D) * (hv_Row4.D - hv_Row1.D) + (hv_Column4.D - hv_Column1.D) * (hv_Column4.D - hv_Column1.D)));
                    Array.Add(Math.Sqrt((hv_Row2.D - hv_Row3.D) * (hv_Row2.D - hv_Row3.D) + (hv_Column2.D - hv_Column3.D) * (hv_Column2.D - hv_Column3.D)));
                    Array.Add(hv_Area0.D / 100);
                    Array.Add(hv_Area1.D / 100);
                    Array.Add(hv_Area2.D / 100);
                    Array.Add(hv_Area3.D / 100);
                    Array.Add(hv_Area4.D / 100);


                    ////对心
                    //HObject ho_Rectangle1 = null, ho_Rectangle2 = null, ho_Rectangle3 = null, ho_Rectangle4 = null;
                    //HObject ho_ImageReduced1 = null, ho_ImageReduced2 = null, ho_ImageReduced3 = null, ho_ImageReduced4 = null;
                    //HObject ho_Region1 = null, ho_Region2 = null, ho_Region3 = null, ho_Region4 = null;
                    //HObject ho_RegionClosing1 = null, ho_RegionClosing2 = null, ho_RegionClosing3 = null, ho_RegionClosing4 = null;
                    //HObject ho_ConnectedRegion1 = null, ho_ConnectedRegion2 = null, ho_ConnectedRegion3 = null, ho_ConnectedRegion4 = null;
                    //HObject ho_SelectedRegions1 = null, ho_SelectedRegions2 = null, ho_SelectedRegions3 = null, ho_SelectedRegions4 = null;
                    //HObject ho_Circle1 = null, ho_Circle2 = null, ho_Circle3 = null, ho_Circle4 = null;

                    //// Local control variables

                    //HTuple hv_XField = null, hv_YField = null;
                    //HTuple hv_Corner1ROIR = null;
                    //HTuple hv_Corner1ROIC = null, hv_Corner1MinArea = null;
                    //HTuple hv_Corner1SFRThreshold = null;
                    //HTuple hv_Row0 = new HTuple(), hv_Column0 = new HTuple();
                    //HTuple hv_Corner1Closing = null, hv_Width = new HTuple();
                    //HTuple hv_Height = new HTuple(), hv_del = new HTuple();
                    //HTuple hv_delX = new HTuple(), hv_delY = new HTuple();
                    //HTuple hv_Area1 = new HTuple(), hv_Area2 = new HTuple(), hv_Area3 = new HTuple(), hv_Area4 = new HTuple();
                    //HTuple hv_Row1 = new HTuple(), hv_Row2 = new HTuple(), hv_Row3 = new HTuple(), hv_Row4 = new HTuple();
                    //HTuple hv_Column1 = new HTuple(), hv_Column2 = new HTuple(), hv_Column3 = new HTuple(), hv_Column4 = new HTuple();
                    //// Initialize local and output iconic variables
                    //HOperatorSet.GenEmptyObj(out ho_GrayImage);
                    //HOperatorSet.GenEmptyObj(out ho_Rectangle1);
                    //HOperatorSet.GenEmptyObj(out ho_Rectangle2);
                    //HOperatorSet.GenEmptyObj(out ho_Rectangle3);
                    //HOperatorSet.GenEmptyObj(out ho_Rectangle4);
                    //HOperatorSet.GenEmptyObj(out ho_ImageReduced1);
                    //HOperatorSet.GenEmptyObj(out ho_ImageReduced2);
                    //HOperatorSet.GenEmptyObj(out ho_ImageReduced3);
                    //HOperatorSet.GenEmptyObj(out ho_ImageReduced4);
                    //HOperatorSet.GenEmptyObj(out ho_Region1);
                    //HOperatorSet.GenEmptyObj(out ho_Region2);
                    //HOperatorSet.GenEmptyObj(out ho_Region3);
                    //HOperatorSet.GenEmptyObj(out ho_Region4);
                    //HOperatorSet.GenEmptyObj(out ho_RegionClosing1);
                    //HOperatorSet.GenEmptyObj(out ho_RegionClosing2);
                    //HOperatorSet.GenEmptyObj(out ho_RegionClosing3);
                    //HOperatorSet.GenEmptyObj(out ho_RegionClosing4);
                    //HOperatorSet.GenEmptyObj(out ho_ConnectedRegion1);
                    //HOperatorSet.GenEmptyObj(out ho_ConnectedRegion2);
                    //HOperatorSet.GenEmptyObj(out ho_ConnectedRegion3);
                    //HOperatorSet.GenEmptyObj(out ho_ConnectedRegion4);
                    //HOperatorSet.GenEmptyObj(out ho_SelectedRegions1);
                    //HOperatorSet.GenEmptyObj(out ho_SelectedRegions2);
                    //HOperatorSet.GenEmptyObj(out ho_SelectedRegions3);
                    //HOperatorSet.GenEmptyObj(out ho_SelectedRegions4);
                    //HOperatorSet.GenEmptyObj(out ho_Circle1);
                    //HOperatorSet.GenEmptyObj(out ho_Circle2);
                    //HOperatorSet.GenEmptyObj(out ho_Circle3);
                    //HOperatorSet.GenEmptyObj(out ho_Circle4);
                    //hv_XField = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dCorner1XField");
                    //hv_YField = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dCorner1YField");
                    //hv_Corner1ROIR = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCorner1ROIW");
                    //hv_Corner1ROIC = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCorner1ROIH");
                    //hv_Corner1MinArea = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1最小面积");
                    //hv_Corner1SFRThreshold = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1阈值设置");
                    //hv_Corner1Closing = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1膨胀系数");

                    //ho_GrayImage.Dispose();
                    //HOperatorSet.Rgb1ToGray(ho_Image, out ho_GrayImage);
                    ////初步对心

                    //HOperatorSet.GetImageSize(ho_GrayImage, out hv_Width, out hv_Height);
                    //hv_delX = hv_Width * hv_XField;
                    //hv_delY = hv_Height * hv_YField;

                    //ho_Rectangle1.Dispose();
                    //HOperatorSet.GenRectangle2(out ho_Rectangle1, (hv_Height / 2) - (hv_delY / 2), (hv_Width / 2) - (hv_delX / 2), 0, hv_Corner1ROIR, hv_Corner1ROIC);
                    //ho_Rectangle2.Dispose();
                    //HOperatorSet.GenRectangle2(out ho_Rectangle2, (hv_Height / 2) - (hv_delY / 2), (hv_Width / 2) + (hv_delX / 2), 0, hv_Corner1ROIR, hv_Corner1ROIC);
                    //ho_Rectangle3.Dispose();
                    //HOperatorSet.GenRectangle2(out ho_Rectangle3, (hv_Height / 2) + (hv_delY / 2), (hv_Width / 2) - (hv_delX / 2), 0, hv_Corner1ROIR, hv_Corner1ROIC);
                    //ho_Rectangle4.Dispose();
                    //HOperatorSet.GenRectangle2(out ho_Rectangle4, (hv_Height / 2) + (hv_delY / 2), (hv_Width / 2) + (hv_delX / 2), 0, hv_Corner1ROIR, hv_Corner1ROIC);

                    //ho_ImageReduced1.Dispose();
                    //HOperatorSet.ReduceDomain(ho_GrayImage, ho_Rectangle1, out ho_ImageReduced1);
                    //ho_ImageReduced2.Dispose();
                    //HOperatorSet.ReduceDomain(ho_GrayImage, ho_Rectangle2, out ho_ImageReduced2);
                    //ho_ImageReduced3.Dispose();
                    //HOperatorSet.ReduceDomain(ho_GrayImage, ho_Rectangle3, out ho_ImageReduced3);
                    //ho_ImageReduced4.Dispose();
                    //HOperatorSet.ReduceDomain(ho_GrayImage, ho_Rectangle4, out ho_ImageReduced4);
                    //ho_Region1.Dispose();
                    //HOperatorSet.Threshold(ho_ImageReduced1, out ho_Region1, hv_Corner1SFRThreshold, 255);
                    //ho_Region2.Dispose();
                    //HOperatorSet.Threshold(ho_ImageReduced2, out ho_Region2, hv_Corner1SFRThreshold, 255);
                    //ho_Region3.Dispose();
                    //HOperatorSet.Threshold(ho_ImageReduced3, out ho_Region3, hv_Corner1SFRThreshold, 255);
                    //ho_Region4.Dispose();
                    //HOperatorSet.Threshold(ho_ImageReduced4, out ho_Region4, hv_Corner1SFRThreshold, 255);
                    //ho_RegionClosing1.Dispose();
                    //HOperatorSet.ClosingCircle(ho_Region1, out ho_RegionClosing1, hv_Corner1Closing);
                    //ho_RegionClosing2.Dispose();
                    //HOperatorSet.ClosingCircle(ho_Region2, out ho_RegionClosing2, hv_Corner1Closing);
                    //ho_RegionClosing3.Dispose();
                    //HOperatorSet.ClosingCircle(ho_Region3, out ho_RegionClosing3, hv_Corner1Closing);
                    //ho_RegionClosing4.Dispose();
                    //HOperatorSet.ClosingCircle(ho_Region4, out ho_RegionClosing4, hv_Corner1Closing);
                    //ho_ConnectedRegion1.Dispose();
                    //HOperatorSet.Connection(ho_RegionClosing1, out ho_ConnectedRegion1);
                    //ho_ConnectedRegion2.Dispose();
                    //HOperatorSet.Connection(ho_RegionClosing2, out ho_ConnectedRegion2);
                    //ho_ConnectedRegion3.Dispose();
                    //HOperatorSet.Connection(ho_RegionClosing3, out ho_ConnectedRegion3);
                    //ho_ConnectedRegion4.Dispose();
                    //HOperatorSet.Connection(ho_RegionClosing4, out ho_ConnectedRegion4);
                    //HOperatorSet.AreaCenter(ho_ConnectedRegion1, out hv_Area1, out hv_Row0, out hv_Column0);
                    //HOperatorSet.AreaCenter(ho_ConnectedRegion2, out hv_Area2, out hv_Row0, out hv_Column0);
                    //HOperatorSet.AreaCenter(ho_ConnectedRegion3, out hv_Area3, out hv_Row0, out hv_Column0);
                    //HOperatorSet.AreaCenter(ho_ConnectedRegion4, out hv_Area4, out hv_Row0, out hv_Column0);
                    //ho_SelectedRegions1.Dispose();
                    //HOperatorSet.SelectShape(ho_ConnectedRegion1, out ho_SelectedRegions1, "area", "and", hv_Area1.TupleMax(), 9999999);
                    //ho_SelectedRegions2.Dispose();
                    //HOperatorSet.SelectShape(ho_ConnectedRegion2, out ho_SelectedRegions2, "area", "and", hv_Area2.TupleMax(), 9999999);
                    //ho_SelectedRegions3.Dispose();
                    //HOperatorSet.SelectShape(ho_ConnectedRegion3, out ho_SelectedRegions3, "area", "and", hv_Area3.TupleMax(), 9999999);
                    //ho_SelectedRegions4.Dispose();
                    //HOperatorSet.SelectShape(ho_ConnectedRegion4, out ho_SelectedRegions4, "area", "and", hv_Area4.TupleMax(), 9999999);
                }
                catch (Exception e)
                {
                    return(false);
                }
                return(true);
            }
            else
            {
                AlignmentInfo info = new AlignmentInfo();
                try
                {
                    if (bmp == null)
                    {
                        return(false);
                    }
                    Bitmap temp     = (Bitmap)bmp.Clone();
                    bool   bRet     = false;
                    int    nWidth   = temp.Width;
                    int    nHeight  = temp.Height;
                    byte[] byBuffer = ImageChangeHelper.Instance.Rgb2Gray(bmp);
                    unsafe
                    {
                        fixed(byte *pbuffer = byBuffer)
                        {
                            bRet = ActiveAlignment.GetAlignmentValue_Sector(pbuffer, nWidth, nHeight, ref info);
                        }
                    }
                    temp.Dispose();
                    dx = info.dSx;
                    dy = info.dSy;
                    return(bRet);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
コード例 #17
0
        public override bool Findcenter(Bitmap bmp, ref double dx, ref double dy, ref List <double> Array, bool MF)
        {
            if (ParamSetMgr.GetInstance().GetBoolParam("更换对心算法"))
            {
                HObject ho_Image = null, ho_GrayImage = null; HTuple hv_Area0 = new HTuple();
                try
                {
                    ImageChangeHelper.Instance.Bitmap2HObject((Bitmap)bmp.Clone(), ref ho_Image);
                    if (ho_Image == null)
                    {
                        return(false);
                    }
                }
                catch
                {
                    return(false);
                }
                try
                {
                    HObject ho_SelectedRegions0 = null;
                    HTuple  hv_CenterROIR = null, hv_CenterROIC = null, hv_CenterMinArea = null;
                    HTuple  hv_CenterSFRThreshold = null;
                    HTuple  hv_CenterClosing = null, hv_Width = new HTuple(), hv_Height = new HTuple();
                    HTuple  hv_Row0 = new HTuple(), hv_Column0 = new HTuple();
                    hv_CenterROIR         = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCenterROIW");
                    hv_CenterROIC         = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCenterROIH");
                    hv_CenterMinArea      = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心最小面积");
                    hv_CenterSFRThreshold = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心阈值设置");
                    hv_CenterClosing      = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心膨胀系数");
                    double pixelSize = ParamSetMgr.GetInstance().GetDoubleParam("[Sensor] dPixelSize");
                    HOperatorSet.Rgb1ToGray(ho_Image, out ho_GrayImage);
                    HOperatorSet.GetImageSize(ho_GrayImage, out hv_Width, out hv_Height);
                    bool result = FindCenterRegions(ho_Image, hv_CenterROIR, hv_CenterROIC, 0, 0, hv_CenterMinArea, hv_CenterSFRThreshold, hv_CenterClosing, ref ho_SelectedRegions0);
                    if (!result)
                    {
                        return(false);
                    }
                    HOperatorSet.AreaCenter(ho_SelectedRegions0, out hv_Area0, out hv_Row0, out hv_Column0);
                    dx = (hv_Column0.D - hv_Width / 2) * pixelSize / 1000.0;
                    dy = (hv_Row0.D - hv_Height / 2) * pixelSize / 1000.0;
                }
                catch (Exception e)
                {
                    return(false);
                }
                if (!MF)
                {
                    return(true);//不选择计算MF ,直接返回
                }
                try
                {
                    HObject ho_SelectedRegions1 = null;
                    HObject ho_SelectedRegions2 = null;
                    HObject ho_SelectedRegions3 = null;
                    HObject ho_SelectedRegions4 = null;
                    HTuple  hv_XField = null, hv_YField = null;
                    HTuple  hv_Corner1ROIR = null, hv_Corner1ROIC = null, hv_Corner1MinArea = null, hv_Corner1SFRThreshold = null, hv_Corner1Closing = null;
                    HTuple  hv_Area1 = new HTuple(), hv_Area2 = new HTuple(), hv_Area3 = new HTuple(), hv_Area4 = new HTuple();
                    HTuple  hv_Row1 = new HTuple(), hv_Row2 = new HTuple(), hv_Row3 = new HTuple(), hv_Row4 = new HTuple();
                    HTuple  hv_Column1 = new HTuple(), hv_Column2 = new HTuple(), hv_Column3 = new HTuple(), hv_Column4 = new HTuple();
                    hv_XField              = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dCorner1XField");
                    hv_YField              = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dCorner1YField");
                    hv_Corner1ROIR         = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCorner1ROIW");
                    hv_Corner1ROIC         = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCorner1ROIH");
                    hv_Corner1MinArea      = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1最小面积");
                    hv_Corner1SFRThreshold = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1阈值设置");
                    hv_Corner1Closing      = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1膨胀系数");

                    bool result = true;
                    result &= FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, -hv_XField, -hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions1);
                    result &= FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, hv_XField, -hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions2);
                    result &= FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, -hv_XField, hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions3);
                    result &= FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, hv_XField, hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions4);
                    if (!result)
                    {
                        return(false);
                    }
                    HOperatorSet.AreaCenter(ho_SelectedRegions1, out hv_Area1, out hv_Row1, out hv_Column1);
                    HOperatorSet.AreaCenter(ho_SelectedRegions2, out hv_Area2, out hv_Row2, out hv_Column2);
                    HOperatorSet.AreaCenter(ho_SelectedRegions3, out hv_Area3, out hv_Row3, out hv_Column3);
                    HOperatorSet.AreaCenter(ho_SelectedRegions4, out hv_Area4, out hv_Row4, out hv_Column4);

                    Array.Add(Math.Sqrt((hv_Row2.D - hv_Row1.D) * (hv_Row2.D - hv_Row1.D) + (hv_Column2.D - hv_Column1.D) * (hv_Column2.D - hv_Column1.D)));
                    Array.Add(Math.Sqrt((hv_Row4.D - hv_Row2.D) * (hv_Row4.D - hv_Row2.D) + (hv_Column4.D - hv_Column2.D) * (hv_Column4.D - hv_Column2.D)));
                    Array.Add(Math.Sqrt((hv_Row3.D - hv_Row4.D) * (hv_Row3.D - hv_Row4.D) + (hv_Column3.D - hv_Column4.D) * (hv_Column3.D - hv_Column4.D)));
                    Array.Add(Math.Sqrt((hv_Row1.D - hv_Row3.D) * (hv_Row1.D - hv_Row3.D) + (hv_Column1.D - hv_Column3.D) * (hv_Column1.D - hv_Column3.D)));
                    Array.Add(Math.Sqrt((hv_Row4.D - hv_Row1.D) * (hv_Row4.D - hv_Row1.D) + (hv_Column4.D - hv_Column1.D) * (hv_Column4.D - hv_Column1.D)));
                    Array.Add(Math.Sqrt((hv_Row2.D - hv_Row3.D) * (hv_Row2.D - hv_Row3.D) + (hv_Column2.D - hv_Column3.D) * (hv_Column2.D - hv_Column3.D)));
                    Array.Add(hv_Area0.D / 100);
                    Array.Add(hv_Area1.D / 100);
                    Array.Add(hv_Area2.D / 100);
                    Array.Add(hv_Area3.D / 100);
                    Array.Add(hv_Area4.D / 100);
                }
                catch (Exception e)
                {
                    return(false);
                }
                return(true);
            }
            else
            {
                AlignmentInfo info = new AlignmentInfo();
                try
                {
                    if (bmp == null)
                    {
                        return(false);
                    }
                    Bitmap temp     = (Bitmap)bmp.Clone();
                    bool   bRet     = false;
                    int    nWidth   = temp.Width;
                    int    nHeight  = temp.Height;
                    byte[] byBuffer = ImageChangeHelper.Instance.Rgb2Gray(bmp);
                    unsafe
                    {
                        fixed(byte *pbuffer = byBuffer)
                        {
                            bRet = ActiveAlignment.GetAlignmentValue(pbuffer, nWidth, nHeight, ref info);
                        }
                    }
                    temp.Dispose();
                    dx = info.dSx;
                    dy = info.dSy;
                    return(bRet);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
コード例 #18
0
        /// <summary>
        /// Inicializa una nueva instancia de la clase <see cref="Style"/> con una cadena como base.
        /// </summary>
        /// <param name="text">Texto conteniendo el estilo.</param>
        public Style(string text)
        {
            var regex = new Regex(RegularExpressions.RegexStyle);
            var match = regex.Match(text);

            if (match.Success)
            {
                Name           = match.Groups["name"].Value;
                FontName       = match.Groups["fontName"].Value;
                FontSize       = double.Parse(match.Groups["fontSize"].Value);
                PrimaryColor   = new TagTypeColor(match.Groups["color1"].Value);
                SecondaryColor = new TagTypeColor(match.Groups["color2"].Value);
                OutlineColor   = new TagTypeColor(match.Groups["color3"].Value);
                BackColor      = new TagTypeColor(match.Groups["color4"].Value);
                PrimaryAlpha   = Maths.HexToInt(match.Groups["alpha1"].Value);
                SecondaryAlpha = Maths.HexToInt(match.Groups["alpha2"].Value);
                OutlineAlpha   = Maths.HexToInt(match.Groups["alpha3"].Value);
                BackAlpha      = Maths.HexToInt(match.Groups["alpha4"].Value);

                Bold = false;
                if (match.Groups["bold"].Value == "-1")
                {
                    Bold = true;
                }

                Italic = false;
                if (match.Groups["italic"].Value == "-1")
                {
                    Italic = true;
                }

                Underline = false;
                if (match.Groups["underline"].Value == "-1")
                {
                    Underline = true;
                }

                StrikeOut = false;
                if (match.Groups["strikeout"].Value == "-1")
                {
                    StrikeOut = true;
                }

                Bold = false;
                if (match.Groups["bold"].Value == "-1")
                {
                    Bold = true;
                }

                ScaleX  = double.Parse(match.Groups["scaleX"].Value);
                ScaleY  = double.Parse(match.Groups["scaleX"].Value);
                Spacing = double.Parse(match.Groups["spacing"].Value);
                Angle   = double.Parse(match.Groups["angle"].Value);

                BorderStyle = false;
                if (match.Groups["borderStyle"].Value == "3")
                {
                    StrikeOut = true;
                }

                Outline        = double.Parse(match.Groups["outline"].Value);
                Shadow         = double.Parse(match.Groups["shadow"].Value);
                Alignment      = AlignmentInfo.StringToAlignment(match.Groups["alignment"].Value);
                MarginLeft     = int.Parse(match.Groups["marginL"].Value);
                MarginRight    = int.Parse(match.Groups["marginR"].Value);
                MarginVertical = int.Parse(match.Groups["marginV"].Value);
                Encoding       = CodificacionesInfo.StringToCodificacion(match.Groups["encoding"].Value);
            }
        }
コード例 #19
0
        /// <summary>
        /// Devuelve una cadena con el estilo preparado para un script ASS: "Style: Default,Arial,20...".
        /// </summary>
        public override string ToString()
        {
            var _Bold        = 0;
            var _Italic      = 0;
            var _Underline   = 0;
            var _StrikeOut   = 0;
            var _BorderStyle = 1;
            var _Alignment   = 5;
            var _Encoding    = 1;
            var _Color1      = "";
            var _Color2      = "";
            var _Color3      = "";
            var _Color4      = "";

            if (Bold)
            {
                _Bold = -1;
            }

            if (Italic)
            {
                _Italic = -1;
            }

            if (Underline)
            {
                _Underline = -1;
            }

            if (StrikeOut)
            {
                _StrikeOut = -1;
            }

            if (BorderStyle)
            {
                _BorderStyle = 3;
            }

            _Alignment = AlignmentInfo.AlignmentToInt(Alignment);
            _Encoding  = (int)Encoding;

            _Color1 = string.Format("&H{0:00}{1:00}{2:00}{3:00}",
                                    Maths.IntToHex(PrimaryAlpha),
                                    Maths.IntToHex(PrimaryColor.Blue),
                                    Maths.IntToHex(PrimaryColor.Green),
                                    Maths.IntToHex(PrimaryColor.Red));

            _Color2 = string.Format("&H{0:00}{1:00}{2:00}{3:00}",
                                    Maths.IntToHex(SecondaryAlpha),
                                    Maths.IntToHex(SecondaryColor.Blue),
                                    Maths.IntToHex(SecondaryColor.Green),
                                    Maths.IntToHex(SecondaryColor.Red));

            _Color3 = string.Format("&H{0:00}{1:00}{2:00}{3:00}",
                                    Maths.IntToHex(OutlineAlpha),
                                    Maths.IntToHex(OutlineColor.Blue),
                                    Maths.IntToHex(OutlineColor.Green),
                                    Maths.IntToHex(OutlineColor.Red));

            _Color4 = string.Format("&H{0:00}{1:00}{2:00}{3:00}",
                                    Maths.IntToHex(BackAlpha),
                                    Maths.IntToHex(BackColor.Blue),
                                    Maths.IntToHex(BackColor.Green),
                                    Maths.IntToHex(BackColor.Red));

            return(string.Format("Style: {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22}", Name, FontName, FontSize, _Color1, _Color2, _Color3, _Color4, _Bold, _Italic, _Underline, _StrikeOut, ScaleX, ScaleY, Spacing, Angle, _BorderStyle, Outline, Shadow, _Alignment, MarginLeft, MarginRight, MarginVertical, _Encoding));
        }
コード例 #20
0
        /// <summary>
        /// Initializes a new instance of the PairwiseAlignmentAttributes class.
        /// </summary>
        public PamsamAlignmentAttributes()
        {
            AlignmentInfo alignmentAttribute;

            attributes = new Dictionary <string, AlignmentInfo>();

            alignmentAttribute = new AlignmentInfo(
                KmerLength,
                "Kmer Length",
                true,
                "3",
                AlignmentInfo.IntType,
                null);
            attributes.Add(KmerLength, alignmentAttribute);

            StringListValidator listValidator = new StringListValidator(
                Enum.GetNames(typeof(DistanceFunctionTypes))
                );

            alignmentAttribute = new AlignmentInfo(
                DistanceFunctionType,
                "Distance Function Type",
                true,
                DistanceFunctionTypes.EuclideanDistance.ToString(),
                AlignmentInfo.StringListType,
                listValidator);
            attributes.Add(DistanceFunctionType, alignmentAttribute);

            listValidator = new StringListValidator(
                Enum.GetNames(typeof(UpdateDistanceMethodsTypes))
                );
            alignmentAttribute = new AlignmentInfo(
                UpdateDistanceMethodsType,
                "Update Distance Methods Type",
                true,
                UpdateDistanceMethodsTypes.Average.ToString(),
                AlignmentInfo.StringListType,
                listValidator);
            attributes.Add(UpdateDistanceMethodsType, alignmentAttribute);

            listValidator = new StringListValidator(
                Enum.GetNames(typeof(ProfileAlignerNames))
                );
            alignmentAttribute = new AlignmentInfo(
                ProfileAlignerName,
                "Profile Aligner Name",
                true,
                ProfileAlignerNames.NeedlemanWunschProfileAligner.ToString(),
                AlignmentInfo.StringListType,
                listValidator);
            attributes.Add(ProfileAlignerName, alignmentAttribute);

            listValidator = new StringListValidator(
                Enum.GetNames(typeof(ProfileScoreFunctionNames))
                );
            alignmentAttribute = new AlignmentInfo(
                ProfileScoreFunctionName,
                "Profile Score Function Name",
                true,
                ProfileScoreFunctionNames.WeightedInnerProduct.ToString(),
                AlignmentInfo.StringListType,
                listValidator);
            attributes.Add(ProfileScoreFunctionName, alignmentAttribute);

            listValidator = new StringListValidator(
                SM.StandardSimilarityMatrix.AmbiguousDna.ToString(),
                SM.StandardSimilarityMatrix.AmbiguousRna.ToString(),
                SM.StandardSimilarityMatrix.Blosum45.ToString(),
                SM.StandardSimilarityMatrix.Blosum50.ToString(),
                SM.StandardSimilarityMatrix.Blosum62.ToString(),
                SM.StandardSimilarityMatrix.Blosum80.ToString(),
                SM.StandardSimilarityMatrix.Blosum90.ToString(),
                SM.StandardSimilarityMatrix.Pam250.ToString(),
                SM.StandardSimilarityMatrix.Pam30.ToString(),
                SM.StandardSimilarityMatrix.Pam70.ToString()
                );

            alignmentAttribute = new AlignmentInfo(
                SimilarityMatrix,
                "Similarity Matrix",
                true,
                SM.StandardSimilarityMatrix.AmbiguousDna.ToString(),
                AlignmentInfo.StringListType,
                listValidator);
            attributes.Add(SimilarityMatrix, alignmentAttribute);

            alignmentAttribute = new AlignmentInfo(
                GapOpenPenalty,
                "Gap Open Penalty",
                true,
                "-4",
                AlignmentInfo.IntType,
                null);
            attributes.Add(GapOpenPenalty, alignmentAttribute);

            alignmentAttribute = new AlignmentInfo(
                GapExtendPenalty,
                "Gap Extention Penalty",
                true,
                "-1",
                AlignmentInfo.IntType,
                null);
            attributes.Add(GapExtendPenalty, alignmentAttribute);

            alignmentAttribute = new AlignmentInfo(
                NumberOfPartitions,
                "Number Of Partitions",
                true,
                (Environment.ProcessorCount * 2).ToString(),
                AlignmentInfo.IntType,
                null);
            attributes.Add(NumberOfPartitions, alignmentAttribute);

            alignmentAttribute = new AlignmentInfo(
                DegreeOfParallelism,
                "Degree Of Parallelism",
                true,
                Environment.ProcessorCount.ToString(),
                AlignmentInfo.IntType,
                null);
            attributes.Add(DegreeOfParallelism, alignmentAttribute);
        }