alroyso před 3 roky
rodič
revize
54d1afda63

+ 20 - 0
SProxy/CApp.cpp

@@ -0,0 +1,20 @@
+#include "stdafx.h"
+#include "CApp.h"
+CApp* SSingleton<CApp>::ms_Singleton = NULL;
+CApp::CApp() : m_is_out(0)
+{
+}
+
+CApp::~CApp()
+{
+}
+
+void CApp::SetOut(int out)
+{
+	m_is_out = out;
+}
+
+int CApp::GetOut()
+{
+	return m_is_out;
+}

+ 33 - 0
SProxy/CApp.h

@@ -0,0 +1,33 @@
+#pragma once
+
+
+enum PROXY_MODE {
+
+	sys_mode = 0,
+	tun_mode,
+
+};
+
+
+enum ROUT_MODE {
+
+	cn_mode = 0,
+	qg_mode,
+
+};
+
+
+class CApp : public SSingleton<CApp>
+{
+public:
+	CApp();
+	~CApp();
+
+	void SetOut(int out);
+
+	int GetOut();
+
+private:
+	int m_is_out;
+};
+

binární
SProxy/MainDlg.cpp


binární
SProxy/MainDlg.h


binární
SProxy/SProxy.cpp


+ 6 - 0
SProxy/SProxy.vcxproj

@@ -188,11 +188,14 @@
     <Text Include="readme.txt" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="CApp.cpp" />
     <ClCompile Include="LoginDlg.cpp" />
     <ClCompile Include="MainDlg.cpp" />
     <ClCompile Include="SouiInit.cpp" />
     <ClCompile Include="SProxy.cpp" />
     <ClCompile Include="SRadioBox2.cpp" />
+    <ClCompile Include="SShellNofityHwnd2.cpp" />
+    <ClCompile Include="SShellNotifyIcon.cpp" />
     <ClCompile Include="StabtypeControl.cpp" />
     <ClCompile Include="stdafx.cpp">
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
@@ -205,11 +208,14 @@
     <ResourceCompile Include="SProxy.rc" />
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="CApp.h" />
     <ClInclude Include="LoginDlg.h" />
     <ClInclude Include="MainDlg.h" />
     <ClInclude Include="resource.h" />
     <ClInclude Include="SouiInit.h" />
     <ClInclude Include="SRadioBox2.h" />
+    <ClInclude Include="SShellNofityHwnd2.h" />
+    <ClInclude Include="SShellNotifyIcon.h" />
     <ClInclude Include="StabtypeControl.h" />
     <ClInclude Include="stdafx.h" />
   </ItemGroup>

+ 18 - 0
SProxy/SProxy.vcxproj.filters

@@ -44,6 +44,15 @@
     <ClCompile Include="LoginDlg.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="CApp.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="SShellNofityHwnd2.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="SShellNotifyIcon.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="SProxy.rc">
@@ -72,6 +81,15 @@
     <ClInclude Include="LoginDlg.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="CApp.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="SShellNotifyIcon.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="SShellNofityHwnd2.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="res\soui_res.rc2">

+ 62 - 0
SProxy/SShellNofityHwnd2.cpp

@@ -0,0 +1,62 @@
+#include "stdafx.h"
+#include "SShellNofityHwnd2.h"
+
+namespace SOUI
+{
+	CShellNotifyHwnd2::CShellNotifyHwnd2(SHostWnd * pMainWnd, SShellNotifyIcon* shellnotifyicon) :m_pMainWnd(pMainWnd),m_ShellNotifyIcon(shellnotifyicon)
+	{
+		MsgTaskbarCreated = RegisterWindowMessage(L"TaskbarCreated");
+		Create(L"shell_nofity_msg_windows", 0, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr);
+	}
+
+	//ÍÐÅÌ֪ͨÏûÏ¢´¦Àíº¯Êý
+
+	LRESULT CShellNotifyHwnd2::OnIconNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL)
+	{
+		LRESULT bRet = S_FALSE;
+		switch (lParam)
+		{
+		case  WM_RBUTTONDOWN:
+		{
+			m_ShellNotifyIcon->ShowMenu();
+			bRet = S_OK;
+		}break;
+		case WM_LBUTTONDOWN:
+		{
+			if (m_pMainWnd->IsWindowVisible())
+				m_pMainWnd->ShowWindow(SW_HIDE);
+			else
+			{
+				m_pMainWnd->ShowWindow(SW_SHOW);
+				SetForegroundWindow(m_pMainWnd->m_hWnd);
+			}
+			bRet = S_OK;
+		}break;
+		}
+		return bRet;
+	}
+
+	LRESULT CShellNotifyHwnd2::OnTaskbarCreated(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL)
+	{
+		return m_ShellNotifyIcon->Show();
+	}
+
+	void CShellNotifyHwnd2::OnFinalMessage(HWND hWnd)
+	{
+		__super::OnFinalMessage(hWnd);
+		delete this;
+	}
+
+	void CShellNotifyHwnd2::OnTimer(UINT_PTR nIDEvent)
+	{
+		switch (nIDEvent)
+		{
+		case ANI_TIMER_ID:
+		{
+			m_ShellNotifyIcon->NextFrame();
+		}break;
+		default:
+			break;
+		}
+	}
+}

+ 58 - 0
SProxy/SShellNofityHwnd2.h

@@ -0,0 +1,58 @@
+#pragma once
+#include "core\SimpleWnd.h"
+#include "helper\SMenu.h"
+
+//添加一个事件接收窗口用于专门处理托盘图标
+#ifndef WM_ICONNOTIFY
+#define WM_ICONNOTIFY (WM_USER + 1111)
+#endif // !WM_ICONNOTIFY
+#ifndef ID_TASKBARICON
+#define ID_TASKBARICON	100
+#endif // !ID_TASKBARICON
+#define ANI_TIMER_ID 8
+#include "SShellNotifyIcon.h"
+#define CHAIN_MSG_MAP_MEMBER_PTR(theChainMember) \
+    { \
+	bHandled=FALSE;BOOL bCanChain=TRUE;\
+	if(theChainMember==nullptr||((uMsg!=WM_ICONNOTIFY)&&(uMsg!=WM_COMMAND)))\
+		bCanChain=FALSE;\
+    if(bCanChain&&theChainMember->ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult)) \
+		bHandled=TRUE; \
+		if(bHandled)\
+			return TRUE;\
+    }
+
+
+#if _MSC_VER<1600
+#define nullptr NULL
+#endif
+
+namespace SOUI
+{
+	class SShellNotifyIcon;
+	class CShellNotifyHwnd2 :public CSimpleWnd
+	{
+	public:
+		CShellNotifyHwnd2(SHostWnd* pMainWnd,SShellNotifyIcon* shellnotifyicon);
+		~CShellNotifyHwnd2(){}
+	protected:
+		//托盘通知消息处理函数
+		LRESULT OnIconNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL/* bHandled*/);
+		LRESULT OnTaskbarCreated(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL);
+		virtual void OnFinalMessage(HWND hWnd);
+		void OnTimer(UINT_PTR nIDEvent);
+
+		BEGIN_MSG_MAP_EX(CShellNotifyHwnd2)
+			//托盘消息处理
+			MESSAGE_HANDLER(MsgTaskbarCreated, OnTaskbarCreated)
+			MSG_WM_TIMER(OnTimer)
+			CHAIN_MSG_MAP_MEMBER_PTR(m_pMainWnd)
+			MESSAGE_HANDLER(WM_ICONNOTIFY, OnIconNotify)
+			CHAIN_MSG_MAP(CSimpleWnd)
+		END_MSG_MAP()
+	private:
+		SHostWnd            *m_pMainWnd;
+		SShellNotifyIcon	*m_ShellNotifyIcon;
+		UINT                MsgTaskbarCreated;		
+	};
+}

binární
SProxy/SShellNotifyIcon.cpp


binární
SProxy/SShellNotifyIcon.h


+ 2 - 1
SProxy/SouiInit.cpp

@@ -113,7 +113,8 @@ void SUserObjectDefaultRegister::RegisterWindows(SObjectFactoryMgr * objFactory)
 {	
 #define RegWnd(wndClass) objFactory->TplRegisterFactory<wndClass>();
 	RegWnd(SRadioBox2)
-	RegWnd(StabtypeControl)
+		RegWnd(StabtypeControl)
+		RegWnd(SSkinVScrollbar)
 	//RegWnd(SBrowserTabCtrl)	
 	//RegWnd(CDropWnd)
 	//RegWnd(SRelTabCtrl)

binární
SProxy/res/resource.h


binární
SProxy/res/soui_res.rc2


binární
SProxy/stdafx.h


binární
SProxy/uires/image/btn-border.png


binární
SProxy/uires/image/btn-user.png


binární
SProxy/uires/image/line-2.png


binární
SProxy/uires/image/password.png


binární
SProxy/uires/image/scrollbar.png


binární
SProxy/uires/image/user.png


binární
SProxy/uires/image/vscrollbar__.png


+ 11 - 1
SProxy/uires/uires.idx

@@ -6,6 +6,7 @@
 	<LAYOUT>
 		<file name="XML_MAINWND" path="xml\dlg_main.xml" />
     <file name="XML_LOGIN" path="xml\dlg_login.xml" />
+    <file name="tabtype_control" path="xml\tabtype_control.xml"/>
 	</LAYOUT>
 	<values>
 		<file name="string" path="values\string.xml" />
@@ -16,9 +17,18 @@
   	<file name="bg-login_png" path="image\bg-login.png" />
   	<file name="bg-home_png" path="image\bg-home.png" />
   	<file name="bg-user_png" path="image\bg-user.png" />
+    <file name="ID_DEF_VSCROLL" path="image\scrollbar.png"/>
+    <file name="btn-border" path="image\btn-border.png"/>
+    <file name="bg-user" path="image\bg-user.png"/>
+    <file name="line-2" path="image\line-2.png"/>
+    <file name="user" path="image\user.png"/>
+    <file name="password" path="image\password.png"/>
+      <file name="tyte_selection" path="image\tyte_selection.png"/>
   </IMG>
 	<ICON>
 		<file name="ICON_LOGO" path="image\soui.ico" />
 	</ICON>
- 
+   <SMENU>
+    <file name="menu_tray" path="xml\menu_tray.xml"/>
+  </SMENU>
 </resource>

+ 7 - 0
SProxy/uires/values/skin.xml

@@ -4,4 +4,11 @@
 	<imglist name="bg-login_png" src="img:bg-login_png"/>
 	<imglist name="bg-home_png" src="img:bg-home_png"/>
 	<imglist name="bg-user_png" src="img:bg-user_png"/>
+	<imglist name="skin_btnborder" src="img:btn-border" states="4"/>
+	<imglist name="skin_bguser" src="img:bg-user" />
+	<imglist name="skin_line" src="img:line-2"/>
+	<imglist name="skin_user" src="img:user"/>
+	<imglist name="skin_password" src="img:password"/>
+	<imglist name="skin_tyteselection" src="img:tyte_selection" states="3"/>
+	<vscrollbar name="skin.common.vscroll" src="IMG:ID_DEF_VSCROLL" states="3" margin="3" hasgripper="0"/> 
 </skin>

+ 50 - 0
SProxy/uires/xml/dlg_login.xml

@@ -0,0 +1,50 @@
+<SOUI name="mainWindow" title="@string/title" bigIcon="ICON_LOGO:32" smallIcon="ICON_LOGO:16"  width="414" height="536" margin="5,5,5,5"  resizable="1" wndType="appMain"
+appWnd="1"
+>
+  <root skin="bg-home_png" cache="1">
+    <caption pos="0,0,-0,30" show="1" font="adding:0">
+      <text pos="29,9">@string/title</text>
+      <imgbtn name="btn_close" skin="_skin.sys.btn.close"    pos="-45,0" tip="close" animate="1"/>
+    </caption>
+  <window pos="5,[50,-5,-5">
+    <window size="-2,-2" layout="vbox" gravity="center" >
+
+            <window size="-2,35" layout="hbox"   gravity="center"  extend="47,0,44,0">
+
+                <img skin="skin_user"/>
+
+                <edit name="edit_username" size="247,35" extend="20,0,0,0" colorText="#ffffff"  cueText="Username"/>
+
+            </window>
+
+
+            <img skin="skin_line" extend="60,5,44,0"/>
+
+
+
+            <window size="-2,35" layout="hbox"   gravity="center"  extend="47,50,44,0">
+
+                <img skin="skin_password"/>
+
+                <edit name="edit_password" size="247,35" extend="20,0,0,0" colorText="#ffffff"  cueText="Password"/>
+
+            </window>
+
+
+            <img skin="skin_line" extend="60,5,44,0"/>
+
+            <imgbtn name="onlogin" skin="skin_btnborder"  colorText="#A79BB8" font="adding:12,bold:1"  extend="0,50,0,0">登录</imgbtn>
+
+            <text colorText="#ffffff88" font="adding:5,bold:1" extend="10,25,0,0" >登录服务器选择</text>
+
+            <tabtypecontrol name="nodeclass" size="400,45" gravity="center" extend="47,25,44,0"/>
+                           <!-- <window size="-2,-1" layout="hbox"   gravity="center"  extend="47,19,44,0">
+                                  <radio2 size="0,-1" name="url_txt" colorTextPush="#D8D8D8" colorText="#D8D8D844" font="adding:12,bold:1" checked="1" skin="skin_tyteselection" align="center" weight="1" extend="0,0,0,0" >首选</radio2>
+                                  <radio2 size="0,-1" name="url_txt1" colorTextPush="#D8D8D8" colorText="#D8D8D844" font="adding:12,bold:1" checked="1" skin="skin_tyteselection" align="center" weight="1" extend="0,0,0,0" >备用1</radio2>
+                                  <radio2 size="0,-1" name="url_txt2" colorTextPush="#D8D8D8" colorText="#D8D8D844" font="adding:12,bold:1" checked="1" skin="skin_tyteselection" align="center" weight="1" extend="0,0,0,0" >备用2</radio2>
+                            </window> -->
+
+     </window>
+    </window>
+  </root>
+</SOUI>

+ 7 - 1
SProxy/uires/xml/dlg_main.xml

@@ -7,6 +7,12 @@ appWnd="1"
       <imgbtn name="btn_close" skin="_skin.sys.btn.close"    pos="-45,0" tip="close" animate="1"/>
     </caption>
  
-    
+    <window pos="5,[2,-5,-5">
+
+
+    </window>
+
+
+     <shellnotifyicon id="110" menu="SMENU:menu_tray" ico="ICON_LOGO:16" tip="退出"/>
   </root>
 </SOUI>

+ 3 - 0
SProxy/uires/xml/menu_tray.xml

@@ -0,0 +1,3 @@
+<menu itemHeight="26" iconMargin="4" textMargin="8">
+  <item id="6">退出</item>
+</menu>

+ 5 - 0
SProxy/uires/xml/tabtype_control.xml

@@ -0,0 +1,5 @@
+<tabtypecontrol>
+  <window size="-2,-2" layout="hbox" extend="0,0,0,0" name="con">
+   
+  </window>
+</tabtypecontrol>

+ 56 - 0
__INCLUDE/SVscrollbar.h

@@ -0,0 +1,56 @@
+#pragma once
+namespace SOUI{
+
+//实现一个只有纵向滚动条皮肤
+/*img format: 1-normal, 2-hover, 3-pushdown, 4-disable
+1 2 3 4 //for thumb
+1 2 3 4 //for rail
+*/
+class SSkinVScrollbar : public SSkinScrollbar
+{
+	SOUI_CLASS_NAME(SSkinVScrollbar, L"vscrollbar")
+
+public:
+
+	SSkinVScrollbar()
+	{
+        m_nStates=4;
+	}
+
+	//不支持显示上下箭头
+	virtual BOOL HasArrow(){return FALSE;}
+	virtual int GetIdealSize(){
+        if(!GetImage()) return 0;
+        return GetImage()->Width()/m_nStates;
+	}
+protected:
+	//返回源指定部分在原位图上的位置。
+	virtual CRect GetPartRect(int nSbCode, int nState,BOOL bVertical)
+	{
+		CRect rc;
+		if(!bVertical 
+            || nSbCode==SB_LINEDOWN 
+            || nSbCode==SB_LINEUP 
+            || nSbCode == SB_CORNOR 
+            || nSbCode==SB_THUMBGRIPPER) 
+            return rc;
+
+        if(nState==SBST_INACTIVE && !m_bHasInactive)
+        {
+            nState=SBST_NORMAL;
+        }
+
+        SASSERT(GetImage());
+        rc.right = GetImage()->Width()/m_nStates;
+        rc.bottom = GetImage()->Height()/2;
+        
+		rc.OffsetRect(rc.Width()*nState,0);
+        if(nSbCode == SB_PAGEUP || nSbCode == SB_PAGEDOWN)
+        {
+            rc.OffsetRect(0,rc.Height());
+        }
+		return rc;
+	}
+};
+
+}