• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { PageDirection, PrintQuality, MediaType ,Duplex} from '@ohos/common'
17import { Log, MediaSize } from '@ohos/common'
18
19const TAG = '[SelectionModel]:'
20export default class SelectionModel {
21
22  public static readonly Add_Printer : SelectionModel = new SelectionModel('index_add_printer'
23    ,null,$r('app.string.index_add_printer'))
24  public static readonly NO_Printer : SelectionModel = new SelectionModel('index_no_printer_selected'
25    ,null,$r('app.string.index_no_printer_selected'))
26  public static readonly MediaSize_ISO_A3 : SelectionModel = new SelectionModel('ISO_A3'
27    ,MediaSize.ISO_A3,MediaSize.ISO_A3.label)
28  public static readonly MediaSize_ISO_A4 : SelectionModel = new SelectionModel('ISO_A4'
29    ,MediaSize.ISO_A4,MediaSize.ISO_A4.label)
30  public static readonly MediaSize_ISO_A5 : SelectionModel = new SelectionModel('ISO_A5'
31    ,MediaSize.ISO_A5,MediaSize.ISO_A5.label)
32  public static readonly MediaSize_JIS_B5 : SelectionModel = new SelectionModel('JIS_B5'
33    ,MediaSize.JIS_B5,MediaSize.JIS_B5.label)
34  public static readonly MediaSize_ISO_C5 : SelectionModel = new SelectionModel('ISO_C5'
35    ,MediaSize.ISO_C5,MediaSize.ISO_C5.label)
36  public static readonly MediaSize_ISO_DL : SelectionModel = new SelectionModel('ISO_DL'
37    ,MediaSize.ISO_DL,MediaSize.ISO_DL.label)
38  public static readonly MediaSize_LETTER : SelectionModel = new SelectionModel('LETTER'
39    ,MediaSize.LETTER,MediaSize.LETTER.label)
40  public static readonly MediaSize_LEGAL : SelectionModel = new SelectionModel('LEGAL'
41    ,MediaSize.LEGAL,MediaSize.LEGAL.label)
42  public static readonly MediaSize_PHOTO_4x6 : SelectionModel = new SelectionModel('PHOTO_4x6'
43    ,MediaSize.PHOTO_4x6,MediaSize.PHOTO_4x6.label)
44  public static readonly MediaSize_PHOTO_5x7 : SelectionModel = new SelectionModel('PHOTO_5x7'
45    ,MediaSize.PHOTO_5x7,MediaSize.PHOTO_5x7.label)
46  public static readonly MediaSize_INT_DL_ENVELOPE : SelectionModel = new SelectionModel('INT_DL_ENVELOPE'
47    ,MediaSize.INT_DL_ENVELOPE,MediaSize.INT_DL_ENVELOPE.label)
48  public static readonly MediaSize_B_TABLOID : SelectionModel = new SelectionModel('B_TABLOID'
49    ,MediaSize.B_TABLOID,MediaSize.B_TABLOID.label)
50  public static readonly Direction_AUTO : SelectionModel = new SelectionModel('PageDirection_AUTO'
51    ,PageDirection.AUTO,$r('app.string.PageDirection_AUTO'))
52  public static readonly Direction_LANDSCAPE : SelectionModel = new SelectionModel('PageDirection_LANDSCAPE'
53    ,PageDirection.LANDSCAPE,$r('app.string.PageDirection_LANDSCAPE'))
54  public static readonly Direction_VERTICAL : SelectionModel = new SelectionModel('PageDirection_VERTICAL'
55    ,PageDirection.VERTICAL,$r('app.string.PageDirection_VERTICAL'))
56  public static readonly MediaType_NORMAL : SelectionModel = new SelectionModel('MediaType_NORMAL'
57    ,MediaType.NORMAL,$r('app.string.MediaType_NORMAL'))
58  public static readonly MediaType_PHOTO : SelectionModel = new SelectionModel('MediaType_PHOTO'
59    ,MediaType.PHOTO,$r('app.string.MediaType_PHOTO'))
60  public static readonly PrintQuality_BEST : SelectionModel = new SelectionModel('PrintQuality_BEST'
61    ,PrintQuality.BEST,$r('app.string.PrintQuality_BEST'))
62  public static readonly PrintQuality_STANDARD : SelectionModel = new SelectionModel('PrintQuality_STANDARD'
63    ,PrintQuality.STANDARD,$r('app.string.PrintQuality_STANDARD'))
64  public static readonly PrintQuality_ECONOMY : SelectionModel = new SelectionModel('PrintQuality_ECONOMY'
65    ,PrintQuality.ECONOMY,$r('app.string.PrintQuality_ECONOMY'))
66  public static readonly DuplexMode_SINGLE : SelectionModel = new SelectionModel('DuplexMode_ONESIDE'
67    ,Duplex.SINGLE,$r('app.string.DuplexMode_ONESIDE'))
68  public static readonly DuplexMode_LONG : SelectionModel = new SelectionModel('DuplexMode_LONG'
69    ,Duplex.LONG,$r('app.string.DuplexMode_LONG'))
70  public static readonly DuplexMode_SHORT : SelectionModel = new SelectionModel('DuplexMode_SHORT'
71    ,Duplex.SHORT,$r('app.string.DuplexMode_SHORT'))
72  public static MediaSizeSelections :Array<SelectionModel> = undefined;
73
74  name: string // 选项名称
75  obj: any // 选项对象
76  res:Resource|string
77
78  constructor( name: string,obj: any,res:Resource|string) {
79    this.name = name
80    this.obj = obj
81    this.res = res
82  }
83
84  public static getSelectionModelByLabel(label : string){
85    if(SelectionModel.MediaSizeSelections === undefined){
86      this.initMediaSizeSelections()
87    }
88    let rtnSelect = undefined;
89    SelectionModel.MediaSizeSelections.forEach((selection,index,all) =>{
90      if(selection.res === label){
91        rtnSelect = selection
92      }
93    })
94    return rtnSelect
95  }
96
97  public static initMediaSizeSelections(){
98    SelectionModel.MediaSizeSelections = new Array<SelectionModel>()
99    SelectionModel.MediaSizeSelections.push(SelectionModel.MediaSize_ISO_A3);
100    SelectionModel.MediaSizeSelections.push(SelectionModel.MediaSize_ISO_A4);
101    SelectionModel.MediaSizeSelections.push(SelectionModel.MediaSize_ISO_A5);
102    SelectionModel.MediaSizeSelections.push(SelectionModel.MediaSize_ISO_C5);
103    SelectionModel.MediaSizeSelections.push(SelectionModel.MediaSize_ISO_DL);
104    SelectionModel.MediaSizeSelections.push(SelectionModel.MediaSize_JIS_B5);
105    SelectionModel.MediaSizeSelections.push(SelectionModel.MediaSize_LEGAL);
106    SelectionModel.MediaSizeSelections.push(SelectionModel.MediaSize_LETTER);
107    SelectionModel.MediaSizeSelections.push(SelectionModel.MediaSize_PHOTO_4x6);
108    SelectionModel.MediaSizeSelections.push(SelectionModel.MediaSize_PHOTO_5x7);
109    SelectionModel.MediaSizeSelections.push(SelectionModel.MediaSize_INT_DL_ENVELOPE);
110    SelectionModel.MediaSizeSelections.push(SelectionModel.MediaSize_B_TABLOID);
111  }
112}
113