2015-11-02 6 views
-3

В main.cs У меня есть сильфонные коды:C# - ... недоступен из-за его уровня защиты?

using HalconDotNet; 

public partial class HDevelopExport 
{ 
#if !(NO_EXPORT_MAIN || NO_EXPORT_APP_MAIN) 
    public HDevelopExport() 
    { 
    // Default settings used in HDevelop 
    HOperatorSet.SetSystem("width", 512); 
    HOperatorSet.SetSystem("height", 512); 
    action(); 
    } 
#endif 

    public void HDevelopStop() 
    { 
    } 

    // Procedures 
    // External procedures 
    // Chapter: Graphics/Text 
    // Short Description: This procedure displays 'Click 'Run' to continue' in the lower right corner of the screen. 
    public void disp_continue_message (HTuple hv_WindowHandle, HTuple hv_Color, HTuple hv_Box) 
    { 


    // Local control variables 

    HTuple hv_ContinueMessage = null, hv_Row = null; 
    HTuple hv_Column = null, hv_Width = null, hv_Height = null; 
    HTuple hv_Ascent = null, hv_Descent = null, hv_TextWidth = null; 
    HTuple hv_TextHeight = null; 

    // Initialize local and output iconic variables 

    //This procedure displays 'Press Run (F5) to continue' in the 
    //lower right corner of the screen. 
    //It uses the procedure disp_message. 
    // 
    //Input parameters: 
    //WindowHandle: The window, where the text shall be displayed 
    //Color: defines the text color. 
    // If set to '' or 'auto', the currently set color is used. 
    //Box: If set to 'true', the text is displayed in a box. 
    // 
    hv_ContinueMessage = "Press Run (F5) to continue"; 
    HOperatorSet.GetWindowExtents(hv_WindowHandle, out hv_Row, out hv_Column, out hv_Width, 
     out hv_Height); 
    HOperatorSet.GetStringExtents(hv_WindowHandle, (" "+hv_ContinueMessage)+" ", 
     out hv_Ascent, out hv_Descent, out hv_TextWidth, out hv_TextHeight); 
    /* disp_message(hv_WindowHandle, hv_ContinueMessage, "window", (hv_Height-hv_TextHeight)-12, 
     (hv_Width-hv_TextWidth)-12, hv_Color, hv_Box);*/ 

    return; 
    } 

    // Chapter: Graphics/Text 
    // Short Description: This procedure writes a text message. 
    public void disp_message (HTuple hv_WindowHandle, HTuple hv_String, HTuple hv_CoordSystem, 
     HTuple hv_Row, HTuple hv_Column, HTuple hv_Color, HTuple hv_Box) 
    { 


    // Local control variables 

    HTuple hv_Red = null, hv_Green = null, hv_Blue = null; 
    HTuple hv_Row1Part = null, hv_Column1Part = null, hv_Row2Part = null; 
    HTuple hv_Column2Part = null, hv_RowWin = null, hv_ColumnWin = null; 
    HTuple hv_WidthWin = null, hv_HeightWin = null, hv_MaxAscent = null; 
    HTuple hv_MaxDescent = null, hv_MaxWidth = null, hv_MaxHeight = null; 
    HTuple hv_R1 = new HTuple(), hv_C1 = new HTuple(), hv_FactorRow = new HTuple(); 
    HTuple hv_FactorColumn = new HTuple(), hv_Width = new HTuple(); 
    HTuple hv_Index = new HTuple(), hv_Ascent = new HTuple(); 
    HTuple hv_Descent = new HTuple(), hv_W = new HTuple(); 
    HTuple hv_H = new HTuple(), hv_FrameHeight = new HTuple(); 
    HTuple hv_FrameWidth = new HTuple(), hv_R2 = new HTuple(); 
    HTuple hv_C2 = new HTuple(), hv_DrawMode = new HTuple(); 
    HTuple hv_Exception = new HTuple(), hv_CurrentColor = new HTuple(); 

    HTuple hv_Color_COPY_INP_TMP = hv_Color.Clone(); 
    HTuple hv_Column_COPY_INP_TMP = hv_Column.Clone(); 
    HTuple hv_Row_COPY_INP_TMP = hv_Row.Clone(); 
    HTuple hv_String_COPY_INP_TMP = hv_String.Clone(); 

    // Initialize local and output iconic variables 

    //This procedure displays text in a graphics window. 
    // 
    //Input parameters: 
    //WindowHandle: The WindowHandle of the graphics window, where 
    // the message should be displayed 
    //String: A tuple of strings containing the text message to be displayed 
    //CoordSystem: If set to 'window', the text position is given 
    // with respect to the window coordinate system. 
    // If set to 'image', image coordinates are used. 
    // (This may be useful in zoomed images.) 
    //Row: The row coordinate of the desired text position 
    // If set to -1, a default value of 12 is used. 
    //Column: The column coordinate of the desired text position 
    // If set to -1, a default value of 12 is used. 
    //Color: defines the color of the text as string. 
    // If set to [], '' or 'auto' the currently set color is used. 
    // If a tuple of strings is passed, the colors are used cyclically 
    // for each new textline. 
    //Box: If set to 'true', the text is written within a white box. 
    // 
    //prepare window 
    HOperatorSet.GetRgb(hv_WindowHandle, out hv_Red, out hv_Green, out hv_Blue); 
    HOperatorSet.GetPart(hv_WindowHandle, out hv_Row1Part, out hv_Column1Part, out hv_Row2Part, 
     out hv_Column2Part); 
    HOperatorSet.GetWindowExtents(hv_WindowHandle, out hv_RowWin, out hv_ColumnWin, 
     out hv_WidthWin, out hv_HeightWin); 
    HOperatorSet.SetPart(hv_WindowHandle, 0, 0, hv_HeightWin-1, hv_WidthWin-1); 
    // 
    //default settings 
    if ((int)(new HTuple(hv_Row_COPY_INP_TMP.TupleEqual(-1))) != 0) 
    { 
     hv_Row_COPY_INP_TMP = 12; 
    } 
    if ((int)(new HTuple(hv_Column_COPY_INP_TMP.TupleEqual(-1))) != 0) 
    { 
     hv_Column_COPY_INP_TMP = 12; 
    } 
    if ((int)(new HTuple(hv_Color_COPY_INP_TMP.TupleEqual(new HTuple()))) != 0) 
    { 
     hv_Color_COPY_INP_TMP = ""; 
    } 
    // 
    hv_String_COPY_INP_TMP = (((""+hv_String_COPY_INP_TMP)+"")).TupleSplit("\n"); 
    // 
    //Estimate extentions of text depending on font size. 
    HOperatorSet.GetFontExtents(hv_WindowHandle, out hv_MaxAscent, out hv_MaxDescent, 
     out hv_MaxWidth, out hv_MaxHeight); 
    if ((int)(new HTuple(hv_CoordSystem.TupleEqual("window"))) != 0) 
    { 
     hv_R1 = hv_Row_COPY_INP_TMP.Clone(); 
     hv_C1 = hv_Column_COPY_INP_TMP.Clone(); 
    } 
    else 
    { 
     //transform image to window coordinates 
     hv_FactorRow = (1.0*hv_HeightWin)/((hv_Row2Part-hv_Row1Part)+1); 
     hv_FactorColumn = (1.0*hv_WidthWin)/((hv_Column2Part-hv_Column1Part)+1); 
     hv_R1 = ((hv_Row_COPY_INP_TMP-hv_Row1Part)+0.5)*hv_FactorRow; 
     hv_C1 = ((hv_Column_COPY_INP_TMP-hv_Column1Part)+0.5)*hv_FactorColumn; 
    } 
    // 
    //display text box depending on text size 
    if ((int)(new HTuple(hv_Box.TupleEqual("true"))) != 0) 
    { 
     //calculate box extents 
     hv_String_COPY_INP_TMP = (" "+hv_String_COPY_INP_TMP)+" "; 
     hv_Width = new HTuple(); 
     for (hv_Index=0; (int)hv_Index<=(int)((new HTuple(hv_String_COPY_INP_TMP.TupleLength() 
     ))-1); hv_Index = (int)hv_Index + 1) 
     { 
     HOperatorSet.GetStringExtents(hv_WindowHandle, hv_String_COPY_INP_TMP.TupleSelect(
      hv_Index), out hv_Ascent, out hv_Descent, out hv_W, out hv_H); 
     hv_Width = hv_Width.TupleConcat(hv_W); 
     } 
     hv_FrameHeight = hv_MaxHeight*(new HTuple(hv_String_COPY_INP_TMP.TupleLength() 
     )); 
     hv_FrameWidth = (((new HTuple(0)).TupleConcat(hv_Width))).TupleMax(); 
     hv_R2 = hv_R1+hv_FrameHeight; 
     hv_C2 = hv_C1+hv_FrameWidth; 
     //display rectangles 
     HOperatorSet.GetDraw(hv_WindowHandle, out hv_DrawMode); 
     HOperatorSet.SetDraw(hv_WindowHandle, "fill"); 
     HOperatorSet.SetColor(hv_WindowHandle, "light gray"); 
     HOperatorSet.DispRectangle1(hv_WindowHandle, hv_R1+3, hv_C1+3, hv_R2+3, hv_C2+3); 
     HOperatorSet.SetColor(hv_WindowHandle, "white"); 
     HOperatorSet.DispRectangle1(hv_WindowHandle, hv_R1, hv_C1, hv_R2, hv_C2); 
     HOperatorSet.SetDraw(hv_WindowHandle, hv_DrawMode); 
    } 
    else if ((int)(new HTuple(hv_Box.TupleNotEqual("false"))) != 0) 
    { 
     hv_Exception = "Wrong value of control parameter Box"; 
     throw new HalconException(hv_Exception); 
    } 
    //Write text. 
    for (hv_Index=0; (int)hv_Index<=(int)((new HTuple(hv_String_COPY_INP_TMP.TupleLength() 
     ))-1); hv_Index = (int)hv_Index + 1) 
    { 
     hv_CurrentColor = hv_Color_COPY_INP_TMP.TupleSelect(hv_Index%(new HTuple(hv_Color_COPY_INP_TMP.TupleLength() 
     ))); 
     if ((int)((new HTuple(hv_CurrentColor.TupleNotEqual(""))).TupleAnd(new HTuple(hv_CurrentColor.TupleNotEqual(
      "auto")))) != 0) 
     { 
     HOperatorSet.SetColor(hv_WindowHandle, hv_CurrentColor); 
     } 
     else 
     { 
     HOperatorSet.SetRgb(hv_WindowHandle, hv_Red, hv_Green, hv_Blue); 
     } 
     hv_Row_COPY_INP_TMP = hv_R1+(hv_MaxHeight*hv_Index); 
     HOperatorSet.SetTposition(hv_WindowHandle, hv_Row_COPY_INP_TMP, hv_C1); 
     HOperatorSet.WriteString(hv_WindowHandle, hv_String_COPY_INP_TMP.TupleSelect(
      hv_Index)); 
    } 
    //reset changed window settings 
    HOperatorSet.SetRgb(hv_WindowHandle, hv_Red, hv_Green, hv_Blue); 
    HOperatorSet.SetPart(hv_WindowHandle, hv_Row1Part, hv_Column1Part, hv_Row2Part, 
     hv_Column2Part); 

    return; 
    } 

    // Chapter: Graphics/Text 
    // Short Description: Set font independent of OS 
    public void set_display_font (HTuple hv_WindowHandle, HTuple hv_Size, HTuple hv_Font, 
     HTuple hv_Bold, HTuple hv_Slant) 
    { 


     // Local control variables 

     HTuple hv_OS = null, hv_Exception = new HTuple(); 
     HTuple hv_BoldString = new HTuple(), hv_SlantString = new HTuple(); 
     HTuple hv_AllowedFontSizes = new HTuple(), hv_Distances = new HTuple(); 
     HTuple hv_Indices = new HTuple(), hv_Fonts = new HTuple(); 
     HTuple hv_FontSelRegexp = new HTuple(), hv_FontsCourier = new HTuple(); 

     HTuple hv_Bold_COPY_INP_TMP = hv_Bold.Clone(); 
     HTuple hv_Font_COPY_INP_TMP = hv_Font.Clone(); 
     HTuple hv_Size_COPY_INP_TMP = hv_Size.Clone(); 
     HTuple hv_Slant_COPY_INP_TMP = hv_Slant.Clone(); 

     // Initialize local and output iconic variables 

    //This procedure sets the text font of the current window with 
    //the specified attributes. 
    //It is assumed that following fonts are installed on the system: 
    //Windows: Courier New, Arial Times New Roman 
    //Mac OS X: CourierNewPS, Arial, TimesNewRomanPS 
    //Linux: courier, helvetica, times 
    //Because fonts are displayed smaller on Linux than on Windows, 
    //a scaling factor of 1.25 is used the get comparable results. 
    //For Linux, only a limited number of font sizes is supported, 
    //to get comparable results, it is recommended to use one of the 
    //following sizes: 9, 11, 14, 16, 20, 27 
    //(which will be mapped internally on Linux systems to 11, 14, 17, 20, 25, 34) 
    // 
    //Input parameters: 
    //WindowHandle: The graphics window for which the font will be set 
    //Size: The font size. If Size=-1, the default of 16 is used. 
    //Bold: If set to 'true', a bold font is used 
    //Slant: If set to 'true', a slanted font is used 
    // 
    HOperatorSet.GetSystem("operating_system", out hv_OS); 
    // dev_get_preferences(...); only in hdevelop 
    // dev_set_preferences(...); only in hdevelop 
    if ((int)((new HTuple(hv_Size_COPY_INP_TMP.TupleEqual(new HTuple()))).TupleOr(
     new HTuple(hv_Size_COPY_INP_TMP.TupleEqual(-1)))) != 0) 
    { 
     hv_Size_COPY_INP_TMP = 16; 
    } 
    if ((int)(new HTuple(((hv_OS.TupleSubstr(0,2))).TupleEqual("Win"))) != 0) 
    { 
     //Set font on Windows systems 
     if ((int)((new HTuple((new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("mono"))).TupleOr(
      new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("Courier"))))).TupleOr(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual(
      "courier")))) != 0) 
     { 
     hv_Font_COPY_INP_TMP = "Courier New"; 
     } 
     else if ((int)(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("sans"))) != 0) 
     { 
     hv_Font_COPY_INP_TMP = "Arial"; 
     } 
     else if ((int)(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("serif"))) != 0) 
     { 
     hv_Font_COPY_INP_TMP = "Times New Roman"; 
     } 
     if ((int)(new HTuple(hv_Bold_COPY_INP_TMP.TupleEqual("true"))) != 0) 
     { 
     hv_Bold_COPY_INP_TMP = 1; 
     } 
     else if ((int)(new HTuple(hv_Bold_COPY_INP_TMP.TupleEqual("false"))) != 0) 
     { 
     hv_Bold_COPY_INP_TMP = 0; 
     } 
     else 
     { 
     hv_Exception = "Wrong value of control parameter Bold"; 
     throw new HalconException(hv_Exception); 
     } 
     if ((int)(new HTuple(hv_Slant_COPY_INP_TMP.TupleEqual("true"))) != 0) 
     { 
     hv_Slant_COPY_INP_TMP = 1; 
     } 
     else if ((int)(new HTuple(hv_Slant_COPY_INP_TMP.TupleEqual("false"))) != 0) 
     { 
     hv_Slant_COPY_INP_TMP = 0; 
     } 
     else 
     { 
     hv_Exception = "Wrong value of control parameter Slant"; 
     throw new HalconException(hv_Exception); 
     } 
     try 
     { 
     HOperatorSet.SetFont(hv_WindowHandle, ((((((("-"+hv_Font_COPY_INP_TMP)+"-")+hv_Size_COPY_INP_TMP)+"-*-")+hv_Slant_COPY_INP_TMP)+"-*-*-")+hv_Bold_COPY_INP_TMP)+"-"); 
     } 
     // catch (Exception) 
     catch (HalconException HDevExpDefaultException1) 
     { 
     HDevExpDefaultException1.ToHTuple(out hv_Exception); 
     //throw (Exception) 
     } 
    } 
    else if ((int)(new HTuple(((hv_OS.TupleSubstr(0,2))).TupleEqual("Dar"))) != 0) 
    { 
     //Set font on Mac OS X systems 
     if ((int)(new HTuple(hv_Bold_COPY_INP_TMP.TupleEqual("true"))) != 0) 
     { 
     hv_BoldString = "Bold"; 
     } 
     else if ((int)(new HTuple(hv_Bold_COPY_INP_TMP.TupleEqual("false"))) != 0) 
     { 
     hv_BoldString = ""; 
     } 
     else 
     { 
     hv_Exception = "Wrong value of control parameter Bold"; 
     throw new HalconException(hv_Exception); 
     } 
     if ((int)(new HTuple(hv_Slant_COPY_INP_TMP.TupleEqual("true"))) != 0) 
     { 
     hv_SlantString = "Italic"; 
     } 
     else if ((int)(new HTuple(hv_Slant_COPY_INP_TMP.TupleEqual("false"))) != 0) 
     { 
     hv_SlantString = ""; 
     } 
     else 
     { 
     hv_Exception = "Wrong value of control parameter Slant"; 
     throw new HalconException(hv_Exception); 
     } 
     if ((int)((new HTuple((new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("mono"))).TupleOr(
      new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("Courier"))))).TupleOr(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual(
      "courier")))) != 0) 
     { 
     hv_Font_COPY_INP_TMP = "CourierNewPS"; 
     } 
     else if ((int)(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("sans"))) != 0) 
     { 
     hv_Font_COPY_INP_TMP = "Arial"; 
     } 
     else if ((int)(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("serif"))) != 0) 
     { 
     hv_Font_COPY_INP_TMP = "TimesNewRomanPS"; 
     } 
     if ((int)((new HTuple(hv_Bold_COPY_INP_TMP.TupleEqual("true"))).TupleOr(new HTuple(hv_Slant_COPY_INP_TMP.TupleEqual(
      "true")))) != 0) 
     { 
     hv_Font_COPY_INP_TMP = ((hv_Font_COPY_INP_TMP+"-")+hv_BoldString)+hv_SlantString; 
     } 
     hv_Font_COPY_INP_TMP = hv_Font_COPY_INP_TMP+"MT"; 
     try 
     { 
     HOperatorSet.SetFont(hv_WindowHandle, (hv_Font_COPY_INP_TMP+"-")+hv_Size_COPY_INP_TMP); 
     } 
     // catch (Exception) 
     catch (HalconException HDevExpDefaultException1) 
     { 
     HDevExpDefaultException1.ToHTuple(out hv_Exception); 
     //throw (Exception) 
     } 
    } 
    else 
    { 
     //Set font for UNIX systems 
     hv_Size_COPY_INP_TMP = hv_Size_COPY_INP_TMP*1.25; 
     hv_AllowedFontSizes = new HTuple(); 
     hv_AllowedFontSizes[0] = 11; 
     hv_AllowedFontSizes[1] = 14; 
     hv_AllowedFontSizes[2] = 17; 
     hv_AllowedFontSizes[3] = 20; 
     hv_AllowedFontSizes[4] = 25; 
     hv_AllowedFontSizes[5] = 34; 
     if ((int)(new HTuple(((hv_AllowedFontSizes.TupleFind(hv_Size_COPY_INP_TMP))).TupleEqual(
      -1))) != 0) 
     { 
     hv_Distances = ((hv_AllowedFontSizes-hv_Size_COPY_INP_TMP)).TupleAbs(); 
     HOperatorSet.TupleSortIndex(hv_Distances, out hv_Indices); 
     hv_Size_COPY_INP_TMP = hv_AllowedFontSizes.TupleSelect(hv_Indices.TupleSelect(
      0)); 
     } 
     if ((int)((new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("mono"))).TupleOr(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual(
      "Courier")))) != 0) 
     { 
     hv_Font_COPY_INP_TMP = "courier"; 
     } 
     else if ((int)(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("sans"))) != 0) 
     { 
     hv_Font_COPY_INP_TMP = "helvetica"; 
     } 
     else if ((int)(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("serif"))) != 0) 
     { 
     hv_Font_COPY_INP_TMP = "times"; 
     } 
     if ((int)(new HTuple(hv_Bold_COPY_INP_TMP.TupleEqual("true"))) != 0) 
     { 
     hv_Bold_COPY_INP_TMP = "bold"; 
     } 
     else if ((int)(new HTuple(hv_Bold_COPY_INP_TMP.TupleEqual("false"))) != 0) 
     { 
     hv_Bold_COPY_INP_TMP = "medium"; 
     } 
     else 
     { 
     hv_Exception = "Wrong value of control parameter Bold"; 
     throw new HalconException(hv_Exception); 
     } 
     if ((int)(new HTuple(hv_Slant_COPY_INP_TMP.TupleEqual("true"))) != 0) 
     { 
     if ((int)(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("times"))) != 0) 
     { 
      hv_Slant_COPY_INP_TMP = "i"; 
     } 
     else 
     { 
      hv_Slant_COPY_INP_TMP = "o"; 
     } 
     } 
     else if ((int)(new HTuple(hv_Slant_COPY_INP_TMP.TupleEqual("false"))) != 0) 
     { 
     hv_Slant_COPY_INP_TMP = "r"; 
     } 
     else 
     { 
     hv_Exception = "Wrong value of control parameter Slant"; 
     throw new HalconException(hv_Exception); 
     } 
     try 
     { 
     HOperatorSet.SetFont(hv_WindowHandle, ((((((("-adobe-"+hv_Font_COPY_INP_TMP)+"-")+hv_Bold_COPY_INP_TMP)+"-")+hv_Slant_COPY_INP_TMP)+"-normal-*-")+hv_Size_COPY_INP_TMP)+"-*-*-*-*-*-*-*"); 
     } 
     // catch (Exception) 
     catch (HalconException HDevExpDefaultException1) 
     { 
     HDevExpDefaultException1.ToHTuple(out hv_Exception); 
     if ((int)((new HTuple(((hv_OS.TupleSubstr(0,4))).TupleEqual("Linux"))).TupleAnd(
      new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("courier")))) != 0) 
     { 
      HOperatorSet.QueryFont(hv_WindowHandle, out hv_Fonts); 
      hv_FontSelRegexp = (("^-[^-]*-[^-]*[Cc]ourier[^-]*-"+hv_Bold_COPY_INP_TMP)+"-")+hv_Slant_COPY_INP_TMP; 
      hv_FontsCourier = ((hv_Fonts.TupleRegexpSelect(hv_FontSelRegexp))).TupleRegexpMatch(
       hv_FontSelRegexp); 
      if ((int)(new HTuple((new HTuple(hv_FontsCourier.TupleLength())).TupleEqual(
       0))) != 0) 
      { 
      hv_Exception = "Wrong font name"; 
      //throw (Exception) 
      } 
      else 
      { 
      try 
      { 
       HOperatorSet.SetFont(hv_WindowHandle, (((hv_FontsCourier.TupleSelect(
        0))+"-normal-*-")+hv_Size_COPY_INP_TMP)+"-*-*-*-*-*-*-*"); 
      } 
      // catch (Exception) 
      catch (HalconException HDevExpDefaultException2) 
      { 
       HDevExpDefaultException2.ToHTuple(out hv_Exception); 
       //throw (Exception) 
      } 
      } 
     } 
     //throw (Exception) 
     } 
    } 
    // dev_set_preferences(...); only in hdevelop 

    return; 
    } 

#if !NO_EXPORT_MAIN 
    // Main procedure 
    private void action() 
    { 

    // Local iconic variables 

    HObject ho_Clip, ho_Dark, ho_Single, ho_Selected; 


    // Local control variables 

    HTuple hv_Width = null, hv_Height = null, hv_WindowID = null; 
    HTuple hv_Phi = null, hv_Area = null, hv_Row = null, hv_Column = null; 
    HTuple hv_Length = null, hv_i = null; 

    // Initialize local and output iconic variables 
    HOperatorSet.GenEmptyObj(out ho_Clip); 
    HOperatorSet.GenEmptyObj(out ho_Dark); 
    HOperatorSet.GenEmptyObj(out ho_Single); 
    HOperatorSet.GenEmptyObj(out ho_Selected); 

    try 
    { 
     //clip.hdev: Orientation of clips 
     // 
     // dev_update_window(...); only in hdevelop 
     ho_Clip.Dispose(); 
     HOperatorSet.ReadImage(out ho_Clip, "C:/Users/admin/Desktop/newfolder/clip.png"); 
     HOperatorSet.GetImageSize(ho_Clip, out hv_Width, out hv_Height); 
     if (HDevWindowStack.IsOpen()) 
     { 
     HOperatorSet.CloseWindow(HDevWindowStack.Pop()); 
     } 
     HOperatorSet.SetWindowAttr("background_color","black"); 
     HOperatorSet.OpenWindow(0,0,hv_Width/2,hv_Height/2,0,"","",out hv_WindowID); 
     HDevWindowStack.Push(hv_WindowID); 
     if (HDevWindowStack.IsOpen()) 
     { 
     HOperatorSet.DispObj(ho_Clip, HDevWindowStack.GetActive()); 
     } 
    // set_display_font(hv_WindowID, 14, "mono", "true", "false"); 
    // disp_continue_message(hv_WindowID, "black", "true"); 
     HDevelopStop(); 
     ho_Dark.Dispose(); 
     HOperatorSet.BinThreshold(ho_Clip, out ho_Dark); 
     ho_Single.Dispose(); 
     HOperatorSet.Connection(ho_Dark, out ho_Single); 
     ho_Selected.Dispose(); 
     HOperatorSet.SelectShape(ho_Single, out ho_Selected, "area", "and", 5000, 10000); 
     if (HDevWindowStack.IsOpen()) 
     { 
     HOperatorSet.SetDraw(HDevWindowStack.GetActive(), "fill"); 
     } 
     if (HDevWindowStack.IsOpen()) 
     { 
     HOperatorSet.SetColored(HDevWindowStack.GetActive(), 12); 
     } 
     if (HDevWindowStack.IsOpen()) 
     { 
     HOperatorSet.DispObj(ho_Selected, HDevWindowStack.GetActive()); 
     } 
    // disp_continue_message(hv_WindowID, "black", "true"); 
     HDevelopStop(); 
     if (HDevWindowStack.IsOpen()) 
     { 
     HOperatorSet.DispObj(ho_Clip, HDevWindowStack.GetActive()); 
     } 
     if (HDevWindowStack.IsOpen()) 
     { 
     HOperatorSet.SetColor(HDevWindowStack.GetActive(), "green"); 
     } 
     if (HDevWindowStack.IsOpen()) 
     { 
     HOperatorSet.DispObj(ho_Selected, HDevWindowStack.GetActive()); 
     } 
     HOperatorSet.OrientationRegion(ho_Selected, out hv_Phi); 
     HOperatorSet.AreaCenter(ho_Selected, out hv_Area, out hv_Row, out hv_Column); 
     if (HDevWindowStack.IsOpen()) 
     { 
     HOperatorSet.SetLineWidth(HDevWindowStack.GetActive(), 3); 
     } 
     if (HDevWindowStack.IsOpen()) 
     { 
     HOperatorSet.SetDraw(HDevWindowStack.GetActive(), "margin"); 
     } 
     hv_Length = 80; 
     for (hv_i=0; (int)hv_i<=(int)((new HTuple(hv_Phi.TupleLength()))-1); hv_i = (int)hv_i + 1) 
     { 
     if (HDevWindowStack.IsOpen()) 
     { 
      HOperatorSet.SetColor(HDevWindowStack.GetActive(), "blue"); 
     } 
     HOperatorSet.DispArrow(hv_WindowID, hv_Row.TupleSelect(hv_i), hv_Column.TupleSelect(
      hv_i), (hv_Row.TupleSelect(hv_i))-(hv_Length*(((hv_Phi.TupleSelect(hv_i))).TupleSin() 
      )), (hv_Column.TupleSelect(hv_i))+(hv_Length*(((hv_Phi.TupleSelect(hv_i))).TupleCos() 
      )), 4); 
     /* disp_message(hv_WindowID, (((((hv_Phi.TupleSelect(hv_i))).TupleDeg())).TupleString(
      "3.1f"))+" deg", "image", hv_Row.TupleSelect(hv_i), (hv_Column.TupleSelect(
      hv_i))-100, "black", "false");*/ 
     } 
     // dev_update_window(...); only in hdevelop 
    } 
    catch (HalconException HDevExpDefaultException) 
    { 
     ho_Clip.Dispose(); 
     ho_Dark.Dispose(); 
     ho_Single.Dispose(); 
     ho_Selected.Dispose(); 

     throw HDevExpDefaultException; 
    } 
    ho_Clip.Dispose(); 
    ho_Dark.Dispose(); 
    ho_Single.Dispose(); 
    ho_Selected.Dispose(); 

    } 

#endif 


} 
#if !(NO_EXPORT_MAIN || NO_EXPORT_APP_MAIN) 
public class HDevelopExportApp 
{ 
    static void Main(string[] args) 
    { 
    new HDevelopExport(); 
    } 
} 
#endif 

Но когда я использую из этого класса получить мне ошибку:

namespace DetectObject35 
{ 
    public partial class Form1 : Form 
    { 
     private HDevelopExport c; 

     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void Form1_Load(object sender, EventArgs e) 
     { 
      HTuple WindowID = hWindowControl1.HalconID; 
      c = new HDevelopExport(); 
     } 

     private void btnRun_Click(object sender, EventArgs e) 
     { 
      c.action(); 
     } 
    } 
} 

В этой строке (c.action();) говорят мне HDevelopExport.action() недоступен из-за его уровень защиты.

+3

'action()' является закрытым, вам нужно сделать его общедоступным, чтобы ваш текущий код работал. – Jonesopolis

+0

'action()' является частным членом класса 'HDevelopExport'. Ваш код отсутствует в этом классе, но пытается получить к нему доступ. Частичные классы должны иметь одно и то же имя, чтобы считаться частями того же класса – Orphid

ответ

2

Метод action является частным:

... 
#if !NO_EXPORT_MAIN 
    // Main procedure 
    private void action() 
    { 
... 

Это то, что сообщение об ошибке говорит вам. Если вы хотите иметь доступ к нему из-за пределов класса HDevelopExport, он должен быть public (или internal, или вам придется использовать отражение).

+0

Oh. Да, спасибо . –

+0

Привет @sloth. У меня проблема в моем проекте, могу ли я получить ссылку на мой проект и увидеть мою проблему? –

0

HDevelopExport.action() является закрытым. Вот почему он недоступен.

Вам нужно будет сделать его общедоступным или использовать отражение для доступа к нему. Тем не менее, я настоятельно рекомендую против использования отражения, чтобы подорвать уровень защиты метода.

public void action() 
{ 
    ....... 
Смежные вопросы