예제 #1
0
    // Main procedure
    private void action()
    {
        HOperatorSetX    Op    = new HOperatorSetX();
        HTupleX          Tuple = new HTupleX();
        HDevWindowStackX COMExpWinHandleStack = new HDevWindowStackX();

        // Local iconic variables

        HUntypedObjectX ho_Image = null, ho_SymbolRegions = null;


        // Local control variables

        object hv_BarCodeHandle, hv_WindowHandle, hv_I;
        object hv_Width = null, hv_Height = null, hv_DecodedDataStrings = null;
        object hv_LastChar = null;

        // Initialize local and output iconic variables
        Op.GenEmptyObj(out ho_Image);
        Op.GenEmptyObj(out ho_SymbolRegions);

        //Read bar codes of type 2/5 Industrial
        //
        Op.CreateBarCodeModel(null, null, out hv_BarCodeHandle);
        if (COMExpWinHandleStack.IsOpen() != 0)
        {
            Op.CloseWindow(COMExpWinHandleStack.Pop());
        }
        Op.SetWindowAttr("background_color", "black");
        Op.OpenWindow(0, 0, 120, 300, 0, "", "", out hv_WindowHandle);
        COMExpWinHandleStack.Push(hv_WindowHandle);
        set_display_font(hv_WindowHandle, 14, "mono", "true", "false");
        if (COMExpWinHandleStack.IsOpen() != 0)
        {
            Op.SetDraw(COMExpWinHandleStack.GetActive(), "margin");
        }
        if (COMExpWinHandleStack.IsOpen() != 0)
        {
            Op.SetLineWidth(COMExpWinHandleStack.GetActive(), 3);
        }
        for (hv_I = 1; Convert.ToInt32(hv_I) <= 4; hv_I = Convert.ToInt32(hv_I) + 1)
        {
            Marshal.ReleaseComObject(ho_Image);
            Op.ReadImage(out ho_Image, Tuple.TupleAdd("barcode/25industrial/25industrial0",
                                                      hv_I));
            Op.GetImageSize(ho_Image, out hv_Width, out hv_Height);
            if (COMExpWinHandleStack.IsOpen() != 0)
            {
                Op.SetWindowExtents(COMExpWinHandleStack.GetActive(), 0, 0, Tuple.TupleSub(
                                        hv_Width, 1), Tuple.TupleSub(hv_Height, 1));
            }
            if (COMExpWinHandleStack.IsOpen() != 0)
            {
                Op.DispObj(ho_Image, COMExpWinHandleStack.GetActive());
            }
            if (COMExpWinHandleStack.IsOpen() != 0)
            {
                Op.SetColor(COMExpWinHandleStack.GetActive(), "green");
            }
            //Read bar code, the resulting string includes the check character
            Op.SetBarCodeParam(hv_BarCodeHandle, "check_char", "absent");
            Marshal.ReleaseComObject(ho_SymbolRegions);
            Op.FindBarCode(ho_Image, out ho_SymbolRegions, hv_BarCodeHandle, "2/5 Industrial",
                           out hv_DecodedDataStrings);
            disp_message(hv_WindowHandle, hv_DecodedDataStrings, "window", 12, 12, "black",
                         "false");
            hv_LastChar = Tuple.TupleSub(Tuple.TupleStrlen(hv_DecodedDataStrings), 1);
            disp_message(hv_WindowHandle, Tuple.TupleAdd(Tuple.TupleSum(Tuple.TupleGenConst(
                                                                            hv_LastChar, " ")), Tuple.TupleStrBitSelect(hv_DecodedDataStrings, hv_LastChar)),
                         "window", 12, 12, "forest green", "false");
            HDevelopStop();
            //Read bar code using the check character to check the result, i.e.,
            //the check character does not belong to the returned string anymore.
            //If the check character is not correct, the bar code reading fails
            if (COMExpWinHandleStack.IsOpen() != 0)
            {
                Op.SetColor(COMExpWinHandleStack.GetActive(), "green");
            }
            Op.SetBarCodeParam(hv_BarCodeHandle, "check_char", "present");
            Marshal.ReleaseComObject(ho_SymbolRegions);
            Op.FindBarCode(ho_Image, out ho_SymbolRegions, hv_BarCodeHandle, "2/5 Industrial",
                           out hv_DecodedDataStrings);
            disp_message(hv_WindowHandle, hv_DecodedDataStrings, "window", 36, 12, "black",
                         "false");
            if (COMExpWinHandleStack.IsOpen() != 0)
            {
                Op.SetColor(COMExpWinHandleStack.GetActive(), "magenta");
            }
            if (Convert.ToInt32(Tuple.TupleLess(hv_I, 4)) != 0)
            {
                HDevelopStop();
            }
        }
        Op.ClearBarCodeModel(hv_BarCodeHandle);
        Marshal.ReleaseComObject(ho_Image);
        Marshal.ReleaseComObject(ho_SymbolRegions);
    }