#pragma once

#include "RemoteComboBox.h"
#include "RemoteTreeCtrl.h"
#include "RemoteListCtrl.h"

#include "TextProgressCtrl.h"


#define WMU_SHOW_VOLUMELIST   (WM_USER + 1)
#define WMU_EXPAND_FOLDERLIST (WM_USER + 2)
#define WMU_SHOW_FOLDERLIST   (WM_USER + 3)
#define WMU_SHOW_OBJECTLIST   (WM_USER + 4)

#define	WM_GET_FILE_LIST_END  (WM_USER + 10)

// CRemoteView 폼 뷰입니다.

class CRemoteView : public CFormView
{
protected:
	CRemoteView();           // 동적 만들기에 사용되는 protected 생성자입니다.
	DECLARE_DYNCREATE(CRemoteView)

public:
	enum{ IDD = IDD_REMOTE_VIEW };

public:
	virtual ~CRemoteView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

private:
	bool m_bClosing;

	CString m_sOldFileName;

	UINT m_nTimer;

public:
	CBitmapButton   m_capTitleIcon;
	CXTCaption      m_capTitle;
	CRemoteTreeCtrl m_tree;
	CStatic         m_capAddr;
	CRemoteComboBox m_cboAddr;
	CXTButton       m_btnGoAddr;
	CXTButton       m_btnUpAddr;
	CXTButton       m_btnListStyle;
	CRemoteListCtrl m_list;

	CXTCaption        m_capStatus;
	CTextProgressCtrl m_prgStatusSpace;
	CStatic           m_stcStatusSpace;
	CStatic           m_stcStatusObject;
	CStatic           m_stcStatusMsg;
	CStatic           m_stcSeparator1;
	CStatic           m_stcSeparator2;

	int  m_cxSplitter;
	BOOL m_bDragSplitter;

	long    m_nTotalCount;
	__int64 m_nTotalBytes;
	long    m_nTotalFiles;
	long    m_nSelectedCount;
	__int64 m_nSelectedBytes;
	long    m_nSelectedFiles;

	bool m_bUpdating;

	CImageList* m_pilSmall;
	CImageList* m_pilLarge;

private:
	void RedrawControl(int cx, int cy);
	void InvertTracker(int x);

	bool RefreshObjectlist(HTREEITEM htiFolder, BOOL bRefresh);

	

	void InsertAnonyFolderIcon(bool bLarge, bool bOpen);
	bool IsExistsFileName(HTREEITEM htiParent, LPCTSTR pszOldFileName, LPCTSTR pszNewFileName);
public:
	inline CRemoteTreeCtrl *GetTreeCtrl() { return &m_tree; }
	inline CRemoteListCtrl *GetListCtrl() { return &m_list; }

	void SetControlStatus(BOOL bConnected);
	void RedrawFocus();
	void RedrawControl();

	void ApplyListStyle();

	void ShowStatusSpace();
	void ShowStatusObject(BOOL bSelected = FALSE, BOOL bUpdate = TRUE, BOOL bAllSelected = FALSE);

	void AppendObject(HTREEITEM htiParent, bool bFolder, LPCTSTR pszPath, __int64 nSize, LPCTSTR pszLastModified);

	void ClearAllData();

	// 기능
	void RefreshItem();

	void MakeNewFolder();

	void DeleteTreeItem(HTREEITEM htiDelete);
	void DeleteListItem();

	BOOL GetSelectedObject(CStringArray &saObject);

	void SetAnonyFolder(HTREEITEM htiVolume, LPCTSTR pszFolder, bool bSet, bool bRefresh = false);

protected:
	virtual void OnDraw(CDC* pDC);  // 이 뷰를 그리기 위해 재정의되었습니다.
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 지원
	virtual void OnInitialUpdate(); // 생성 후 처음 호출되었습니다.

public:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnDestroy();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnRemoteTitle();
	afx_msg void OnRemoteBtnUpAddr();
	afx_msg void OnRemoteBtnListStyle();
	afx_msg void OnTreeSelchanged(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTreeItemexpanding(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTreeItemexpanded(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTreeBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTreeEndlabeledit(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnListBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnListEndlabeledit(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnListItemChanged(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnListNMClick(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTimer(UINT nIDEvent);

	afx_msg LRESULT OnShowVolumelist(WPARAM, LPARAM);
	afx_msg LRESULT OnExpandFolderlist(WPARAM, LPARAM);
	afx_msg LRESULT OnShowFolderlist(WPARAM, LPARAM);
	afx_msg LRESULT OnShowObjectlist(WPARAM, LPARAM);

	DECLARE_MESSAGE_MAP()
};
