spc-kiosk-pb/Kiosk/PB/SPC.Kiosk.PB.ViewModel/PBViewModel.cs
2019-06-16 14:12:09 +09:00

2854 lines
125 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.IO;
using System.ComponentModel;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.Windows;
using System.Collections.ObjectModel;
using System.Text.RegularExpressions;
using System.Windows.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
#region SPC.Kiosk
using SPC.Kiosk.Base;
using SPC.Kiosk.Common;
using SPC.Kiosk.DataHelper;
using SPC.Kiosk.PB.Model;
using SPC.Kiosk.Popup;
using SPC.Kiosk.Popup.Model;
using System.Threading;
#endregion
namespace SPC.Kiosk.PB.ViewModel
{
/// <summary>
/// PBWindow View Model
/// </summary>
public class VmPBViewModel : ViewModelBase
{
#region [ Members ]
private PopupManager popupManager = PopupManager.GetInstance;
private BackDataService backDataService;
private Queue<M_ScanData> scanQueue = new Queue<M_ScanData>();
private bool IsScanProcess = true;
private Task ScanProcess = null;
//public Dictionary<string, string> PosOptionValues;
private string optionValue810;
/// <summary>
/// 자동계산 사용여부
/// </summary>
public string OptionValue810
{
get { return optionValue810; }
set { optionValue810 = value; PropertyChange("OptionValue810"); }
}
private string optionValue811;
/// <summary>
/// 바코드계산 사용여부
/// </summary>
public string OptionValue811
{
get { return optionValue811; }
set { optionValue811 = value; PropertyChange("OptionValue811"); }
}
private string optionValue812;
/// <summary>
/// 직원호출 사용여부
/// </summary>
public string OptionValue812
{
get { return optionValue812; }
set { optionValue812 = value; PropertyChange("OptionValue812"); }
}
/// <summary>
/// 처리중 화면
/// </summary>
public WaitWindow WaitWindowFrom { get; set; }
private DispatcherTimer ToIntoroTimer;
/// <summary>
/// 입력 대기 초과시 연장 팝업 사용 유무
/// </summary>
public bool IsTimeoutPopup { get; set; } = false;
private DateTime LastAccessTime { get; set; }
/// <summary>
/// 대기 화면에서 다음 화면 연결시 옵션
/// </summary>
public string DefaultLinkValue { get; set; }
/// <summary>
/// 상품 목록 초기화 필요 유무
/// </summary>
public bool NeedIntailizeItems { get; set; }
private SupportLanguageType showLanguageType;
/// <summary>
/// 다국어 코드
/// </summary>
public SupportLanguageType ShowLanguageType
{
get { return showLanguageType; }
set { showLanguageType = value; PropertyChange("ShowLanguageType"); }
}
private PBPageType defaultPage = PBPageType.Intro;
/// <summary>
/// 현재 화면
/// </summary>
public PBPageType DefaultPage
{
get { return defaultPage; }
set { defaultPage = value; PropertyChange("DefaultPage"); }
}
private bool canWindowClose = false;
/// <summary>
/// 화면 닫기 (true 이면 바로 닫음)
/// </summary>
public bool CanWindowClose
{
get { return canWindowClose; }
set { canWindowClose = value; PropertyChange("CanWindowClose"); }
}
#region Intro & Page
private ObservableCollection<M_IntroItems> introItems;
/// <summary>
/// 대기 화면 Contents
/// </summary>
public ObservableCollection<M_IntroItems> IntroItems
{
get { return introItems; }
set { introItems = value; PropertyChange("IntroItems"); }
}
private M_HappyPointReturn happyPointReturn;
/// <summary>
/// 해피 포인트 인증 정보
/// </summary>
public M_HappyPointReturn HappyPointReturn
{
get { return happyPointReturn; }
set { happyPointReturn = value; PropertyChange("HappyPointReturn"); }
}
/// <summary>
/// Alt+F4 대한 Command
/// </summary>
public ICommand ToExecuteNothing { get; protected set; } = null;
/// <summary>
/// 대기 화면 클릭
/// </summary>
public ICommand RollMediaCommand { get; protected set; } = null;
#endregion
#region GMB
#region GMB Left
/// <summary>
/// 공통 메뉴 로고
/// </summary>
public string GmbLogo { get; set; } = ResourceManager.GetNximagePathAdd("Img_main_logo.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// 공통 메뉴 관리자 기능 클릭
/// </summary>
public ICommand ReaderCheckCommand { get; protected set; } = null;
/// <summary>
/// 로로 클릭 > 홈 화면으로 이동
/// </summary>
public ICommand GotoFirstCommand { get; protected set; } = null;
/// <summary>
/// 관리자 기능 클릭 수
/// </summary>
public int ReaderCheckClickCount { get; set; } = 0;
private bool gmbReaderCheckOpen = false;
/// <summary>
/// 관리자 기늘 오픈
/// </summary>
public bool GmbReaderCheckOpen
{
get { return gmbReaderCheckOpen; }
set { gmbReaderCheckOpen = value; PropertyChange("GmbReaderCheckOpen"); }
}
#endregion
#region GMB Center
/// <summary>
/// 공통 토글 메뉴 배경 (센싱,일반주문 전환 배경)
/// </summary>
public string GmbToggleOff { get; set; } = ResourceManager.GetNximagePathAdd("Btn_toggle_off.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// 공통 토글 메뉴 전경 (센싱,일반주문 전환 전경)
/// </summary>
public string GmbToggleOn { get; set; } = ResourceManager.GetNximagePathAdd("Btn_toggle_on.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// 자동 주문 배경
/// </summary>
public string GmbAIscannerNormal { get; set; } = ResourceManager.GetNximagePathAdd("Ic_ai_off.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// 자동 주문 Disable 배경
/// </summary>
public string GmbAIscannerDisable { get; set; } = ResourceManager.GetNximagePathAdd("Ic_ai_on.png", CommonValue.PBdesignImagesPath);
private bool gmbAIscannerEnable;
/// <summary>
/// 자동 주문 버튼 Enabled
/// </summary>
public bool GmbAIscannerEnable
{
get { return gmbAIscannerEnable; }
set { gmbAIscannerEnable = value; PropertyChange("GmbAIscannerEnable"); }
}
/// <summary>
/// 일반 주문 배경
/// </summary>
public string GmbOrderNormal { get; set; } = ResourceManager.GetNximagePathAdd("Ic_order_off.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// 일반 주문 Disable 배경
/// </summary>
public string GmbOrderDisable { get; set; } = ResourceManager.GetNximagePathAdd("Ic_order_on.png", CommonValue.PBdesignImagesPath);
private bool gmbOrderEnable;
/// <summary>
/// 일반 주문 버튼 Enabled
/// </summary>
public bool GmbOrderEnable
{
get { return gmbOrderEnable; }
set { gmbOrderEnable = value; PropertyChange("GmbOrderEnable"); }
}
/// <summary>
/// 자동 주문 Command
/// </summary>
public ICommand GmbAIscannerCommand { get; protected set; } = null;
/// <summary>
/// 일반 주문 Command
/// </summary>
public ICommand GmbOrderCommand { get; protected set; } = null;
private string gmbMemberName;
/// <summary>
/// 해피 포인트 가입 고객명
/// </summary>
public string GmbMemberName
{
get { return gmbMemberName; }
set { gmbMemberName = value; PropertyChange("GmbMemberName"); }
}
/// <summary>
/// 해피 포인트 안내 배경
/// </summary>
public string GmbHappyInfoBackGround { get; set; } = ResourceManager.GetNximagePathAdd("btn_happypoint_info.png", CommonValue.PBdesignImagesPath);
private bool gmbHappyInfoEnable = false;
/// <summary>
/// 해피 포인트 안내 Enabled
/// </summary>
public bool GmbHappyInfoEnable
{
get { return gmbHappyInfoEnable; }
set { gmbHappyInfoEnable = value; PropertyChange("GmbHappyInfoEnable"); }
}
/// <summary>
/// 해피 포인트 안내 표시 시점
/// </summary>
public DateTime GmbHappyInfoEnableTime { get; set; }
#endregion
#region GMB Right
/// <summary>
/// 해피 포인트 로그인 아이콘
/// </summary>
public string GmbHappyPointimage { get; set; } = ResourceManager.GetNximagePathAdd("btn_happypoint_d.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// 해피 포인트 로그인 Disabled 아이콘
/// </summary>
public string GmbHappyPointDisable { get; set; } = ResourceManager.GetNximagePathAdd("btn_happypoint_n.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// 직원 호출 아이콘
/// </summary>
public string GmbCallimage { get; set; } = ResourceManager.GetNximagePathAdd("btn_help.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// 로그 아웃 아이콘
/// </summary>
public string GmbHomeimage { get; set; } = ResourceManager.GetNximagePathAdd("btn_reset.png", CommonValue.PBdesignImagesPath);
private string gmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_kor.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// 다국어 변경 아이콘
/// </summary>
public string GmbLanguageimage
{
get { return gmbLanguageimage; }
set { gmbLanguageimage = value; PropertyChange("GmbLanguageimage"); }
}
private bool gmbHome = true;
/// <summary>
/// 로그 아웃 Enabled
/// </summary>
public bool GmbHome
{
get { return gmbHome; }
set { gmbHome = value; PropertyChange("GmbHome"); }
}
private bool gmbHappyPointEnable = true;
/// <summary>
/// 해피 포인트 로그인 Enabled
/// </summary>
public bool GmbHappyPointEnable
{
get { return gmbHappyPointEnable; }
set { gmbHappyPointEnable = value; PropertyChange("GmbHappyPointEnable"); }
}
private bool gmbEmpCall = true;
/// <summary>
/// 직원 호출 Enabled
/// </summary>
public bool GmbEmpCall
{
get { return gmbEmpCall; }
set { gmbEmpCall = value; PropertyChange("GmbEmpCall"); }
}
private bool gmbLanguage = true;
/// <summary>
/// 다국어 변경 Enabled
/// </summary>
public bool GmbLanguage
{
get { return gmbLanguage; }
set { gmbLanguage = value; PropertyChange("GmbLanguage"); }
}
private bool memberLoginOK = false;
/// <summary>
/// 해피 포인트 로그인 유무
/// </summary>
public bool MemberLoginOK
{
get { return memberLoginOK; }
set { memberLoginOK = value; PropertyChange("MemberLoginOK"); }
}
/// <summary>
/// 해피 포인트 로그인 Command
/// </summary>
public ICommand HappyPointCommand { get; protected set; } = null;
/// <summary>
/// 직원 호출 Command
/// </summary>
public ICommand CallEmployeeCommand { get; protected set; } = null;
/// <summary>
/// 다국어 변경 Command
/// </summary>
public ICommand LanguageCommand { get; protected set; } = null;
/// <summary>
/// 로그 아웃 Command
/// </summary>
public ICommand GotoIntroPageCommand { get; protected set; } = null;
#endregion
#endregion
#region First Page Contents
/// <summary>
/// 홈페이지 자동 주문 배경
/// </summary>
public string First2CameraBackNormal { get; set; } = ResourceManager.GetNximagePathAdd("btn_main_camerascan_n.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// 홈페이지 자동 주문 마우스 다운 배경
/// </summary>
public string First2CameraBackDown { get; set; } = ResourceManager.GetNximagePathAdd("btn_main_camerascan_f.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// 홈페이지 일반 주문 배경
/// </summary>
public string First2SelfOrderBackNormal { get; set; } = ResourceManager.GetNximagePathAdd("btn_main_selforder_n.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// 홈페이지 일반 주문 마우스 다운 배경
/// </summary>
public string First2SelfOrderBackDown { get; set; } = ResourceManager.GetNximagePathAdd("btn_main_selforder_f.png", CommonValue.PBdesignImagesPath);
#endregion
#region Items Contents
#region Category
/// <summary>
/// Category1 Background
/// </summary>
public string Category1Background { get; set; } = ResourceManager.GetNximagePathAdd("btn_main_menu_n.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// All Category Data
/// </summary>
public List<M_CategoryItems> AllCategory { get; set; }
private ObservableCollection<M_ItemData> category1Data;
/// <summary>
/// Category1 Data
/// </summary>
public ObservableCollection<M_ItemData> Category1Data
{
get { return category1Data; }
set { category1Data = value; PropertyChange("Category1Data"); }
}
private ObservableCollection<M_ItemData> category2Data;
/// <summary>
/// Category2 Data
/// </summary>
public ObservableCollection<M_ItemData> Category2Data
{
get { return category2Data; }
set { category2Data = value; PropertyChange("Category2Data"); }
}
private int defaultCategory1Item;
/// <summary>
/// Default Category1 Item
/// </summary>
public int DefaultCategory1Item
{
get { return defaultCategory1Item; }
set { defaultCategory1Item = value; PropertyChange("DefaultCategory1Item"); }
}
private int defaultCategory2Item;
/// <summary>
/// Default Category2 Item
/// </summary>
public int DefaultCategory2Item
{
get { return defaultCategory2Item; }
set { defaultCategory2Item = value; PropertyChange("DefaultCategory2Item"); }
}
private int defaultCategory1PageNo;
/// <summary>
/// Default Category1 Page No
/// </summary>
public int DefaultCategory1PageNo
{
get { return defaultCategory1PageNo; }
set { defaultCategory1PageNo = value; PropertyChange("DefaultCategory1PageNo"); }
}
private int defaultCategory2PageNo;
/// <summary>
/// Default Category2 Page No
/// </summary>
public int DefaultCategory2PageNo
{
get { return defaultCategory2PageNo; }
set { defaultCategory2PageNo = value; PropertyChange("DefaultCategory2PageNo"); }
}
/// <summary>
/// Category1 Commad
/// </summary>
public ICommand Category1Command { get; protected set; } = null;
/// <summary>
/// Category2 Commad
/// </summary>
public ICommand Category2Command { get; protected set; } = null;
/// <summary>
/// OrderHistory Command (open)
/// </summary>
public ICommand OrderHistoryCommand { get; protected set; } = null;
/// <summary>
/// OrderHistory Close Command
/// </summary>
public ICommand OrderHistoryCloseCommand { get; protected set; } = null;
#endregion
#region Items
/// <summary>
/// AllI tems
/// </summary>
public List<M_ItemData> AllItems { get; set; }
/// <summary>
/// Order(item) Column Count
/// </summary>
public int OrderColumnCount { get; set; }
/// <summary>
/// Order(item) Row Count
/// </summary>
public int OrderRowCount { get; set; }
private int defaultOrderItem;
/// <summary>
/// Default Order Item
/// </summary>
public int DefaultOrderItem
{
get { return defaultOrderItem; }
set { defaultOrderItem = value; PropertyChange("DefaultOrderItem"); }
}
private int orderItemPageNo;
/// <summary>
/// Default Order Item Page No
/// </summary>
public int OrderItemPageNo
{
get { return orderItemPageNo; }
set { orderItemPageNo = value; PropertyChange("OrderItemPageNo"); }
}
private ObservableCollection<M_ItemData> orderItems;
/// <summary>
/// Order Items Data
/// </summary>
public ObservableCollection<M_ItemData> OrderItems
{
get { return orderItems; }
set { orderItems = value; PropertyChange("OrderItems"); }
}
/// <summary>
/// Item Command
/// </summary>
public ICommand ItemCommand { get; protected set; } = null;
/// <summary>
/// Page to Left Normal Image
/// </summary>
public string Page2LeftNormalImage { get; set; } = ResourceManager.GetNximagePathAdd("btn_page_before_n.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Page to Right Normal Image
/// </summary>
public string Page2RightNormalImage { get; set; } = ResourceManager.GetNximagePathAdd("btn_page_after_n.png", CommonValue.PBdesignImagesPath);
private bool page2LeftEnable;
/// <summary>
/// Page to Left Enabled
/// </summary>
public bool Page2LeftEnable
{
get { return page2LeftEnable; }
set { page2LeftEnable = value; PropertyChange("Page2LeftEnable"); }
}
private bool page2RightEnable;
/// <summary>
/// Page to Right Enabled
/// </summary>
public bool Page2RightEnable
{
get { return page2RightEnable; }
set { page2RightEnable = value; PropertyChange("Page2RightEnable"); }
}
/// <summary>
/// Page to Left Command
/// </summary>
public ICommand Page2LeftCommand { get; protected set; } = null;
/// <summary>
/// Page to Right Command
/// </summary>
public ICommand Page2RightCommand { get; protected set; } = null;
private ObservableCollection<M_ItemData> itemPageStatus;
/// <summary>
/// Item Page Status
/// </summary>
public ObservableCollection<M_ItemData> ItemPageStatus
{
get { return itemPageStatus; }
set { itemPageStatus = value; PropertyChange("ItemPageStatus"); }
}
private int pageStatusColumnCount;
/// <summary>
/// Page Status Column Count
/// </summary>
public int PageStatusColumnCount
{
get { return pageStatusColumnCount; }
set { pageStatusColumnCount = value; PropertyChange("PageStatusColumnCount"); }
}
/// <summary>
/// Page Select Command
/// </summary>
public ICommand PageSelectCommand { get; protected set; } = null;
#endregion
#region Order History
/// <summary>
/// Order History Normal Brush
/// </summary>
public string OrderHistoryNormalBrush { get; set; } = ResourceManager.GetNximagePathAdd("Ic_mylist_d.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Order History Disable Brush
/// </summary>
public string OrderHistoryDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("Ic_mylist_n.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Order History Close NormalB rush
/// </summary>
public string CloseOrderHistoryNormalBrush { get; set; } = ResourceManager.GetNximagePathAdd("Ic_mylist_s.png", CommonValue.PBdesignImagesPath);
private bool orderHistoryView = false;
/// <summary>
/// Is Order History View
/// </summary>
public bool OrderHistoryView
{
get { return orderHistoryView; }
set { orderHistoryView = value; PropertyChange("OrderHistoryView"); }
}
private List<string> findOrderHistoryItems;
/// <summary>
/// Find Order History Items
/// </summary>
public List<string> FindOrderHistoryItems
{
get { return findOrderHistoryItems; }
set { findOrderHistoryItems = value; PropertyChange("FindOrderHistoryItems"); }
}
private ObservableCollection<M_ItemData> orderHistoryItems;
/// <summary>
/// Order History Items
/// </summary>
public ObservableCollection<M_ItemData> OrderHistoryItems
{
get { return orderHistoryItems; }
set { orderHistoryItems = value; PropertyChange("OrderHistoryItems"); }
}
private bool orderHistoryItemsEnable;
/// <summary>
/// Order History Items Enable
/// </summary>
public bool OrderHistoryItemsEnable
{
get { return orderHistoryItemsEnable; }
set { orderHistoryItemsEnable = value; PropertyChange("OrderHistoryItemsEnable"); }
}
#endregion
#endregion Contents
#region Scan Contents
/// <summary>
/// Scan Info GIF
/// </summary>
public string ScanInfoGIF { get; set; } = ResourceManager.GetNximagePathAdd("img_gif_barcodescan.gif", CommonValue.PBdesignImagesPath);
/// <summary>
/// Scan Header Bar
/// </summary>
public string ScanHeaderBar { get; set; } = ResourceManager.GetNximagePathAdd("Bl_bar.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Scan Payment1 Normal
/// </summary>
public string ScanPayment1Normal { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_payment_n.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Scan Payment1 Down
/// </summary>
public string ScanPayment1Down { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_payment_f.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Add Scan1 Normal
/// </summary>
public string AddScan1Normal { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_camerascan_n.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Add Scan1 Down
/// </summary>
public string AddScan1Down { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_camerascan_f.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Scan Order1 Normal
/// </summary>
public string ScanOrder1Normal { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_selforder_n.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Scan Order1 Down
/// </summary>
public string ScanOrder1Down { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_selforder_f.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Scan Button Small Normal
/// </summary>
public string ScanButtonSmallNormal { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_n.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Scan Button Small Down
/// </summary>
public string ScanButtonSmallDown { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_f.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Scan Button Large Normal
/// </summary>
public string ScanButtonLargeNormal { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder2_n.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Scan Button Large Down
/// </summary>
public string ScanButtonLargeDown { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder2_f.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Scan Button Normal
/// </summary>
public string ScanButtonNormal { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder3_n.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Scan Button Down
/// </summary>
public string ScanButtonDown { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder3_f.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Info Logo
/// </summary>
public string InfoLogo { get; set; } = ResourceManager.GetNximagePathAdd("ic_info.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Info LogoX
/// </summary>
public string InfoLogoX { get; set; } = ResourceManager.GetNximagePathAdd("btn_help.png", CommonValue.PBdesignImagesPath);
private PBSensingSubPageType sensingSubPage = PBSensingSubPageType.SensingPage;
/// <summary>
/// PB Sensing SubPage Type
/// </summary>
public PBSensingSubPageType SensingSubPage
{
get { return sensingSubPage; }
set { sensingSubPage = value; PropertyChange("SensingSubPage"); }
}
private string readBarCode;
/// <summary>
/// Read Barcode
/// </summary>
public string ReadBarCode
{
get { return readBarCode; }
set { readBarCode = value; PropertyChange("ReadBarCode"); }
}
private int aIScanCount;
/// <summary>
/// AI Scan Count
/// </summary>
public int AIScanCount
{
get { return aIScanCount; }
set { aIScanCount = value; PropertyChange("AIScanCount"); }
}
/// <summary>
/// Rescan Commad
/// </summary>
public ICommand RescanCommand { get; protected set; } = null;
/// <summary>
/// Goto Barcode Commad
/// </summary>
public ICommand GotoBarcodeCommand { get; protected set; } = null;
#endregion
#region MiniBasket
/// <summary>
/// MiniBasket Delete All Image
/// </summary>
public string MiniBasketDeleteAllImage { get; set; } = ResourceManager.GetNximagePathAdd("btn_delete.png", CommonValue.PBdesignImagesPath);
private bool miniBasketDeleteAllEnable;
/// <summary>
/// MiniBasket Delete All Enabled
/// </summary>
public bool MiniBasketDeleteAllEnable
{
get { return miniBasketDeleteAllEnable; }
set { miniBasketDeleteAllEnable = value; PropertyChange("MiniBasketDeleteAllEnable"); }
}
/// <summary>
/// Empty Basket Image
/// </summary>
public string EmptyBasketImage { get; set; } = ResourceManager.GetNximagePathAdd("Ic_Basket.png", CommonValue.PBdesignImagesPath);
/// <summary>
/// Empty Basket DropCommand
/// </summary>
public ICommand EmptyBasketDropCommand { get; protected set; } = null;
/// <summary>
/// MiniBasket Delete All Command
/// </summary>
public ICommand MiniBasketDeleteAllCommand { get; protected set; } = null;
private Visibility orderNoneDataGridVisibility = Visibility.Visible;
/// <summary>
/// Order None Data Grid Visibility
/// </summary>
public Visibility OrderNoneDataGridVisibility
{
get { return orderNoneDataGridVisibility; }
set { orderNoneDataGridVisibility = value; PropertyChange("OrderNoneDataGridVisibility"); }
}
private Visibility orderExistDataGridVisibility = Visibility.Hidden;
/// <summary>
/// Order Exist Data Grid Visibility
/// </summary>
public Visibility OrderExistDataGridVisibility
{
get { return orderExistDataGridVisibility; }
set { orderExistDataGridVisibility = value; PropertyChange("OrderExistDataGridVisibility"); }
}
#region BasketItems
private ObservableCollection<M_BasketItem> miniBasketData;
/// <summary>
/// Mini Basket Data
/// </summary>
public ObservableCollection<M_BasketItem> MiniBasketData
{
get { return miniBasketData; }
set { miniBasketData = value; PropertyChange("MiniBasketData"); }
}
/// <summary>
/// Basket Item Delete Command
/// </summary>
public ICommand BasketItemDeleteCommand { get; protected set; } = null;
#endregion
#region Total
/// <summary>
/// Order Total Payment Icon
/// </summary>
public string OrderTotalPaymentIcon { get; set; } = ResourceManager.GetNximagePathAdd("Ic_totalcost.png", CommonValue.PBdesignImagesPath);
private int orderTotalCount = 0;
/// <summary>
/// Order Total Count
/// </summary>
public int OrderTotalCount
{
get { return orderTotalCount; }
set { orderTotalCount = value; PropertyChange("OrderTotalCount"); }
}
private double orderTotalPayment = 0d;
/// <summary>
/// Order Total Payment
/// </summary>
public double OrderTotalPayment
{
get { return orderTotalPayment; }
set { orderTotalPayment = value; PropertyChange("OrderTotalPayment"); }
}
#endregion
#region Button
private bool orderDetailEnable;
/// <summary>
/// Order Detail Enabled
/// </summary>
public bool OrderDetailEnable
{
get { return orderDetailEnable; }
set { orderDetailEnable = value; PropertyChange("OrderDetailEnable"); }
}
/// <summary>
/// Order Detail Command
/// </summary>
public ICommand OrderDetailCommand { get; protected set; } = null;
private bool gotoPaymentEnable;
/// <summary>
/// Goto Payment Enabled
/// </summary>
public bool GotoPaymentEnable
{
get { return gotoPaymentEnable; }
set { gotoPaymentEnable = value; PropertyChange("GotoPaymentEnable"); }
}
/// <summary>
/// Goto Payment Command
/// </summary>
public ICommand GotoPaymentCommand { get; protected set; } = null;
private PBPaymentPageType openPBPaymentPage = PBPaymentPageType.DetailBasket;
/// <summary>
/// Open PB Payment Page
/// </summary>
public PBPaymentPageType OpenPBPaymentPage
{
get { return openPBPaymentPage; }
set { openPBPaymentPage = value; PropertyChange("OpenPBPaymentPage"); }
}
#endregion
#endregion MiniBasket
#endregion Members
#region [ Ctor ]
/// <summary>
/// Ctor
/// </summary>
public VmPBViewModel()
{
WaitWindowFrom = WaitWindow.GetInstance;
InitViewModel();
LastAccessTime = DateTime.Now;
ToIntoroTimer = new DispatcherTimer
{
Interval = TimeSpan.FromSeconds(1d),
};
ToIntoroTimer.Tick += ToIntoroTimer_Tick;
backDataService = new BackDataService();
}
/// <summary>
/// Dispose
/// </summary>
public void Dispose()
{
if (ScanProcess != null)
{
IsScanProcess = false;
ScanProcess.Wait();
ScanProcess = null;
}
if (backDataService != null)
{
backDataService.Dispose();
backDataService = null;
}
this.PropertyChanged -= VmPBViewModel_PropertyChanged;
if (WaitWindowFrom != null)
{
WaitWindowFrom.CloseWaitWindow();
WaitWindowFrom = null;
}
if (ToIntoroTimer != null)
{
ToIntoroTimer.Stop();
ToIntoroTimer.Tick -= ToIntoroTimer_Tick;
ToIntoroTimer = null;
}
if (popupManager != null)
{
popupManager = null;
}
GC.SuppressFinalize(this);
}
#endregion Ctor
#region [ Methods ]
private void InitViewModel()
{
WaitWindowFrom.ShowWaitWindow();
try
{
//Intro
SetCommon();
SetIntro();
ToExecuteNothing = new Command(ToExecuteNothingHandler);
RollMediaCommand = new Command(RollMediaCommandHandler);
//GMB Left
GotoFirstCommand = new Command(GotoFirstCommandHandler);
ReaderCheckCommand = new Command(ReaderCheckCommandHandler);
//GMB Right
LanguageCommand = new Command(LanguageCommandHandler);
HappyPointCommand = new Command(HappyPointCommandHandler);
CallEmployeeCommand = new Command(CallEmployeeCommandHandler);
GotoIntroPageCommand = new Command(GotoIntroPageCommadHandler);
//GMB Center
GmbAIscannerCommand = new Command(GmbAIscannerCommandHandler);
GmbOrderCommand = new Command(GmbOrderCommandHandler);
GmbAIscannerEnable = false;
//Scan Contents
RescanCommand = new Command(RescanCommandHandler);
GotoBarcodeCommand = new Command(GotoBarcodeCommandHandler);
//Item Contents
ItemCommand = new Command(ItemCommandCommandHandler);
Category1Command = new Command(Category1CommandHandler);
Category2Command = new Command(Category2CommandHandler);
OrderHistoryCommand = new Command(OrderHistoryCommandHandler);
OrderHistoryCloseCommand = new Command(OrderHistoryCloseCommandHandler);
Page2LeftCommand = new Command(Page2LeftCommandHandler);
Page2RightCommand = new Command(Page2RightCommandHandler);
OrderColumnCount = 5;
OrderRowCount = 2;
PageSelectCommand = new Command(PageSelectCommandHandler);
//MiniBasket
MiniBasketDeleteAllCommand = new Command(MiniBasketDeleteAllCommandHandler);
EmptyBasketDropCommand = new Command(EmptyBasketDropCommandHandler);
BasketItemDeleteCommand = new Command(BasketItemDeleteCommandHandler);
OrderDetailCommand = new Command(OrderDetailCommandHandler);
GotoPaymentCommand = new Command(GotoPaymentCommandHandler);
this.PropertyChanged += VmPBViewModel_PropertyChanged;
ShowLanguageType = CommonValue.CommonLanguageType;
ScanProcess = new Task(ScanDataProcessor);
ScanProcess.Start();
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "InitViewModel()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
finally
{
WaitWindowFrom.CloseWaitWindow();
}
}
private void SetCommon()
{
#if TESTMODE
using (var dataHelper = new CommonDataHelper())
{
if (!dataHelper.NeedInitModule) dataHelper.SetCommonLanguage();
}
#endif
//PosOption 값 획득
using (var backDataService = new BackDataService())
{
this.OptionValue810 = backDataService.GetPosOption(nameof(PosOptionType.OPT810));
this.OptionValue811 = backDataService.GetPosOption(nameof(PosOptionType.OPT811));
this.OptionValue812 = backDataService.GetPosOption(nameof(PosOptionType.OPT812));
//if (this.PosOptionValues == null) this.PosOptionValues = new Dictionary<string, string>();
//if (!this.PosOptionValues.ContainsKey(nameof(PosOptionType.OPT810))) { this.PosOptionValues.Add(nameof(PosOptionType.OPT810), this.optionValue810); }
//if (!this.PosOptionValues.ContainsKey(nameof(PosOptionType.OPT811))) { this.PosOptionValues.Add(nameof(PosOptionType.OPT811), this.optionValue811); }
}
}
#region Intro
private void SetIntro()
{
using (var dataHelper = new CommonDataHelper())
{
var getIntro = dataHelper.GetIntroData(1920d);
if (getIntro is List<M_IntroItems> && getIntro.Count > 0)
{
IntroItems = new ObservableCollection<M_IntroItems>(getIntro);
}
else
{
#region Default Intro
IntroItems = new ObservableCollection<M_IntroItems>
{
new M_IntroItems
{
ItemsStack=0,
StackWidth=1920,
StackContents = new List<M_StackContents>
{
new M_StackContents
{
ItemsIndex = 0,
MediaRollItems = new List<M_MediaRollItem>
{
new M_MediaRollItem
{
Type = MediaType.Image,
MediaPath =ResourceManager.GetNximagePathAdd("nextstation_img.jpg", CommonValue.PBdesignImagesPath),
LinkType = IntroLinkType.Page,
LinkParameter = "FirstSelect",
RunnigSeconds =10
},
}
},
new M_StackContents
{
ItemsIndex = 1,
MediaRollItems = new List<M_MediaRollItem>
{
new M_MediaRollItem{
Type = MediaType.Image,
MediaPath = ResourceManager.GetNximagePathAdd("nextstation_button.jpg", CommonValue.PBdesignImagesPath),
LinkType = IntroLinkType.Page,
LinkParameter = "ItemPage",
RunnigSeconds =10
},
}
}
}
},
};
#endregion
}
}
}
#endregion Intro
#region Contents
#region Self Order
private void SetContents()
{
if (!string.IsNullOrEmpty(DefaultLinkValue))
{
if (DefaultLinkValue.ToLower().StartsWith("category&"))
{
DataModelInit();
var getCategory = DefaultLinkValue.Split('&');
switch (getCategory.Length)
{
case 2:
DefaultCategory1Item = Category1Data.IndexOf(Category1Data.Where(r => r.Category1.Equals(getCategory[1])).FirstOrDefault());
if (DefaultCategory1Item < 0) DefaultCategory1Item = 0;
DefaultCategory2Item = 0;
break;
case 3:
DefaultCategory1Item = Category1Data.IndexOf(Category1Data.Where(r => r.Category1.Equals(getCategory[1])).FirstOrDefault());
if (DefaultCategory1Item < 0) DefaultCategory1Item = 0;
if (!string.IsNullOrEmpty(getCategory[2]))
{
DefaultCategory2Item = Category2Data.IndexOf(Category2Data.Where(r => r.Category2.Equals(getCategory[2])).FirstOrDefault());
if (DefaultCategory2Item < 0) DefaultCategory2Item = 0;
}
else
{
DefaultCategory2Item = 0;
}
break;
default:
DefaultCategory1Item = 0;
DefaultCategory2Item = 0;
break;
}
DefaultOrderItem = 0;
}
else
{
DataModelInit();
var findItem = AllItems.Where(r => r.ItemCode.Equals(DefaultLinkValue)).FirstOrDefault();
if (findItem is M_ItemData)
{
DefaultCategory1Item = Category1Data.IndexOf(Category1Data.Where(r => r.Category1.Equals(findItem.Category1)).FirstOrDefault());
DefaultCategory2Item = Category2Data.IndexOf(Category2Data.Where(r => r.Category2.Equals(findItem.Category2)).FirstOrDefault());
DefaultOrderItem = OrderItems.IndexOf(OrderItems.Where(r => r.ItemCode.Equals(DefaultLinkValue)).FirstOrDefault());
}
else
{
DefaultCategory1Item = 0;
DefaultCategory2Item = 0;
DefaultOrderItem = 0;
}
}
}
else
{
DataModelInit();
DefaultCategory1Item = 0;
DefaultCategory2Item = 0;
DefaultOrderItem = 0;
}
}
private void DataModelInit()
{
try
{
if (NeedIntailizeItems)
{
ItemCacheClear();
this.SetItemData();
SetCategory1();
NeedIntailizeItems = false;
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "DataModelInit()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
}
private void ItemCacheClear()
{
if (AllItems is List<M_ItemData>)
{
foreach (var aitem in AllItems)
{
if (aitem.DataParameter.NormalBrush != null)
{
CacheManager.CacheRemove(aitem.DataParameter.NormalBrush);
}
if (aitem.DataParameter.SwitchOnBrush != null)
{
CacheManager.CacheRemove(aitem.DataParameter.SwitchOnBrush);
}
if (aitem.DataParameter.DisableBrush != null)
{
CacheManager.CacheRemove(aitem.DataParameter.DisableBrush);
}
if (aitem.DataParameter.DownBrush != null)
{
CacheManager.CacheRemove(aitem.DataParameter.DownBrush);
}
if (aitem.DataParameter.DragCursorImage != null)
{
CacheManager.CacheRemove(aitem.DataParameter.DragCursorImage);
}
}
}
}
private void SetItemData()
{
try
{
#region Item Data From DB
using (var dataHelper = new CommonDataHelper())
{
//Categoty Data
AllCategory = dataHelper.GetCategoryData();
if (AllCategory is List<M_CategoryItems>)
{
//Category Design Parameter Add
foreach (var category1Item in AllCategory)
{
//Category1 Design Parameter
category1Item.Catalog1Item.DataParameter = new M_AnimationButton
{
NormalBrush = ResourceManager.GetNximagePathAdd("btn_main_menu_n.png", CommonValue.PBdesignImagesPath),
SwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_main_menu_p.png", CommonValue.PBdesignImagesPath),
Width = 150,
Height = 160,
BrushStretch = Stretch.Fill,
ClickAnimationType = ButtonAnimationType.TextSizeDown,
CircleBackBrush = "Transparent",
CircleTextBruch = "Transparent",
CircleText = string.Empty,
TextVisible = Visibility.Visible,
TextFontSize = 28,
SwitchOnFontSize = 30,
TextForeground = "#adadad",
TextWrapping = TextWrapping.Wrap,
SwitchOnForeground = "White",
TextFontFamily = "NanumSquare",
TextFontWeight = FontWeights.Normal,
SwitchOnFontWeight = FontWeights.Bold,
TextAlignment = TextAlignment.Right,
TextHorizontalAlignment = HorizontalAlignment.Right,
TextVerticalAlignment = VerticalAlignment.Top,
TextMargin = new Thickness(5, 21, 20, 21),
LanguageText = dataHelper.GetLaguageData("CATE", category1Item.Catalog1Item.Category1)
};
foreach (var category2Item in category1Item.Catalog2Items)
{
//Category2 Design Parameter
category2Item.DataParameter = new M_AnimationButton
{
NormalBrush = "Transparent",
SwitchOnBrush = "Transparent",
Width = 194,
Height = 86,
BrushStretch = Stretch.Fill,
ClickAnimationType = ButtonAnimationType.TextBounceDown,
CircleBackBrush = "Transparent",
CircleTextBruch = "Transparent",
CircleText = string.Empty,
TextVisible = Visibility.Visible,
TextFontSize = 24,
SwitchOnFontSize = 24,
TextForeground = "Black",
SwitchOnForeground = "#1469cc",
TextFontFamily = "NanumSquare",
TextFontWeight = FontWeights.Normal,
SwitchOnFontWeight = FontWeights.Bold,
TextAlignment = TextAlignment.Center,
TextMargin = new Thickness(0, 0, 18, 0),
TextWrapping = TextWrapping.Wrap,
TextHorizontalAlignment = HorizontalAlignment.Center,
TextVerticalAlignment = VerticalAlignment.Center,
LanguageText = dataHelper.GetLaguageData("CATE", category2Item.Category2)
};
};
}
}
//Item Master
AllItems = dataHelper.GetItemsData();
if (AllItems is List<M_ItemData> && AllItems.Count > 0)
{
//Item Design Parameter Add
foreach (var aItem in AllItems)
{
aItem.BadgeHeight = 30;
aItem.BadgeOrientation = Orientation.Horizontal;
if (aItem.BadgeImages is List<string> && aItem.BadgeImages.Count > 0)
{
var newBadgeImages = new List<string>();
foreach (var aBadgeImage in aItem.BadgeImages)
{
var strBadgeImage = ResourceManager.GetNximagePathAdd(aBadgeImage, CommonValue.PBdesignImagesPath);
if (!string.IsNullOrEmpty(strBadgeImage))
{
newBadgeImages.Add(strBadgeImage);
}
}
aItem.BadgeImages = newBadgeImages;
}
if (aItem.Option is List<M_ItemOptionGroup> && aItem.Option.Count > 0)
{
foreach (var aOptionGRP in aItem.Option)
{
if (aOptionGRP is M_ItemOptionGroup)
{
aOptionGRP.ImageFile = aOptionGRP.Index.Equals(0)
? "ic_option_takein.png"
: aOptionGRP.Index.Equals(1)
? "ic_option_shot.png"
: "ic_option_candle.png";
}
}
}
var itemImage = ResourceManager.GetItemImage(aItem.ImageFile, CommonValue.ItemDefaultImage);//파일 없을 경우 DefaultImage로
aItem.DataParameter = new M_AnimationButton
{
NormalBrush = itemImage,
DragCursorImage = itemImage,
DisableBrush = ResourceManager.GetNximagePathAdd("img_contents_soldout.png", CommonValue.PBdesignImagesPath),
Width = 100,
Height = 100,
Margin = new Thickness(80, 30, 80, 40),
BrushStretch = Stretch.Fill,
DragCursorHotSpot = HotSpotType.Center,
ClickAnimationType = ButtonAnimationType.SizeDown,
CircleBackBrush = "Transparent",
CircleTextBruch = "Transparent",
Enabled = !aItem.IsSoldOut,
CircleText = string.Empty,
};
aItem.BaseTextBlock = new M_TextBlock()
{
LanguageData = dataHelper.GetLaguageData("PROD", aItem.ItemCode),
TextSize = 24,
Width = 250,
Height = 82,
TextBrush = "Black",
TextFontFamily = "NanumSquare",
TextVerticalAlignment = VerticalAlignment.Center,
TextMargin = new Thickness(5, 0, 5, 0),
TextWeight = FontWeights.Bold,
TextWrapping = TextWrapping.Wrap
};
aItem.AdditionTextBlock = new M_TextBlock()
{
LanguageData = new List<M_Language>
{
new M_Language{ Type = SupportLanguageType.ko, LanguageData = string.Format("₩{0:#,##0}", aItem.Price)},
},
TextSize = 26,
Width = 250,
Height = 40,
TextBrush = "#1469cc",
TextFontFamily = "NanumSquare",
TextVerticalAlignment = VerticalAlignment.Top,
TextMargin = new Thickness(5, 0, 5, 0),
TextWeight = FontWeights.Bold,
};
}
}
else
{
#if TESTMODE
#region Test Item
AllItems = new List<M_ItemData>();
AllCategory = new List<M_CategoryItems>();
var itemFiles = ResourceManager.GetItemImages("*.png");
int index = 0;
foreach (var aItemFles in itemFiles)
{
var aFile = new FileInfo(aItemFles);
if (Regex.IsMatch(aFile.Name.Replace(aFile.Extension, ""), "^[0-9]") && !aFile.Name.Contains("_FULL"))
{
var category1Code = aFile.Name.Substring(0, 1);
var category2Code = aFile.Name.Substring(1, 2);
var testPrice = 2000d;
int intCategory1Code = int.Parse(category1Code);
if (intCategory1Code < 4)
{
//Add ItemData
AllItems.Add(new M_ItemData()
{
Index = index,
ItemCode = aFile.Name.Replace(aFile.Extension, ""),
Category1 = category1Code,
Category2 = category2Code,
Price = testPrice,
BadgeHeight = 30,
BadgeOrientation = Orientation.Horizontal,
BadgeImages = index.Equals(0)
? new List<string>
{
ResourceManager.GetNximagePathAdd("Img_best.png", CommonValue.PBdesignImagesPath),
ResourceManager.GetNximagePathAdd("Img_new.png", CommonValue.PBdesignImagesPath),
ResourceManager.GetNximagePathAdd("img_like.png", CommonValue.PBdesignImagesPath),
ResourceManager.GetNximagePathAdd("img_event.png", CommonValue.PBdesignImagesPath)
}
: index.Equals(1)
? new List<string>
{
ResourceManager.GetNximagePathAdd("Img_best.png", CommonValue.PBdesignImagesPath),
ResourceManager.GetNximagePathAdd("Img_new.png", CommonValue.PBdesignImagesPath),
}
: index.Equals(2)
? new List<string>
{
ResourceManager.GetNximagePathAdd("img_like.png", CommonValue.PBdesignImagesPath),
ResourceManager.GetNximagePathAdd("img_event.png", CommonValue.PBdesignImagesPath),
}
: index.Equals(3)
? new List<string>
{
ResourceManager.GetNximagePathAdd("Img_best.png", CommonValue.PBdesignImagesPath),
}
: null,
DataParameter = new M_AnimationButton
{
NormalBrush = aItemFles,
DragCursorImage = aItemFles,
DisableBrush = ResourceManager.GetNximagePathAdd("img_contents_soldout.png", CommonValue.PBdesignImagesPath),
Width = 100,
Height = 100,
Margin = new Thickness(80, 30, 80, 40),
BrushStretch = Stretch.Fill,
DragCursorHotSpot = HotSpotType.Center,
ClickAnimationType = ButtonAnimationType.SizeDown,
CircleBackBrush = "Transparent",
CircleTextBruch = "Transparent",
Enabled = !index.Equals(7),
CircleText = string.Empty,
},
BaseTextBlock = new M_TextBlock()
{
LanguageData = index.Equals(0)
? new List<M_Language>
{
new M_Language{ Type = SupportLanguageType.en, LanguageData = "en아메리카노"},
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "아메리카노"}
}
: index.Equals(1)
? new List<M_Language>
{
new M_Language{ Type = SupportLanguageType.en, LanguageData = "3mm 황금비율로 바삭하고 en고소한 전병세트"},
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "3mm 황금비율로 바삭하고 고소한 전병세트"}
}
: index.Equals(2)
? new List<M_Language>
{
new M_Language{ Type = SupportLanguageType.en, LanguageData = "en카푸치노"},
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "카푸치노"}
}
: index.Equals(3)
? new List<M_Language>
{
new M_Language{ Type = SupportLanguageType.en, LanguageData = "en바닐라라떼"},
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "바닐라라떼"}
}
: new List<M_Language>
{
new M_Language{ Type = SupportLanguageType.en, LanguageData = aFile.Name.Replace(aFile.Extension, "")},
new M_Language{ Type = SupportLanguageType.ko, LanguageData = aFile.Name.Replace(aFile.Extension, "")}
},
TextSize = 24,
Width = 250,
Height = 82,
TextBrush = "Black",
TextFontFamily = "NanumSquare",
TextVerticalAlignment = VerticalAlignment.Center,
TextMargin = new Thickness(5, 0, 5, 0),
TextWeight = FontWeights.Bold,
TextWrapping = TextWrapping.Wrap
},
AdditionTextBlock = new M_TextBlock()
{
LanguageData = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.ko, LanguageData = string.Format("₩{0:#,##0}", testPrice)},
},
TextSize = 26,
Width = 250,
Height = 40,
TextBrush = "#1469cc",
TextFontFamily = "NanumSquare",
TextVerticalAlignment = VerticalAlignment.Top,
TextMargin = new Thickness(5, 0, 5, 0),
TextWeight = FontWeights.Bold,
},
});
//Add CategoryData
if (!CheckExistCategory1(category1Code))
{
var mItemData = new M_ItemData
{
Index = -1,
ItemCode = category1Code,
Category1 = category1Code,
DataParameter = new M_AnimationButton
{
NormalBrush = ResourceManager.GetNximagePathAdd("btn_main_menu_n.png", CommonValue.PBdesignImagesPath),
SwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_main_menu_p.png", CommonValue.PBdesignImagesPath),
Width = 150,
Height = 160,
BrushStretch = Stretch.Fill,
ClickAnimationType = ButtonAnimationType.TextSizeDown,
CircleBackBrush = "Transparent",
CircleTextBruch = "Transparent",
CircleText = string.Empty,
TextVisible = Visibility.Visible,
TextFontSize = 27,
SwitchOnFontSize = 40,
TextForeground = "#adadad",
TextWrapping = TextWrapping.Wrap,
SwitchOnForeground = "White",
TextFontFamily = "NanumSquare",
TextFontWeight = FontWeights.Normal,
SwitchOnFontWeight = FontWeights.Bold,
TextAlignment = TextAlignment.Right,
TextHorizontalAlignment = HorizontalAlignment.Right,
TextVerticalAlignment = VerticalAlignment.Top,
TextMargin = new Thickness(10, 21, 27, 21),
LanguageText = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.en, LanguageData = category1Code+"en" },
new M_Language{ Type = SupportLanguageType.ko, LanguageData = category1Code+"ko" }
},
}
};
switch (category1Code)
{
case "0":
mItemData.DataParameter.LanguageText = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.en, LanguageData = "Coffee" },
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "커피" }
};
break;
case "1":
mItemData.DataParameter.LanguageText = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.en, LanguageData = "Beverage" },
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "음료" }
};
break;
case "2":
mItemData.DataParameter.LanguageText = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.en, LanguageData = "Sherbet" },
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "빙수" }
};
break;
case "3":
mItemData.DataParameter.LanguageText = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.en, LanguageData = "Cake" },
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "케이크" }
};
break;
}
AddCategory1(category1Code, mItemData);
}
if (!CheckExistCategory2(category1Code, category2Code))
{
var mItemData = new M_ItemData
{
Index = -1,
ItemCode = category2Code,
Category1 = category1Code,
Category2 = category2Code,
DataParameter = new M_AnimationButton
{
NormalBrush = "Transparent",
SwitchOnBrush = "Transparent",
//SwitchOnBrush = ResourceManager.GetNximagePathAdd("line_main_tab.png", CommonValue.PBdesignImagesPath),
Width = 194,
Height = 86,
BrushStretch = Stretch.Fill,
ClickAnimationType = ButtonAnimationType.TextBounceDown,
CircleBackBrush = "Transparent",
CircleTextBruch = "Transparent",
CircleText = string.Empty,
TextVisible = Visibility.Visible,
TextFontSize = 24,
SwitchOnFontSize = 28,
TextForeground = "Black",
SwitchOnForeground = "#1469cc",
TextFontFamily = "NanumSquare",
TextFontWeight = FontWeights.Normal,
SwitchOnFontWeight = FontWeights.Bold,
TextAlignment = TextAlignment.Center,
TextMargin = new Thickness(0, 0, 18, 0),
TextWrapping = TextWrapping.Wrap,
TextHorizontalAlignment = HorizontalAlignment.Center,
TextVerticalAlignment = VerticalAlignment.Center,
LanguageText = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.en, LanguageData = category2Code+"en" },
new M_Language{ Type = SupportLanguageType.ko, LanguageData = category2Code+"ko" }
},
}
};
if (category1Code.Equals("0"))
{
switch (category2Code)
{
case "01":
mItemData.DataParameter.LanguageText = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.en, LanguageData = "Cafe Adagio" },
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "카페 아다지오" }
};
break;
case "10":
mItemData.DataParameter.LanguageText = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.en, LanguageData = "Latte&Tea" },
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "라떼&티" }
};
break;
case "50":
mItemData.DataParameter.LanguageText = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.en, LanguageData = "Juice&Ade" },
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "주스&에이드" }
};
break;
case "51":
mItemData.DataParameter.LanguageText = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.en, LanguageData = "Smoothies" },
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "스무디" }
};
break;
case "52":
mItemData.DataParameter.LanguageText = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.en, LanguageData = "Sherbet" },
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "빙수" }
};
break;
case "71":
mItemData.DataParameter.LanguageText = new List<M_Language> {
new M_Language{ Type = SupportLanguageType.en, LanguageData = "Product Beverage" },
new M_Language{ Type = SupportLanguageType.ko, LanguageData = "완제음료" }
};
break;
}
}
AddCategory2(category1Code, category2Code, mItemData);
}
index++;
}
}
}
#endregion
#endif
}
}
#endregion
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "SetOrderHistoryItems()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
}
private void SetOrderHistoryItems()
{
try
{
if (FindOrderHistoryItems is List<string>
&& FindOrderHistoryItems.Count > 0
&& AllItems is List<M_ItemData>
&& AllItems.Count > 0)
{
var newOrderHistoryItems = new List<M_ItemData>();
foreach (var aHistoryItem in FindOrderHistoryItems)
{
var findItem = AllItems.Find(r => r.ItemCode.Equals(aHistoryItem));
if (findItem is M_ItemData) newOrderHistoryItems.Add(findItem);
}
if (newOrderHistoryItems.Count > 0)
{
OrderHistoryItems = new ObservableCollection<M_ItemData>(newOrderHistoryItems);
}
else
{
OrderHistoryItems = null;
}
}
else
{
OrderHistoryItems = null;
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "SetOrderHistoryItems()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
}
private void SetCategory1(int _index = 0)
{
if (AllCategory != null)
{
if (NeedIntailizeItems) Category1Data = new ObservableCollection<M_ItemData>((from aRow in AllCategory
select aRow.Catalog1Item).ToList());
DefaultCategory1Item = _index < 0 ? 0 : _index;
}
}
private void SetCategory2(int _index = 0)
{
if (Category1Data != null)
{
var catalog2Items = AllCategory[DefaultCategory1Item].Catalog2Items;
Category2Data = new ObservableCollection<M_ItemData>(catalog2Items);
DefaultCategory2Item = _index < 0 ? 0 : _index;
}
}
private void SetItemList(int _index = 0)
{
if (AllItems != null)
{
var category1Code = Category1Data[DefaultCategory1Item < 0 ? 0 : DefaultCategory1Item].Category1;
var category2Code = Category2Data[DefaultCategory2Item < 0 ? 0 : DefaultCategory2Item].Category2;
if (OrderItems != null) OrderItemPageNo = 0;
OrderItems = new ObservableCollection<M_ItemData>
(
from aRow in AllItems
where aRow.Category1.Equals(category1Code)
&& aRow.Category2.Equals(category2Code)
select aRow
);
DefaultOrderItem = _index < 0 ? 0 : _index;
}
}
private bool CheckExistCategory1(string _categoryCode)
{
bool result = false;
try
{
if (AllCategory != null)
{
result = !AllCategory.Where(r => r.Catalog1Item.Category1.Equals(_categoryCode)).Count().Equals(0);
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "CheckExistCategory1()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
result = false;
}
return result;
}
private bool CheckExistCategory2(string _category1Code, string _category2Code)
{
bool result = false;
try
{
if (AllCategory != null)
{
var category1Items = AllCategory.Where(r => r.Catalog1Item.Category1.Equals(_category1Code)).FirstOrDefault();
if (category1Items != null && category1Items.Catalog2Items != null)
{
result = !category1Items.Catalog2Items.Where(r => r.Category2.Equals(_category2Code)).Count().Equals(0);
}
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "CheckExistCategory2()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
result = false;
}
return result;
}
private void AddCategory1(string _categoryCode, M_ItemData _categoryItem)
{
if (AllCategory != null)
{
if (AllCategory.Where(r => r.Catalog1Item.Category1.Equals(_categoryCode)).Count().Equals(0))
{
_categoryItem.Index = AllCategory.Count;
AllCategory.Add(
new M_CategoryItems
{
Catalog1Item = _categoryItem,
Catalog2Items = new List<M_ItemData>()
}
);
}
}
}
private void AddCategory2(string _category1Code, string _category2Code, M_ItemData _categoryItem)
{
if (AllCategory != null)
{
var category1Items = AllCategory.Where(r => r.Catalog1Item.Category1.Equals(_category1Code)).FirstOrDefault();
if (category1Items != null && category1Items.Catalog2Items != null)
{
if (category1Items.Catalog2Items.Where(r => r.Category2.Equals(_category2Code)).Count().Equals(0))
{
_categoryItem.Index = category1Items.Catalog2Items.Count;
category1Items.Catalog2Items.Add(_categoryItem);
}
}
}
}
private void SetPageNumber()
{
var pageCount = GetItemPageCount();
var pageNumbers = new ObservableCollection<M_ItemData>();
for (int index = 0; index < pageCount; index++)
{
pageNumbers.Add(new M_ItemData
{
Index = index,
DataParameter = new M_AnimationButton
{
NormalBrush = ResourceManager.GetNximagePathAdd("Img_page_dot_off.png", CommonValue.PBdesignImagesPath),
SwitchOnBrush = ResourceManager.GetNximagePathAdd("Img_page_dot_on.png", CommonValue.PBdesignImagesPath),
Width = 20,
Height = 20,
BrushStretch = Stretch.Fill,
ClickAnimationType = ButtonAnimationType.SizeDown,
CircleBackBrush = "Transparent",
CircleTextBruch = "Transparent",
CircleText = string.Empty,
TextVisible = Visibility.Collapsed,
}
});
}
ItemPageStatus = pageNumbers;
}
#endregion
#region Senssing
private M_ItemData SetItemDesignData(CommonDataHelper dataHelper, M_ItemData aItem)
{
var result = aItem;
try
{
aItem.BadgeHeight = 30;
aItem.BadgeOrientation = Orientation.Horizontal;
if (aItem.BadgeImages is List<string> && aItem.BadgeImages.Count > 0)
{
var newBadgeImages = new List<string>();
foreach (var aBadgeImage in aItem.BadgeImages)
{
var strBadgeImage = ResourceManager.GetNximagePathAdd(aBadgeImage, CommonValue.PBdesignImagesPath);
if (!string.IsNullOrEmpty(strBadgeImage))
{
newBadgeImages.Add(strBadgeImage);
}
}
aItem.BadgeImages = newBadgeImages;
}
//if (aItem.Option is List<M_ItemOptionGroup> && aItem.Option.Count > 0)
//{
// foreach (var aOptionGRP in aItem.Option)
// {
// if (aOptionGRP is M_ItemOptionGroup)
// {
// aOptionGRP.ImageFile = aOptionGRP.Index.Equals(0)
// ? "ic_option_takein.png"
// : aOptionGRP.Index.Equals(1)
// ? "ic_option_shot.png"
// : "ic_option_candle.png";
// }
// }
//}
var itemImage = ResourceManager.GetItemImage(aItem.ImageFile, CommonValue.ItemDefaultImage);
aItem.DataParameter = new M_AnimationButton
{
NormalBrush = itemImage,
DragCursorImage = itemImage,
DisableBrush = ResourceManager.GetNximagePathAdd("img_contents_soldout.png", CommonValue.PBdesignImagesPath),
Width = 100,
Height = 100,
Margin = new Thickness(80, 30, 80, 40),
BrushStretch = Stretch.Fill,
DragCursorHotSpot = HotSpotType.Center,
ClickAnimationType = ButtonAnimationType.SizeDown,
CircleBackBrush = "Transparent",
CircleTextBruch = "Transparent",
Enabled = !aItem.IsSoldOut,
CircleText = string.Empty,
};
aItem.BaseTextBlock = new M_TextBlock()
{
LanguageData = dataHelper.GetLaguageData("PROD", aItem.ItemCode),
TextSize = 24,
Width = 250,
Height = 82,
TextBrush = "Black",
TextFontFamily = "NanumSquare",
TextVerticalAlignment = VerticalAlignment.Center,
TextMargin = new Thickness(5, 0, 5, 0),
TextWeight = FontWeights.Bold,
TextWrapping = TextWrapping.Wrap
};
aItem.AdditionTextBlock = new M_TextBlock()
{
LanguageData = new List<M_Language>
{
new M_Language{ Type = SupportLanguageType.ko, LanguageData = string.Format("₩{0:#,##0}", aItem.Price)},
},
TextSize = 26,
Width = 250,
Height = 40,
TextBrush = "#1469cc",
TextFontFamily = "NanumSquare",
TextVerticalAlignment = VerticalAlignment.Top,
TextMargin = new Thickness(5, 0, 5, 0),
TextWeight = FontWeights.Bold,
};
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "SetItemDesignData()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
result = aItem;
}
return result;
}
private void ProcessBardcord()
{
Console.WriteLine("Paag={0},SubPage={1},Barcord={2}", DefaultPage, SensingSubPage, ReadBarCode);
if (string.IsNullOrEmpty(ReadBarCode) || !DefaultPage.Equals(PBPageType.Sensing)) return;
var barcordData = ReadBarCode.Trim().ToUpper();
if (barcordData.rIsBigAlpa() && barcordData.Contains("SCANSTART"))
{
AIScanCount = 0;
}
else
{
var isNumeric = barcordData.rIsNum();
var isAlpaNumaric = barcordData.rIsAlpaNum();
var barcord = isNumeric && isAlpaNumaric ? barcordData : null;
var itemcode = !isNumeric && isAlpaNumaric ? barcordData.rGetOnlyNum() : null;
var itemType = string.IsNullOrEmpty(itemcode) && !string.IsNullOrEmpty(barcord) && SensingSubPage.Equals(PBSensingSubPageType.BarcordPage)
? BasketItemType.Barcode
: !string.IsNullOrEmpty(itemcode) && string.IsNullOrEmpty(barcord) && SensingSubPage.Equals(PBSensingSubPageType.SensingPage)
? BasketItemType.Scan
: BasketItemType.None;
if (!itemType.Equals(BasketItemType.None))
{
var newScanData = new M_ScanData
{
ItemCode = itemcode,
Barcord = barcord,
ItemType = itemType,
};
scanQueue.Enqueue(newScanData);
}
}
}
private void ScanDataProcessor()
{
while (IsScanProcess)
{
try
{
var scanData = scanQueue.Count > 0 ? scanQueue.Dequeue() : null;
if (scanData is M_ScanData)
{
using (var dataHelper = new CommonDataHelper())
{
var getItemData = dataHelper.GetBarcordItemsData(scanData.ItemCode, scanData.Barcord);
if (getItemData is M_ItemData)
{
var designItem = SetItemDesignData(dataHelper, getItemData);
AddItem2Basket(designItem, scanData.ItemType);
if (scanData.ItemType.Equals(BasketItemType.Scan)) AIScanCount += 1;
}
else
{
CommonLog.ErrorLogWrite(this, "ScanDataProcessor()", "Not Found Item Error !!", string.Format("\nItem={0},Barcord={1}", scanData.ItemCode, scanData.Barcord));
}
}
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "Dispose", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
}
}
#endregion
#region Basket
private void AddItem2Basket(M_ItemData _itemData, BasketItemType _itemType = BasketItemType.Order)
{
var option = new List<M_ItemOptionGroup>();
var itemCount = 1;
var unitPrice = _itemData.Price;
if (_itemType.Equals(BasketItemType.Order))
{
if (_itemData.IsOption)
{
ToIntorTimerStop();
try
{
var newOptions = new List<M_ItemOptionGroup>();
foreach (var aOptionGroup in _itemData.Option)
{
newOptions.Add(aOptionGroup.Clone());
}
var popupReturn = popupManager.OpenOptionSelect(_itemData.BaseTextBlock.LanguageData
, newOptions
, _itemData.DataParameter.NormalBrush
, itemCount
, _itemData.Price);
if (popupReturn is M_PopupReturn)
{
if (popupReturn.TimeOut)
{
DefaultPage = PBPageType.Intro;
option = null;
}
else
{
if (popupReturn.PopupArgs is M_OptionReturn getOption)
{
option = getOption.Options;
itemCount = getOption.ItemCount;
unitPrice = getOption.PriceWithOption;
}
else
{
option = null;
}
}
}
else
{
option = null;
}
}
catch
{
option = null;
}
finally
{
ToIntorTimerStart();
}
if (option == null) return;
}
else
{
option = null;
itemCount = 1;
unitPrice = _itemData.Price;
}
}
else
{
option = null;
}
using (var posDataService = new PosDataService())
{
var getNewBasketData = posDataService.AddItemToBasket(MiniBasketData
, itemCount
, unitPrice
, CommonValue.PBdesignImagesPath
, _itemData
, option
, _itemType);
if (getNewBasketData is ObservableCollection<M_BasketItem>) MiniBasketData = getNewBasketData;
}
}
private double GetItemPrice(M_ItemData _itemData, List<M_ItemOptionGroup> _option)
{
double result = _itemData.Price;
try
{
foreach (var aOptionGroup in _option)
{
foreach (var aOption in aOptionGroup.Options)
{
if (aOption.IsSelected)
{
}
}
}
}
catch
{
result = _itemData.Price;
}
return result;
}
private void SetBasketSum()
{
if (MiniBasketData is ObservableCollection<M_BasketItem>)
{
OrderTotalCount = MiniBasketData.Sum(r => r.Count);
OrderTotalPayment = MiniBasketData.Sum(r => r.Count * r.Price);
}
else
{
OrderTotalCount = 0;
OrderTotalPayment = 0;
}
}
private void DeleteBasketItem(M_BasketItem _deleteItem)
{
if (MiniBasketData is ObservableCollection<M_BasketItem>)
{
var newBasketData = MiniBasketData.ToList();
using (var posDataService = new PosDataService())
{
if (posDataService.DelItem(_deleteItem))
{
newBasketData.Remove(_deleteItem);
}
}
MiniBasketData = new ObservableCollection<M_BasketItem>(newBasketData);
}
}
private void DeleteScanItem()
{
if (MiniBasketData is ObservableCollection<M_BasketItem>)
{
var newBasketData = MiniBasketData.ToList();
using (var posDataService = new PosDataService())
{
foreach (var aitem in newBasketData.Where(r => r.ItemType.Equals(BasketItemType.Scan)).ToList())
{
if (posDataService.DelItem(aitem))
{
newBasketData.Remove(aitem);
}
}
}
newBasketData.RemoveAll(r => r.ItemType.Equals(BasketItemType.Scan));
MiniBasketData = new ObservableCollection<M_BasketItem>(newBasketData);
}
}
public void DeledteAllBasket()
{
if (MiniBasketData is ObservableCollection<M_BasketItem>)
{
using (var posDataService = new PosDataService())
{
foreach (var aitem in MiniBasketData)
{
posDataService.DelItem(aitem);
}
}
MiniBasketData = null;
}
}
#endregion
#endregion Contents
#region Etc
/// <summary>
/// 타이머 스톱
/// </summary>
public void ToIntorTimerStart()
{
LastAccessTime = DateTime.Now;
ToIntoroTimer.Start();
}
/// <summary>
/// 타이머 재시작
/// </summary>
public void ToIntorTimerStop()
{
LastAccessTime = DateTime.Now;
ToIntoroTimer.Stop();
}
private int GetMaxItemPageNo()
{
int result = 0;
try
{
result = OrderItems.Count / (OrderColumnCount * OrderRowCount);
if ((OrderItems.Count % (OrderColumnCount * OrderRowCount)).Equals(0)) result -= 1;
}
catch
{
result = 0;
}
return result;
}
private int GetItemPageCount()
{
int result = 0;
try
{
result = OrderItems.Count / (OrderColumnCount * OrderRowCount);
if (!(OrderItems.Count % (OrderColumnCount * OrderRowCount)).Equals(0)) result += 1;
}
catch
{
result = 0;
}
return result;
}
#endregion Etc
#endregion Methods
#region [ Event Handlers ]
private void ToExecuteNothingHandler(object obj)
{
}
private void VmPBViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
LastAccessTime = DateTime.Now;
try
{
switch (e.PropertyName)
{
case "DefaultPage":
if (DefaultPage.Equals(PBPageType.FirstSelect)
|| DefaultPage.Equals(PBPageType.Items))
{
GmbHappyInfoEnable = !MemberLoginOK;
}
else
{
GmbHappyInfoEnable = false;
}
switch (DefaultPage)
{
case PBPageType.Intro:
ToIntorTimerStop();
OrderHistoryView = false;
MemberLoginOK = false;
HappyPointReturn = null;
FindOrderHistoryItems = null;
SetIntro();
DeledteAllBasket();
break;
case PBPageType.FirstSelect:
ToIntorTimerStart();
break;
case PBPageType.Items:
GmbOrderEnable = false;
SetContents();
SetOrderHistoryItems();
ToIntorTimerStart();
break;
case PBPageType.Sensing:
GmbAIscannerEnable = false;
AIScanCount = 0;
ToIntorTimerStart();
break;
}
break;
case "MemberLoginOK":
GmbHappyPointEnable = !MemberLoginOK;
GmbHappyInfoEnable = !MemberLoginOK;
break;
case "GmbHappyInfoEnable":
if (GmbHappyInfoEnable)
{
GmbHappyInfoEnableTime = DateTime.Now;
}
break;
case "DefaultCategory1Item":
if (DefaultCategory1Item > -1)
{
if (Category2Data == null)
{
SetCategory2();
}
else
{
if (!Category1Data[DefaultCategory1Item].Category1.Equals(Category2Data.FirstOrDefault().Category1))
{
SetCategory2();
}
}
}
OrderItemPageNo = 0;
break;
case "DefaultCategory2Item":
if (DefaultCategory1Item > -1)
{
SetItemList();
}
OrderItemPageNo = 0;
ToIntorTimerStart();
break;
case "DefaultCategory1PageNo":
case "DefaultCategory2PageNo":
break;
case "ShowLanguageType":
CommonValue.CommonLanguageType = ShowLanguageType;
switch (ShowLanguageType)
{
case SupportLanguageType.ko:
GmbLanguageimage=ResourceManager.GetNximagePathAdd("btn_language_kor.png", CommonValue.PBdesignImagesPath);
break;
case SupportLanguageType.en:
GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_eng.png", CommonValue.PBdesignImagesPath);
break;
case SupportLanguageType.ja:
GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_jap.png", CommonValue.PBdesignImagesPath);
break;
case SupportLanguageType.zh:
GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_chi.png", CommonValue.PBdesignImagesPath);
break;
}
break;
case "OrderItems":
PageStatusColumnCount = GetItemPageCount();
SetPageNumber();
break;
case "OrderItemPageNo":
Page2LeftEnable = !OrderItemPageNo.Equals(0);
Page2RightEnable = !OrderItemPageNo.Equals(GetMaxItemPageNo());
break;
case "MiniBasketData":
SetBasketSum();
if (MiniBasketData is ObservableCollection<M_BasketItem> miniBasketItems
&& miniBasketItems.Count > 0)
{
OrderDetailEnable = true;
GotoPaymentEnable = true;
MiniBasketDeleteAllEnable = true;
OrderNoneDataGridVisibility = Visibility.Hidden;
OrderExistDataGridVisibility = Visibility.Visible;
foreach (var aBasketItem in miniBasketItems )
{
aBasketItem.PropertyChanged += ABasketItem_PropertyChanged;
}
}
else
{
OrderDetailEnable = false;
GotoPaymentEnable = false;
MiniBasketDeleteAllEnable = false;
OrderNoneDataGridVisibility = Visibility.Visible;
OrderExistDataGridVisibility = Visibility.Hidden;
}
break;
case "FindOrderHistoryItems":
SetOrderHistoryItems();
break;
case "OrderHistoryItems":
//OrderHistoryItemsEnable = OrderHistoryItems != null && OrderHistoryItems.Count > 0;
OrderHistoryItemsEnable = MemberLoginOK;
GmbHappyPointEnable = !MemberLoginOK;
GmbHappyInfoEnable = !MemberLoginOK;
break;
case "ReadBarCode":
ProcessBardcord();
break;
default:
break;
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "VmPBViewModel_PropertyChanged()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
}
#region Intro Click
private void RollMediaCommandHandler(object _param)
{
try
{
if (_param is M_MediaRollItem selectItem)
{
NeedIntailizeItems = true;
PBPageType targetPage = PBPageType.Intro;
switch (selectItem.LinkType)
{
case IntroLinkType.Page:
DefaultLinkValue = string.Empty;
switch (selectItem.LinkParameter)
{
case "IntroPage":
targetPage = PBPageType.Intro;
break;
case "ItemPage":
targetPage = PBPageType.Items;
break;
case "SensingPage":
targetPage = PBPageType.Sensing;
break;
case "FirstSelect":
targetPage = PBPageType.FirstSelect;
break;
}
break;
case IntroLinkType.Category:
DefaultLinkValue = selectItem.LinkParameter;
targetPage = PBPageType.Items;
break;
case IntroLinkType.ItemCode:
DefaultLinkValue = selectItem.LinkParameter;
targetPage = PBPageType.Items;
break;
default:
targetPage = PBPageType.FirstSelect;
break;
}
ShowLanguageType = SupportLanguageType.ko;
#region ( )
//if (!targetPage.Equals(PBPageType.Intro))
//{
// var popupReturn = popupManager.OpenHappyPointCertify();
// if (popupReturn is M_PopupReturn)
// {
// MemberLoginOK = popupReturn.OKAnswer;
// if (popupReturn.PopupArgs is M_HappyPointReturn _HappyPointReturn)
// {
// HappyPointReturn = _HappyPointReturn;
// GmbMemberName = HappyPointReturn.MemberName;
// }
// if (!popupReturn.ReturnLanguage.Equals(ShowLanguageType))
// {
// ShowLanguageType = popupReturn.ReturnLanguage;
// }
// if (popupReturn.TimeOut) targetPage = PBPageType.Intro;
// }
//}
#endregion
WaitWindowFrom.ShowWaitWindow();
DefaultPage = targetPage;
if (!targetPage.Equals(PBPageType.Intro)) IntroItems = null;
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "RollMediaCommandHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
finally
{
WaitWindowFrom.CloseWaitWindow();
}
}
#endregion
#region GMB Left Click
private void GotoFirstCommandHandler(object obj)
{
DefaultPage = PBPageType.FirstSelect;
}
private void ReaderCheckCommandHandler(object obj)
{
try
{
ReaderCheckClickCount += 1;
if (ReaderCheckClickCount.Equals(10))
{
ToIntorTimerStop();
try
{
var popupReturn = popupManager.OpenNumPadPopup(ShowLanguageType
, Languages.GetMessages("InputPassword")
, false,true,5,5);
if (popupReturn is M_PopupReturn)
{
if (popupReturn.TimeOut)
{
DefaultPage = PBPageType.Intro;
return;
}
else
{
if (popupReturn.OKAnswer)
{
if (popupReturn.PopupArgs is string getPassword
&& getPassword.Equals(DateTime.Now.ToString("ddMM")
+ ((int.Parse(DateTime.Now.ToString("dd"))
* int.Parse(DateTime.Now.ToString("MM"))) % 10).ToString()))
{
GmbReaderCheckOpen = true;
}
}
}
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "ReaderCheckCommandHandler()", "OpenNumPadPopup Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
finally
{
ReaderCheckClickCount = 0;
ToIntorTimerStart();
}
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "ReaderCheckCommandHandler()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
}
#endregion
#region GMB Right Click
private void HappyPointCommandHandler(object obj)
{
if (HappyPointReturn is M_HappyPointReturn)
{
GmbHappyPointEnable = false;
return;
}
ToIntorTimerStop();
try
{
OrderHistoryView = false;
FindOrderHistoryItems = null;
var popupReturn = popupManager.OpenHappyPointCertify(false, true, ParentPage.PBWindow);
if (popupReturn is M_PopupReturn)
{
if (popupReturn.TimeOut)
{
DefaultPage = PBPageType.Intro;
return;
}
else
{
MemberLoginOK = popupReturn.OKAnswer;
if (popupReturn.PopupArgs is M_HappyPointReturn _HappyPointReturn)
{
HappyPointReturn = _HappyPointReturn;
GmbMemberName = HappyPointReturn.IsCardNoUsed ? HappyPointReturn.MemberName : "고객";
if (HappyPointReturn.OrderHistoryItems is List<string> orderHistoryItems
&& orderHistoryItems.Count > 0)
{
FindOrderHistoryItems = orderHistoryItems;
}
else
{
FindOrderHistoryItems = null;
}
if (DefaultPage.Equals(PBPageType.Items)) OrderHistoryView = OrderHistoryItemsEnable;
}
else
{
HappyPointReturn = null;
}
if (!popupReturn.ReturnLanguage.Equals(ShowLanguageType))
{
ShowLanguageType = popupReturn.ReturnLanguage;
}
}
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "HappyPointCommandHandler()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
finally
{
ToIntorTimerStart();
}
}
private void CallEmployeeCommandHandler(object obj)
{
ToIntorTimerStop();
try
{
var popupReturn = popupManager.OpenCallEmployee();
if (popupReturn is M_PopupReturn)
{
if (popupReturn.TimeOut)
{
DefaultPage = PBPageType.Intro;
return;
}
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "CallEmployeeCommandHandler()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
finally
{
ToIntorTimerStart();
}
}
private void LanguageCommandHandler(object obj)
{
ToIntorTimerStop();
try
{
var popupReturn = popupManager.OpenLanguageSelector(ShowLanguageType);
if (popupReturn is M_PopupReturn)
{
if (popupReturn.TimeOut)
{
DefaultPage = PBPageType.Intro;
return;
}
else
{
ShowLanguageType = popupReturn.ReturnLanguage;
}
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "LanguageCommandHandler()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
finally
{
ToIntorTimerStart();
}
}
private void GotoIntroPageCommadHandler(object obj)
{
ToIntorTimerStop();
try
{
if (MiniBasketData != null && MiniBasketData.Count > 0)
{
var miniPopup = new M_MiniPopup
{
Icon = MiniPopupIcon.Cancel,
DisplayLanguage = ShowLanguageType,
Message = Languages.GetMessages("LBL0085"),
CencalButtonText = Languages.GetMessages("BTN0021"),
OkButtonText = Languages.GetMessages("BTN0005"),
IsCencalButton = true,
TimeoutSeconds = 10,
};
var popupReturn = popupManager.OpenMiniPopup(miniPopup);
if (popupReturn is M_PopupReturn)
{
if (popupReturn.OKAnswer)
{
DefaultPage = PBPageType.Intro;
}
}
}
else
{
DefaultPage = PBPageType.Intro;
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "GotoIntroPageCommadHandler()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
finally
{
ToIntorTimerStart();
}
}
#endregion
#region GMB Center Click
private void GmbOrderCommandHandler(object obj)
{
DefaultPage = PBPageType.Items;
}
private void GmbAIscannerCommandHandler(object obj)
{
DefaultPage = PBPageType.Sensing;
if (this.OptionValue810 == "0"
&& this.OptionValue811 == "1")
{
SensingSubPage = PBSensingSubPageType.BarcordPage;
}
}
#endregion
#region Contents
private void RescanCommandHandler(object obj)
{
DeleteScanItem();
DefaultPage = PBPageType.Sensing;
}
private void GotoBarcodeCommandHandler(object obj)
{
if (DefaultPage.Equals(PBPageType.Sensing))
{
SensingSubPage = PBSensingSubPageType.BarcordPage;
}
}
private void Page2LeftCommandHandler(object obj)
{
OrderItemPageNo -= 1;
}
private void Page2RightCommandHandler(object obj)
{
OrderItemPageNo += 1;
}
private void ItemCommandCommandHandler(object _param)
{
if (_param is AnimationButton targetButton && targetButton.DataParameter is M_ItemData _ItemData)
{
//AddItem2Basket(_ItemData);
}
}
private void Category2CommandHandler(object _param)
{
ToIntorTimerStart();
if (_param is AnimationButton targetButton && targetButton.DataParameter is M_ItemData _ItemData)
{
DefaultCategory2Item = Category2Data.IndexOf(_ItemData);
}
}
private void Category1CommandHandler(object _param)
{
ToIntorTimerStart();
if (_param is AnimationButton targetButton && targetButton.DataParameter is M_ItemData _ItemData)
{
DefaultCategory1Item = Category1Data.IndexOf(_ItemData);
}
}
private void PageSelectCommandHandler(object _param)
{
if (_param is AnimationButton targetButton && targetButton.DataParameter is M_ItemData _ItemData)
{
OrderItemPageNo = ItemPageStatus.IndexOf(_ItemData);
}
}
private void OrderHistoryCommandHandler(object obj)
{
OrderHistoryView = true;
}
private void OrderHistoryCloseCommandHandler(object obj)
{
OrderHistoryView = false;
}
#endregion
#region MiniBasket
private void ABasketItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (sender is M_BasketItem basketItem)
{
using (var posDataService = new PosDataService())
{
posDataService.UpdatedItem(basketItem);
}
SetBasketSum();
}
}
private void MiniBasketDeleteAllCommandHandler(object _param)
{
ToIntorTimerStop();
try
{
var miniPopup = new M_MiniPopup
{
Icon = MiniPopupIcon.ListCancel,
DisplayLanguage = ShowLanguageType,
Message = Languages.GetMessages("LBL0099"),
CencalButtonText = Languages.GetMessages("BTN0021"),
OkButtonText = Languages.GetMessages("BTN0005"),
IsCencalButton = true,
TimeoutSeconds = 10,
};
var popupReturn = popupManager.OpenMiniPopup(miniPopup);
if (popupReturn is M_PopupReturn && popupReturn.OKAnswer)
{
DeledteAllBasket();
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite(this, "MiniBasketDeleteAllCommandHandler()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
finally
{
ToIntorTimerStart();
}
}
private void EmptyBasketDropCommandHandler(object _param)
{
if (_param is M_ItemDropEventArgs dropedItem)
{
if (dropedItem.SourceObject is AnimationButton sourceButton && sourceButton.DataParameter is M_ItemData _ItemData)
{
AddItem2Basket(_ItemData);
}
}
}
private void BasketItemDeleteCommandHandler(object _param)
{
if (_param is M_BasketItem deleteItem)
{
DeleteBasketItem(deleteItem);
}
}
private void OrderDetailCommandHandler(object _param)
{
OpenPBPaymentPage = PBPaymentPageType.DetailBasket;
}
private void GotoPaymentCommandHandler(object _param)
{
if (MiniBasketData is ObservableCollection<M_BasketItem>
&& MiniBasketData.Count > 0)
{
OpenPBPaymentPage = PBPaymentPageType.PointsDisCounts;
}
else
{
ToIntorTimerStop();
var topMessage = new List<M_Language>
{
new M_Language
{
Type = SupportLanguageType.ko,
LanguageData = "선택한 제품이 없습니다."
},
new M_Language
{
Type = SupportLanguageType.en,
LanguageData = "en선택한 제품이 없습니다."
},
};
var popupReturn = PopupMessageBox.ShowMessageBox(ShowLanguageType
, topMessage
, null
, MessageBoxButton.OK
, OpenCloseAnimationType.FullSizeUp
, OpenCloseAnimationType.FullSizeDown
, 0.5, 0.2, 5);
ToIntorTimerStart();
}
}
#endregion
private void ToIntoroTimer_Tick(object sender, EventArgs e)
{
if (GmbHappyInfoEnable)
{
if (GmbHappyInfoEnableTime.AddSeconds(3) <= DateTime.Now)
{
GmbHappyInfoEnableTime = DateTime.Now;
GmbHappyInfoEnable = false;
}
}
if (DefaultPage.Equals(PBPageType.Intro))
{
LastAccessTime = DateTime.Now;
}
else if ((DateTime.Now - LastAccessTime) > TimeSpan.FromSeconds(CommonValue.TimeOutSeconds))
{
ReaderCheckClickCount = 0;
#if !TESTMODE
if (IsTimeoutPopup)
{
ToIntorTimerStop();
var popupReturn = PopupMessageBox.ShowMessageBox(ShowLanguageType
, Languages.GetMessages("LBL0067")
, Languages.GetMessages("LBL0021")
, MessageBoxButton.YesNo
, OpenCloseAnimationType.FullSizeUp
, OpenCloseAnimationType.FullSizeDown
, 0.5, 0.2, 10);
if (popupReturn.Equals(MessageBoxResult.Yes))
{
ToIntorTimerStart();
}
else
{
if (!DefaultPage.Equals(PBPageType.Intro)) DefaultPage = PBPageType.Intro;
}
}
#else
LastAccessTime = DateTime.Now;
Console.WriteLine(">>> PBViewModel.DefaultPage=PBPageType.Intro");
#endif
}
}
#endregion Event Handlers
}
}