예제 #1
0
LRESULT CMainDlg::OnTreeRClick(int idCtrl, LPNMHDR pNMHDR, BOOL& bHandled)
{
	DWORD dwPos = GetMessagePos();
	POINT pt = {GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos)};

	UINT uFlags;
	m_Tree.ScreenToClient(&pt);
	HTREEITEM htItem = m_Tree.HitTest(pt, &uFlags);
	if (htItem)
	{
		m_Tree.SelectItem(htItem);

		CTreeItem ti = m_Tree.GetSelectedItem();
		if(ti)
		{
			int out = ti.GetData()-1;
			CMenu menu, pPopup;
			menu.LoadMenu(IDR_CONTEXTMENU);
			pPopup = menu.GetSubMenu((out >= 0) ? 0 : 1);
			m_Tree.ClientToScreen(&pt);
			pPopup.TrackPopupMenu(TPM_LEFTALIGN, pt.x, pt.y, m_hWnd);
		}
	}

	return 0;
}
예제 #2
0
CNBDevice *CNBTreeListView::GetSelectedDevice()
{
	CTreeItem itemSelected = GetTreeControl().GetSelectedItem();
	if ( !itemSelected.IsNull() )
	{
		return (CNBDevice *)itemSelected.GetData();
	}

	return NULL;
}
예제 #3
0
LRESULT CMainDlg::OnSaveSelected(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	CTreeItem ti = m_Tree.GetSelectedItem();
	if(ti)
	{
		int out = ti.GetData()-1;
		if(out >= 0)
		{
			OnSaveFile(wNotifyCode, wID, hWndCtl, bHandled);
		}
		else
		{
			OnSaveFolder(wNotifyCode, wID, hWndCtl, bHandled);
		}
	}

	return 0;
}
예제 #4
0
LRESULT CMainDlg::OnSaveFile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	CTreeItem ti = m_Tree.GetSelectedItem();
	if(ti)
	{
		int out = ti.GetData()-1;
		if(out >= 0)
		{
			CFileDialog fd(false, NULL, PathFindFileName(sc.index[out].filename.c_str()), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("All Files (*.*)"), m_hWnd);
			if(fd.DoModal(m_hWnd) != IDCANCEL)
			{
				sc.SaveFile(sc.index[out], fd.m_szFileName);
			}
		}
	}

	return 0;
}
예제 #5
0
LRESULT CMainFrame::OnSelChanged(LPNMHDR /*lpNLHDR*/)
{
	CTreeItem itemSelected;
	itemSelected = m_view.GetSelectedItem();

	UIEnable(IDM_AGGR_UNBIND, FALSE);
	UIEnable(IDM_AGGR_SYNCHRONIZE, FALSE);
	UIEnable(IDM_AGGR_ADDMIRROR, FALSE);
	if ( !itemSelected.IsNull() )
	{
		CDiskObjectPtr obj = m_mapObject[itemSelected.GetData()];
		ATLASSERT( obj.get() != NULL );
		CCommandSet cmdSet = 
			CObjectUIHandler::GetUIHandler(obj)->GetCommandSet(obj);
		CCommandSet::iterator itr;
		for ( itr = cmdSet.begin(); itr != cmdSet.end(); itr++ )
		{
			UIEnable( itr->GetID(), !itr->IsDisabled() );
		}
	}
	return 0;
}
예제 #6
0
LRESULT CMainDlg::OnTreeDblClick(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& bHandled)
{
	CTreeItem ti = m_Tree.GetSelectedItem();
	if(ti)
	{
		int out = ti.GetData()-1;
		if(out>=0)
		{
			CString f = sc.index[out].filename.c_str();
			if(!f.Right(4).Compare(".tri"))
			{
				delete file;
				file = new TriFile();
				Load(out);
			}
			else if(!f.Right(4).Compare(".dds"))
			{
				if(loaded)
				{
					Add(f.Right(f.GetLength()-f.ReverseFind('/')-1), out);
					m_p3d.TextureChange(sc, texdata);
				}
			}
			else if(!f.Right(4).Compare(".gr2"))
			{
				delete file;
				file = new GrannyTriFile();
				Load(out);
			}
			else
				MessageBox("WTF?", "Error", MB_ICONERROR | MB_OK);
		}
	}
	else
		if(!loaded)
			EnableAll(FALSE);
	return TRUE;
}
예제 #7
0
void CMainFrame::RefreshAction()
{
	CTreeItem itemSelected;
	itemSelected = m_viewTree.GetSelectedItem();

//	UIEnable(IDM_AGGR_BIND, FALSE);
	UIEnable(IDM_AGGR_UNBIND, FALSE);
	UIEnable(IDM_AGGR_SYNCHRONIZE, FALSE);
	UIEnable(IDM_AGGR_ADDMIRROR, FALSE);

	if ( !itemSelected.IsNull() )
	{
		CDiskObjectPtr obj = m_mapObject[itemSelected.GetData()];
		ATLASSERT( obj.get() != NULL );
		CCommandSet cmdSet = 
			CObjectUIHandler::GetUIHandler(obj)->GetCommandSet(obj);
		CCommandSet::iterator itr;
		for ( itr = cmdSet.begin(); itr != cmdSet.end(); itr++ )
		{
			UIEnable( itr->GetID(), !itr->IsDisabled() );
		}
	}
}
예제 #8
0
LRESULT CMainDlg::OnSaveFolder(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	CTreeItem ti = m_Tree.GetSelectedItem();
	if(ti)
	{
		int out = ti.GetData()-1;
		if(out < 0)
		{
			CFolderDialog fd(m_hWnd, "Select folder to save files:");
			if(fd.DoModal(m_hWnd) != IDCANCEL)
			{
				CString path = fd.m_szFolderPath;
				CUnstuffDlg dlg; 
				DWORD data[3]; 
				data[0] = (DWORD)&ti;
				data[1] = (DWORD)&sc;
				data[2] = (DWORD)&path;
				dlg.DoModal(m_hWnd, (LPARAM)data); 
			}
		}
	}

	return 0;
}
예제 #9
0
void CMainFrame::OnContextMenu(HWND /*hWnd*/, CPoint pos)
{
	if(m_bRefreshing)
		return;

	ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	CRect rect;
	CPoint posInView;
	CTreeItem itemSelected;
	m_view.GetWindowRect( rect );

	if ( !rect.PtInRect(pos) )
	{
		// If clicked point is outside the tree control, do nothing.
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}
	// Change screen coordinates to client coordinates
	posInView = pos - rect.TopLeft();

	itemSelected = m_view.HitTest( posInView, NULL );

	CMenu menu;
	CMenu newSubMenu;
	CMenuHandle subMenu;

	menu.LoadMenu( MAKEINTRESOURCE(IDR_CONTEXT_MENU) );
	subMenu = menu.GetSubMenu(0);
	if ( subMenu.IsNull() )
	{
		newSubMenu.CreatePopupMenu();
		subMenu = newSubMenu;
	}
	if ( itemSelected.IsNull() )
	{
		// Display default menu
		subMenu.TrackPopupMenu(
			TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
			pos.x, 
			pos.y, 
			m_hWnd
			);
	}
	else
	{
		// Change select
		m_view.SelectItem(itemSelected);

		// Display context menu
		CDiskObjectPtr obj = m_mapObject[itemSelected.GetData()];
		ATLASSERT( obj.get() != NULL );
		CObjectUIHandler::GetUIHandler(obj)->InsertMenu(obj, subMenu);
		subMenu.TrackPopupMenu(
			TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
			pos.x, 
			pos.y, 
			m_hWnd
			);
	}

	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
}
예제 #10
0
LRESULT CChildFrame::OnTvnSelChanged(int idCtrl, LPNMHDR pNMHDR, BOOL& bHandled)
{ 
    USES_CONVERSION; 
    HRESULT hr = E_FAIL; 

    idCtrl, pNMHDR, bHandled; 
    CTreeViewCtrl ctrlTree = m_wndCatalog; 

    bHandled = FALSE; 

    NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; 
    ATLASSERT( pNMTreeView ); 

    { 
        m_pData.m_hTreeItem = pNMTreeView->itemNew.hItem; 
        m_pData.m_pTreeView = &m_wndCatalog; 
    } 

    CTreeItem hItem(pNMTreeView->itemNew.hItem, &m_wndCatalog); 

    TREE_ITEM_DATA * pCurrSel = NULL; 
    pCurrSel = (TREE_ITEM_DATA *) ctrlTree.GetItemData(hItem); 

    if (pCurrSel && STGTY_STREAM == pCurrSel->dwStgType) 
    { 
        CComPtr<IStream> spStrm; 
        hr = pCurrSel->spStgOrStrm->QueryInterface(&spStrm); 
        if (FAILED(hr)) return hr; 

        STATSTG st = { 0 }; 
        hr = spStrm->Stat(&st, STATFLAG_NONAME); 
        if (FAILED(hr)) return hr; 

        LARGE_INTEGER liBegin = { 0 }; 
        hr = spStrm->Seek(liBegin, STREAM_SEEK_SET, NULL); 

        BYTE * byBuff = new BYTE[st.cbSize.QuadPart+1]; 
        ZeroMemory(byBuff, (st.cbSize.QuadPart+1)*sizeof(BYTE)); 
        ULONG ulSize = 0; 
        hr = spStrm->Read(byBuff, st.cbSize.QuadPart, &ulSize); 

		ATLASSERT(SUCCEEDED(hr));

        if(st.cbSize.QuadPart) 
        { 
            CComSafeArray data; 
            data.CreateOneDim(VT_UI1, st.cbSize.QuadPart, (const void *)byBuff); 
            m_wndHexEdit.SetData(data); 
        } 
        else 
        {
            CComVariant data; 
            m_wndHexEdit.SetData(data); 
        }

        { 
            m_wndFileDetails.ShowWindow(SW_HIDE); 
            m_wndHexEdit.ShowWindow(SW_NORMAL); 
            SetSplitterPane(SPLIT_PANE_RIGHT, m_wndHexEdit); 
        } 

        delete [] byBuff; 
    } 
    else if (pCurrSel && STGTY_STORAGE == pCurrSel->dwStgType) 
    { 
        CComVariant data; 
        m_wndHexEdit.SetData(data); 
        m_wndHexEdit.ShowWindow(SW_HIDE); 

        std::vector<STATSTG_EX> vecFileInfo; 

        CTreeItem tiChild = hItem.GetChild(); 
        while (FALSE == tiChild.IsNull()) 
        { 
            TREE_ITEM_DATA * pData = (TREE_ITEM_DATA *)tiChild.GetData(); 

            STATSTG_EX statstgex; 

            do 
            { 
                if (pData->dwStgType == STGTY_STREAM) 
                { 
                    CComPtr<IStream> spStrm; 
                    hr = pData->spStgOrStrm->QueryInterface(&spStrm); 
                    if (FAILED(hr)) break; 
                    
                    hr = spStrm->Stat(&statstgex, STATFLAG_NONAME); 
                    if (FAILED(hr)) break; 
                } 
                else if (pData->dwStgType == STGTY_STORAGE) 
                { 
                    CComPtr<IStorage> spStg; 
                    hr = pData->spStgOrStrm->QueryInterface(&spStg); 
                    if (FAILED(hr)) break; 
                    
                    hr = spStg->Stat(&statstgex, STATFLAG_NONAME); 
                    if (FAILED(hr)) break; 
                } 
            } while(0); 
            
            statstgex.htiHost = tiChild.m_hTreeItem; 
            
            TCHAR szSwap[MAX_PATH] = { 0 }; 
            tiChild.GetText(szSwap, _countof(szSwap)); 
            TCHAR2WCHAR(szSwap, statstgex.szwName, _countof(statstgex.szwName)); 
            
            vecFileInfo.push_back(statstgex); 

            tiChild = tiChild.GetNextSibling(); 
        } 

        m_wndFileDetails.SetFileInfo(vecFileInfo); 

        m_wndFileDetails.ShowWindow(SW_NORMAL); 
        SetSplitterPane(SPLIT_PANE_RIGHT, m_wndFileDetails); 
    } 

    return 0;
} 
예제 #11
0
void CMainFrame::OnRepair(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
	ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	BOOL bResults;
	BOOL bReturn = FALSE;

	CTreeItem itemSelected = m_viewTree.GetSelectedItem();

	if ( itemSelected.IsNull() )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}
	
	CDiskObjectPtr obj = m_mapObject[itemSelected.GetData()];


	if( dynamic_cast<CDiskObjectComposite *>(obj.get()) == NULL )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}

	CDiskObjectCompositePtr DiskObjectComposite =
		boost::dynamic_pointer_cast<CDiskObjectComposite>(obj);

	if(!((NMT_RAID1 == DiskObjectComposite->GetNDASMediaType() ||
		NMT_RAID4 == DiskObjectComposite->GetNDASMediaType()) &&
		1 == DiskObjectComposite->GetMissingMemberCount()))
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		// TODO : No disk is available
		WTL::CString strMsg;
		strMsg.LoadString( IDS_MAINFRAME_NOT_READY_REPAIR );
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle, 
			MB_OK | MB_ICONERROR
			);
		return;
	}		


	CSelectDiskDlg dlgSelect(IDD_REPAIR);
	CDiskObjectList singleDisks;
	CFindIfVisitor<FALSE> singleDiskFinder;
	singleDisks = singleDiskFinder.FindIf(m_pRoot, IsWritableUnitDisk);

	if ( singleDisks.size() == 0 )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		// TODO : No disk is available
		WTL::CString strMsg;
		strMsg.LoadString( IDS_MAINFRAME_NO_DISK_REPAIR );
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle, 
			MB_OK | MB_ICONWARNING
			);
		return;
	}

	dlgSelect.SetSingleDisks(singleDisks);

	if ( dlgSelect.DoModal() != IDOK )
		return;

	CUnitDiskObjectPtr replaceDisk, sourceDisk;
	sourceDisk = DiskObjectComposite->GetAvailableUnitDisk();
	replaceDisk = dlgSelect.GetSelectedDisk();

	if(NULL == sourceDisk.get())
		return;
	
	NDASCOMM_CONNECTION_INFO ci, ciReplace;

	ZeroMemory(&ci, sizeof(NDASCOMM_CONNECTION_INFO));

	ci.address_type = NDASCOMM_CONNECTION_INFO_TYPE_ADDR_LPX;
	ci.login_type = NDASCOMM_LOGIN_TYPE_NORMAL;
	ci.UnitNo = sourceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
	ci.bWriteAccess = TRUE;
	ci.ui64OEMCode = NULL;
	ci.protocol = NDASCOMM_TRANSPORT_LPX;
	CopyMemory(ci.AddressLPX, 
		sourceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
		LPXADDR_NODE_LENGTH);

	ZeroMemory(&ciReplace, sizeof(NDASCOMM_CONNECTION_INFO));

	ciReplace.address_type = NDASCOMM_CONNECTION_INFO_TYPE_ADDR_LPX;
	ciReplace.login_type = NDASCOMM_LOGIN_TYPE_NORMAL;
	ciReplace.UnitNo = replaceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
	ciReplace.bWriteAccess = TRUE;
	ciReplace.ui64OEMCode = NULL;
	ciReplace.protocol = NDASCOMM_TRANSPORT_LPX;
	CopyMemory(ciReplace.AddressLPX, 
		replaceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
		LPXADDR_NODE_LENGTH);

	bResults = NdasOpRepair(&ci, &ciReplace);

	if(!bResults)
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);

		WTL :: CString strMsg;

		DWORD dwLastError = ::GetLastError();
		strMsg.LoadString(IDS_REPAIR_FAIL);

		ShowErrorMessageBox(strMsg);

		return;
	}

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		CUnitDiskObjectPtr UnitDiskObjectPtr;
		NDAS_UNITDEVICE_ID unitDeviceId;

		CDiskObjectComposite::const_iterator itr;
		for ( itr = DiskObjectComposite->begin(); itr != DiskObjectComposite->end(); ++itr )
		{
			if((dynamic_cast<CEmptyDiskObject*>((*itr).get()) != NULL))
				continue;

			UnitDiskObjectPtr = 
				boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);

			CopyMemory(unitDeviceId.DeviceId.Node, 
				UnitDiskObjectPtr->GetLocation()->GetUnitDiskLocation()->MACAddr, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = 
				UnitDiskObjectPtr->GetLocation()->GetUnitDiskLocation()->UnitNumber;
			HixChangeNotify.Notify(unitDeviceId);
		}

		CopyMemory(unitDeviceId.DeviceId.Node, 
			replaceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr, 
			sizeof(unitDeviceId.DeviceId.Node));
		unitDeviceId.UnitNo = 
			replaceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
		HixChangeNotify.Notify(unitDeviceId);
	}


	CRecoverDlg dlgRecover(
		TRUE, 
        (NMT_RAID1 == DiskObjectComposite->GetNDASMediaType()) ?
		IDS_LOGDEV_TYPE_DISK_RAID1 : IDS_LOGDEV_TYPE_DISK_RAID4,
		IDS_RECOVERDLG_TASK_REPAIR);

	dlgRecover.SetMemberDevice(sourceDisk);
	dlgRecover.DoModal();

	OnRefreshStatus(NULL, NULL, NULL);

	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
	return;
}
예제 #12
0
void CMainFrame::OnContextMenu(HWND /*hWnd*/, CPoint pos)
{
	if(m_bRefreshing)
		return;

	ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus);


	int selectedItemData;

	// get selectedItemData
	{
		CRect rect;
		CPoint posInView;
		CTreeItem itemSelected;		

		// if clicked on tree, we need to change selection
		if (m_viewTree.GetWindowRect( rect ) && rect.PtInRect(pos) )
		{
			// clicked point is inside the tree control
			// Change screen coordinates to client coordinates
			posInView = pos - rect.TopLeft();

			itemSelected = m_viewTree.HitTest( posInView, NULL );

			if(itemSelected.IsNull())
			{
				LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
				return;
			}

			// an item is really selected
			// Change select
			m_viewTree.SelectItem(itemSelected);

			selectedItemData = itemSelected.GetData();
		}
		else if(m_viewList.GetWindowRect( rect ) && rect.PtInRect(pos))
		{
			selectedItemData = m_viewList.GetSelectedItemData();
		}

		if(-1 == selectedItemData)
		{
			LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
			return;
		}

		ATLTRACE(_T("selectedItemData = %d\n"), selectedItemData);

	}

	// Display context menu
	{
		CMenu menu;
		CMenuHandle subMenu;
		CDiskObjectPtr obj = m_mapObject[selectedItemData];
		ATLASSERT( obj.get() != NULL );
		menu.LoadMenu( MAKEINTRESOURCE(IDR_CONTEXT_MENU) );
		subMenu = menu.GetSubMenu(0);
		CObjectUIHandler::GetUIHandler(obj)->InsertMenu(obj, subMenu);
		ATLTRACE(_T("Menu Count : %d"), subMenu.GetMenuItemCount());
		subMenu.RemoveMenu(IDM_AGGR_PROPERTY, MF_BYCOMMAND);
//		subMenu.RemoveMenu(MF_BYPOSITION, subMenu.GetMenuItemCount());
		subMenu.TrackPopupMenu(
			TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
			pos.x, 
			pos.y, 
			m_hWnd
			);
	}

	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
	return;

}