├── setup.ico ├── Notes ├── Notes.rc ├── resource.h ├── NoteDlg.cpp ├── NotesDlg.cpp ├── defintion.h ├── app │ ├── AppCtrl.cpp │ ├── AppCtrl.h │ ├── Config.h │ ├── NoteConfig.h │ ├── Note.h │ ├── Note.cpp │ ├── Config.cpp │ └── NoteConfig.cpp ├── res │ ├── Notes.ico │ └── Notes.rc2 ├── stdafx.cpp ├── ref │ ├── XFile.h │ ├── RawInput.h │ ├── Utility.h │ ├── Log.h │ ├── HotKey.h │ ├── Cvt.h │ ├── RawInput.cpp │ ├── XFile.cpp │ ├── Registry.h │ ├── Shell.h │ ├── Cvt.cpp │ ├── HotKey.cpp │ ├── Utility.cpp │ ├── Ini.h │ ├── Log.cpp │ ├── Ini.cpp │ ├── Registry.cpp │ ├── Shell.cpp │ ├── Path.h │ └── Path.cpp ├── targetver.h ├── packages.config ├── Notes.h ├── control │ ├── HotKeyEdit.h │ └── HotKeyEdit.cpp ├── NotesDlg.h ├── NoteDlg.h ├── Notes.cpp ├── stdafx.h ├── ReadMe.txt └── Notes.vcxproj.filters ├── themes ├── default │ ├── src │ │ ├── themes │ │ │ ├── tailwind.scss │ │ │ ├── style.scss │ │ │ └── app.scss │ │ ├── components │ │ │ ├── icons │ │ │ │ ├── IconSupport.vue │ │ │ │ ├── IconTooling.vue │ │ │ │ ├── IconCommunity.vue │ │ │ │ ├── IconDocumentation.vue │ │ │ │ └── IconEcosystem.vue │ │ │ ├── HelloWorld.vue │ │ │ ├── WelcomeItem.vue │ │ │ └── TheWelcome.vue │ │ ├── router │ │ │ └── index.ts │ │ ├── stores │ │ │ └── counter.ts │ │ ├── main.ts │ │ ├── views │ │ │ ├── HomeView.vue │ │ │ └── NoteItem.vue │ │ ├── utils │ │ │ └── index.ts │ │ └── App.vue │ ├── public │ │ ├── logo.png │ │ └── favicon.ico │ ├── .vscode │ │ └── extensions.json │ ├── postcss.config.js │ ├── .prettierrc.json │ ├── tsconfig.json │ ├── env.d.ts │ ├── tailwind.config.js │ ├── tsconfig.app.json │ ├── .gitignore │ ├── tsconfig.node.json │ ├── .eslintrc.cjs │ ├── vite.config.ts │ ├── index.html │ ├── README.md │ └── package.json └── simple │ ├── src │ ├── themes │ │ ├── tailwind.scss │ │ ├── style.scss │ │ └── app.scss │ ├── components │ │ ├── icons │ │ │ ├── IconSupport.vue │ │ │ ├── IconTooling.vue │ │ │ ├── IconCommunity.vue │ │ │ ├── IconDocumentation.vue │ │ │ └── IconEcosystem.vue │ │ ├── HelloWorld.vue │ │ ├── WelcomeItem.vue │ │ └── TheWelcome.vue │ ├── router │ │ └── index.ts │ ├── stores │ │ └── counter.ts │ ├── main.ts │ ├── views │ │ ├── HomeView.vue │ │ └── NoteItem.vue │ ├── utils │ │ └── index.ts │ └── App.vue │ ├── public │ ├── logo.png │ └── favicon.ico │ ├── .vscode │ └── extensions.json │ ├── postcss.config.js │ ├── .prettierrc.json │ ├── tsconfig.json │ ├── env.d.ts │ ├── tailwind.config.js │ ├── tsconfig.app.json │ ├── .gitignore │ ├── tsconfig.node.json │ ├── .eslintrc.cjs │ ├── vite.config.ts │ ├── index.html │ ├── README.md │ └── package.json ├── .gitignore ├── README.md ├── Notes.sln ├── setup.iss └── setupx64.iss /setup.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/setup.ico -------------------------------------------------------------------------------- /Notes/Notes.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/Notes/Notes.rc -------------------------------------------------------------------------------- /Notes/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/Notes/resource.h -------------------------------------------------------------------------------- /Notes/NoteDlg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/Notes/NoteDlg.cpp -------------------------------------------------------------------------------- /Notes/NotesDlg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/Notes/NotesDlg.cpp -------------------------------------------------------------------------------- /Notes/defintion.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/Notes/defintion.h -------------------------------------------------------------------------------- /Notes/app/AppCtrl.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/Notes/app/AppCtrl.cpp -------------------------------------------------------------------------------- /Notes/res/Notes.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/Notes/res/Notes.ico -------------------------------------------------------------------------------- /Notes/res/Notes.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/Notes/res/Notes.rc2 -------------------------------------------------------------------------------- /themes/default/src/themes/tailwind.scss: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; -------------------------------------------------------------------------------- /themes/simple/src/themes/tailwind.scss: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; -------------------------------------------------------------------------------- /themes/default/src/themes/style.scss: -------------------------------------------------------------------------------- 1 | @import 'app.scss'; 2 | @import 'tailwind.scss'; 3 | @import 'markdown.scss' -------------------------------------------------------------------------------- /themes/simple/src/themes/style.scss: -------------------------------------------------------------------------------- 1 | @import 'app.scss'; 2 | @import 'tailwind.scss'; 3 | @import 'markdown.scss' -------------------------------------------------------------------------------- /themes/default/public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/themes/default/public/logo.png -------------------------------------------------------------------------------- /themes/simple/public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/themes/simple/public/logo.png -------------------------------------------------------------------------------- /themes/default/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] 3 | } 4 | -------------------------------------------------------------------------------- /themes/default/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/themes/default/public/favicon.ico -------------------------------------------------------------------------------- /themes/simple/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] 3 | } 4 | -------------------------------------------------------------------------------- /themes/simple/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imlinhanchao/sticky_notes/HEAD/themes/simple/public/favicon.ico -------------------------------------------------------------------------------- /themes/default/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /themes/simple/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /themes/default/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/prettierrc", 3 | "semi": false, 4 | "tabWidth": 2, 5 | "singleQuote": true, 6 | "printWidth": 100, 7 | "trailingComma": "none" 8 | } -------------------------------------------------------------------------------- /themes/default/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { 5 | "path": "./tsconfig.node.json" 6 | }, 7 | { 8 | "path": "./tsconfig.app.json" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /themes/simple/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/prettierrc", 3 | "semi": false, 4 | "tabWidth": 2, 5 | "singleQuote": true, 6 | "printWidth": 100, 7 | "trailingComma": "none" 8 | } -------------------------------------------------------------------------------- /themes/simple/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { 5 | "path": "./tsconfig.node.json" 6 | }, 7 | { 8 | "path": "./tsconfig.app.json" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /themes/default/env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | declare module '*.vue' { 3 | import { defineComponent } from 'vue' 4 | const Component: ReturnType 5 | export default Component 6 | } -------------------------------------------------------------------------------- /themes/simple/env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | declare module '*.vue' { 3 | import { defineComponent } from 'vue' 4 | const Component: ReturnType 5 | export default Component 6 | } -------------------------------------------------------------------------------- /Notes/stdafx.cpp: -------------------------------------------------------------------------------- 1 | 2 | // stdafx.cpp : source file that includes just the standard includes 3 | // Notes.pch will be the pre-compiled header 4 | // stdafx.obj will contain the pre-compiled type information 5 | 6 | #include "stdafx.h" 7 | 8 | 9 | -------------------------------------------------------------------------------- /themes/default/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'], 4 | theme: { 5 | extend: {}, 6 | }, 7 | plugins: [], 8 | } 9 | 10 | -------------------------------------------------------------------------------- /themes/simple/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'], 4 | theme: { 5 | extend: {}, 6 | }, 7 | plugins: [], 8 | } 9 | 10 | -------------------------------------------------------------------------------- /Notes/ref/XFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Easy { 4 | 5 | class XFile 6 | { 7 | public: 8 | static bool ReadFile(CString sFile, CString& data); 9 | static bool WriteFile(CString sFile, CString data); 10 | static bool AppendFile(CString sFile, CString data); 11 | }; 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /themes/default/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@vue/tsconfig/tsconfig.dom.json", 3 | "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], 4 | "exclude": ["src/**/__tests__/*"], 5 | "compilerOptions": { 6 | "composite": true, 7 | "baseUrl": ".", 8 | "paths": { 9 | "@/*": ["./src/*"] 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /themes/simple/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@vue/tsconfig/tsconfig.dom.json", 3 | "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], 4 | "exclude": ["src/**/__tests__/*"], 5 | "compilerOptions": { 6 | "composite": true, 7 | "baseUrl": ".", 8 | "paths": { 9 | "@/*": ["./src/*"] 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Notes/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Notes/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /themes/default/src/components/icons/IconSupport.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /themes/simple/src/components/icons/IconSupport.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /Notes/app/AppCtrl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "NoteDlg.h" 3 | 4 | class CAppCtrl 5 | { 6 | public: 7 | CAppCtrl(void); 8 | ~CAppCtrl(void); 9 | 10 | void Init(); 11 | void New(CString sName = _T("")); 12 | bool CheckEdit(); 13 | void MouseThrough(bool bThrough=true); 14 | void Visible(bool bShow); 15 | 16 | private: 17 | vector m_NoteListDlg; 18 | }; 19 | 20 | -------------------------------------------------------------------------------- /themes/default/src/router/index.ts: -------------------------------------------------------------------------------- 1 | import { createRouter, createWebHashHistory } from 'vue-router' 2 | import HomeView from '../views/HomeView.vue' 3 | 4 | const router = createRouter({ 5 | history: createWebHashHistory(), 6 | routes: [ 7 | { 8 | path: '/', 9 | name: 'home', 10 | component: HomeView 11 | } 12 | ] 13 | }) 14 | 15 | export default router 16 | -------------------------------------------------------------------------------- /themes/default/src/stores/counter.ts: -------------------------------------------------------------------------------- 1 | import { ref, computed } from 'vue' 2 | import { defineStore } from 'pinia' 3 | 4 | export const useCounterStore = defineStore('counter', () => { 5 | const count = ref(0) 6 | const doubleCount = computed(() => count.value * 2) 7 | function increment() { 8 | count.value++ 9 | } 10 | 11 | return { count, doubleCount, increment } 12 | }) 13 | -------------------------------------------------------------------------------- /themes/simple/src/router/index.ts: -------------------------------------------------------------------------------- 1 | import { createRouter, createWebHashHistory } from 'vue-router' 2 | import HomeView from '../views/HomeView.vue' 3 | 4 | const router = createRouter({ 5 | history: createWebHashHistory(), 6 | routes: [ 7 | { 8 | path: '/', 9 | name: 'home', 10 | component: HomeView 11 | } 12 | ] 13 | }) 14 | 15 | export default router 16 | -------------------------------------------------------------------------------- /themes/simple/src/stores/counter.ts: -------------------------------------------------------------------------------- 1 | import { ref, computed } from 'vue' 2 | import { defineStore } from 'pinia' 3 | 4 | export const useCounterStore = defineStore('counter', () => { 5 | const count = ref(0) 6 | const doubleCount = computed(() => count.value * 2) 7 | function increment() { 8 | count.value++ 9 | } 10 | 11 | return { count, doubleCount, increment } 12 | }) 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | *release 3 | *debug 4 | *debughttp 5 | *ipch 6 | *.sdf 7 | *.aps 8 | *.user 9 | *.opensdf 10 | *.suo 11 | *.tmp 12 | *.zip 13 | *.rar 14 | *.7z 15 | _* 16 | Thumbs.db 17 | *.obj 18 | *.pdb 19 | *.user 20 | *.aps 21 | *.pch 22 | *.vspscc 23 | *_i.c 24 | *_p.c 25 | *.ncb 26 | *.suo 27 | *.tlb 28 | *.tlh 29 | *.bak 30 | *.cache 31 | *.ilk 32 | *.log 33 | *.lib 34 | *.sbr 35 | obj/ 36 | _ReSharper*/ 37 | .vs/ 38 | packages/ 39 | output/ -------------------------------------------------------------------------------- /themes/default/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | .DS_Store 12 | dist 13 | dist-ssr 14 | coverage 15 | *.local 16 | 17 | /cypress/videos/ 18 | /cypress/screenshots/ 19 | 20 | # Editor directories and files 21 | .vscode/* 22 | !.vscode/extensions.json 23 | .idea 24 | *.suo 25 | *.ntvs* 26 | *.njsproj 27 | *.sln 28 | *.sw? 29 | -------------------------------------------------------------------------------- /themes/simple/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | .DS_Store 12 | dist 13 | dist-ssr 14 | coverage 15 | *.local 16 | 17 | /cypress/videos/ 18 | /cypress/screenshots/ 19 | 20 | # Editor directories and files 21 | .vscode/* 22 | !.vscode/extensions.json 23 | .idea 24 | *.suo 25 | *.ntvs* 26 | *.njsproj 27 | *.sln 28 | *.sw? 29 | -------------------------------------------------------------------------------- /themes/default/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node18/tsconfig.json", 3 | "include": ["vite.config.*", "vitest.config.*", "cypress.config.*", "playwright.config.*"], 4 | "compilerOptions": { 5 | "composite": true, 6 | "module": "esnext", 7 | "allowSyntheticDefaultImports": true, 8 | "moduleResolution": "node", 9 | "resolveJsonModule": true, 10 | "types": [ 11 | "element-plus/global" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /themes/simple/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node18/tsconfig.json", 3 | "include": ["vite.config.*", "vitest.config.*", "cypress.config.*", "playwright.config.*"], 4 | "compilerOptions": { 5 | "composite": true, 6 | "module": "esnext", 7 | "allowSyntheticDefaultImports": true, 8 | "moduleResolution": "node", 9 | "resolveJsonModule": true, 10 | "types": [ 11 | "element-plus/global" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Notes/ref/RawInput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Easy { 4 | 5 | typedef enum RAW_TYPE 6 | { 7 | RAW_TYPE_HID = 0x01, 8 | RAW_TYPE_KB = 0x02, 9 | RAW_TYPE_MS = 0x04, 10 | }; 11 | 12 | class CRawInput 13 | { 14 | CRawInput(); 15 | ~CRawInput(); 16 | 17 | public: 18 | static bool Register(HWND hWnd, WORD wRawType); 19 | static bool Remove(HWND hWnd, WORD wRawType); 20 | 21 | private: 22 | static bool SetRawInput(HWND hWnd, WORD wRawType, bool bRegister); 23 | }; 24 | 25 | } -------------------------------------------------------------------------------- /themes/default/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | require('@rushstack/eslint-patch/modern-module-resolution') 3 | 4 | module.exports = { 5 | root: true, 6 | 'extends': [ 7 | 'plugin:vue/vue3-essential', 8 | 'eslint:recommended', 9 | '@vue/eslint-config-typescript', 10 | '@vue/eslint-config-prettier/skip-formatting' 11 | ], 12 | parserOptions: { 13 | ecmaVersion: 'latest' 14 | }, 15 | overrides: [ 16 | { 17 | files: ['*.config.js'], 18 | env: { 19 | node: true, 20 | }, 21 | }, 22 | ], 23 | } 24 | -------------------------------------------------------------------------------- /themes/simple/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | require('@rushstack/eslint-patch/modern-module-resolution') 3 | 4 | module.exports = { 5 | root: true, 6 | 'extends': [ 7 | 'plugin:vue/vue3-essential', 8 | 'eslint:recommended', 9 | '@vue/eslint-config-typescript', 10 | '@vue/eslint-config-prettier/skip-formatting' 11 | ], 12 | parserOptions: { 13 | ecmaVersion: 'latest' 14 | }, 15 | overrides: [ 16 | { 17 | files: ['*.config.js'], 18 | env: { 19 | node: true, 20 | }, 21 | }, 22 | ], 23 | } 24 | -------------------------------------------------------------------------------- /Notes/ref/Utility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Easy 4 | { 5 | 6 | typedef struct _MODULE_VER { // Module version 7 | WORD wMajor; 8 | WORD wMinor; 9 | WORD wRevision; 10 | WORD wBuild; 11 | 12 | CString ToString() 13 | { 14 | return Cvt::ToString(_T("%d.%d.%d"), wMajor, wMinor, wRevision); 15 | } 16 | }MODULE_VER; 17 | 18 | class Utility 19 | { 20 | public: 21 | static bool IsWow64(); 22 | static MODULE_VER GetVersion(CString sModuleName); 23 | static void SetAutoRun(bool bAuto); 24 | static HANDLE ProgramLock(CString sInstanceName); 25 | }; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /themes/simple/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { fileURLToPath, URL } from 'node:url' 2 | import legacy from '@vitejs/plugin-legacy' 3 | 4 | import { defineConfig } from 'vite' 5 | import vue from '@vitejs/plugin-vue' 6 | 7 | // https://vitejs.dev/config/ 8 | export default defineConfig({ 9 | base: './', 10 | plugins: [ 11 | legacy({ 12 | targets: ['defaults', 'not IE 11'] 13 | }), 14 | vue() 15 | ], 16 | resolve: { 17 | alias: { 18 | '@': fileURLToPath(new URL('./src', import.meta.url)) 19 | } 20 | }, 21 | build: { 22 | minify: 'terser' 23 | } 24 | }) 25 | -------------------------------------------------------------------------------- /themes/default/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { fileURLToPath, URL } from 'node:url' 2 | import legacy from '@vitejs/plugin-legacy' 3 | 4 | import { defineConfig } from 'vite' 5 | import vue from '@vitejs/plugin-vue' 6 | 7 | // https://vitejs.dev/config/ 8 | export default defineConfig({ 9 | base: './', 10 | plugins: [ 11 | legacy({ 12 | targets: ['defaults', 'not IE 11'] 13 | }), 14 | vue() 15 | ], 16 | resolve: { 17 | alias: { 18 | '@': fileURLToPath(new URL('./src', import.meta.url)) 19 | } 20 | }, 21 | build: { 22 | minify: 'terser' 23 | } 24 | }) 25 | -------------------------------------------------------------------------------- /Notes/Notes.h: -------------------------------------------------------------------------------- 1 | 2 | // Notes.h : main header file for the PROJECT_NAME application 3 | // 4 | 5 | #pragma once 6 | 7 | #ifndef __AFXWIN_H__ 8 | #error "include 'stdafx.h' before including this file for PCH" 9 | #endif 10 | 11 | #include "resource.h" // main symbols 12 | 13 | 14 | // CNotesApp: 15 | // See Notes.cpp for the implementation of this class 16 | // 17 | 18 | class CNotesApp : public CWinApp 19 | { 20 | public: 21 | CNotesApp(); 22 | 23 | // Overrides 24 | public: 25 | virtual BOOL InitInstance(); 26 | 27 | // Implementation 28 | 29 | DECLARE_MESSAGE_MAP() 30 | }; 31 | 32 | extern CNotesApp theApp; -------------------------------------------------------------------------------- /Notes/app/Config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CConfig 4 | { 5 | public: 6 | static void LoadNoteGroup(vector &lstName); 7 | static bool GetNoteGroup(CString sName, NoteGroup &group); 8 | static void SetNoteGroup(NoteGroup group); 9 | static bool RenameNoteGroup(CString sOldName, CString sNewName); 10 | 11 | static void LoadSetting(Setting &setting); 12 | static void SaveSetting(Setting setting); 13 | static Setting& GetCurrentSetting(); 14 | 15 | static void SearchThemes(vector& lstName); 16 | 17 | static CString NotesDir(); 18 | 19 | private: 20 | static Setting m_setting; 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 |

Sticky Notes | 贴纸便签

6 | 7 | 这是一个 Windows 桌面应用,可以用来记录你的工作事项,然后钉在桌面上,随时可以查看修改。不需要修改的时候,可以完全成为桌面上一个半透明的区块,而不会影响到你的工作。 8 | 9 | ## ✨ 功能 10 | 1. 📝 新建便签 11 | 2. 📌 钉在桌面上 12 | 13 | ## 使用方法 14 | 1. 下载 [Sticky Notes](https://github.com/imlinhanchao/sticky_notes/releases)。 15 | 2. 运行 `Notes.exe`。 16 | 3. 按下快捷键 `Win + Shift + F8` 新建便签。 17 | 4. 写上你的工作事项,然后按下 `Ctrl + Enter` 添加。 18 | 5. 完成编写后,点击便签右上角的⚪,转为半透明。 19 | 6. 点击便签右上角的🔒,可以锁定便签,然后就无法点击到了。 20 | 7. 需要修改便签内容时,把鼠标移动到便签上,按下快捷键 `Win + Shift + F7`,解锁便签。 21 | 8. 快捷键可以在系统托盘的图标右键菜单 `Setting` 中修改。 22 | 23 | > 使用有任何需求改进,欢迎给我提出 issue ~ 24 | 25 | -------------------------------------------------------------------------------- /Notes/app/NoteConfig.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CNoteConfig 4 | { 5 | public: 6 | static void LoadNoteGroup(vector &lstName); 7 | static bool GetNoteGroup(CString sName, NoteGroup &group); 8 | static void SetNoteGroup(NoteGroup group); 9 | static bool RenameNoteGroup(CString sOldName, CString sNewName); 10 | 11 | static void LoadSetting(Setting &setting); 12 | static void SaveSetting(Setting setting); 13 | static Setting& GetCurrentSetting(); 14 | 15 | static void SearchThemes(vector& lstName); 16 | 17 | static CString NotesDir(); 18 | 19 | static CString GetJsonString(rapidjson::GenericValue>& data); 20 | 21 | private: 22 | static Setting m_setting; 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /Notes/app/Note.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CNote 4 | { 5 | public: 6 | CNote(); 7 | CNote(CString sName); 8 | ~CNote(void); 9 | 10 | bool Create(CString sName); 11 | bool Rename(CString sName); 12 | CString GetName(); 13 | 14 | NoteGroup& GetNoteGroup(); 15 | void SetNoteGroup(NoteGroup group); 16 | void SetNoteItems(vector items); 17 | 18 | void SetNoteItem(NoteItem item, int nIndex, bool bNew = false); 19 | void UpdateRect(CRect rc); 20 | void UpdateOpacity(int nOpacity); 21 | void UpdateOpacityAble(bool bOpacityAble); 22 | void UpdateTopMost(bool bTopMost); 23 | void UpdateBgColor(COLORREF clrBg); 24 | void UpdateTitle(CString sTitle); 25 | void MakeTask(NoteItem item); 26 | void Hide(); 27 | void Clear(); 28 | 29 | private: 30 | NoteGroup m_noteGroup; 31 | }; 32 | 33 | -------------------------------------------------------------------------------- /Notes/ref/Log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef enum { 4 | LOG_FILE = 1 << 0, 5 | LOG_PRINT = 1 << 1, 6 | LOG_DEBUG = 1 << 2, 7 | LOG_LIST = 1 << 3, 8 | LOG_ALL = 0xffffff 9 | }LOG_TYPE; 10 | 11 | 12 | class CLogApp 13 | { 14 | public: 15 | CLogApp(void); 16 | ~CLogApp(void); 17 | 18 | static void SetList(CListBox* pList) { m_pListBox = pList; } 19 | static void Init(DWORD dwType, CString sPath=_T("")); 20 | static CString Write(const TCHAR* pszFormat, ...); 21 | static CString Debug(const TCHAR* pszFormat, ...); 22 | static CString Print(const TCHAR* pszFormat, ...); 23 | static CString List(const TCHAR* pszFormat, ...); 24 | static CString WriteFile(const TCHAR* pszFormat, ...); 25 | private: 26 | static CString GetCurDirectory(); 27 | 28 | static DWORD m_dwLogType; 29 | static CString m_sPath; 30 | static CListBox* m_pListBox; 31 | }; 32 | -------------------------------------------------------------------------------- /themes/default/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 17 | 18 | 41 | -------------------------------------------------------------------------------- /themes/simple/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 17 | 18 | 41 | -------------------------------------------------------------------------------- /Notes/ref/HotKey.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Easy { 4 | 5 | typedef void (CALLBACK* HOTKEYCALLBACK)(LPVOID lpParam); 6 | typedef struct _HOTKEY_CALL 7 | { 8 | HOTKEYCALLBACK callback; 9 | LPVOID lpParam; 10 | } HOTKEY_CALL, *PHOTKEY_CALL; 11 | 12 | class CHotKey 13 | { 14 | public: 15 | CHotKey(void); 16 | ~CHotKey(void); 17 | 18 | static bool SetWithCall(DWORD dwHotKey, HOTKEYCALLBACK pCallback, LPVOID lpParam, HWND hWnd = NULL); 19 | static bool RemoveHotKey(DWORD dwHotKey, HWND hWnd = NULL); 20 | static bool SetHotKey(DWORD dwHotKey, HWND hWnd = NULL); 21 | static CString GetHotKeyName(DWORD dwHotKey); 22 | static USHORT GetHotKeyCode(CString sHotKey); 23 | 24 | static void Execute(DWORD dwHotKey); 25 | 26 | protected: 27 | static UINT GetModifiers(DWORD dwHotKey); 28 | static bool IsExtendedKey(DWORD vKey); 29 | 30 | static map m_HotKeyCallback; 31 | }; 32 | 33 | } -------------------------------------------------------------------------------- /themes/default/src/main.ts: -------------------------------------------------------------------------------- 1 | import { library } from "@fortawesome/fontawesome-svg-core"; 2 | import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; 3 | import { fas } from "@fortawesome/free-solid-svg-icons"; 4 | import { far } from "@fortawesome/free-regular-svg-icons"; 5 | import { fab } from "@fortawesome/free-brands-svg-icons"; 6 | import ElementPlus from "element-plus"; 7 | import "./themes/style.scss"; 8 | import "element-plus/dist/index.css"; 9 | import "element-plus/theme-chalk/dark/css-vars.css"; 10 | 11 | import { createApp } from 'vue' 12 | import { createPinia } from 'pinia' 13 | 14 | import App from './App.vue' 15 | import router from './router' 16 | 17 | library.add(fas) 18 | library.add(far) 19 | library.add(fab) 20 | 21 | const app = createApp(App) 22 | app.use(createPinia()) 23 | app.component("font-awesome-icon", FontAwesomeIcon) 24 | app.use(router); 25 | app.use(ElementPlus).mount('#app') 26 | -------------------------------------------------------------------------------- /themes/simple/src/main.ts: -------------------------------------------------------------------------------- 1 | import { library } from "@fortawesome/fontawesome-svg-core"; 2 | import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; 3 | import { fas } from "@fortawesome/free-solid-svg-icons"; 4 | import { far } from "@fortawesome/free-regular-svg-icons"; 5 | import { fab } from "@fortawesome/free-brands-svg-icons"; 6 | import ElementPlus from "element-plus"; 7 | import "./themes/style.scss"; 8 | import "element-plus/dist/index.css"; 9 | import "element-plus/theme-chalk/dark/css-vars.css"; 10 | 11 | import { createApp } from 'vue' 12 | import { createPinia } from 'pinia' 13 | 14 | import App from './App.vue' 15 | import router from './router' 16 | 17 | library.add(fas) 18 | library.add(far) 19 | library.add(fab) 20 | 21 | const app = createApp(App) 22 | app.use(createPinia()) 23 | app.component("font-awesome-icon", FontAwesomeIcon) 24 | app.use(router); 25 | app.use(ElementPlus).mount('#app') 26 | -------------------------------------------------------------------------------- /themes/simple/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Sticky 8 | 28 | 29 | 30 |
31 | 32 |
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /themes/default/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Sticky 8 | 28 | 29 | 30 |
31 | 32 |
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /themes/default/src/components/icons/IconTooling.vue: -------------------------------------------------------------------------------- 1 | 2 | 20 | -------------------------------------------------------------------------------- /themes/simple/src/components/icons/IconTooling.vue: -------------------------------------------------------------------------------- 1 | 2 | 20 | -------------------------------------------------------------------------------- /Notes/ref/Cvt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define _ttof _tstof 4 | 5 | namespace Easy { 6 | 7 | class Cvt 8 | { 9 | public: 10 | static COleDateTime ToDateTime(CString sDateTime); // 'YYYY-MM-DD HH:mm:SS' -> DateTime 11 | 12 | static CString ToString(bool bValue); // true -> '1'; false -> '0'; 13 | static CString ToString(int nValue); 14 | static CString ToString(long nValue); 15 | static CString ToString(UINT nValue); 16 | static CString ToString(DWORD dwValue); 17 | static CString ToString(float fValue, int nPrecision=0); // P=0 -> No limited; P=1 -> '0.0'; P=2 -> '0.00'; ... 18 | static CString ToString(double fValue, int nPrecision=0); 19 | static CString ToString(COleDateTime date); // DateTime -> 'YYYY-MM-DD HH:mm:SS' 20 | static CString ToString(const TCHAR* pszFormat, ...); 21 | static CString ToString(CTime time, CString sFormat=_T("%Y-%m-%d %H:%M:%S")); 22 | static vector SplitString(CString sData, CString sSp); 23 | static CString ToHex(COLORREF color); 24 | static COLORREF ToColor(CString sHex); 25 | 26 | }; 27 | 28 | } -------------------------------------------------------------------------------- /Notes/control/HotKeyEdit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "afxwin.h" 3 | 4 | class CHotKeyEdit : public CEdit 5 | { 6 | public: 7 | CHotKeyEdit(void); 8 | ~CHotKeyEdit(void); 9 | 10 | enum { SHIFT = 1, CONTROL= 2, ALT = 4, WIN = 8 }; 11 | 12 | void SetSingleKey(bool bSingle, bool bHotKey=false); 13 | 14 | private: 15 | afx_msg void OnRawInput(UINT nInputcode, HRAWINPUT hRawInput); 16 | afx_msg void OnEnSetfocus(); 17 | afx_msg void OnEnKillfocus(); 18 | afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); 19 | afx_msg void OnTimer(UINT_PTR nIDEvent); 20 | virtual BOOL PreTranslateMessage(MSG* pMsg); 21 | 22 | DECLARE_MESSAGE_MAP() 23 | 24 | void PushKey(USHORT vKeyCode); 25 | void PopKey( USHORT vKeyCode ); 26 | void ShowKeys(void); 27 | bool IsExtendKey(USHORT vKeyCode); 28 | 29 | USHORT m_uKeyCode; 30 | bool m_bSingleKey; 31 | bool m_bHotKey; 32 | bool m_bRecord; 33 | USHORT m_uExtendKey; 34 | 35 | public: 36 | static DWORD GetHotKeyByString(CString sHotKey); 37 | void SetHotKey(DWORD dwHotKey); 38 | DWORD GetHotKey(void); 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /themes/default/src/components/icons/IconCommunity.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /themes/simple/src/components/icons/IconCommunity.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /themes/simple/src/components/icons/IconDocumentation.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /themes/default/src/components/icons/IconDocumentation.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /Notes/ref/RawInput.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "RawInput.h" 3 | 4 | namespace Easy { 5 | 6 | CRawInput::CRawInput() 7 | { 8 | 9 | } 10 | 11 | CRawInput::~CRawInput() 12 | { 13 | 14 | } 15 | 16 | bool CRawInput::SetRawInput(HWND hWnd, WORD wRawType, bool bRegister) 17 | { 18 | RAWINPUTDEVICE rid[3]; 19 | memset (rid, 0, sizeof (rid)); 20 | 21 | int n = 0; 22 | 23 | if (RAW_TYPE_HID & wRawType) 24 | { 25 | rid[n].usUsagePage = 0xFF00; 26 | rid[n].usUsage = 0x01; 27 | rid[n].dwFlags = bRegister ? RIDEV_INPUTSINK : RIDEV_REMOVE; 28 | rid[n].hwndTarget = bRegister ? hWnd : NULL; 29 | n++; 30 | } 31 | 32 | if (RAW_TYPE_KB & wRawType) 33 | { 34 | rid[n].usUsagePage = 0x01; 35 | rid[n].usUsage = 0x06; 36 | rid[n].dwFlags = bRegister ? RIDEV_INPUTSINK | RIDEV_NOHOTKEYS : RIDEV_REMOVE; 37 | rid[n].hwndTarget = bRegister ? hWnd : NULL; 38 | n++; 39 | } 40 | 41 | if (RAW_TYPE_MS & wRawType) 42 | { 43 | rid[n].usUsagePage = 0x01; 44 | rid[n].usUsage = 0x02; 45 | rid[n].dwFlags = bRegister ? RIDEV_INPUTSINK : RIDEV_REMOVE; 46 | rid[n].hwndTarget = bRegister ? hWnd : NULL; 47 | n++; 48 | } 49 | 50 | return RegisterRawInputDevices(rid, n, sizeof (RAWINPUTDEVICE)) == TRUE; // Register listen device input 51 | } 52 | 53 | bool CRawInput::Register( HWND hWnd, WORD wRawType ) 54 | { 55 | return SetRawInput(hWnd, wRawType, true); 56 | } 57 | 58 | bool CRawInput::Remove( HWND hWnd, WORD wRawType ) 59 | { 60 | return SetRawInput(hWnd, wRawType, false); 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /Notes/ref/XFile.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "XFile.h" 3 | 4 | namespace Easy { 5 | 6 | bool XFile::ReadFile(CString sFile, CString& data) 7 | { 8 | CFile file; 9 | 10 | if (!file.Open(sFile, CFile::modeRead)) 11 | { 12 | return false; 13 | } 14 | 15 | data = _T(""); 16 | 17 | int nLen = file.GetLength() + 1; 18 | char* utf8Buf = new char[nLen]; 19 | ZeroMemory(utf8Buf, nLen); 20 | 21 | file.Read(utf8Buf, nLen - 1); 22 | 23 | MultiByteToWideChar(CP_UTF8, 0, utf8Buf, -1, data.GetBuffer(nLen), nLen); 24 | data.ReleaseBuffer(); 25 | 26 | file.Close(); 27 | return true; 28 | } 29 | 30 | bool XFile::WriteFile(CString sFile, CString data) 31 | { 32 | CFile file; 33 | 34 | if (!file.Open(sFile, CFile::modeCreate | CFile::modeWrite)) 35 | { 36 | return false; 37 | } 38 | 39 | int nLen = WideCharToMultiByte(CP_UTF8, 0, data, -1, NULL, 0, NULL, NULL); 40 | char* utf8Buf = new char[nLen]; 41 | WideCharToMultiByte(CP_UTF8, 0, data, -1, utf8Buf, nLen, NULL, NULL); 42 | 43 | file.Write(utf8Buf, (nLen - 1) * sizeof(char)); 44 | data.ReleaseBuffer(); 45 | 46 | file.Close(); 47 | return true; 48 | } 49 | 50 | bool XFile::AppendFile(CString sFile, CString data) 51 | { 52 | CStdioFile file; 53 | 54 | if (!file.Open(sFile, CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite)) 55 | { 56 | return false; 57 | } 58 | 59 | file.SeekToEnd(); 60 | file.Write(data.GetBuffer(), data.GetLength() * sizeof(TCHAR)); 61 | data.ReleaseBuffer(); 62 | 63 | file.Close(); 64 | return true; 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /themes/default/src/components/WelcomeItem.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 87 | -------------------------------------------------------------------------------- /themes/simple/src/components/WelcomeItem.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 87 | -------------------------------------------------------------------------------- /themes/default/README.md: -------------------------------------------------------------------------------- 1 | # notes 2 | 3 | This template should help get you started developing with Vue 3 in Vite. 4 | 5 | ## Recommended IDE Setup 6 | 7 | [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin). 8 | 9 | ## Type Support for `.vue` Imports in TS 10 | 11 | TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types. 12 | 13 | If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps: 14 | 15 | 1. Disable the built-in TypeScript Extension 16 | 1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette 17 | 2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)` 18 | 2. Reload the VSCode window by running `Developer: Reload Window` from the command palette. 19 | 20 | ## Customize configuration 21 | 22 | See [Vite Configuration Reference](https://vitejs.dev/config/). 23 | 24 | ## Project Setup 25 | 26 | ```sh 27 | npm install 28 | ``` 29 | 30 | ### Compile and Hot-Reload for Development 31 | 32 | ```sh 33 | npm run dev 34 | ``` 35 | 36 | ### Type-Check, Compile and Minify for Production 37 | 38 | ```sh 39 | npm run build 40 | ``` 41 | 42 | ### Lint with [ESLint](https://eslint.org/) 43 | 44 | ```sh 45 | npm run lint 46 | ``` 47 | -------------------------------------------------------------------------------- /themes/default/src/themes/app.scss: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | color: var(--el-text-color-primary); 5 | background-color: var(--background-color); 6 | } 7 | 8 | #app { 9 | height: 100vh; 10 | .el-textarea { 11 | --el-input-bg-color: transparent; 12 | font-size: 16px; 13 | --el-input-border-color: transparent; 14 | --el-input-hover-border-color: transparent; 15 | --el-input-focus-border-color: transparent; 16 | } 17 | 18 | .el-button { 19 | --el-button-text-color: var(--el-text-color-primary); 20 | font-size: inherit; 21 | } 22 | 23 | .el-checkbox__inner { 24 | border-color: var(--el-text-color-primary); 25 | background-color: transparent; 26 | border-width: 2px; 27 | } 28 | .el-checkbox__input.is-checked .el-checkbox__inner { 29 | background-color: var(--el-text-color-primary); 30 | border-color: var(--el-text-color-primary);; 31 | &::after { 32 | border-color: var(--background-color); 33 | } 34 | } 35 | 36 | .el-color-picker__trigger { 37 | border: none; 38 | .el-color-picker__color { 39 | border-color: var(--el-text-color-primary); 40 | .el-color-picker__icon { 41 | color: var(--el-text-color-primary); 42 | } 43 | } 44 | } 45 | 46 | .el-input.no-border { 47 | --el-input-bg-color: transparent; 48 | --el-input-border-color: transparent; 49 | --el-input-hover-border-color: transparent; 50 | --el-input-focus-border-color: transparent; 51 | } 52 | } 53 | 54 | 55 | ::-webkit-scrollbar { 56 | width: 7px; 57 | height: 7px; 58 | } 59 | 60 | ::-webkit-scrollbar-thumb { 61 | background: #FFF; 62 | } 63 | 64 | :root { 65 | --background-color: #fff; 66 | } 67 | 68 | @media (prefers-color-scheme: dark) { 69 | :root { 70 | --background-color: #0b0f14; 71 | } 72 | } 73 | 74 | .drag-ghost { 75 | opacity: 0.5; 76 | } -------------------------------------------------------------------------------- /themes/simple/README.md: -------------------------------------------------------------------------------- 1 | # notes 2 | 3 | This template should help get you started developing with Vue 3 in Vite. 4 | 5 | ## Recommended IDE Setup 6 | 7 | [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin). 8 | 9 | ## Type Support for `.vue` Imports in TS 10 | 11 | TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types. 12 | 13 | If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps: 14 | 15 | 1. Disable the built-in TypeScript Extension 16 | 1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette 17 | 2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)` 18 | 2. Reload the VSCode window by running `Developer: Reload Window` from the command palette. 19 | 20 | ## Customize configuration 21 | 22 | See [Vite Configuration Reference](https://vitejs.dev/config/). 23 | 24 | ## Project Setup 25 | 26 | ```sh 27 | npm install 28 | ``` 29 | 30 | ### Compile and Hot-Reload for Development 31 | 32 | ```sh 33 | npm run dev 34 | ``` 35 | 36 | ### Type-Check, Compile and Minify for Production 37 | 38 | ```sh 39 | npm run build 40 | ``` 41 | 42 | ### Lint with [ESLint](https://eslint.org/) 43 | 44 | ```sh 45 | npm run lint 46 | ``` 47 | -------------------------------------------------------------------------------- /themes/simple/src/themes/app.scss: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | color: var(--el-text-color-primary); 5 | background-color: transparent; 6 | } 7 | 8 | #app { 9 | height: 100vh; 10 | .el-textarea { 11 | --el-input-bg-color: transparent; 12 | font-size: 16px; 13 | --el-input-border-color: transparent; 14 | --el-input-hover-border-color: transparent; 15 | --el-input-focus-border-color: transparent; 16 | } 17 | 18 | .el-button { 19 | --el-button-text-color: var(--el-text-color-primary); 20 | font-size: inherit; 21 | } 22 | 23 | .el-checkbox__inner { 24 | border-color: var(--el-text-color-primary); 25 | background-color: transparent; 26 | border-width: 2px; 27 | } 28 | .el-checkbox__input.is-checked .el-checkbox__inner { 29 | background-color: var(--el-text-color-primary); 30 | border-color: var(--el-text-color-primary);; 31 | &::after { 32 | border-color: var(--background-color); 33 | } 34 | } 35 | 36 | .el-color-picker__trigger { 37 | border: none; 38 | .el-color-picker__color { 39 | border-color: var(--el-text-color-primary); 40 | .el-color-picker__icon { 41 | color: var(--el-text-color-primary); 42 | } 43 | } 44 | } 45 | 46 | .el-input.no-border { 47 | --el-input-bg-color: transparent; 48 | --el-input-border-color: transparent; 49 | --el-input-hover-border-color: transparent; 50 | --el-input-focus-border-color: transparent; 51 | } 52 | } 53 | 54 | 55 | ::-webkit-scrollbar { 56 | width: 7px; 57 | height: 7px; 58 | } 59 | 60 | ::-webkit-scrollbar-thumb { 61 | background: #FFF; 62 | } 63 | 64 | .drag-ghost { 65 | opacity: 0.5; 66 | } 67 | 68 | .hidden-unlock { 69 | display: none; 70 | } 71 | 72 | .mouse-lock { 73 | .hidden-lock { 74 | display: none; 75 | } 76 | .hidden-unlock { 77 | display: block; 78 | } 79 | } -------------------------------------------------------------------------------- /themes/default/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "notes", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "vite", 7 | "build": "run-p type-check build-only", 8 | "preview": "vite preview", 9 | "build-only": "vite build", 10 | "type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false", 11 | "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", 12 | "format": "prettier --write src/" 13 | }, 14 | "dependencies": { 15 | "@element-plus/icons-vue": "^2.1.0", 16 | "@fortawesome/fontawesome-svg-core": "^6.4.0", 17 | "@fortawesome/free-brands-svg-icons": "^6.4.0", 18 | "@fortawesome/free-regular-svg-icons": "^6.4.0", 19 | "@fortawesome/free-solid-svg-icons": "^6.4.0", 20 | "@fortawesome/vue-fontawesome": "^3.0.3", 21 | "@types/marked": "^5.0.0", 22 | "@vitejs/plugin-legacy": "^4.0.4", 23 | "@vueuse/core": "^10.1.2", 24 | "element-plus": "^2.3.5", 25 | "marked": "^5.0.4", 26 | "pinia": "^2.0.36", 27 | "sass": "^1.62.1", 28 | "scss-loader": "^0.0.1", 29 | "terser": "^5.17.7", 30 | "vue": "^3.3.2", 31 | "vue-router": "^4.2.0", 32 | "vuedraggable": "^4.1.0" 33 | }, 34 | "devDependencies": { 35 | "@rushstack/eslint-patch": "^1.2.0", 36 | "@tsconfig/node18": "^2.0.1", 37 | "@types/node": "^18.16.8", 38 | "@vitejs/plugin-vue": "^4.2.3", 39 | "@vue/eslint-config-prettier": "^7.1.0", 40 | "@vue/eslint-config-typescript": "^11.0.3", 41 | "@vue/tsconfig": "^0.4.0", 42 | "autoprefixer": "^10.4.14", 43 | "eslint": "^8.39.0", 44 | "eslint-plugin-vue": "^9.11.0", 45 | "npm-run-all": "^4.1.5", 46 | "postcss": "^8.4.24", 47 | "prettier": "^2.8.8", 48 | "tailwindcss": "^3.3.2", 49 | "typescript": "~5.0.4", 50 | "vite": "^4.3.5", 51 | "vue-tsc": "^1.6.4" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /themes/simple/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "notes", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "vite", 7 | "build": "run-p type-check build-only", 8 | "preview": "vite preview", 9 | "build-only": "vite build", 10 | "type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false", 11 | "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", 12 | "format": "prettier --write src/" 13 | }, 14 | "dependencies": { 15 | "@element-plus/icons-vue": "^2.1.0", 16 | "@fortawesome/fontawesome-svg-core": "^6.4.0", 17 | "@fortawesome/free-brands-svg-icons": "^6.4.0", 18 | "@fortawesome/free-regular-svg-icons": "^6.4.0", 19 | "@fortawesome/free-solid-svg-icons": "^6.4.0", 20 | "@fortawesome/vue-fontawesome": "^3.0.3", 21 | "@types/marked": "^5.0.0", 22 | "@vitejs/plugin-legacy": "^4.0.4", 23 | "@vueuse/core": "^10.1.2", 24 | "element-plus": "^2.3.5", 25 | "marked": "^5.0.4", 26 | "pinia": "^2.0.36", 27 | "sass": "^1.62.1", 28 | "scss-loader": "^0.0.1", 29 | "terser": "^5.17.7", 30 | "vue": "^3.3.2", 31 | "vue-router": "^4.2.0", 32 | "vuedraggable": "^4.1.0" 33 | }, 34 | "devDependencies": { 35 | "@rushstack/eslint-patch": "^1.2.0", 36 | "@tsconfig/node18": "^2.0.1", 37 | "@types/node": "^18.16.8", 38 | "@vitejs/plugin-vue": "^4.2.3", 39 | "@vue/eslint-config-prettier": "^7.1.0", 40 | "@vue/eslint-config-typescript": "^11.0.3", 41 | "@vue/tsconfig": "^0.4.0", 42 | "autoprefixer": "^10.4.14", 43 | "eslint": "^8.39.0", 44 | "eslint-plugin-vue": "^9.11.0", 45 | "npm-run-all": "^4.1.5", 46 | "postcss": "^8.4.24", 47 | "prettier": "^2.8.8", 48 | "tailwindcss": "^3.3.2", 49 | "typescript": "~5.0.4", 50 | "vite": "^4.3.5", 51 | "vue-tsc": "^1.6.4" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Notes.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.6.33723.286 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Notes", "Notes\Notes.vcxproj", "{6769A8F9-CF54-47BB-8262-FE3D739E79AB}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | DebugHttp|Win32 = DebugHttp|Win32 13 | DebugHttp|x64 = DebugHttp|x64 14 | Release|Win32 = Release|Win32 15 | Release|x64 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {6769A8F9-CF54-47BB-8262-FE3D739E79AB}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {6769A8F9-CF54-47BB-8262-FE3D739E79AB}.Debug|Win32.Build.0 = Debug|Win32 20 | {6769A8F9-CF54-47BB-8262-FE3D739E79AB}.Debug|x64.ActiveCfg = Debug|x64 21 | {6769A8F9-CF54-47BB-8262-FE3D739E79AB}.Debug|x64.Build.0 = Debug|x64 22 | {6769A8F9-CF54-47BB-8262-FE3D739E79AB}.DebugHttp|Win32.ActiveCfg = DebugHttp|Win32 23 | {6769A8F9-CF54-47BB-8262-FE3D739E79AB}.DebugHttp|Win32.Build.0 = DebugHttp|Win32 24 | {6769A8F9-CF54-47BB-8262-FE3D739E79AB}.DebugHttp|x64.ActiveCfg = DebugHttp|x64 25 | {6769A8F9-CF54-47BB-8262-FE3D739E79AB}.DebugHttp|x64.Build.0 = DebugHttp|x64 26 | {6769A8F9-CF54-47BB-8262-FE3D739E79AB}.Release|Win32.ActiveCfg = Release|Win32 27 | {6769A8F9-CF54-47BB-8262-FE3D739E79AB}.Release|Win32.Build.0 = Release|Win32 28 | {6769A8F9-CF54-47BB-8262-FE3D739E79AB}.Release|x64.ActiveCfg = Release|x64 29 | {6769A8F9-CF54-47BB-8262-FE3D739E79AB}.Release|x64.Build.0 = Release|x64 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {F49CC348-7203-46C4-9085-BA9779C913EF} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /themes/default/src/components/icons/IconEcosystem.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /themes/simple/src/components/icons/IconEcosystem.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /Notes/NotesDlg.h: -------------------------------------------------------------------------------- 1 | 2 | // NotesDlg.h : header file 3 | // 4 | 5 | #pragma once 6 | #include "control/HotKeyEdit.h" 7 | 8 | // CNotesDlg dialog 9 | class CNotesDlg : public CDialogEx 10 | { 11 | // Construction 12 | public: 13 | CNotesDlg(CWnd* pParent = NULL); // standard constructor 14 | 15 | // Dialog Data 16 | enum { IDD = IDD_NOTES_DIALOG, WM_TRAYICON = WM_USER + 100 }; 17 | 18 | protected: 19 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 20 | 21 | 22 | // Implementation 23 | protected: 24 | HICON m_hIcon; 25 | 26 | // Generated message map functions 27 | virtual BOOL OnInitDialog(); 28 | virtual BOOL PreTranslateMessage(MSG* pMsg); 29 | afx_msg void OnSysCommand(UINT nID, LPARAM lParam); 30 | afx_msg void OnPaint(); 31 | afx_msg HCURSOR OnQueryDragIcon(); 32 | afx_msg void OnClose(); 33 | afx_msg LRESULT OnTrayIcon(WPARAM wParam, LPARAM lParam); 34 | afx_msg void OnNew(); 35 | afx_msg void OnHideall(); 36 | afx_msg void OnShowall(); 37 | afx_msg void OnShow(); 38 | afx_msg void OnQuit(); 39 | afx_msg void OnBnClickedBtnBrowse(); 40 | afx_msg void OnBnClickedOk(); 41 | virtual void OnCancel(); 42 | 43 | DECLARE_MESSAGE_MAP() 44 | 45 | void Init(); 46 | void InitSetting(Setting setting); 47 | Setting ReadSetting(); 48 | void SetHotKey(Setting setting); 49 | void ClearHotKey(Setting setting); 50 | void SetTrayIcon(); 51 | void SetWindownAlpha(float fAlpha); 52 | bool ShowInTaskbar(HWND hWnd, bool isShow); 53 | 54 | CHotKeyEdit m_ActiveHKey; 55 | CHotKeyEdit m_UnActiveHKey; 56 | CHotKeyEdit m_ActiveAllHKey; 57 | CHotKeyEdit m_NewHKey; 58 | CMenu m_MenuTray; 59 | NOTIFYICONDATA m_nid; 60 | 61 | HANDLE m_Instance; 62 | public: 63 | static bool m_bIsNoticeRuntime; 64 | static CAppCtrl m_ctrl; 65 | Setting m_setting; 66 | afx_msg void OnDestroy(); 67 | afx_msg void OnBnClickedBtnBrowseRuntime(); 68 | afx_msg void OnMenuThroughAllOn(); 69 | afx_msg void OnMenuThroughAllOff(); 70 | }; 71 | -------------------------------------------------------------------------------- /Notes/NoteDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // CNoteDlg dialog 5 | 6 | class CNoteDlg : public CDialogEx 7 | { 8 | DECLARE_DYNAMIC(CNoteDlg) 9 | 10 | public: 11 | CNoteDlg(CWnd* pParent = NULL); // standard constructor 12 | virtual ~CNoteDlg(); 13 | 14 | // Dialog Data 15 | enum { IDD = IDD_DLG_NOTE }; 16 | 17 | protected: 18 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 19 | virtual BOOL OnInitDialog(); 20 | afx_msg void OnSize(UINT nType, int cx, int cy); 21 | afx_msg LRESULT OnNcHitTest(CPoint point); 22 | afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point); 23 | afx_msg BOOL OnEraseBkgnd(CDC* pDC); 24 | afx_msg void OnPaint(); 25 | afx_msg void OnRawInput(UINT nInputcode, HRAWINPUT hRawInput); 26 | afx_msg void OnMove(int x, int y); 27 | 28 | DECLARE_MESSAGE_MAP() 29 | 30 | void Init(); 31 | 32 | void SendNoteItems(); 33 | void SendNoteSetting(); 34 | void SendMouseThrough(); 35 | 36 | void InitWebView(); 37 | HRESULT OnCreateEnvironmentCompleted(HRESULT result, ICoreWebView2Environment* environment); 38 | HRESULT OnCreateCoreWebView2ControllerCompleted(HRESULT result, ICoreWebView2Controller* controller); 39 | HRESULT OnWebMessageReceived(ICoreWebView2* webview, ICoreWebView2WebMessageReceivedEventArgs* args); 40 | HRESULT OnDocumentReady(ICoreWebView2* webview, ICoreWebView2NavigationCompletedEventArgs* args); 41 | 42 | void SendMessageToWeb(CString sEvent, rapidjson::GenericValue>& data, Document::AllocatorType& allocator); 43 | void ExecuteScript(CString sJavascript, ICoreWebView2ExecuteScriptCompletedHandler* handler); 44 | const TCHAR* GetDocumentReadyJavascript(); 45 | void OnMouseMoving(CPoint pt); 46 | 47 | private: 48 | Microsoft::WRL::ComPtr m_webViewEnvironment; 49 | Microsoft::WRL::ComPtr m_controller; 50 | Microsoft::WRL::ComPtr m_webView; 51 | CBrush m_brush; 52 | bool m_bMoveWindow; 53 | CRect m_BeginMoveRect; 54 | CPoint m_BeginMovePoint; 55 | 56 | public: 57 | CNote m_Note; 58 | 59 | void SetWindownAlpha(float fAlpha); 60 | void SetMouseThrough(bool bThought); 61 | bool IsMouseThrough(); 62 | }; 63 | -------------------------------------------------------------------------------- /Notes/ref/Registry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Easy { 4 | 5 | class Registry 6 | { 7 | public: 8 | Registry(); 9 | Registry(HKEY hKey, bool bWOW6432 = false); 10 | 11 | void Init(HKEY hKey, bool bWOW6432 = false); 12 | bool IsExisted(CString sSubKey); 13 | bool CreateKey(CString sSubKey); 14 | bool DeleteKey(CString sSubKey); 15 | 16 | bool DeleteValue(CString sSubKey, CString sValueName); 17 | 18 | bool Read(CString sSubKey, CString sValueName, int& nValue); 19 | bool Read(CString sSubKey, CString sValueName, bool& bValue); 20 | bool Read(CString sSubKey, CString sValueName, UINT& nValue); 21 | bool Read(CString sSubKey, CString sValueName, long& nValue); 22 | bool Read(CString sSubKey, CString sValueName, DWORD& dwValue); 23 | bool Read(CString sSubKey, CString sValueName, CString& sValue); 24 | bool Read(CString sSubKey, CString sValueName, LPVOID lpData, DWORD& dwDataSize); 25 | 26 | bool Write(CString sSubKey, CString sValueName, int nValue); 27 | bool Write(CString sSubKey, CString sValueName, bool bValue); 28 | bool Write(CString sSubKey, CString sValueName, UINT nValue); 29 | bool Write(CString sSubKey, CString sValueName, long nValue); 30 | bool Write(CString sSubKey, CString sValueName, DWORD dwValue); 31 | bool Write(CString sSubKey, CString sValueName, CString sValue); 32 | bool Write(CString sSubKey, CString sValueName, LPVOID lpData, DWORD dwDataSize, DWORD dwType); 33 | 34 | 35 | /*! 36 | * @brief GetLastError 37 | * 38 | * Get the last error code 39 | * @return DWORD the error code 40 | */ 41 | DWORD GetLastError(); 42 | 43 | /*! 44 | * @brief GetLastErrorMsg 45 | * 46 | * Get the last error message 47 | * @return CString the error message 48 | */ 49 | CString GetLastErrorMsg(); 50 | 51 | private: 52 | 53 | /*! 54 | * @brief FormatLastError 55 | * 56 | * format the last error code to string 57 | * @param dwLastError the error code want to format 58 | * @return CString the error message 59 | */ 60 | CString FormatLastError(DWORD dwLastError); 61 | 62 | CString m_sLastError; 63 | DWORD m_nLastError; 64 | 65 | HKEY m_hKey; 66 | DWORD m_dwWOW6432; 67 | }; 68 | 69 | } -------------------------------------------------------------------------------- /setup.iss: -------------------------------------------------------------------------------- 1 | ; Script generated by the Inno Setup Script Wizard. 2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 3 | 4 | #define MyAppName "Sticky Note" 5 | #define MyAppVersion "1.1.2" 6 | #define MyAppPublisher "Hancel.Lin" 7 | #define MyAppURL "https://github.com/imlinhanchao/sticky_notes" 8 | #define MyAppExeName "Notes.exe" 9 | 10 | [Setup] 11 | ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. 12 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 13 | AppId={{CD1E65B4-0A4C-4853-B4EA-F447CD00B780} 14 | AppName={#MyAppName} 15 | AppVersion={#MyAppVersion} 16 | AppVerName={#MyAppName} 17 | AppPublisher={#MyAppPublisher} 18 | AppPublisherURL={#MyAppURL} 19 | AppSupportURL={#MyAppURL} 20 | AppUpdatesURL={#MyAppURL} 21 | DefaultDirName={autopf}\StickyNotes 22 | UninstallDisplayIcon={app}\unins000.exe 23 | DisableProgramGroupPage=yes 24 | LicenseFile=LICENSE 25 | ; Remove the following line to run in administrative install mode (install for all users.) 26 | PrivilegesRequired=lowest 27 | PrivilegesRequiredOverridesAllowed=dialog 28 | OutputDir=output 29 | OutputBaseFilename=Sticky.Notes.{#MyAppVersion} 30 | SetupIconFile=setup.ico 31 | Compression=lzma 32 | SolidCompression=yes 33 | WizardStyle=modern 34 | 35 | [Languages] 36 | Name: "english"; MessagesFile: "compiler:Default.isl" 37 | 38 | [Tasks] 39 | Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked 40 | 41 | [Files] 42 | Source: "Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion 43 | Source: "Release\WebView2Loader.dll"; DestDir: "{app}"; Flags: ignoreversion 44 | Source: "themes\default\dist\*"; DestDir: "{app}\themes\Default"; Flags: ignoreversion recursesubdirs createallsubdirs 45 | Source: "themes\simple\dist\*"; DestDir: "{app}\themes\Simple"; Flags: ignoreversion recursesubdirs createallsubdirs 46 | ; NOTE: Don't use "Flags: ignoreversion" on any shared system files 47 | 48 | [Icons] 49 | Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" 50 | Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon 51 | 52 | [Run] 53 | Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent 54 | 55 | [UninstallDelete] 56 | Type: files; Name: "{userstartup}\setting.ini" 57 | Type: filesandordirs; Name: "{app}\{#MyAppExeName}.WebView2" -------------------------------------------------------------------------------- /setupx64.iss: -------------------------------------------------------------------------------- 1 | ; Script generated by the Inno Setup Script Wizard. 2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 3 | 4 | #define MyAppName "Sticky Note" 5 | #define MyAppVersion "1.1.2" 6 | #define MyAppPublisher "Hancel.Lin" 7 | #define MyAppURL "https://github.com/imlinhanchao/sticky_notes" 8 | #define MyAppExeName "Notes.exe" 9 | 10 | [Setup] 11 | ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. 12 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 13 | AppId={{CD1E65B4-0A4C-4853-B4EA-F447CD00B780} 14 | AppName={#MyAppName} 15 | AppVersion={#MyAppVersion} 16 | AppVerName={#MyAppName} 17 | AppPublisher={#MyAppPublisher} 18 | AppPublisherURL={#MyAppURL} 19 | AppSupportURL={#MyAppURL} 20 | AppUpdatesURL={#MyAppURL} 21 | DefaultDirName={autopf}\StickyNotes 22 | UninstallDisplayIcon={app}\unins000.exe 23 | DisableProgramGroupPage=yes 24 | LicenseFile=LICENSE 25 | ; Remove the following line to run in administrative install mode (install for all users.) 26 | PrivilegesRequired=lowest 27 | PrivilegesRequiredOverridesAllowed=dialog 28 | OutputDir=output 29 | OutputBaseFilename=Sticky.Notes.{#MyAppVersion}.x64 30 | SetupIconFile=setup.ico 31 | Compression=lzma 32 | SolidCompression=yes 33 | WizardStyle=modern 34 | 35 | [Languages] 36 | Name: "english"; MessagesFile: "compiler:Default.isl" 37 | 38 | [Tasks] 39 | Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked 40 | 41 | [Files] 42 | Source: "x64\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion 43 | Source: "x64\Release\WebView2Loader.dll"; DestDir: "{app}"; Flags: ignoreversion 44 | Source: "themes\default\dist\*"; DestDir: "{app}\themes\Default"; Flags: ignoreversion recursesubdirs createallsubdirs 45 | Source: "themes\simple\dist\*"; DestDir: "{app}\themes\Simple"; Flags: ignoreversion recursesubdirs createallsubdirs 46 | ; NOTE: Don't use "Flags: ignoreversion" on any shared system files 47 | 48 | [Icons] 49 | Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" 50 | Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon 51 | 52 | [Run] 53 | Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent 54 | 55 | [UninstallDelete] 56 | Type: files; Name: "{userstartup}\setting.ini" 57 | Type: filesandordirs; Name: "{app}\{#MyAppExeName}.WebView2" -------------------------------------------------------------------------------- /Notes/ref/Shell.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Easy { 4 | 5 | class Shell 6 | { 7 | public: 8 | Shell(void); 9 | ~Shell(void); 10 | 11 | typedef enum SHELL_TYPE { CONSOLE = 0, APP }; 12 | 13 | /*! 14 | * @brief Execute 15 | * 16 | * Execute a program 17 | * @param sPath The path of program. 18 | * @param sCommand The command line with program 19 | * @param type The type of program to execute 20 | * @param bShow Show the program window or not. Not work for all program. 21 | * @return bool Execute success or not 22 | */ 23 | bool Execute(CString sPath, CString sCommand=_T(""), SHELL_TYPE type=APP, bool bShow=true, CString sWorkDirectory=_T("")); 24 | 25 | /*! 26 | * @brief IsRunning 27 | * 28 | * Is the program running 29 | * @return bool True means running, false was not. 30 | */ 31 | bool IsRunning(void); 32 | 33 | /*! 34 | * @brief Stop 35 | * 36 | * Stop run the program. 37 | * @return bool Stop success or not 38 | */ 39 | bool Stop(void); 40 | 41 | /*! 42 | * @brief GetOutput 43 | * 44 | * Get the program output, work for console application. 45 | * @return CString The output string. 46 | */ 47 | CString GetOutput(void); 48 | 49 | /*! 50 | * @brief GetOutput 51 | * 52 | * Get the program window handle. 53 | * @return HWND The window handle. 54 | */ 55 | HWND GetWnd(void); 56 | 57 | /*! 58 | * @brief GetLastError 59 | * 60 | * Get the last error code 61 | * @return DWORD the error code 62 | */ 63 | DWORD GetLastError(); 64 | 65 | /*! 66 | * @brief GetLastErrorMsg 67 | * 68 | * Get the last error message 69 | * @return CString the error message 70 | */ 71 | CString GetLastErrorMsg(); 72 | 73 | private: 74 | static DWORD WINAPI ShellThread(LPVOID lpParam); 75 | static BOOL WINAPI EnumWindowsProc(HWND hWnd, LPARAM lParam); 76 | 77 | bool ExecuteConsole(CString sPath, CString sCommand, bool bShow, CString sWorkDirectory); 78 | bool ExecuteApplication(CString sPath, CString sCommand, bool bShow, CString sWorkDirectory); 79 | 80 | /*! 81 | * @brief GetSystemError 82 | * 83 | * used to get system error and save it 84 | */ 85 | void GetSystemError(); 86 | 87 | /*! 88 | * @brief FormatLastError 89 | * 90 | * format the last error code to string 91 | * @param dwLastError the error code want to format 92 | * @return CString the error message 93 | */ 94 | CString FormatLastError(DWORD dwLastError); 95 | 96 | CString m_sLastError; 97 | DWORD m_nLastError; 98 | 99 | PROCESS_INFORMATION m_pi; 100 | HANDLE m_hRead; 101 | 102 | bool m_bRunning; 103 | HWND m_hWnd; 104 | CString m_sOutput; 105 | }; 106 | 107 | } 108 | -------------------------------------------------------------------------------- /Notes/Notes.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Notes.cpp : Defines the class behaviors for the application. 3 | // 4 | 5 | #include "stdafx.h" 6 | #include "Notes.h" 7 | #include "NotesDlg.h" 8 | 9 | #ifdef _DEBUG 10 | #define new DEBUG_NEW 11 | #endif 12 | 13 | 14 | // CNotesApp 15 | 16 | BEGIN_MESSAGE_MAP(CNotesApp, CWinApp) 17 | ON_COMMAND(ID_HELP, &CWinApp::OnHelp) 18 | END_MESSAGE_MAP() 19 | 20 | 21 | // CNotesApp construction 22 | 23 | CNotesApp::CNotesApp() 24 | { 25 | // support Restart Manager 26 | m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; 27 | 28 | // TODO: add construction code here, 29 | // Place all significant initialization in InitInstance 30 | } 31 | 32 | 33 | // The one and only CNotesApp object 34 | 35 | CNotesApp theApp; 36 | 37 | 38 | // CNotesApp initialization 39 | 40 | BOOL CNotesApp::InitInstance() 41 | { 42 | // InitCommonControlsEx() is required on Windows XP if an application 43 | // manifest specifies use of ComCtl32.dll version 6 or later to enable 44 | // visual styles. Otherwise, any window creation will fail. 45 | INITCOMMONCONTROLSEX InitCtrls; 46 | InitCtrls.dwSize = sizeof(InitCtrls); 47 | // Set this to include all the common control classes you want to use 48 | // in your application. 49 | InitCtrls.dwICC = ICC_WIN95_CLASSES; 50 | InitCommonControlsEx(&InitCtrls); 51 | 52 | CWinApp::InitInstance(); 53 | 54 | 55 | AfxEnableControlContainer(); 56 | 57 | // Create the shell manager, in case the dialog contains 58 | // any shell tree view or shell list view controls. 59 | CShellManager *pShellManager = new CShellManager; 60 | 61 | // Standard initialization 62 | // If you are not using these features and wish to reduce the size 63 | // of your final executable, you should remove from the following 64 | // the specific initialization routines you do not need 65 | // Change the registry key under which our settings are stored 66 | // TODO: You should modify this string to be something appropriate 67 | // such as the name of your company or organization 68 | SetRegistryKey(_T("Local AppWizard-Generated Applications")); 69 | 70 | CNotesDlg dlg; 71 | m_pMainWnd = &dlg; 72 | INT_PTR nResponse = dlg.DoModal(); 73 | if (nResponse == IDOK) 74 | { 75 | // TODO: Place code here to handle when the dialog is 76 | // dismissed with OK 77 | } 78 | else if (nResponse == IDCANCEL) 79 | { 80 | // TODO: Place code here to handle when the dialog is 81 | // dismissed with Cancel 82 | } 83 | 84 | // Delete the shell manager created above. 85 | if (pShellManager != NULL) 86 | { 87 | delete pShellManager; 88 | } 89 | 90 | // Since the dialog has been closed, return FALSE so that we exit the 91 | // application, rather than start the application's message pump. 92 | return FALSE; 93 | } 94 | 95 | -------------------------------------------------------------------------------- /Notes/stdafx.h: -------------------------------------------------------------------------------- 1 | 2 | // stdafx.h : include file for standard system include files, 3 | // or project specific include files that are used frequently, 4 | // but are changed infrequently 5 | 6 | #pragma once 7 | 8 | #ifndef _SECURE_ATL 9 | #define _SECURE_ATL 1 10 | #endif 11 | 12 | #ifndef VC_EXTRALEAN 13 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 14 | #endif 15 | 16 | #include "targetver.h" 17 | 18 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 19 | 20 | // turns off MFC's hiding of some common and often safely ignored warning messages 21 | #define _AFX_ALL_WARNINGS 22 | 23 | #include // MFC core and standard components 24 | #include // MFC extensions 25 | 26 | 27 | #include // MFC Automation classes 28 | 29 | 30 | 31 | #ifndef _AFX_NO_OLE_SUPPORT 32 | #include // MFC support for Internet Explorer 4 Common Controls 33 | #endif 34 | #ifndef _AFX_NO_AFXCMN_SUPPORT 35 | #include // MFC support for Windows Common Controls 36 | #endif // _AFX_NO_AFXCMN_SUPPORT 37 | 38 | #include // MFC support for ribbons and control bars 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | #ifdef _UNICODE 49 | #if defined _M_IX86 50 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") 51 | #elif defined _M_X64 52 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") 53 | #else 54 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 55 | #endif 56 | #endif 57 | 58 | #include 59 | #include 60 | 61 | // include WebView2 62 | #include "WebView2.h" 63 | 64 | // include Json 65 | #include "rapidjson/document.h" 66 | #include "rapidjson/writer.h" 67 | #include "rapidjson/stringbuffer.h" 68 | 69 | using namespace rapidjson; 70 | 71 | #include "resource.h" 72 | 73 | #include 74 | #include 75 | #include 76 | using namespace std; 77 | 78 | 79 | #include "ref/Path.h" 80 | #include "ref/Ini.h" 81 | #include "ref/Log.h" 82 | #include "ref/Cvt.h" 83 | #include "ref/Shell.h" 84 | #include "ref/Registry.h" 85 | #include "ref/Utility.h" 86 | #include "ref/HotKey.h" 87 | #include "ref/RawInput.h" 88 | #include "ref/XFile.h" 89 | using namespace Easy; 90 | 91 | #include "control/HotKeyEdit.h" 92 | 93 | #include "defintion.h" 94 | #include "app/Config.h" 95 | #include "app/NoteConfig.h" 96 | #include "app/Note.h" 97 | #include "app/AppCtrl.h" -------------------------------------------------------------------------------- /Notes/ref/Cvt.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Cvt.h" 3 | 4 | namespace Easy 5 | { 6 | 7 | CString Cvt::ToString(bool bValue) 8 | { 9 | return bValue ? _T("1") : _T("0"); 10 | } 11 | 12 | CString Cvt::ToString(int nValue) 13 | { 14 | CString sValue = _T(""); 15 | sValue.Format(_T("%d"), nValue); 16 | 17 | return sValue; 18 | } 19 | 20 | CString Cvt::ToString(long nValue) 21 | { 22 | CString sValue = _T(""); 23 | sValue.Format(_T("%ld"), nValue); 24 | 25 | return sValue; 26 | } 27 | 28 | CString Cvt::ToString(float fValue, int nPrecision) 29 | { 30 | CString sValue = _T(""); 31 | CString sFormat = _T("%f"); 32 | if(nPrecision > 0) 33 | { 34 | sFormat.Format(_T("%%0.%df"), nPrecision); 35 | } 36 | 37 | sValue.Format(sFormat, fValue); 38 | 39 | return sValue; 40 | } 41 | 42 | CString Cvt::ToString(double fValue, int nPrecision) 43 | { 44 | CString sValue = _T(""); 45 | CString sFormat = _T("%f"); 46 | if(nPrecision > 0) 47 | { 48 | sFormat.Format(_T("%%0.%df"), nPrecision); 49 | } 50 | 51 | sValue.Format(sFormat, fValue); 52 | return sValue; 53 | } 54 | 55 | CString Cvt::ToString(DWORD dwValue) 56 | { 57 | CString sValue = _T(""); 58 | sValue.Format(_T("%u"), dwValue); 59 | 60 | return sValue; 61 | } 62 | 63 | CString Cvt::ToString(UINT nValue) 64 | { 65 | CString sValue = _T(""); 66 | sValue.Format(_T("%u"), nValue); 67 | 68 | return sValue; 69 | } 70 | 71 | CString Cvt::ToString(COleDateTime date) 72 | { 73 | CString sValue = _T(""); 74 | sValue.Format(_T("%d-%02d-%02d %02d:%02d:%02d"), date.GetYear(), 75 | date.GetMonth(), date.GetDay(), date.GetHour(), date.GetMinute(), date.GetSecond()); 76 | 77 | return sValue; 78 | } 79 | 80 | CString Cvt::ToString( const TCHAR* pszFormat, ... ) 81 | { 82 | ASSERT(pszFormat && *pszFormat); 83 | 84 | TCHAR szMsg[1024]; 85 | va_list vargs; 86 | 87 | va_start(vargs, pszFormat); 88 | 89 | _vsnwprintf_s( szMsg, sizeof(szMsg) - 1, pszFormat, vargs); 90 | 91 | return CString(szMsg); 92 | } 93 | 94 | CString Cvt::ToString( CTime time, CString sFormat ) 95 | { 96 | return time.Format(sFormat); 97 | } 98 | 99 | COleDateTime Cvt::ToDateTime(CString sDateTime) 100 | { 101 | COleDateTime dt; 102 | return dt.ParseDateTime(sDateTime) ? dt : COleDateTime(0, 0, 0, 0, 0, 0); 103 | } 104 | 105 | vector Cvt::SplitString( CString sData, CString sSp ) 106 | { 107 | vector lstList; 108 | 109 | int nPos = 0; 110 | CString sItem = sData.Tokenize(sSp, nPos); 111 | 112 | while (!sItem.IsEmpty()) 113 | { 114 | lstList.push_back(sItem); 115 | sItem = sData.Tokenize(sSp, nPos); 116 | } 117 | 118 | return lstList; 119 | } 120 | 121 | CString Cvt::ToHex(COLORREF color) 122 | { 123 | CString sColor = _T(""); 124 | sColor.Format(_T("#%02X%02X%02X"), GetRValue(color), GetGValue(color), GetBValue(color)); 125 | 126 | return sColor; 127 | } 128 | 129 | COLORREF Cvt::ToColor(CString sHex) 130 | { 131 | if (sHex.GetLength() != 7) 132 | { 133 | return RGB(0, 0, 0); 134 | } 135 | 136 | int nR = 0, nG = 0, nB = 0; 137 | _stscanf(sHex, _T("#%2X%2X%2X"), &nR, &nG, &nB); 138 | return RGB(nR, nG, nB); 139 | } 140 | 141 | } -------------------------------------------------------------------------------- /Notes/ref/HotKey.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "HotKey.h" 3 | 4 | namespace Easy { 5 | 6 | map CHotKey::m_HotKeyCallback; 7 | 8 | CHotKey::CHotKey(void) 9 | { 10 | } 11 | 12 | 13 | CHotKey::~CHotKey(void) 14 | { 15 | } 16 | 17 | bool CHotKey::SetWithCall( DWORD dwHotKey, HOTKEYCALLBACK pCallback, LPVOID lpParam, HWND hWnd) 18 | { 19 | HOTKEY_CALL hotkeyCall = { pCallback, lpParam }; 20 | m_HotKeyCallback[dwHotKey] = hotkeyCall; 21 | return SetHotKey(dwHotKey, hWnd); 22 | } 23 | 24 | bool CHotKey::RemoveHotKey( DWORD dwHotKey, HWND hWnd ) 25 | { 26 | if (m_HotKeyCallback.find(dwHotKey) != m_HotKeyCallback.end()) 27 | { 28 | m_HotKeyCallback.erase(dwHotKey); 29 | } 30 | return UnregisterHotKey(hWnd == NULL ? AfxGetMainWnd()->GetSafeHwnd() : hWnd, dwHotKey); 31 | } 32 | 33 | bool CHotKey::SetHotKey( DWORD dwHotKey, HWND hWnd ) 34 | { 35 | return RegisterHotKey(hWnd == NULL ? AfxGetMainWnd()->GetSafeHwnd() : hWnd, dwHotKey, GetModifiers(dwHotKey), dwHotKey & 0xff); 36 | } 37 | 38 | UINT CHotKey::GetModifiers( DWORD dwHotKey ) 39 | { 40 | UINT uModifiers = 0; 41 | dwHotKey >>= 0x08; 42 | if(dwHotKey & HOTKEYF_ALT) uModifiers |= MOD_ALT; 43 | if(dwHotKey & HOTKEYF_SHIFT) uModifiers |= MOD_SHIFT; 44 | if(dwHotKey & HOTKEYF_CONTROL) uModifiers |= MOD_CONTROL; 45 | if(dwHotKey & HOTKEYF_EXT) uModifiers |= MOD_WIN; 46 | return uModifiers; 47 | } 48 | 49 | CString CHotKey::GetHotKeyName( DWORD dwHotKey ) 50 | { 51 | DWORD dwKeyCode = dwHotKey & 0xff; 52 | CString sKey = CHotKeyCtrl::GetKeyName(dwKeyCode, IsExtendedKey(dwKeyCode)); 53 | 54 | if (dwKeyCode == VK_PAUSE) 55 | { 56 | sKey = _T("Pause"); 57 | } 58 | 59 | if (dwKeyCode == VK_LWIN || dwKeyCode == VK_RWIN) 60 | { 61 | sKey = _T("Win"); 62 | } 63 | 64 | if(_T(" ") == sKey) 65 | { 66 | sKey = _T("Space"); 67 | } 68 | else if(sKey.IsEmpty()) 69 | { 70 | sKey = CHotKeyCtrl::GetKeyName(dwKeyCode, TRUE); 71 | } 72 | 73 | dwHotKey >>= 0x08; 74 | if(dwHotKey & HOTKEYF_ALT) sKey = _T("Alt + ") + sKey; 75 | if(dwHotKey & HOTKEYF_SHIFT) sKey = _T("Shift + ") + sKey; 76 | if(dwHotKey & HOTKEYF_CONTROL) sKey = _T("Ctrl + ") + sKey; 77 | 78 | return sKey; 79 | } 80 | 81 | USHORT CHotKey::GetHotKeyCode(CString sHotKey) 82 | { 83 | USHORT uHotKey = 0; 84 | if (sHotKey.IsEmpty()) return uHotKey; 85 | 86 | return 0; 87 | } 88 | 89 | bool CHotKey::IsExtendedKey(DWORD vKey) 90 | { 91 | DWORD dwKeyCodes[] = { 92 | VK_DELETE, 93 | VK_HOME, 94 | VK_PRIOR, 95 | VK_NEXT, 96 | VK_END, 97 | 98 | VK_NUMLOCK, 99 | VK_INSERT, 100 | 101 | VK_LEFT, 102 | VK_UP, 103 | VK_RIGHT, 104 | VK_DOWN, 105 | 106 | VK_LWIN, 107 | VK_RWIN, 108 | }; 109 | 110 | int nCount = sizeof(dwKeyCodes) / sizeof(DWORD); 111 | for (int i = 0; i < nCount; i++) 112 | { 113 | if (vKey == dwKeyCodes[i]) return true; 114 | } 115 | return false; 116 | } 117 | 118 | void CHotKey::Execute( DWORD dwHotKey ) 119 | { 120 | if (m_HotKeyCallback.find(dwHotKey) != m_HotKeyCallback.end() && m_HotKeyCallback[dwHotKey].callback != NULL) 121 | m_HotKeyCallback[dwHotKey].callback(m_HotKeyCallback[dwHotKey].lpParam); 122 | } 123 | 124 | } -------------------------------------------------------------------------------- /themes/default/src/components/TheWelcome.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 87 | -------------------------------------------------------------------------------- /themes/simple/src/components/TheWelcome.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 87 | -------------------------------------------------------------------------------- /Notes/ref/Utility.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Utility.h" 3 | #pragma comment(lib, "version") 4 | 5 | namespace Easy { 6 | bool Utility::IsWow64() 7 | { 8 | typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); 9 | LPFN_ISWOW64PROCESS fnIsWow64Process = NULL; 10 | 11 | BOOL bIsWow64 = FALSE; 12 | BOOL bSuccessful = FALSE; 13 | fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress ( GetModuleHandle(_T("kernel32")), "IsWow64Process"); 14 | if (NULL != fnIsWow64Process && 15 | fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) 16 | { 17 | bSuccessful = TRUE; 18 | } 19 | 20 | if(bSuccessful) 21 | { 22 | return bIsWow64 ? true : false; 23 | } 24 | 25 | SYSTEM_INFO info = {0}; 26 | typedef VOID (WINAPI *LPFN_GetNativeSystemInfo)(LPSYSTEM_INFO lpSystemInfo); 27 | LPFN_GetNativeSystemInfo fnGetNativeSystemInfo = (LPFN_GetNativeSystemInfo)GetProcAddress(GetModuleHandle(_T("kernel32")), "GetNativeSystemInfo"); 28 | if(NULL == fnGetNativeSystemInfo) 29 | { 30 | GetSystemInfo(&info); 31 | } 32 | else 33 | { 34 | fnGetNativeSystemInfo(&info); 35 | } 36 | 37 | if(info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || 38 | info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) 39 | { 40 | bIsWow64 = TRUE; 41 | } 42 | 43 | return bIsWow64 ? true : false; // we treat it as 32bit if failure. 44 | } 45 | 46 | MODULE_VER Utility::GetVersion(CString sModuleName) 47 | { 48 | MODULE_VER ver; 49 | ver.wMajor = 0; 50 | ver.wMinor = 0; 51 | ver.wRevision = 0; 52 | ver.wBuild = 0; 53 | LPBYTE lpVersionData = NULL; 54 | DWORD dwLangCharset = 0; 55 | 56 | // Get the version information size for allocate the buffer 57 | DWORD dwHandle = 0; 58 | DWORD dwDataSize = ::GetFileVersionInfoSize((LPTSTR)sModuleName.GetBuffer(), &dwHandle); 59 | sModuleName.ReleaseBuffer(); 60 | if ( dwDataSize == 0 ) 61 | { 62 | return ver; 63 | } 64 | 65 | // Allocate buffer and retrieve version information 66 | lpVersionData = new BYTE[dwDataSize + 1]; 67 | if (!::GetFileVersionInfo((LPTSTR)sModuleName.GetBuffer(), dwHandle, dwDataSize, (void**)lpVersionData) ) 68 | { 69 | sModuleName.ReleaseBuffer(); 70 | delete[] lpVersionData; 71 | return ver; 72 | } 73 | sModuleName.ReleaseBuffer(); 74 | 75 | // Retrieve the first language and character-set identifier 76 | UINT nQuerySize = 0; 77 | DWORD* pTransTable = NULL; 78 | if (!::VerQueryValue(lpVersionData, _T("\\VarFileInfo\\Translation"), (void **)&pTransTable, &nQuerySize) ) 79 | { 80 | delete[] lpVersionData; 81 | return ver; 82 | } 83 | 84 | // Swap the words to have lang-charset in the correct format 85 | dwLangCharset = MAKELONG(HIWORD(pTransTable[0]), LOWORD(pTransTable[0])); 86 | 87 | // Get fixed file information 88 | VS_FIXEDFILEINFO* pVsffi; 89 | if ( !::VerQueryValue((void **)lpVersionData, _T("\\"), (void**)&pVsffi, &nQuerySize) ) 90 | { 91 | return ver; 92 | } 93 | 94 | ver.wMajor = HIWORD(pVsffi->dwFileVersionMS); 95 | ver.wMinor = LOWORD(pVsffi->dwFileVersionMS); 96 | ver.wRevision = HIWORD(pVsffi->dwFileVersionLS); 97 | ver.wBuild = LOWORD(pVsffi->dwFileVersionLS); 98 | 99 | return ver; 100 | } 101 | 102 | void Utility::SetAutoRun(bool bAuto) 103 | { 104 | #define AUTO_REG _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run") 105 | Registry reg(HKEY_CURRENT_USER, true); 106 | 107 | if (bAuto) reg.Write(AUTO_REG, _T("Sticky Note"), Path::GetProgramPath()); 108 | else reg.DeleteValue(AUTO_REG, _T("Sticky Note")); 109 | } 110 | 111 | HANDLE Utility::ProgramLock(CString sInstanceName) 112 | { 113 | HANDLE hInstance = CreateMutex(NULL, TRUE, _T("GRAPHICS ENGINE_INSTANCE")); 114 | if (ERROR_ALREADY_EXISTS == GetLastError()) 115 | { 116 | CloseHandle(hInstance); 117 | hInstance = nullptr; 118 | ::PostQuitMessage(0); 119 | } 120 | return hInstance; 121 | } 122 | 123 | } -------------------------------------------------------------------------------- /Notes/ref/Ini.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Easy { 4 | 5 | /*! 6 | * @class Ini 7 | * @brief Initialization File operation class 8 | * 9 | * Used to get read/write *.ini File 10 | */ 11 | class Ini 12 | { 13 | public: 14 | Ini(void); 15 | Ini(CString sPath); 16 | ~Ini(void); 17 | 18 | /*! 19 | * @brief SetFile 20 | * 21 | * Set the file path to operation 22 | * @param sPath The path of file 23 | */ 24 | void SetFile(CString sPath); 25 | 26 | /*! 27 | * @brief GetAllSections 28 | * 29 | * Get all of the sections from file 30 | * @param sSections The name of sections that you get. 31 | * @return bool Get sections success or not 32 | */ 33 | bool GetAllSections(vector& sSections); 34 | 35 | /*! 36 | * @brief GetAllKeys 37 | * 38 | * Get all of the keys from section of file 39 | * @param sSection The section where you get keys. 40 | * @param sKeys The keys that you get. 41 | * @return bool Get keys success or not 42 | */ 43 | bool GetAllKeys(CString sSection, vector& sKeys); 44 | 45 | 46 | /*! 47 | * @brief Read 48 | * 49 | * Read value of the key from section of file 50 | * @param sSection The section where key is. 51 | * @param sKeyName The key to read value. 52 | * @param Value The value that you read. 53 | * @return bool Read sections success or not 54 | * @{ 55 | */ 56 | bool Read(CString sSection, CString sKeyName, CString& sValue); 57 | bool Read(CString sSection, CString sKeyName, ULONG& dwValue); 58 | bool Read(CString sSection, CString sKeyName, int& nValue); 59 | bool Read(CString sSection, CString sKeyName, UINT& nValue); 60 | bool Read(CString sSection, CString sKeyName, long& nValue); 61 | bool Read(CString sSection, CString sKeyName, bool& bValue); 62 | /* @} */ 63 | 64 | 65 | /*! 66 | * @brief Read 67 | * 68 | * Write value of the key from section of file 69 | * @param sSection The section where key is. 70 | * @param sKeyName The key to write value. 71 | * @param Value The value that you write. 72 | * @return bool Write Value success or not 73 | * @{ 74 | */ 75 | bool Write(CString sSection, CString sKeyName, CString sValue); 76 | bool Write(CString sSection, CString sKeyName, DWORD dwValue); 77 | bool Write(CString sSection, CString sKeyName, int nValue); 78 | bool Write(CString sSection, CString sKeyName, UINT nValue); 79 | bool Write(CString sSection, CString sKeyName, long nValue); 80 | bool Write(CString sSection, CString sKeyName, bool bValue); 81 | /* @} */ 82 | 83 | /*! 84 | * @brief Remove 85 | * 86 | * Remove key of the section 87 | * @param sSection The section where key is. 88 | * @param sKeyName The key to remove. 89 | * @return bool Remove key success or not 90 | */ 91 | bool Remove(CString sSection, CString sKeyName); 92 | 93 | /*! 94 | * @brief Remove 95 | * 96 | * Remove the section and all of the content 97 | * @param sSection The section to remove. 98 | * @return bool Remove section success or not 99 | */ 100 | bool Remove(CString sSection); 101 | 102 | /*! 103 | * @brief GetLastError 104 | * 105 | * Get the last error code 106 | * @return DWORD the error code 107 | */ 108 | DWORD GetLastError(); 109 | 110 | /*! 111 | * @brief GetLastErrorMsg 112 | * 113 | * Get the last error message 114 | * @return CString the error message 115 | */ 116 | CString GetLastErrorMsg(); 117 | 118 | private: 119 | /*! 120 | * @brief GetSystemError 121 | * 122 | * used to get system error and save it 123 | */ 124 | void GetSystemError(); 125 | 126 | /*! 127 | * @brief FormatLastError 128 | * 129 | * format the last error code to string 130 | * @param dwLastError the error code want to format 131 | * @return CString the error message 132 | */ 133 | CString FormatLastError(DWORD dwLastError); 134 | 135 | CString m_sLastError; 136 | DWORD m_nLastError; 137 | 138 | CString m_sIniFile; 139 | }; 140 | 141 | } -------------------------------------------------------------------------------- /themes/default/src/views/HomeView.vue: -------------------------------------------------------------------------------- 1 | 65 | 66 | 125 | 126 | 143 | -------------------------------------------------------------------------------- /themes/simple/src/views/HomeView.vue: -------------------------------------------------------------------------------- 1 | 66 | 67 | 126 | 127 | 144 | -------------------------------------------------------------------------------- /themes/default/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | export const isWebview = !!window?.chrome?.webview; 3 | 4 | /** 5 | * 发送事件到客户端 6 | * @param event 事件 7 | * @param data 数据 8 | */ 9 | export function send(event: string, data: any=null ) { 10 | // @ts-ignore 11 | if (!isWebview) return; 12 | // @ts-ignore 13 | window.chrome.webview.postMessage(JSON.stringify({ event, data })); 14 | } 15 | 16 | /** 17 | * 监听客户端返回数据 18 | * @param callback 监听函数 19 | * @returns 20 | */ 21 | export function listen(callback: (event: string, data: any) => void) { 22 | // @ts-ignore 23 | if (!isWebview) return; 24 | // @ts-ignore 25 | window.chrome.webview.addEventListener('message', (event) => { 26 | const { event: e, data } = event.data; 27 | callback(e, data); 28 | }); 29 | } 30 | 31 | /** 32 | * 便签操作类 33 | */ 34 | export class App { 35 | static listener: { [key: string]: ((data: any) => void)[] } = {}; 36 | /** 37 | * 初始化,进入便签时调用 38 | */ 39 | static init () { 40 | send('listen'); 41 | listen((ev, data) => { 42 | if (this.listener[ev]) this.listener[ev].forEach(fn => fn(data)) 43 | }) 44 | } 45 | 46 | /** 47 | * 隐藏便签 48 | */ 49 | static hide () { 50 | send('hide') 51 | } 52 | 53 | /** 54 | * 触发/停止移动窗口 55 | * @param move 是否移动 56 | */ 57 | static move (move: boolean) { 58 | send('move', move) 59 | } 60 | 61 | /** 62 | * 关闭便签 63 | */ 64 | static close () { 65 | send('close') 66 | } 67 | 68 | /** 69 | * 监听客户端事件 70 | * @param event 事件名,比如 setting:设置项目更新,lock:鼠标穿透开关,data:便签数据更新 71 | * @param callback 回调 72 | */ 73 | static on(event: string, callback: (data: any) => void) { 74 | this.listener[event] = this.listener[event] || []; 75 | this.listener[event].push(callback) 76 | } 77 | 78 | /** 79 | * 关闭客户端监听 80 | * @param event 事件名 81 | * @param callback 回调 82 | */ 83 | static off(event: string, callback: (data: any) => void) { 84 | this.listener[event].splice(this.listener[event].indexOf(callback), 1) 85 | } 86 | } 87 | 88 | /** 89 | * 设置操作类 90 | */ 91 | export class Config { 92 | /** 93 | * 设置背景色 94 | * @param color 背景颜色 95 | */ 96 | static bgcolor(color: string) { 97 | send('bgcolor', color) 98 | } 99 | 100 | /** 101 | * 开启关闭半透明 102 | * @param value 是否可透明 103 | */ 104 | static opacityable (value: boolean) { 105 | send('opacityable', value) 106 | } 107 | 108 | /** 109 | * 开启/关闭鼠标穿透 110 | * @param value 是否开启鼠标穿透 111 | */ 112 | static lock (value: boolean) { 113 | send('lock', value) 114 | } 115 | 116 | /** 117 | * 开启/关闭窗口置顶 118 | * @param value 是否置顶 119 | */ 120 | static top (value: boolean) { 121 | send('top', value) 122 | } 123 | 124 | /** 125 | * 设置便签标题 126 | * @param value 便签标题 127 | */ 128 | static title(value:string) { 129 | send('title', value) 130 | } 131 | } 132 | 133 | /** 134 | * 便签项定义与操作类 135 | */ 136 | export class Note { 137 | /** 138 | * 便签id 139 | */ 140 | id: number = 0; 141 | /** 142 | * 是否完成 143 | */ 144 | finish: boolean = false; 145 | /** 146 | * 便签内容 147 | */ 148 | content: string = ''; 149 | /** 150 | * 是否可编辑 151 | */ 152 | editable?: boolean; 153 | 154 | constructor(content = '') { 155 | this.id = new Date().getTime(); 156 | this.content = content; 157 | } 158 | 159 | /** 160 | * 添加便签项 161 | * @param data 便签内容 162 | */ 163 | static add (data: Note) { 164 | send('add', data) 165 | } 166 | 167 | /** 168 | * 更新便签项 169 | * @param data 便签项 170 | */ 171 | static update (data: Note) { 172 | send('update', data) 173 | } 174 | 175 | /** 176 | * 删除便签项 177 | * @param data 便签项 178 | */ 179 | static remove (data: Note) { 180 | send('remove', data) 181 | } 182 | 183 | /** 184 | * 添加便签项目到日程 185 | * @param data 便签项 186 | */ 187 | static makeTask (data: Note) { 188 | send('task', data) 189 | } 190 | 191 | /** 192 | * 清空便签项 193 | */ 194 | static clear () { 195 | send('clear') 196 | } 197 | 198 | /** 199 | * 批量更新便签项,通常用于排序 200 | * @param notes 便签项列表 201 | */ 202 | static updateAll (notes: Note[]) { 203 | send('update_all', notes) 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /themes/simple/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | export const isWebview = !!window?.chrome?.webview; 3 | 4 | /** 5 | * 发送事件到客户端 6 | * @param event 事件 7 | * @param data 数据 8 | */ 9 | export function send(event: string, data: any=null ) { 10 | // @ts-ignore 11 | if (!isWebview) return; 12 | // @ts-ignore 13 | window.chrome.webview.postMessage(JSON.stringify({ event, data })); 14 | } 15 | 16 | /** 17 | * 监听客户端返回数据 18 | * @param callback 监听函数 19 | * @returns 20 | */ 21 | export function listen(callback: (event: string, data: any) => void) { 22 | // @ts-ignore 23 | if (!isWebview) return; 24 | // @ts-ignore 25 | window.chrome.webview.addEventListener('message', (event) => { 26 | const { event: e, data } = event.data; 27 | callback(e, data); 28 | }); 29 | } 30 | 31 | /** 32 | * 便签操作类 33 | */ 34 | export class App { 35 | static listener: { [key: string]: ((data: any) => void)[] } = {}; 36 | /** 37 | * 初始化,进入便签时调用 38 | */ 39 | static init () { 40 | send('listen'); 41 | listen((ev, data) => { 42 | if (this.listener[ev]) this.listener[ev].forEach(fn => fn(data)) 43 | }) 44 | } 45 | 46 | /** 47 | * 隐藏便签 48 | */ 49 | static hide () { 50 | send('hide') 51 | } 52 | 53 | /** 54 | * 触发/停止移动窗口 55 | * @param move 是否移动 56 | */ 57 | static move (move: boolean) { 58 | send('move', move) 59 | } 60 | 61 | /** 62 | * 关闭便签 63 | */ 64 | static close () { 65 | send('close') 66 | } 67 | 68 | /** 69 | * 监听客户端事件 70 | * @param event 事件名,比如 setting:设置项目更新,lock:鼠标穿透开关,data:便签数据更新 71 | * @param callback 回调 72 | */ 73 | static on(event: string, callback: (data: any) => void) { 74 | this.listener[event] = this.listener[event] || []; 75 | this.listener[event].push(callback) 76 | } 77 | 78 | /** 79 | * 关闭客户端监听 80 | * @param event 事件名 81 | * @param callback 回调 82 | */ 83 | static off(event: string, callback: (data: any) => void) { 84 | this.listener[event].splice(this.listener[event].indexOf(callback), 1) 85 | } 86 | } 87 | 88 | /** 89 | * 设置操作类 90 | */ 91 | export class Config { 92 | /** 93 | * 设置背景色 94 | * @param color 背景颜色 95 | */ 96 | static bgcolor(color: string) { 97 | send('bgcolor', color) 98 | } 99 | 100 | /** 101 | * 开启关闭半透明 102 | * @param value 是否可透明 103 | */ 104 | static opacityable (value: boolean) { 105 | send('opacityable', value) 106 | } 107 | 108 | /** 109 | * 开启/关闭鼠标穿透 110 | * @param value 是否开启鼠标穿透 111 | */ 112 | static lock (value: boolean) { 113 | send('lock', value) 114 | } 115 | 116 | /** 117 | * 开启/关闭窗口置顶 118 | * @param value 是否置顶 119 | */ 120 | static top (value: boolean) { 121 | send('top', value) 122 | } 123 | 124 | /** 125 | * 设置便签标题 126 | * @param value 便签标题 127 | */ 128 | static title(value:string) { 129 | send('title', value) 130 | } 131 | } 132 | 133 | /** 134 | * 便签项定义与操作类 135 | */ 136 | export class Note { 137 | /** 138 | * 便签id 139 | */ 140 | id: number = 0; 141 | /** 142 | * 是否完成 143 | */ 144 | finish: boolean = false; 145 | /** 146 | * 便签内容 147 | */ 148 | content: string = ''; 149 | /** 150 | * 是否可编辑 151 | */ 152 | editable?: boolean; 153 | 154 | constructor(content = '') { 155 | this.id = new Date().getTime(); 156 | this.content = content; 157 | } 158 | 159 | /** 160 | * 添加便签项 161 | * @param data 便签内容 162 | */ 163 | static add (data: Note) { 164 | send('add', data) 165 | } 166 | 167 | /** 168 | * 更新便签项 169 | * @param data 便签项 170 | */ 171 | static update (data: Note) { 172 | send('update', data) 173 | } 174 | 175 | /** 176 | * 删除便签项 177 | * @param data 便签项 178 | */ 179 | static remove (data: Note) { 180 | send('remove', data) 181 | } 182 | 183 | /** 184 | * 添加便签项目到日程 185 | * @param data 便签项 186 | */ 187 | static makeTask (data: Note) { 188 | send('task', data) 189 | } 190 | 191 | /** 192 | * 清空便签项 193 | */ 194 | static clear () { 195 | send('clear') 196 | } 197 | 198 | /** 199 | * 批量更新便签项,通常用于排序 200 | * @param notes 便签项列表 201 | */ 202 | static updateAll (notes: Note[]) { 203 | send('update_all', notes) 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /themes/default/src/views/NoteItem.vue: -------------------------------------------------------------------------------- 1 | 2 | 56 | 106 | 107 | 136 | -------------------------------------------------------------------------------- /Notes/app/Note.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Note.h" 3 | #include 4 | #include 5 | #include 6 | 7 | CNote::CNote() 8 | { 9 | } 10 | 11 | CNote::CNote(CString sName) 12 | { 13 | if (sName.IsEmpty()) sName = CTime::GetCurrentTime().Format(_T("%Y%m%d%H%M%S")); 14 | if(!CNoteConfig::GetNoteGroup(sName, m_noteGroup)) 15 | CNoteConfig::SetNoteGroup(m_noteGroup); 16 | } 17 | 18 | CNote::~CNote(void) 19 | { 20 | } 21 | 22 | bool CNote::Create(CString sName) 23 | { 24 | if (sName.IsEmpty()) sName = CTime::GetCurrentTime().Format(_T("%Y%m%d%H%M%S")); 25 | if (!CNoteConfig::GetNoteGroup(sName, m_noteGroup)) { 26 | CNoteConfig::SetNoteGroup(m_noteGroup); 27 | return false; 28 | } 29 | return true; 30 | } 31 | 32 | bool CNote::Rename(CString sName) 33 | { 34 | if (!CNoteConfig::RenameNoteGroup(m_noteGroup.sName, sName)) return false; 35 | 36 | m_noteGroup.sName = sName; 37 | CNoteConfig::SetNoteGroup(m_noteGroup); 38 | 39 | return true; 40 | } 41 | 42 | CString CNote::GetName() 43 | { 44 | return m_noteGroup.sName; 45 | } 46 | 47 | NoteGroup& CNote::GetNoteGroup() 48 | { 49 | return m_noteGroup; 50 | } 51 | 52 | void CNote::SetNoteGroup(NoteGroup group) 53 | { 54 | m_noteGroup = group; 55 | CNoteConfig::SetNoteGroup(m_noteGroup); 56 | } 57 | 58 | void CNote::SetNoteItems(vector items) 59 | { 60 | m_noteGroup.vNotes = items; 61 | CNoteConfig::SetNoteGroup(m_noteGroup); 62 | } 63 | 64 | void CNote::SetNoteItem(NoteItem item, int nIndex, bool bNew) 65 | { 66 | if (bNew) m_noteGroup.vNotes.push_back(item); 67 | else { 68 | for (int i = 0; i < m_noteGroup.vNotes.size(); i++) 69 | { 70 | if (m_noteGroup.vNotes[i].uId == item.uId) { 71 | m_noteGroup.vNotes[i] = item; 72 | break; 73 | } 74 | } 75 | } 76 | CNoteConfig::SetNoteGroup(m_noteGroup); 77 | } 78 | 79 | void CNote::UpdateRect(CRect rc) 80 | { 81 | m_noteGroup.rect = rc; 82 | CNoteConfig::SetNoteGroup(m_noteGroup); 83 | } 84 | 85 | void CNote::UpdateOpacity(int nOpacity) 86 | { 87 | m_noteGroup.nOpacity = nOpacity; 88 | CNoteConfig::SetNoteGroup(m_noteGroup); 89 | } 90 | 91 | void CNote::UpdateOpacityAble(bool bOpacityAble) 92 | { 93 | m_noteGroup.bOpacity = bOpacityAble; 94 | CNoteConfig::SetNoteGroup(m_noteGroup); 95 | } 96 | 97 | void CNote::UpdateTopMost(bool bTopMost) 98 | { 99 | m_noteGroup.bTopMost = bTopMost; 100 | CNoteConfig::SetNoteGroup(m_noteGroup); 101 | } 102 | 103 | void CNote::UpdateBgColor(COLORREF clrBg) 104 | { 105 | m_noteGroup.bgColor = clrBg; 106 | CNoteConfig::SetNoteGroup(m_noteGroup); 107 | } 108 | 109 | void CNote::UpdateTitle(CString sTitle) 110 | { 111 | m_noteGroup.sTitle = sTitle; 112 | CNoteConfig::SetNoteGroup(m_noteGroup); 113 | } 114 | 115 | void CNote::MakeTask(NoteItem item) 116 | { 117 | CString sPath = Path::GetTmpDirectory(Cvt::ToString(CTime(GetCurrentTime()), _T("%Y%m%d%H%M%S")) + _T(".ics")); 118 | CString icsTpl = _T("BEGIN:VCALENDAR\n\ 119 | VERSION:2.0\n\ 120 | PRODID:-//Hancel.Lin//StickyNotes//EN\n\ 121 | BEGIN:VEVENT\n\ 122 | UID:{UID}\n\ 123 | DTSTAMP:{DTSTAMP}\n\ 124 | DTSTART:{DTSTART}\n\ 125 | DTEND :{DTEND}\n\ 126 | SUMMARY:{SUMMARY}\n\ 127 | LOCATION:\n\ 128 | DESCRIPTION:{DESCRIPTION}\n\ 129 | EN:VEVENT\n\ 130 | END:VCALENDAR"); 131 | icsTpl.Replace(_T("{UID}"), Cvt::ToString(item.uId)); 132 | icsTpl.Replace(_T("{DTSTAMP}"), Cvt::ToString(CTime::GetCurrentTime(), _T("%Y%m%dT%H%M%SZ"))); 133 | icsTpl.Replace(_T("{DTSTART}"), Cvt::ToString(CTime::GetCurrentTime(), _T("%Y%m%dT%H%M%SZ"))); 134 | icsTpl.Replace(_T("{DTEND}"), Cvt::ToString(CTime::GetCurrentTime(), _T("%Y%m%dT%H%M%SZ"))); 135 | icsTpl.Replace(_T("{SUMMARY}"), item.sContent); 136 | icsTpl.Replace(_T("{DESCRIPTION}"), item.sContent); 137 | 138 | std::wstring_convert> converter; 139 | std::string utf8String = converter.to_bytes((LPCTSTR)icsTpl); 140 | 141 | std::ofstream file(sPath); 142 | if (file.is_open()) { 143 | file << utf8String; 144 | file.close(); 145 | } 146 | 147 | ShellExecute(NULL, _T("open"), sPath, NULL, NULL, SW_SHOWNORMAL); 148 | } 149 | 150 | void CNote::Hide() 151 | { 152 | m_noteGroup.bVisible = true; 153 | CNoteConfig::SetNoteGroup(m_noteGroup); 154 | } 155 | 156 | void CNote::Clear() 157 | { 158 | DeleteFile(CNoteConfig::NotesDir() + m_noteGroup.sName + _T(".json")); 159 | } -------------------------------------------------------------------------------- /themes/simple/src/views/NoteItem.vue: -------------------------------------------------------------------------------- 1 | 2 | 56 | 105 | 106 | 137 | -------------------------------------------------------------------------------- /themes/default/src/App.vue: -------------------------------------------------------------------------------- 1 | 65 | 66 | 124 | 125 | 130 | -------------------------------------------------------------------------------- /Notes/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | MICROSOFT FOUNDATION CLASS LIBRARY : Notes Project Overview 3 | =============================================================================== 4 | 5 | The application wizard has created this Notes application for 6 | you. This application not only demonstrates the basics of using the Microsoft 7 | Foundation Classes but is also a starting point for writing your application. 8 | 9 | This file contains a summary of what you will find in each of the files that 10 | make up your Notes application. 11 | 12 | Notes.vcxproj 13 | This is the main project file for VC++ projects generated using an application wizard. 14 | It contains information about the version of Visual C++ that generated the file, and 15 | information about the platforms, configurations, and project features selected with the 16 | application wizard. 17 | 18 | Notes.vcxproj.filters 19 | This is the filters file for VC++ projects generated using an Application Wizard. 20 | It contains information about the association between the files in your project 21 | and the filters. This association is used in the IDE to show grouping of files with 22 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 23 | "Source Files" filter). 24 | 25 | Notes.h 26 | This is the main header file for the application. It includes other 27 | project specific headers (including Resource.h) and declares the 28 | CNotesApp application class. 29 | 30 | Notes.cpp 31 | This is the main application source file that contains the application 32 | class CNotesApp. 33 | 34 | Notes.rc 35 | This is a listing of all of the Microsoft Windows resources that the 36 | program uses. It includes the icons, bitmaps, and cursors that are stored 37 | in the RES subdirectory. This file can be directly edited in Microsoft 38 | Visual C++. Your project resources are in 1033. 39 | 40 | res\Notes.ico 41 | This is an icon file, which is used as the application's icon. This 42 | icon is included by the main resource file Notes.rc. 43 | 44 | res\Notes.rc2 45 | This file contains resources that are not edited by Microsoft 46 | Visual C++. You should place all resources not editable by 47 | the resource editor in this file. 48 | 49 | 50 | ///////////////////////////////////////////////////////////////////////////// 51 | 52 | The application wizard creates one dialog class: 53 | 54 | NotesDlg.h, NotesDlg.cpp - the dialog 55 | These files contain your CNotesDlg class. This class defines 56 | the behavior of your application's main dialog. The dialog's template is 57 | in Notes.rc, which can be edited in Microsoft Visual C++. 58 | 59 | 60 | ///////////////////////////////////////////////////////////////////////////// 61 | 62 | Other Features: 63 | 64 | ActiveX Controls 65 | The application includes support to use ActiveX controls. 66 | 67 | ///////////////////////////////////////////////////////////////////////////// 68 | 69 | Other standard files: 70 | 71 | StdAfx.h, StdAfx.cpp 72 | These files are used to build a precompiled header (PCH) file 73 | named Notes.pch and a precompiled types file named StdAfx.obj. 74 | 75 | Resource.h 76 | This is the standard header file, which defines new resource IDs. 77 | Microsoft Visual C++ reads and updates this file. 78 | 79 | Notes.manifest 80 | Application manifest files are used by Windows XP to describe an applications 81 | dependency on specific versions of Side-by-Side assemblies. The loader uses this 82 | information to load the appropriate assembly from the assembly cache or private 83 | from the application. The Application manifest maybe included for redistribution 84 | as an external .manifest file that is installed in the same folder as the application 85 | executable or it may be included in the executable in the form of a resource. 86 | ///////////////////////////////////////////////////////////////////////////// 87 | 88 | Other notes: 89 | 90 | The application wizard uses "TODO:" to indicate parts of the source code you 91 | should add to or customize. 92 | 93 | If your application uses MFC in a shared DLL, you will need 94 | to redistribute the MFC DLLs. If your application is in a language 95 | other than the operating system's locale, you will also have to 96 | redistribute the corresponding localized resources MFC100XXX.DLL. 97 | For more information on both of these topics, please see the section on 98 | redistributing Visual C++ applications in MSDN documentation. 99 | 100 | ///////////////////////////////////////////////////////////////////////////// 101 | -------------------------------------------------------------------------------- /themes/simple/src/App.vue: -------------------------------------------------------------------------------- 1 | 65 | 66 | 125 | 126 | 140 | -------------------------------------------------------------------------------- /Notes/ref/Log.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Log.h" 3 | 4 | DWORD CLogApp::m_dwLogType = (DWORD)LOG_DEBUG; 5 | CString CLogApp::m_sPath = CLogApp::GetCurDirectory() + _T("error.log"); 6 | CListBox* CLogApp::m_pListBox = NULL; 7 | 8 | CLogApp::CLogApp(void) 9 | { 10 | m_dwLogType = (DWORD)LOG_DEBUG; 11 | } 12 | 13 | void CLogApp::Init( DWORD dwType, CString sPath/*=_T("")*/ ) 14 | { 15 | m_dwLogType = dwType; 16 | if(sPath.IsEmpty()) sPath = GetCurDirectory() + _T("error.log"); 17 | m_sPath = sPath; 18 | DeleteFile(m_sPath); 19 | } 20 | 21 | CLogApp::~CLogApp(void) 22 | { 23 | } 24 | 25 | CString CLogApp::GetCurDirectory() 26 | { 27 | CString sModuleFile = _T(""); 28 | GetModuleFileName(NULL, sModuleFile.GetBuffer(MAX_PATH), MAX_PATH); 29 | sModuleFile.ReleaseBuffer(); 30 | if(sModuleFile != _T("")) 31 | { 32 | sModuleFile = sModuleFile.Left(sModuleFile.ReverseFind('\\') + 1); 33 | } 34 | 35 | return sModuleFile; 36 | } 37 | 38 | CString CLogApp::Write( const TCHAR* pszFormat, ... ) 39 | { 40 | ASSERT(pszFormat && *pszFormat); 41 | 42 | TCHAR szMsg[1024]; 43 | va_list vargs; 44 | 45 | va_start(vargs, pszFormat); 46 | 47 | _vsnwprintf_s( szMsg, sizeof(szMsg) - 1, pszFormat, vargs); 48 | 49 | CString sLog(szMsg); 50 | CString sTime; 51 | SYSTEMTIME st; 52 | memset(&st, 0, sizeof(SYSTEMTIME)); 53 | GetLocalTime(&st); 54 | sTime.Format(_T("%04d-%02d-%02d %02d:%02d:%02d.%03d"),st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); 55 | 56 | if (m_dwLogType & LOG_FILE) { 57 | CStdioFile Logfile; 58 | if(Logfile.Open(m_sPath, CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate)) 59 | { 60 | 61 | Logfile.SeekToEnd(); 62 | Logfile.WriteString(sTime + _T(" >>> ") + sLog + _T("\n")); 63 | Logfile.Close(); 64 | } 65 | 66 | va_end(vargs); 67 | } 68 | 69 | if (m_dwLogType & LOG_PRINT) { 70 | _tprintf(sTime + _T(" >>> ") + sLog + _T("\n")); 71 | } 72 | 73 | if (m_dwLogType & LOG_DEBUG) { 74 | OutputDebugString(sTime + _T(" >>> ") + sLog + _T("\n")); 75 | } 76 | 77 | if (m_dwLogType & LOG_LIST) { 78 | if (m_pListBox != NULL) m_pListBox->AddString(sTime + _T(" >>> ") + sLog + _T("\n")); 79 | if (m_pListBox != NULL) m_pListBox->SetTopIndex(m_pListBox->GetCount() - 1); 80 | } 81 | 82 | return sLog; 83 | } 84 | 85 | CString CLogApp::Debug( const TCHAR* pszFormat, ... ) 86 | { 87 | ASSERT(pszFormat && *pszFormat); 88 | 89 | TCHAR szMsg[1024]; 90 | va_list vargs; 91 | 92 | va_start(vargs, pszFormat); 93 | 94 | _vsnwprintf_s( szMsg, sizeof(szMsg) - 1, pszFormat, vargs); 95 | 96 | CString sLog(szMsg); 97 | CString sTime; 98 | SYSTEMTIME st; 99 | memset(&st, 0, sizeof(SYSTEMTIME)); 100 | GetLocalTime(&st); 101 | sTime.Format(_T("%04d-%02d-%02d %02d:%02d:%02d.%03d"),st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); 102 | 103 | OutputDebugString(sTime + _T(" >>> ") + sLog + _T("\n")); 104 | 105 | return sLog; 106 | } 107 | 108 | CString CLogApp::Print( const TCHAR* pszFormat, ... ) 109 | { 110 | ASSERT(pszFormat && *pszFormat); 111 | 112 | TCHAR szMsg[1024]; 113 | va_list vargs; 114 | 115 | va_start(vargs, pszFormat); 116 | 117 | _vsnwprintf_s( szMsg, sizeof(szMsg) - 1, pszFormat, vargs); 118 | 119 | CString sLog(szMsg); 120 | CString sTime; 121 | SYSTEMTIME st; 122 | memset(&st, 0, sizeof(SYSTEMTIME)); 123 | GetLocalTime(&st); 124 | sTime.Format(_T("%04d-%02d-%02d %02d:%02d:%02d.%03d"),st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); 125 | 126 | _tprintf(sTime + _T(" >>> ") + sLog + _T("\n")); 127 | 128 | return sLog; 129 | } 130 | 131 | CString CLogApp::WriteFile( const TCHAR* pszFormat, ... ) 132 | { 133 | ASSERT(pszFormat && *pszFormat); 134 | 135 | TCHAR szMsg[1024]; 136 | va_list vargs; 137 | 138 | va_start(vargs, pszFormat); 139 | 140 | _vsnwprintf_s( szMsg, sizeof(szMsg) - 1, pszFormat, vargs); 141 | 142 | CString sLog(szMsg); 143 | CString sTime; 144 | SYSTEMTIME st; 145 | memset(&st, 0, sizeof(SYSTEMTIME)); 146 | GetLocalTime(&st); 147 | sTime.Format(_T("%04d-%02d-%02d %02d:%02d:%02d.%03d"),st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); 148 | 149 | CStdioFile Logfile; 150 | if(Logfile.Open(m_sPath, CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate)) 151 | { 152 | 153 | Logfile.SeekToEnd(); 154 | Logfile.WriteString(sTime + _T(" >>> ") + sLog + _T("\n")); 155 | Logfile.Close(); 156 | } 157 | 158 | va_end(vargs); 159 | 160 | return sLog; 161 | } 162 | 163 | CString CLogApp::List( const TCHAR* pszFormat, ... ) 164 | { 165 | ASSERT(pszFormat && *pszFormat); 166 | 167 | TCHAR szMsg[1024]; 168 | va_list vargs; 169 | 170 | va_start(vargs, pszFormat); 171 | 172 | _vsnwprintf_s( szMsg, sizeof(szMsg) - 1, pszFormat, vargs); 173 | 174 | CString sLog(szMsg); 175 | CString sTime; 176 | SYSTEMTIME st; 177 | memset(&st, 0, sizeof(SYSTEMTIME)); 178 | GetLocalTime(&st); 179 | sTime.Format(_T("%04d-%02d-%02d %02d:%02d:%02d.%03d"),st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); 180 | 181 | if(m_pListBox != NULL) m_pListBox->AddString(sTime + _T(" >>> ") + sLog + _T("\n")); 182 | 183 | return sLog; 184 | } 185 | -------------------------------------------------------------------------------- /Notes/control/HotKeyEdit.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "HotKeyEdit.h" 3 | 4 | 5 | CHotKeyEdit::CHotKeyEdit(void) 6 | { 7 | m_bHotKey = false; 8 | m_bSingleKey = false; 9 | m_bRecord = false; 10 | m_uExtendKey = 0; 11 | } 12 | 13 | 14 | CHotKeyEdit::~CHotKeyEdit(void) 15 | { 16 | } 17 | BEGIN_MESSAGE_MAP(CHotKeyEdit, CEdit) 18 | ON_WM_INPUT() 19 | ON_CONTROL_REFLECT(EN_SETFOCUS, &CHotKeyEdit::OnEnSetfocus) 20 | ON_CONTROL_REFLECT(EN_KILLFOCUS, &CHotKeyEdit::OnEnKillfocus) 21 | ON_WM_CHAR() 22 | ON_WM_TIMER() 23 | END_MESSAGE_MAP() 24 | 25 | 26 | void CHotKeyEdit::OnRawInput(UINT nInputcode, HRAWINPUT hRawInput) 27 | { 28 | UINT dwSize = 0; 29 | BYTE* lpb = NULL; 30 | RAWINPUT* raw = NULL; 31 | 32 | GetRawInputData(hRawInput, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)); 33 | if (dwSize == 0) goto DONE; 34 | 35 | lpb = new BYTE[dwSize]; 36 | if (GetRawInputData(hRawInput, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) 37 | goto DONE; 38 | 39 | raw = (RAWINPUT*)lpb; 40 | if (raw->header.dwType == RIM_TYPEKEYBOARD) 41 | { 42 | static RAWKEYBOARD keyLast = {0}; 43 | RAWKEYBOARD keyboard = raw->data.keyboard; 44 | 45 | if(keyboard.Flags == keyLast.Flags 46 | && keyboard.VKey == keyLast.VKey) goto DONE; 47 | 48 | if(keyboard.Flags & RI_KEY_BREAK && m_bRecord){ 49 | if(!m_bHotKey || !IsExtendKey(keyboard.VKey)) m_bRecord = false; 50 | else PopKey(keyboard.VKey); 51 | } 52 | else if (keyboard.Flags == RI_KEY_MAKE || keyboard.Flags == RI_KEY_E0) 53 | { 54 | if (!m_bRecord || m_bSingleKey) { 55 | m_uKeyCode = 0; 56 | m_uExtendKey = 0; 57 | } 58 | PushKey(keyboard.VKey); 59 | m_bRecord = true; 60 | } 61 | 62 | keyLast = keyboard; 63 | } 64 | 65 | DONE: 66 | if(lpb != NULL) delete lpb; 67 | 68 | CEdit::OnRawInput(nInputcode, hRawInput); 69 | } 70 | 71 | 72 | void CHotKeyEdit::OnEnSetfocus() 73 | { 74 | CRawInput::Register(m_hWnd, RAW_TYPE_KB); 75 | } 76 | 77 | 78 | void CHotKeyEdit::OnEnKillfocus() 79 | { 80 | CRawInput::Remove(m_hWnd, RAW_TYPE_KB); 81 | } 82 | 83 | 84 | void CHotKeyEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 85 | { 86 | // TODO: Add your message handler code here and/or call default 87 | 88 | // CEdit::OnChar(nChar, nRepCnt, nFlags); 89 | } 90 | 91 | 92 | BOOL CHotKeyEdit::PreTranslateMessage(MSG* pMsg) 93 | { 94 | if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) 95 | { 96 | return TRUE; 97 | } 98 | 99 | return CEdit::PreTranslateMessage(pMsg); 100 | } 101 | 102 | void CHotKeyEdit::PushKey( USHORT vKeyCode ) 103 | { 104 | if (m_bHotKey && IsExtendKey(vKeyCode)) 105 | { 106 | switch (vKeyCode) 107 | { 108 | case VK_CONTROL: m_uExtendKey |= CONTROL; break; 109 | case VK_SHIFT: m_uExtendKey |= SHIFT; break; 110 | case VK_MENU: m_uExtendKey |= ALT; break; 111 | case VK_LWIN: 112 | case VK_RWIN: m_uExtendKey |= WIN; break; 113 | } 114 | } 115 | else 116 | m_uKeyCode = vKeyCode; 117 | ShowKeys(); 118 | } 119 | 120 | void CHotKeyEdit::PopKey( USHORT vKeyCode ) 121 | { 122 | switch (vKeyCode) 123 | { 124 | case VK_CONTROL: m_uExtendKey &= ~CONTROL; break; 125 | case VK_SHIFT: m_uExtendKey &= ~SHIFT; break; 126 | case VK_MENU: m_uExtendKey &= ~ALT; break; 127 | case VK_LWIN: 128 | case VK_RWIN: m_uExtendKey &= ~WIN; break; 129 | } 130 | ShowKeys(); 131 | } 132 | 133 | void CHotKeyEdit::ShowKeys( void ) 134 | { 135 | CString sValue; 136 | 137 | if (m_bHotKey) 138 | { 139 | if(m_uExtendKey & WIN) sValue += _T("Win + "); 140 | if(m_uExtendKey & CONTROL) sValue += _T("Ctrl + "); 141 | if(m_uExtendKey & ALT) sValue += _T("Alt + "); 142 | if(m_uExtendKey & SHIFT) sValue += _T("Shift + "); 143 | } 144 | 145 | sValue += CHotKey::GetHotKeyName(m_uKeyCode); 146 | sValue = sValue.Trim(_T(" + ")); 147 | SetWindowText(sValue); 148 | } 149 | 150 | void CHotKeyEdit::SetSingleKey( bool bSingle, bool bHotKey/*=false*/ ) 151 | { 152 | m_bSingleKey = bSingle; 153 | m_bHotKey = bHotKey; 154 | } 155 | 156 | bool CHotKeyEdit::IsExtendKey( USHORT vKeyCode ) 157 | { 158 | return (VK_SHIFT == vKeyCode || 159 | VK_CONTROL == vKeyCode || 160 | VK_MENU == vKeyCode || 161 | VK_LWIN == vKeyCode || 162 | VK_RWIN == vKeyCode ); 163 | } 164 | 165 | DWORD CHotKeyEdit::GetHotKeyByString(CString sHotKey) 166 | { 167 | DWORD dwHotKey = 0; 168 | if (sHotKey.IsEmpty()) 169 | return dwHotKey; 170 | 171 | vector lstKeys = Cvt::SplitString(sHotKey, _T("+")); 172 | if (lstKeys.size() == 0) 173 | return dwHotKey; 174 | 175 | for (int i = 0; i < lstKeys.size(); i++) 176 | { 177 | CString sKey = lstKeys.at(i); 178 | sKey.Trim(); 179 | sKey.MakeUpper(); 180 | 181 | if (sKey == _T("WIN")) 182 | dwHotKey |= WIN; 183 | else if (sKey == _T("CTRL")) 184 | dwHotKey |= CONTROL; 185 | else if (sKey == _T("ALT")) 186 | dwHotKey |= ALT; 187 | else if (sKey == _T("SHIFT")) 188 | dwHotKey |= SHIFT; 189 | else 190 | { 191 | USHORT uKeyCode = CHotKey::GetHotKeyCode(sKey); 192 | if (uKeyCode != 0) 193 | dwHotKey |= uKeyCode; 194 | } 195 | } 196 | 197 | 198 | 199 | return dwHotKey; 200 | } 201 | 202 | void CHotKeyEdit::SetHotKey(DWORD dwHotKey) 203 | { 204 | m_uKeyCode = dwHotKey & 0xFF; 205 | m_uExtendKey = (dwHotKey >> 8) & 0xFF; 206 | m_bHotKey = true; 207 | ShowKeys(); 208 | } 209 | 210 | DWORD CHotKeyEdit::GetHotKey(void) 211 | { 212 | DWORD dwHotKey = 0; 213 | if (m_bHotKey) 214 | { 215 | dwHotKey = m_uExtendKey; 216 | dwHotKey <<= 8; 217 | dwHotKey |= m_uKeyCode; 218 | } 219 | return dwHotKey; 220 | } 221 | 222 | 223 | void CHotKeyEdit::OnTimer(UINT_PTR nIDEvent) 224 | { 225 | // TODO: Add your message handler code here and/or call default 226 | 227 | CEdit::OnTimer(nIDEvent); 228 | } 229 | 230 | -------------------------------------------------------------------------------- /Notes/Notes.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {74aaf450-03cb-42a5-82f0-fbde78bd91ae} 6 | 7 | 8 | {6fba9fe0-0c76-4151-ad7d-412262673399} 9 | 10 | 11 | {75aa9ffb-0359-4d37-80f4-d7c295aa7da9} 12 | 13 | 14 | {4bd0cef8-18b3-472c-a0be-e5ef5cdea348} 15 | 16 | 17 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 18 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 19 | 20 | 21 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 22 | h;hpp;hxx;hm;inl;inc;xsd 23 | 24 | 25 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 26 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 27 | 28 | 29 | 30 | 31 | 32 | res 33 | 34 | 35 | res 36 | 37 | 38 | 39 | 40 | 41 | header 42 | 43 | 44 | header 45 | 46 | 47 | header 48 | 49 | 50 | header 51 | 52 | 53 | ref 54 | 55 | 56 | ref 57 | 58 | 59 | ref 60 | 61 | 62 | ref 63 | 64 | 65 | ref 66 | 67 | 68 | ref 69 | 70 | 71 | ref 72 | 73 | 74 | ref 75 | 76 | 77 | ref 78 | 79 | 80 | control 81 | 82 | 83 | app 84 | 85 | 86 | view 87 | 88 | 89 | view 90 | 91 | 92 | header 93 | 94 | 95 | header 96 | 97 | 98 | header 99 | 100 | 101 | ref 102 | 103 | 104 | app 105 | 106 | 107 | 108 | 109 | src 110 | 111 | 112 | src 113 | 114 | 115 | ref 116 | 117 | 118 | ref 119 | 120 | 121 | ref 122 | 123 | 124 | ref 125 | 126 | 127 | ref 128 | 129 | 130 | ref 131 | 132 | 133 | ref 134 | 135 | 136 | ref 137 | 138 | 139 | ref 140 | 141 | 142 | control 143 | 144 | 145 | view 146 | 147 | 148 | view 149 | 150 | 151 | app 152 | 153 | 154 | src 155 | 156 | 157 | src 158 | 159 | 160 | ref 161 | 162 | 163 | app 164 | 165 | 166 | 167 | 168 | res 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /Notes/app/Config.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Config.h" 3 | 4 | Setting CConfig::m_setting; 5 | 6 | CString CConfig::NotesDir() 7 | { 8 | CString sNoteDir = m_setting.sNoteDir; 9 | if (!Path::Exists(sNoteDir)) 10 | { 11 | Path::Create(sNoteDir); 12 | } 13 | return sNoteDir; 14 | } 15 | 16 | void CConfig::LoadNoteGroup(vector& lstName) 17 | { 18 | vector lstConfig = Path::GetFileList(NotesDir(), _T("*.ini")); 19 | for (int i = 0; i < lstConfig.size(); i++) 20 | { 21 | CString sNote = Path::GetFileName(lstConfig[i]); 22 | lstName.push_back(sNote.Mid(0, sNote.GetLength() - 4)); 23 | } 24 | } 25 | 26 | bool CConfig::GetNoteGroup(CString sName, NoteGroup& group) 27 | { 28 | CString sConfigFile = Path::Resolve(NotesDir(), sName + _T(".ini")); 29 | 30 | group.sName = sName; 31 | if (!Path::Exists(sConfigFile)) return false; 32 | 33 | Ini ini(sConfigFile); 34 | int nCount = 0; 35 | CString sRect; 36 | ini.Read(_T("Group"), _T("Count"), nCount); 37 | ini.Read(_T("Group"), _T("Name"), group.sName); 38 | ini.Read(_T("Group"), _T("Rect"), sRect); 39 | ini.Read(_T("Group"), _T("Opacity"), group.nOpacity); 40 | ini.Read(_T("Group"), _T("OpacityAble"), group.bOpacity); 41 | ini.Read(_T("Group"), _T("Visible"), group.bVisible); 42 | ini.Read(_T("Group"), _T("TopMost"), group.bTopMost); 43 | ini.Read(_T("Group"), _T("BgColor"), group.bgColor); 44 | ini.Read(_T("Group"), _T("Title"), group.sTitle); 45 | vector lstRect = Cvt::SplitString(sRect, _T(",")); 46 | group.rect = CRect(_ttoi(lstRect[0]), _ttoi(lstRect[1]), _ttoi(lstRect[2]), _ttoi(lstRect[3])); 47 | 48 | for (int i = 0; i < nCount; i++) 49 | { 50 | NoteItem item; 51 | CString sKey = _T("Note") + Cvt::ToString(i); 52 | ini.Read(sKey, _T("Id"), item.uId); 53 | ini.Read(sKey, _T("Content"), item.sContent); 54 | ini.Read(sKey, _T("Finished"), item.bFinished); 55 | item.sContent.Replace(_T("{{\\n}}"), _T("\n")); 56 | group.vNotes.push_back(item); 57 | } 58 | 59 | return true; 60 | } 61 | 62 | void CConfig::SetNoteGroup( NoteGroup group) 63 | { 64 | CString sConfigFile = Path::Resolve(NotesDir(), group.sName + _T(".ini")); 65 | 66 | CLogApp::Write(_T("SetNoteGroup: ") + sConfigFile); 67 | 68 | Ini ini(sConfigFile); 69 | ini.Write(_T("Group"), _T("Count"), (int)group.vNotes.size()); 70 | ini.Write(_T("Group"), _T("Name"), group.sName); 71 | ini.Write(_T("Group"), _T("Opacity"), group.nOpacity); 72 | ini.Write(_T("Group"), _T("OpacityAble"), group.bOpacity); 73 | ini.Write(_T("Group"), _T("Visible"), group.bVisible); 74 | ini.Write(_T("Group"), _T("TopMost"), group.bTopMost); 75 | ini.Write(_T("Group"), _T("Rect"), Cvt::ToString(group.rect.left) + _T(",") + Cvt::ToString(group.rect.top) + _T(",") + Cvt::ToString(group.rect.right) + _T(",") + Cvt::ToString(group.rect.bottom)); 76 | ini.Write(_T("Group"), _T("BgColor"), group.bgColor); 77 | ini.Write(_T("Group"), _T("Title"), group.sTitle); 78 | 79 | for (int i = 0; i < group.vNotes.size(); i++) { 80 | NoteItem item = group.vNotes.at(i); 81 | CString sKey = _T("Note") + Cvt::ToString(i); 82 | item.sContent.Replace(_T("\n"), _T("{{\\n}}")); 83 | ini.Write(sKey, _T("Id"), item.uId); 84 | ini.Write(sKey, _T("Content"), item.sContent); 85 | ini.Write(sKey, _T("Finished"), item.bFinished); 86 | } 87 | } 88 | 89 | bool CConfig::RenameNoteGroup(CString sOldName, CString sNewName) 90 | { 91 | CString sOldConfigFile = Path::Resolve(NotesDir(), sOldName + _T(".ini")); 92 | CString sNewConfigFile = Path::Resolve(NotesDir(), sNewName + _T(".ini")); 93 | if (Path::Exists(sOldConfigFile) && !Path::Exists(sNewConfigFile)) 94 | { 95 | CopyFile(sOldConfigFile, sNewConfigFile, FALSE); 96 | DeleteFile(sOldConfigFile); 97 | return true; 98 | } 99 | return false; 100 | } 101 | 102 | void CConfig::LoadSetting(Setting& setting) 103 | { 104 | CString sConfigFile = Path::GetCurDirectory(_T("setting.ini")); 105 | 106 | if (!Path::Exists(sConfigFile)) return; 107 | 108 | Ini ini(sConfigFile); 109 | ini.Read(_T("HotKey"), _T("Edit"), setting.dwEditHotKey); 110 | ini.Read(_T("HotKey"), _T("New"), setting.dwNewHotKey); 111 | ini.Read(_T("HotKey"), _T("UnActive"), setting.dwUnActiveHotKey); 112 | ini.Read(_T("HotKey"), _T("ActiveAll"), setting.dwActiveAllHotKey); 113 | ini.Read(_T("Setting"), _T("NoteDir"), setting.sNoteDir); 114 | ini.Read(_T("Setting"), _T("Theme"), setting.sTheme); 115 | ini.Read(_T("Setting"), _T("AutoRun"), setting.bAutoRun); 116 | ini.Read(_T("Setting"), _T("CustomWebview2"), setting.bCustomWebview2); 117 | ini.Read(_T("Setting"), _T("Webview2Path"), setting.sWebview2Path); 118 | 119 | if (setting.sTheme.IsEmpty()) setting.sTheme = _T("Default"); 120 | 121 | m_setting = setting; 122 | } 123 | 124 | void CConfig::SaveSetting(Setting setting) 125 | { 126 | CString sConfigFile = Path::GetCurDirectory(_T("setting.ini")); 127 | 128 | setting.sNoteDir = setting.sNoteDir.Trim('\\') + _T("\\"); 129 | 130 | Ini ini(sConfigFile); 131 | ini.Write(_T("HotKey"), _T("Edit"), setting.dwEditHotKey); 132 | ini.Write(_T("HotKey"), _T("New"), setting.dwNewHotKey); 133 | ini.Write(_T("HotKey"), _T("UnActive"), setting.dwUnActiveHotKey); 134 | ini.Write(_T("HotKey"), _T("ActiveAll"), setting.dwActiveAllHotKey); 135 | ini.Write(_T("Setting"), _T("NoteDir"), setting.sNoteDir); 136 | ini.Write(_T("Setting"), _T("Theme"), setting.sTheme); 137 | ini.Write(_T("Setting"), _T("AutoRun"), setting.bAutoRun); 138 | ini.Write(_T("Setting"), _T("CustomWebview2"), setting.bCustomWebview2); 139 | ini.Write(_T("Setting"), _T("Webview2Path"), setting.sWebview2Path); 140 | 141 | m_setting = setting; 142 | } 143 | 144 | Setting& CConfig::GetCurrentSetting() 145 | { 146 | return m_setting; 147 | } 148 | 149 | void CConfig::SearchThemes(vector& lstName) 150 | { 151 | vector lstConfig = Path::GetFileList(Path::GetCurDirectory(_T("themes")), _T("*"), true); 152 | for (int i = 0; i < lstConfig.size(); i++) 153 | { 154 | if (!Path::Exists(_PATH_JOIN(lstConfig[i], _T("index.html")))) continue; 155 | CString sNote = Path::GetFileName(lstConfig[i]); 156 | lstName.push_back(sNote); 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /Notes/ref/Ini.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "ini.h" 3 | 4 | namespace Easy { 5 | 6 | Ini::Ini(void) 7 | { 8 | } 9 | 10 | Ini::Ini( CString sPath ) 11 | { 12 | SetFile(sPath); 13 | } 14 | 15 | Ini::~Ini(void) 16 | { 17 | } 18 | 19 | void Ini::SetFile( CString sPath ) 20 | { 21 | m_sIniFile = sPath; 22 | } 23 | 24 | bool Ini::GetAllSections( vector& sSections ) 25 | { 26 | const int nBufferSize = 102400; 27 | TCHAR szValue[nBufferSize] = {0}; 28 | DWORD dwBuffer = GetPrivateProfileString(NULL, NULL, NULL, szValue, nBufferSize, m_sIniFile.GetBuffer()); 29 | m_sIniFile.ReleaseBuffer(); 30 | 31 | sSections.clear(); 32 | if(dwBuffer == 0) 33 | { 34 | GetSystemError(); 35 | return false; 36 | } 37 | 38 | sSections.push_back(CString(szValue)); 39 | for (DWORD nPos = 0; nPos < dwBuffer; nPos++) 40 | { 41 | if (szValue[nPos] == _T('\0')) 42 | { 43 | CString sSection = CString(szValue + nPos + 1); 44 | if(!sSection.IsEmpty())sSections.push_back(sSection); 45 | } 46 | } 47 | return true; 48 | } 49 | 50 | bool Ini::GetAllKeys( CString sSection, vector& sKeys ) 51 | { 52 | const int nBufferSize = 102400; 53 | TCHAR szValue[nBufferSize] = {0}; 54 | DWORD dwBuffer = GetPrivateProfileString(sSection.GetBuffer(), NULL, NULL, szValue, nBufferSize, m_sIniFile.GetBuffer()); 55 | sSection.ReleaseBuffer(); 56 | m_sIniFile.ReleaseBuffer(); 57 | 58 | sKeys.clear(); 59 | if(dwBuffer == 0) 60 | { 61 | GetSystemError(); 62 | return false; 63 | } 64 | 65 | sKeys.push_back(CString(szValue)); 66 | for (DWORD nPos = 0; nPos < dwBuffer; nPos++) 67 | { 68 | if (szValue[nPos] == _T('\0')) 69 | { 70 | CString sKey = CString(szValue + nPos + 1); 71 | if (!sKey.IsEmpty()) sKeys.push_back(CString(szValue + nPos + 1)); 72 | } 73 | } 74 | return true; 75 | } 76 | 77 | bool Ini::Read( CString sSection, CString sKeyName, CString& sValue ) 78 | { 79 | DWORD dwBuffer = GetPrivateProfileString(sSection.GetBuffer(), sKeyName.GetBuffer(), NULL, sValue.GetBuffer(1024), 1024, m_sIniFile.GetBuffer()); 80 | 81 | sSection.ReleaseBuffer(); 82 | sKeyName.ReleaseBuffer(); 83 | sValue.ReleaseBuffer(); 84 | m_sIniFile.ReleaseBuffer(); 85 | 86 | if(dwBuffer != 0) 87 | { 88 | return true; 89 | } 90 | 91 | GetSystemError(); 92 | return false; 93 | } 94 | 95 | bool Ini::Read( CString sSection, CString sKeyName, ULONG& dwValue ) 96 | { 97 | CString sValue; 98 | bool bSuccess = Read(sSection, sKeyName, sValue); 99 | 100 | if(bSuccess) dwValue = _ttoll(sValue); 101 | return bSuccess; 102 | } 103 | 104 | bool Ini::Read( CString sSection, CString sKeyName, int& nValue ) 105 | { 106 | CString sValue; 107 | bool bSuccess = Read(sSection, sKeyName, sValue); 108 | 109 | if(bSuccess) nValue = _ttoi(sValue); 110 | return bSuccess; 111 | } 112 | 113 | bool Ini::Read( CString sSection, CString sKeyName, UINT& nValue ) 114 | { 115 | CString sValue; 116 | bool bSuccess = Read(sSection, sKeyName, sValue); 117 | 118 | if(bSuccess) nValue = _ttol(sValue); 119 | return bSuccess; 120 | } 121 | 122 | bool Ini::Read( CString sSection, CString sKeyName, long& nValue ) 123 | { 124 | CString sValue; 125 | bool bSuccess = Read(sSection, sKeyName, sValue); 126 | 127 | if(bSuccess) nValue = _ttol(sValue); 128 | return bSuccess; 129 | } 130 | 131 | bool Ini::Read( CString sSection, CString sKeyName, bool& bValue ) 132 | { 133 | CString sValue; 134 | bool bSuccess = Read(sSection, sKeyName, sValue); 135 | 136 | if(bSuccess) bValue = _ttol(sValue) != 0; 137 | return bSuccess; 138 | } 139 | 140 | bool Ini::Write( CString sSection, CString sKeyName, CString sValue ) 141 | { 142 | bool bSuccess = WritePrivateProfileString(sSection.GetBuffer(), sKeyName.GetBuffer(), sValue.GetBuffer(), m_sIniFile.GetBuffer()); 143 | 144 | sSection.ReleaseBuffer(); 145 | sKeyName.ReleaseBuffer(); 146 | sValue.ReleaseBuffer(); 147 | m_sIniFile.ReleaseBuffer(); 148 | 149 | if(!bSuccess) GetSystemError(); 150 | return bSuccess; 151 | } 152 | 153 | bool Ini::Write( CString sSection, CString sKeyName, DWORD dwValue ) 154 | { 155 | CString sValue; 156 | _ultot_s(dwValue, sValue.GetBuffer(100), 100, 10); 157 | sValue.ReleaseBuffer(); 158 | 159 | return Write(sSection, sKeyName, sValue); 160 | } 161 | 162 | bool Ini::Write( CString sSection, CString sKeyName, int nValue ) 163 | { 164 | CString sValue; 165 | _itot_s(nValue, sValue.GetBuffer(100), 100, 10); 166 | sValue.ReleaseBuffer(); 167 | 168 | return Write(sSection, sKeyName, sValue); 169 | } 170 | 171 | bool Ini::Write( CString sSection, CString sKeyName, UINT nValue ) 172 | { 173 | CString sValue; 174 | _ltot_s(nValue, sValue.GetBuffer(100), 100, 10); 175 | sValue.ReleaseBuffer(); 176 | 177 | return Write(sSection, sKeyName, sValue); 178 | } 179 | 180 | bool Ini::Write( CString sSection, CString sKeyName, long nValue ) 181 | { 182 | CString sValue; 183 | _ltot_s(nValue, sValue.GetBuffer(100), 100, 10); 184 | sValue.ReleaseBuffer(); 185 | 186 | return Write(sSection, sKeyName, sValue); 187 | } 188 | 189 | bool Ini::Write( CString sSection, CString sKeyName, bool bValue ) 190 | { 191 | return Write(sSection, sKeyName, CString(bValue ? _T("1") : _T("0"))); 192 | } 193 | 194 | bool Ini::Remove( CString sSection, CString sKeyName ) 195 | { 196 | bool bSuccess = WritePrivateProfileString(sSection.GetBuffer(), sKeyName.GetBuffer(), NULL, m_sIniFile.GetBuffer()); 197 | 198 | sSection.ReleaseBuffer(); 199 | sKeyName.ReleaseBuffer(); 200 | m_sIniFile.ReleaseBuffer(); 201 | 202 | if(!bSuccess) GetSystemError(); 203 | return bSuccess; 204 | } 205 | 206 | bool Ini::Remove( CString sSection ) 207 | { 208 | bool bSuccess = WritePrivateProfileString(sSection.GetBuffer(), NULL, NULL, m_sIniFile.GetBuffer()); 209 | 210 | sSection.ReleaseBuffer(); 211 | m_sIniFile.ReleaseBuffer(); 212 | 213 | if(!bSuccess) GetSystemError(); 214 | return bSuccess; 215 | } 216 | 217 | CString Ini::GetLastErrorMsg() 218 | { 219 | return m_sLastError; 220 | } 221 | 222 | DWORD Ini::GetLastError() 223 | { 224 | return m_nLastError; 225 | } 226 | 227 | CString Ini::FormatLastError( DWORD dwLastError ) 228 | { 229 | LPVOID lpMsgBuf; 230 | CString sErrMsg = _T(""); 231 | 232 | FormatMessage( 233 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 234 | FORMAT_MESSAGE_FROM_SYSTEM | 235 | FORMAT_MESSAGE_IGNORE_INSERTS, 236 | NULL, 237 | dwLastError, 238 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 239 | (LPTSTR) &lpMsgBuf, 240 | 0, NULL); 241 | 242 | sErrMsg.Format(_T("%s"), lpMsgBuf); 243 | LocalFree(lpMsgBuf); 244 | 245 | return sErrMsg; 246 | } 247 | 248 | void Ini::GetSystemError() 249 | { 250 | LPVOID lpMsgBuf; 251 | m_nLastError = ::GetLastError(); 252 | 253 | FormatMessage( 254 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 255 | FORMAT_MESSAGE_FROM_SYSTEM | 256 | FORMAT_MESSAGE_IGNORE_INSERTS, 257 | NULL, 258 | m_nLastError, 259 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 260 | (LPTSTR) &lpMsgBuf, 261 | 0, NULL); 262 | 263 | m_sLastError.Format(_T("Error Code: %d.\r\nError Message: %s"), m_nLastError, lpMsgBuf); 264 | LocalFree(lpMsgBuf); 265 | } 266 | 267 | } -------------------------------------------------------------------------------- /Notes/ref/Registry.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Registry.h" 3 | 4 | 5 | namespace Easy 6 | { 7 | 8 | Registry::Registry() 9 | { 10 | Init(HKEY_CURRENT_USER, false); 11 | } 12 | 13 | Registry::Registry(HKEY hKey, bool bWOW6432) 14 | { 15 | Init(hKey, bWOW6432); 16 | } 17 | 18 | void Registry::Init( HKEY hKey, bool bWOW6432 /*= false*/ ) 19 | { 20 | m_hKey = hKey; 21 | m_dwWOW6432 = bWOW6432 ? KEY_WOW64_32KEY : KEY_WOW64_64KEY; 22 | } 23 | 24 | bool Registry::IsExisted(CString sSubKey) 25 | { 26 | HKEY hKey = NULL; 27 | sSubKey = sSubKey.TrimLeft(_T('\\')); 28 | DWORD dwErr = RegOpenKeyEx(m_hKey, sSubKey, 0, KEY_READ | m_dwWOW6432, &hKey); 29 | if(ERROR_SUCCESS != dwErr) 30 | { 31 | return false; 32 | } 33 | 34 | RegCloseKey(hKey); 35 | return true; 36 | } 37 | 38 | bool Registry::CreateKey(CString sSubKey) 39 | { 40 | int nCurPos = 0; 41 | sSubKey = sSubKey.TrimLeft(_T('\\')); 42 | CString sChildKey = sSubKey.Tokenize(_T("\\"), nCurPos); 43 | while (_T("") != sChildKey) 44 | { 45 | TCHAR szKey[260]; 46 | _tcscpy_s(szKey, 260, sSubKey.Mid(0, nCurPos - 1)); 47 | m_nLastError = ERROR_SUCCESS; 48 | if(!IsExisted(szKey)) 49 | { 50 | HKEY hKey = NULL; 51 | m_nLastError = RegCreateKey(m_hKey, szKey, &hKey); 52 | RegCloseKey(hKey); 53 | } 54 | 55 | if(ERROR_SUCCESS != m_nLastError) 56 | { 57 | m_sLastError = FormatLastError(m_nLastError); return false; 58 | } 59 | 60 | sChildKey = sSubKey.Tokenize(_T("\\"), nCurPos); 61 | } 62 | 63 | return true; 64 | } 65 | 66 | bool Registry::DeleteKey(CString sSubKey) 67 | { 68 | sSubKey = sSubKey.TrimLeft(_T('\\')); 69 | m_nLastError = RegDeleteKey(m_hKey, sSubKey); 70 | if(ERROR_SUCCESS != m_nLastError) 71 | { 72 | m_sLastError = FormatLastError(m_nLastError); return false; 73 | } 74 | 75 | return true; 76 | } 77 | 78 | bool Registry::DeleteValue(CString sSubKey, CString sValueName) 79 | { 80 | HKEY hKey = NULL; 81 | sSubKey = sSubKey.TrimLeft(_T('\\')); 82 | m_nLastError = RegOpenKeyEx(m_hKey, sSubKey, 0, KEY_SET_VALUE | m_dwWOW6432, &hKey); 83 | if(ERROR_SUCCESS != m_nLastError) 84 | { 85 | m_sLastError = FormatLastError(m_nLastError); return false; 86 | } 87 | 88 | m_nLastError = RegDeleteValue(hKey, sValueName); 89 | RegCloseKey(hKey); 90 | 91 | if(ERROR_SUCCESS != m_nLastError) 92 | { 93 | m_sLastError = FormatLastError(m_nLastError); return false; 94 | } 95 | 96 | return true; 97 | } 98 | 99 | bool Registry::Read(CString sSubKey, CString sValueName, int& nValue) 100 | { 101 | DWORD dwValue = 0; 102 | if(!Read(sSubKey, sValueName, dwValue)) return false; 103 | nValue = (int)dwValue; 104 | return true; 105 | } 106 | 107 | bool Registry::Read(CString sSubKey, CString sValueName, bool& bValue) 108 | { 109 | DWORD dwValue = 0; 110 | if(!Read(sSubKey, sValueName, dwValue)) return false; 111 | bValue = (0 != dwValue) ? true : false; 112 | return true; 113 | } 114 | 115 | bool Registry::Read(CString sSubKey, CString sValueName, UINT& nValue) 116 | { 117 | DWORD dwValue = 0; 118 | if(!Read(sSubKey, sValueName, dwValue)) return false; 119 | nValue = (UINT)dwValue; 120 | return true; 121 | } 122 | 123 | bool Registry::Read(CString sSubKey, CString sValueName, long& nValue) 124 | { 125 | DWORD dwValue = 0; 126 | if(!Read(sSubKey, sValueName, dwValue)) return false; 127 | nValue = (long)dwValue; 128 | return true; 129 | } 130 | 131 | bool Registry::Read(CString sSubKey, CString sValueName, DWORD& dwValue) 132 | { 133 | DWORD dwSize = sizeof(DWORD); 134 | return Read(sSubKey, sValueName, &dwValue, dwSize); 135 | } 136 | 137 | bool Registry::Read(CString sSubKey, CString sValueName, CString& sValue) 138 | { 139 | DWORD dwSize = 2048; 140 | TCHAR szValue[2048] = {0}; 141 | if(!Read(sSubKey, sValueName, szValue, dwSize)) return false; 142 | sValue.Format(_T("%s"), szValue); 143 | return true; 144 | } 145 | 146 | bool Registry::Read(CString sSubKey, CString sValueName, LPVOID lpData, DWORD& dwDataSize) 147 | { 148 | HKEY hKey = NULL; 149 | sSubKey = sSubKey.TrimLeft(_T('\\')); 150 | m_nLastError = RegOpenKeyEx(m_hKey, sSubKey, 0, KEY_READ | m_dwWOW6432, &hKey); 151 | if(ERROR_SUCCESS != m_nLastError) 152 | { 153 | m_sLastError = FormatLastError(m_nLastError); return false; 154 | } 155 | 156 | m_nLastError = RegQueryValueEx(hKey, sValueName, NULL, NULL, (LPBYTE)lpData, &dwDataSize); 157 | RegCloseKey(hKey); 158 | if(ERROR_SUCCESS != m_nLastError) 159 | { 160 | m_sLastError = FormatLastError(m_nLastError); return false; 161 | } 162 | 163 | return true; 164 | } 165 | 166 | bool Registry::Write(CString sSubKey, CString sValueName, int nValue) 167 | { 168 | DWORD dwValue = (DWORD)nValue; 169 | return Write(sSubKey, sValueName, dwValue); 170 | } 171 | 172 | bool Registry::Write(CString sSubKey, CString sValueName, bool bValue) 173 | { 174 | DWORD dwValue = (DWORD)bValue; 175 | return Write(sSubKey, sValueName, dwValue); 176 | } 177 | 178 | bool Registry::Write(CString sSubKey, CString sValueName, UINT nValue) 179 | { 180 | DWORD dwValue = (DWORD)nValue; 181 | return Write(sSubKey, sValueName, dwValue); 182 | } 183 | 184 | bool Registry::Write(CString sSubKey, CString sValueName, long nValue) 185 | { 186 | DWORD dwValue = (DWORD)nValue; 187 | return Write(sSubKey, sValueName, dwValue); 188 | } 189 | 190 | bool Registry::Write(CString sSubKey, CString sValueName, DWORD dwValue) 191 | { 192 | return Write(sSubKey, sValueName, &dwValue, sizeof(DWORD), REG_DWORD); 193 | } 194 | 195 | bool Registry::Write(CString sSubKey, CString sValueName, CString sValue) 196 | { 197 | DWORD dwLen = sValue.GetLength(); 198 | bool bSuccessful = Write(sSubKey, sValueName, sValue.GetBuffer(dwLen), dwLen * sizeof(TCHAR), REG_SZ); 199 | sValue.ReleaseBuffer(); 200 | return bSuccessful; 201 | } 202 | 203 | bool Registry::Write(CString sSubKey, CString sValueName, LPVOID lpData, DWORD dwDataSize, DWORD dwType) 204 | { 205 | if(!IsExisted(sSubKey)) 206 | { 207 | CreateKey(sSubKey); 208 | } 209 | 210 | HKEY hKey = NULL; 211 | sSubKey = sSubKey.TrimLeft(_T('\\')); 212 | m_nLastError = RegOpenKeyEx(m_hKey, sSubKey, 0, KEY_WRITE | m_dwWOW6432, &hKey); 213 | if(ERROR_SUCCESS != m_nLastError) 214 | { 215 | m_sLastError = FormatLastError(m_nLastError); return false; 216 | } 217 | 218 | m_nLastError = RegSetValueEx(hKey, sValueName, NULL, dwType, (LPBYTE)lpData, dwDataSize); 219 | RegCloseKey(hKey); 220 | if(ERROR_SUCCESS != m_nLastError) 221 | { 222 | m_sLastError = FormatLastError(m_nLastError); return false; 223 | } 224 | 225 | return true; 226 | } 227 | 228 | CString Registry::GetLastErrorMsg() 229 | { 230 | return m_sLastError; 231 | } 232 | 233 | DWORD Registry::GetLastError() 234 | { 235 | return m_nLastError; 236 | } 237 | 238 | CString Registry::FormatLastError( DWORD dwLastError ) 239 | { 240 | LPVOID lpMsgBuf; 241 | CString sErrMsg = _T(""); 242 | 243 | FormatMessage( 244 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 245 | FORMAT_MESSAGE_FROM_SYSTEM | 246 | FORMAT_MESSAGE_IGNORE_INSERTS, 247 | NULL, 248 | dwLastError, 249 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 250 | (LPTSTR) &lpMsgBuf, 251 | 0, NULL); 252 | 253 | sErrMsg.Format(_T("%s"), lpMsgBuf); 254 | LocalFree(lpMsgBuf); 255 | 256 | return sErrMsg; 257 | } 258 | 259 | } -------------------------------------------------------------------------------- /Notes/ref/Shell.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Shell.h" 3 | 4 | namespace Easy { 5 | 6 | Shell::Shell(void) 7 | { 8 | m_bRunning = false; 9 | m_hRead = INVALID_HANDLE_VALUE; 10 | m_hWnd = NULL; 11 | ZeroMemory(&m_pi, sizeof(PROCESS_INFORMATION)); 12 | } 13 | 14 | 15 | Shell::~Shell(void) 16 | { 17 | } 18 | 19 | bool Shell::Execute( CString sPath, CString sCommand/*=_T("")*/, SHELL_TYPE type/*=APP*/, bool bShow/*=true*/, CString sWorkDirectory/*=Path::GetCurDirectory()*/ ) 20 | { 21 | switch (type) 22 | { 23 | case CONSOLE: return ExecuteConsole(sPath, sCommand, bShow, sWorkDirectory); 24 | case APP: return ExecuteApplication(sPath, sCommand, bShow, sWorkDirectory); 25 | } 26 | return true; 27 | } 28 | 29 | bool Shell::IsRunning( void ) 30 | { 31 | if (NULL != m_pi.hProcess && 32 | WAIT_TIMEOUT == WaitForSingleObject(m_pi.hProcess, 0)) 33 | { 34 | return true; 35 | } 36 | 37 | return m_bRunning; 38 | } 39 | 40 | bool Shell::Stop( void ) 41 | { 42 | if (!IsRunning()) return true; 43 | 44 | bool bSuccess = TerminateProcess(m_pi.hProcess, 0); 45 | if (!bSuccess) GetSystemError(); 46 | 47 | return bSuccess; 48 | } 49 | 50 | CString Shell::GetOutput( void ) 51 | { 52 | return m_sOutput; 53 | } 54 | 55 | HWND Shell::GetWnd( void ) 56 | { 57 | if (m_hWnd == NULL) EnumWindows(EnumWindowsProc, (LPARAM)this); 58 | return m_hWnd; 59 | } 60 | 61 | DWORD Shell::ShellThread( LPVOID lpParam ) 62 | { 63 | Shell* pThis = (Shell*)lpParam; 64 | 65 | const DWORD dwSize = 40960; 66 | char szBuffer[dwSize] = {0}; 67 | DWORD dwRead = 0; 68 | int nTry = 5; 69 | 70 | while(EnumWindows(EnumWindowsProc, (LPARAM)pThis) && nTry--) Sleep(100); 71 | 72 | if (pThis->m_hWnd == NULL) pThis->GetSystemError(); 73 | 74 | pThis->m_bRunning = true; 75 | pThis->m_sOutput = _T(""); 76 | 77 | USES_CONVERSION; 78 | while (true) 79 | { 80 | if (ReadFile(pThis->m_hRead, szBuffer, dwSize, &dwRead, NULL) == NULL) 81 | break; 82 | pThis->m_sOutput += A2W(szBuffer); 83 | memset(szBuffer, 0, sizeof(szBuffer)); 84 | } 85 | pThis->m_sOutput += A2W(szBuffer); 86 | pThis->m_bRunning = false; 87 | 88 | if(pThis->m_hRead != INVALID_HANDLE_VALUE) CloseHandle(pThis->m_hRead); 89 | if(pThis->m_pi.hThread != INVALID_HANDLE_VALUE) CloseHandle (pThis->m_pi.hThread); 90 | if(pThis->m_pi.hProcess != INVALID_HANDLE_VALUE) CloseHandle (pThis->m_pi.hProcess); 91 | 92 | return 0; 93 | } 94 | 95 | BOOL Shell::EnumWindowsProc(HWND hWnd, LPARAM lParam) 96 | { 97 | Shell* pThis = (Shell*)lParam; 98 | 99 | DWORD dwProcessId = 0; 100 | GetWindowThreadProcessId(hWnd, &dwProcessId); 101 | if(dwProcessId == pThis->m_pi.dwProcessId && CWnd::FromHandle(hWnd)->IsWindowVisible()) 102 | { 103 | HWND h = GetParent(hWnd); 104 | while(GetParent(h)!=NULL) 105 | { 106 | h = GetParent(h); 107 | return FALSE; 108 | } 109 | pThis->m_hWnd = hWnd; 110 | return FALSE; 111 | } 112 | return TRUE; 113 | } 114 | 115 | bool Shell::ExecuteConsole( CString sPath, CString sCommand, bool bShow, CString sWorkDirectory ) 116 | { 117 | if(_T("") == sPath) 118 | { 119 | SetLastError(ERROR_INVALID_PARAMETER); 120 | return false; 121 | } 122 | 123 | m_bRunning = false; 124 | m_hRead = INVALID_HANDLE_VALUE; 125 | m_hWnd = NULL; 126 | ZeroMemory(&m_pi, sizeof(PROCESS_INFORMATION)); 127 | 128 | SECURITY_ATTRIBUTES sa; 129 | HANDLE hWrite; 130 | 131 | sa.nLength = sizeof(SECURITY_ATTRIBUTES); 132 | sa.lpSecurityDescriptor = NULL; 133 | sa.bInheritHandle = TRUE; 134 | if (!CreatePipe(&m_hRead, &hWrite, &sa, 0)) 135 | { 136 | GetSystemError(); 137 | return FALSE; 138 | } 139 | 140 | if(sWorkDirectory.IsEmpty()) sWorkDirectory = Path::GetDirectory(sPath); 141 | 142 | STARTUPINFO si; 143 | si.cb = sizeof(STARTUPINFO); 144 | GetStartupInfo(&si); 145 | si.hStdError = hWrite; 146 | si.hStdOutput = hWrite; 147 | si.wShowWindow = bShow ? SW_SHOW : SW_HIDE; 148 | si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; 149 | 150 | sCommand = _T(" ") + sCommand; 151 | 152 | if (!CreateProcess(sPath.GetBuffer(), sCommand.GetBuffer(), NULL, NULL, TRUE, NULL, NULL, sWorkDirectory.IsEmpty() ? NULL : sWorkDirectory.GetBuffer(), &si, &m_pi)) 153 | { 154 | sPath.ReleaseBuffer(); 155 | sCommand.ReleaseBuffer(); 156 | sWorkDirectory.ReleaseBuffer(); 157 | GetSystemError(); 158 | CloseHandle(hWrite); 159 | CloseHandle(m_hRead); 160 | return false; 161 | } 162 | sPath.ReleaseBuffer(); 163 | sCommand.ReleaseBuffer(); 164 | sWorkDirectory.ReleaseBuffer(); 165 | CloseHandle(hWrite); 166 | 167 | if(m_pi.dwProcessId != 0) m_bRunning = true; 168 | 169 | HANDLE hThread = CreateThread(NULL, 0, ShellThread, this, 0, NULL); 170 | 171 | if (hThread != NULL) 172 | { 173 | CloseHandle(hThread); 174 | } 175 | 176 | return true; 177 | } 178 | 179 | bool Shell::ExecuteApplication(CString sPath, CString sCommand, bool bShow, CString sWorkDirectory) 180 | { 181 | if(_T("") == sPath) 182 | { 183 | SetLastError(ERROR_INVALID_PARAMETER); 184 | return false; 185 | } 186 | 187 | m_sOutput = _T(""); 188 | m_bRunning = false; 189 | m_hRead = INVALID_HANDLE_VALUE; 190 | m_hWnd = NULL; 191 | ZeroMemory(&m_pi, sizeof(PROCESS_INFORMATION)); 192 | 193 | if(sWorkDirectory.IsEmpty()) sWorkDirectory = Path::GetDirectory(sPath); 194 | 195 | SHELLEXECUTEINFO stInfo; 196 | memset(&stInfo, 0, sizeof(SHELLEXECUTEINFO)); 197 | 198 | stInfo.cbSize = sizeof(SHELLEXECUTEINFO); 199 | stInfo.fMask = SEE_MASK_NOCLOSEPROCESS; 200 | stInfo.hwnd = NULL; 201 | stInfo.lpVerb = _T("open"); 202 | stInfo.lpFile = sPath.GetBuffer(); 203 | stInfo.lpDirectory = sWorkDirectory.GetBuffer(); 204 | stInfo.lpParameters = sCommand.GetBuffer(); 205 | stInfo.nShow = bShow ? SW_SHOW : SW_HIDE; 206 | stInfo.hInstApp = NULL; 207 | 208 | BOOL bExecute = ShellExecuteEx(&stInfo); 209 | 210 | sPath.ReleaseBuffer(); 211 | sCommand.ReleaseBuffer(); 212 | sWorkDirectory.ReleaseBuffer(); 213 | 214 | if(!bExecute) 215 | { 216 | GetSystemError(); 217 | return false; 218 | } 219 | 220 | m_pi.hProcess = stInfo.hProcess; 221 | m_pi.dwProcessId = GetProcessId(stInfo.hProcess); 222 | return true; 223 | } 224 | 225 | CString Shell::GetLastErrorMsg() 226 | { 227 | return m_sLastError; 228 | } 229 | 230 | DWORD Shell::GetLastError() 231 | { 232 | return m_nLastError; 233 | } 234 | 235 | CString Shell::FormatLastError( DWORD dwLastError ) 236 | { 237 | LPVOID lpMsgBuf; 238 | CString sErrMsg = _T(""); 239 | 240 | FormatMessage( 241 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 242 | FORMAT_MESSAGE_FROM_SYSTEM | 243 | FORMAT_MESSAGE_IGNORE_INSERTS, 244 | NULL, 245 | dwLastError, 246 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 247 | (LPTSTR) &lpMsgBuf, 248 | 0, NULL); 249 | 250 | sErrMsg.Format(_T("%s"), lpMsgBuf); 251 | LocalFree(lpMsgBuf); 252 | 253 | return sErrMsg; 254 | } 255 | 256 | void Shell::GetSystemError() 257 | { 258 | LPVOID lpMsgBuf; 259 | m_nLastError = ::GetLastError(); 260 | 261 | FormatMessage( 262 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 263 | FORMAT_MESSAGE_FROM_SYSTEM | 264 | FORMAT_MESSAGE_IGNORE_INSERTS, 265 | NULL, 266 | m_nLastError, 267 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 268 | (LPTSTR) &lpMsgBuf, 269 | 0, NULL); 270 | 271 | m_sLastError.Format(_T("Error Code: %d.\r\nError Message: %s"), m_nLastError, lpMsgBuf); 272 | LocalFree(lpMsgBuf); 273 | } 274 | 275 | } -------------------------------------------------------------------------------- /Notes/app/NoteConfig.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "NoteConfig.h" 3 | #include 4 | #include 5 | #include 6 | 7 | Setting CNoteConfig::m_setting; 8 | 9 | CString CNoteConfig::NotesDir() 10 | { 11 | CString sNoteDir = m_setting.sNoteDir; 12 | if (!Path::Exists(sNoteDir)) 13 | { 14 | Path::Create(sNoteDir); 15 | } 16 | return sNoteDir; 17 | } 18 | 19 | void CNoteConfig::LoadNoteGroup(vector& lstName) 20 | { 21 | vector lstConfig = Path::GetFileList(NotesDir(), _T("*.json")); 22 | for (int i = 0; i < lstConfig.size(); i++) 23 | { 24 | CString sNote = Path::GetFileName(lstConfig[i]); 25 | lstName.push_back(sNote.Mid(0, sNote.GetLength() - 5)); 26 | } 27 | } 28 | 29 | bool CNoteConfig::GetNoteGroup(CString sName, NoteGroup& group) 30 | { 31 | CString sConfigFile = Path::Resolve(NotesDir(), sName + _T(".json")); 32 | 33 | group.sName = sName; 34 | if (!Path::Exists(sConfigFile)) { 35 | CLogApp::Write(_T("Confg File Not Exists: ") + sConfigFile); 36 | return false; 37 | } 38 | 39 | GenericDocument> vData; 40 | 41 | CString sJson; 42 | if (!XFile::ReadFile(sConfigFile, sJson)) { 43 | CLogApp::Write(_T("Read Confg File Failed: ") + sConfigFile + _T(", ErrorCode: %d"), GetLastError()); 44 | return false; 45 | } 46 | 47 | vData.Parse(sJson.GetBuffer()); sJson.ReleaseBuffer(); 48 | if (vData.HasParseError()) { 49 | CLogApp::Write(_T("Parse Confg File Failed: ") + sConfigFile + _T(", ErrorCode: %d"), vData.GetParseError()); 50 | return false; 51 | } 52 | 53 | group.sName = vData[_T("name")].GetString(); 54 | group.sTitle = vData[_T("title")].GetString(); 55 | group.rect = CRect(vData[_T("left")].GetInt(), vData[_T("top")].GetInt(), vData[_T("right")].GetInt(), vData[_T("bottom")].GetInt()); 56 | group.bgColor = Cvt::ToColor(vData[_T("bgcolor")].GetString()); 57 | group.nOpacity = vData[_T("opacity")].GetInt(); 58 | group.bOpacity = vData[_T("opacityable")].GetBool(); 59 | group.bVisible = vData[_T("visible")].GetBool(); 60 | group.bTopMost = vData[_T("topmost")].GetBool(); 61 | const rapidjson::GenericValue>& vNotes = vData[_T("notes")]; 62 | 63 | if (!vNotes.IsArray()) { 64 | CLogApp::Write(_T("Notes is not array: ") + sConfigFile); 65 | return false; 66 | } 67 | 68 | for (int i = 0; i < vNotes.Size(); i++) 69 | { 70 | NoteItem item; 71 | item.uId = vNotes[i][_T("id")].GetUint64(); 72 | item.sContent = vNotes[i][_T("content")].GetString(); 73 | item.bFinished = vNotes[i][_T("finish")].GetBool(); 74 | group.vNotes.push_back(item); 75 | } 76 | 77 | return true; 78 | } 79 | 80 | void CNoteConfig::SetNoteGroup( NoteGroup group) 81 | { 82 | CString sConfigFile = Path::Resolve(NotesDir(), group.sName + _T(".json")); 83 | 84 | CLogApp::Write(_T("SetNoteGroup: ") + sConfigFile); 85 | Document::AllocatorType allocator; 86 | rapidjson::GenericValue> vData; 87 | CString sJson = GetJsonString(group.toJson(vData, allocator)); 88 | if (!XFile::WriteFile(sConfigFile, sJson)) { 89 | CLogApp::Write(_T("Write Confg File Failed: ") + sConfigFile + _T(", ErrorCode: %d"), GetLastError()); 90 | return; 91 | } 92 | } 93 | 94 | bool CNoteConfig::RenameNoteGroup(CString sOldName, CString sNewName) 95 | { 96 | CString sOldConfigFile = Path::Resolve(NotesDir(), sOldName + _T(".json")); 97 | CString sNewConfigFile = Path::Resolve(NotesDir(), sNewName + _T(".json")); 98 | if (Path::Exists(sOldConfigFile) && !Path::Exists(sNewConfigFile)) 99 | { 100 | CopyFile(sOldConfigFile, sNewConfigFile, FALSE); 101 | DeleteFile(sOldConfigFile); 102 | return true; 103 | } 104 | return false; 105 | } 106 | 107 | void CNoteConfig::LoadSetting(Setting& setting) 108 | { 109 | CString sConfigFile = Path::GetCurDirectory(_T("setting.ini")); 110 | 111 | if (!Path::Exists(sConfigFile)) return; 112 | 113 | Ini ini(sConfigFile); 114 | ini.Read(_T("HotKey"), _T("Edit"), setting.dwEditHotKey); 115 | ini.Read(_T("HotKey"), _T("New"), setting.dwNewHotKey); 116 | ini.Read(_T("HotKey"), _T("UnActive"), setting.dwUnActiveHotKey); 117 | ini.Read(_T("HotKey"), _T("ActiveAll"), setting.dwActiveAllHotKey); 118 | ini.Read(_T("Setting"), _T("NoteDir"), setting.sNoteDir); 119 | ini.Read(_T("Setting"), _T("Theme"), setting.sTheme); 120 | ini.Read(_T("Setting"), _T("AutoRun"), setting.bAutoRun); 121 | ini.Read(_T("Setting"), _T("CustomWebview2"), setting.bCustomWebview2); 122 | ini.Read(_T("Setting"), _T("Webview2Path"), setting.sWebview2Path); 123 | 124 | if (setting.sTheme.IsEmpty()) setting.sTheme = _T("Default"); 125 | 126 | m_setting = setting; 127 | } 128 | 129 | void CNoteConfig::SaveSetting(Setting setting) 130 | { 131 | CString sConfigFile = Path::GetCurDirectory(_T("setting.ini")); 132 | 133 | setting.sNoteDir = setting.sNoteDir.Trim('\\') + _T("\\"); 134 | 135 | Ini ini(sConfigFile); 136 | ini.Write(_T("HotKey"), _T("Edit"), setting.dwEditHotKey); 137 | ini.Write(_T("HotKey"), _T("New"), setting.dwNewHotKey); 138 | ini.Write(_T("HotKey"), _T("UnActive"), setting.dwUnActiveHotKey); 139 | ini.Write(_T("HotKey"), _T("ActiveAll"), setting.dwActiveAllHotKey); 140 | ini.Write(_T("Setting"), _T("NoteDir"), setting.sNoteDir); 141 | ini.Write(_T("Setting"), _T("Theme"), setting.sTheme); 142 | ini.Write(_T("Setting"), _T("AutoRun"), setting.bAutoRun); 143 | ini.Write(_T("Setting"), _T("CustomWebview2"), setting.bCustomWebview2); 144 | ini.Write(_T("Setting"), _T("Webview2Path"), setting.sWebview2Path); 145 | 146 | m_setting = setting; 147 | } 148 | 149 | Setting& CNoteConfig::GetCurrentSetting() 150 | { 151 | return m_setting; 152 | } 153 | 154 | void CNoteConfig::SearchThemes(vector& lstName) 155 | { 156 | vector lstConfig = Path::GetFileList(Path::GetCurDirectory(_T("themes")), _T("*"), true); 157 | for (int i = 0; i < lstConfig.size(); i++) 158 | { 159 | if (!Path::Exists(_PATH_JOIN(lstConfig[i], _T("index.html")))) continue; 160 | CString sNote = Path::GetFileName(lstConfig[i]); 161 | lstName.push_back(sNote); 162 | } 163 | } 164 | 165 | CString CNoteConfig::GetJsonString(rapidjson::GenericValue>& data) 166 | { 167 | CString sJson = _T(""); 168 | if (data.IsObject()) { 169 | sJson += _T("{"); 170 | for (auto m = data.MemberBegin(); m != data.MemberEnd(); m++) 171 | { 172 | sJson += _T("\"") + CString(m->name.GetString()) + _T("\":"); 173 | sJson += GetJsonString(m->value); 174 | if (m + 1 != data.MemberEnd()) sJson += _T(","); 175 | } 176 | sJson += _T("}"); 177 | return sJson; 178 | } 179 | if (data.IsArray()) { 180 | sJson += _T("["); 181 | for (auto m = data.Begin(); m != data.End(); m++) { 182 | sJson += GetJsonString(*m); 183 | if (m + 1 != data.End()) sJson += _T(","); 184 | } 185 | sJson += _T("]"); 186 | return sJson; 187 | } 188 | if (data.IsBool()) { 189 | return CString(data.GetBool() ? _T("true") : _T("false")); 190 | } 191 | if (data.IsUint()) { 192 | return Cvt::ToString((UINT)data.GetUint()); 193 | } 194 | if (data.IsUint64()) { 195 | return Cvt::ToString((ULONG)data.GetUint64()); 196 | } 197 | if (data.IsInt()) { 198 | return Cvt::ToString(data.GetInt()); 199 | } 200 | if (data.IsInt64()) { 201 | return Cvt::ToString((long)data.GetInt64()); 202 | } 203 | if (data.IsNull()) { 204 | return CString(_T("null")); 205 | } 206 | if (data.IsDouble()) { 207 | return Cvt::ToString(data.GetDouble()); 208 | } 209 | if (data.IsString()) { 210 | return _T("\"") + CString(data.GetString()) + _T("\""); 211 | } 212 | return CString(_T("\"Unknow Type\"")); 213 | } 214 | -------------------------------------------------------------------------------- /Notes/ref/Path.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | namespace Easy { 5 | 6 | typedef bool (WINAPI * FILITER)(CString); 7 | 8 | /*! 9 | * @class Path 10 | * @brief Path Tools 11 | * 12 | * Used to get different path 13 | */ 14 | class Path 15 | { 16 | public: 17 | 18 | /*! 19 | * @brief GetFileName 20 | * 21 | * Get filename from path 22 | * @param sPath The path. 23 | * @return CString The filename 24 | */ 25 | static CString GetFileName(CString sPath); 26 | 27 | /*! 28 | * @brief GetDirectory 29 | * 30 | * Get directory from path 31 | * @param sPath The path. 32 | * @return CString The directory 33 | */ 34 | static CString GetDirectory(CString sPath); 35 | 36 | /*! 37 | * @brief GetExtName 38 | * 39 | * Get extension from path 40 | * @param sPath The path. 41 | * @return CString The extension 42 | */ 43 | static CString GetExtName(CString sPath); 44 | 45 | 46 | /*! 47 | * @brief Resolve 48 | * 49 | * Stitching path 50 | * @param sPath The path of one. 51 | * @param sPathNext The path of next. You can use `..` to indicate the parent directory 52 | * @return CString The final path 53 | */ 54 | static CString Resolve(CString sPath, CString sPathNext); 55 | 56 | 57 | /*! 58 | * @brief Join 59 | * 60 | * Stitching path 61 | * @param sPath The path of one. 62 | * @param ... The paths of next. You can use `..` to indicate the parent directory. pls end by NULL. 63 | * @return CString The final path 64 | */ 65 | static CString Join(const TCHAR* szPath, ...); 66 | 67 | /*! 68 | * @brief Omit 69 | * 70 | * Compressed path 71 | * @param sPath The path. 72 | * @param nSize The path length you want to compressed. 73 | * @return CString The final path, like as `C:\...\sample.txt` 74 | */ 75 | static CString Omit(CString sPath, int nSize); 76 | 77 | 78 | /*! 79 | * @brief GetCurDirectory 80 | * 81 | * The Directory of Program 82 | * @param sPath The path you want to expand. 83 | * @return CString The final path 84 | */ 85 | static CString GetCurDirectory(CString sPath=_T("")); 86 | 87 | /*! 88 | * @brief GetTmpDirectory 89 | * 90 | * System temporary directory 91 | * @param sPath The path you want to expand. 92 | * @return CString The final path 93 | */ 94 | static CString GetTmpDirectory(CString sPath=_T("")); 95 | 96 | /*! 97 | * @brief GetUserDirectory 98 | * 99 | * The user root directory 100 | * @param sPath The path you want to expand. 101 | * @return CString The final path 102 | */ 103 | static CString GetUserDirectory(CString sPath=_T("")); 104 | 105 | /*! 106 | * @brief GetAppDataDirectory 107 | * 108 | * The user application data directory 109 | * @param sPath The path you want to expand. 110 | * @return CString The final path 111 | */ 112 | static CString GetAppDataDirectory(CString sPath=_T("")); 113 | 114 | /*! 115 | * @brief GetDesktopDirectory 116 | * 117 | * The user desktop path 118 | * @param sPath The path you want to expand. 119 | * @return CString The final path 120 | */ 121 | static CString GetDesktopDirectory(CString sPath=_T("")); 122 | 123 | /*! 124 | * @brief GetStartupDirectory 125 | * 126 | * The user startup path 127 | * @param sPath The path you want to expand. 128 | * @return CString The final path 129 | */ 130 | static CString GetStartupDirectory(CString sPath=_T("")); 131 | 132 | /*! 133 | * @brief GetStartMenuDirectory 134 | * 135 | * The system start menu path 136 | * @param sPath The path you want to expand. 137 | * @return CString The final path 138 | */ 139 | static CString GetStartMenuDirectory(CString sPath=_T("")); 140 | 141 | /*! 142 | * @brief GetProgramPath 143 | * 144 | * Get program path 145 | * @return CString The program path 146 | */ 147 | static CString GetProgramPath(void); 148 | 149 | /*! 150 | * @brief GetProgramName 151 | * 152 | * Get program filename 153 | * @return CString The program filename 154 | */ 155 | static CString GetProgramName(void); 156 | 157 | 158 | /*! 159 | * @brief IsDirectory 160 | * 161 | * Check Path is directory or not 162 | * @return bool Is directory or not 163 | */ 164 | static bool IsDirectory(CString sPath); 165 | 166 | /*! 167 | * @brief IsDirectory 168 | * 169 | * Check directory is empty or not 170 | * @return bool Is empty or not 171 | */ 172 | static bool IsEmpty(CString sPath); 173 | 174 | /*! 175 | * @brief Exists 176 | * 177 | * Check Path is exists or not 178 | * @return bool Is exists or not 179 | */ 180 | static bool Exists(CString sPath); 181 | 182 | /*! 183 | * @brief Exists 184 | * 185 | * Check Path is exists or not 186 | * @return bool Is exists or not 187 | */ 188 | static void Open(CString sPath); 189 | 190 | /*! 191 | * @brief Browse 192 | * 193 | * Open a dialog to browse file 194 | * @param lpszFilter A series of string pairs that specify filters you can apply to the file. For example: "Excel File(*.xls)|*.xls;||" 195 | * @param lpszDefExt The default file name extension. If this parameter is NULL, no extension is appended. 196 | * @param bOpen Type of dialog box to create, TRUE to construct a File Open dialog box. Set it to FALSE to construct a File Save As dialog box. 197 | * @param lpInitiaDir The default directory open in file dialog 198 | * @param lpszFileName The initial file name that appears in the Filename box. If NULL, no initial file name appears. 199 | * @return CString The file Path. User cancels if it's empty. 200 | */ 201 | static CString Browse(LPCTSTR lpszFilter, LPCTSTR lpszDefExt, BOOL bOpen, LPCTSTR lpszFileName, LPCTSTR lpInitiaDir=NULL); 202 | 203 | /*! 204 | * @brief Folder 205 | * 206 | * Open a dialog to browse folder 207 | * @param hWnd A handle to the owner window for the dialog box. 208 | * @param sRootPath Specifies the path of a folder to select. 209 | * @return CString The final path 210 | */ 211 | static CString Folder(HWND hWnd, CString sRootPath=_T("")); 212 | 213 | /*! 214 | * @brief Copy 215 | * 216 | * copy file or folder with a loading dialog 217 | * @param sSrc Source file or folder. 218 | * @param sDst Copy Target Path. 219 | * @return CString The final path 220 | */ 221 | static int CopyTo(vector lstSrc, CString sDst); 222 | 223 | /*! 224 | * @brief GetFileList 225 | * 226 | * Traversing folder and get file list 227 | * @param sDirectory The folder to traversing. 228 | * @param filter A Callback used to check file. It will be skip file/folder when return false 229 | * @return CString The final path 230 | */ 231 | static vector Traversing(CString sDirectory, FILITER filter=NULL); 232 | 233 | /*! 234 | * @brief Traversing 235 | * 236 | * Traversing folder and get file list 237 | * @param sDirectory The folder to traversing. 238 | * @param sFormat A Callback used to check file. It will be skip file/folder when return false 239 | * @return CString The final path 240 | */ 241 | static vector GetFileList(CString sDirectory, CString sFormat=_T("*"), bool bOnlyDirectory = false); 242 | 243 | /*! 244 | * @brief Create 245 | * 246 | * Creates all the directories in the specified path, beginning with the root. 247 | * @param sPath A valid path name. If the final component of the path is a directory, not a file name. 248 | * @return bool If the function succeeds, the return value is true; 249 | */ 250 | static bool Create(CString sPath); 251 | }; 252 | 253 | /*! 254 | * @brief PATH_JOIN 255 | * 256 | * Stitching path macro define, you don't want to add null in the end 257 | * @return CString The final path 258 | */ 259 | #define _PATH_JOIN(...) Path::Join(__VA_ARGS__, NULL) 260 | 261 | } 262 | -------------------------------------------------------------------------------- /Notes/ref/Path.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Path.h" 3 | #include 4 | #include "imagehlp.h" 5 | #pragma comment(lib, "imagehlp.lib") 6 | 7 | namespace Easy { 8 | 9 | CString Path::GetFileName( CString sPath ) 10 | { 11 | CString sFilename(PathFindFileName(sPath.GetBuffer())); 12 | sPath.ReleaseBuffer(); 13 | return sFilename; 14 | } 15 | 16 | CString Path::GetDirectory( CString sPath ) 17 | { 18 | PathRemoveFileSpec(sPath.GetBuffer()); 19 | sPath.ReleaseBuffer(); 20 | return sPath + _T("\\"); 21 | } 22 | 23 | CString Path::GetExtName( CString sPath ) 24 | { 25 | CString sFilename(PathFindExtension(sPath.GetBuffer())); 26 | sPath.ReleaseBuffer(); 27 | return sFilename; 28 | } 29 | 30 | CString Path::Resolve( CString sPath, CString sPathNext ) 31 | { 32 | PathAddBackslash(sPath.GetBuffer(sPath.GetLength() + 1)); 33 | sPath.ReleaseBuffer(); 34 | CString sPathFull = sPath + sPathNext; 35 | CString sPathFinal; 36 | 37 | PathCanonicalize(sPathFinal.GetBuffer(sPathFull.GetLength() + 100), sPathFull.GetBuffer()); 38 | sPathFinal.ReleaseBuffer(); 39 | sPathFull.ReleaseBuffer(); 40 | 41 | if (IsDirectory(sPathFinal)) PathAddBackslash(sPathFinal.GetBuffer(sPath.GetLength() + 1)); 42 | sPathFinal.ReleaseBuffer(); 43 | 44 | return sPathFinal; 45 | } 46 | 47 | CString Path::Join( const TCHAR* szPath, ... ) 48 | { 49 | va_list vargs; 50 | int argno = 0; 51 | const TCHAR* next; 52 | va_start( vargs, szPath ); 53 | CString sPath(szPath); 54 | 55 | while ((next = va_arg( vargs, const TCHAR*)) != NULL) 56 | { 57 | sPath = Resolve(sPath, CString(next)); 58 | } 59 | 60 | va_end( vargs ); 61 | 62 | return sPath; 63 | } 64 | 65 | CString Path::Omit( CString sPath, int nSize ) 66 | { 67 | CString sOmitPath; 68 | PathCompactPathEx(sOmitPath.GetBuffer(sPath.GetLength() + 100), sPath.GetBuffer(), nSize, 0); 69 | sOmitPath.ReleaseBuffer(); 70 | sPath.ReleaseBuffer(); 71 | 72 | return sOmitPath; 73 | } 74 | 75 | CString Path::GetCurDirectory( CString sPath/*=_T("")*/ ) 76 | { 77 | return Resolve(GetDirectory(GetProgramPath()), sPath); 78 | } 79 | 80 | CString Path::GetTmpDirectory( CString sPath/*=_T("")*/ ) 81 | { 82 | DWORD dwLen = 1024; 83 | TCHAR szPath[1024] = {0}; 84 | if(0 != GetTempPath(dwLen, szPath)) 85 | { 86 | return Resolve(CString(szPath), sPath); 87 | } 88 | return _T(""); 89 | } 90 | 91 | CString Path::GetUserDirectory( CString sPath/*=_T("")*/ ) 92 | { 93 | return Resolve(GetDesktopDirectory() + _T(".."), sPath); 94 | } 95 | 96 | CString Path::GetAppDataDirectory( CString sPath/*=_T("")*/ ) 97 | { 98 | TCHAR szPath[MAX_PATH]; 99 | SHGetSpecialFolderPath(NULL, szPath, CSIDL_LOCAL_APPDATA, FALSE); 100 | return Resolve(CString(szPath), sPath); 101 | } 102 | 103 | CString Path::GetDesktopDirectory( CString sPath/*=_T("")*/ ) 104 | { 105 | TCHAR szPath[MAX_PATH]; 106 | SHGetSpecialFolderPath(NULL, szPath, CSIDL_DESKTOPDIRECTORY, FALSE); 107 | return Resolve(CString(szPath), sPath); 108 | } 109 | 110 | CString Path::GetStartupDirectory( CString sPath/*=_T("")*/ ) 111 | { 112 | TCHAR szPath[MAX_PATH]; 113 | SHGetSpecialFolderPath(NULL, szPath, CSIDL_STARTUP, FALSE); 114 | return Resolve(CString(szPath), sPath); 115 | } 116 | 117 | CString Path::GetStartMenuDirectory( CString sPath/*=_T("")*/ ) 118 | { 119 | TCHAR szPath[MAX_PATH]; 120 | SHGetSpecialFolderPath(NULL, szPath, CSIDL_STARTMENU, FALSE); 121 | return Resolve(CString(szPath), sPath); 122 | } 123 | 124 | CString Path::GetProgramPath(void) 125 | { 126 | CString sPath = _T(""); 127 | GetModuleFileName(NULL, sPath.GetBuffer(MAX_PATH), MAX_PATH); 128 | sPath.ReleaseBuffer(); 129 | return sPath; 130 | } 131 | 132 | CString Path::GetProgramName(void) 133 | { 134 | return GetFileName(GetProgramPath()); 135 | } 136 | 137 | bool Path::IsDirectory( CString sPath ) 138 | { 139 | bool bDirectory = PathIsDirectory(sPath.GetBuffer()); 140 | sPath.ReleaseBuffer(); 141 | return bDirectory; 142 | } 143 | 144 | bool Path::IsEmpty( CString sPath ) 145 | { 146 | bool bEmpty = PathIsDirectoryEmpty(sPath.GetBuffer()); 147 | sPath.ReleaseBuffer(); 148 | return bEmpty; 149 | } 150 | 151 | bool Path::Exists( CString sPath ) 152 | { 153 | bool bExists = PathFileExists(sPath.GetBuffer()); 154 | sPath.ReleaseBuffer(); 155 | return bExists; 156 | } 157 | 158 | void Path::Open( CString sPath ) 159 | { 160 | if (Path::IsDirectory(sPath)) 161 | ShellExecute(NULL, _T("open"), _T("explorer.exe"), sPath, NULL, SW_SHOWNORMAL); 162 | else 163 | ShellExecute(NULL, _T("open"), _T("explorer.exe"), _T("/select,") + sPath, NULL, SW_SHOWNORMAL); 164 | } 165 | 166 | CString Path::Browse( LPCTSTR lpszFilter, LPCTSTR lpszDefExt, BOOL bOpen, LPCTSTR lpszFileName, LPCTSTR lpInitiaDir ) 167 | { 168 | CString sPathName = _T(""); 169 | CFileDialog dlg(bOpen, 170 | lpszDefExt, 171 | lpszFileName, 172 | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_CREATEPROMPT | (bOpen ? OFN_FILEMUSTEXIST : 0), 173 | lpszFilter, 174 | NULL); 175 | if (lpInitiaDir != NULL) dlg.m_ofn.lpstrInitialDir = lpInitiaDir; 176 | if(dlg.DoModal() == IDOK) 177 | { 178 | sPathName = dlg.GetPathName(); 179 | } 180 | return sPathName; 181 | } 182 | 183 | static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData) 184 | { 185 | switch(uMsg) 186 | { 187 | case BFFM_INITIALIZED: 188 | ::SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)(LPTSTR)(LPCTSTR)lpData); 189 | break; 190 | case BFFM_SELCHANGED: 191 | { 192 | TCHAR szCurrent[MAX_PATH]; 193 | SHGetPathFromIDList((LPCITEMIDLIST)lParam, szCurrent); 194 | ::SendMessage(hWnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szCurrent); 195 | } 196 | break; 197 | default: 198 | break; 199 | } 200 | return 0; 201 | } 202 | 203 | CString Path::Folder( HWND hWnd, CString sRootPath/*=_T("")*/ ) 204 | { 205 | ASSERT(hWnd); 206 | 207 | CString sPath = _T(""); 208 | LPITEMIDLIST pIdList = NULL; 209 | if (sRootPath.IsEmpty()) sRootPath = GetDesktopDirectory(); 210 | 211 | TCHAR szBuffer[MAX_PATH]; 212 | ZeroMemory(szBuffer, MAX_PATH); 213 | _tcscpy(szBuffer, sRootPath.GetBuffer()); 214 | sRootPath.ReleaseBuffer(); 215 | 216 | BROWSEINFO bi; 217 | bi.hwndOwner = hWnd; 218 | bi.pidlRoot = NULL; 219 | bi.pszDisplayName = NULL; 220 | bi.lpszTitle = NULL; 221 | bi.ulFlags = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_BROWSEFORCOMPUTER; 222 | bi.lpfn = BrowseCallbackProc; 223 | bi.lParam = (LPARAM)szBuffer; 224 | bi.iImage = 0; 225 | 226 | if(NULL != (pIdList = SHBrowseForFolder(&bi))) 227 | { 228 | SHGetPathFromIDList(pIdList, sPath.GetBuffer(MAX_PATH)); 229 | sPath.ReleaseBuffer(); 230 | } 231 | 232 | return sPath; 233 | } 234 | 235 | int Path::CopyTo( vector lstSrc, CString sDst ) 236 | { 237 | CString sSrc; 238 | for (vector::iterator it = lstSrc.begin(); it != lstSrc.end(); it++) 239 | { 240 | sSrc += it->Trim('\\') + _T("|"); 241 | } 242 | sDst.Trim('\\'); 243 | 244 | int nSrcSize = sSrc.GetLength() + 2, nDstSize = sDst.GetLength() + 2; 245 | TCHAR* pFrom = new TCHAR[nSrcSize]; 246 | TCHAR* pTo = new TCHAR[nDstSize]; 247 | 248 | ZeroMemory(pFrom, sizeof(TCHAR) * (nSrcSize)); 249 | ZeroMemory(pTo, sizeof(TCHAR) * (nDstSize)); 250 | _tcscpy(pFrom, sSrc.GetBuffer()); 251 | _tcscpy(pTo, sDst.GetBuffer()); 252 | sSrc.ReleaseBuffer(); 253 | sDst.ReleaseBuffer(); 254 | 255 | for (int i = 0; i < nSrcSize; i++) 256 | { 257 | if(pFrom[i] == '|') pFrom[i] = 0; 258 | } 259 | 260 | SHFILEOPSTRUCT fop; 261 | ZeroMemory(&fop, sizeof(SHFILEOPSTRUCT)); 262 | fop.wFunc = FO_COPY; 263 | fop.pFrom = pFrom; 264 | fop.pTo = pTo; 265 | int nRet = SHFileOperation(&fop); 266 | delete pFrom; 267 | delete pTo; 268 | return nRet; 269 | } 270 | 271 | vector Path::Traversing( CString sDirectory, FILITER filter/*=NULL*/ ) 272 | { 273 | vector lstPath; 274 | 275 | PathAddBackslash(sDirectory.GetBuffer(sDirectory.GetLength() + 1)); 276 | sDirectory.ReleaseBuffer(); 277 | 278 | if(!sDirectory.IsEmpty() && Exists(sDirectory) && !IsEmpty(sDirectory)) 279 | { 280 | CFileFind ff; 281 | BOOL bFound = ff.FindFile(sDirectory + _T("*"), 0); 282 | while(bFound) 283 | { 284 | bFound = ff.FindNextFile(); 285 | if(ff.IsDots()) 286 | { 287 | continue; 288 | } 289 | 290 | SetFileAttributes(ff.GetFilePath(), FILE_ATTRIBUTE_NORMAL); 291 | CString sPath = ff.GetFilePath(); 292 | if(ff.IsDirectory()) 293 | { 294 | if (filter != NULL && !filter(sPath)) continue; 295 | vector lstPathEx = Traversing(sPath, filter); 296 | lstPath.insert(lstPath.begin(), lstPathEx.begin(), lstPathEx.end()); 297 | } 298 | else 299 | { 300 | if (filter != NULL && !filter(sPath)) continue; 301 | lstPath.push_back(sPath); 302 | } 303 | } 304 | ff.Close(); 305 | return lstPath; 306 | } 307 | return lstPath; 308 | } 309 | 310 | vector Path::GetFileList( CString sDirectory, CString sFormat/*=_T("*")*/, bool bOnlyDirectory/* = false*/) 311 | { 312 | vector lstPath; 313 | 314 | PathAddBackslash(sDirectory.GetBuffer(sDirectory.GetLength() + 1)); 315 | sDirectory.ReleaseBuffer(); 316 | 317 | if(!sDirectory.IsEmpty() && Exists(sDirectory) && !IsEmpty(sDirectory)) 318 | { 319 | CFileFind ff; 320 | BOOL bFound = ff.FindFile(sDirectory + sFormat, 0); 321 | while(bFound) 322 | { 323 | bFound = ff.FindNextFile(); 324 | if(ff.IsDots()) 325 | { 326 | continue; 327 | } 328 | 329 | SetFileAttributes(ff.GetFilePath(), FILE_ATTRIBUTE_NORMAL); 330 | CString sPath = ff.GetFilePath(); 331 | if (bOnlyDirectory && !IsDirectory(sPath)) continue; 332 | lstPath.push_back(sPath); 333 | } 334 | ff.Close(); 335 | return lstPath; 336 | } 337 | return lstPath; 338 | } 339 | 340 | bool Path::Create( CString sPath ) 341 | { 342 | PathAddBackslash(sPath.GetBuffer(sPath.GetLength() + 1)); 343 | sPath.ReleaseBuffer(); 344 | 345 | USES_CONVERSION; 346 | return MakeSureDirectoryPathExists(T2A(sPath)); 347 | } 348 | 349 | } --------------------------------------------------------------------------------