diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ed2219 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/**/.idea/ +/**/cmake-build-debug/ +/*/cmake-build-debug/ +*.exe +/**/CMakeLists.txt +/**/CMakeFiles/ diff --git "a/Java/2020-2021\357\274\2101\357\274\211Java--A\345\215\267 \345\217\202\350\200\203\347\255\224\346\241\210.pdf" "b/Java/2020-2021\357\274\2101\357\274\211Java--A\345\215\267 \345\217\202\350\200\203\347\255\224\346\241\210.pdf" new file mode 100644 index 0000000..2c49630 Binary files /dev/null and "b/Java/2020-2021\357\274\2101\357\274\211Java--A\345\215\267 \345\217\202\350\200\203\347\255\224\346\241\210.pdf" differ diff --git "a/Java/Java\347\250\213\345\272\217\350\256\276\350\256\241\346\234\237\346\234\253\345\244\215\344\271\240(2021).pdf" "b/Java/Java\347\250\213\345\272\217\350\256\276\350\256\241\346\234\237\346\234\253\345\244\215\344\271\240(2021).pdf" new file mode 100644 index 0000000..3adf05b Binary files /dev/null and "b/Java/Java\347\250\213\345\272\217\350\256\276\350\256\241\346\234\237\346\234\253\345\244\215\344\271\240(2021).pdf" differ diff --git "a/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2141.pdf" "b/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2141.pdf" new file mode 100644 index 0000000..16c23ba Binary files /dev/null and "b/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2141.pdf" differ diff --git "a/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2142.pdf" "b/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2142.pdf" new file mode 100644 index 0000000..33147f0 Binary files /dev/null and "b/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2142.pdf" differ diff --git "a/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2143.pdf" "b/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2143.pdf" new file mode 100644 index 0000000..5a35e81 Binary files /dev/null and "b/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2143.pdf" differ diff --git "a/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2144.pdf" "b/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2144.pdf" new file mode 100644 index 0000000..4a24f58 Binary files /dev/null and "b/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2144.pdf" differ diff --git "a/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2145.pdf" "b/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2145.pdf" new file mode 100644 index 0000000..4cb89d6 Binary files /dev/null and "b/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2145.pdf" differ diff --git "a/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2146.pdf" "b/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2146.pdf" new file mode 100644 index 0000000..5b226ee Binary files /dev/null and "b/Java/\345\256\236\351\252\214\346\212\245\345\221\212/\345\256\236\351\252\2146.pdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2121-ASP.NET\346\240\207\345\207\206\346\216\247\344\273\266.pdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2121-ASP.NET\346\240\207\345\207\206\346\216\247\344\273\266.pdf" new file mode 100644 index 0000000..f02f892 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2121-ASP.NET\346\240\207\345\207\206\346\216\247\344\273\266.pdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2122-ASP.NET \347\252\227\344\275\223\351\252\214\350\257\201.pdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2122-ASP.NET \347\252\227\344\275\223\351\252\214\350\257\201.pdf" new file mode 100644 index 0000000..96854e9 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2122-ASP.NET \347\252\227\344\275\223\351\252\214\350\257\201.pdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2123-HTTP\350\257\267\346\261\202\343\200\201\345\223\215\345\272\224\345\217\212\347\212\266\346\200\201\347\256\241\347\220\206.pdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2123-HTTP\350\257\267\346\261\202\343\200\201\345\223\215\345\272\224\345\217\212\347\212\266\346\200\201\347\256\241\347\220\206.pdf" new file mode 100644 index 0000000..088ef5e Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2123-HTTP\350\257\267\346\261\202\343\200\201\345\223\215\345\272\224\345\217\212\347\212\266\346\200\201\347\256\241\347\220\206.pdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2124-\346\225\260\346\215\256\350\256\277\351\227\256.pdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2124-\346\225\260\346\215\256\350\256\277\351\227\256.pdf" new file mode 100644 index 0000000..dbfab0b Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2124-\346\225\260\346\215\256\350\256\277\351\227\256.pdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2125-\346\225\260\346\215\256\347\273\221\345\256\232.pdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2125-\346\225\260\346\215\256\347\273\221\345\256\232.pdf" new file mode 100644 index 0000000..237f31e Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2022/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2125-\346\225\260\346\215\256\347\273\221\345\256\232.pdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/CheatPaper.pdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/CheatPaper.pdf" new file mode 100644 index 0000000..325d79b Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/CheatPaper.pdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2121-ASP.NET\346\240\207\345\207\206\346\216\247\344\273\266.pdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2121-ASP.NET\346\240\207\345\207\206\346\216\247\344\273\266.pdf" new file mode 100644 index 0000000..71cd252 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2121-ASP.NET\346\240\207\345\207\206\346\216\247\344\273\266.pdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2122-ASP.NET \347\252\227\344\275\223\351\252\214\350\257\201.pdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2122-ASP.NET \347\252\227\344\275\223\351\252\214\350\257\201.pdf" new file mode 100644 index 0000000..d6c2c54 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2122-ASP.NET \347\252\227\344\275\223\351\252\214\350\257\201.pdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2123-HTTP\350\257\267\346\261\202\343\200\201\345\223\215\345\272\224\345\217\212\347\212\266\346\200\201\347\256\241\347\220\206.pdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2123-HTTP\350\257\267\346\261\202\343\200\201\345\223\215\345\272\224\345\217\212\347\212\266\346\200\201\347\256\241\347\220\206.pdf" new file mode 100644 index 0000000..df1ed01 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2123-HTTP\350\257\267\346\261\202\343\200\201\345\223\215\345\272\224\345\217\212\347\212\266\346\200\201\347\256\241\347\220\206.pdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2124-\346\225\260\346\215\256\350\256\277\351\227\256.pdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2124-\346\225\260\346\215\256\350\256\277\351\227\256.pdf" new file mode 100644 index 0000000..3517907 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2124-\346\225\260\346\215\256\350\256\277\351\227\256.pdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2125-\346\225\260\346\215\256\347\273\221\345\256\232.pdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2125-\346\225\260\346\215\256\347\273\221\345\256\232.pdf" new file mode 100644 index 0000000..b610315 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237-\345\256\236\351\252\214\346\212\245\345\221\2125-\346\225\260\346\215\256\347\273\221\345\256\232.pdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Calculator.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Calculator.aspx" new file mode 100644 index 0000000..273d718 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Calculator.aspx" @@ -0,0 +1,24 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Calculator.aspx.cs" Inherits="Ex1.Calculator" %> + + + + + + + 简易计算器 + + +
+
+ 简易计算器
+
+ + +
+ + + +
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Calculator.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Calculator.aspx.cs" new file mode 100644 index 0000000..c8e7df2 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Calculator.aspx.cs" @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Ex1 +{ + public partial class Calculator : System.Web.UI.Page + { + static string num1 = "0", num2 = "0", total = "", sign = ""; + protected void BtnOne_Click(object sender, EventArgs e) + { + total += "1"; + txtDisplay.Text = total; + } + protected void BtnTwo_Click(object sender, EventArgs e) + { + total += "2"; + txtDisplay.Text = total; + } + protected void BtnThree_Click(object sender, EventArgs e) + { + total += "3"; + txtDisplay.Text = total; + } + protected void BtnAdd_Click(object sender, EventArgs e) + { + if (sign.Length == 1) + { + Count(); + num1 = txtDisplay.Text; + sign = "+"; + } + else + { + num1 = txtDisplay.Text; + txtDisplay.Text = ""; + total = ""; + sign = "+"; + } + } + protected void BtnSubtract_Click(object sender, EventArgs e) + { + if (sign.Length == 1) + { + Count(); + num1 = txtDisplay.Text; + sign = "-"; + } + else + { + num1 = txtDisplay.Text; + txtDisplay.Text = ""; + total = ""; + sign = "-"; + } + } + protected void BtnEqual_Click(object sender, EventArgs e) + { + Count(); + } + protected void Count() + { + num2 = txtDisplay.Text; + if (num2 == "") + { + num2 = "0"; + } + switch (sign) + { + case "+": + txtDisplay.Text = (int.Parse(num1) + int.Parse(num2)).ToString(); + num1 = "0"; + num2 = "0"; + total = ""; + sign = ""; + break; + case "-": + txtDisplay.Text = (int.Parse(num1) - int.Parse(num2)).ToString(); + num1 = "0"; + num2 = "0"; + total = ""; + sign = ""; + break; + } + } + protected void Page_Load(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Calculator.aspx.designer.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Calculator.aspx.designer.cs" new file mode 100644 index 0000000..522c2ef --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Calculator.aspx.designer.cs" @@ -0,0 +1,89 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace Ex1 +{ + + + public partial class Calculator + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// txtDisplay 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtDisplay; + + /// + /// btnOne 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnOne; + + /// + /// btnTwo 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnTwo; + + /// + /// btnThree 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnThree; + + /// + /// btnAdd 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnAdd; + + /// + /// btnSubtract 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnSubtract; + + /// + /// btnEqual 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnEqual; + } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Choice.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Choice.aspx" new file mode 100644 index 0000000..aaee01e --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Choice.aspx" @@ -0,0 +1,19 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Choice.aspx.cs" Inherits="Ex1.Choice" %> + + + + + + + 单项选择题 + + +
+
+ + + +
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Choice.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Choice.aspx.cs" new file mode 100644 index 0000000..b3d3392 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Choice.aspx.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Ex1 +{ + public partial class Choice : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + Label lblQuestion = new Label + { + ID = "lblQuestion", + Text = "1. Web服务器控件不包括(    )。" + }; + plhChoice.Controls.Add(lblQuestion); + RadioButtonList rdoltChoice = new RadioButtonList + { + ID = "rdoltChoice" + }; + rdoltChoice.Items.Add(new ListItem("A. Wizard", "A")); + rdoltChoice.Items.Add(new ListItem("B. input", "B")); + rdoltChoice.Items.Add(new ListItem("C. AdRotator", "C")); + rdoltChoice.Items.Add(new ListItem("D. Calendar", "D")); + plhChoice.Controls.Add(rdoltChoice); + } + protected void BtnSubmit_Click(object sender, EventArgs e) + { + RadioButtonList rdoltChoice = (RadioButtonList)plhChoice.FindControl("rdoltChoice"); + lblDisplay.Text = "您选择了:" + rdoltChoice.SelectedValue; + } + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Choice.aspx.designer.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Choice.aspx.designer.cs" new file mode 100644 index 0000000..8f3bfd5 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Choice.aspx.designer.cs" @@ -0,0 +1,53 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace Ex1 +{ + + + public partial class Choice + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// plhChoice 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.PlaceHolder plhChoice; + + /// + /// btnSubmit 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + + /// + /// lblDisplay 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label lblDisplay; + } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Course.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Course.aspx" new file mode 100644 index 0000000..13228a8 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Course.aspx" @@ -0,0 +1,24 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Course.aspx.cs" Inherits="Ex1.Course" %> + + + + + + + 联动的教师课表 + + +
+
+ 学年: + + 学期: + + 分院: + + 教师: + +
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Course.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Course.aspx.cs" new file mode 100644 index 0000000..8fe059b --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Course.aspx.cs" @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Ex1 +{ + public partial class Course : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + BindYear(); + BindTerm(); + BindCollege(); + BindTeacher(); + } + } + protected void BindYear() + { + ddlYear.Items.Clear(); + int startYear = DateTime.Now.Year - 10; + int currentYear = DateTime.Now.Year; + for (int i = startYear; i <= currentYear; i++) + { + ddlYear.Items.Add(new ListItem((i - 1).ToString() + "-" + i.ToString())); + } + ddlYear.SelectedValue = (currentYear - 1).ToString() + "-" + currentYear.ToString(); + } + protected void BindTerm() + { + ddlTerm.Items.Clear(); + for (int i = 1; i <= 2; i++) + { + ddlTerm.Items.Add(i.ToString()); + } + } + protected void BindCollege() + { + ddlCollege.Items.Clear(); + ddlCollege.Items.Add(new ListItem("计算机学院")); + ddlCollege.Items.Add(new ListItem("外国语学院")); + ddlCollege.Items.Add(new ListItem("机电学院")); + } + protected void BindTeacher() + { + ddlTeacher.Items.Clear(); + switch (ddlCollege.SelectedValue) + { + case "计算机学院": + ddlTeacher.Items.Add(new ListItem("曹明")); + ddlTeacher.Items.Add(new ListItem("李妙")); + ddlTeacher.Items.Add(new ListItem("王芳")); + break; + case "外国语学院": + ddlTeacher.Items.Add(new ListItem("张强")); + ddlTeacher.Items.Add(new ListItem("王第男")); + break; + case "机电学院": + ddlTeacher.Items.Add(new ListItem("朱兆清")); + ddlTeacher.Items.Add(new ListItem("毛沁程")); + break; + } + } + protected void DdlCollege_SelectedIndexChanged(object sender, EventArgs e) + { + BindTeacher(); + } + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Course.aspx.designer.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Course.aspx.designer.cs" new file mode 100644 index 0000000..7b149bc --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Course.aspx.designer.cs" @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace Ex1 +{ + + + public partial class Course + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// ddlYear 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.DropDownList ddlYear; + + /// + /// ddlTerm 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.DropDownList ddlTerm; + + /// + /// ddlCollege 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.DropDownList ddlCollege; + + /// + /// ddlTeacher 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.DropDownList ddlTeacher; + } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Ex1.csproj" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Ex1.csproj" new file mode 100644 index 0000000..739af0f --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Ex1.csproj" @@ -0,0 +1,146 @@ + + + + + Debug + AnyCPU + + + 2.0 + {54329C57-9A51-4E1D-BCAA-4A85003C2B74} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Ex1 + Ex1 + v4.7.2 + true + + 44386 + + + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + true + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + + + + + + + + + + Calculator.aspx + ASPXCodeBehind + + + Calculator.aspx + + + Choice.aspx + ASPXCodeBehind + + + Choice.aspx + + + Course.aspx + ASPXCodeBehind + + + Course.aspx + + + + + + + Web.config + + + Web.config + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 11953 + / + https://localhost:44386/ + False + False + + + False + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Ex1.csproj.user" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Ex1.csproj.user" new file mode 100644 index 0000000..f8366ee --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Ex1.csproj.user" @@ -0,0 +1,38 @@ + + + + true + + 44386 + + + + + Debug|Any CPU + + + + + + + + CurrentPage + True + False + False + False + + + + + + + + + True + False + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Ex1.sln" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Ex1.sln" new file mode 100644 index 0000000..7bac3fc --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Ex1.sln" @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.33808.371 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex1", "Ex1.csproj", "{54329C57-9A51-4E1D-BCAA-4A85003C2B74}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {54329C57-9A51-4E1D-BCAA-4A85003C2B74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54329C57-9A51-4E1D-BCAA-4A85003C2B74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54329C57-9A51-4E1D-BCAA-4A85003C2B74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54329C57-9A51-4E1D-BCAA-4A85003C2B74}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {703D92D4-6FAC-47D4-9A19-5DB819A63036} + EndGlobalSection +EndGlobal diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Web.Debug.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Web.Debug.config" new file mode 100644 index 0000000..b9a9fde --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Web.Debug.config" @@ -0,0 +1,31 @@ + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Web.Release.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Web.Release.config" new file mode 100644 index 0000000..755e745 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Web.Release.config" @@ -0,0 +1,32 @@ + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Web.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Web.config" new file mode 100644 index 0000000..ab1b924 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/Web.config" @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/packages.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/packages.config" new file mode 100644 index 0000000..55d586f --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex1/packages.config" @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Ex2.csproj" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Ex2.csproj" new file mode 100644 index 0000000..fd2ccaf --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Ex2.csproj" @@ -0,0 +1,149 @@ + + + + + Debug + AnyCPU + + + 2.0 + {0FA8EA1A-9D53-4BEE-96F3-BB627E399AFA} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Ex2 + Ex2 + v4.7.2 + true + + 44364 + + + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + true + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + + + + + + + + + + + + + + + Global.asax + + + GroupValidation.aspx + ASPXCodeBehind + + + GroupValidation.aspx + + + + Register.aspx + ASPXCodeBehind + + + Register.aspx + + + + + + + + Web.config + + + Web.config + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 14405 + / + https://localhost:44364/ + False + False + + + False + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Ex2.csproj.user" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Ex2.csproj.user" new file mode 100644 index 0000000..64c3b29 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Ex2.csproj.user" @@ -0,0 +1,38 @@ + + + + true + + 44364 + + + + + Debug|Any CPU + + + + + + + + CurrentPage + True + False + False + False + + + + + + + + + True + False + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Ex2.sln" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Ex2.sln" new file mode 100644 index 0000000..ad149a4 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Ex2.sln" @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.33808.371 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex2", "Ex2.csproj", "{0FA8EA1A-9D53-4BEE-96F3-BB627E399AFA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0FA8EA1A-9D53-4BEE-96F3-BB627E399AFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0FA8EA1A-9D53-4BEE-96F3-BB627E399AFA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0FA8EA1A-9D53-4BEE-96F3-BB627E399AFA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0FA8EA1A-9D53-4BEE-96F3-BB627E399AFA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DBD20584-B8E0-46D2-942F-F59AD5439860} + EndGlobalSection +EndGlobal diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Global.asax" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Global.asax" new file mode 100644 index 0000000..0cf905e --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Global.asax" @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.cs" Inherits="Ex2.Global" Language="C#" %> diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Global.asax.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Global.asax.cs" new file mode 100644 index 0000000..90263c2 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Global.asax.cs" @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Security; +using System.Web.SessionState; +using System.Web.UI; + +namespace Ex2 +{ + public class Global : System.Web.HttpApplication + { + + protected void Application_Start(object sender, EventArgs e) + { + ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition + { + Path = "~/scripts/jquery-3.7.1.min.js", + DebugPath = "~/scripts/jquery-3.7.1.js", + CdnPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-3.7.1.min.js", + CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-3.7.1.js" + }); + } + + protected void Session_Start(object sender, EventArgs e) + { + + } + + protected void Application_BeginRequest(object sender, EventArgs e) + { + + } + + protected void Application_AuthenticateRequest(object sender, EventArgs e) + { + + } + + protected void Application_Error(object sender, EventArgs e) + { + + } + + protected void Session_End(object sender, EventArgs e) + { + + } + + protected void Application_End(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/GroupValidation.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/GroupValidation.aspx" new file mode 100644 index 0000000..615394b --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/GroupValidation.aspx" @@ -0,0 +1,89 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GroupValidation.aspx.cs" Inherits="Ex2.GroupValidation" %> + + + + + + 分组验证 + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
用户名: + + + * + + +
密码: + + + * +
确认密码: + + + * + +
生日: + + + * + +
电话号码: + + + * + +
身份证号: + + + * + +
+ + +
+ + + + + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/GroupValidation.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/GroupValidation.aspx.cs" new file mode 100644 index 0000000..f88bc2a --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/GroupValidation.aspx.cs" @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Ex2 +{ + public partial class GroupValidation : System.Web.UI.Page + { + protected void BtnValidateName_Click(object sender, EventArgs e) + { + if (txtName.Text == "leaf") + { + lblName.Text = "抱歉!该用户名已被占用!"; + } + else + { + lblName.Text = "恭喜!该用户名可用!"; + } + } + + protected void CvIdentity_ServerValidate(object source, ServerValidateEventArgs args) + { + string cid = args.Value; + args.IsValid = true; + try + { + DateTime.Parse(cid.Substring(6, 4) + "-" + cid.Substring(10, 2) + "-" + cid.Substring(12, 2)); + } + catch + { + args.IsValid = false; + } + } + + protected void BtnSubmit_Click(object sender, EventArgs e) + { + lblMsg.Text = ""; + if (Page.IsValid) + { + lblMsg.Text = "验证通过!"; + } + } + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/GroupValidation.aspx.designer.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/GroupValidation.aspx.designer.cs" new file mode 100644 index 0000000..8d86983 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/GroupValidation.aspx.designer.cs" @@ -0,0 +1,224 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace Ex2 +{ + + + public partial class GroupValidation + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// txtName 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtName; + + /// + /// rfvName 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvName; + + /// + /// btnValidateName 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnValidateName; + + /// + /// lblName 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label lblName; + + /// + /// txtPassword 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtPassword; + + /// + /// rfvPassword 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvPassword; + + /// + /// txtPasswordAgain 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtPasswordAgain; + + /// + /// rfvPasswordAgain 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvPasswordAgain; + + /// + /// cvPassword 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.CompareValidator cvPassword; + + /// + /// txtBirthday 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtBirthday; + + /// + /// rfvBirthday 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvBirthday; + + /// + /// rvBirthday 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RangeValidator rvBirthday; + + /// + /// txtTelephone 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtTelephone; + + /// + /// rfvTelephone 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvTelephone; + + /// + /// revTelephone 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RegularExpressionValidator revTelephone; + + /// + /// txtIdentity 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtIdentity; + + /// + /// rfvIdentity 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvIdentity; + + /// + /// cvIdentity 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.CustomValidator cvIdentity; + + /// + /// btnSubmit 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + + /// + /// lblMsg 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label lblMsg; + + /// + /// vsName 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.ValidationSummary vsName; + + /// + /// vsSubmit 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.ValidationSummary vsSubmit; + } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Register.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Register.aspx" new file mode 100644 index 0000000..3c9c0d5 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Register.aspx" @@ -0,0 +1,86 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="Ex2.WebForm1" %> + + + + + + + 用户注册验证 + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
用户名: + + + * +
密码: + + + * +
确认密码: + + + * + +
生日: + + + * + +
电话号码: + + + * + +
身份证号: + + + * + +
+ + +
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Register.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Register.aspx.cs" new file mode 100644 index 0000000..6acb6eb --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Register.aspx.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Ex2 +{ + public partial class WebForm1 : System.Web.UI.Page + { + protected void CsvIdentity_ServerValidate(object source, ServerValidateEventArgs args) + { + string cid = args.Value; + args.IsValid = true; + try + { + DateTime.Parse(cid.Substring(6, 4) + "-" + cid.Substring(10, 2) + "-" + cid.Substring(12, 2)); + } + catch + { + args.IsValid = false; + } + } + protected void BtnSubmit_Click(object sender, EventArgs e) + { + lblMsg.Text = ""; + if (Page.IsValid) + { + lblMsg.Text = "验证通过!"; + } + } + + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Register.aspx.designer.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Register.aspx.designer.cs" new file mode 100644 index 0000000..33b0d28 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Register.aspx.designer.cs" @@ -0,0 +1,188 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace Ex2 +{ + + + public partial class WebForm1 + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// txtName 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtName; + + /// + /// rfvName 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvName; + + /// + /// txtPassword 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtPassword; + + /// + /// rfvPassword 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvPassword; + + /// + /// txtPasswordAgain 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtPasswordAgain; + + /// + /// rfvPasswordAgain 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvPasswordAgain; + + /// + /// cvPassword 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.CompareValidator cvPassword; + + /// + /// txtBirthday 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtBirthday; + + /// + /// rfvBirthday 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvBirthday; + + /// + /// rvBirthday 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RangeValidator rvBirthday; + + /// + /// txtTelephone 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtTelephone; + + /// + /// rfvTelephone 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvTelephone; + + /// + /// revTelephone 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RegularExpressionValidator revTelephone; + + /// + /// txtIdentity 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtIdentity; + + /// + /// rfvIdentity 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvIdentity; + + /// + /// csvIdentity 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.CustomValidator csvIdentity; + + /// + /// btnSubmit 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + + /// + /// lblMsg 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label lblMsg; + } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Scripts/jquery-3.7.1.intellisense.js" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Scripts/jquery-3.7.1.intellisense.js" new file mode 100644 index 0000000..a88b6c6 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Scripts/jquery-3.7.1.intellisense.js" @@ -0,0 +1,2670 @@ +intellisense.annotate(jQuery, { + 'ajax': function() { + /// + /// Perform an asynchronous HTTP (Ajax) request. + /// A string containing the URL to which the request is sent. + /// A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). See jQuery.ajax( settings ) below for a complete list of all settings. + /// + /// + /// + /// Perform an asynchronous HTTP (Ajax) request. + /// A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). + /// + /// + }, + 'ajaxPrefilter': function() { + /// + /// Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax(). + /// An optional string containing one or more space-separated dataTypes + /// A handler to set default values for future Ajax requests. + /// + }, + 'ajaxSetup': function() { + /// + /// Set default values for future Ajax requests. Its use is not recommended. + /// A set of key/value pairs that configure the default Ajax request. All options are optional. + /// + }, + 'ajaxTransport': function() { + /// + /// Creates an object that handles the actual transmission of Ajax data. + /// A string identifying the data type to use + /// A handler to return the new transport object to use with the data type provided in the first argument. + /// + }, + 'boxModel': function() { + /// Deprecated in jQuery 1.3 (see jQuery.support). States if the current page, in the user's browser, is being rendered using the W3C CSS Box Model. + /// + }, + 'browser': function() { + /// Contains flags for the useragent, read from navigator.userAgent. This property was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. Please try to use feature detection instead. + /// + }, + 'browser.version': function() { + /// The version number of the rendering engine for the user's browser. This property was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. + /// + }, + 'Callbacks': function() { + /// + /// A multi-purpose callbacks list object that provides a powerful way to manage callback lists. + /// An optional list of space-separated flags that change how the callback list behaves. + /// + /// + }, + 'contains': function() { + /// + /// Check to see if a DOM element is a descendant of another DOM element. + /// The DOM element that may contain the other element. + /// The DOM element that may be contained by (a descendant of) the other element. + /// + /// + }, + 'cssHooks': function() { + /// Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize CSS property naming, or create custom properties. + /// + }, + 'data': function() { + /// + /// Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element. + /// The DOM element to query for the data. + /// Name of the data stored. + /// + /// + /// + /// Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element. + /// The DOM element to query for the data. + /// + /// + }, + 'Deferred': function() { + /// + /// A constructor function that returns a chainable utility object with methods to register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function. + /// A function that is called just before the constructor returns. + /// + /// + }, + 'dequeue': function() { + /// + /// Execute the next function on the queue for the matched element. + /// A DOM element from which to remove and execute a queued function. + /// A string containing the name of the queue. Defaults to fx, the standard effects queue. + /// + }, + 'each': function() { + /// + /// A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties. + /// The object or array to iterate over. + /// The function that will be executed on every object. + /// + /// + }, + 'error': function() { + /// + /// Takes a string and throws an exception containing it. + /// The message to send out. + /// + }, + 'extend': function() { + /// + /// Merge the contents of two or more objects together into the first object. + /// An object that will receive the new properties if additional objects are passed in or that will extend the jQuery namespace if it is the sole argument. + /// An object containing additional properties to merge in. + /// Additional objects containing properties to merge in. + /// + /// + /// + /// Merge the contents of two or more objects together into the first object. + /// If true, the merge becomes recursive (aka. deep copy). + /// The object to extend. It will receive the new properties. + /// An object containing additional properties to merge in. + /// Additional objects containing properties to merge in. + /// + /// + }, + 'fn.extend': function() { + /// + /// Merge the contents of an object onto the jQuery prototype to provide new jQuery instance methods. + /// An object to merge onto the jQuery prototype. + /// + /// + }, + 'get': function() { + /// + /// Load data from the server using a HTTP GET request. + /// A string containing the URL to which the request is sent. + /// A plain object or string that is sent to the server with the request. + /// A callback function that is executed if the request succeeds. + /// The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + /// + /// + }, + 'getJSON': function() { + /// + /// Load JSON-encoded data from the server using a GET HTTP request. + /// A string containing the URL to which the request is sent. + /// A plain object or string that is sent to the server with the request. + /// A callback function that is executed if the request succeeds. + /// + /// + }, + 'getScript': function() { + /// + /// Load a JavaScript file from the server using a GET HTTP request, then execute it. + /// A string containing the URL to which the request is sent. + /// A callback function that is executed if the request succeeds. + /// + /// + }, + 'globalEval': function() { + /// + /// Execute some JavaScript code globally. + /// The JavaScript code to execute. + /// + }, + 'grep': function() { + /// + /// Finds the elements of an array which satisfy a filter function. The original array is not affected. + /// The array to search through. + /// The function to process each item against. The first argument to the function is the item, and the second argument is the index. The function should return a Boolean value. this will be the global window object. + /// If "invert" is false, or not provided, then the function returns an array consisting of all elements for which "callback" returns true. If "invert" is true, then the function returns an array consisting of all elements for which "callback" returns false. + /// + /// + }, + 'hasData': function() { + /// + /// Determine whether an element has any jQuery data associated with it. + /// A DOM element to be checked for data. + /// + /// + }, + 'holdReady': function() { + /// + /// Holds or releases the execution of jQuery's ready event. + /// Indicates whether the ready hold is being requested or released + /// + }, + 'inArray': function() { + /// + /// Search for a specified value within an array and return its index (or -1 if not found). + /// The value to search for. + /// An array through which to search. + /// The index of the array at which to begin the search. The default is 0, which will search the whole array. + /// + /// + }, + 'isArray': function() { + /// + /// Determine whether the argument is an array. + /// Object to test whether or not it is an array. + /// + /// + }, + 'isEmptyObject': function() { + /// + /// Check to see if an object is empty (contains no enumerable properties). + /// The object that will be checked to see if it's empty. + /// + /// + }, + 'isFunction': function() { + /// + /// Determine if the argument passed is a Javascript function object. + /// Object to test whether or not it is a function. + /// + /// + }, + 'isNumeric': function() { + /// + /// Determines whether its argument is a number. + /// The value to be tested. + /// + /// + }, + 'isPlainObject': function() { + /// + /// Check to see if an object is a plain object (created using "{}" or "new Object"). + /// The object that will be checked to see if it's a plain object. + /// + /// + }, + 'isWindow': function() { + /// + /// Determine whether the argument is a window. + /// Object to test whether or not it is a window. + /// + /// + }, + 'isXMLDoc': function() { + /// + /// Check to see if a DOM node is within an XML document (or is an XML document). + /// The DOM node that will be checked to see if it's in an XML document. + /// + /// + }, + 'makeArray': function() { + /// + /// Convert an array-like object into a true JavaScript array. + /// Any object to turn into a native Array. + /// + /// + }, + 'map': function() { + /// + /// Translate all items in an array or object to new array of items. + /// The Array to translate. + /// The function to process each item against. The first argument to the function is the array item, the second argument is the index in array The function can return any value. Within the function, this refers to the global (window) object. + /// + /// + /// + /// Translate all items in an array or object to new array of items. + /// The Array or Object to translate. + /// The function to process each item against. The first argument to the function is the value; the second argument is the index or key of the array or object property. The function can return any value to add to the array. A returned array will be flattened into the resulting array. Within the function, this refers to the global (window) object. + /// + /// + }, + 'merge': function() { + /// + /// Merge the contents of two arrays together into the first array. + /// The first array to merge, the elements of second added. + /// The second array to merge into the first, unaltered. + /// + /// + }, + 'noConflict': function() { + /// + /// Relinquish jQuery's control of the $ variable. + /// A Boolean indicating whether to remove all jQuery variables from the global scope (including jQuery itself). + /// + /// + }, + 'noop': function() { + /// An empty function. + }, + 'now': function() { + /// Return a number representing the current time. + /// + }, + 'param': function() { + /// + /// Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. + /// An array or object to serialize. + /// + /// + /// + /// Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. + /// An array or object to serialize. + /// A Boolean indicating whether to perform a traditional "shallow" serialization. + /// + /// + }, + 'parseHTML': function() { + /// + /// Parses a string into an array of DOM nodes. + /// HTML string to be parsed + /// Document element to serve as the context in which the HTML fragment will be created + /// A Boolean indicating whether to include scripts passed in the HTML string + /// + /// + }, + 'parseJSON': function() { + /// + /// Takes a well-formed JSON string and returns the resulting JavaScript object. + /// The JSON string to parse. + /// + /// + }, + 'parseXML': function() { + /// + /// Parses a string into an XML document. + /// a well-formed XML string to be parsed + /// + /// + }, + 'post': function() { + /// + /// Load data from the server using a HTTP POST request. + /// A string containing the URL to which the request is sent. + /// A plain object or string that is sent to the server with the request. + /// A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. + /// The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + /// + /// + }, + 'proxy': function() { + /// + /// Takes a function and returns a new one that will always have a particular context. + /// The function whose context will be changed. + /// The object to which the context (this) of the function should be set. + /// + /// + /// + /// Takes a function and returns a new one that will always have a particular context. + /// The object to which the context of the function should be set. + /// The name of the function whose context will be changed (should be a property of the context object). + /// + /// + /// + /// Takes a function and returns a new one that will always have a particular context. + /// The function whose context will be changed. + /// The object to which the context (this) of the function should be set. + /// Any number of arguments to be passed to the function referenced in the function argument. + /// + /// + /// + /// Takes a function and returns a new one that will always have a particular context. + /// The object to which the context of the function should be set. + /// The name of the function whose context will be changed (should be a property of the context object). + /// Any number of arguments to be passed to the function named in the name argument. + /// + /// + }, + 'queue': function() { + /// + /// Manipulate the queue of functions to be executed on the matched element. + /// A DOM element where the array of queued functions is attached. + /// A string containing the name of the queue. Defaults to fx, the standard effects queue. + /// An array of functions to replace the current queue contents. + /// + /// + /// + /// Manipulate the queue of functions to be executed on the matched element. + /// A DOM element on which to add a queued function. + /// A string containing the name of the queue. Defaults to fx, the standard effects queue. + /// The new function to add to the queue. + /// + /// + }, + 'removeData': function() { + /// + /// Remove a previously-stored piece of data. + /// A DOM element from which to remove data. + /// A string naming the piece of data to remove. + /// + /// + }, + 'sub': function() { + /// Creates a new copy of jQuery whose properties and methods can be modified without affecting the original jQuery object. + /// + }, + 'support': function() { + /// A collection of properties that represent the presence of different browser features or bugs. Primarily intended for jQuery's internal use; specific properties may be removed when they are no longer needed internally to improve page startup performance. + /// + }, + 'trim': function() { + /// + /// Remove the whitespace from the beginning and end of a string. + /// The string to trim. + /// + /// + }, + 'type': function() { + /// + /// Determine the internal JavaScript [[Class]] of an object. + /// Object to get the internal JavaScript [[Class]] of. + /// + /// + }, + 'unique': function() { + /// + /// Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers. + /// The Array of DOM elements. + /// + /// + }, + 'when': function() { + /// + /// Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. + /// One or more Deferred objects, or plain JavaScript objects. + /// + /// + }, +}); + +var _1228819969 = jQuery.Callbacks; +jQuery.Callbacks = function(flags) { +var _object = _1228819969(flags); +intellisense.annotate(_object, { + 'add': function() { + /// + /// Add a callback or a collection of callbacks to a callback list. + /// A function, or array of functions, that are to be added to the callback list. + /// + /// + }, + 'disable': function() { + /// Disable a callback list from doing anything more. + /// + }, + 'disabled': function() { + /// Determine if the callbacks list has been disabled. + /// + }, + 'empty': function() { + /// Remove all of the callbacks from a list. + /// + }, + 'fire': function() { + /// + /// Call all of the callbacks with the given arguments + /// The argument or list of arguments to pass back to the callback list. + /// + /// + }, + 'fired': function() { + /// Determine if the callbacks have already been called at least once. + /// + }, + 'fireWith': function() { + /// + /// Call all callbacks in a list with the given context and arguments. + /// A reference to the context in which the callbacks in the list should be fired. + /// An argument, or array of arguments, to pass to the callbacks in the list. + /// + /// + }, + 'has': function() { + /// + /// Determine whether a supplied callback is in a list + /// The callback to search for. + /// + /// + }, + 'lock': function() { + /// Lock a callback list in its current state. + /// + }, + 'locked': function() { + /// Determine if the callbacks list has been locked. + /// + }, + 'remove': function() { + /// + /// Remove a callback or a collection of callbacks from a callback list. + /// A function, or array of functions, that are to be removed from the callback list. + /// + /// + }, +}); + +return _object; +}; +intellisense.redirectDefinition(jQuery.Callbacks, _1228819969); + +var _731531622 = jQuery.Deferred; +jQuery.Deferred = function(func) { +var _object = _731531622(func); +intellisense.annotate(_object, { + 'always': function() { + /// + /// Add handlers to be called when the Deferred object is either resolved or rejected. + /// A function, or array of functions, that is called when the Deferred is resolved or rejected. + /// Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. + /// + /// + }, + 'done': function() { + /// + /// Add handlers to be called when the Deferred object is resolved. + /// A function, or array of functions, that are called when the Deferred is resolved. + /// Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. + /// + /// + }, + 'fail': function() { + /// + /// Add handlers to be called when the Deferred object is rejected. + /// A function, or array of functions, that are called when the Deferred is rejected. + /// Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. + /// + /// + }, + 'isRejected': function() { + /// Determine whether a Deferred object has been rejected. + /// + }, + 'isResolved': function() { + /// Determine whether a Deferred object has been resolved. + /// + }, + 'notify': function() { + /// + /// Call the progressCallbacks on a Deferred object with the given args. + /// Optional arguments that are passed to the progressCallbacks. + /// + /// + }, + 'notifyWith': function() { + /// + /// Call the progressCallbacks on a Deferred object with the given context and args. + /// Context passed to the progressCallbacks as the this object. + /// Optional arguments that are passed to the progressCallbacks. + /// + /// + }, + 'pipe': function() { + /// + /// Utility method to filter and/or chain Deferreds. + /// An optional function that is called when the Deferred is resolved. + /// An optional function that is called when the Deferred is rejected. + /// + /// + /// + /// Utility method to filter and/or chain Deferreds. + /// An optional function that is called when the Deferred is resolved. + /// An optional function that is called when the Deferred is rejected. + /// An optional function that is called when progress notifications are sent to the Deferred. + /// + /// + }, + 'progress': function() { + /// + /// Add handlers to be called when the Deferred object generates progress notifications. + /// A function, or array of functions, to be called when the Deferred generates progress notifications. + /// + /// + }, + 'promise': function() { + /// + /// Return a Deferred's Promise object. + /// Object onto which the promise methods have to be attached + /// + /// + }, + 'reject': function() { + /// + /// Reject a Deferred object and call any failCallbacks with the given args. + /// Optional arguments that are passed to the failCallbacks. + /// + /// + }, + 'rejectWith': function() { + /// + /// Reject a Deferred object and call any failCallbacks with the given context and args. + /// Context passed to the failCallbacks as the this object. + /// An optional array of arguments that are passed to the failCallbacks. + /// + /// + }, + 'resolve': function() { + /// + /// Resolve a Deferred object and call any doneCallbacks with the given args. + /// Optional arguments that are passed to the doneCallbacks. + /// + /// + }, + 'resolveWith': function() { + /// + /// Resolve a Deferred object and call any doneCallbacks with the given context and args. + /// Context passed to the doneCallbacks as the this object. + /// An optional array of arguments that are passed to the doneCallbacks. + /// + /// + }, + 'state': function() { + /// Determine the current state of a Deferred object. + /// + }, + 'then': function() { + /// + /// Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + /// A function that is called when the Deferred is resolved. + /// An optional function that is called when the Deferred is rejected. + /// An optional function that is called when progress notifications are sent to the Deferred. + /// + /// + /// + /// Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + /// A function, or array of functions, called when the Deferred is resolved. + /// A function, or array of functions, called when the Deferred is rejected. + /// + /// + /// + /// Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + /// A function, or array of functions, called when the Deferred is resolved. + /// A function, or array of functions, called when the Deferred is rejected. + /// A function, or array of functions, called when the Deferred notifies progress. + /// + /// + }, +}); + +return _object; +}; +intellisense.redirectDefinition(jQuery.Callbacks, _731531622); + +intellisense.annotate(jQuery.Event.prototype, { + 'currentTarget': function() { + /// The current DOM element within the event bubbling phase. + /// + }, + 'data': function() { + /// An optional object of data passed to an event method when the current executing handler is bound. + /// + }, + 'delegateTarget': function() { + /// The element where the currently-called jQuery event handler was attached. + /// + }, + 'isDefaultPrevented': function() { + /// Returns whether event.preventDefault() was ever called on this event object. + /// + }, + 'isImmediatePropagationStopped': function() { + /// Returns whether event.stopImmediatePropagation() was ever called on this event object. + /// + }, + 'isPropagationStopped': function() { + /// Returns whether event.stopPropagation() was ever called on this event object. + /// + }, + 'metaKey': function() { + /// Indicates whether the META key was pressed when the event fired. + /// + }, + 'namespace': function() { + /// The namespace specified when the event was triggered. + /// + }, + 'pageX': function() { + /// The mouse position relative to the left edge of the document. + /// + }, + 'pageY': function() { + /// The mouse position relative to the top edge of the document. + /// + }, + 'preventDefault': function() { + /// If this method is called, the default action of the event will not be triggered. + }, + 'relatedTarget': function() { + /// The other DOM element involved in the event, if any. + /// + }, + 'result': function() { + /// The last value returned by an event handler that was triggered by this event, unless the value was undefined. + /// + }, + 'stopImmediatePropagation': function() { + /// Keeps the rest of the handlers from being executed and prevents the event from bubbling up the DOM tree. + }, + 'stopPropagation': function() { + /// Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. + }, + 'target': function() { + /// The DOM element that initiated the event. + /// + }, + 'timeStamp': function() { + /// The difference in milliseconds between the time the browser created the event and January 1, 1970. + /// + }, + 'type': function() { + /// Describes the nature of the event. + /// + }, + 'which': function() { + /// For key or mouse events, this property indicates the specific key or button that was pressed. + /// + }, +}); + +intellisense.annotate(jQuery.fn, { + 'add': function() { + /// + /// Add elements to the set of matched elements. + /// A string representing a selector expression to find additional elements to add to the set of matched elements. + /// + /// + /// + /// Add elements to the set of matched elements. + /// One or more elements to add to the set of matched elements. + /// + /// + /// + /// Add elements to the set of matched elements. + /// An HTML fragment to add to the set of matched elements. + /// + /// + /// + /// Add elements to the set of matched elements. + /// An existing jQuery object to add to the set of matched elements. + /// + /// + /// + /// Add elements to the set of matched elements. + /// A string representing a selector expression to find additional elements to add to the set of matched elements. + /// The point in the document at which the selector should begin matching; similar to the context argument of the $(selector, context) method. + /// + /// + }, + 'addBack': function() { + /// + /// Add the previous set of elements on the stack to the current set, optionally filtered by a selector. + /// A string containing a selector expression to match the current set of elements against. + /// + /// + }, + 'addClass': function() { + /// + /// Adds the specified class(es) to each of the set of matched elements. + /// One or more space-separated classes to be added to the class attribute of each matched element. + /// + /// + /// + /// Adds the specified class(es) to each of the set of matched elements. + /// A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set. + /// + /// + }, + 'after': function() { + /// + /// Insert content, specified by the parameter, after each element in the set of matched elements. + /// HTML string, DOM element, or jQuery object to insert after each element in the set of matched elements. + /// One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + /// + /// + /// + /// Insert content, specified by the parameter, after each element in the set of matched elements. + /// A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + /// + /// + }, + 'ajaxComplete': function() { + /// + /// Register a handler to be called when Ajax requests complete. This is an AjaxEvent. + /// The function to be invoked. + /// + /// + }, + 'ajaxError': function() { + /// + /// Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event. + /// The function to be invoked. + /// + /// + }, + 'ajaxSend': function() { + /// + /// Attach a function to be executed before an Ajax request is sent. This is an Ajax Event. + /// The function to be invoked. + /// + /// + }, + 'ajaxStart': function() { + /// + /// Register a handler to be called when the first Ajax request begins. This is an Ajax Event. + /// The function to be invoked. + /// + /// + }, + 'ajaxStop': function() { + /// + /// Register a handler to be called when all Ajax requests have completed. This is an Ajax Event. + /// The function to be invoked. + /// + /// + }, + 'ajaxSuccess': function() { + /// + /// Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event. + /// The function to be invoked. + /// + /// + }, + 'all': function() { + /// Selects all elements. + }, + 'andSelf': function() { + /// Add the previous set of elements on the stack to the current set. + /// + }, + 'animate': function() { + /// + /// Perform a custom animation of a set of CSS properties. + /// An object of CSS properties and values that the animation will move toward. + /// A string or number determining how long the animation will run. + /// A string indicating which easing function to use for the transition. + /// A function to call once the animation is complete. + /// + /// + /// + /// Perform a custom animation of a set of CSS properties. + /// An object of CSS properties and values that the animation will move toward. + /// A map of additional options to pass to the method. + /// + /// + }, + 'animated': function() { + /// Select all elements that are in the progress of an animation at the time the selector is run. + }, + 'append': function() { + /// + /// Insert content, specified by the parameter, to the end of each element in the set of matched elements. + /// DOM element, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + /// One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + /// + /// + /// + /// Insert content, specified by the parameter, to the end of each element in the set of matched elements. + /// A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + /// + /// + }, + 'appendTo': function() { + /// + /// Insert every element in the set of matched elements to the end of the target. + /// A selector, element, HTML string, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter. + /// + /// + }, + 'attr': function() { + /// + /// Set one or more attributes for the set of matched elements. + /// The name of the attribute to set. + /// A value to set for the attribute. + /// + /// + /// + /// Set one or more attributes for the set of matched elements. + /// An object of attribute-value pairs to set. + /// + /// + /// + /// Set one or more attributes for the set of matched elements. + /// The name of the attribute to set. + /// A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old attribute value as arguments. + /// + /// + }, + 'attributeContains': function() { + /// + /// Selects elements that have the specified attribute with a value containing the a given substring. + /// An attribute name. + /// An attribute value. Can be either an unquoted single word or a quoted string. + /// + }, + 'attributeContainsPrefix': function() { + /// + /// Selects elements that have the specified attribute with a value either equal to a given string or starting with that string followed by a hyphen (-). + /// An attribute name. + /// An attribute value. Can be either an unquoted single word or a quoted string. + /// + }, + 'attributeContainsWord': function() { + /// + /// Selects elements that have the specified attribute with a value containing a given word, delimited by spaces. + /// An attribute name. + /// An attribute value. Can be either an unquoted single word or a quoted string. + /// + }, + 'attributeEndsWith': function() { + /// + /// Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive. + /// An attribute name. + /// An attribute value. Can be either an unquoted single word or a quoted string. + /// + }, + 'attributeEquals': function() { + /// + /// Selects elements that have the specified attribute with a value exactly equal to a certain value. + /// An attribute name. + /// An attribute value. Can be either an unquoted single word or a quoted string. + /// + }, + 'attributeHas': function() { + /// + /// Selects elements that have the specified attribute, with any value. + /// An attribute name. + /// + }, + 'attributeMultiple': function() { + /// + /// Matches elements that match all of the specified attribute filters. + /// An attribute filter. + /// Another attribute filter, reducing the selection even more + /// As many more attribute filters as necessary + /// + }, + 'attributeNotEqual': function() { + /// + /// Select elements that either don't have the specified attribute, or do have the specified attribute but not with a certain value. + /// An attribute name. + /// An attribute value. Can be either an unquoted single word or a quoted string. + /// + }, + 'attributeStartsWith': function() { + /// + /// Selects elements that have the specified attribute with a value beginning exactly with a given string. + /// An attribute name. + /// An attribute value. Can be either an unquoted single word or a quoted string. + /// + }, + 'before': function() { + /// + /// Insert content, specified by the parameter, before each element in the set of matched elements. + /// HTML string, DOM element, or jQuery object to insert before each element in the set of matched elements. + /// One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. + /// + /// + /// + /// Insert content, specified by the parameter, before each element in the set of matched elements. + /// A function that returns an HTML string, DOM element(s), or jQuery object to insert before each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + /// + /// + }, + 'bind': function() { + /// + /// Attach a handler to an event for the elements. + /// A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Attach a handler to an event for the elements. + /// A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + /// An object containing data that will be passed to the event handler. + /// Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + /// + /// + /// + /// Attach a handler to an event for the elements. + /// An object containing one or more DOM event types and functions to execute for them. + /// + /// + }, + 'blur': function() { + /// + /// Bind an event handler to the "blur" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "blur" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'button': function() { + /// Selects all button elements and elements of type button. + }, + 'change': function() { + /// + /// Bind an event handler to the "change" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "change" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'checkbox': function() { + /// Selects all elements of type checkbox. + }, + 'checked': function() { + /// Matches all elements that are checked or selected. + }, + 'child': function() { + /// + /// Selects all direct child elements specified by "child" of elements specified by "parent". + /// Any valid selector. + /// A selector to filter the child elements. + /// + }, + 'children': function() { + /// + /// Get the children of each element in the set of matched elements, optionally filtered by a selector. + /// A string containing a selector expression to match elements against. + /// + /// + }, + 'class': function() { + /// + /// Selects all elements with the given class. + /// A class to search for. An element can have multiple classes; only one of them must match. + /// + }, + 'clearQueue': function() { + /// + /// Remove from the queue all items that have not yet been run. + /// A string containing the name of the queue. Defaults to fx, the standard effects queue. + /// + /// + }, + 'click': function() { + /// + /// Bind an event handler to the "click" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "click" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'clone': function() { + /// + /// Create a deep copy of the set of matched elements. + /// A Boolean indicating whether event handlers should be copied along with the elements. As of jQuery 1.4, element data will be copied as well. + /// + /// + /// + /// Create a deep copy of the set of matched elements. + /// A Boolean indicating whether event handlers and data should be copied along with the elements. The default value is false. *In jQuery 1.5.0 the default value was incorrectly true; it was changed back to false in 1.5.1 and up. + /// A Boolean indicating whether event handlers and data for all children of the cloned element should be copied. By default its value matches the first argument's value (which defaults to false). + /// + /// + }, + 'closest': function() { + /// + /// For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + /// A string containing a selector expression to match elements against. + /// + /// + /// + /// For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + /// A string containing a selector expression to match elements against. + /// A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead. + /// + /// + /// + /// For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + /// A jQuery object to match elements against. + /// + /// + /// + /// For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + /// An element to match elements against. + /// + /// + }, + 'contains': function() { + /// + /// Select all elements that contain the specified text. + /// A string of text to look for. It's case sensitive. + /// + }, + 'contents': function() { + /// Get the children of each element in the set of matched elements, including text and comment nodes. + /// + }, + 'context': function() { + /// The DOM node context originally passed to jQuery(); if none was passed then context will likely be the document. + /// + }, + 'css': function() { + /// + /// Set one or more CSS properties for the set of matched elements. + /// A CSS property name. + /// A value to set for the property. + /// + /// + /// + /// Set one or more CSS properties for the set of matched elements. + /// A CSS property name. + /// A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + /// + /// + /// + /// Set one or more CSS properties for the set of matched elements. + /// An object of property-value pairs to set. + /// + /// + }, + 'data': function() { + /// + /// Store arbitrary data associated with the matched elements. + /// A string naming the piece of data to set. + /// The new data value; it can be any Javascript type including Array or Object. + /// + /// + /// + /// Store arbitrary data associated with the matched elements. + /// An object of key-value pairs of data to update. + /// + /// + }, + 'dblclick': function() { + /// + /// Bind an event handler to the "dblclick" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "dblclick" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'delay': function() { + /// + /// Set a timer to delay execution of subsequent items in the queue. + /// An integer indicating the number of milliseconds to delay execution of the next item in the queue. + /// A string containing the name of the queue. Defaults to fx, the standard effects queue. + /// + /// + }, + 'delegate': function() { + /// + /// Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements. + /// A selector to filter the elements that trigger the event. + /// A string containing one or more space-separated JavaScript event types, such as "click" or "keydown," or custom event names. + /// A function to execute at the time the event is triggered. + /// + /// + /// + /// Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements. + /// A selector to filter the elements that trigger the event. + /// A string containing one or more space-separated JavaScript event types, such as "click" or "keydown," or custom event names. + /// An object containing data that will be passed to the event handler. + /// A function to execute at the time the event is triggered. + /// + /// + /// + /// Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements. + /// A selector to filter the elements that trigger the event. + /// A plain object of one or more event types and functions to execute for them. + /// + /// + }, + 'dequeue': function() { + /// + /// Execute the next function on the queue for the matched elements. + /// A string containing the name of the queue. Defaults to fx, the standard effects queue. + /// + /// + }, + 'descendant': function() { + /// + /// Selects all elements that are descendants of a given ancestor. + /// Any valid selector. + /// A selector to filter the descendant elements. + /// + }, + 'detach': function() { + /// + /// Remove the set of matched elements from the DOM. + /// A selector expression that filters the set of matched elements to be removed. + /// + /// + }, + 'die': function() { + /// + /// Remove event handlers previously attached using .live() from the elements. + /// A string containing a JavaScript event type, such as click or keydown. + /// The function that is no longer to be executed. + /// + /// + /// + /// Remove event handlers previously attached using .live() from the elements. + /// A plain object of one or more event types, such as click or keydown and their corresponding functions that are no longer to be executed. + /// + /// + }, + 'disabled': function() { + /// Selects all elements that are disabled. + }, + 'each': function() { + /// + /// Iterate over a jQuery object, executing a function for each matched element. + /// A function to execute for each matched element. + /// + /// + }, + 'element': function() { + /// + /// Selects all elements with the given tag name. + /// An element to search for. Refers to the tagName of DOM nodes. + /// + }, + 'empty': function() { + /// Select all elements that have no children (including text nodes). + }, + 'enabled': function() { + /// Selects all elements that are enabled. + }, + 'end': function() { + /// End the most recent filtering operation in the current chain and return the set of matched elements to its previous state. + /// + }, + 'eq': function() { + /// + /// Select the element at index n within the matched set. + /// Zero-based index of the element to match. + /// + /// + /// Select the element at index n within the matched set. + /// Zero-based index of the element to match, counting backwards from the last element. + /// + }, + 'error': function() { + /// + /// Bind an event handler to the "error" JavaScript event. + /// A function to execute when the event is triggered. + /// + /// + /// + /// Bind an event handler to the "error" JavaScript event. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'even': function() { + /// Selects even elements, zero-indexed. See also odd. + }, + 'fadeIn': function() { + /// + /// Display the matched elements by fading them to opaque. + /// A string or number determining how long the animation will run. + /// A function to call once the animation is complete. + /// + /// + /// + /// Display the matched elements by fading them to opaque. + /// A map of additional options to pass to the method. + /// + /// + /// + /// Display the matched elements by fading them to opaque. + /// A string or number determining how long the animation will run. + /// A string indicating which easing function to use for the transition. + /// A function to call once the animation is complete. + /// + /// + }, + 'fadeOut': function() { + /// + /// Hide the matched elements by fading them to transparent. + /// A string or number determining how long the animation will run. + /// A function to call once the animation is complete. + /// + /// + /// + /// Hide the matched elements by fading them to transparent. + /// A map of additional options to pass to the method. + /// + /// + /// + /// Hide the matched elements by fading them to transparent. + /// A string or number determining how long the animation will run. + /// A string indicating which easing function to use for the transition. + /// A function to call once the animation is complete. + /// + /// + }, + 'fadeTo': function() { + /// + /// Adjust the opacity of the matched elements. + /// A string or number determining how long the animation will run. + /// A number between 0 and 1 denoting the target opacity. + /// A function to call once the animation is complete. + /// + /// + /// + /// Adjust the opacity of the matched elements. + /// A string or number determining how long the animation will run. + /// A number between 0 and 1 denoting the target opacity. + /// A string indicating which easing function to use for the transition. + /// A function to call once the animation is complete. + /// + /// + }, + 'fadeToggle': function() { + /// + /// Display or hide the matched elements by animating their opacity. + /// A string or number determining how long the animation will run. + /// A string indicating which easing function to use for the transition. + /// A function to call once the animation is complete. + /// + /// + /// + /// Display or hide the matched elements by animating their opacity. + /// A map of additional options to pass to the method. + /// + /// + }, + 'file': function() { + /// Selects all elements of type file. + }, + 'filter': function() { + /// + /// Reduce the set of matched elements to those that match the selector or pass the function's test. + /// A string containing a selector expression to match the current set of elements against. + /// + /// + /// + /// Reduce the set of matched elements to those that match the selector or pass the function's test. + /// A function used as a test for each element in the set. this is the current DOM element. + /// + /// + /// + /// Reduce the set of matched elements to those that match the selector or pass the function's test. + /// An element to match the current set of elements against. + /// + /// + /// + /// Reduce the set of matched elements to those that match the selector or pass the function's test. + /// An existing jQuery object to match the current set of elements against. + /// + /// + }, + 'find': function() { + /// + /// Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. + /// A string containing a selector expression to match elements against. + /// + /// + /// + /// Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. + /// A jQuery object to match elements against. + /// + /// + /// + /// Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. + /// An element to match elements against. + /// + /// + }, + 'finish': function() { + /// + /// Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements. + /// The name of the queue in which to stop animations. + /// + /// + }, + 'first': function() { + /// Selects the first matched element. + }, + 'first-child': function() { + /// Selects all elements that are the first child of their parent. + }, + 'first-of-type': function() { + /// Selects all elements that are the first among siblings of the same element name. + }, + 'focus': function() { + /// + /// Bind an event handler to the "focus" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "focus" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'focusin': function() { + /// + /// Bind an event handler to the "focusin" event. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "focusin" event. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'focusout': function() { + /// + /// Bind an event handler to the "focusout" JavaScript event. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "focusout" JavaScript event. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'get': function() { + /// + /// Retrieve one of the DOM elements matched by the jQuery object. + /// A zero-based integer indicating which element to retrieve. + /// + /// + }, + 'gt': function() { + /// + /// Select all elements at an index greater than index within the matched set. + /// Zero-based index. + /// + /// + /// Select all elements at an index greater than index within the matched set. + /// Zero-based index, counting backwards from the last element. + /// + }, + 'has': function() { + /// + /// Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element. + /// A string containing a selector expression to match elements against. + /// + /// + /// + /// Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element. + /// A DOM element to match elements against. + /// + /// + }, + 'hasClass': function() { + /// + /// Determine whether any of the matched elements are assigned the given class. + /// The class name to search for. + /// + /// + }, + 'header': function() { + /// Selects all elements that are headers, like h1, h2, h3 and so on. + }, + 'height': function() { + /// + /// Set the CSS height of every matched element. + /// An integer representing the number of pixels, or an integer with an optional unit of measure appended (as a string). + /// + /// + /// + /// Set the CSS height of every matched element. + /// A function returning the height to set. Receives the index position of the element in the set and the old height as arguments. Within the function, this refers to the current element in the set. + /// + /// + }, + 'hidden': function() { + /// Selects all elements that are hidden. + }, + 'hide': function() { + /// + /// Hide the matched elements. + /// A string or number determining how long the animation will run. + /// A function to call once the animation is complete. + /// + /// + /// + /// Hide the matched elements. + /// A map of additional options to pass to the method. + /// + /// + /// + /// Hide the matched elements. + /// A string or number determining how long the animation will run. + /// A string indicating which easing function to use for the transition. + /// A function to call once the animation is complete. + /// + /// + }, + 'hover': function() { + /// + /// Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements. + /// A function to execute when the mouse pointer enters the element. + /// A function to execute when the mouse pointer leaves the element. + /// + /// + }, + 'html': function() { + /// + /// Set the HTML contents of each element in the set of matched elements. + /// A string of HTML to set as the content of each matched element. + /// + /// + /// + /// Set the HTML contents of each element in the set of matched elements. + /// A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set. + /// + /// + }, + 'id': function() { + /// + /// Selects a single element with the given id attribute. + /// An ID to search for, specified via the id attribute of an element. + /// + }, + 'image': function() { + /// Selects all elements of type image. + }, + 'index': function() { + /// + /// Search for a given element from among the matched elements. + /// A selector representing a jQuery collection in which to look for an element. + /// + /// + /// + /// Search for a given element from among the matched elements. + /// The DOM element or first element within the jQuery object to look for. + /// + /// + }, + 'init': function() { + /// + /// Accepts a string containing a CSS selector which is then used to match a set of elements. + /// A string containing a selector expression + /// A DOM Element, Document, or jQuery to use as context + /// + /// + /// + /// Accepts a string containing a CSS selector which is then used to match a set of elements. + /// A DOM element to wrap in a jQuery object. + /// + /// + /// + /// Accepts a string containing a CSS selector which is then used to match a set of elements. + /// An array containing a set of DOM elements to wrap in a jQuery object. + /// + /// + /// + /// Accepts a string containing a CSS selector which is then used to match a set of elements. + /// A plain object to wrap in a jQuery object. + /// + /// + /// + /// Accepts a string containing a CSS selector which is then used to match a set of elements. + /// An existing jQuery object to clone. + /// + /// + }, + 'innerHeight': function() { + /// Get the current computed height for the first element in the set of matched elements, including padding but not border. + /// + }, + 'innerWidth': function() { + /// Get the current computed width for the first element in the set of matched elements, including padding but not border. + /// + }, + 'input': function() { + /// Selects all input, textarea, select and button elements. + }, + 'insertAfter': function() { + /// + /// Insert every element in the set of matched elements after the target. + /// A selector, element, HTML string, or jQuery object; the matched set of elements will be inserted after the element(s) specified by this parameter. + /// + /// + }, + 'insertBefore': function() { + /// + /// Insert every element in the set of matched elements before the target. + /// A selector, element, HTML string, or jQuery object; the matched set of elements will be inserted before the element(s) specified by this parameter. + /// + /// + }, + 'is': function() { + /// + /// Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. + /// A string containing a selector expression to match elements against. + /// + /// + /// + /// Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. + /// A function used as a test for the set of elements. It accepts one argument, index, which is the element's index in the jQuery collection.Within the function, this refers to the current DOM element. + /// + /// + /// + /// Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. + /// An existing jQuery object to match the current set of elements against. + /// + /// + /// + /// Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. + /// An element to match the current set of elements against. + /// + /// + }, + 'jquery': function() { + /// A string containing the jQuery version number. + /// + }, + 'keydown': function() { + /// + /// Bind an event handler to the "keydown" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "keydown" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'keypress': function() { + /// + /// Bind an event handler to the "keypress" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "keypress" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'keyup': function() { + /// + /// Bind an event handler to the "keyup" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "keyup" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'lang': function() { + /// + /// Selects all elements of the specified language. + /// A language code. + /// + }, + 'last': function() { + /// Selects the last matched element. + }, + 'last-child': function() { + /// Selects all elements that are the last child of their parent. + }, + 'last-of-type': function() { + /// Selects all elements that are the last among siblings of the same element name. + }, + 'length': function() { + /// The number of elements in the jQuery object. + /// + }, + 'live': function() { + /// + /// Attach an event handler for all elements which match the current selector, now and in the future. + /// A string containing a JavaScript event type, such as "click" or "keydown." As of jQuery 1.4 the string can contain multiple, space-separated event types or custom event names. + /// A function to execute at the time the event is triggered. + /// + /// + /// + /// Attach an event handler for all elements which match the current selector, now and in the future. + /// A string containing a JavaScript event type, such as "click" or "keydown." As of jQuery 1.4 the string can contain multiple, space-separated event types or custom event names. + /// An object containing data that will be passed to the event handler. + /// A function to execute at the time the event is triggered. + /// + /// + /// + /// Attach an event handler for all elements which match the current selector, now and in the future. + /// A plain object of one or more JavaScript event types and functions to execute for them. + /// + /// + }, + 'load': function() { + /// + /// Bind an event handler to the "load" JavaScript event. + /// A function to execute when the event is triggered. + /// + /// + /// + /// Bind an event handler to the "load" JavaScript event. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'lt': function() { + /// + /// Select all elements at an index less than index within the matched set. + /// Zero-based index. + /// + /// + /// Select all elements at an index less than index within the matched set. + /// Zero-based index, counting backwards from the last element. + /// + }, + 'map': function() { + /// + /// Pass each element in the current matched set through a function, producing a new jQuery object containing the return values. + /// A function object that will be invoked for each element in the current set. + /// + /// + }, + 'mousedown': function() { + /// + /// Bind an event handler to the "mousedown" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "mousedown" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'mouseenter': function() { + /// + /// Bind an event handler to be fired when the mouse enters an element, or trigger that handler on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to be fired when the mouse enters an element, or trigger that handler on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'mouseleave': function() { + /// + /// Bind an event handler to be fired when the mouse leaves an element, or trigger that handler on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to be fired when the mouse leaves an element, or trigger that handler on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'mousemove': function() { + /// + /// Bind an event handler to the "mousemove" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "mousemove" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'mouseout': function() { + /// + /// Bind an event handler to the "mouseout" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "mouseout" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'mouseover': function() { + /// + /// Bind an event handler to the "mouseover" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "mouseover" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'mouseup': function() { + /// + /// Bind an event handler to the "mouseup" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "mouseup" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'multiple': function() { + /// + /// Selects the combined results of all the specified selectors. + /// Any valid selector. + /// Another valid selector. + /// As many more valid selectors as you like. + /// + }, + 'next': function() { + /// + /// Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector. + /// A string containing a selector expression to match elements against. + /// + /// + }, + 'next adjacent': function() { + /// + /// Selects all next elements matching "next" that are immediately preceded by a sibling "prev". + /// Any valid selector. + /// A selector to match the element that is next to the first selector. + /// + }, + 'next siblings': function() { + /// + /// Selects all sibling elements that follow after the "prev" element, have the same parent, and match the filtering "siblings" selector. + /// Any valid selector. + /// A selector to filter elements that are the following siblings of the first selector. + /// + }, + 'nextAll': function() { + /// + /// Get all following siblings of each element in the set of matched elements, optionally filtered by a selector. + /// A string containing a selector expression to match elements against. + /// + /// + }, + 'nextUntil': function() { + /// + /// Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. + /// A string containing a selector expression to indicate where to stop matching following sibling elements. + /// A string containing a selector expression to match elements against. + /// + /// + /// + /// Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. + /// A DOM node or jQuery object indicating where to stop matching following sibling elements. + /// A string containing a selector expression to match elements against. + /// + /// + }, + 'not': function() { + /// + /// Remove elements from the set of matched elements. + /// A string containing a selector expression to match elements against. + /// + /// + /// + /// Remove elements from the set of matched elements. + /// One or more DOM elements to remove from the matched set. + /// + /// + /// + /// Remove elements from the set of matched elements. + /// A function used as a test for each element in the set. this is the current DOM element. + /// + /// + /// + /// Remove elements from the set of matched elements. + /// An existing jQuery object to match the current set of elements against. + /// + /// + }, + 'nth-child': function() { + /// + /// Selects all elements that are the nth-child of their parent. + /// The index of each child to match, starting with 1, the string even or odd, or an equation ( eg. :nth-child(even), :nth-child(4n) ) + /// + }, + 'nth-last-child': function() { + /// + /// Selects all elements that are the nth-child of their parent, counting from the last element to the first. + /// The index of each child to match, starting with the last one (1), the string even or odd, or an equation ( eg. :nth-last-child(even), :nth-last-child(4n) ) + /// + }, + 'nth-last-of-type': function() { + /// + /// Selects all elements that are the nth-child of their parent, counting from the last element to the first. + /// The index of each child to match, starting with the last one (1), the string even or odd, or an equation ( eg. :nth-last-of-type(even), :nth-last-of-type(4n) ) + /// + }, + 'nth-of-type': function() { + /// + /// Selects all elements that are the nth child of their parent in relation to siblings with the same element name. + /// The index of each child to match, starting with 1, the string even or odd, or an equation ( eg. :nth-of-type(even), :nth-of-type(4n) ) + /// + }, + 'odd': function() { + /// Selects odd elements, zero-indexed. See also even. + }, + 'off': function() { + /// + /// Remove an event handler. + /// One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". + /// A selector which should match the one originally passed to .on() when attaching event handlers. + /// A handler function previously attached for the event(s), or the special value false. + /// + /// + /// + /// Remove an event handler. + /// An object where the string keys represent one or more space-separated event types and optional namespaces, and the values represent handler functions previously attached for the event(s). + /// A selector which should match the one originally passed to .on() when attaching event handlers. + /// + /// + }, + 'offset': function() { + /// + /// Set the current coordinates of every element in the set of matched elements, relative to the document. + /// An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements. + /// + /// + /// + /// Set the current coordinates of every element in the set of matched elements, relative to the document. + /// A function to return the coordinates to set. Receives the index of the element in the collection as the first argument and the current coordinates as the second argument. The function should return an object with the new top and left properties. + /// + /// + }, + 'offsetParent': function() { + /// Get the closest ancestor element that is positioned. + /// + }, + 'on': function() { + /// + /// Attach an event handler function for one or more events to the selected elements. + /// One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + /// A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + /// Data to be passed to the handler in event.data when an event is triggered. + /// A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + /// + /// + /// + /// Attach an event handler function for one or more events to the selected elements. + /// An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + /// A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. + /// Data to be passed to the handler in event.data when an event occurs. + /// + /// + }, + 'one': function() { + /// + /// Attach a handler to an event for the elements. The handler is executed at most once per element. + /// A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names. + /// An object containing data that will be passed to the event handler. + /// A function to execute at the time the event is triggered. + /// + /// + /// + /// Attach a handler to an event for the elements. The handler is executed at most once per element. + /// One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + /// A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + /// Data to be passed to the handler in event.data when an event is triggered. + /// A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + /// + /// + /// + /// Attach a handler to an event for the elements. The handler is executed at most once per element. + /// An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + /// A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. + /// Data to be passed to the handler in event.data when an event occurs. + /// + /// + }, + 'only-child': function() { + /// Selects all elements that are the only child of their parent. + }, + 'only-of-type': function() { + /// Selects all elements that have no siblings with the same element name. + }, + 'outerHeight': function() { + /// + /// Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements. + /// A Boolean indicating whether to include the element's margin in the calculation. + /// + /// + }, + 'outerWidth': function() { + /// + /// Get the current computed width for the first element in the set of matched elements, including padding and border. + /// A Boolean indicating whether to include the element's margin in the calculation. + /// + /// + }, + 'parent': function() { + /// + /// Get the parent of each element in the current set of matched elements, optionally filtered by a selector. + /// A string containing a selector expression to match elements against. + /// + /// + }, + 'parents': function() { + /// + /// Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector. + /// A string containing a selector expression to match elements against. + /// + /// + }, + 'parentsUntil': function() { + /// + /// Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object. + /// A string containing a selector expression to indicate where to stop matching ancestor elements. + /// A string containing a selector expression to match elements against. + /// + /// + /// + /// Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object. + /// A DOM node or jQuery object indicating where to stop matching ancestor elements. + /// A string containing a selector expression to match elements against. + /// + /// + }, + 'password': function() { + /// Selects all elements of type password. + }, + 'position': function() { + /// Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. + /// + }, + 'prepend': function() { + /// + /// Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. + /// DOM element, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + /// One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. + /// + /// + /// + /// Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. + /// A function that returns an HTML string, DOM element(s), or jQuery object to insert at the beginning of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + /// + /// + }, + 'prependTo': function() { + /// + /// Insert every element in the set of matched elements to the beginning of the target. + /// A selector, element, HTML string, or jQuery object; the matched set of elements will be inserted at the beginning of the element(s) specified by this parameter. + /// + /// + }, + 'prev': function() { + /// + /// Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector. + /// A string containing a selector expression to match elements against. + /// + /// + }, + 'prevAll': function() { + /// + /// Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector. + /// A string containing a selector expression to match elements against. + /// + /// + }, + 'prevUntil': function() { + /// + /// Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object. + /// A string containing a selector expression to indicate where to stop matching preceding sibling elements. + /// A string containing a selector expression to match elements against. + /// + /// + /// + /// Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object. + /// A DOM node or jQuery object indicating where to stop matching preceding sibling elements. + /// A string containing a selector expression to match elements against. + /// + /// + }, + 'promise': function() { + /// + /// Return a Promise object to observe when all actions of a certain type bound to the collection, queued or not, have finished. + /// The type of queue that needs to be observed. + /// Object onto which the promise methods have to be attached + /// + /// + }, + 'prop': function() { + /// + /// Set one or more properties for the set of matched elements. + /// The name of the property to set. + /// A value to set for the property. + /// + /// + /// + /// Set one or more properties for the set of matched elements. + /// An object of property-value pairs to set. + /// + /// + /// + /// Set one or more properties for the set of matched elements. + /// The name of the property to set. + /// A function returning the value to set. Receives the index position of the element in the set and the old property value as arguments. Within the function, the keyword this refers to the current element. + /// + /// + }, + 'pushStack': function() { + /// + /// Add a collection of DOM elements onto the jQuery stack. + /// An array of elements to push onto the stack and make into a new jQuery object. + /// + /// + /// + /// Add a collection of DOM elements onto the jQuery stack. + /// An array of elements to push onto the stack and make into a new jQuery object. + /// The name of a jQuery method that generated the array of elements. + /// The arguments that were passed in to the jQuery method (for serialization). + /// + /// + }, + 'queue': function() { + /// + /// Manipulate the queue of functions to be executed, once for each matched element. + /// A string containing the name of the queue. Defaults to fx, the standard effects queue. + /// An array of functions to replace the current queue contents. + /// + /// + /// + /// Manipulate the queue of functions to be executed, once for each matched element. + /// A string containing the name of the queue. Defaults to fx, the standard effects queue. + /// The new function to add to the queue, with a function to call that will dequeue the next item. + /// + /// + }, + 'radio': function() { + /// Selects all elements of type radio. + }, + 'ready': function() { + /// + /// Specify a function to execute when the DOM is fully loaded. + /// A function to execute after the DOM is ready. + /// + /// + }, + 'remove': function() { + /// + /// Remove the set of matched elements from the DOM. + /// A selector expression that filters the set of matched elements to be removed. + /// + /// + }, + 'removeAttr': function() { + /// + /// Remove an attribute from each element in the set of matched elements. + /// An attribute to remove; as of version 1.7, it can be a space-separated list of attributes. + /// + /// + }, + 'removeClass': function() { + /// + /// Remove a single class, multiple classes, or all classes from each element in the set of matched elements. + /// One or more space-separated classes to be removed from the class attribute of each matched element. + /// + /// + /// + /// Remove a single class, multiple classes, or all classes from each element in the set of matched elements. + /// A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments. + /// + /// + }, + 'removeData': function() { + /// + /// Remove a previously-stored piece of data. + /// A string naming the piece of data to delete. + /// + /// + /// + /// Remove a previously-stored piece of data. + /// An array or space-separated string naming the pieces of data to delete. + /// + /// + }, + 'removeProp': function() { + /// + /// Remove a property for the set of matched elements. + /// The name of the property to remove. + /// + /// + }, + 'replaceAll': function() { + /// + /// Replace each target element with the set of matched elements. + /// A selector string, jQuery object, or DOM element reference indicating which element(s) to replace. + /// + /// + }, + 'replaceWith': function() { + /// + /// Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. + /// The content to insert. May be an HTML string, DOM element, or jQuery object. + /// + /// + /// + /// Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. + /// A function that returns content with which to replace the set of matched elements. + /// + /// + }, + 'reset': function() { + /// Selects all elements of type reset. + }, + 'resize': function() { + /// + /// Bind an event handler to the "resize" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "resize" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'root': function() { + /// Selects the element that is the root of the document. + }, + 'scroll': function() { + /// + /// Bind an event handler to the "scroll" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "scroll" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'scrollLeft': function() { + /// + /// Set the current horizontal position of the scroll bar for each of the set of matched elements. + /// An integer indicating the new position to set the scroll bar to. + /// + /// + }, + 'scrollTop': function() { + /// + /// Set the current vertical position of the scroll bar for each of the set of matched elements. + /// An integer indicating the new position to set the scroll bar to. + /// + /// + }, + 'select': function() { + /// + /// Bind an event handler to the "select" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "select" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'selected': function() { + /// Selects all elements that are selected. + }, + 'selector': function() { + /// A selector representing selector passed to jQuery(), if any, when creating the original set. + /// + }, + 'serialize': function() { + /// Encode a set of form elements as a string for submission. + /// + }, + 'serializeArray': function() { + /// Encode a set of form elements as an array of names and values. + /// + }, + 'show': function() { + /// + /// Display the matched elements. + /// A string or number determining how long the animation will run. + /// A function to call once the animation is complete. + /// + /// + /// + /// Display the matched elements. + /// A map of additional options to pass to the method. + /// + /// + /// + /// Display the matched elements. + /// A string or number determining how long the animation will run. + /// A string indicating which easing function to use for the transition. + /// A function to call once the animation is complete. + /// + /// + }, + 'siblings': function() { + /// + /// Get the siblings of each element in the set of matched elements, optionally filtered by a selector. + /// A string containing a selector expression to match elements against. + /// + /// + }, + 'size': function() { + /// Return the number of elements in the jQuery object. + /// + }, + 'slice': function() { + /// + /// Reduce the set of matched elements to a subset specified by a range of indices. + /// An integer indicating the 0-based position at which the elements begin to be selected. If negative, it indicates an offset from the end of the set. + /// An integer indicating the 0-based position at which the elements stop being selected. If negative, it indicates an offset from the end of the set. If omitted, the range continues until the end of the set. + /// + /// + }, + 'slideDown': function() { + /// + /// Display the matched elements with a sliding motion. + /// A string or number determining how long the animation will run. + /// A function to call once the animation is complete. + /// + /// + /// + /// Display the matched elements with a sliding motion. + /// A map of additional options to pass to the method. + /// + /// + /// + /// Display the matched elements with a sliding motion. + /// A string or number determining how long the animation will run. + /// A string indicating which easing function to use for the transition. + /// A function to call once the animation is complete. + /// + /// + }, + 'slideToggle': function() { + /// + /// Display or hide the matched elements with a sliding motion. + /// A string or number determining how long the animation will run. + /// A function to call once the animation is complete. + /// + /// + /// + /// Display or hide the matched elements with a sliding motion. + /// A map of additional options to pass to the method. + /// + /// + /// + /// Display or hide the matched elements with a sliding motion. + /// A string or number determining how long the animation will run. + /// A string indicating which easing function to use for the transition. + /// A function to call once the animation is complete. + /// + /// + }, + 'slideUp': function() { + /// + /// Hide the matched elements with a sliding motion. + /// A string or number determining how long the animation will run. + /// A function to call once the animation is complete. + /// + /// + /// + /// Hide the matched elements with a sliding motion. + /// A map of additional options to pass to the method. + /// + /// + /// + /// Hide the matched elements with a sliding motion. + /// A string or number determining how long the animation will run. + /// A string indicating which easing function to use for the transition. + /// A function to call once the animation is complete. + /// + /// + }, + 'stop': function() { + /// + /// Stop the currently-running animation on the matched elements. + /// A Boolean indicating whether to remove queued animation as well. Defaults to false. + /// A Boolean indicating whether to complete the current animation immediately. Defaults to false. + /// + /// + /// + /// Stop the currently-running animation on the matched elements. + /// The name of the queue in which to stop animations. + /// A Boolean indicating whether to remove queued animation as well. Defaults to false. + /// A Boolean indicating whether to complete the current animation immediately. Defaults to false. + /// + /// + }, + 'submit': function() { + /// + /// Bind an event handler to the "submit" JavaScript event, or trigger that event on an element. + /// A function to execute each time the event is triggered. + /// + /// + /// + /// Bind an event handler to the "submit" JavaScript event, or trigger that event on an element. + /// An object containing data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'target': function() { + /// Selects the target element indicated by the fragment identifier of the document's URI. + }, + 'text': function() { + /// + /// Set the content of each element in the set of matched elements to the specified text. + /// A string of text to set as the content of each matched element. + /// + /// + /// + /// Set the content of each element in the set of matched elements to the specified text. + /// A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments. + /// + /// + }, + 'toArray': function() { + /// Retrieve all the DOM elements contained in the jQuery set, as an array. + /// + }, + 'toggle': function() { + /// + /// Display or hide the matched elements. + /// A string or number determining how long the animation will run. + /// A function to call once the animation is complete. + /// + /// + /// + /// Display or hide the matched elements. + /// A map of additional options to pass to the method. + /// + /// + /// + /// Display or hide the matched elements. + /// A string or number determining how long the animation will run. + /// A string indicating which easing function to use for the transition. + /// A function to call once the animation is complete. + /// + /// + /// + /// Display or hide the matched elements. + /// A Boolean indicating whether to show or hide the elements. + /// + /// + }, + 'toggleClass': function() { + /// + /// Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + /// One or more class names (separated by spaces) to be toggled for each element in the matched set. + /// + /// + /// + /// Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + /// One or more class names (separated by spaces) to be toggled for each element in the matched set. + /// A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed. + /// + /// + /// + /// Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + /// A boolean value to determine whether the class should be added or removed. + /// + /// + /// + /// Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + /// A function that returns class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the switch as arguments. + /// A boolean value to determine whether the class should be added or removed. + /// + /// + }, + 'trigger': function() { + /// + /// Execute all handlers and behaviors attached to the matched elements for the given event type. + /// A string containing a JavaScript event type, such as click or submit. + /// Additional parameters to pass along to the event handler. + /// + /// + /// + /// Execute all handlers and behaviors attached to the matched elements for the given event type. + /// A jQuery.Event object. + /// Additional parameters to pass along to the event handler. + /// + /// + }, + 'triggerHandler': function() { + /// + /// Execute all handlers attached to an element for an event. + /// A string containing a JavaScript event type, such as click or submit. + /// An array of additional parameters to pass along to the event handler. + /// + /// + }, + 'unbind': function() { + /// + /// Remove a previously-attached event handler from the elements. + /// A string containing a JavaScript event type, such as click or submit. + /// The function that is to be no longer executed. + /// + /// + /// + /// Remove a previously-attached event handler from the elements. + /// A string containing a JavaScript event type, such as click or submit. + /// Unbinds the corresponding 'return false' function that was bound using .bind( eventType, false ). + /// + /// + /// + /// Remove a previously-attached event handler from the elements. + /// A JavaScript event object as passed to an event handler. + /// + /// + }, + 'undelegate': function() { + /// + /// Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + /// A selector which will be used to filter the event results. + /// A string containing a JavaScript event type, such as "click" or "keydown" + /// + /// + /// + /// Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + /// A selector which will be used to filter the event results. + /// A string containing a JavaScript event type, such as "click" or "keydown" + /// A function to execute at the time the event is triggered. + /// + /// + /// + /// Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + /// A selector which will be used to filter the event results. + /// An object of one or more event types and previously bound functions to unbind from them. + /// + /// + /// + /// Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + /// A string containing a namespace to unbind all events from. + /// + /// + }, + 'unload': function() { + /// + /// Bind an event handler to the "unload" JavaScript event. + /// A function to execute when the event is triggered. + /// + /// + /// + /// Bind an event handler to the "unload" JavaScript event. + /// A plain object of data that will be passed to the event handler. + /// A function to execute each time the event is triggered. + /// + /// + }, + 'unwrap': function() { + /// Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place. + /// + }, + 'val': function() { + /// + /// Set the value of each element in the set of matched elements. + /// A string of text or an array of strings corresponding to the value of each matched element to set as selected/checked. + /// + /// + /// + /// Set the value of each element in the set of matched elements. + /// A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + /// + /// + }, + 'visible': function() { + /// Selects all elements that are visible. + }, + 'width': function() { + /// + /// Set the CSS width of each element in the set of matched elements. + /// An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + /// + /// + /// + /// Set the CSS width of each element in the set of matched elements. + /// A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set. + /// + /// + }, + 'wrap': function() { + /// + /// Wrap an HTML structure around each element in the set of matched elements. + /// A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + /// + /// + /// + /// Wrap an HTML structure around each element in the set of matched elements. + /// A callback function returning the HTML content or jQuery object to wrap around the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + /// + /// + }, + 'wrapAll': function() { + /// + /// Wrap an HTML structure around all elements in the set of matched elements. + /// A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + /// + /// + }, + 'wrapInner': function() { + /// + /// Wrap an HTML structure around the content of each element in the set of matched elements. + /// An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements. + /// + /// + /// + /// Wrap an HTML structure around the content of each element in the set of matched elements. + /// A callback function which generates a structure to wrap around the content of the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + /// + /// + }, +}); + +intellisense.annotate(window, { + '$': function() { + /// + /// Accepts a string containing a CSS selector which is then used to match a set of elements. + /// A string containing a selector expression + /// A DOM Element, Document, or jQuery to use as context + /// + /// + /// + /// Accepts a string containing a CSS selector which is then used to match a set of elements. + /// A DOM element to wrap in a jQuery object. + /// + /// + /// + /// Accepts a string containing a CSS selector which is then used to match a set of elements. + /// An array containing a set of DOM elements to wrap in a jQuery object. + /// + /// + /// + /// Accepts a string containing a CSS selector which is then used to match a set of elements. + /// A plain object to wrap in a jQuery object. + /// + /// + /// + /// Accepts a string containing a CSS selector which is then used to match a set of elements. + /// An existing jQuery object to clone. + /// + /// + }, +}); + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Scripts/jquery-3.7.1.js" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Scripts/jquery-3.7.1.js" new file mode 100644 index 0000000..1a86433 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex2/Scripts/jquery-3.7.1.js" @@ -0,0 +1,10716 @@ +/*! + * jQuery JavaScript Library v3.7.1 + * https://jquery.com/ + * + * Copyright OpenJS Foundation and other contributors + * Released under the MIT license + * https://jquery.org/license + * + * Date: 2023-08-28T13:37Z + */ +( function( global, factory ) { + + "use strict"; + + if ( typeof module === "object" && typeof module.exports === "object" ) { + + // For CommonJS and CommonJS-like environments where a proper `window` + // is present, execute the factory and get jQuery. + // For environments that do not have a `window` with a `document` + // (such as Node.js), expose a factory as module.exports. + // This accentuates the need for the creation of a real `window`. + // e.g. var jQuery = require("jquery")(window); + // See ticket trac-14549 for more info. + module.exports = global.document ? + factory( global, true ) : + function( w ) { + if ( !w.document ) { + throw new Error( "jQuery requires a window with a document" ); + } + return factory( w ); + }; + } else { + factory( global ); + } + +// Pass this if window is not defined yet +} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { + +// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1 +// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode +// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common +// enough that all such attempts are guarded in a try block. +"use strict"; + +var arr = []; + +var getProto = Object.getPrototypeOf; + +var slice = arr.slice; + +var flat = arr.flat ? function( array ) { + return arr.flat.call( array ); +} : function( array ) { + return arr.concat.apply( [], array ); +}; + + +var push = arr.push; + +var indexOf = arr.indexOf; + +var class2type = {}; + +var toString = class2type.toString; + +var hasOwn = class2type.hasOwnProperty; + +var fnToString = hasOwn.toString; + +var ObjectFunctionString = fnToString.call( Object ); + +var support = {}; + +var isFunction = function isFunction( obj ) { + + // Support: Chrome <=57, Firefox <=52 + // In some browsers, typeof returns "function" for HTML elements + // (i.e., `typeof document.createElement( "object" ) === "function"`). + // We don't want to classify *any* DOM node as a function. + // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5 + // Plus for old WebKit, typeof returns "function" for HTML collections + // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756) + return typeof obj === "function" && typeof obj.nodeType !== "number" && + typeof obj.item !== "function"; + }; + + +var isWindow = function isWindow( obj ) { + return obj != null && obj === obj.window; + }; + + +var document = window.document; + + + + var preservedScriptAttributes = { + type: true, + src: true, + nonce: true, + noModule: true + }; + + function DOMEval( code, node, doc ) { + doc = doc || document; + + var i, val, + script = doc.createElement( "script" ); + + script.text = code; + if ( node ) { + for ( i in preservedScriptAttributes ) { + + // Support: Firefox 64+, Edge 18+ + // Some browsers don't support the "nonce" property on scripts. + // On the other hand, just using `getAttribute` is not enough as + // the `nonce` attribute is reset to an empty string whenever it + // becomes browsing-context connected. + // See https://github.com/whatwg/html/issues/2369 + // See https://html.spec.whatwg.org/#nonce-attributes + // The `node.getAttribute` check was added for the sake of + // `jQuery.globalEval` so that it can fake a nonce-containing node + // via an object. + val = node[ i ] || node.getAttribute && node.getAttribute( i ); + if ( val ) { + script.setAttribute( i, val ); + } + } + } + doc.head.appendChild( script ).parentNode.removeChild( script ); + } + + +function toType( obj ) { + if ( obj == null ) { + return obj + ""; + } + + // Support: Android <=2.3 only (functionish RegExp) + return typeof obj === "object" || typeof obj === "function" ? + class2type[ toString.call( obj ) ] || "object" : + typeof obj; +} +/* global Symbol */ +// Defining this global in .eslintrc.json would create a danger of using the global +// unguarded in another place, it seems safer to define global only for this module + + + +var version = "3.7.1", + + rhtmlSuffix = /HTML$/i, + + // Define a local copy of jQuery + jQuery = function( selector, context ) { + + // The jQuery object is actually just the init constructor 'enhanced' + // Need init if jQuery is called (just allow error to be thrown if not included) + return new jQuery.fn.init( selector, context ); + }; + +jQuery.fn = jQuery.prototype = { + + // The current version of jQuery being used + jquery: version, + + constructor: jQuery, + + // The default length of a jQuery object is 0 + length: 0, + + toArray: function() { + return slice.call( this ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + + // Return all the elements in a clean array + if ( num == null ) { + return slice.call( this ); + } + + // Return just the one element from the set + return num < 0 ? this[ num + this.length ] : this[ num ]; + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems ) { + + // Build a new jQuery matched element set + var ret = jQuery.merge( this.constructor(), elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + each: function( callback ) { + return jQuery.each( this, callback ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map( this, function( elem, i ) { + return callback.call( elem, i, elem ); + } ) ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ) ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + even: function() { + return this.pushStack( jQuery.grep( this, function( _elem, i ) { + return ( i + 1 ) % 2; + } ) ); + }, + + odd: function() { + return this.pushStack( jQuery.grep( this, function( _elem, i ) { + return i % 2; + } ) ); + }, + + eq: function( i ) { + var len = this.length, + j = +i + ( i < 0 ? len : 0 ); + return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); + }, + + end: function() { + return this.prevObject || this.constructor(); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: arr.sort, + splice: arr.splice +}; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[ 0 ] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + + // Skip the boolean and the target + target = arguments[ i ] || {}; + i++; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !isFunction( target ) ) { + target = {}; + } + + // Extend jQuery itself if only one argument is passed + if ( i === length ) { + target = this; + i--; + } + + for ( ; i < length; i++ ) { + + // Only deal with non-null/undefined values + if ( ( options = arguments[ i ] ) != null ) { + + // Extend the base object + for ( name in options ) { + copy = options[ name ]; + + // Prevent Object.prototype pollution + // Prevent never-ending loop + if ( name === "__proto__" || target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject( copy ) || + ( copyIsArray = Array.isArray( copy ) ) ) ) { + src = target[ name ]; + + // Ensure proper type for the source value + if ( copyIsArray && !Array.isArray( src ) ) { + clone = []; + } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) { + clone = {}; + } else { + clone = src; + } + copyIsArray = false; + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend( { + + // Unique for each copy of jQuery on the page + expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), + + // Assume jQuery is ready without the ready module + isReady: true, + + error: function( msg ) { + throw new Error( msg ); + }, + + noop: function() {}, + + isPlainObject: function( obj ) { + var proto, Ctor; + + // Detect obvious negatives + // Use toString instead of jQuery.type to catch host objects + if ( !obj || toString.call( obj ) !== "[object Object]" ) { + return false; + } + + proto = getProto( obj ); + + // Objects with no prototype (e.g., `Object.create( null )`) are plain + if ( !proto ) { + return true; + } + + // Objects with prototype are plain iff they were constructed by a global Object function + Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; + return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; + }, + + isEmptyObject: function( obj ) { + var name; + + for ( name in obj ) { + return false; + } + return true; + }, + + // Evaluates a script in a provided context; falls back to the global one + // if not specified. + globalEval: function( code, options, doc ) { + DOMEval( code, { nonce: options && options.nonce }, doc ); + }, + + each: function( obj, callback ) { + var length, i = 0; + + if ( isArrayLike( obj ) ) { + length = obj.length; + for ( ; i < length; i++ ) { + if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { + break; + } + } + } else { + for ( i in obj ) { + if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { + break; + } + } + } + + return obj; + }, + + + // Retrieve the text value of an array of DOM nodes + text: function( elem ) { + var node, + ret = "", + i = 0, + nodeType = elem.nodeType; + + if ( !nodeType ) { + + // If no nodeType, this is expected to be an array + while ( ( node = elem[ i++ ] ) ) { + + // Do not traverse comment nodes + ret += jQuery.text( node ); + } + } + if ( nodeType === 1 || nodeType === 11 ) { + return elem.textContent; + } + if ( nodeType === 9 ) { + return elem.documentElement.textContent; + } + if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + + // Do not include comment or processing instruction nodes + + return ret; + }, + + // results is for internal usage only + makeArray: function( arr, results ) { + var ret = results || []; + + if ( arr != null ) { + if ( isArrayLike( Object( arr ) ) ) { + jQuery.merge( ret, + typeof arr === "string" ? + [ arr ] : arr + ); + } else { + push.call( ret, arr ); + } + } + + return ret; + }, + + inArray: function( elem, arr, i ) { + return arr == null ? -1 : indexOf.call( arr, elem, i ); + }, + + isXMLDoc: function( elem ) { + var namespace = elem && elem.namespaceURI, + docElem = elem && ( elem.ownerDocument || elem ).documentElement; + + // Assume HTML when documentElement doesn't yet exist, such as inside + // document fragments. + return !rhtmlSuffix.test( namespace || docElem && docElem.nodeName || "HTML" ); + }, + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + merge: function( first, second ) { + var len = +second.length, + j = 0, + i = first.length; + + for ( ; j < len; j++ ) { + first[ i++ ] = second[ j ]; + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, invert ) { + var callbackInverse, + matches = [], + i = 0, + length = elems.length, + callbackExpect = !invert; + + // Go through the array, only saving the items + // that pass the validator function + for ( ; i < length; i++ ) { + callbackInverse = !callback( elems[ i ], i ); + if ( callbackInverse !== callbackExpect ) { + matches.push( elems[ i ] ); + } + } + + return matches; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var length, value, + i = 0, + ret = []; + + // Go through the array, translating each of the items to their new values + if ( isArrayLike( elems ) ) { + length = elems.length; + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + + // Go through every key on the object, + } else { + for ( i in elems ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + } + + // Flatten any nested arrays + return flat( ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // jQuery.support is not used in Core but other projects attach their + // properties to it so it needs to exist. + support: support +} ); + +if ( typeof Symbol === "function" ) { + jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; +} + +// Populate the class2type map +jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), + function( _i, name ) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); + } ); + +function isArrayLike( obj ) { + + // Support: real iOS 8.2 only (not reproducible in simulator) + // `in` check used to prevent JIT error (gh-2145) + // hasOwn isn't used here due to false negatives + // regarding Nodelist length in IE + var length = !!obj && "length" in obj && obj.length, + type = toType( obj ); + + if ( isFunction( obj ) || isWindow( obj ) ) { + return false; + } + + return type === "array" || length === 0 || + typeof length === "number" && length > 0 && ( length - 1 ) in obj; +} + + +function nodeName( elem, name ) { + + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + +} +var pop = arr.pop; + + +var sort = arr.sort; + + +var splice = arr.splice; + + +var whitespace = "[\\x20\\t\\r\\n\\f]"; + + +var rtrimCSS = new RegExp( + "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", + "g" +); + + + + +// Note: an element does not contain itself +jQuery.contains = function( a, b ) { + var bup = b && b.parentNode; + + return a === bup || !!( bup && bup.nodeType === 1 && ( + + // Support: IE 9 - 11+ + // IE doesn't have `contains` on SVG. + a.contains ? + a.contains( bup ) : + a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 + ) ); +}; + + + + +// CSS string/identifier serialization +// https://drafts.csswg.org/cssom/#common-serializing-idioms +var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g; + +function fcssescape( ch, asCodePoint ) { + if ( asCodePoint ) { + + // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER + if ( ch === "\0" ) { + return "\uFFFD"; + } + + // Control characters and (dependent upon position) numbers get escaped as code points + return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; + } + + // Other potentially-special ASCII characters get backslash-escaped + return "\\" + ch; +} + +jQuery.escapeSelector = function( sel ) { + return ( sel + "" ).replace( rcssescape, fcssescape ); +}; + + + + +var preferredDoc = document, + pushNative = push; + +( function() { + +var i, + Expr, + outermostContext, + sortInput, + hasDuplicate, + push = pushNative, + + // Local document vars + document, + documentElement, + documentIsHTML, + rbuggyQSA, + matches, + + // Instance-specific data + expando = jQuery.expando, + dirruns = 0, + done = 0, + classCache = createCache(), + tokenCache = createCache(), + compilerCache = createCache(), + nonnativeSelectorCache = createCache(), + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + } + return 0; + }, + + booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|" + + "loop|multiple|open|readonly|required|scoped", + + // Regular expressions + + // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram + identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", + + // Attribute selectors: https://www.w3.org/TR/selectors/#attribute-selectors + attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + + + // Operator (capture 2) + "*([*^$|!~]?=)" + whitespace + + + // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + + whitespace + "*\\]", + + pseudos = ":(" + identifier + ")(?:\\((" + + + // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: + // 1. quoted (capture 3; capture 4 or capture 5) + "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + + + // 2. simple (capture 6) + "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + + + // 3. anything else (capture 2) + ".*" + + ")\\)|)", + + // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter + rwhitespace = new RegExp( whitespace + "+", "g" ), + + rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), + rleadingCombinator = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + + whitespace + "*" ), + rdescend = new RegExp( whitespace + "|>" ), + + rpseudo = new RegExp( pseudos ), + ridentifier = new RegExp( "^" + identifier + "$" ), + + matchExpr = { + ID: new RegExp( "^#(" + identifier + ")" ), + CLASS: new RegExp( "^\\.(" + identifier + ")" ), + TAG: new RegExp( "^(" + identifier + "|[*])" ), + ATTR: new RegExp( "^" + attributes ), + PSEUDO: new RegExp( "^" + pseudos ), + CHILD: new RegExp( + "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), + bool: new RegExp( "^(?:" + booleans + ")$", "i" ), + + // For use in libraries implementing .is() + // We use this for POS matching in `select` + needsContext: new RegExp( "^" + whitespace + + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) + }, + + rinputs = /^(?:input|select|textarea|button)$/i, + rheader = /^h\d$/i, + + // Easily-parseable/retrievable ID or TAG or CLASS selectors + rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, + + rsibling = /[+~]/, + + // CSS escapes + // https://www.w3.org/TR/CSS21/syndata.html#escaped-characters + runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + + "?|\\\\([^\\r\\n\\f])", "g" ), + funescape = function( escape, nonHex ) { + var high = "0x" + escape.slice( 1 ) - 0x10000; + + if ( nonHex ) { + + // Strip the backslash prefix from a non-hex escape sequence + return nonHex; + } + + // Replace a hexadecimal escape sequence with the encoded Unicode code point + // Support: IE <=11+ + // For values outside the Basic Multilingual Plane (BMP), manually construct a + // surrogate pair + return high < 0 ? + String.fromCharCode( high + 0x10000 ) : + String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); + }, + + // Used for iframes; see `setDocument`. + // Support: IE 9 - 11+, Edge 12 - 18+ + // Removing the function wrapper causes a "Permission Denied" + // error in IE/Edge. + unloadHandler = function() { + setDocument(); + }, + + inDisabledFieldset = addCombinator( + function( elem ) { + return elem.disabled === true && nodeName( elem, "fieldset" ); + }, + { dir: "parentNode", next: "legend" } + ); + +// Support: IE <=9 only +// Accessing document.activeElement can throw unexpectedly +// https://bugs.jquery.com/ticket/13393 +function safeActiveElement() { + try { + return document.activeElement; + } catch ( err ) { } +} + +// Optimize for push.apply( _, NodeList ) +try { + push.apply( + ( arr = slice.call( preferredDoc.childNodes ) ), + preferredDoc.childNodes + ); + + // Support: Android <=4.0 + // Detect silently failing push.apply + // eslint-disable-next-line no-unused-expressions + arr[ preferredDoc.childNodes.length ].nodeType; +} catch ( e ) { + push = { + apply: function( target, els ) { + pushNative.apply( target, slice.call( els ) ); + }, + call: function( target ) { + pushNative.apply( target, slice.call( arguments, 1 ) ); + } + }; +} + +function find( selector, context, results, seed ) { + var m, i, elem, nid, match, groups, newSelector, + newContext = context && context.ownerDocument, + + // nodeType defaults to 9, since context defaults to document + nodeType = context ? context.nodeType : 9; + + results = results || []; + + // Return early from calls with invalid selector or context + if ( typeof selector !== "string" || !selector || + nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { + + return results; + } + + // Try to shortcut find operations (as opposed to filters) in HTML documents + if ( !seed ) { + setDocument( context ); + context = context || document; + + if ( documentIsHTML ) { + + // If the selector is sufficiently simple, try using a "get*By*" DOM method + // (excepting DocumentFragment context, where the methods don't exist) + if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) { + + // ID selector + if ( ( m = match[ 1 ] ) ) { + + // Document context + if ( nodeType === 9 ) { + if ( ( elem = context.getElementById( m ) ) ) { + + // Support: IE 9 only + // getElementById can match elements by name instead of ID + if ( elem.id === m ) { + push.call( results, elem ); + return results; + } + } else { + return results; + } + + // Element context + } else { + + // Support: IE 9 only + // getElementById can match elements by name instead of ID + if ( newContext && ( elem = newContext.getElementById( m ) ) && + find.contains( context, elem ) && + elem.id === m ) { + + push.call( results, elem ); + return results; + } + } + + // Type selector + } else if ( match[ 2 ] ) { + push.apply( results, context.getElementsByTagName( selector ) ); + return results; + + // Class selector + } else if ( ( m = match[ 3 ] ) && context.getElementsByClassName ) { + push.apply( results, context.getElementsByClassName( m ) ); + return results; + } + } + + // Take advantage of querySelectorAll + if ( !nonnativeSelectorCache[ selector + " " ] && + ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) ) { + + newSelector = selector; + newContext = context; + + // qSA considers elements outside a scoping root when evaluating child or + // descendant combinators, which is not what we want. + // In such cases, we work around the behavior by prefixing every selector in the + // list with an ID selector referencing the scope context. + // The technique has to be used as well when a leading combinator is used + // as such selectors are not recognized by querySelectorAll. + // Thanks to Andrew Dupont for this technique. + if ( nodeType === 1 && + ( rdescend.test( selector ) || rleadingCombinator.test( selector ) ) ) { + + // Expand context for sibling selectors + newContext = rsibling.test( selector ) && testContext( context.parentNode ) || + context; + + // We can use :scope instead of the ID hack if the browser + // supports it & if we're not changing the context. + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when + // strict-comparing two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( newContext != context || !support.scope ) { + + // Capture the context ID, setting it first if necessary + if ( ( nid = context.getAttribute( "id" ) ) ) { + nid = jQuery.escapeSelector( nid ); + } else { + context.setAttribute( "id", ( nid = expando ) ); + } + } + + // Prefix every selector in the list + groups = tokenize( selector ); + i = groups.length; + while ( i-- ) { + groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " + + toSelector( groups[ i ] ); + } + newSelector = groups.join( "," ); + } + + try { + push.apply( results, + newContext.querySelectorAll( newSelector ) + ); + return results; + } catch ( qsaError ) { + nonnativeSelectorCache( selector, true ); + } finally { + if ( nid === expando ) { + context.removeAttribute( "id" ); + } + } + } + } + } + + // All others + return select( selector.replace( rtrimCSS, "$1" ), context, results, seed ); +} + +/** + * Create key-value caches of limited size + * @returns {function(string, object)} Returns the Object data after storing it on itself with + * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) + * deleting the oldest entry + */ +function createCache() { + var keys = []; + + function cache( key, value ) { + + // Use (key + " ") to avoid collision with native prototype properties + // (see https://github.com/jquery/sizzle/issues/157) + if ( keys.push( key + " " ) > Expr.cacheLength ) { + + // Only keep the most recent entries + delete cache[ keys.shift() ]; + } + return ( cache[ key + " " ] = value ); + } + return cache; +} + +/** + * Mark a function for special use by jQuery selector module + * @param {Function} fn The function to mark + */ +function markFunction( fn ) { + fn[ expando ] = true; + return fn; +} + +/** + * Support testing using an element + * @param {Function} fn Passed the created element and returns a boolean result + */ +function assert( fn ) { + var el = document.createElement( "fieldset" ); + + try { + return !!fn( el ); + } catch ( e ) { + return false; + } finally { + + // Remove from its parent by default + if ( el.parentNode ) { + el.parentNode.removeChild( el ); + } + + // release memory in IE + el = null; + } +} + +/** + * Returns a function to use in pseudos for input types + * @param {String} type + */ +function createInputPseudo( type ) { + return function( elem ) { + return nodeName( elem, "input" ) && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for buttons + * @param {String} type + */ +function createButtonPseudo( type ) { + return function( elem ) { + return ( nodeName( elem, "input" ) || nodeName( elem, "button" ) ) && + elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for :enabled/:disabled + * @param {Boolean} disabled true for :disabled; false for :enabled + */ +function createDisabledPseudo( disabled ) { + + // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable + return function( elem ) { + + // Only certain elements can match :enabled or :disabled + // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled + // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled + if ( "form" in elem ) { + + // Check for inherited disabledness on relevant non-disabled elements: + // * listed form-associated elements in a disabled fieldset + // https://html.spec.whatwg.org/multipage/forms.html#category-listed + // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled + // * option elements in a disabled optgroup + // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled + // All such elements have a "form" property. + if ( elem.parentNode && elem.disabled === false ) { + + // Option elements defer to a parent optgroup if present + if ( "label" in elem ) { + if ( "label" in elem.parentNode ) { + return elem.parentNode.disabled === disabled; + } else { + return elem.disabled === disabled; + } + } + + // Support: IE 6 - 11+ + // Use the isDisabled shortcut property to check for disabled fieldset ancestors + return elem.isDisabled === disabled || + + // Where there is no isDisabled, check manually + elem.isDisabled !== !disabled && + inDisabledFieldset( elem ) === disabled; + } + + return elem.disabled === disabled; + + // Try to winnow out elements that can't be disabled before trusting the disabled property. + // Some victims get caught in our net (label, legend, menu, track), but it shouldn't + // even exist on them, let alone have a boolean value. + } else if ( "label" in elem ) { + return elem.disabled === disabled; + } + + // Remaining elements are neither :enabled nor :disabled + return false; + }; +} + +/** + * Returns a function to use in pseudos for positionals + * @param {Function} fn + */ +function createPositionalPseudo( fn ) { + return markFunction( function( argument ) { + argument = +argument; + return markFunction( function( seed, matches ) { + var j, + matchIndexes = fn( [], seed.length, argument ), + i = matchIndexes.length; + + // Match elements found at the specified indexes + while ( i-- ) { + if ( seed[ ( j = matchIndexes[ i ] ) ] ) { + seed[ j ] = !( matches[ j ] = seed[ j ] ); + } + } + } ); + } ); +} + +/** + * Checks a node for validity as a jQuery selector context + * @param {Element|Object=} context + * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value + */ +function testContext( context ) { + return context && typeof context.getElementsByTagName !== "undefined" && context; +} + +/** + * Sets document-related variables once based on the current document + * @param {Element|Object} [node] An element or document object to use to set the document + * @returns {Object} Returns the current document + */ +function setDocument( node ) { + var subWindow, + doc = node ? node.ownerDocument || node : preferredDoc; + + // Return early if doc is invalid or already selected + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) { + return document; + } + + // Update global variables + document = doc; + documentElement = document.documentElement; + documentIsHTML = !jQuery.isXMLDoc( document ); + + // Support: iOS 7 only, IE 9 - 11+ + // Older browsers didn't support unprefixed `matches`. + matches = documentElement.matches || + documentElement.webkitMatchesSelector || + documentElement.msMatchesSelector; + + // Support: IE 9 - 11+, Edge 12 - 18+ + // Accessing iframe documents after unload throws "permission denied" errors + // (see trac-13936). + // Limit the fix to IE & Edge Legacy; despite Edge 15+ implementing `matches`, + // all IE 9+ and Edge Legacy versions implement `msMatchesSelector` as well. + if ( documentElement.msMatchesSelector && + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + preferredDoc != document && + ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { + + // Support: IE 9 - 11+, Edge 12 - 18+ + subWindow.addEventListener( "unload", unloadHandler ); + } + + // Support: IE <10 + // Check if getElementById returns elements by name + // The broken getElementById methods don't pick up programmatically-set names, + // so use a roundabout getElementsByName test + support.getById = assert( function( el ) { + documentElement.appendChild( el ).id = jQuery.expando; + return !document.getElementsByName || + !document.getElementsByName( jQuery.expando ).length; + } ); + + // Support: IE 9 only + // Check to see if it's possible to do matchesSelector + // on a disconnected node. + support.disconnectedMatch = assert( function( el ) { + return matches.call( el, "*" ); + } ); + + // Support: IE 9 - 11+, Edge 12 - 18+ + // IE/Edge don't support the :scope pseudo-class. + support.scope = assert( function() { + return document.querySelectorAll( ":scope" ); + } ); + + // Support: Chrome 105 - 111 only, Safari 15.4 - 16.3 only + // Make sure the `:has()` argument is parsed unforgivingly. + // We include `*` in the test to detect buggy implementations that are + // _selectively_ forgiving (specifically when the list includes at least + // one valid selector). + // Note that we treat complete lack of support for `:has()` as if it were + // spec-compliant support, which is fine because use of `:has()` in such + // environments will fail in the qSA path and fall back to jQuery traversal + // anyway. + support.cssHas = assert( function() { + try { + document.querySelector( ":has(*,:jqfake)" ); + return false; + } catch ( e ) { + return true; + } + } ); + + // ID filter and find + if ( support.getById ) { + Expr.filter.ID = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + return elem.getAttribute( "id" ) === attrId; + }; + }; + Expr.find.ID = function( id, context ) { + if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { + var elem = context.getElementById( id ); + return elem ? [ elem ] : []; + } + }; + } else { + Expr.filter.ID = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + var node = typeof elem.getAttributeNode !== "undefined" && + elem.getAttributeNode( "id" ); + return node && node.value === attrId; + }; + }; + + // Support: IE 6 - 7 only + // getElementById is not reliable as a find shortcut + Expr.find.ID = function( id, context ) { + if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { + var node, i, elems, + elem = context.getElementById( id ); + + if ( elem ) { + + // Verify the id attribute + node = elem.getAttributeNode( "id" ); + if ( node && node.value === id ) { + return [ elem ]; + } + + // Fall back on getElementsByName + elems = context.getElementsByName( id ); + i = 0; + while ( ( elem = elems[ i++ ] ) ) { + node = elem.getAttributeNode( "id" ); + if ( node && node.value === id ) { + return [ elem ]; + } + } + } + + return []; + } + }; + } + + // Tag + Expr.find.TAG = function( tag, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( tag ); + + // DocumentFragment nodes don't have gEBTN + } else { + return context.querySelectorAll( tag ); + } + }; + + // Class + Expr.find.CLASS = function( className, context ) { + if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { + return context.getElementsByClassName( className ); + } + }; + + /* QSA/matchesSelector + ---------------------------------------------------------------------- */ + + // QSA and matchesSelector support + + rbuggyQSA = []; + + // Build QSA regex + // Regex strategy adopted from Diego Perini + assert( function( el ) { + + var input; + + documentElement.appendChild( el ).innerHTML = + "" + + ""; + + // Support: iOS <=7 - 8 only + // Boolean attributes and "value" are not treated correctly in some XML documents + if ( !el.querySelectorAll( "[selected]" ).length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); + } + + // Support: iOS <=7 - 8 only + if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { + rbuggyQSA.push( "~=" ); + } + + // Support: iOS 8 only + // https://bugs.webkit.org/show_bug.cgi?id=136851 + // In-page `selector#id sibling-combinator selector` fails + if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { + rbuggyQSA.push( ".#.+[+~]" ); + } + + // Support: Chrome <=105+, Firefox <=104+, Safari <=15.4+ + // In some of the document kinds, these selectors wouldn't work natively. + // This is probably OK but for backwards compatibility we want to maintain + // handling them through jQuery traversal in jQuery 3.x. + if ( !el.querySelectorAll( ":checked" ).length ) { + rbuggyQSA.push( ":checked" ); + } + + // Support: Windows 8 Native Apps + // The type and name attributes are restricted during .innerHTML assignment + input = document.createElement( "input" ); + input.setAttribute( "type", "hidden" ); + el.appendChild( input ).setAttribute( "name", "D" ); + + // Support: IE 9 - 11+ + // IE's :disabled selector does not pick up the children of disabled fieldsets + // Support: Chrome <=105+, Firefox <=104+, Safari <=15.4+ + // In some of the document kinds, these selectors wouldn't work natively. + // This is probably OK but for backwards compatibility we want to maintain + // handling them through jQuery traversal in jQuery 3.x. + documentElement.appendChild( el ).disabled = true; + if ( el.querySelectorAll( ":disabled" ).length !== 2 ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Support: IE 11+, Edge 15 - 18+ + // IE 11/Edge don't find elements on a `[name='']` query in some cases. + // Adding a temporary attribute to the document before the selection works + // around the issue. + // Interestingly, IE 10 & older don't seem to have the issue. + input = document.createElement( "input" ); + input.setAttribute( "name", "" ); + el.appendChild( input ); + if ( !el.querySelectorAll( "[name='']" ).length ) { + rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" + + whitespace + "*(?:''|\"\")" ); + } + } ); + + if ( !support.cssHas ) { + + // Support: Chrome 105 - 110+, Safari 15.4 - 16.3+ + // Our regular `try-catch` mechanism fails to detect natively-unsupported + // pseudo-classes inside `:has()` (such as `:has(:contains("Foo"))`) + // in browsers that parse the `:has()` argument as a forgiving selector list. + // https://drafts.csswg.org/selectors/#relational now requires the argument + // to be parsed unforgivingly, but browsers have not yet fully adjusted. + rbuggyQSA.push( ":has" ); + } + + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); + + /* Sorting + ---------------------------------------------------------------------- */ + + // Document order sorting + sortOrder = function( a, b ) { + + // Flag for duplicate removal + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + // Sort on method existence if only one input has compareDocumentPosition + var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; + if ( compare ) { + return compare; + } + + // Calculate position if both inputs belong to the same document + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ? + a.compareDocumentPosition( b ) : + + // Otherwise we know they are disconnected + 1; + + // Disconnected nodes + if ( compare & 1 || + ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) { + + // Choose the first element that is related to our preferred document + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( a === document || a.ownerDocument == preferredDoc && + find.contains( preferredDoc, a ) ) { + return -1; + } + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( b === document || b.ownerDocument == preferredDoc && + find.contains( preferredDoc, b ) ) { + return 1; + } + + // Maintain original order + return sortInput ? + ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : + 0; + } + + return compare & 4 ? -1 : 1; + }; + + return document; +} + +find.matches = function( expr, elements ) { + return find( expr, null, null, elements ); +}; + +find.matchesSelector = function( elem, expr ) { + setDocument( elem ); + + if ( documentIsHTML && + !nonnativeSelectorCache[ expr + " " ] && + ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { + + try { + var ret = matches.call( elem, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || support.disconnectedMatch || + + // As well, disconnected nodes are said to be in a document + // fragment in IE 9 + elem.document && elem.document.nodeType !== 11 ) { + return ret; + } + } catch ( e ) { + nonnativeSelectorCache( expr, true ); + } + } + + return find( expr, document, null, [ elem ] ).length > 0; +}; + +find.contains = function( context, elem ) { + + // Set document vars if needed + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( ( context.ownerDocument || context ) != document ) { + setDocument( context ); + } + return jQuery.contains( context, elem ); +}; + + +find.attr = function( elem, name ) { + + // Set document vars if needed + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( ( elem.ownerDocument || elem ) != document ) { + setDocument( elem ); + } + + var fn = Expr.attrHandle[ name.toLowerCase() ], + + // Don't get fooled by Object.prototype properties (see trac-13807) + val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? + fn( elem, name, !documentIsHTML ) : + undefined; + + if ( val !== undefined ) { + return val; + } + + return elem.getAttribute( name ); +}; + +find.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * Document sorting and removing duplicates + * @param {ArrayLike} results + */ +jQuery.uniqueSort = function( results ) { + var elem, + duplicates = [], + j = 0, + i = 0; + + // Unless we *know* we can detect duplicates, assume their presence + // + // Support: Android <=4.0+ + // Testing for detecting duplicates is unpredictable so instead assume we can't + // depend on duplicate detection in all browsers without a stable sort. + hasDuplicate = !support.sortStable; + sortInput = !support.sortStable && slice.call( results, 0 ); + sort.call( results, sortOrder ); + + if ( hasDuplicate ) { + while ( ( elem = results[ i++ ] ) ) { + if ( elem === results[ i ] ) { + j = duplicates.push( i ); + } + } + while ( j-- ) { + splice.call( results, duplicates[ j ], 1 ); + } + } + + // Clear input after sorting to release objects + // See https://github.com/jquery/sizzle/pull/225 + sortInput = null; + + return results; +}; + +jQuery.fn.uniqueSort = function() { + return this.pushStack( jQuery.uniqueSort( slice.apply( this ) ) ); +}; + +Expr = jQuery.expr = { + + // Can be adjusted by the user + cacheLength: 50, + + createPseudo: markFunction, + + match: matchExpr, + + attrHandle: {}, + + find: {}, + + relative: { + ">": { dir: "parentNode", first: true }, + " ": { dir: "parentNode" }, + "+": { dir: "previousSibling", first: true }, + "~": { dir: "previousSibling" } + }, + + preFilter: { + ATTR: function( match ) { + match[ 1 ] = match[ 1 ].replace( runescape, funescape ); + + // Move the given value to match[3] whether quoted or unquoted + match[ 3 ] = ( match[ 3 ] || match[ 4 ] || match[ 5 ] || "" ) + .replace( runescape, funescape ); + + if ( match[ 2 ] === "~=" ) { + match[ 3 ] = " " + match[ 3 ] + " "; + } + + return match.slice( 0, 4 ); + }, + + CHILD: function( match ) { + + /* matches from matchExpr["CHILD"] + 1 type (only|nth|...) + 2 what (child|of-type) + 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) + 4 xn-component of xn+y argument ([+-]?\d*n|) + 5 sign of xn-component + 6 x of xn-component + 7 sign of y-component + 8 y of y-component + */ + match[ 1 ] = match[ 1 ].toLowerCase(); + + if ( match[ 1 ].slice( 0, 3 ) === "nth" ) { + + // nth-* requires argument + if ( !match[ 3 ] ) { + find.error( match[ 0 ] ); + } + + // numeric x and y parameters for Expr.filter.CHILD + // remember that false/true cast respectively to 0/1 + match[ 4 ] = +( match[ 4 ] ? + match[ 5 ] + ( match[ 6 ] || 1 ) : + 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) + ); + match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" ); + + // other types prohibit arguments + } else if ( match[ 3 ] ) { + find.error( match[ 0 ] ); + } + + return match; + }, + + PSEUDO: function( match ) { + var excess, + unquoted = !match[ 6 ] && match[ 2 ]; + + if ( matchExpr.CHILD.test( match[ 0 ] ) ) { + return null; + } + + // Accept quoted arguments as-is + if ( match[ 3 ] ) { + match[ 2 ] = match[ 4 ] || match[ 5 ] || ""; + + // Strip excess characters from unquoted arguments + } else if ( unquoted && rpseudo.test( unquoted ) && + + // Get excess from tokenize (recursively) + ( excess = tokenize( unquoted, true ) ) && + + // advance to the next closing parenthesis + ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) { + + // excess is a negative index + match[ 0 ] = match[ 0 ].slice( 0, excess ); + match[ 2 ] = unquoted.slice( 0, excess ); + } + + // Return only captures needed by the pseudo filter method (type and argument) + return match.slice( 0, 3 ); + } + }, + + filter: { + + TAG: function( nodeNameSelector ) { + var expectedNodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); + return nodeNameSelector === "*" ? + function() { + return true; + } : + function( elem ) { + return nodeName( elem, expectedNodeName ); + }; + }, + + CLASS: function( className ) { + var pattern = classCache[ className + " " ]; + + return pattern || + ( pattern = new RegExp( "(^|" + whitespace + ")" + className + + "(" + whitespace + "|$)" ) ) && + classCache( className, function( elem ) { + return pattern.test( + typeof elem.className === "string" && elem.className || + typeof elem.getAttribute !== "undefined" && + elem.getAttribute( "class" ) || + "" + ); + } ); + }, + + ATTR: function( name, operator, check ) { + return function( elem ) { + var result = find.attr( elem, name ); + + if ( result == null ) { + return operator === "!="; + } + if ( !operator ) { + return true; + } + + result += ""; + + if ( operator === "=" ) { + return result === check; + } + if ( operator === "!=" ) { + return result !== check; + } + if ( operator === "^=" ) { + return check && result.indexOf( check ) === 0; + } + if ( operator === "*=" ) { + return check && result.indexOf( check ) > -1; + } + if ( operator === "$=" ) { + return check && result.slice( -check.length ) === check; + } + if ( operator === "~=" ) { + return ( " " + result.replace( rwhitespace, " " ) + " " ) + .indexOf( check ) > -1; + } + if ( operator === "|=" ) { + return result === check || result.slice( 0, check.length + 1 ) === check + "-"; + } + + return false; + }; + }, + + CHILD: function( type, what, _argument, first, last ) { + var simple = type.slice( 0, 3 ) !== "nth", + forward = type.slice( -4 ) !== "last", + ofType = what === "of-type"; + + return first === 1 && last === 0 ? + + // Shortcut for :nth-*(n) + function( elem ) { + return !!elem.parentNode; + } : + + function( elem, _context, xml ) { + var cache, outerCache, node, nodeIndex, start, + dir = simple !== forward ? "nextSibling" : "previousSibling", + parent = elem.parentNode, + name = ofType && elem.nodeName.toLowerCase(), + useCache = !xml && !ofType, + diff = false; + + if ( parent ) { + + // :(first|last|only)-(child|of-type) + if ( simple ) { + while ( dir ) { + node = elem; + while ( ( node = node[ dir ] ) ) { + if ( ofType ? + nodeName( node, name ) : + node.nodeType === 1 ) { + + return false; + } + } + + // Reverse direction for :only-* (if we haven't yet done so) + start = dir = type === "only" && !start && "nextSibling"; + } + return true; + } + + start = [ forward ? parent.firstChild : parent.lastChild ]; + + // non-xml :nth-child(...) stores cache data on `parent` + if ( forward && useCache ) { + + // Seek `elem` from a previously-cached index + outerCache = parent[ expando ] || ( parent[ expando ] = {} ); + cache = outerCache[ type ] || []; + nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; + diff = nodeIndex && cache[ 2 ]; + node = nodeIndex && parent.childNodes[ nodeIndex ]; + + while ( ( node = ++nodeIndex && node && node[ dir ] || + + // Fallback to seeking `elem` from the start + ( diff = nodeIndex = 0 ) || start.pop() ) ) { + + // When found, cache indexes on `parent` and break + if ( node.nodeType === 1 && ++diff && node === elem ) { + outerCache[ type ] = [ dirruns, nodeIndex, diff ]; + break; + } + } + + } else { + + // Use previously-cached element index if available + if ( useCache ) { + outerCache = elem[ expando ] || ( elem[ expando ] = {} ); + cache = outerCache[ type ] || []; + nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; + diff = nodeIndex; + } + + // xml :nth-child(...) + // or :nth-last-child(...) or :nth(-last)?-of-type(...) + if ( diff === false ) { + + // Use the same loop as above to seek `elem` from the start + while ( ( node = ++nodeIndex && node && node[ dir ] || + ( diff = nodeIndex = 0 ) || start.pop() ) ) { + + if ( ( ofType ? + nodeName( node, name ) : + node.nodeType === 1 ) && + ++diff ) { + + // Cache the index of each encountered element + if ( useCache ) { + outerCache = node[ expando ] || + ( node[ expando ] = {} ); + outerCache[ type ] = [ dirruns, diff ]; + } + + if ( node === elem ) { + break; + } + } + } + } + } + + // Incorporate the offset, then check against cycle size + diff -= last; + return diff === first || ( diff % first === 0 && diff / first >= 0 ); + } + }; + }, + + PSEUDO: function( pseudo, argument ) { + + // pseudo-class names are case-insensitive + // https://www.w3.org/TR/selectors/#pseudo-classes + // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters + // Remember that setFilters inherits from pseudos + var args, + fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || + find.error( "unsupported pseudo: " + pseudo ); + + // The user may use createPseudo to indicate that + // arguments are needed to create the filter function + // just as jQuery does + if ( fn[ expando ] ) { + return fn( argument ); + } + + // But maintain support for old signatures + if ( fn.length > 1 ) { + args = [ pseudo, pseudo, "", argument ]; + return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? + markFunction( function( seed, matches ) { + var idx, + matched = fn( seed, argument ), + i = matched.length; + while ( i-- ) { + idx = indexOf.call( seed, matched[ i ] ); + seed[ idx ] = !( matches[ idx ] = matched[ i ] ); + } + } ) : + function( elem ) { + return fn( elem, 0, args ); + }; + } + + return fn; + } + }, + + pseudos: { + + // Potentially complex pseudos + not: markFunction( function( selector ) { + + // Trim the selector passed to compile + // to avoid treating leading and trailing + // spaces as combinators + var input = [], + results = [], + matcher = compile( selector.replace( rtrimCSS, "$1" ) ); + + return matcher[ expando ] ? + markFunction( function( seed, matches, _context, xml ) { + var elem, + unmatched = matcher( seed, null, xml, [] ), + i = seed.length; + + // Match elements unmatched by `matcher` + while ( i-- ) { + if ( ( elem = unmatched[ i ] ) ) { + seed[ i ] = !( matches[ i ] = elem ); + } + } + } ) : + function( elem, _context, xml ) { + input[ 0 ] = elem; + matcher( input, null, xml, results ); + + // Don't keep the element + // (see https://github.com/jquery/sizzle/issues/299) + input[ 0 ] = null; + return !results.pop(); + }; + } ), + + has: markFunction( function( selector ) { + return function( elem ) { + return find( selector, elem ).length > 0; + }; + } ), + + contains: markFunction( function( text ) { + text = text.replace( runescape, funescape ); + return function( elem ) { + return ( elem.textContent || jQuery.text( elem ) ).indexOf( text ) > -1; + }; + } ), + + // "Whether an element is represented by a :lang() selector + // is based solely on the element's language value + // being equal to the identifier C, + // or beginning with the identifier C immediately followed by "-". + // The matching of C against the element's language value is performed case-insensitively. + // The identifier C does not have to be a valid language name." + // https://www.w3.org/TR/selectors/#lang-pseudo + lang: markFunction( function( lang ) { + + // lang value must be a valid identifier + if ( !ridentifier.test( lang || "" ) ) { + find.error( "unsupported lang: " + lang ); + } + lang = lang.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + var elemLang; + do { + if ( ( elemLang = documentIsHTML ? + elem.lang : + elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) { + + elemLang = elemLang.toLowerCase(); + return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; + } + } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 ); + return false; + }; + } ), + + // Miscellaneous + target: function( elem ) { + var hash = window.location && window.location.hash; + return hash && hash.slice( 1 ) === elem.id; + }, + + root: function( elem ) { + return elem === documentElement; + }, + + focus: function( elem ) { + return elem === safeActiveElement() && + document.hasFocus() && + !!( elem.type || elem.href || ~elem.tabIndex ); + }, + + // Boolean properties + enabled: createDisabledPseudo( false ), + disabled: createDisabledPseudo( true ), + + checked: function( elem ) { + + // In CSS3, :checked should return both checked and selected elements + // https://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + return ( nodeName( elem, "input" ) && !!elem.checked ) || + ( nodeName( elem, "option" ) && !!elem.selected ); + }, + + selected: function( elem ) { + + // Support: IE <=11+ + // Accessing the selectedIndex property + // forces the browser to treat the default option as + // selected when in an optgroup. + if ( elem.parentNode ) { + // eslint-disable-next-line no-unused-expressions + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + // Contents + empty: function( elem ) { + + // https://www.w3.org/TR/selectors/#empty-pseudo + // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), + // but not by others (comment: 8; processing instruction: 7; etc.) + // nodeType < 6 works because attributes (2) do not appear as children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + if ( elem.nodeType < 6 ) { + return false; + } + } + return true; + }, + + parent: function( elem ) { + return !Expr.pseudos.empty( elem ); + }, + + // Element/input types + header: function( elem ) { + return rheader.test( elem.nodeName ); + }, + + input: function( elem ) { + return rinputs.test( elem.nodeName ); + }, + + button: function( elem ) { + return nodeName( elem, "input" ) && elem.type === "button" || + nodeName( elem, "button" ); + }, + + text: function( elem ) { + var attr; + return nodeName( elem, "input" ) && elem.type === "text" && + + // Support: IE <10 only + // New HTML5 attribute values (e.g., "search") appear + // with elem.type === "text" + ( ( attr = elem.getAttribute( "type" ) ) == null || + attr.toLowerCase() === "text" ); + }, + + // Position-in-collection + first: createPositionalPseudo( function() { + return [ 0 ]; + } ), + + last: createPositionalPseudo( function( _matchIndexes, length ) { + return [ length - 1 ]; + } ), + + eq: createPositionalPseudo( function( _matchIndexes, length, argument ) { + return [ argument < 0 ? argument + length : argument ]; + } ), + + even: createPositionalPseudo( function( matchIndexes, length ) { + var i = 0; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + } ), + + odd: createPositionalPseudo( function( matchIndexes, length ) { + var i = 1; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + } ), + + lt: createPositionalPseudo( function( matchIndexes, length, argument ) { + var i; + + if ( argument < 0 ) { + i = argument + length; + } else if ( argument > length ) { + i = length; + } else { + i = argument; + } + + for ( ; --i >= 0; ) { + matchIndexes.push( i ); + } + return matchIndexes; + } ), + + gt: createPositionalPseudo( function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; ++i < length; ) { + matchIndexes.push( i ); + } + return matchIndexes; + } ) + } +}; + +Expr.pseudos.nth = Expr.pseudos.eq; + +// Add button/input type pseudos +for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { + Expr.pseudos[ i ] = createInputPseudo( i ); +} +for ( i in { submit: true, reset: true } ) { + Expr.pseudos[ i ] = createButtonPseudo( i ); +} + +// Easy API for creating new setFilters +function setFilters() {} +setFilters.prototype = Expr.filters = Expr.pseudos; +Expr.setFilters = new setFilters(); + +function tokenize( selector, parseOnly ) { + var matched, match, tokens, type, + soFar, groups, preFilters, + cached = tokenCache[ selector + " " ]; + + if ( cached ) { + return parseOnly ? 0 : cached.slice( 0 ); + } + + soFar = selector; + groups = []; + preFilters = Expr.preFilter; + + while ( soFar ) { + + // Comma and first run + if ( !matched || ( match = rcomma.exec( soFar ) ) ) { + if ( match ) { + + // Don't consume trailing commas as valid + soFar = soFar.slice( match[ 0 ].length ) || soFar; + } + groups.push( ( tokens = [] ) ); + } + + matched = false; + + // Combinators + if ( ( match = rleadingCombinator.exec( soFar ) ) ) { + matched = match.shift(); + tokens.push( { + value: matched, + + // Cast descendant combinators to space + type: match[ 0 ].replace( rtrimCSS, " " ) + } ); + soFar = soFar.slice( matched.length ); + } + + // Filters + for ( type in Expr.filter ) { + if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] || + ( match = preFilters[ type ]( match ) ) ) ) { + matched = match.shift(); + tokens.push( { + value: matched, + type: type, + matches: match + } ); + soFar = soFar.slice( matched.length ); + } + } + + if ( !matched ) { + break; + } + } + + // Return the length of the invalid excess + // if we're just parsing + // Otherwise, throw an error or return tokens + if ( parseOnly ) { + return soFar.length; + } + + return soFar ? + find.error( selector ) : + + // Cache the tokens + tokenCache( selector, groups ).slice( 0 ); +} + +function toSelector( tokens ) { + var i = 0, + len = tokens.length, + selector = ""; + for ( ; i < len; i++ ) { + selector += tokens[ i ].value; + } + return selector; +} + +function addCombinator( matcher, combinator, base ) { + var dir = combinator.dir, + skip = combinator.next, + key = skip || dir, + checkNonElements = base && key === "parentNode", + doneName = done++; + + return combinator.first ? + + // Check against closest ancestor/preceding element + function( elem, context, xml ) { + while ( ( elem = elem[ dir ] ) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + return matcher( elem, context, xml ); + } + } + return false; + } : + + // Check against all ancestor/preceding elements + function( elem, context, xml ) { + var oldCache, outerCache, + newCache = [ dirruns, doneName ]; + + // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching + if ( xml ) { + while ( ( elem = elem[ dir ] ) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + if ( matcher( elem, context, xml ) ) { + return true; + } + } + } + } else { + while ( ( elem = elem[ dir ] ) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + outerCache = elem[ expando ] || ( elem[ expando ] = {} ); + + if ( skip && nodeName( elem, skip ) ) { + elem = elem[ dir ] || elem; + } else if ( ( oldCache = outerCache[ key ] ) && + oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { + + // Assign to newCache so results back-propagate to previous elements + return ( newCache[ 2 ] = oldCache[ 2 ] ); + } else { + + // Reuse newcache so results back-propagate to previous elements + outerCache[ key ] = newCache; + + // A match means we're done; a fail means we have to keep checking + if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) { + return true; + } + } + } + } + } + return false; + }; +} + +function elementMatcher( matchers ) { + return matchers.length > 1 ? + function( elem, context, xml ) { + var i = matchers.length; + while ( i-- ) { + if ( !matchers[ i ]( elem, context, xml ) ) { + return false; + } + } + return true; + } : + matchers[ 0 ]; +} + +function multipleContexts( selector, contexts, results ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + find( selector, contexts[ i ], results ); + } + return results; +} + +function condense( unmatched, map, filter, context, xml ) { + var elem, + newUnmatched = [], + i = 0, + len = unmatched.length, + mapped = map != null; + + for ( ; i < len; i++ ) { + if ( ( elem = unmatched[ i ] ) ) { + if ( !filter || filter( elem, context, xml ) ) { + newUnmatched.push( elem ); + if ( mapped ) { + map.push( i ); + } + } + } + } + + return newUnmatched; +} + +function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { + if ( postFilter && !postFilter[ expando ] ) { + postFilter = setMatcher( postFilter ); + } + if ( postFinder && !postFinder[ expando ] ) { + postFinder = setMatcher( postFinder, postSelector ); + } + return markFunction( function( seed, results, context, xml ) { + var temp, i, elem, matcherOut, + preMap = [], + postMap = [], + preexisting = results.length, + + // Get initial elements from seed or context + elems = seed || + multipleContexts( selector || "*", + context.nodeType ? [ context ] : context, [] ), + + // Prefilter to get matcher input, preserving a map for seed-results synchronization + matcherIn = preFilter && ( seed || !selector ) ? + condense( elems, preMap, preFilter, context, xml ) : + elems; + + if ( matcher ) { + + // If we have a postFinder, or filtered seed, or non-seed postFilter + // or preexisting results, + matcherOut = postFinder || ( seed ? preFilter : preexisting || postFilter ) ? + + // ...intermediate processing is necessary + [] : + + // ...otherwise use results directly + results; + + // Find primary matches + matcher( matcherIn, matcherOut, context, xml ); + } else { + matcherOut = matcherIn; + } + + // Apply postFilter + if ( postFilter ) { + temp = condense( matcherOut, postMap ); + postFilter( temp, [], context, xml ); + + // Un-match failing elements by moving them back to matcherIn + i = temp.length; + while ( i-- ) { + if ( ( elem = temp[ i ] ) ) { + matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem ); + } + } + } + + if ( seed ) { + if ( postFinder || preFilter ) { + if ( postFinder ) { + + // Get the final matcherOut by condensing this intermediate into postFinder contexts + temp = []; + i = matcherOut.length; + while ( i-- ) { + if ( ( elem = matcherOut[ i ] ) ) { + + // Restore matcherIn since elem is not yet a final match + temp.push( ( matcherIn[ i ] = elem ) ); + } + } + postFinder( null, ( matcherOut = [] ), temp, xml ); + } + + // Move matched elements from seed to results to keep them synchronized + i = matcherOut.length; + while ( i-- ) { + if ( ( elem = matcherOut[ i ] ) && + ( temp = postFinder ? indexOf.call( seed, elem ) : preMap[ i ] ) > -1 ) { + + seed[ temp ] = !( results[ temp ] = elem ); + } + } + } + + // Add elements to results, through postFinder if defined + } else { + matcherOut = condense( + matcherOut === results ? + matcherOut.splice( preexisting, matcherOut.length ) : + matcherOut + ); + if ( postFinder ) { + postFinder( null, results, matcherOut, xml ); + } else { + push.apply( results, matcherOut ); + } + } + } ); +} + +function matcherFromTokens( tokens ) { + var checkContext, matcher, j, + len = tokens.length, + leadingRelative = Expr.relative[ tokens[ 0 ].type ], + implicitRelative = leadingRelative || Expr.relative[ " " ], + i = leadingRelative ? 1 : 0, + + // The foundational matcher ensures that elements are reachable from top-level context(s) + matchContext = addCombinator( function( elem ) { + return elem === checkContext; + }, implicitRelative, true ), + matchAnyContext = addCombinator( function( elem ) { + return indexOf.call( checkContext, elem ) > -1; + }, implicitRelative, true ), + matchers = [ function( elem, context, xml ) { + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + var ret = ( !leadingRelative && ( xml || context != outermostContext ) ) || ( + ( checkContext = context ).nodeType ? + matchContext( elem, context, xml ) : + matchAnyContext( elem, context, xml ) ); + + // Avoid hanging onto element + // (see https://github.com/jquery/sizzle/issues/299) + checkContext = null; + return ret; + } ]; + + for ( ; i < len; i++ ) { + if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) { + matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; + } else { + matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches ); + + // Return special upon seeing a positional matcher + if ( matcher[ expando ] ) { + + // Find the next relative operator (if any) for proper handling + j = ++i; + for ( ; j < len; j++ ) { + if ( Expr.relative[ tokens[ j ].type ] ) { + break; + } + } + return setMatcher( + i > 1 && elementMatcher( matchers ), + i > 1 && toSelector( + + // If the preceding token was a descendant combinator, insert an implicit any-element `*` + tokens.slice( 0, i - 1 ) + .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } ) + ).replace( rtrimCSS, "$1" ), + matcher, + i < j && matcherFromTokens( tokens.slice( i, j ) ), + j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ), + j < len && toSelector( tokens ) + ); + } + matchers.push( matcher ); + } + } + + return elementMatcher( matchers ); +} + +function matcherFromGroupMatchers( elementMatchers, setMatchers ) { + var bySet = setMatchers.length > 0, + byElement = elementMatchers.length > 0, + superMatcher = function( seed, context, xml, results, outermost ) { + var elem, j, matcher, + matchedCount = 0, + i = "0", + unmatched = seed && [], + setMatched = [], + contextBackup = outermostContext, + + // We must always have either seed elements or outermost context + elems = seed || byElement && Expr.find.TAG( "*", outermost ), + + // Use integer dirruns iff this is the outermost matcher + dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ), + len = elems.length; + + if ( outermost ) { + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + outermostContext = context == document || context || outermost; + } + + // Add elements passing elementMatchers directly to results + // Support: iOS <=7 - 9 only + // Tolerate NodeList properties (IE: "length"; Safari: ) matching + // elements by id. (see trac-14142) + for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) { + if ( byElement && elem ) { + j = 0; + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( !context && elem.ownerDocument != document ) { + setDocument( elem ); + xml = !documentIsHTML; + } + while ( ( matcher = elementMatchers[ j++ ] ) ) { + if ( matcher( elem, context || document, xml ) ) { + push.call( results, elem ); + break; + } + } + if ( outermost ) { + dirruns = dirrunsUnique; + } + } + + // Track unmatched elements for set filters + if ( bySet ) { + + // They will have gone through all possible matchers + if ( ( elem = !matcher && elem ) ) { + matchedCount--; + } + + // Lengthen the array for every element, matched or not + if ( seed ) { + unmatched.push( elem ); + } + } + } + + // `i` is now the count of elements visited above, and adding it to `matchedCount` + // makes the latter nonnegative. + matchedCount += i; + + // Apply set filters to unmatched elements + // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` + // equals `i`), unless we didn't visit _any_ elements in the above loop because we have + // no element matchers and no seed. + // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that + // case, which will result in a "00" `matchedCount` that differs from `i` but is also + // numerically zero. + if ( bySet && i !== matchedCount ) { + j = 0; + while ( ( matcher = setMatchers[ j++ ] ) ) { + matcher( unmatched, setMatched, context, xml ); + } + + if ( seed ) { + + // Reintegrate element matches to eliminate the need for sorting + if ( matchedCount > 0 ) { + while ( i-- ) { + if ( !( unmatched[ i ] || setMatched[ i ] ) ) { + setMatched[ i ] = pop.call( results ); + } + } + } + + // Discard index placeholder values to get only actual matches + setMatched = condense( setMatched ); + } + + // Add matches to results + push.apply( results, setMatched ); + + // Seedless set matches succeeding multiple successful matchers stipulate sorting + if ( outermost && !seed && setMatched.length > 0 && + ( matchedCount + setMatchers.length ) > 1 ) { + + jQuery.uniqueSort( results ); + } + } + + // Override manipulation of globals by nested matchers + if ( outermost ) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; + } + + return unmatched; + }; + + return bySet ? + markFunction( superMatcher ) : + superMatcher; +} + +function compile( selector, match /* Internal Use Only */ ) { + var i, + setMatchers = [], + elementMatchers = [], + cached = compilerCache[ selector + " " ]; + + if ( !cached ) { + + // Generate a function of recursive functions that can be used to check each element + if ( !match ) { + match = tokenize( selector ); + } + i = match.length; + while ( i-- ) { + cached = matcherFromTokens( match[ i ] ); + if ( cached[ expando ] ) { + setMatchers.push( cached ); + } else { + elementMatchers.push( cached ); + } + } + + // Cache the compiled function + cached = compilerCache( selector, + matcherFromGroupMatchers( elementMatchers, setMatchers ) ); + + // Save selector and tokenization + cached.selector = selector; + } + return cached; +} + +/** + * A low-level selection function that works with jQuery's compiled + * selector functions + * @param {String|Function} selector A selector or a pre-compiled + * selector function built with jQuery selector compile + * @param {Element} context + * @param {Array} [results] + * @param {Array} [seed] A set of elements to match against + */ +function select( selector, context, results, seed ) { + var i, tokens, token, type, find, + compiled = typeof selector === "function" && selector, + match = !seed && tokenize( ( selector = compiled.selector || selector ) ); + + results = results || []; + + // Try to minimize operations if there is only one selector in the list and no seed + // (the latter of which guarantees us context) + if ( match.length === 1 ) { + + // Reduce context if the leading compound selector is an ID + tokens = match[ 0 ] = match[ 0 ].slice( 0 ); + if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" && + context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) { + + context = ( Expr.find.ID( + token.matches[ 0 ].replace( runescape, funescape ), + context + ) || [] )[ 0 ]; + if ( !context ) { + return results; + + // Precompiled matchers will still verify ancestry, so step up a level + } else if ( compiled ) { + context = context.parentNode; + } + + selector = selector.slice( tokens.shift().value.length ); + } + + // Fetch a seed set for right-to-left matching + i = matchExpr.needsContext.test( selector ) ? 0 : tokens.length; + while ( i-- ) { + token = tokens[ i ]; + + // Abort if we hit a combinator + if ( Expr.relative[ ( type = token.type ) ] ) { + break; + } + if ( ( find = Expr.find[ type ] ) ) { + + // Search, expanding context for leading sibling combinators + if ( ( seed = find( + token.matches[ 0 ].replace( runescape, funescape ), + rsibling.test( tokens[ 0 ].type ) && + testContext( context.parentNode ) || context + ) ) ) { + + // If seed is empty or no tokens remain, we can return early + tokens.splice( i, 1 ); + selector = seed.length && toSelector( tokens ); + if ( !selector ) { + push.apply( results, seed ); + return results; + } + + break; + } + } + } + } + + // Compile and execute a filtering function if one is not provided + // Provide `match` to avoid retokenization if we modified the selector above + ( compiled || compile( selector, match ) )( + seed, + context, + !documentIsHTML, + results, + !context || rsibling.test( selector ) && testContext( context.parentNode ) || context + ); + return results; +} + +// One-time assignments + +// Support: Android <=4.0 - 4.1+ +// Sort stability +support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando; + +// Initialize against the default document +setDocument(); + +// Support: Android <=4.0 - 4.1+ +// Detached nodes confoundingly follow *each other* +support.sortDetached = assert( function( el ) { + + // Should return 1, but returns 4 (following) + return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1; +} ); + +jQuery.find = find; + +// Deprecated +jQuery.expr[ ":" ] = jQuery.expr.pseudos; +jQuery.unique = jQuery.uniqueSort; + +// These have always been private, but they used to be documented as part of +// Sizzle so let's maintain them for now for backwards compatibility purposes. +find.compile = compile; +find.select = select; +find.setDocument = setDocument; +find.tokenize = tokenize; + +find.escape = jQuery.escapeSelector; +find.getText = jQuery.text; +find.isXML = jQuery.isXMLDoc; +find.selectors = jQuery.expr; +find.support = jQuery.support; +find.uniqueSort = jQuery.uniqueSort; + + /* eslint-enable */ + +} )(); + + +var dir = function( elem, dir, until ) { + var matched = [], + truncate = until !== undefined; + + while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { + if ( elem.nodeType === 1 ) { + if ( truncate && jQuery( elem ).is( until ) ) { + break; + } + matched.push( elem ); + } + } + return matched; +}; + + +var siblings = function( n, elem ) { + var matched = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + matched.push( n ); + } + } + + return matched; +}; + + +var rneedsContext = jQuery.expr.match.needsContext; + +var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); + + + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, not ) { + if ( isFunction( qualifier ) ) { + return jQuery.grep( elements, function( elem, i ) { + return !!qualifier.call( elem, i, elem ) !== not; + } ); + } + + // Single element + if ( qualifier.nodeType ) { + return jQuery.grep( elements, function( elem ) { + return ( elem === qualifier ) !== not; + } ); + } + + // Arraylike of elements (jQuery, arguments, Array) + if ( typeof qualifier !== "string" ) { + return jQuery.grep( elements, function( elem ) { + return ( indexOf.call( qualifier, elem ) > -1 ) !== not; + } ); + } + + // Filtered directly for both simple and complex selectors + return jQuery.filter( qualifier, elements, not ); +} + +jQuery.filter = function( expr, elems, not ) { + var elem = elems[ 0 ]; + + if ( not ) { + expr = ":not(" + expr + ")"; + } + + if ( elems.length === 1 && elem.nodeType === 1 ) { + return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; + } + + return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { + return elem.nodeType === 1; + } ) ); +}; + +jQuery.fn.extend( { + find: function( selector ) { + var i, ret, + len = this.length, + self = this; + + if ( typeof selector !== "string" ) { + return this.pushStack( jQuery( selector ).filter( function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + } ) ); + } + + ret = this.pushStack( [] ); + + for ( i = 0; i < len; i++ ) { + jQuery.find( selector, self[ i ], ret ); + } + + return len > 1 ? jQuery.uniqueSort( ret ) : ret; + }, + filter: function( selector ) { + return this.pushStack( winnow( this, selector || [], false ) ); + }, + not: function( selector ) { + return this.pushStack( winnow( this, selector || [], true ) ); + }, + is: function( selector ) { + return !!winnow( + this, + + // If this is a positional/relative selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + typeof selector === "string" && rneedsContext.test( selector ) ? + jQuery( selector ) : + selector || [], + false + ).length; + } +} ); + + +// Initialize a jQuery object + + +// A central reference to the root jQuery(document) +var rootjQuery, + + // A simple way to check for HTML strings + // Prioritize #id over to avoid XSS via location.hash (trac-9521) + // Strict HTML recognition (trac-11290: must start with <) + // Shortcut simple #id case for speed + rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, + + init = jQuery.fn.init = function( selector, context, root ) { + var match, elem; + + // HANDLE: $(""), $(null), $(undefined), $(false) + if ( !selector ) { + return this; + } + + // Method init() accepts an alternate rootjQuery + // so migrate can support jQuery.sub (gh-2101) + root = root || rootjQuery; + + // Handle HTML strings + if ( typeof selector === "string" ) { + if ( selector[ 0 ] === "<" && + selector[ selector.length - 1 ] === ">" && + selector.length >= 3 ) { + + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = rquickExpr.exec( selector ); + } + + // Match html or make sure no context is specified for #id + if ( match && ( match[ 1 ] || !context ) ) { + + // HANDLE: $(html) -> $(array) + if ( match[ 1 ] ) { + context = context instanceof jQuery ? context[ 0 ] : context; + + // Option to run scripts is true for back-compat + // Intentionally let the error be thrown if parseHTML is not present + jQuery.merge( this, jQuery.parseHTML( + match[ 1 ], + context && context.nodeType ? context.ownerDocument || context : document, + true + ) ); + + // HANDLE: $(html, props) + if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { + for ( match in context ) { + + // Properties of context are called as methods if possible + if ( isFunction( this[ match ] ) ) { + this[ match ]( context[ match ] ); + + // ...and otherwise set as attributes + } else { + this.attr( match, context[ match ] ); + } + } + } + + return this; + + // HANDLE: $(#id) + } else { + elem = document.getElementById( match[ 2 ] ); + + if ( elem ) { + + // Inject the element directly into the jQuery object + this[ 0 ] = elem; + this.length = 1; + } + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || root ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(DOMElement) + } else if ( selector.nodeType ) { + this[ 0 ] = selector; + this.length = 1; + return this; + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( isFunction( selector ) ) { + return root.ready !== undefined ? + root.ready( selector ) : + + // Execute immediately if ready is not present + selector( jQuery ); + } + + return jQuery.makeArray( selector, this ); + }; + +// Give the init function the jQuery prototype for later instantiation +init.prototype = jQuery.fn; + +// Initialize central reference +rootjQuery = jQuery( document ); + + +var rparentsprev = /^(?:parents|prev(?:Until|All))/, + + // Methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend( { + has: function( target ) { + var targets = jQuery( target, this ), + l = targets.length; + + return this.filter( function() { + var i = 0; + for ( ; i < l; i++ ) { + if ( jQuery.contains( this, targets[ i ] ) ) { + return true; + } + } + } ); + }, + + closest: function( selectors, context ) { + var cur, + i = 0, + l = this.length, + matched = [], + targets = typeof selectors !== "string" && jQuery( selectors ); + + // Positional selectors never match, since there's no _selection_ context + if ( !rneedsContext.test( selectors ) ) { + for ( ; i < l; i++ ) { + for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { + + // Always skip document fragments + if ( cur.nodeType < 11 && ( targets ? + targets.index( cur ) > -1 : + + // Don't pass non-elements to jQuery#find + cur.nodeType === 1 && + jQuery.find.matchesSelector( cur, selectors ) ) ) { + + matched.push( cur ); + break; + } + } + } + } + + return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); + }, + + // Determine the position of an element within the set + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; + } + + // Index in selector + if ( typeof elem === "string" ) { + return indexOf.call( jQuery( elem ), this[ 0 ] ); + } + + // Locate the position of the desired element + return indexOf.call( this, + + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[ 0 ] : elem + ); + }, + + add: function( selector, context ) { + return this.pushStack( + jQuery.uniqueSort( + jQuery.merge( this.get(), jQuery( selector, context ) ) + ) + ); + }, + + addBack: function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter( selector ) + ); + } +} ); + +function sibling( cur, dir ) { + while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} + return cur; +} + +jQuery.each( { + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, _i, until ) { + return dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return sibling( elem, "nextSibling" ); + }, + prev: function( elem ) { + return sibling( elem, "previousSibling" ); + }, + nextAll: function( elem ) { + return dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, _i, until ) { + return dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, _i, until ) { + return dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return siblings( ( elem.parentNode || {} ).firstChild, elem ); + }, + children: function( elem ) { + return siblings( elem.firstChild ); + }, + contents: function( elem ) { + if ( elem.contentDocument != null && + + // Support: IE 11+ + // elements with no `data` attribute has an object + // `contentDocument` with a `null` prototype. + getProto( elem.contentDocument ) ) { + + return elem.contentDocument; + } + + // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only + // Treat the template element as a regular one in browsers that + // don't support it. + if ( nodeName( elem, "template" ) ) { + elem = elem.content || elem; + } + + return jQuery.merge( [], elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var matched = jQuery.map( this, fn, until ); + + if ( name.slice( -5 ) !== "Until" ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + matched = jQuery.filter( selector, matched ); + } + + if ( this.length > 1 ) { + + // Remove duplicates + if ( !guaranteedUnique[ name ] ) { + jQuery.uniqueSort( matched ); + } + + // Reverse order for parents* and prev-derivatives + if ( rparentsprev.test( name ) ) { + matched.reverse(); + } + } + + return this.pushStack( matched ); + }; +} ); +var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g ); + + + +// Convert String-formatted options into Object-formatted ones +function createOptions( options ) { + var object = {}; + jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) { + object[ flag ] = true; + } ); + return object; +} + +/* + * Create a callback list using the following parameters: + * + * options: an optional list of space-separated options that will change how + * the callback list behaves or a more traditional option object + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible options: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( options ) { + + // Convert options from String-formatted to Object-formatted if needed + // (we check in cache first) + options = typeof options === "string" ? + createOptions( options ) : + jQuery.extend( {}, options ); + + var // Flag to know if list is currently firing + firing, + + // Last fire value for non-forgettable lists + memory, + + // Flag to know if list was already fired + fired, + + // Flag to prevent firing + locked, + + // Actual callback list + list = [], + + // Queue of execution data for repeatable lists + queue = [], + + // Index of currently firing callback (modified by add/remove as needed) + firingIndex = -1, + + // Fire callbacks + fire = function() { + + // Enforce single-firing + locked = locked || options.once; + + // Execute callbacks for all pending executions, + // respecting firingIndex overrides and runtime changes + fired = firing = true; + for ( ; queue.length; firingIndex = -1 ) { + memory = queue.shift(); + while ( ++firingIndex < list.length ) { + + // Run callback and check for early termination + if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && + options.stopOnFalse ) { + + // Jump to end and forget the data so .add doesn't re-fire + firingIndex = list.length; + memory = false; + } + } + } + + // Forget the data if we're done with it + if ( !options.memory ) { + memory = false; + } + + firing = false; + + // Clean up if we're done firing for good + if ( locked ) { + + // Keep an empty list if we have data for future add calls + if ( memory ) { + list = []; + + // Otherwise, this object is spent + } else { + list = ""; + } + } + }, + + // Actual Callbacks object + self = { + + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + + // If we have memory from a past run, we should fire after adding + if ( memory && !firing ) { + firingIndex = list.length - 1; + queue.push( memory ); + } + + ( function add( args ) { + jQuery.each( args, function( _, arg ) { + if ( isFunction( arg ) ) { + if ( !options.unique || !self.has( arg ) ) { + list.push( arg ); + } + } else if ( arg && arg.length && toType( arg ) !== "string" ) { + + // Inspect recursively + add( arg ); + } + } ); + } )( arguments ); + + if ( memory && !firing ) { + fire(); + } + } + return this; + }, + + // Remove a callback from the list + remove: function() { + jQuery.each( arguments, function( _, arg ) { + var index; + while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { + list.splice( index, 1 ); + + // Handle firing indexes + if ( index <= firingIndex ) { + firingIndex--; + } + } + } ); + return this; + }, + + // Check if a given callback is in the list. + // If no argument is given, return whether or not list has callbacks attached. + has: function( fn ) { + return fn ? + jQuery.inArray( fn, list ) > -1 : + list.length > 0; + }, + + // Remove all callbacks from the list + empty: function() { + if ( list ) { + list = []; + } + return this; + }, + + // Disable .fire and .add + // Abort any current/pending executions + // Clear all callbacks and values + disable: function() { + locked = queue = []; + list = memory = ""; + return this; + }, + disabled: function() { + return !list; + }, + + // Disable .fire + // Also disable .add unless we have memory (since it would have no effect) + // Abort any pending executions + lock: function() { + locked = queue = []; + if ( !memory && !firing ) { + list = memory = ""; + } + return this; + }, + locked: function() { + return !!locked; + }, + + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( !locked ) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + queue.push( args ); + if ( !firing ) { + fire(); + } + } + return this; + }, + + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + + // To know if the callbacks have already been called at least once + fired: function() { + return !!fired; + } + }; + + return self; +}; + + +function Identity( v ) { + return v; +} +function Thrower( ex ) { + throw ex; +} + +function adoptValue( value, resolve, reject, noValue ) { + var method; + + try { + + // Check for promise aspect first to privilege synchronous behavior + if ( value && isFunction( ( method = value.promise ) ) ) { + method.call( value ).done( resolve ).fail( reject ); + + // Other thenables + } else if ( value && isFunction( ( method = value.then ) ) ) { + method.call( value, resolve, reject ); + + // Other non-thenables + } else { + + // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: + // * false: [ value ].slice( 0 ) => resolve( value ) + // * true: [ value ].slice( 1 ) => resolve() + resolve.apply( undefined, [ value ].slice( noValue ) ); + } + + // For Promises/A+, convert exceptions into rejections + // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in + // Deferred#then to conditionally suppress rejection. + } catch ( value ) { + + // Support: Android 4.0 only + // Strict mode functions invoked without .call/.apply get global-object context + reject.apply( undefined, [ value ] ); + } +} + +jQuery.extend( { + + Deferred: function( func ) { + var tuples = [ + + // action, add listener, callbacks, + // ... .then handlers, argument index, [final state] + [ "notify", "progress", jQuery.Callbacks( "memory" ), + jQuery.Callbacks( "memory" ), 2 ], + [ "resolve", "done", jQuery.Callbacks( "once memory" ), + jQuery.Callbacks( "once memory" ), 0, "resolved" ], + [ "reject", "fail", jQuery.Callbacks( "once memory" ), + jQuery.Callbacks( "once memory" ), 1, "rejected" ] + ], + state = "pending", + promise = { + state: function() { + return state; + }, + always: function() { + deferred.done( arguments ).fail( arguments ); + return this; + }, + "catch": function( fn ) { + return promise.then( null, fn ); + }, + + // Keep pipe for back-compat + pipe: function( /* fnDone, fnFail, fnProgress */ ) { + var fns = arguments; + + return jQuery.Deferred( function( newDefer ) { + jQuery.each( tuples, function( _i, tuple ) { + + // Map tuples (progress, done, fail) to arguments (done, fail, progress) + var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; + + // deferred.progress(function() { bind to newDefer or newDefer.notify }) + // deferred.done(function() { bind to newDefer or newDefer.resolve }) + // deferred.fail(function() { bind to newDefer or newDefer.reject }) + deferred[ tuple[ 1 ] ]( function() { + var returned = fn && fn.apply( this, arguments ); + if ( returned && isFunction( returned.promise ) ) { + returned.promise() + .progress( newDefer.notify ) + .done( newDefer.resolve ) + .fail( newDefer.reject ); + } else { + newDefer[ tuple[ 0 ] + "With" ]( + this, + fn ? [ returned ] : arguments + ); + } + } ); + } ); + fns = null; + } ).promise(); + }, + then: function( onFulfilled, onRejected, onProgress ) { + var maxDepth = 0; + function resolve( depth, deferred, handler, special ) { + return function() { + var that = this, + args = arguments, + mightThrow = function() { + var returned, then; + + // Support: Promises/A+ section 2.3.3.3.3 + // https://promisesaplus.com/#point-59 + // Ignore double-resolution attempts + if ( depth < maxDepth ) { + return; + } + + returned = handler.apply( that, args ); + + // Support: Promises/A+ section 2.3.1 + // https://promisesaplus.com/#point-48 + if ( returned === deferred.promise() ) { + throw new TypeError( "Thenable self-resolution" ); + } + + // Support: Promises/A+ sections 2.3.3.1, 3.5 + // https://promisesaplus.com/#point-54 + // https://promisesaplus.com/#point-75 + // Retrieve `then` only once + then = returned && + + // Support: Promises/A+ section 2.3.4 + // https://promisesaplus.com/#point-64 + // Only check objects and functions for thenability + ( typeof returned === "object" || + typeof returned === "function" ) && + returned.then; + + // Handle a returned thenable + if ( isFunction( then ) ) { + + // Special processors (notify) just wait for resolution + if ( special ) { + then.call( + returned, + resolve( maxDepth, deferred, Identity, special ), + resolve( maxDepth, deferred, Thrower, special ) + ); + + // Normal processors (resolve) also hook into progress + } else { + + // ...and disregard older resolution values + maxDepth++; + + then.call( + returned, + resolve( maxDepth, deferred, Identity, special ), + resolve( maxDepth, deferred, Thrower, special ), + resolve( maxDepth, deferred, Identity, + deferred.notifyWith ) + ); + } + + // Handle all other returned values + } else { + + // Only substitute handlers pass on context + // and multiple values (non-spec behavior) + if ( handler !== Identity ) { + that = undefined; + args = [ returned ]; + } + + // Process the value(s) + // Default process is resolve + ( special || deferred.resolveWith )( that, args ); + } + }, + + // Only normal processors (resolve) catch and reject exceptions + process = special ? + mightThrow : + function() { + try { + mightThrow(); + } catch ( e ) { + + if ( jQuery.Deferred.exceptionHook ) { + jQuery.Deferred.exceptionHook( e, + process.error ); + } + + // Support: Promises/A+ section 2.3.3.3.4.1 + // https://promisesaplus.com/#point-61 + // Ignore post-resolution exceptions + if ( depth + 1 >= maxDepth ) { + + // Only substitute handlers pass on context + // and multiple values (non-spec behavior) + if ( handler !== Thrower ) { + that = undefined; + args = [ e ]; + } + + deferred.rejectWith( that, args ); + } + } + }; + + // Support: Promises/A+ section 2.3.3.3.1 + // https://promisesaplus.com/#point-57 + // Re-resolve promises immediately to dodge false rejection from + // subsequent errors + if ( depth ) { + process(); + } else { + + // Call an optional hook to record the error, in case of exception + // since it's otherwise lost when execution goes async + if ( jQuery.Deferred.getErrorHook ) { + process.error = jQuery.Deferred.getErrorHook(); + + // The deprecated alias of the above. While the name suggests + // returning the stack, not an error instance, jQuery just passes + // it directly to `console.warn` so both will work; an instance + // just better cooperates with source maps. + } else if ( jQuery.Deferred.getStackHook ) { + process.error = jQuery.Deferred.getStackHook(); + } + window.setTimeout( process ); + } + }; + } + + return jQuery.Deferred( function( newDefer ) { + + // progress_handlers.add( ... ) + tuples[ 0 ][ 3 ].add( + resolve( + 0, + newDefer, + isFunction( onProgress ) ? + onProgress : + Identity, + newDefer.notifyWith + ) + ); + + // fulfilled_handlers.add( ... ) + tuples[ 1 ][ 3 ].add( + resolve( + 0, + newDefer, + isFunction( onFulfilled ) ? + onFulfilled : + Identity + ) + ); + + // rejected_handlers.add( ... ) + tuples[ 2 ][ 3 ].add( + resolve( + 0, + newDefer, + isFunction( onRejected ) ? + onRejected : + Thrower + ) + ); + } ).promise(); + }, + + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + return obj != null ? jQuery.extend( obj, promise ) : promise; + } + }, + deferred = {}; + + // Add list-specific methods + jQuery.each( tuples, function( i, tuple ) { + var list = tuple[ 2 ], + stateString = tuple[ 5 ]; + + // promise.progress = list.add + // promise.done = list.add + // promise.fail = list.add + promise[ tuple[ 1 ] ] = list.add; + + // Handle state + if ( stateString ) { + list.add( + function() { + + // state = "resolved" (i.e., fulfilled) + // state = "rejected" + state = stateString; + }, + + // rejected_callbacks.disable + // fulfilled_callbacks.disable + tuples[ 3 - i ][ 2 ].disable, + + // rejected_handlers.disable + // fulfilled_handlers.disable + tuples[ 3 - i ][ 3 ].disable, + + // progress_callbacks.lock + tuples[ 0 ][ 2 ].lock, + + // progress_handlers.lock + tuples[ 0 ][ 3 ].lock + ); + } + + // progress_handlers.fire + // fulfilled_handlers.fire + // rejected_handlers.fire + list.add( tuple[ 3 ].fire ); + + // deferred.notify = function() { deferred.notifyWith(...) } + // deferred.resolve = function() { deferred.resolveWith(...) } + // deferred.reject = function() { deferred.rejectWith(...) } + deferred[ tuple[ 0 ] ] = function() { + deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); + return this; + }; + + // deferred.notifyWith = list.fireWith + // deferred.resolveWith = list.fireWith + // deferred.rejectWith = list.fireWith + deferred[ tuple[ 0 ] + "With" ] = list.fireWith; + } ); + + // Make the deferred a promise + promise.promise( deferred ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( singleValue ) { + var + + // count of uncompleted subordinates + remaining = arguments.length, + + // count of unprocessed arguments + i = remaining, + + // subordinate fulfillment data + resolveContexts = Array( i ), + resolveValues = slice.call( arguments ), + + // the primary Deferred + primary = jQuery.Deferred(), + + // subordinate callback factory + updateFunc = function( i ) { + return function( value ) { + resolveContexts[ i ] = this; + resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; + if ( !( --remaining ) ) { + primary.resolveWith( resolveContexts, resolveValues ); + } + }; + }; + + // Single- and empty arguments are adopted like Promise.resolve + if ( remaining <= 1 ) { + adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject, + !remaining ); + + // Use .then() to unwrap secondary thenables (cf. gh-3000) + if ( primary.state() === "pending" || + isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { + + return primary.then(); + } + } + + // Multiple arguments are aggregated like Promise.all array elements + while ( i-- ) { + adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject ); + } + + return primary.promise(); + } +} ); + + +// These usually indicate a programmer mistake during development, +// warn about them ASAP rather than swallowing them by default. +var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; + +// If `jQuery.Deferred.getErrorHook` is defined, `asyncError` is an error +// captured before the async barrier to get the original error cause +// which may otherwise be hidden. +jQuery.Deferred.exceptionHook = function( error, asyncError ) { + + // Support: IE 8 - 9 only + // Console exists when dev tools are open, which can happen at any time + if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { + window.console.warn( "jQuery.Deferred exception: " + error.message, + error.stack, asyncError ); + } +}; + + + + +jQuery.readyException = function( error ) { + window.setTimeout( function() { + throw error; + } ); +}; + + + + +// The deferred used on DOM ready +var readyList = jQuery.Deferred(); + +jQuery.fn.ready = function( fn ) { + + readyList + .then( fn ) + + // Wrap jQuery.readyException in a function so that the lookup + // happens at the time of error handling instead of callback + // registration. + .catch( function( error ) { + jQuery.readyException( error ); + } ); + + return this; +}; + +jQuery.extend( { + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See trac-6781 + readyWait: 1, + + // Handle when the DOM is ready + ready: function( wait ) { + + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + } +} ); + +jQuery.ready.then = readyList.then; + +// The ready event handler and self cleanup method +function completed() { + document.removeEventListener( "DOMContentLoaded", completed ); + window.removeEventListener( "load", completed ); + jQuery.ready(); +} + +// Catch cases where $(document).ready() is called +// after the browser event has already occurred. +// Support: IE <=9 - 10 only +// Older IE sometimes signals "interactive" too soon +if ( document.readyState === "complete" || + ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { + + // Handle it asynchronously to allow scripts the opportunity to delay ready + window.setTimeout( jQuery.ready ); + +} else { + + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed ); +} + + + + +// Multifunctional method to get and set values of a collection +// The value/s can optionally be executed if it's a function +var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { + var i = 0, + len = elems.length, + bulk = key == null; + + // Sets many values + if ( toType( key ) === "object" ) { + chainable = true; + for ( i in key ) { + access( elems, fn, i, key[ i ], true, emptyGet, raw ); + } + + // Sets one value + } else if ( value !== undefined ) { + chainable = true; + + if ( !isFunction( value ) ) { + raw = true; + } + + if ( bulk ) { + + // Bulk operations run against the entire set + if ( raw ) { + fn.call( elems, value ); + fn = null; + + // ...except when executing function values + } else { + bulk = fn; + fn = function( elem, _key, value ) { + return bulk.call( jQuery( elem ), value ); + }; + } + } + + if ( fn ) { + for ( ; i < len; i++ ) { + fn( + elems[ i ], key, raw ? + value : + value.call( elems[ i ], i, fn( elems[ i ], key ) ) + ); + } + } + } + + if ( chainable ) { + return elems; + } + + // Gets + if ( bulk ) { + return fn.call( elems ); + } + + return len ? fn( elems[ 0 ], key ) : emptyGet; +}; + + +// Matches dashed string for camelizing +var rmsPrefix = /^-ms-/, + rdashAlpha = /-([a-z])/g; + +// Used by camelCase as callback to replace() +function fcamelCase( _all, letter ) { + return letter.toUpperCase(); +} + +// Convert dashed to camelCase; used by the css and data modules +// Support: IE <=9 - 11, Edge 12 - 15 +// Microsoft forgot to hump their vendor prefix (trac-9572) +function camelCase( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); +} +var acceptData = function( owner ) { + + // Accepts only: + // - Node + // - Node.ELEMENT_NODE + // - Node.DOCUMENT_NODE + // - Object + // - Any + return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); +}; + + + + +function Data() { + this.expando = jQuery.expando + Data.uid++; +} + +Data.uid = 1; + +Data.prototype = { + + cache: function( owner ) { + + // Check if the owner object already has a cache + var value = owner[ this.expando ]; + + // If not, create one + if ( !value ) { + value = {}; + + // We can accept data for non-element nodes in modern browsers, + // but we should not, see trac-8335. + // Always return an empty object. + if ( acceptData( owner ) ) { + + // If it is a node unlikely to be stringify-ed or looped over + // use plain assignment + if ( owner.nodeType ) { + owner[ this.expando ] = value; + + // Otherwise secure it in a non-enumerable property + // configurable must be true to allow the property to be + // deleted when data is removed + } else { + Object.defineProperty( owner, this.expando, { + value: value, + configurable: true + } ); + } + } + } + + return value; + }, + set: function( owner, data, value ) { + var prop, + cache = this.cache( owner ); + + // Handle: [ owner, key, value ] args + // Always use camelCase key (gh-2257) + if ( typeof data === "string" ) { + cache[ camelCase( data ) ] = value; + + // Handle: [ owner, { properties } ] args + } else { + + // Copy the properties one-by-one to the cache object + for ( prop in data ) { + cache[ camelCase( prop ) ] = data[ prop ]; + } + } + return cache; + }, + get: function( owner, key ) { + return key === undefined ? + this.cache( owner ) : + + // Always use camelCase key (gh-2257) + owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; + }, + access: function( owner, key, value ) { + + // In cases where either: + // + // 1. No key was specified + // 2. A string key was specified, but no value provided + // + // Take the "read" path and allow the get method to determine + // which value to return, respectively either: + // + // 1. The entire cache object + // 2. The data stored at the key + // + if ( key === undefined || + ( ( key && typeof key === "string" ) && value === undefined ) ) { + + return this.get( owner, key ); + } + + // When the key is not a string, or both a key and value + // are specified, set or extend (existing objects) with either: + // + // 1. An object of properties + // 2. A key and value + // + this.set( owner, key, value ); + + // Since the "set" path can have two possible entry points + // return the expected data based on which path was taken[*] + return value !== undefined ? value : key; + }, + remove: function( owner, key ) { + var i, + cache = owner[ this.expando ]; + + if ( cache === undefined ) { + return; + } + + if ( key !== undefined ) { + + // Support array or space separated string of keys + if ( Array.isArray( key ) ) { + + // If key is an array of keys... + // We always set camelCase keys, so remove that. + key = key.map( camelCase ); + } else { + key = camelCase( key ); + + // If a key with the spaces exists, use it. + // Otherwise, create an array by matching non-whitespace + key = key in cache ? + [ key ] : + ( key.match( rnothtmlwhite ) || [] ); + } + + i = key.length; + + while ( i-- ) { + delete cache[ key[ i ] ]; + } + } + + // Remove the expando if there's no more data + if ( key === undefined || jQuery.isEmptyObject( cache ) ) { + + // Support: Chrome <=35 - 45 + // Webkit & Blink performance suffers when deleting properties + // from DOM nodes, so set to undefined instead + // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) + if ( owner.nodeType ) { + owner[ this.expando ] = undefined; + } else { + delete owner[ this.expando ]; + } + } + }, + hasData: function( owner ) { + var cache = owner[ this.expando ]; + return cache !== undefined && !jQuery.isEmptyObject( cache ); + } +}; +var dataPriv = new Data(); + +var dataUser = new Data(); + + + +// Implementation Summary +// +// 1. Enforce API surface and semantic compatibility with 1.9.x branch +// 2. Improve the module's maintainability by reducing the storage +// paths to a single mechanism. +// 3. Use the same single mechanism to support "private" and "user" data. +// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) +// 5. Avoid exposing implementation details on user objects (eg. expando properties) +// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 + +var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, + rmultiDash = /[A-Z]/g; + +function getData( data ) { + if ( data === "true" ) { + return true; + } + + if ( data === "false" ) { + return false; + } + + if ( data === "null" ) { + return null; + } + + // Only convert to a number if it doesn't change the string + if ( data === +data + "" ) { + return +data; + } + + if ( rbrace.test( data ) ) { + return JSON.parse( data ); + } + + return data; +} + +function dataAttr( elem, key, data ) { + var name; + + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = getData( data ); + } catch ( e ) {} + + // Make sure we set the data so it isn't changed later + dataUser.set( elem, key, data ); + } else { + data = undefined; + } + } + return data; +} + +jQuery.extend( { + hasData: function( elem ) { + return dataUser.hasData( elem ) || dataPriv.hasData( elem ); + }, + + data: function( elem, name, data ) { + return dataUser.access( elem, name, data ); + }, + + removeData: function( elem, name ) { + dataUser.remove( elem, name ); + }, + + // TODO: Now that all calls to _data and _removeData have been replaced + // with direct calls to dataPriv methods, these can be deprecated. + _data: function( elem, name, data ) { + return dataPriv.access( elem, name, data ); + }, + + _removeData: function( elem, name ) { + dataPriv.remove( elem, name ); + } +} ); + +jQuery.fn.extend( { + data: function( key, value ) { + var i, name, data, + elem = this[ 0 ], + attrs = elem && elem.attributes; + + // Gets all values + if ( key === undefined ) { + if ( this.length ) { + data = dataUser.get( elem ); + + if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { + i = attrs.length; + while ( i-- ) { + + // Support: IE 11 only + // The attrs elements can be null (trac-14894) + if ( attrs[ i ] ) { + name = attrs[ i ].name; + if ( name.indexOf( "data-" ) === 0 ) { + name = camelCase( name.slice( 5 ) ); + dataAttr( elem, name, data[ name ] ); + } + } + } + dataPriv.set( elem, "hasDataAttrs", true ); + } + } + + return data; + } + + // Sets multiple values + if ( typeof key === "object" ) { + return this.each( function() { + dataUser.set( this, key ); + } ); + } + + return access( this, function( value ) { + var data; + + // The calling jQuery object (element matches) is not empty + // (and therefore has an element appears at this[ 0 ]) and the + // `value` parameter was not undefined. An empty jQuery object + // will result in `undefined` for elem = this[ 0 ] which will + // throw an exception if an attempt to read a data cache is made. + if ( elem && value === undefined ) { + + // Attempt to get data from the cache + // The key will always be camelCased in Data + data = dataUser.get( elem, key ); + if ( data !== undefined ) { + return data; + } + + // Attempt to "discover" the data in + // HTML5 custom data-* attrs + data = dataAttr( elem, key ); + if ( data !== undefined ) { + return data; + } + + // We tried really hard, but the data doesn't exist. + return; + } + + // Set the data... + this.each( function() { + + // We always store the camelCased key + dataUser.set( this, key, value ); + } ); + }, null, value, arguments.length > 1, null, true ); + }, + + removeData: function( key ) { + return this.each( function() { + dataUser.remove( this, key ); + } ); + } +} ); + + +jQuery.extend( { + queue: function( elem, type, data ) { + var queue; + + if ( elem ) { + type = ( type || "fx" ) + "queue"; + queue = dataPriv.get( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !queue || Array.isArray( data ) ) { + queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); + } else { + queue.push( data ); + } + } + return queue || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + startLength = queue.length, + fn = queue.shift(), + hooks = jQuery._queueHooks( elem, type ), + next = function() { + jQuery.dequeue( elem, type ); + }; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + startLength--; + } + + if ( fn ) { + + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + // Clear up the last queue stop function + delete hooks.stop; + fn.call( elem, next, hooks ); + } + + if ( !startLength && hooks ) { + hooks.empty.fire(); + } + }, + + // Not public - generate a queueHooks object, or return the current one + _queueHooks: function( elem, type ) { + var key = type + "queueHooks"; + return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { + empty: jQuery.Callbacks( "once memory" ).add( function() { + dataPriv.remove( elem, [ type + "queue", key ] ); + } ) + } ); + } +} ); + +jQuery.fn.extend( { + queue: function( type, data ) { + var setter = 2; + + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + setter--; + } + + if ( arguments.length < setter ) { + return jQuery.queue( this[ 0 ], type ); + } + + return data === undefined ? + this : + this.each( function() { + var queue = jQuery.queue( this, type, data ); + + // Ensure a hooks for this queue + jQuery._queueHooks( this, type ); + + if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + } ); + }, + dequeue: function( type ) { + return this.each( function() { + jQuery.dequeue( this, type ); + } ); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, obj ) { + var tmp, + count = 1, + defer = jQuery.Deferred(), + elements = this, + i = this.length, + resolve = function() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + }; + + if ( typeof type !== "string" ) { + obj = type; + type = undefined; + } + type = type || "fx"; + + while ( i-- ) { + tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); + if ( tmp && tmp.empty ) { + count++; + tmp.empty.add( resolve ); + } + } + resolve(); + return defer.promise( obj ); + } +} ); +var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; + +var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); + + +var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; + +var documentElement = document.documentElement; + + + + var isAttached = function( elem ) { + return jQuery.contains( elem.ownerDocument, elem ); + }, + composed = { composed: true }; + + // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only + // Check attachment across shadow DOM boundaries when possible (gh-3504) + // Support: iOS 10.0-10.2 only + // Early iOS 10 versions support `attachShadow` but not `getRootNode`, + // leading to errors. We need to check for `getRootNode`. + if ( documentElement.getRootNode ) { + isAttached = function( elem ) { + return jQuery.contains( elem.ownerDocument, elem ) || + elem.getRootNode( composed ) === elem.ownerDocument; + }; + } +var isHiddenWithinTree = function( elem, el ) { + + // isHiddenWithinTree might be called from jQuery#filter function; + // in that case, element will be second argument + elem = el || elem; + + // Inline style trumps all + return elem.style.display === "none" || + elem.style.display === "" && + + // Otherwise, check computed style + // Support: Firefox <=43 - 45 + // Disconnected elements can have computed display: none, so first confirm that elem is + // in the document. + isAttached( elem ) && + + jQuery.css( elem, "display" ) === "none"; + }; + + + +function adjustCSS( elem, prop, valueParts, tween ) { + var adjusted, scale, + maxIterations = 20, + currentValue = tween ? + function() { + return tween.cur(); + } : + function() { + return jQuery.css( elem, prop, "" ); + }, + initial = currentValue(), + unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), + + // Starting value computation is required for potential unit mismatches + initialInUnit = elem.nodeType && + ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && + rcssNum.exec( jQuery.css( elem, prop ) ); + + if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { + + // Support: Firefox <=54 + // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) + initial = initial / 2; + + // Trust units reported by jQuery.css + unit = unit || initialInUnit[ 3 ]; + + // Iteratively approximate from a nonzero starting point + initialInUnit = +initial || 1; + + while ( maxIterations-- ) { + + // Evaluate and update our best guess (doubling guesses that zero out). + // Finish if the scale equals or crosses 1 (making the old*new product non-positive). + jQuery.style( elem, prop, initialInUnit + unit ); + if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { + maxIterations = 0; + } + initialInUnit = initialInUnit / scale; + + } + + initialInUnit = initialInUnit * 2; + jQuery.style( elem, prop, initialInUnit + unit ); + + // Make sure we update the tween properties later on + valueParts = valueParts || []; + } + + if ( valueParts ) { + initialInUnit = +initialInUnit || +initial || 0; + + // Apply relative offset (+=/-=) if specified + adjusted = valueParts[ 1 ] ? + initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : + +valueParts[ 2 ]; + if ( tween ) { + tween.unit = unit; + tween.start = initialInUnit; + tween.end = adjusted; + } + } + return adjusted; +} + + +var defaultDisplayMap = {}; + +function getDefaultDisplay( elem ) { + var temp, + doc = elem.ownerDocument, + nodeName = elem.nodeName, + display = defaultDisplayMap[ nodeName ]; + + if ( display ) { + return display; + } + + temp = doc.body.appendChild( doc.createElement( nodeName ) ); + display = jQuery.css( temp, "display" ); + + temp.parentNode.removeChild( temp ); + + if ( display === "none" ) { + display = "block"; + } + defaultDisplayMap[ nodeName ] = display; + + return display; +} + +function showHide( elements, show ) { + var display, elem, + values = [], + index = 0, + length = elements.length; + + // Determine new display value for elements that need to change + for ( ; index < length; index++ ) { + elem = elements[ index ]; + if ( !elem.style ) { + continue; + } + + display = elem.style.display; + if ( show ) { + + // Since we force visibility upon cascade-hidden elements, an immediate (and slow) + // check is required in this first loop unless we have a nonempty display value (either + // inline or about-to-be-restored) + if ( display === "none" ) { + values[ index ] = dataPriv.get( elem, "display" ) || null; + if ( !values[ index ] ) { + elem.style.display = ""; + } + } + if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { + values[ index ] = getDefaultDisplay( elem ); + } + } else { + if ( display !== "none" ) { + values[ index ] = "none"; + + // Remember what we're overwriting + dataPriv.set( elem, "display", display ); + } + } + } + + // Set the display of the elements in a second loop to avoid constant reflow + for ( index = 0; index < length; index++ ) { + if ( values[ index ] != null ) { + elements[ index ].style.display = values[ index ]; + } + } + + return elements; +} + +jQuery.fn.extend( { + show: function() { + return showHide( this, true ); + }, + hide: function() { + return showHide( this ); + }, + toggle: function( state ) { + if ( typeof state === "boolean" ) { + return state ? this.show() : this.hide(); + } + + return this.each( function() { + if ( isHiddenWithinTree( this ) ) { + jQuery( this ).show(); + } else { + jQuery( this ).hide(); + } + } ); + } +} ); +var rcheckableType = ( /^(?:checkbox|radio)$/i ); + +var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i ); + +var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); + + + +( function() { + var fragment = document.createDocumentFragment(), + div = fragment.appendChild( document.createElement( "div" ) ), + input = document.createElement( "input" ); + + // Support: Android 4.0 - 4.3 only + // Check state lost if the name is set (trac-11217) + // Support: Windows Web Apps (WWA) + // `name` and `type` must use .setAttribute for WWA (trac-14901) + input.setAttribute( "type", "radio" ); + input.setAttribute( "checked", "checked" ); + input.setAttribute( "name", "t" ); + + div.appendChild( input ); + + // Support: Android <=4.1 only + // Older WebKit doesn't clone checked state correctly in fragments + support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Support: IE <=11 only + // Make sure textarea (and checkbox) defaultValue is properly cloned + div.innerHTML = ""; + support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; + + // Support: IE <=9 only + // IE <=9 replaces "; + support.option = !!div.lastChild; +} )(); + + +// We have to close these tags to support XHTML (trac-13200) +var wrapMap = { + + // XHTML parsers do not magically insert elements in the + // same way that tag soup parsers do. So we cannot shorten + // this by omitting or other required elements. + thead: [ 1, "", "
" ], + col: [ 2, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + + _default: [ 0, "", "" ] +}; + +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// Support: IE <=9 only +if ( !support.option ) { + wrapMap.optgroup = wrapMap.option = [ 1, "" ]; +} + + +function getAll( context, tag ) { + + // Support: IE <=9 - 11 only + // Use typeof to avoid zero-argument method invocation on host objects (trac-15151) + var ret; + + if ( typeof context.getElementsByTagName !== "undefined" ) { + ret = context.getElementsByTagName( tag || "*" ); + + } else if ( typeof context.querySelectorAll !== "undefined" ) { + ret = context.querySelectorAll( tag || "*" ); + + } else { + ret = []; + } + + if ( tag === undefined || tag && nodeName( context, tag ) ) { + return jQuery.merge( [ context ], ret ); + } + + return ret; +} + + +// Mark scripts as having already been evaluated +function setGlobalEval( elems, refElements ) { + var i = 0, + l = elems.length; + + for ( ; i < l; i++ ) { + dataPriv.set( + elems[ i ], + "globalEval", + !refElements || dataPriv.get( refElements[ i ], "globalEval" ) + ); + } +} + + +var rhtml = /<|&#?\w+;/; + +function buildFragment( elems, context, scripts, selection, ignored ) { + var elem, tmp, tag, wrap, attached, j, + fragment = context.createDocumentFragment(), + nodes = [], + i = 0, + l = elems.length; + + for ( ; i < l; i++ ) { + elem = elems[ i ]; + + if ( elem || elem === 0 ) { + + // Add nodes directly + if ( toType( elem ) === "object" ) { + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); + + // Convert non-html into a text node + } else if ( !rhtml.test( elem ) ) { + nodes.push( context.createTextNode( elem ) ); + + // Convert html into DOM nodes + } else { + tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); + + // Deserialize a standard representation + tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); + wrap = wrapMap[ tag ] || wrapMap._default; + tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; + + // Descend through wrappers to the right content + j = wrap[ 0 ]; + while ( j-- ) { + tmp = tmp.lastChild; + } + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + jQuery.merge( nodes, tmp.childNodes ); + + // Remember the top-level container + tmp = fragment.firstChild; + + // Ensure the created nodes are orphaned (trac-12392) + tmp.textContent = ""; + } + } + } + + // Remove wrapper from fragment + fragment.textContent = ""; + + i = 0; + while ( ( elem = nodes[ i++ ] ) ) { + + // Skip elements already in the context collection (trac-4087) + if ( selection && jQuery.inArray( elem, selection ) > -1 ) { + if ( ignored ) { + ignored.push( elem ); + } + continue; + } + + attached = isAttached( elem ); + + // Append to fragment + tmp = getAll( fragment.appendChild( elem ), "script" ); + + // Preserve script evaluation history + if ( attached ) { + setGlobalEval( tmp ); + } + + // Capture executables + if ( scripts ) { + j = 0; + while ( ( elem = tmp[ j++ ] ) ) { + if ( rscriptType.test( elem.type || "" ) ) { + scripts.push( elem ); + } + } + } + } + + return fragment; +} + + +var rtypenamespace = /^([^.]*)(?:\.(.+)|)/; + +function returnTrue() { + return true; +} + +function returnFalse() { + return false; +} + +function on( elem, types, selector, data, fn, one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + + // ( types-Object, data ) + data = data || selector; + selector = undefined; + } + for ( type in types ) { + on( elem, type, selector, data, types[ type ], one ); + } + return elem; + } + + if ( data == null && fn == null ) { + + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return elem; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return elem.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + } ); +} + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + global: {}, + + add: function( elem, types, handler, data, selector ) { + + var handleObjIn, eventHandle, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = dataPriv.get( elem ); + + // Only attach events to objects that accept data + if ( !acceptData( elem ) ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } + + // Ensure that invalid selectors throw exceptions at attach time + // Evaluate against documentElement in case elem is a non-element node (e.g., document) + if ( selector ) { + jQuery.find.matchesSelector( documentElement, selector ); + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + if ( !( events = elemData.events ) ) { + events = elemData.events = Object.create( null ); + } + if ( !( eventHandle = elemData.handle ) ) { + eventHandle = elemData.handle = function( e ) { + + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? + jQuery.event.dispatch.apply( elem, arguments ) : undefined; + }; + } + + // Handle multiple events separated by a space + types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[ t ] ) || []; + type = origType = tmp[ 1 ]; + namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); + + // There *must* be a type, no attaching namespace-only handlers + if ( !type ) { + continue; + } + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend( { + type: type, + origType: origType, + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + needsContext: selector && jQuery.expr.match.needsContext.test( selector ), + namespace: namespaces.join( "." ) + }, handleObjIn ); + + // Init the event handler queue if we're the first + if ( !( handlers = events[ type ] ) ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener if the special events handler returns false + if ( !special.setup || + special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + }, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var j, origCount, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); + + if ( !elemData || !( events = elemData.events ) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[ t ] ) || []; + type = origType = tmp[ 1 ]; + namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector ? special.delegateType : special.bindType ) || type; + handlers = events[ type ] || []; + tmp = tmp[ 2 ] && + new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); + + // Remove matching events + origCount = j = handlers.length; + while ( j-- ) { + handleObj = handlers[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !tmp || tmp.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || + selector === "**" && handleObj.selector ) ) { + handlers.splice( j, 1 ); + + if ( handleObj.selector ) { + handlers.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( origCount && !handlers.length ) { + if ( !special.teardown || + special.teardown.call( elem, namespaces, elemData.handle ) === false ) { + + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove data and the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + dataPriv.remove( elem, "handle events" ); + } + }, + + dispatch: function( nativeEvent ) { + + var i, j, ret, matched, handleObj, handlerQueue, + args = new Array( arguments.length ), + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( nativeEvent ), + + handlers = ( + dataPriv.get( this, "events" ) || Object.create( null ) + )[ event.type ] || [], + special = jQuery.event.special[ event.type ] || {}; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[ 0 ] = event; + + for ( i = 1; i < arguments.length; i++ ) { + args[ i ] = arguments[ i ]; + } + + event.delegateTarget = this; + + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; + } + + // Determine handlers + handlerQueue = jQuery.event.handlers.call( this, event, handlers ); + + // Run delegates first; they may want to stop propagation beneath us + i = 0; + while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { + event.currentTarget = matched.elem; + + j = 0; + while ( ( handleObj = matched.handlers[ j++ ] ) && + !event.isImmediatePropagationStopped() ) { + + // If the event is namespaced, then each handler is only invoked if it is + // specially universal or its namespaces are a superset of the event's. + if ( !event.rnamespace || handleObj.namespace === false || + event.rnamespace.test( handleObj.namespace ) ) { + + event.handleObj = handleObj; + event.data = handleObj.data; + + ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || + handleObj.handler ).apply( matched.elem, args ); + + if ( ret !== undefined ) { + if ( ( event.result = ret ) === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + // Call the postDispatch hook for the mapped type + if ( special.postDispatch ) { + special.postDispatch.call( this, event ); + } + + return event.result; + }, + + handlers: function( event, handlers ) { + var i, handleObj, sel, matchedHandlers, matchedSelectors, + handlerQueue = [], + delegateCount = handlers.delegateCount, + cur = event.target; + + // Find delegate handlers + if ( delegateCount && + + // Support: IE <=9 + // Black-hole SVG instance trees (trac-13180) + cur.nodeType && + + // Support: Firefox <=42 + // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861) + // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click + // Support: IE 11 only + // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343) + !( event.type === "click" && event.button >= 1 ) ) { + + for ( ; cur !== this; cur = cur.parentNode || this ) { + + // Don't check non-elements (trac-13208) + // Don't process clicks on disabled elements (trac-6911, trac-8165, trac-11382, trac-11764) + if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) { + matchedHandlers = []; + matchedSelectors = {}; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + + // Don't conflict with Object.prototype properties (trac-13203) + sel = handleObj.selector + " "; + + if ( matchedSelectors[ sel ] === undefined ) { + matchedSelectors[ sel ] = handleObj.needsContext ? + jQuery( sel, this ).index( cur ) > -1 : + jQuery.find( sel, this, null, [ cur ] ).length; + } + if ( matchedSelectors[ sel ] ) { + matchedHandlers.push( handleObj ); + } + } + if ( matchedHandlers.length ) { + handlerQueue.push( { elem: cur, handlers: matchedHandlers } ); + } + } + } + } + + // Add the remaining (directly-bound) handlers + cur = this; + if ( delegateCount < handlers.length ) { + handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } ); + } + + return handlerQueue; + }, + + addProp: function( name, hook ) { + Object.defineProperty( jQuery.Event.prototype, name, { + enumerable: true, + configurable: true, + + get: isFunction( hook ) ? + function() { + if ( this.originalEvent ) { + return hook( this.originalEvent ); + } + } : + function() { + if ( this.originalEvent ) { + return this.originalEvent[ name ]; + } + }, + + set: function( value ) { + Object.defineProperty( this, name, { + enumerable: true, + configurable: true, + writable: true, + value: value + } ); + } + } ); + }, + + fix: function( originalEvent ) { + return originalEvent[ jQuery.expando ] ? + originalEvent : + new jQuery.Event( originalEvent ); + }, + + special: { + load: { + + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + click: { + + // Utilize native event to ensure correct state for checkable inputs + setup: function( data ) { + + // For mutual compressibility with _default, replace `this` access with a local var. + // `|| data` is dead code meant only to preserve the variable through minification. + var el = this || data; + + // Claim the first handler + if ( rcheckableType.test( el.type ) && + el.click && nodeName( el, "input" ) ) { + + // dataPriv.set( el, "click", ... ) + leverageNative( el, "click", true ); + } + + // Return false to allow normal processing in the caller + return false; + }, + trigger: function( data ) { + + // For mutual compressibility with _default, replace `this` access with a local var. + // `|| data` is dead code meant only to preserve the variable through minification. + var el = this || data; + + // Force setup before triggering a click + if ( rcheckableType.test( el.type ) && + el.click && nodeName( el, "input" ) ) { + + leverageNative( el, "click" ); + } + + // Return non-false to allow normal event-path propagation + return true; + }, + + // For cross-browser consistency, suppress native .click() on links + // Also prevent it if we're currently inside a leveraged native-event stack + _default: function( event ) { + var target = event.target; + return rcheckableType.test( target.type ) && + target.click && nodeName( target, "input" ) && + dataPriv.get( target, "click" ) || + nodeName( target, "a" ); + } + }, + + beforeunload: { + postDispatch: function( event ) { + + // Support: Firefox 20+ + // Firefox doesn't alert if the returnValue field is not set. + if ( event.result !== undefined && event.originalEvent ) { + event.originalEvent.returnValue = event.result; + } + } + } + } +}; + +// Ensure the presence of an event listener that handles manually-triggered +// synthetic events by interrupting progress until reinvoked in response to +// *native* events that it fires directly, ensuring that state changes have +// already occurred before other listeners are invoked. +function leverageNative( el, type, isSetup ) { + + // Missing `isSetup` indicates a trigger call, which must force setup through jQuery.event.add + if ( !isSetup ) { + if ( dataPriv.get( el, type ) === undefined ) { + jQuery.event.add( el, type, returnTrue ); + } + return; + } + + // Register the controller as a special universal handler for all event namespaces + dataPriv.set( el, type, false ); + jQuery.event.add( el, type, { + namespace: false, + handler: function( event ) { + var result, + saved = dataPriv.get( this, type ); + + if ( ( event.isTrigger & 1 ) && this[ type ] ) { + + // Interrupt processing of the outer synthetic .trigger()ed event + if ( !saved ) { + + // Store arguments for use when handling the inner native event + // There will always be at least one argument (an event object), so this array + // will not be confused with a leftover capture object. + saved = slice.call( arguments ); + dataPriv.set( this, type, saved ); + + // Trigger the native event and capture its result + this[ type ](); + result = dataPriv.get( this, type ); + dataPriv.set( this, type, false ); + + if ( saved !== result ) { + + // Cancel the outer synthetic event + event.stopImmediatePropagation(); + event.preventDefault(); + + return result; + } + + // If this is an inner synthetic event for an event with a bubbling surrogate + // (focus or blur), assume that the surrogate already propagated from triggering + // the native event and prevent that from happening again here. + // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the + // bubbling surrogate propagates *after* the non-bubbling base), but that seems + // less bad than duplication. + } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) { + event.stopPropagation(); + } + + // If this is a native event triggered above, everything is now in order + // Fire an inner synthetic event with the original arguments + } else if ( saved ) { + + // ...and capture the result + dataPriv.set( this, type, jQuery.event.trigger( + saved[ 0 ], + saved.slice( 1 ), + this + ) ); + + // Abort handling of the native event by all jQuery handlers while allowing + // native handlers on the same element to run. On target, this is achieved + // by stopping immediate propagation just on the jQuery event. However, + // the native event is re-wrapped by a jQuery one on each level of the + // propagation so the only way to stop it for jQuery is to stop it for + // everyone via native `stopPropagation()`. This is not a problem for + // focus/blur which don't bubble, but it does also stop click on checkboxes + // and radios. We accept this limitation. + event.stopPropagation(); + event.isImmediatePropagationStopped = returnTrue; + } + } + } ); +} + +jQuery.removeEvent = function( elem, type, handle ) { + + // This "if" is needed for plain objects + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle ); + } +}; + +jQuery.Event = function( src, props ) { + + // Allow instantiation without the 'new' keyword + if ( !( this instanceof jQuery.Event ) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = src.defaultPrevented || + src.defaultPrevented === undefined && + + // Support: Android <=2.3 only + src.returnValue === false ? + returnTrue : + returnFalse; + + // Create target properties + // Support: Safari <=6 - 7 only + // Target should not be a text node (trac-504, trac-13143) + this.target = ( src.target && src.target.nodeType === 3 ) ? + src.target.parentNode : + src.target; + + this.currentTarget = src.currentTarget; + this.relatedTarget = src.relatedTarget; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || Date.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + constructor: jQuery.Event, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse, + isSimulated: false, + + preventDefault: function() { + var e = this.originalEvent; + + this.isDefaultPrevented = returnTrue; + + if ( e && !this.isSimulated ) { + e.preventDefault(); + } + }, + stopPropagation: function() { + var e = this.originalEvent; + + this.isPropagationStopped = returnTrue; + + if ( e && !this.isSimulated ) { + e.stopPropagation(); + } + }, + stopImmediatePropagation: function() { + var e = this.originalEvent; + + this.isImmediatePropagationStopped = returnTrue; + + if ( e && !this.isSimulated ) { + e.stopImmediatePropagation(); + } + + this.stopPropagation(); + } +}; + +// Includes all common event props including KeyEvent and MouseEvent specific props +jQuery.each( { + altKey: true, + bubbles: true, + cancelable: true, + changedTouches: true, + ctrlKey: true, + detail: true, + eventPhase: true, + metaKey: true, + pageX: true, + pageY: true, + shiftKey: true, + view: true, + "char": true, + code: true, + charCode: true, + key: true, + keyCode: true, + button: true, + buttons: true, + clientX: true, + clientY: true, + offsetX: true, + offsetY: true, + pointerId: true, + pointerType: true, + screenX: true, + screenY: true, + targetTouches: true, + toElement: true, + touches: true, + which: true +}, jQuery.event.addProp ); + +jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) { + + function focusMappedHandler( nativeEvent ) { + if ( document.documentMode ) { + + // Support: IE 11+ + // Attach a single focusin/focusout handler on the document while someone wants + // focus/blur. This is because the former are synchronous in IE while the latter + // are async. In other browsers, all those handlers are invoked synchronously. + + // `handle` from private data would already wrap the event, but we need + // to change the `type` here. + var handle = dataPriv.get( this, "handle" ), + event = jQuery.event.fix( nativeEvent ); + event.type = nativeEvent.type === "focusin" ? "focus" : "blur"; + event.isSimulated = true; + + // First, handle focusin/focusout + handle( nativeEvent ); + + // ...then, handle focus/blur + // + // focus/blur don't bubble while focusin/focusout do; simulate the former by only + // invoking the handler at the lower level. + if ( event.target === event.currentTarget ) { + + // The setup part calls `leverageNative`, which, in turn, calls + // `jQuery.event.add`, so event handle will already have been set + // by this point. + handle( event ); + } + } else { + + // For non-IE browsers, attach a single capturing handler on the document + // while someone wants focusin/focusout. + jQuery.event.simulate( delegateType, nativeEvent.target, + jQuery.event.fix( nativeEvent ) ); + } + } + + jQuery.event.special[ type ] = { + + // Utilize native event if possible so blur/focus sequence is correct + setup: function() { + + var attaches; + + // Claim the first handler + // dataPriv.set( this, "focus", ... ) + // dataPriv.set( this, "blur", ... ) + leverageNative( this, type, true ); + + if ( document.documentMode ) { + + // Support: IE 9 - 11+ + // We use the same native handler for focusin & focus (and focusout & blur) + // so we need to coordinate setup & teardown parts between those events. + // Use `delegateType` as the key as `type` is already used by `leverageNative`. + attaches = dataPriv.get( this, delegateType ); + if ( !attaches ) { + this.addEventListener( delegateType, focusMappedHandler ); + } + dataPriv.set( this, delegateType, ( attaches || 0 ) + 1 ); + } else { + + // Return false to allow normal processing in the caller + return false; + } + }, + trigger: function() { + + // Force setup before trigger + leverageNative( this, type ); + + // Return non-false to allow normal event-path propagation + return true; + }, + + teardown: function() { + var attaches; + + if ( document.documentMode ) { + attaches = dataPriv.get( this, delegateType ) - 1; + if ( !attaches ) { + this.removeEventListener( delegateType, focusMappedHandler ); + dataPriv.remove( this, delegateType ); + } else { + dataPriv.set( this, delegateType, attaches ); + } + } else { + + // Return false to indicate standard teardown should be applied + return false; + } + }, + + // Suppress native focus or blur if we're currently inside + // a leveraged native-event stack + _default: function( event ) { + return dataPriv.get( event.target, type ); + }, + + delegateType: delegateType + }; + + // Support: Firefox <=44 + // Firefox doesn't have focus(in | out) events + // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 + // + // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 + // focus(in | out) events fire after focus & blur events, + // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order + // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 + // + // Support: IE 9 - 11+ + // To preserve relative focusin/focus & focusout/blur event order guaranteed on the 3.x branch, + // attach a single handler for both events in IE. + jQuery.event.special[ delegateType ] = { + setup: function() { + + // Handle: regular nodes (via `this.ownerDocument`), window + // (via `this.document`) & document (via `this`). + var doc = this.ownerDocument || this.document || this, + dataHolder = document.documentMode ? this : doc, + attaches = dataPriv.get( dataHolder, delegateType ); + + // Support: IE 9 - 11+ + // We use the same native handler for focusin & focus (and focusout & blur) + // so we need to coordinate setup & teardown parts between those events. + // Use `delegateType` as the key as `type` is already used by `leverageNative`. + if ( !attaches ) { + if ( document.documentMode ) { + this.addEventListener( delegateType, focusMappedHandler ); + } else { + doc.addEventListener( type, focusMappedHandler, true ); + } + } + dataPriv.set( dataHolder, delegateType, ( attaches || 0 ) + 1 ); + }, + teardown: function() { + var doc = this.ownerDocument || this.document || this, + dataHolder = document.documentMode ? this : doc, + attaches = dataPriv.get( dataHolder, delegateType ) - 1; + + if ( !attaches ) { + if ( document.documentMode ) { + this.removeEventListener( delegateType, focusMappedHandler ); + } else { + doc.removeEventListener( type, focusMappedHandler, true ); + } + dataPriv.remove( dataHolder, delegateType ); + } else { + dataPriv.set( dataHolder, delegateType, attaches ); + } + } + }; +} ); + +// Create mouseenter/leave events using mouseover/out and event-time checks +// so that event delegation works in jQuery. +// Do the same for pointerenter/pointerleave and pointerover/pointerout +// +// Support: Safari 7 only +// Safari sends mouseenter too often; see: +// https://bugs.chromium.org/p/chromium/issues/detail?id=470258 +// for the description of the bug (it existed in older Chrome versions as well). +jQuery.each( { + mouseenter: "mouseover", + mouseleave: "mouseout", + pointerenter: "pointerover", + pointerleave: "pointerout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var ret, + target = this, + related = event.relatedTarget, + handleObj = event.handleObj; + + // For mouseenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +} ); + +jQuery.fn.extend( { + + on: function( types, selector, data, fn ) { + return on( this, types, selector, data, fn ); + }, + one: function( types, selector, data, fn ) { + return on( this, types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + var handleObj, type; + if ( types && types.preventDefault && types.handleObj ) { + + // ( event ) dispatched jQuery.Event + handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace ? + handleObj.origType + "." + handleObj.namespace : + handleObj.origType, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + + // ( types-object [, selector] ) + for ( type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each( function() { + jQuery.event.remove( this, types, fn, selector ); + } ); + } +} ); + + +var + + // Support: IE <=10 - 11, Edge 12 - 13 only + // In IE/Edge using regex groups here causes severe slowdowns. + // See https://connect.microsoft.com/IE/feedback/details/1736512/ + rnoInnerhtml = /\s*$/g; + +// Prefer a tbody over its parent table for containing new rows +function manipulationTarget( elem, content ) { + if ( nodeName( elem, "table" ) && + nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { + + return jQuery( elem ).children( "tbody" )[ 0 ] || elem; + } + + return elem; +} + +// Replace/restore the type attribute of script elements for safe DOM manipulation +function disableScript( elem ) { + elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; + return elem; +} +function restoreScript( elem ) { + if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) { + elem.type = elem.type.slice( 5 ); + } else { + elem.removeAttribute( "type" ); + } + + return elem; +} + +function cloneCopyEvent( src, dest ) { + var i, l, type, pdataOld, udataOld, udataCur, events; + + if ( dest.nodeType !== 1 ) { + return; + } + + // 1. Copy private data: events, handlers, etc. + if ( dataPriv.hasData( src ) ) { + pdataOld = dataPriv.get( src ); + events = pdataOld.events; + + if ( events ) { + dataPriv.remove( dest, "handle events" ); + + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type, events[ type ][ i ] ); + } + } + } + } + + // 2. Copy user data + if ( dataUser.hasData( src ) ) { + udataOld = dataUser.access( src ); + udataCur = jQuery.extend( {}, udataOld ); + + dataUser.set( dest, udataCur ); + } +} + +// Fix IE bugs, see support tests +function fixInput( src, dest ) { + var nodeName = dest.nodeName.toLowerCase(); + + // Fails to persist the checked state of a cloned checkbox or radio button. + if ( nodeName === "input" && rcheckableType.test( src.type ) ) { + dest.checked = src.checked; + + // Fails to return the selected option to the default selected state when cloning options + } else if ( nodeName === "input" || nodeName === "textarea" ) { + dest.defaultValue = src.defaultValue; + } +} + +function domManip( collection, args, callback, ignored ) { + + // Flatten any nested arrays + args = flat( args ); + + var fragment, first, scripts, hasScripts, node, doc, + i = 0, + l = collection.length, + iNoClone = l - 1, + value = args[ 0 ], + valueIsFunction = isFunction( value ); + + // We can't cloneNode fragments that contain checked, in WebKit + if ( valueIsFunction || + ( l > 1 && typeof value === "string" && + !support.checkClone && rchecked.test( value ) ) ) { + return collection.each( function( index ) { + var self = collection.eq( index ); + if ( valueIsFunction ) { + args[ 0 ] = value.call( this, index, self.html() ); + } + domManip( self, args, callback, ignored ); + } ); + } + + if ( l ) { + fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); + first = fragment.firstChild; + + if ( fragment.childNodes.length === 1 ) { + fragment = first; + } + + // Require either new content or an interest in ignored elements to invoke the callback + if ( first || ignored ) { + scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); + hasScripts = scripts.length; + + // Use the original fragment for the last item + // instead of the first because it can end up + // being emptied incorrectly in certain situations (trac-8070). + for ( ; i < l; i++ ) { + node = fragment; + + if ( i !== iNoClone ) { + node = jQuery.clone( node, true, true ); + + // Keep references to cloned scripts for later restoration + if ( hasScripts ) { + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + jQuery.merge( scripts, getAll( node, "script" ) ); + } + } + + callback.call( collection[ i ], node, i ); + } + + if ( hasScripts ) { + doc = scripts[ scripts.length - 1 ].ownerDocument; + + // Re-enable scripts + jQuery.map( scripts, restoreScript ); + + // Evaluate executable scripts on first document insertion + for ( i = 0; i < hasScripts; i++ ) { + node = scripts[ i ]; + if ( rscriptType.test( node.type || "" ) && + !dataPriv.access( node, "globalEval" ) && + jQuery.contains( doc, node ) ) { + + if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) { + + // Optional AJAX dependency, but won't run scripts if not present + if ( jQuery._evalUrl && !node.noModule ) { + jQuery._evalUrl( node.src, { + nonce: node.nonce || node.getAttribute( "nonce" ) + }, doc ); + } + } else { + + // Unwrap a CDATA section containing script contents. This shouldn't be + // needed as in XML documents they're already not visible when + // inspecting element contents and in HTML documents they have no + // meaning but we're preserving that logic for backwards compatibility. + // This will be removed completely in 4.0. See gh-4904. + DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc ); + } + } + } + } + } + } + + return collection; +} + +function remove( elem, selector, keepData ) { + var node, + nodes = selector ? jQuery.filter( selector, elem ) : elem, + i = 0; + + for ( ; ( node = nodes[ i ] ) != null; i++ ) { + if ( !keepData && node.nodeType === 1 ) { + jQuery.cleanData( getAll( node ) ); + } + + if ( node.parentNode ) { + if ( keepData && isAttached( node ) ) { + setGlobalEval( getAll( node, "script" ) ); + } + node.parentNode.removeChild( node ); + } + } + + return elem; +} + +jQuery.extend( { + htmlPrefilter: function( html ) { + return html; + }, + + clone: function( elem, dataAndEvents, deepDataAndEvents ) { + var i, l, srcElements, destElements, + clone = elem.cloneNode( true ), + inPage = isAttached( elem ); + + // Fix IE cloning issues + if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && + !jQuery.isXMLDoc( elem ) ) { + + // We eschew jQuery#find here for performance reasons: + // https://jsperf.com/getall-vs-sizzle/2 + destElements = getAll( clone ); + srcElements = getAll( elem ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + fixInput( srcElements[ i ], destElements[ i ] ); + } + } + + // Copy the events from the original to the clone + if ( dataAndEvents ) { + if ( deepDataAndEvents ) { + srcElements = srcElements || getAll( elem ); + destElements = destElements || getAll( clone ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + cloneCopyEvent( srcElements[ i ], destElements[ i ] ); + } + } else { + cloneCopyEvent( elem, clone ); + } + } + + // Preserve script evaluation history + destElements = getAll( clone, "script" ); + if ( destElements.length > 0 ) { + setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); + } + + // Return the cloned set + return clone; + }, + + cleanData: function( elems ) { + var data, elem, type, + special = jQuery.event.special, + i = 0; + + for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { + if ( acceptData( elem ) ) { + if ( ( data = elem[ dataPriv.expando ] ) ) { + if ( data.events ) { + for ( type in data.events ) { + if ( special[ type ] ) { + jQuery.event.remove( elem, type ); + + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); + } + } + } + + // Support: Chrome <=35 - 45+ + // Assign undefined instead of using delete, see Data#remove + elem[ dataPriv.expando ] = undefined; + } + if ( elem[ dataUser.expando ] ) { + + // Support: Chrome <=35 - 45+ + // Assign undefined instead of using delete, see Data#remove + elem[ dataUser.expando ] = undefined; + } + } + } + } +} ); + +jQuery.fn.extend( { + detach: function( selector ) { + return remove( this, selector, true ); + }, + + remove: function( selector ) { + return remove( this, selector ); + }, + + text: function( value ) { + return access( this, function( value ) { + return value === undefined ? + jQuery.text( this ) : + this.empty().each( function() { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + this.textContent = value; + } + } ); + }, null, value, arguments.length ); + }, + + append: function() { + return domManip( this, arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.appendChild( elem ); + } + } ); + }, + + prepend: function() { + return domManip( this, arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.insertBefore( elem, target.firstChild ); + } + } ); + }, + + before: function() { + return domManip( this, arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this ); + } + } ); + }, + + after: function() { + return domManip( this, arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this.nextSibling ); + } + } ); + }, + + empty: function() { + var elem, + i = 0; + + for ( ; ( elem = this[ i ] ) != null; i++ ) { + if ( elem.nodeType === 1 ) { + + // Prevent memory leaks + jQuery.cleanData( getAll( elem, false ) ); + + // Remove any remaining nodes + elem.textContent = ""; + } + } + + return this; + }, + + clone: function( dataAndEvents, deepDataAndEvents ) { + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; + + return this.map( function() { + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); + } ); + }, + + html: function( value ) { + return access( this, function( value ) { + var elem = this[ 0 ] || {}, + i = 0, + l = this.length; + + if ( value === undefined && elem.nodeType === 1 ) { + return elem.innerHTML; + } + + // See if we can take a shortcut and just use innerHTML + if ( typeof value === "string" && !rnoInnerhtml.test( value ) && + !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { + + value = jQuery.htmlPrefilter( value ); + + try { + for ( ; i < l; i++ ) { + elem = this[ i ] || {}; + + // Remove element nodes and prevent memory leaks + if ( elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem, false ) ); + elem.innerHTML = value; + } + } + + elem = 0; + + // If using innerHTML throws an exception, use the fallback method + } catch ( e ) {} + } + + if ( elem ) { + this.empty().append( value ); + } + }, null, value, arguments.length ); + }, + + replaceWith: function() { + var ignored = []; + + // Make the changes, replacing each non-ignored context element with the new content + return domManip( this, arguments, function( elem ) { + var parent = this.parentNode; + + if ( jQuery.inArray( this, ignored ) < 0 ) { + jQuery.cleanData( getAll( this ) ); + if ( parent ) { + parent.replaceChild( elem, this ); + } + } + + // Force callback invocation + }, ignored ); + } +} ); + +jQuery.each( { + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" +}, function( name, original ) { + jQuery.fn[ name ] = function( selector ) { + var elems, + ret = [], + insert = jQuery( selector ), + last = insert.length - 1, + i = 0; + + for ( ; i <= last; i++ ) { + elems = i === last ? this : this.clone( true ); + jQuery( insert[ i ] )[ original ]( elems ); + + // Support: Android <=4.0 only, PhantomJS 1 only + // .get() because push.apply(_, arraylike) throws on ancient WebKit + push.apply( ret, elems.get() ); + } + + return this.pushStack( ret ); + }; +} ); +var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); + +var rcustomProp = /^--/; + + +var getStyles = function( elem ) { + + // Support: IE <=11 only, Firefox <=30 (trac-15098, trac-14150) + // IE throws on elements created in popups + // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" + var view = elem.ownerDocument.defaultView; + + if ( !view || !view.opener ) { + view = window; + } + + return view.getComputedStyle( elem ); + }; + +var swap = function( elem, options, callback ) { + var ret, name, + old = {}; + + // Remember the old values, and insert the new ones + for ( name in options ) { + old[ name ] = elem.style[ name ]; + elem.style[ name ] = options[ name ]; + } + + ret = callback.call( elem ); + + // Revert the old values + for ( name in options ) { + elem.style[ name ] = old[ name ]; + } + + return ret; +}; + + +var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); + + + +( function() { + + // Executing both pixelPosition & boxSizingReliable tests require only one layout + // so they're executed at the same time to save the second computation. + function computeStyleTests() { + + // This is a singleton, we need to execute it only once + if ( !div ) { + return; + } + + container.style.cssText = "position:absolute;left:-11111px;width:60px;" + + "margin-top:1px;padding:0;border:0"; + div.style.cssText = + "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + + "margin:auto;border:1px;padding:1px;" + + "width:60%;top:1%"; + documentElement.appendChild( container ).appendChild( div ); + + var divStyle = window.getComputedStyle( div ); + pixelPositionVal = divStyle.top !== "1%"; + + // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 + reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; + + // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 + // Some styles come back with percentage values, even though they shouldn't + div.style.right = "60%"; + pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; + + // Support: IE 9 - 11 only + // Detect misreporting of content dimensions for box-sizing:border-box elements + boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; + + // Support: IE 9 only + // Detect overflow:scroll screwiness (gh-3699) + // Support: Chrome <=64 + // Don't get tricked when zoom affects offsetWidth (gh-4029) + div.style.position = "absolute"; + scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12; + + documentElement.removeChild( container ); + + // Nullify the div so it wouldn't be stored in the memory and + // it will also be a sign that checks already performed + div = null; + } + + function roundPixelMeasures( measure ) { + return Math.round( parseFloat( measure ) ); + } + + var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, + reliableTrDimensionsVal, reliableMarginLeftVal, + container = document.createElement( "div" ), + div = document.createElement( "div" ); + + // Finish early in limited (non-browser) environments + if ( !div.style ) { + return; + } + + // Support: IE <=9 - 11 only + // Style of cloned element affects source element cloned (trac-8908) + div.style.backgroundClip = "content-box"; + div.cloneNode( true ).style.backgroundClip = ""; + support.clearCloneStyle = div.style.backgroundClip === "content-box"; + + jQuery.extend( support, { + boxSizingReliable: function() { + computeStyleTests(); + return boxSizingReliableVal; + }, + pixelBoxStyles: function() { + computeStyleTests(); + return pixelBoxStylesVal; + }, + pixelPosition: function() { + computeStyleTests(); + return pixelPositionVal; + }, + reliableMarginLeft: function() { + computeStyleTests(); + return reliableMarginLeftVal; + }, + scrollboxSize: function() { + computeStyleTests(); + return scrollboxSizeVal; + }, + + // Support: IE 9 - 11+, Edge 15 - 18+ + // IE/Edge misreport `getComputedStyle` of table rows with width/height + // set in CSS while `offset*` properties report correct values. + // Behavior in IE 9 is more subtle than in newer versions & it passes + // some versions of this test; make sure not to make it pass there! + // + // Support: Firefox 70+ + // Only Firefox includes border widths + // in computed dimensions. (gh-4529) + reliableTrDimensions: function() { + var table, tr, trChild, trStyle; + if ( reliableTrDimensionsVal == null ) { + table = document.createElement( "table" ); + tr = document.createElement( "tr" ); + trChild = document.createElement( "div" ); + + table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate"; + tr.style.cssText = "box-sizing:content-box;border:1px solid"; + + // Support: Chrome 86+ + // Height set through cssText does not get applied. + // Computed height then comes back as 0. + tr.style.height = "1px"; + trChild.style.height = "9px"; + + // Support: Android 8 Chrome 86+ + // In our bodyBackground.html iframe, + // display for all div elements is set to "inline", + // which causes a problem only in Android 8 Chrome 86. + // Ensuring the div is `display: block` + // gets around this issue. + trChild.style.display = "block"; + + documentElement + .appendChild( table ) + .appendChild( tr ) + .appendChild( trChild ); + + trStyle = window.getComputedStyle( tr ); + reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) + + parseInt( trStyle.borderTopWidth, 10 ) + + parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight; + + documentElement.removeChild( table ); + } + return reliableTrDimensionsVal; + } + } ); +} )(); + + +function curCSS( elem, name, computed ) { + var width, minWidth, maxWidth, ret, + isCustomProp = rcustomProp.test( name ), + + // Support: Firefox 51+ + // Retrieving style before computed somehow + // fixes an issue with getting wrong values + // on detached elements + style = elem.style; + + computed = computed || getStyles( elem ); + + // getPropertyValue is needed for: + // .css('filter') (IE 9 only, trac-12537) + // .css('--customProperty) (gh-3144) + if ( computed ) { + + // Support: IE <=9 - 11+ + // IE only supports `"float"` in `getPropertyValue`; in computed styles + // it's only available as `"cssFloat"`. We no longer modify properties + // sent to `.css()` apart from camelCasing, so we need to check both. + // Normally, this would create difference in behavior: if + // `getPropertyValue` returns an empty string, the value returned + // by `.css()` would be `undefined`. This is usually the case for + // disconnected elements. However, in IE even disconnected elements + // with no styles return `"none"` for `getPropertyValue( "float" )` + ret = computed.getPropertyValue( name ) || computed[ name ]; + + if ( isCustomProp && ret ) { + + // Support: Firefox 105+, Chrome <=105+ + // Spec requires trimming whitespace for custom properties (gh-4926). + // Firefox only trims leading whitespace. Chrome just collapses + // both leading & trailing whitespace to a single space. + // + // Fall back to `undefined` if empty string returned. + // This collapses a missing definition with property defined + // and set to an empty string but there's no standard API + // allowing us to differentiate them without a performance penalty + // and returning `undefined` aligns with older jQuery. + // + // rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED + // as whitespace while CSS does not, but this is not a problem + // because CSS preprocessing replaces them with U+000A LINE FEED + // (which *is* CSS whitespace) + // https://www.w3.org/TR/css-syntax-3/#input-preprocessing + ret = ret.replace( rtrimCSS, "$1" ) || undefined; + } + + if ( ret === "" && !isAttached( elem ) ) { + ret = jQuery.style( elem, name ); + } + + // A tribute to the "awesome hack by Dean Edwards" + // Android Browser returns percentage for some values, + // but width seems to be reliably pixels. + // This is against the CSSOM draft spec: + // https://drafts.csswg.org/cssom/#resolved-values + if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) { + + // Remember the original values + width = style.width; + minWidth = style.minWidth; + maxWidth = style.maxWidth; + + // Put in the new values to get a computed value out + style.minWidth = style.maxWidth = style.width = ret; + ret = computed.width; + + // Revert the changed values + style.width = width; + style.minWidth = minWidth; + style.maxWidth = maxWidth; + } + } + + return ret !== undefined ? + + // Support: IE <=9 - 11 only + // IE returns zIndex value as an integer. + ret + "" : + ret; +} + + +function addGetHookIf( conditionFn, hookFn ) { + + // Define the hook, we'll check on the first run if it's really needed. + return { + get: function() { + if ( conditionFn() ) { + + // Hook not needed (or it's not possible to use it due + // to missing dependency), remove it. + delete this.get; + return; + } + + // Hook needed; redefine it so that the support test is not executed again. + return ( this.get = hookFn ).apply( this, arguments ); + } + }; +} + + +var cssPrefixes = [ "Webkit", "Moz", "ms" ], + emptyStyle = document.createElement( "div" ).style, + vendorProps = {}; + +// Return a vendor-prefixed property or undefined +function vendorPropName( name ) { + + // Check for vendor prefixed names + var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), + i = cssPrefixes.length; + + while ( i-- ) { + name = cssPrefixes[ i ] + capName; + if ( name in emptyStyle ) { + return name; + } + } +} + +// Return a potentially-mapped jQuery.cssProps or vendor prefixed property +function finalPropName( name ) { + var final = jQuery.cssProps[ name ] || vendorProps[ name ]; + + if ( final ) { + return final; + } + if ( name in emptyStyle ) { + return name; + } + return vendorProps[ name ] = vendorPropName( name ) || name; +} + + +var + + // Swappable if display is none or starts with table + // except "table", "table-cell", or "table-caption" + // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display + rdisplayswap = /^(none|table(?!-c[ea]).+)/, + cssShow = { position: "absolute", visibility: "hidden", display: "block" }, + cssNormalTransform = { + letterSpacing: "0", + fontWeight: "400" + }; + +function setPositiveNumber( _elem, value, subtract ) { + + // Any relative (+/-) values have already been + // normalized at this point + var matches = rcssNum.exec( value ); + return matches ? + + // Guard against undefined "subtract", e.g., when used as in cssHooks + Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : + value; +} + +function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { + var i = dimension === "width" ? 1 : 0, + extra = 0, + delta = 0, + marginDelta = 0; + + // Adjustment may not be necessary + if ( box === ( isBorderBox ? "border" : "content" ) ) { + return 0; + } + + for ( ; i < 4; i += 2 ) { + + // Both box models exclude margin + // Count margin delta separately to only add it after scroll gutter adjustment. + // This is needed to make negative margins work with `outerHeight( true )` (gh-3982). + if ( box === "margin" ) { + marginDelta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); + } + + // If we get here with a content-box, we're seeking "padding" or "border" or "margin" + if ( !isBorderBox ) { + + // Add padding + delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + + // For "border" or "margin", add border + if ( box !== "padding" ) { + delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + + // But still keep track of it otherwise + } else { + extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + } + + // If we get here with a border-box (content + padding + border), we're seeking "content" or + // "padding" or "margin" + } else { + + // For "content", subtract padding + if ( box === "content" ) { + delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + } + + // For "content" or "padding", subtract border + if ( box !== "margin" ) { + delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + } + } + } + + // Account for positive content-box scroll gutter when requested by providing computedVal + if ( !isBorderBox && computedVal >= 0 ) { + + // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border + // Assuming integer scroll gutter, subtract the rest and round down + delta += Math.max( 0, Math.ceil( + elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - + computedVal - + delta - + extra - + 0.5 + + // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter + // Use an explicit zero to avoid NaN (gh-3964) + ) ) || 0; + } + + return delta + marginDelta; +} + +function getWidthOrHeight( elem, dimension, extra ) { + + // Start with computed style + var styles = getStyles( elem ), + + // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). + // Fake content-box until we know it's needed to know the true value. + boxSizingNeeded = !support.boxSizingReliable() || extra, + isBorderBox = boxSizingNeeded && + jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + valueIsBorderBox = isBorderBox, + + val = curCSS( elem, dimension, styles ), + offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); + + // Support: Firefox <=54 + // Return a confounding non-pixel value or feign ignorance, as appropriate. + if ( rnumnonpx.test( val ) ) { + if ( !extra ) { + return val; + } + val = "auto"; + } + + + // Support: IE 9 - 11 only + // Use offsetWidth/offsetHeight for when box sizing is unreliable. + // In those cases, the computed value can be trusted to be border-box. + if ( ( !support.boxSizingReliable() && isBorderBox || + + // Support: IE 10 - 11+, Edge 15 - 18+ + // IE/Edge misreport `getComputedStyle` of table rows with width/height + // set in CSS while `offset*` properties report correct values. + // Interestingly, in some cases IE 9 doesn't suffer from this issue. + !support.reliableTrDimensions() && nodeName( elem, "tr" ) || + + // Fall back to offsetWidth/offsetHeight when value is "auto" + // This happens for inline elements with no explicit setting (gh-3571) + val === "auto" || + + // Support: Android <=4.1 - 4.3 only + // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) + !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && + + // Make sure the element is visible & connected + elem.getClientRects().length ) { + + isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; + + // Where available, offsetWidth/offsetHeight approximate border box dimensions. + // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the + // retrieved value as a content box dimension. + valueIsBorderBox = offsetProp in elem; + if ( valueIsBorderBox ) { + val = elem[ offsetProp ]; + } + } + + // Normalize "" and auto + val = parseFloat( val ) || 0; + + // Adjust for the element's box model + return ( val + + boxModelAdjustment( + elem, + dimension, + extra || ( isBorderBox ? "border" : "content" ), + valueIsBorderBox, + styles, + + // Provide the current computed size to request scroll gutter calculation (gh-3589) + val + ) + ) + "px"; +} + +jQuery.extend( { + + // Add in style property hooks for overriding the default + // behavior of getting and setting a style property + cssHooks: { + opacity: { + get: function( elem, computed ) { + if ( computed ) { + + // We should always get a number back from opacity + var ret = curCSS( elem, "opacity" ); + return ret === "" ? "1" : ret; + } + } + } + }, + + // Don't automatically add "px" to these possibly-unitless properties + cssNumber: { + animationIterationCount: true, + aspectRatio: true, + borderImageSlice: true, + columnCount: true, + flexGrow: true, + flexShrink: true, + fontWeight: true, + gridArea: true, + gridColumn: true, + gridColumnEnd: true, + gridColumnStart: true, + gridRow: true, + gridRowEnd: true, + gridRowStart: true, + lineHeight: true, + opacity: true, + order: true, + orphans: true, + scale: true, + widows: true, + zIndex: true, + zoom: true, + + // SVG-related + fillOpacity: true, + floodOpacity: true, + stopOpacity: true, + strokeMiterlimit: true, + strokeOpacity: true + }, + + // Add in properties whose names you wish to fix before + // setting or getting the value + cssProps: {}, + + // Get and set the style property on a DOM Node + style: function( elem, name, value, extra ) { + + // Don't set styles on text and comment nodes + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { + return; + } + + // Make sure that we're working with the right name + var ret, type, hooks, + origName = camelCase( name ), + isCustomProp = rcustomProp.test( name ), + style = elem.style; + + // Make sure that we're working with the right name. We don't + // want to query the value if it is a CSS custom property + // since they are user-defined. + if ( !isCustomProp ) { + name = finalPropName( origName ); + } + + // Gets hook for the prefixed version, then unprefixed version + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; + + // Check if we're setting a value + if ( value !== undefined ) { + type = typeof value; + + // Convert "+=" or "-=" to relative numbers (trac-7345) + if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { + value = adjustCSS( elem, name, ret ); + + // Fixes bug trac-9237 + type = "number"; + } + + // Make sure that null and NaN values aren't set (trac-7116) + if ( value == null || value !== value ) { + return; + } + + // If a number was passed in, add the unit (except for certain CSS properties) + // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append + // "px" to a few hardcoded values. + if ( type === "number" && !isCustomProp ) { + value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); + } + + // background-* props affect original clone's values + if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { + style[ name ] = "inherit"; + } + + // If a hook was provided, use that value, otherwise just set the specified value + if ( !hooks || !( "set" in hooks ) || + ( value = hooks.set( elem, value, extra ) ) !== undefined ) { + + if ( isCustomProp ) { + style.setProperty( name, value ); + } else { + style[ name ] = value; + } + } + + } else { + + // If a hook was provided get the non-computed value from there + if ( hooks && "get" in hooks && + ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { + + return ret; + } + + // Otherwise just get the value from the style object + return style[ name ]; + } + }, + + css: function( elem, name, extra, styles ) { + var val, num, hooks, + origName = camelCase( name ), + isCustomProp = rcustomProp.test( name ); + + // Make sure that we're working with the right name. We don't + // want to modify the value if it is a CSS custom property + // since they are user-defined. + if ( !isCustomProp ) { + name = finalPropName( origName ); + } + + // Try prefixed name followed by the unprefixed name + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; + + // If a hook was provided get the computed value from there + if ( hooks && "get" in hooks ) { + val = hooks.get( elem, true, extra ); + } + + // Otherwise, if a way to get the computed value exists, use that + if ( val === undefined ) { + val = curCSS( elem, name, styles ); + } + + // Convert "normal" to computed value + if ( val === "normal" && name in cssNormalTransform ) { + val = cssNormalTransform[ name ]; + } + + // Make numeric if forced or a qualifier was provided and val looks numeric + if ( extra === "" || extra ) { + num = parseFloat( val ); + return extra === true || isFinite( num ) ? num || 0 : val; + } + + return val; + } +} ); + +jQuery.each( [ "height", "width" ], function( _i, dimension ) { + jQuery.cssHooks[ dimension ] = { + get: function( elem, computed, extra ) { + if ( computed ) { + + // Certain elements can have dimension info if we invisibly show them + // but it must have a current display style that would benefit + return rdisplayswap.test( jQuery.css( elem, "display" ) ) && + + // Support: Safari 8+ + // Table columns in Safari have non-zero offsetWidth & zero + // getBoundingClientRect().width unless display is changed. + // Support: IE <=11 only + // Running getBoundingClientRect on a disconnected node + // in IE throws an error. + ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? + swap( elem, cssShow, function() { + return getWidthOrHeight( elem, dimension, extra ); + } ) : + getWidthOrHeight( elem, dimension, extra ); + } + }, + + set: function( elem, value, extra ) { + var matches, + styles = getStyles( elem ), + + // Only read styles.position if the test has a chance to fail + // to avoid forcing a reflow. + scrollboxSizeBuggy = !support.scrollboxSize() && + styles.position === "absolute", + + // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991) + boxSizingNeeded = scrollboxSizeBuggy || extra, + isBorderBox = boxSizingNeeded && + jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + subtract = extra ? + boxModelAdjustment( + elem, + dimension, + extra, + isBorderBox, + styles + ) : + 0; + + // Account for unreliable border-box dimensions by comparing offset* to computed and + // faking a content-box to get border and padding (gh-3699) + if ( isBorderBox && scrollboxSizeBuggy ) { + subtract -= Math.ceil( + elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - + parseFloat( styles[ dimension ] ) - + boxModelAdjustment( elem, dimension, "border", false, styles ) - + 0.5 + ); + } + + // Convert to pixels if value adjustment is needed + if ( subtract && ( matches = rcssNum.exec( value ) ) && + ( matches[ 3 ] || "px" ) !== "px" ) { + + elem.style[ dimension ] = value; + value = jQuery.css( elem, dimension ); + } + + return setPositiveNumber( elem, value, subtract ); + } + }; +} ); + +jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, + function( elem, computed ) { + if ( computed ) { + return ( parseFloat( curCSS( elem, "marginLeft" ) ) || + elem.getBoundingClientRect().left - + swap( elem, { marginLeft: 0 }, function() { + return elem.getBoundingClientRect().left; + } ) + ) + "px"; + } + } +); + +// These hooks are used by animate to expand properties +jQuery.each( { + margin: "", + padding: "", + border: "Width" +}, function( prefix, suffix ) { + jQuery.cssHooks[ prefix + suffix ] = { + expand: function( value ) { + var i = 0, + expanded = {}, + + // Assumes a single number if not a string + parts = typeof value === "string" ? value.split( " " ) : [ value ]; + + for ( ; i < 4; i++ ) { + expanded[ prefix + cssExpand[ i ] + suffix ] = + parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; + } + + return expanded; + } + }; + + if ( prefix !== "margin" ) { + jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; + } +} ); + +jQuery.fn.extend( { + css: function( name, value ) { + return access( this, function( elem, name, value ) { + var styles, len, + map = {}, + i = 0; + + if ( Array.isArray( name ) ) { + styles = getStyles( elem ); + len = name.length; + + for ( ; i < len; i++ ) { + map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); + } + + return map; + } + + return value !== undefined ? + jQuery.style( elem, name, value ) : + jQuery.css( elem, name ); + }, name, value, arguments.length > 1 ); + } +} ); + + +function Tween( elem, options, prop, end, easing ) { + return new Tween.prototype.init( elem, options, prop, end, easing ); +} +jQuery.Tween = Tween; + +Tween.prototype = { + constructor: Tween, + init: function( elem, options, prop, end, easing, unit ) { + this.elem = elem; + this.prop = prop; + this.easing = easing || jQuery.easing._default; + this.options = options; + this.start = this.now = this.cur(); + this.end = end; + this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); + }, + cur: function() { + var hooks = Tween.propHooks[ this.prop ]; + + return hooks && hooks.get ? + hooks.get( this ) : + Tween.propHooks._default.get( this ); + }, + run: function( percent ) { + var eased, + hooks = Tween.propHooks[ this.prop ]; + + if ( this.options.duration ) { + this.pos = eased = jQuery.easing[ this.easing ]( + percent, this.options.duration * percent, 0, 1, this.options.duration + ); + } else { + this.pos = eased = percent; + } + this.now = ( this.end - this.start ) * eased + this.start; + + if ( this.options.step ) { + this.options.step.call( this.elem, this.now, this ); + } + + if ( hooks && hooks.set ) { + hooks.set( this ); + } else { + Tween.propHooks._default.set( this ); + } + return this; + } +}; + +Tween.prototype.init.prototype = Tween.prototype; + +Tween.propHooks = { + _default: { + get: function( tween ) { + var result; + + // Use a property on the element directly when it is not a DOM element, + // or when there is no matching style property that exists. + if ( tween.elem.nodeType !== 1 || + tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { + return tween.elem[ tween.prop ]; + } + + // Passing an empty string as a 3rd parameter to .css will automatically + // attempt a parseFloat and fallback to a string if the parse fails. + // Simple values such as "10px" are parsed to Float; + // complex values such as "rotate(1rad)" are returned as-is. + result = jQuery.css( tween.elem, tween.prop, "" ); + + // Empty strings, null, undefined and "auto" are converted to 0. + return !result || result === "auto" ? 0 : result; + }, + set: function( tween ) { + + // Use step hook for back compat. + // Use cssHook if its there. + // Use .style if available and use plain properties where available. + if ( jQuery.fx.step[ tween.prop ] ) { + jQuery.fx.step[ tween.prop ]( tween ); + } else if ( tween.elem.nodeType === 1 && ( + jQuery.cssHooks[ tween.prop ] || + tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) { + jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); + } else { + tween.elem[ tween.prop ] = tween.now; + } + } + } +}; + +// Support: IE <=9 only +// Panic based approach to setting things on disconnected nodes +Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { + set: function( tween ) { + if ( tween.elem.nodeType && tween.elem.parentNode ) { + tween.elem[ tween.prop ] = tween.now; + } + } +}; + +jQuery.easing = { + linear: function( p ) { + return p; + }, + swing: function( p ) { + return 0.5 - Math.cos( p * Math.PI ) / 2; + }, + _default: "swing" +}; + +jQuery.fx = Tween.prototype.init; + +// Back compat <1.8 extension point +jQuery.fx.step = {}; + + + + +var + fxNow, inProgress, + rfxtypes = /^(?:toggle|show|hide)$/, + rrun = /queueHooks$/; + +function schedule() { + if ( inProgress ) { + if ( document.hidden === false && window.requestAnimationFrame ) { + window.requestAnimationFrame( schedule ); + } else { + window.setTimeout( schedule, jQuery.fx.interval ); + } + + jQuery.fx.tick(); + } +} + +// Animations created synchronously will run synchronously +function createFxNow() { + window.setTimeout( function() { + fxNow = undefined; + } ); + return ( fxNow = Date.now() ); +} + +// Generate parameters to create a standard animation +function genFx( type, includeWidth ) { + var which, + i = 0, + attrs = { height: type }; + + // If we include width, step value is 1 to do all cssExpand values, + // otherwise step value is 2 to skip over Left and Right + includeWidth = includeWidth ? 1 : 0; + for ( ; i < 4; i += 2 - includeWidth ) { + which = cssExpand[ i ]; + attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; + } + + if ( includeWidth ) { + attrs.opacity = attrs.width = type; + } + + return attrs; +} + +function createTween( value, prop, animation ) { + var tween, + collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), + index = 0, + length = collection.length; + for ( ; index < length; index++ ) { + if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { + + // We're done with this property + return tween; + } + } +} + +function defaultPrefilter( elem, props, opts ) { + var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, + isBox = "width" in props || "height" in props, + anim = this, + orig = {}, + style = elem.style, + hidden = elem.nodeType && isHiddenWithinTree( elem ), + dataShow = dataPriv.get( elem, "fxshow" ); + + // Queue-skipping animations hijack the fx hooks + if ( !opts.queue ) { + hooks = jQuery._queueHooks( elem, "fx" ); + if ( hooks.unqueued == null ) { + hooks.unqueued = 0; + oldfire = hooks.empty.fire; + hooks.empty.fire = function() { + if ( !hooks.unqueued ) { + oldfire(); + } + }; + } + hooks.unqueued++; + + anim.always( function() { + + // Ensure the complete handler is called before this completes + anim.always( function() { + hooks.unqueued--; + if ( !jQuery.queue( elem, "fx" ).length ) { + hooks.empty.fire(); + } + } ); + } ); + } + + // Detect show/hide animations + for ( prop in props ) { + value = props[ prop ]; + if ( rfxtypes.test( value ) ) { + delete props[ prop ]; + toggle = toggle || value === "toggle"; + if ( value === ( hidden ? "hide" : "show" ) ) { + + // Pretend to be hidden if this is a "show" and + // there is still data from a stopped show/hide + if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { + hidden = true; + + // Ignore all other no-op show/hide data + } else { + continue; + } + } + orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); + } + } + + // Bail out if this is a no-op like .hide().hide() + propTween = !jQuery.isEmptyObject( props ); + if ( !propTween && jQuery.isEmptyObject( orig ) ) { + return; + } + + // Restrict "overflow" and "display" styles during box animations + if ( isBox && elem.nodeType === 1 ) { + + // Support: IE <=9 - 11, Edge 12 - 15 + // Record all 3 overflow attributes because IE does not infer the shorthand + // from identically-valued overflowX and overflowY and Edge just mirrors + // the overflowX value there. + opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; + + // Identify a display type, preferring old show/hide data over the CSS cascade + restoreDisplay = dataShow && dataShow.display; + if ( restoreDisplay == null ) { + restoreDisplay = dataPriv.get( elem, "display" ); + } + display = jQuery.css( elem, "display" ); + if ( display === "none" ) { + if ( restoreDisplay ) { + display = restoreDisplay; + } else { + + // Get nonempty value(s) by temporarily forcing visibility + showHide( [ elem ], true ); + restoreDisplay = elem.style.display || restoreDisplay; + display = jQuery.css( elem, "display" ); + showHide( [ elem ] ); + } + } + + // Animate inline elements as inline-block + if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { + if ( jQuery.css( elem, "float" ) === "none" ) { + + // Restore the original display value at the end of pure show/hide animations + if ( !propTween ) { + anim.done( function() { + style.display = restoreDisplay; + } ); + if ( restoreDisplay == null ) { + display = style.display; + restoreDisplay = display === "none" ? "" : display; + } + } + style.display = "inline-block"; + } + } + } + + if ( opts.overflow ) { + style.overflow = "hidden"; + anim.always( function() { + style.overflow = opts.overflow[ 0 ]; + style.overflowX = opts.overflow[ 1 ]; + style.overflowY = opts.overflow[ 2 ]; + } ); + } + + // Implement show/hide animations + propTween = false; + for ( prop in orig ) { + + // General show/hide setup for this element animation + if ( !propTween ) { + if ( dataShow ) { + if ( "hidden" in dataShow ) { + hidden = dataShow.hidden; + } + } else { + dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); + } + + // Store hidden/visible for toggle so `.stop().toggle()` "reverses" + if ( toggle ) { + dataShow.hidden = !hidden; + } + + // Show elements before animating them + if ( hidden ) { + showHide( [ elem ], true ); + } + + /* eslint-disable no-loop-func */ + + anim.done( function() { + + /* eslint-enable no-loop-func */ + + // The final step of a "hide" animation is actually hiding the element + if ( !hidden ) { + showHide( [ elem ] ); + } + dataPriv.remove( elem, "fxshow" ); + for ( prop in orig ) { + jQuery.style( elem, prop, orig[ prop ] ); + } + } ); + } + + // Per-property setup + propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); + if ( !( prop in dataShow ) ) { + dataShow[ prop ] = propTween.start; + if ( hidden ) { + propTween.end = propTween.start; + propTween.start = 0; + } + } + } +} + +function propFilter( props, specialEasing ) { + var index, name, easing, value, hooks; + + // camelCase, specialEasing and expand cssHook pass + for ( index in props ) { + name = camelCase( index ); + easing = specialEasing[ name ]; + value = props[ index ]; + if ( Array.isArray( value ) ) { + easing = value[ 1 ]; + value = props[ index ] = value[ 0 ]; + } + + if ( index !== name ) { + props[ name ] = value; + delete props[ index ]; + } + + hooks = jQuery.cssHooks[ name ]; + if ( hooks && "expand" in hooks ) { + value = hooks.expand( value ); + delete props[ name ]; + + // Not quite $.extend, this won't overwrite existing keys. + // Reusing 'index' because we have the correct "name" + for ( index in value ) { + if ( !( index in props ) ) { + props[ index ] = value[ index ]; + specialEasing[ index ] = easing; + } + } + } else { + specialEasing[ name ] = easing; + } + } +} + +function Animation( elem, properties, options ) { + var result, + stopped, + index = 0, + length = Animation.prefilters.length, + deferred = jQuery.Deferred().always( function() { + + // Don't match elem in the :animated selector + delete tick.elem; + } ), + tick = function() { + if ( stopped ) { + return false; + } + var currentTime = fxNow || createFxNow(), + remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), + + // Support: Android 2.3 only + // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (trac-12497) + temp = remaining / animation.duration || 0, + percent = 1 - temp, + index = 0, + length = animation.tweens.length; + + for ( ; index < length; index++ ) { + animation.tweens[ index ].run( percent ); + } + + deferred.notifyWith( elem, [ animation, percent, remaining ] ); + + // If there's more to do, yield + if ( percent < 1 && length ) { + return remaining; + } + + // If this was an empty animation, synthesize a final progress notification + if ( !length ) { + deferred.notifyWith( elem, [ animation, 1, 0 ] ); + } + + // Resolve the animation and report its conclusion + deferred.resolveWith( elem, [ animation ] ); + return false; + }, + animation = deferred.promise( { + elem: elem, + props: jQuery.extend( {}, properties ), + opts: jQuery.extend( true, { + specialEasing: {}, + easing: jQuery.easing._default + }, options ), + originalProperties: properties, + originalOptions: options, + startTime: fxNow || createFxNow(), + duration: options.duration, + tweens: [], + createTween: function( prop, end ) { + var tween = jQuery.Tween( elem, animation.opts, prop, end, + animation.opts.specialEasing[ prop ] || animation.opts.easing ); + animation.tweens.push( tween ); + return tween; + }, + stop: function( gotoEnd ) { + var index = 0, + + // If we are going to the end, we want to run all the tweens + // otherwise we skip this part + length = gotoEnd ? animation.tweens.length : 0; + if ( stopped ) { + return this; + } + stopped = true; + for ( ; index < length; index++ ) { + animation.tweens[ index ].run( 1 ); + } + + // Resolve when we played the last frame; otherwise, reject + if ( gotoEnd ) { + deferred.notifyWith( elem, [ animation, 1, 0 ] ); + deferred.resolveWith( elem, [ animation, gotoEnd ] ); + } else { + deferred.rejectWith( elem, [ animation, gotoEnd ] ); + } + return this; + } + } ), + props = animation.props; + + propFilter( props, animation.opts.specialEasing ); + + for ( ; index < length; index++ ) { + result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); + if ( result ) { + if ( isFunction( result.stop ) ) { + jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = + result.stop.bind( result ); + } + return result; + } + } + + jQuery.map( props, createTween, animation ); + + if ( isFunction( animation.opts.start ) ) { + animation.opts.start.call( elem, animation ); + } + + // Attach callbacks from options + animation + .progress( animation.opts.progress ) + .done( animation.opts.done, animation.opts.complete ) + .fail( animation.opts.fail ) + .always( animation.opts.always ); + + jQuery.fx.timer( + jQuery.extend( tick, { + elem: elem, + anim: animation, + queue: animation.opts.queue + } ) + ); + + return animation; +} + +jQuery.Animation = jQuery.extend( Animation, { + + tweeners: { + "*": [ function( prop, value ) { + var tween = this.createTween( prop, value ); + adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); + return tween; + } ] + }, + + tweener: function( props, callback ) { + if ( isFunction( props ) ) { + callback = props; + props = [ "*" ]; + } else { + props = props.match( rnothtmlwhite ); + } + + var prop, + index = 0, + length = props.length; + + for ( ; index < length; index++ ) { + prop = props[ index ]; + Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; + Animation.tweeners[ prop ].unshift( callback ); + } + }, + + prefilters: [ defaultPrefilter ], + + prefilter: function( callback, prepend ) { + if ( prepend ) { + Animation.prefilters.unshift( callback ); + } else { + Animation.prefilters.push( callback ); + } + } +} ); + +jQuery.speed = function( speed, easing, fn ) { + var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { + complete: fn || !fn && easing || + isFunction( speed ) && speed, + duration: speed, + easing: fn && easing || easing && !isFunction( easing ) && easing + }; + + // Go to the end state if fx are off + if ( jQuery.fx.off ) { + opt.duration = 0; + + } else { + if ( typeof opt.duration !== "number" ) { + if ( opt.duration in jQuery.fx.speeds ) { + opt.duration = jQuery.fx.speeds[ opt.duration ]; + + } else { + opt.duration = jQuery.fx.speeds._default; + } + } + } + + // Normalize opt.queue - true/undefined/null -> "fx" + if ( opt.queue == null || opt.queue === true ) { + opt.queue = "fx"; + } + + // Queueing + opt.old = opt.complete; + + opt.complete = function() { + if ( isFunction( opt.old ) ) { + opt.old.call( this ); + } + + if ( opt.queue ) { + jQuery.dequeue( this, opt.queue ); + } + }; + + return opt; +}; + +jQuery.fn.extend( { + fadeTo: function( speed, to, easing, callback ) { + + // Show any hidden elements after setting opacity to 0 + return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show() + + // Animate to the value specified + .end().animate( { opacity: to }, speed, easing, callback ); + }, + animate: function( prop, speed, easing, callback ) { + var empty = jQuery.isEmptyObject( prop ), + optall = jQuery.speed( speed, easing, callback ), + doAnimation = function() { + + // Operate on a copy of prop so per-property easing won't be lost + var anim = Animation( this, jQuery.extend( {}, prop ), optall ); + + // Empty animations, or finishing resolves immediately + if ( empty || dataPriv.get( this, "finish" ) ) { + anim.stop( true ); + } + }; + + doAnimation.finish = doAnimation; + + return empty || optall.queue === false ? + this.each( doAnimation ) : + this.queue( optall.queue, doAnimation ); + }, + stop: function( type, clearQueue, gotoEnd ) { + var stopQueue = function( hooks ) { + var stop = hooks.stop; + delete hooks.stop; + stop( gotoEnd ); + }; + + if ( typeof type !== "string" ) { + gotoEnd = clearQueue; + clearQueue = type; + type = undefined; + } + if ( clearQueue ) { + this.queue( type || "fx", [] ); + } + + return this.each( function() { + var dequeue = true, + index = type != null && type + "queueHooks", + timers = jQuery.timers, + data = dataPriv.get( this ); + + if ( index ) { + if ( data[ index ] && data[ index ].stop ) { + stopQueue( data[ index ] ); + } + } else { + for ( index in data ) { + if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { + stopQueue( data[ index ] ); + } + } + } + + for ( index = timers.length; index--; ) { + if ( timers[ index ].elem === this && + ( type == null || timers[ index ].queue === type ) ) { + + timers[ index ].anim.stop( gotoEnd ); + dequeue = false; + timers.splice( index, 1 ); + } + } + + // Start the next in the queue if the last step wasn't forced. + // Timers currently will call their complete callbacks, which + // will dequeue but only if they were gotoEnd. + if ( dequeue || !gotoEnd ) { + jQuery.dequeue( this, type ); + } + } ); + }, + finish: function( type ) { + if ( type !== false ) { + type = type || "fx"; + } + return this.each( function() { + var index, + data = dataPriv.get( this ), + queue = data[ type + "queue" ], + hooks = data[ type + "queueHooks" ], + timers = jQuery.timers, + length = queue ? queue.length : 0; + + // Enable finishing flag on private data + data.finish = true; + + // Empty the queue first + jQuery.queue( this, type, [] ); + + if ( hooks && hooks.stop ) { + hooks.stop.call( this, true ); + } + + // Look for any active animations, and finish them + for ( index = timers.length; index--; ) { + if ( timers[ index ].elem === this && timers[ index ].queue === type ) { + timers[ index ].anim.stop( true ); + timers.splice( index, 1 ); + } + } + + // Look for any animations in the old queue and finish them + for ( index = 0; index < length; index++ ) { + if ( queue[ index ] && queue[ index ].finish ) { + queue[ index ].finish.call( this ); + } + } + + // Turn off finishing flag + delete data.finish; + } ); + } +} ); + +jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) { + var cssFn = jQuery.fn[ name ]; + jQuery.fn[ name ] = function( speed, easing, callback ) { + return speed == null || typeof speed === "boolean" ? + cssFn.apply( this, arguments ) : + this.animate( genFx( name, true ), speed, easing, callback ); + }; +} ); + +// Generate shortcuts for custom animations +jQuery.each( { + slideDown: genFx( "show" ), + slideUp: genFx( "hide" ), + slideToggle: genFx( "toggle" ), + fadeIn: { opacity: "show" }, + fadeOut: { opacity: "hide" }, + fadeToggle: { opacity: "toggle" } +}, function( name, props ) { + jQuery.fn[ name ] = function( speed, easing, callback ) { + return this.animate( props, speed, easing, callback ); + }; +} ); + +jQuery.timers = []; +jQuery.fx.tick = function() { + var timer, + i = 0, + timers = jQuery.timers; + + fxNow = Date.now(); + + for ( ; i < timers.length; i++ ) { + timer = timers[ i ]; + + // Run the timer and safely remove it when done (allowing for external removal) + if ( !timer() && timers[ i ] === timer ) { + timers.splice( i--, 1 ); + } + } + + if ( !timers.length ) { + jQuery.fx.stop(); + } + fxNow = undefined; +}; + +jQuery.fx.timer = function( timer ) { + jQuery.timers.push( timer ); + jQuery.fx.start(); +}; + +jQuery.fx.interval = 13; +jQuery.fx.start = function() { + if ( inProgress ) { + return; + } + + inProgress = true; + schedule(); +}; + +jQuery.fx.stop = function() { + inProgress = null; +}; + +jQuery.fx.speeds = { + slow: 600, + fast: 200, + + // Default speed + _default: 400 +}; + + +// Based off of the plugin by Clint Helfers, with permission. +jQuery.fn.delay = function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = window.setTimeout( next, time ); + hooks.stop = function() { + window.clearTimeout( timeout ); + }; + } ); +}; + + +( function() { + var input = document.createElement( "input" ), + select = document.createElement( "select" ), + opt = select.appendChild( document.createElement( "option" ) ); + + input.type = "checkbox"; + + // Support: Android <=4.3 only + // Default value for a checkbox should be "on" + support.checkOn = input.value !== ""; + + // Support: IE <=11 only + // Must access selectedIndex to make default options select + support.optSelected = opt.selected; + + // Support: IE <=11 only + // An input loses its value after becoming a radio + input = document.createElement( "input" ); + input.value = "t"; + input.type = "radio"; + support.radioValue = input.value === "t"; +} )(); + + +var boolHook, + attrHandle = jQuery.expr.attrHandle; + +jQuery.fn.extend( { + attr: function( name, value ) { + return access( this, jQuery.attr, name, value, arguments.length > 1 ); + }, + + removeAttr: function( name ) { + return this.each( function() { + jQuery.removeAttr( this, name ); + } ); + } +} ); + +jQuery.extend( { + attr: function( elem, name, value ) { + var ret, hooks, + nType = elem.nodeType; + + // Don't get/set attributes on text, comment and attribute nodes + if ( nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + // Fallback to prop when attributes are not supported + if ( typeof elem.getAttribute === "undefined" ) { + return jQuery.prop( elem, name, value ); + } + + // Attribute hooks are determined by the lowercase version + // Grab necessary hook if one is defined + if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { + hooks = jQuery.attrHooks[ name.toLowerCase() ] || + ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); + } + + if ( value !== undefined ) { + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return; + } + + if ( hooks && "set" in hooks && + ( ret = hooks.set( elem, value, name ) ) !== undefined ) { + return ret; + } + + elem.setAttribute( name, value + "" ); + return value; + } + + if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { + return ret; + } + + ret = jQuery.find.attr( elem, name ); + + // Non-existent attributes return null, we normalize to undefined + return ret == null ? undefined : ret; + }, + + attrHooks: { + type: { + set: function( elem, value ) { + if ( !support.radioValue && value === "radio" && + nodeName( elem, "input" ) ) { + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + } + }, + + removeAttr: function( elem, value ) { + var name, + i = 0, + + // Attribute names can contain non-HTML whitespace characters + // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 + attrNames = value && value.match( rnothtmlwhite ); + + if ( attrNames && elem.nodeType === 1 ) { + while ( ( name = attrNames[ i++ ] ) ) { + elem.removeAttribute( name ); + } + } + } +} ); + +// Hooks for boolean attributes +boolHook = { + set: function( elem, value, name ) { + if ( value === false ) { + + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + elem.setAttribute( name, name ); + } + return name; + } +}; + +jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) { + var getter = attrHandle[ name ] || jQuery.find.attr; + + attrHandle[ name ] = function( elem, name, isXML ) { + var ret, handle, + lowercaseName = name.toLowerCase(); + + if ( !isXML ) { + + // Avoid an infinite loop by temporarily removing this function from the getter + handle = attrHandle[ lowercaseName ]; + attrHandle[ lowercaseName ] = ret; + ret = getter( elem, name, isXML ) != null ? + lowercaseName : + null; + attrHandle[ lowercaseName ] = handle; + } + return ret; + }; +} ); + + + + +var rfocusable = /^(?:input|select|textarea|button)$/i, + rclickable = /^(?:a|area)$/i; + +jQuery.fn.extend( { + prop: function( name, value ) { + return access( this, jQuery.prop, name, value, arguments.length > 1 ); + }, + + removeProp: function( name ) { + return this.each( function() { + delete this[ jQuery.propFix[ name ] || name ]; + } ); + } +} ); + +jQuery.extend( { + prop: function( elem, name, value ) { + var ret, hooks, + nType = elem.nodeType; + + // Don't get/set properties on text, comment and attribute nodes + if ( nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { + + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && + ( ret = hooks.set( elem, value, name ) ) !== undefined ) { + return ret; + } + + return ( elem[ name ] = value ); + } + + if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { + return ret; + } + + return elem[ name ]; + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + + // Support: IE <=9 - 11 only + // elem.tabIndex doesn't always return the + // correct value when it hasn't been explicitly set + // Use proper attribute retrieval (trac-12072) + var tabindex = jQuery.find.attr( elem, "tabindex" ); + + if ( tabindex ) { + return parseInt( tabindex, 10 ); + } + + if ( + rfocusable.test( elem.nodeName ) || + rclickable.test( elem.nodeName ) && + elem.href + ) { + return 0; + } + + return -1; + } + } + }, + + propFix: { + "for": "htmlFor", + "class": "className" + } +} ); + +// Support: IE <=11 only +// Accessing the selectedIndex property +// forces the browser to respect setting selected +// on the option +// The getter ensures a default option is selected +// when in an optgroup +// eslint rule "no-unused-expressions" is disabled for this code +// since it considers such accessions noop +if ( !support.optSelected ) { + jQuery.propHooks.selected = { + get: function( elem ) { + + /* eslint no-unused-expressions: "off" */ + + var parent = elem.parentNode; + if ( parent && parent.parentNode ) { + parent.parentNode.selectedIndex; + } + return null; + }, + set: function( elem ) { + + /* eslint no-unused-expressions: "off" */ + + var parent = elem.parentNode; + if ( parent ) { + parent.selectedIndex; + + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + } + }; +} + +jQuery.each( [ + "tabIndex", + "readOnly", + "maxLength", + "cellSpacing", + "cellPadding", + "rowSpan", + "colSpan", + "useMap", + "frameBorder", + "contentEditable" +], function() { + jQuery.propFix[ this.toLowerCase() ] = this; +} ); + + + + + // Strip and collapse whitespace according to HTML spec + // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace + function stripAndCollapse( value ) { + var tokens = value.match( rnothtmlwhite ) || []; + return tokens.join( " " ); + } + + +function getClass( elem ) { + return elem.getAttribute && elem.getAttribute( "class" ) || ""; +} + +function classesToArray( value ) { + if ( Array.isArray( value ) ) { + return value; + } + if ( typeof value === "string" ) { + return value.match( rnothtmlwhite ) || []; + } + return []; +} + +jQuery.fn.extend( { + addClass: function( value ) { + var classNames, cur, curValue, className, i, finalValue; + + if ( isFunction( value ) ) { + return this.each( function( j ) { + jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); + } ); + } + + classNames = classesToArray( value ); + + if ( classNames.length ) { + return this.each( function() { + curValue = getClass( this ); + cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); + + if ( cur ) { + for ( i = 0; i < classNames.length; i++ ) { + className = classNames[ i ]; + if ( cur.indexOf( " " + className + " " ) < 0 ) { + cur += className + " "; + } + } + + // Only assign if different to avoid unneeded rendering. + finalValue = stripAndCollapse( cur ); + if ( curValue !== finalValue ) { + this.setAttribute( "class", finalValue ); + } + } + } ); + } + + return this; + }, + + removeClass: function( value ) { + var classNames, cur, curValue, className, i, finalValue; + + if ( isFunction( value ) ) { + return this.each( function( j ) { + jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); + } ); + } + + if ( !arguments.length ) { + return this.attr( "class", "" ); + } + + classNames = classesToArray( value ); + + if ( classNames.length ) { + return this.each( function() { + curValue = getClass( this ); + + // This expression is here for better compressibility (see addClass) + cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); + + if ( cur ) { + for ( i = 0; i < classNames.length; i++ ) { + className = classNames[ i ]; + + // Remove *all* instances + while ( cur.indexOf( " " + className + " " ) > -1 ) { + cur = cur.replace( " " + className + " ", " " ); + } + } + + // Only assign if different to avoid unneeded rendering. + finalValue = stripAndCollapse( cur ); + if ( curValue !== finalValue ) { + this.setAttribute( "class", finalValue ); + } + } + } ); + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var classNames, className, i, self, + type = typeof value, + isValidValue = type === "string" || Array.isArray( value ); + + if ( isFunction( value ) ) { + return this.each( function( i ) { + jQuery( this ).toggleClass( + value.call( this, i, getClass( this ), stateVal ), + stateVal + ); + } ); + } + + if ( typeof stateVal === "boolean" && isValidValue ) { + return stateVal ? this.addClass( value ) : this.removeClass( value ); + } + + classNames = classesToArray( value ); + + return this.each( function() { + if ( isValidValue ) { + + // Toggle individual class names + self = jQuery( this ); + + for ( i = 0; i < classNames.length; i++ ) { + className = classNames[ i ]; + + // Check each className given, space separated list + if ( self.hasClass( className ) ) { + self.removeClass( className ); + } else { + self.addClass( className ); + } + } + + // Toggle whole class name + } else if ( value === undefined || type === "boolean" ) { + className = getClass( this ); + if ( className ) { + + // Store className if set + dataPriv.set( this, "__className__", className ); + } + + // If the element has a class name or if we're passed `false`, + // then remove the whole classname (if there was one, the above saved it). + // Otherwise bring back whatever was previously saved (if anything), + // falling back to the empty string if nothing was stored. + if ( this.setAttribute ) { + this.setAttribute( "class", + className || value === false ? + "" : + dataPriv.get( this, "__className__" ) || "" + ); + } + } + } ); + }, + + hasClass: function( selector ) { + var className, elem, + i = 0; + + className = " " + selector + " "; + while ( ( elem = this[ i++ ] ) ) { + if ( elem.nodeType === 1 && + ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { + return true; + } + } + + return false; + } +} ); + + + + +var rreturn = /\r/g; + +jQuery.fn.extend( { + val: function( value ) { + var hooks, ret, valueIsFunction, + elem = this[ 0 ]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.type ] || + jQuery.valHooks[ elem.nodeName.toLowerCase() ]; + + if ( hooks && + "get" in hooks && + ( ret = hooks.get( elem, "value" ) ) !== undefined + ) { + return ret; + } + + ret = elem.value; + + // Handle most common string cases + if ( typeof ret === "string" ) { + return ret.replace( rreturn, "" ); + } + + // Handle cases where value is null/undef or number + return ret == null ? "" : ret; + } + + return; + } + + valueIsFunction = isFunction( value ); + + return this.each( function( i ) { + var val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( valueIsFunction ) { + val = value.call( this, i, jQuery( this ).val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + + } else if ( typeof val === "number" ) { + val += ""; + + } else if ( Array.isArray( val ) ) { + val = jQuery.map( val, function( value ) { + return value == null ? "" : value + ""; + } ); + } + + hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + } ); + } +} ); + +jQuery.extend( { + valHooks: { + option: { + get: function( elem ) { + + var val = jQuery.find.attr( elem, "value" ); + return val != null ? + val : + + // Support: IE <=10 - 11 only + // option.text throws exceptions (trac-14686, trac-14858) + // Strip and collapse whitespace + // https://html.spec.whatwg.org/#strip-and-collapse-whitespace + stripAndCollapse( jQuery.text( elem ) ); + } + }, + select: { + get: function( elem ) { + var value, option, i, + options = elem.options, + index = elem.selectedIndex, + one = elem.type === "select-one", + values = one ? null : [], + max = one ? index + 1 : options.length; + + if ( index < 0 ) { + i = max; + + } else { + i = one ? index : 0; + } + + // Loop through all the selected options + for ( ; i < max; i++ ) { + option = options[ i ]; + + // Support: IE <=9 only + // IE8-9 doesn't update selected after form reset (trac-2551) + if ( ( option.selected || i === index ) && + + // Don't return options that are disabled or in a disabled optgroup + !option.disabled && + ( !option.parentNode.disabled || + !nodeName( option.parentNode, "optgroup" ) ) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + return values; + }, + + set: function( elem, value ) { + var optionSet, option, + options = elem.options, + values = jQuery.makeArray( value ), + i = options.length; + + while ( i-- ) { + option = options[ i ]; + + /* eslint-disable no-cond-assign */ + + if ( option.selected = + jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 + ) { + optionSet = true; + } + + /* eslint-enable no-cond-assign */ + } + + // Force browsers to behave consistently when non-matching value is set + if ( !optionSet ) { + elem.selectedIndex = -1; + } + return values; + } + } + } +} ); + +// Radios and checkboxes getter/setter +jQuery.each( [ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + set: function( elem, value ) { + if ( Array.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); + } + } + }; + if ( !support.checkOn ) { + jQuery.valHooks[ this ].get = function( elem ) { + return elem.getAttribute( "value" ) === null ? "on" : elem.value; + }; + } +} ); + + + + +// Return jQuery for attributes-only inclusion +var location = window.location; + +var nonce = { guid: Date.now() }; + +var rquery = ( /\?/ ); + + + +// Cross-browser xml parsing +jQuery.parseXML = function( data ) { + var xml, parserErrorElem; + if ( !data || typeof data !== "string" ) { + return null; + } + + // Support: IE 9 - 11 only + // IE throws on parseFromString with invalid input. + try { + xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); + } catch ( e ) {} + + parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ]; + if ( !xml || parserErrorElem ) { + jQuery.error( "Invalid XML: " + ( + parserErrorElem ? + jQuery.map( parserErrorElem.childNodes, function( el ) { + return el.textContent; + } ).join( "\n" ) : + data + ) ); + } + return xml; +}; + + +var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + stopPropagationCallback = function( e ) { + e.stopPropagation(); + }; + +jQuery.extend( jQuery.event, { + + trigger: function( event, data, elem, onlyHandlers ) { + + var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, + eventPath = [ elem || document ], + type = hasOwn.call( event, "type" ) ? event.type : event, + namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; + + cur = lastElement = tmp = elem = elem || document; + + // Don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf( "." ) > -1 ) { + + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split( "." ); + type = namespaces.shift(); + namespaces.sort(); + } + ontype = type.indexOf( ":" ) < 0 && "on" + type; + + // Caller can pass in a jQuery.Event object, Object, or just an event type string + event = event[ jQuery.expando ] ? + event : + new jQuery.Event( type, typeof event === "object" && event ); + + // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) + event.isTrigger = onlyHandlers ? 2 : 3; + event.namespace = namespaces.join( "." ); + event.rnamespace = event.namespace ? + new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : + null; + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data == null ? + [ event ] : + jQuery.makeArray( data, [ event ] ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (trac-9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (trac-9724) + if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + if ( !rfocusMorph.test( bubbleType + type ) ) { + cur = cur.parentNode; + } + for ( ; cur; cur = cur.parentNode ) { + eventPath.push( cur ); + tmp = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( tmp === ( elem.ownerDocument || document ) ) { + eventPath.push( tmp.defaultView || tmp.parentWindow || window ); + } + } + + // Fire handlers on the event path + i = 0; + while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { + lastElement = cur; + event.type = i > 1 ? + bubbleType : + special.bindType || type; + + // jQuery handler + handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] && + dataPriv.get( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + + // Native handler + handle = ontype && cur[ ontype ]; + if ( handle && handle.apply && acceptData( cur ) ) { + event.result = handle.apply( cur, data ); + if ( event.result === false ) { + event.preventDefault(); + } + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( ( !special._default || + special._default.apply( eventPath.pop(), data ) === false ) && + acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name as the event. + // Don't do default actions on window, that's where global variables be (trac-6170) + if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + tmp = elem[ ontype ]; + + if ( tmp ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + + if ( event.isPropagationStopped() ) { + lastElement.addEventListener( type, stopPropagationCallback ); + } + + elem[ type ](); + + if ( event.isPropagationStopped() ) { + lastElement.removeEventListener( type, stopPropagationCallback ); + } + + jQuery.event.triggered = undefined; + + if ( tmp ) { + elem[ ontype ] = tmp; + } + } + } + } + + return event.result; + }, + + // Piggyback on a donor event to simulate a different one + // Used only for `focus(in | out)` events + simulate: function( type, elem, event ) { + var e = jQuery.extend( + new jQuery.Event(), + event, + { + type: type, + isSimulated: true + } + ); + + jQuery.event.trigger( e, null, elem ); + } + +} ); + +jQuery.fn.extend( { + + trigger: function( type, data ) { + return this.each( function() { + jQuery.event.trigger( type, data, this ); + } ); + }, + triggerHandler: function( type, data ) { + var elem = this[ 0 ]; + if ( elem ) { + return jQuery.event.trigger( type, data, elem, true ); + } + } +} ); + + +var + rbracket = /\[\]$/, + rCRLF = /\r?\n/g, + rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, + rsubmittable = /^(?:input|select|textarea|keygen)/i; + +function buildParams( prefix, obj, traditional, add ) { + var name; + + if ( Array.isArray( obj ) ) { + + // Serialize array item. + jQuery.each( obj, function( i, v ) { + if ( traditional || rbracket.test( prefix ) ) { + + // Treat each array item as a scalar. + add( prefix, v ); + + } else { + + // Item is non-scalar (array or object), encode its numeric index. + buildParams( + prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", + v, + traditional, + add + ); + } + } ); + + } else if ( !traditional && toType( obj ) === "object" ) { + + // Serialize object item. + for ( name in obj ) { + buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); + } + + } else { + + // Serialize scalar item. + add( prefix, obj ); + } +} + +// Serialize an array of form elements or a set of +// key/values into a query string +jQuery.param = function( a, traditional ) { + var prefix, + s = [], + add = function( key, valueOrFunction ) { + + // If value is a function, invoke it and use its return value + var value = isFunction( valueOrFunction ) ? + valueOrFunction() : + valueOrFunction; + + s[ s.length ] = encodeURIComponent( key ) + "=" + + encodeURIComponent( value == null ? "" : value ); + }; + + if ( a == null ) { + return ""; + } + + // If an array was passed in, assume that it is an array of form elements. + if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { + + // Serialize the form elements + jQuery.each( a, function() { + add( this.name, this.value ); + } ); + + } else { + + // If traditional, encode the "old" way (the way 1.3.2 or older + // did it), otherwise encode params recursively. + for ( prefix in a ) { + buildParams( prefix, a[ prefix ], traditional, add ); + } + } + + // Return the resulting serialization + return s.join( "&" ); +}; + +jQuery.fn.extend( { + serialize: function() { + return jQuery.param( this.serializeArray() ); + }, + serializeArray: function() { + return this.map( function() { + + // Can add propHook for "elements" to filter or add form elements + var elements = jQuery.prop( this, "elements" ); + return elements ? jQuery.makeArray( elements ) : this; + } ).filter( function() { + var type = this.type; + + // Use .is( ":disabled" ) so that fieldset[disabled] works + return this.name && !jQuery( this ).is( ":disabled" ) && + rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && + ( this.checked || !rcheckableType.test( type ) ); + } ).map( function( _i, elem ) { + var val = jQuery( this ).val(); + + if ( val == null ) { + return null; + } + + if ( Array.isArray( val ) ) { + return jQuery.map( val, function( val ) { + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; + } ); + } + + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; + } ).get(); + } +} ); + + +var + r20 = /%20/g, + rhash = /#.*$/, + rantiCache = /([?&])_=[^&]*/, + rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, + + // trac-7653, trac-8125, trac-8152: local protocol detection + rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, + rnoContent = /^(?:GET|HEAD)$/, + rprotocol = /^\/\//, + + /* Prefilters + * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) + * 2) These are called: + * - BEFORE asking for a transport + * - AFTER param serialization (s.data is a string if s.processData is true) + * 3) key is the dataType + * 4) the catchall symbol "*" can be used + * 5) execution will start with transport dataType and THEN continue down to "*" if needed + */ + prefilters = {}, + + /* Transports bindings + * 1) key is the dataType + * 2) the catchall symbol "*" can be used + * 3) selection will start with transport dataType and THEN go to "*" if needed + */ + transports = {}, + + // Avoid comment-prolog char sequence (trac-10098); must appease lint and evade compression + allTypes = "*/".concat( "*" ), + + // Anchor tag for parsing the document origin + originAnchor = document.createElement( "a" ); + +originAnchor.href = location.href; + +// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport +function addToPrefiltersOrTransports( structure ) { + + // dataTypeExpression is optional and defaults to "*" + return function( dataTypeExpression, func ) { + + if ( typeof dataTypeExpression !== "string" ) { + func = dataTypeExpression; + dataTypeExpression = "*"; + } + + var dataType, + i = 0, + dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || []; + + if ( isFunction( func ) ) { + + // For each dataType in the dataTypeExpression + while ( ( dataType = dataTypes[ i++ ] ) ) { + + // Prepend if requested + if ( dataType[ 0 ] === "+" ) { + dataType = dataType.slice( 1 ) || "*"; + ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); + + // Otherwise append + } else { + ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); + } + } + } + }; +} + +// Base inspection function for prefilters and transports +function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { + + var inspected = {}, + seekingTransport = ( structure === transports ); + + function inspect( dataType ) { + var selected; + inspected[ dataType ] = true; + jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { + var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); + if ( typeof dataTypeOrTransport === "string" && + !seekingTransport && !inspected[ dataTypeOrTransport ] ) { + + options.dataTypes.unshift( dataTypeOrTransport ); + inspect( dataTypeOrTransport ); + return false; + } else if ( seekingTransport ) { + return !( selected = dataTypeOrTransport ); + } + } ); + return selected; + } + + return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); +} + +// A special extend for ajax options +// that takes "flat" options (not to be deep extended) +// Fixes trac-9887 +function ajaxExtend( target, src ) { + var key, deep, + flatOptions = jQuery.ajaxSettings.flatOptions || {}; + + for ( key in src ) { + if ( src[ key ] !== undefined ) { + ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; + } + } + if ( deep ) { + jQuery.extend( true, target, deep ); + } + + return target; +} + +/* Handles responses to an ajax request: + * - finds the right dataType (mediates between content-type and expected dataType) + * - returns the corresponding response + */ +function ajaxHandleResponses( s, jqXHR, responses ) { + + var ct, type, finalDataType, firstDataType, + contents = s.contents, + dataTypes = s.dataTypes; + + // Remove auto dataType and get content-type in the process + while ( dataTypes[ 0 ] === "*" ) { + dataTypes.shift(); + if ( ct === undefined ) { + ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); + } + } + + // Check if we're dealing with a known content-type + if ( ct ) { + for ( type in contents ) { + if ( contents[ type ] && contents[ type ].test( ct ) ) { + dataTypes.unshift( type ); + break; + } + } + } + + // Check to see if we have a response for the expected dataType + if ( dataTypes[ 0 ] in responses ) { + finalDataType = dataTypes[ 0 ]; + } else { + + // Try convertible dataTypes + for ( type in responses ) { + if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { + finalDataType = type; + break; + } + if ( !firstDataType ) { + firstDataType = type; + } + } + + // Or just use first one + finalDataType = finalDataType || firstDataType; + } + + // If we found a dataType + // We add the dataType to the list if needed + // and return the corresponding response + if ( finalDataType ) { + if ( finalDataType !== dataTypes[ 0 ] ) { + dataTypes.unshift( finalDataType ); + } + return responses[ finalDataType ]; + } +} + +/* Chain conversions given the request and the original response + * Also sets the responseXXX fields on the jqXHR instance + */ +function ajaxConvert( s, response, jqXHR, isSuccess ) { + var conv2, current, conv, tmp, prev, + converters = {}, + + // Work with a copy of dataTypes in case we need to modify it for conversion + dataTypes = s.dataTypes.slice(); + + // Create converters map with lowercased keys + if ( dataTypes[ 1 ] ) { + for ( conv in s.converters ) { + converters[ conv.toLowerCase() ] = s.converters[ conv ]; + } + } + + current = dataTypes.shift(); + + // Convert to each sequential dataType + while ( current ) { + + if ( s.responseFields[ current ] ) { + jqXHR[ s.responseFields[ current ] ] = response; + } + + // Apply the dataFilter if provided + if ( !prev && isSuccess && s.dataFilter ) { + response = s.dataFilter( response, s.dataType ); + } + + prev = current; + current = dataTypes.shift(); + + if ( current ) { + + // There's only work to do if current dataType is non-auto + if ( current === "*" ) { + + current = prev; + + // Convert response if prev dataType is non-auto and differs from current + } else if ( prev !== "*" && prev !== current ) { + + // Seek a direct converter + conv = converters[ prev + " " + current ] || converters[ "* " + current ]; + + // If none found, seek a pair + if ( !conv ) { + for ( conv2 in converters ) { + + // If conv2 outputs current + tmp = conv2.split( " " ); + if ( tmp[ 1 ] === current ) { + + // If prev can be converted to accepted input + conv = converters[ prev + " " + tmp[ 0 ] ] || + converters[ "* " + tmp[ 0 ] ]; + if ( conv ) { + + // Condense equivalence converters + if ( conv === true ) { + conv = converters[ conv2 ]; + + // Otherwise, insert the intermediate dataType + } else if ( converters[ conv2 ] !== true ) { + current = tmp[ 0 ]; + dataTypes.unshift( tmp[ 1 ] ); + } + break; + } + } + } + } + + // Apply converter (if not an equivalence) + if ( conv !== true ) { + + // Unless errors are allowed to bubble, catch and return them + if ( conv && s.throws ) { + response = conv( response ); + } else { + try { + response = conv( response ); + } catch ( e ) { + return { + state: "parsererror", + error: conv ? e : "No conversion from " + prev + " to " + current + }; + } + } + } + } + } + } + + return { state: "success", data: response }; +} + +jQuery.extend( { + + // Counter for holding the number of active queries + active: 0, + + // Last-Modified header cache for next request + lastModified: {}, + etag: {}, + + ajaxSettings: { + url: location.href, + type: "GET", + isLocal: rlocalProtocol.test( location.protocol ), + global: true, + processData: true, + async: true, + contentType: "application/x-www-form-urlencoded; charset=UTF-8", + + /* + timeout: 0, + data: null, + dataType: null, + username: null, + password: null, + cache: null, + throws: false, + traditional: false, + headers: {}, + */ + + accepts: { + "*": allTypes, + text: "text/plain", + html: "text/html", + xml: "application/xml, text/xml", + json: "application/json, text/javascript" + }, + + contents: { + xml: /\bxml\b/, + html: /\bhtml/, + json: /\bjson\b/ + }, + + responseFields: { + xml: "responseXML", + text: "responseText", + json: "responseJSON" + }, + + // Data converters + // Keys separate source (or catchall "*") and destination types with a single space + converters: { + + // Convert anything to text + "* text": String, + + // Text to html (true = no transformation) + "text html": true, + + // Evaluate text as a json expression + "text json": JSON.parse, + + // Parse text as xml + "text xml": jQuery.parseXML + }, + + // For options that shouldn't be deep extended: + // you can add your own custom options here if + // and when you create one that shouldn't be + // deep extended (see ajaxExtend) + flatOptions: { + url: true, + context: true + } + }, + + // Creates a full fledged settings object into target + // with both ajaxSettings and settings fields. + // If target is omitted, writes into ajaxSettings. + ajaxSetup: function( target, settings ) { + return settings ? + + // Building a settings object + ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : + + // Extending ajaxSettings + ajaxExtend( jQuery.ajaxSettings, target ); + }, + + ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), + ajaxTransport: addToPrefiltersOrTransports( transports ), + + // Main method + ajax: function( url, options ) { + + // If url is an object, simulate pre-1.5 signature + if ( typeof url === "object" ) { + options = url; + url = undefined; + } + + // Force options to be an object + options = options || {}; + + var transport, + + // URL without anti-cache param + cacheURL, + + // Response headers + responseHeadersString, + responseHeaders, + + // timeout handle + timeoutTimer, + + // Url cleanup var + urlAnchor, + + // Request state (becomes false upon send and true upon completion) + completed, + + // To know if global events are to be dispatched + fireGlobals, + + // Loop variable + i, + + // uncached part of the url + uncached, + + // Create the final options object + s = jQuery.ajaxSetup( {}, options ), + + // Callbacks context + callbackContext = s.context || s, + + // Context for global events is callbackContext if it is a DOM node or jQuery collection + globalEventContext = s.context && + ( callbackContext.nodeType || callbackContext.jquery ) ? + jQuery( callbackContext ) : + jQuery.event, + + // Deferreds + deferred = jQuery.Deferred(), + completeDeferred = jQuery.Callbacks( "once memory" ), + + // Status-dependent callbacks + statusCode = s.statusCode || {}, + + // Headers (they are sent all at once) + requestHeaders = {}, + requestHeadersNames = {}, + + // Default abort message + strAbort = "canceled", + + // Fake xhr + jqXHR = { + readyState: 0, + + // Builds headers hashtable if needed + getResponseHeader: function( key ) { + var match; + if ( completed ) { + if ( !responseHeaders ) { + responseHeaders = {}; + while ( ( match = rheaders.exec( responseHeadersString ) ) ) { + responseHeaders[ match[ 1 ].toLowerCase() + " " ] = + ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) + .concat( match[ 2 ] ); + } + } + match = responseHeaders[ key.toLowerCase() + " " ]; + } + return match == null ? null : match.join( ", " ); + }, + + // Raw string + getAllResponseHeaders: function() { + return completed ? responseHeadersString : null; + }, + + // Caches the header + setRequestHeader: function( name, value ) { + if ( completed == null ) { + name = requestHeadersNames[ name.toLowerCase() ] = + requestHeadersNames[ name.toLowerCase() ] || name; + requestHeaders[ name ] = value; + } + return this; + }, + + // Overrides response content-type header + overrideMimeType: function( type ) { + if ( completed == null ) { + s.mimeType = type; + } + return this; + }, + + // Status-dependent callbacks + statusCode: function( map ) { + var code; + if ( map ) { + if ( completed ) { + + // Execute the appropriate callbacks + jqXHR.always( map[ jqXHR.status ] ); + } else { + + // Lazy-add the new callbacks in a way that preserves old ones + for ( code in map ) { + statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; + } + } + } + return this; + }, + + // Cancel the request + abort: function( statusText ) { + var finalText = statusText || strAbort; + if ( transport ) { + transport.abort( finalText ); + } + done( 0, finalText ); + return this; + } + }; + + // Attach deferreds + deferred.promise( jqXHR ); + + // Add protocol if not provided (prefilters might expect it) + // Handle falsy url in the settings object (trac-10093: consistency with old signature) + // We also use the url parameter if available + s.url = ( ( url || s.url || location.href ) + "" ) + .replace( rprotocol, location.protocol + "//" ); + + // Alias method option to type as per ticket trac-12004 + s.type = options.method || options.type || s.method || s.type; + + // Extract dataTypes list + s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ]; + + // A cross-domain request is in order when the origin doesn't match the current origin. + if ( s.crossDomain == null ) { + urlAnchor = document.createElement( "a" ); + + // Support: IE <=8 - 11, Edge 12 - 15 + // IE throws exception on accessing the href property if url is malformed, + // e.g. http://example.com:80x/ + try { + urlAnchor.href = s.url; + + // Support: IE <=8 - 11 only + // Anchor's host property isn't correctly set when s.url is relative + urlAnchor.href = urlAnchor.href; + s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== + urlAnchor.protocol + "//" + urlAnchor.host; + } catch ( e ) { + + // If there is an error parsing the URL, assume it is crossDomain, + // it can be rejected by the transport if it is invalid + s.crossDomain = true; + } + } + + // Convert data if not already a string + if ( s.data && s.processData && typeof s.data !== "string" ) { + s.data = jQuery.param( s.data, s.traditional ); + } + + // Apply prefilters + inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); + + // If request was aborted inside a prefilter, stop there + if ( completed ) { + return jqXHR; + } + + // We can fire global events as of now if asked to + // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (trac-15118) + fireGlobals = jQuery.event && s.global; + + // Watch for a new set of requests + if ( fireGlobals && jQuery.active++ === 0 ) { + jQuery.event.trigger( "ajaxStart" ); + } + + // Uppercase the type + s.type = s.type.toUpperCase(); + + // Determine if request has content + s.hasContent = !rnoContent.test( s.type ); + + // Save the URL in case we're toying with the If-Modified-Since + // and/or If-None-Match header later on + // Remove hash to simplify url manipulation + cacheURL = s.url.replace( rhash, "" ); + + // More options handling for requests with no content + if ( !s.hasContent ) { + + // Remember the hash so we can put it back + uncached = s.url.slice( cacheURL.length ); + + // If data is available and should be processed, append data to url + if ( s.data && ( s.processData || typeof s.data === "string" ) ) { + cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; + + // trac-9682: remove data so that it's not used in an eventual retry + delete s.data; + } + + // Add or update anti-cache param if needed + if ( s.cache === false ) { + cacheURL = cacheURL.replace( rantiCache, "$1" ); + uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) + + uncached; + } + + // Put hash and anti-cache on the URL that will be requested (gh-1732) + s.url = cacheURL + uncached; + + // Change '%20' to '+' if this is encoded form body content (gh-2658) + } else if ( s.data && s.processData && + ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) { + s.data = s.data.replace( r20, "+" ); + } + + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. + if ( s.ifModified ) { + if ( jQuery.lastModified[ cacheURL ] ) { + jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); + } + if ( jQuery.etag[ cacheURL ] ) { + jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); + } + } + + // Set the correct header, if data is being sent + if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { + jqXHR.setRequestHeader( "Content-Type", s.contentType ); + } + + // Set the Accepts header for the server, depending on the dataType + jqXHR.setRequestHeader( + "Accept", + s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? + s.accepts[ s.dataTypes[ 0 ] ] + + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : + s.accepts[ "*" ] + ); + + // Check for headers option + for ( i in s.headers ) { + jqXHR.setRequestHeader( i, s.headers[ i ] ); + } + + // Allow custom headers/mimetypes and early abort + if ( s.beforeSend && + ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) { + + // Abort if not done already and return + return jqXHR.abort(); + } + + // Aborting is no longer a cancellation + strAbort = "abort"; + + // Install callbacks on deferreds + completeDeferred.add( s.complete ); + jqXHR.done( s.success ); + jqXHR.fail( s.error ); + + // Get transport + transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); + + // If no transport, we auto-abort + if ( !transport ) { + done( -1, "No Transport" ); + } else { + jqXHR.readyState = 1; + + // Send global event + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); + } + + // If request was aborted inside ajaxSend, stop there + if ( completed ) { + return jqXHR; + } + + // Timeout + if ( s.async && s.timeout > 0 ) { + timeoutTimer = window.setTimeout( function() { + jqXHR.abort( "timeout" ); + }, s.timeout ); + } + + try { + completed = false; + transport.send( requestHeaders, done ); + } catch ( e ) { + + // Rethrow post-completion exceptions + if ( completed ) { + throw e; + } + + // Propagate others as results + done( -1, e ); + } + } + + // Callback for when everything is done + function done( status, nativeStatusText, responses, headers ) { + var isSuccess, success, error, response, modified, + statusText = nativeStatusText; + + // Ignore repeat invocations + if ( completed ) { + return; + } + + completed = true; + + // Clear timeout if it exists + if ( timeoutTimer ) { + window.clearTimeout( timeoutTimer ); + } + + // Dereference transport for early garbage collection + // (no matter how long the jqXHR object will be used) + transport = undefined; + + // Cache response headers + responseHeadersString = headers || ""; + + // Set readyState + jqXHR.readyState = status > 0 ? 4 : 0; + + // Determine if successful + isSuccess = status >= 200 && status < 300 || status === 304; + + // Get response data + if ( responses ) { + response = ajaxHandleResponses( s, jqXHR, responses ); + } + + // Use a noop converter for missing script but not if jsonp + if ( !isSuccess && + jQuery.inArray( "script", s.dataTypes ) > -1 && + jQuery.inArray( "json", s.dataTypes ) < 0 ) { + s.converters[ "text script" ] = function() {}; + } + + // Convert no matter what (that way responseXXX fields are always set) + response = ajaxConvert( s, response, jqXHR, isSuccess ); + + // If successful, handle type chaining + if ( isSuccess ) { + + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. + if ( s.ifModified ) { + modified = jqXHR.getResponseHeader( "Last-Modified" ); + if ( modified ) { + jQuery.lastModified[ cacheURL ] = modified; + } + modified = jqXHR.getResponseHeader( "etag" ); + if ( modified ) { + jQuery.etag[ cacheURL ] = modified; + } + } + + // if no content + if ( status === 204 || s.type === "HEAD" ) { + statusText = "nocontent"; + + // if not modified + } else if ( status === 304 ) { + statusText = "notmodified"; + + // If we have data, let's convert it + } else { + statusText = response.state; + success = response.data; + error = response.error; + isSuccess = !error; + } + } else { + + // Extract error from statusText and normalize for non-aborts + error = statusText; + if ( status || !statusText ) { + statusText = "error"; + if ( status < 0 ) { + status = 0; + } + } + } + + // Set data for the fake xhr object + jqXHR.status = status; + jqXHR.statusText = ( nativeStatusText || statusText ) + ""; + + // Success/Error + if ( isSuccess ) { + deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); + } else { + deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); + } + + // Status-dependent callbacks + jqXHR.statusCode( statusCode ); + statusCode = undefined; + + if ( fireGlobals ) { + globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", + [ jqXHR, s, isSuccess ? success : error ] ); + } + + // Complete + completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); + + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); + + // Handle the global AJAX counter + if ( !( --jQuery.active ) ) { + jQuery.event.trigger( "ajaxStop" ); + } + } + } + + return jqXHR; + }, + + getJSON: function( url, data, callback ) { + return jQuery.get( url, data, callback, "json" ); + }, + + getScript: function( url, callback ) { + return jQuery.get( url, undefined, callback, "script" ); + } +} ); + +jQuery.each( [ "get", "post" ], function( _i, method ) { + jQuery[ method ] = function( url, data, callback, type ) { + + // Shift arguments if data argument was omitted + if ( isFunction( data ) ) { + type = type || callback; + callback = data; + data = undefined; + } + + // The url can be an options object (which then must have .url) + return jQuery.ajax( jQuery.extend( { + url: url, + type: method, + dataType: type, + data: data, + success: callback + }, jQuery.isPlainObject( url ) && url ) ); + }; +} ); + +jQuery.ajaxPrefilter( function( s ) { + var i; + for ( i in s.headers ) { + if ( i.toLowerCase() === "content-type" ) { + s.contentType = s.headers[ i ] || ""; + } + } +} ); + + +jQuery._evalUrl = function( url, options, doc ) { + return jQuery.ajax( { + url: url, + + // Make this explicit, since user can override this through ajaxSetup (trac-11264) + type: "GET", + dataType: "script", + cache: true, + async: false, + global: false, + + // Only evaluate the response if it is successful (gh-4126) + // dataFilter is not invoked for failure responses, so using it instead + // of the default converter is kludgy but it works. + converters: { + "text script": function() {} + }, + dataFilter: function( response ) { + jQuery.globalEval( response, options, doc ); + } + } ); +}; + + +jQuery.fn.extend( { + wrapAll: function( html ) { + var wrap; + + if ( this[ 0 ] ) { + if ( isFunction( html ) ) { + html = html.call( this[ 0 ] ); + } + + // The elements to wrap the target around + wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); + + if ( this[ 0 ].parentNode ) { + wrap.insertBefore( this[ 0 ] ); + } + + wrap.map( function() { + var elem = this; + + while ( elem.firstElementChild ) { + elem = elem.firstElementChild; + } + + return elem; + } ).append( this ); + } + + return this; + }, + + wrapInner: function( html ) { + if ( isFunction( html ) ) { + return this.each( function( i ) { + jQuery( this ).wrapInner( html.call( this, i ) ); + } ); + } + + return this.each( function() { + var self = jQuery( this ), + contents = self.contents(); + + if ( contents.length ) { + contents.wrapAll( html ); + + } else { + self.append( html ); + } + } ); + }, + + wrap: function( html ) { + var htmlIsFunction = isFunction( html ); + + return this.each( function( i ) { + jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html ); + } ); + }, + + unwrap: function( selector ) { + this.parent( selector ).not( "body" ).each( function() { + jQuery( this ).replaceWith( this.childNodes ); + } ); + return this; + } +} ); + + +jQuery.expr.pseudos.hidden = function( elem ) { + return !jQuery.expr.pseudos.visible( elem ); +}; +jQuery.expr.pseudos.visible = function( elem ) { + return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); +}; + + + + +jQuery.ajaxSettings.xhr = function() { + try { + return new window.XMLHttpRequest(); + } catch ( e ) {} +}; + +var xhrSuccessStatus = { + + // File protocol always yields status code 0, assume 200 + 0: 200, + + // Support: IE <=9 only + // trac-1450: sometimes IE returns 1223 when it should be 204 + 1223: 204 + }, + xhrSupported = jQuery.ajaxSettings.xhr(); + +support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); +support.ajax = xhrSupported = !!xhrSupported; + +jQuery.ajaxTransport( function( options ) { + var callback, errorCallback; + + // Cross domain only allowed if supported through XMLHttpRequest + if ( support.cors || xhrSupported && !options.crossDomain ) { + return { + send: function( headers, complete ) { + var i, + xhr = options.xhr(); + + xhr.open( + options.type, + options.url, + options.async, + options.username, + options.password + ); + + // Apply custom fields if provided + if ( options.xhrFields ) { + for ( i in options.xhrFields ) { + xhr[ i ] = options.xhrFields[ i ]; + } + } + + // Override mime type if needed + if ( options.mimeType && xhr.overrideMimeType ) { + xhr.overrideMimeType( options.mimeType ); + } + + // X-Requested-With header + // For cross-domain requests, seeing as conditions for a preflight are + // akin to a jigsaw puzzle, we simply never set it to be sure. + // (it can always be set on a per-request basis or even using ajaxSetup) + // For same-domain requests, won't change header if already provided. + if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { + headers[ "X-Requested-With" ] = "XMLHttpRequest"; + } + + // Set headers + for ( i in headers ) { + xhr.setRequestHeader( i, headers[ i ] ); + } + + // Callback + callback = function( type ) { + return function() { + if ( callback ) { + callback = errorCallback = xhr.onload = + xhr.onerror = xhr.onabort = xhr.ontimeout = + xhr.onreadystatechange = null; + + if ( type === "abort" ) { + xhr.abort(); + } else if ( type === "error" ) { + + // Support: IE <=9 only + // On a manual native abort, IE9 throws + // errors on any property access that is not readyState + if ( typeof xhr.status !== "number" ) { + complete( 0, "error" ); + } else { + complete( + + // File: protocol always yields status 0; see trac-8605, trac-14207 + xhr.status, + xhr.statusText + ); + } + } else { + complete( + xhrSuccessStatus[ xhr.status ] || xhr.status, + xhr.statusText, + + // Support: IE <=9 only + // IE9 has no XHR2 but throws on binary (trac-11426) + // For XHR2 non-text, let the caller handle it (gh-2498) + ( xhr.responseType || "text" ) !== "text" || + typeof xhr.responseText !== "string" ? + { binary: xhr.response } : + { text: xhr.responseText }, + xhr.getAllResponseHeaders() + ); + } + } + }; + }; + + // Listen to events + xhr.onload = callback(); + errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" ); + + // Support: IE 9 only + // Use onreadystatechange to replace onabort + // to handle uncaught aborts + if ( xhr.onabort !== undefined ) { + xhr.onabort = errorCallback; + } else { + xhr.onreadystatechange = function() { + + // Check readyState before timeout as it changes + if ( xhr.readyState === 4 ) { + + // Allow onerror to be called first, + // but that will not handle a native abort + // Also, save errorCallback to a variable + // as xhr.onerror cannot be accessed + window.setTimeout( function() { + if ( callback ) { + errorCallback(); + } + } ); + } + }; + } + + // Create the abort callback + callback = callback( "abort" ); + + try { + + // Do send the request (this may raise an exception) + xhr.send( options.hasContent && options.data || null ); + } catch ( e ) { + + // trac-14683: Only rethrow if this hasn't been notified as an error yet + if ( callback ) { + throw e; + } + } + }, + + abort: function() { + if ( callback ) { + callback(); + } + } + }; + } +} ); + + + + +// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) +jQuery.ajaxPrefilter( function( s ) { + if ( s.crossDomain ) { + s.contents.script = false; + } +} ); + +// Install script dataType +jQuery.ajaxSetup( { + accepts: { + script: "text/javascript, application/javascript, " + + "application/ecmascript, application/x-ecmascript" + }, + contents: { + script: /\b(?:java|ecma)script\b/ + }, + converters: { + "text script": function( text ) { + jQuery.globalEval( text ); + return text; + } + } +} ); + +// Handle cache's special case and crossDomain +jQuery.ajaxPrefilter( "script", function( s ) { + if ( s.cache === undefined ) { + s.cache = false; + } + if ( s.crossDomain ) { + s.type = "GET"; + } +} ); + +// Bind script tag hack transport +jQuery.ajaxTransport( "script", function( s ) { + + // This transport only deals with cross domain or forced-by-attrs requests + if ( s.crossDomain || s.scriptAttrs ) { + var script, callback; + return { + send: function( _, complete ) { + script = jQuery( " + <%-- refresh()函数以500毫秒为间隔,连续地局部刷新div层divMsg。其中$.ajax()调用jQuery提供的ajax()方法,用于执行异步请求 --%> + + + +
+
+
+ +
+ +
+ +
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Chat.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Chat.aspx.cs" new file mode 100644 index 0000000..7db4d51 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Chat.aspx.cs" @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Ex3 +{ + public partial class Chat : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + lb1Name.Text = "发言人:" + Session["user"]; + if (!IsPostBack) + { + Application["message"] = Session["user"] + "进入聊天室
" + Application["message"]; + } + } + + protected void BtnSend_Click(object sender, EventArgs e) + { + Application.Lock(); + Application["message"] = Session["user"] + "说:" + txtMessage.Text + "(" + DateTime.Now.ToString() + ")
" + Application["message"]; + Application.UnLock(); + txtMessage.Text = ""; + } + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Chat.aspx.designer.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Chat.aspx.designer.cs" new file mode 100644 index 0000000..bc82f5e --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Chat.aspx.designer.cs" @@ -0,0 +1,53 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace Ex3 +{ + + + public partial class Chat + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// lb1Name 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label lb1Name; + + /// + /// txtMessage 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtMessage; + + /// + /// btnSend 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnSend; + } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ChatLogin.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ChatLogin.aspx" new file mode 100644 index 0000000..8973447 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ChatLogin.aspx" @@ -0,0 +1,59 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChatLogin.aspx.cs" Inherits="Ex3.ChatLogin" %> + + + + + + 聊天室用户登录 + + + +
+
+ + + + + + + + + + + + + + + + + + + +
我的聊天室 +
用户名: + + + + * +
密码: + + + + * +
  + + +   +
+
+
+ + + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ChatLogin.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ChatLogin.aspx.cs" new file mode 100644 index 0000000..a745970 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ChatLogin.aspx.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Xml.Linq; + +namespace Ex3 +{ + public partial class ChatLogin : System.Web.UI.Page + { + string[,] user = { { "zny", "111111" }, { "test", "111111" } }; + protected void Page_Load(object sender, EventArgs e) + { + txtName.Focus(); + } + + protected void BtnLogin_Click(object sender, EventArgs e) + { + for (int i = 0; i <= 1; i++) + { + if (txtName.Text == user[i, 0] && txtPassword.Text == user[i, 1]) + { + Session["user"] = user[i, 0]; + Response.Redirect("Chat.aspx"); + } + } + Response.Write(""); + } + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ChatLogin.aspx.designer.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ChatLogin.aspx.designer.cs" new file mode 100644 index 0000000..1bd5cfb --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ChatLogin.aspx.designer.cs" @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace Ex3 +{ + + + public partial class ChatLogin + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// txtName 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtName; + + /// + /// rfvName 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvName; + + /// + /// txtPassword 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.TextBox txtPassword; + + /// + /// rfvPassword 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvPassword; + + /// + /// btnLogin 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnLogin; + } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Default.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Default.aspx" new file mode 100644 index 0000000..8608ca4 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Default.aspx" @@ -0,0 +1,24 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Ex3.Default" %> + + + + + + 购买宠物页 + + +
+
+ + 盲鱼 + 波斯猫 + 斑马 + 千里马 + 绵羊 + + + +
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Default.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Default.aspx.cs" new file mode 100644 index 0000000..543cdeb --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Default.aspx.cs" @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Ex3 +{ + public partial class Default : System.Web.UI.Page + { + protected void BtnBuy_Click(object sender, EventArgs e) + { + for (int i = 0; i < chklsPet.Items.Count; i++) + { + if (chklsPet.Items[i].Selected) + { + Session["cart"] += chklsPet.Items[i].Text + ","; + } + } + } + + protected void BtnView_Click(object sender, EventArgs e) + { + Response.Redirect("ViewCart.aspx"); + } + + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Default.aspx.designer.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Default.aspx.designer.cs" new file mode 100644 index 0000000..9d56093 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Default.aspx.designer.cs" @@ -0,0 +1,53 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace Ex3 +{ + + + public partial class Default + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// chklsPet 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.CheckBoxList chklsPet; + + /// + /// btnBuy 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnBuy; + + /// + /// btnView 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnView; + } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Ex3.csproj" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Ex3.csproj" new file mode 100644 index 0000000..60d98b9 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Ex3.csproj" @@ -0,0 +1,173 @@ + + + + + Debug + AnyCPU + + + 2.0 + {8789125E-6C77-4DED-AFB0-8B4937F26389} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Ex3 + Ex3 + v4.7.2 + true + + 44372 + + + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + true + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + + + + + + + + + + + + + + + + + + Ajax.aspx + ASPXCodeBehind + + + Ajax.aspx + + + Chat.aspx + ASPXCodeBehind + + + Chat.aspx + + + ChatLogin.aspx + ASPXCodeBehind + + + ChatLogin.aspx + + + Default.aspx + ASPXCodeBehind + + + Default.aspx + + + Global.asax + + + + ViewCart.aspx + ASPXCodeBehind + + + ViewCart.aspx + + + + + + + + Web.config + + + Web.config + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 13326 + / + https://localhost:44372/ + False + False + + + False + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Ex3.csproj.user" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Ex3.csproj.user" new file mode 100644 index 0000000..a631dc6 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Ex3.csproj.user" @@ -0,0 +1,38 @@ + + + + true + + 44372 + + + + + Debug|Any CPU + + + + + + + + CurrentPage + True + False + False + False + + + + + + + + + True + False + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Ex3.sln" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Ex3.sln" new file mode 100644 index 0000000..43a95f7 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Ex3.sln" @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.33808.371 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex3", "Ex3.csproj", "{8789125E-6C77-4DED-AFB0-8B4937F26389}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8789125E-6C77-4DED-AFB0-8B4937F26389}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8789125E-6C77-4DED-AFB0-8B4937F26389}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8789125E-6C77-4DED-AFB0-8B4937F26389}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8789125E-6C77-4DED-AFB0-8B4937F26389}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {940FA0E3-ADD1-4C2C-B2A8-E37780E994E1} + EndGlobalSection +EndGlobal diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Global.asax" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Global.asax" new file mode 100644 index 0000000..0cf905e --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Global.asax" @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.cs" Inherits="Ex2.Global" Language="C#" %> diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Global.asax.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Global.asax.cs" new file mode 100644 index 0000000..90263c2 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Global.asax.cs" @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Security; +using System.Web.SessionState; +using System.Web.UI; + +namespace Ex2 +{ + public class Global : System.Web.HttpApplication + { + + protected void Application_Start(object sender, EventArgs e) + { + ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition + { + Path = "~/scripts/jquery-3.7.1.min.js", + DebugPath = "~/scripts/jquery-3.7.1.js", + CdnPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-3.7.1.min.js", + CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-3.7.1.js" + }); + } + + protected void Session_Start(object sender, EventArgs e) + { + + } + + protected void Application_BeginRequest(object sender, EventArgs e) + { + + } + + protected void Application_AuthenticateRequest(object sender, EventArgs e) + { + + } + + protected void Application_Error(object sender, EventArgs e) + { + + } + + protected void Session_End(object sender, EventArgs e) + { + + } + + protected void Application_End(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ViewCart.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ViewCart.aspx" new file mode 100644 index 0000000..2293fc8 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ViewCart.aspx" @@ -0,0 +1,21 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewCart.aspx.cs" Inherits="Ex3.ViewCart" %> + + + + + + 查看购物车 + + +
+
+ +
+ + + + +
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ViewCart.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ViewCart.aspx.cs" new file mode 100644 index 0000000..f787d8f --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ViewCart.aspx.cs" @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Ex3 +{ + public partial class ViewCart : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + if (Session["cart"] == null) + { + lblMsg.Text = "没有选购任何宠物!"; + btnClear.Enabled = false; + } + else + { + string strPets = Session["cart"].ToString(); + System.Collections.ArrayList pets = new System.Collections.ArrayList(); + int iPosition = strPets.IndexOf(","); + while (iPosition != -1) + { + string strPet = strPets.Substring(0, iPosition); + if (strPet != "") + { + pets.Add(strPet); + strPets = strPets.Substring(iPosition + 1); + iPosition = strPets.IndexOf(","); + } + } + lblMsg.Text = "购物车中现有宠物:"; + chklsPet.DataSource = pets; + chklsPet.DataBind(); + } + } + } + + protected void BtnClear_Click(object sender, EventArgs e) + { + Session.Remove("cart"); + lblMsg.Text = "没有选购任何宠物!"; + chklsPet.Visible = false; + btnClear.Enabled = false; + } + + protected void BtnContinue_Click(object sender, EventArgs e) + { + Response.Redirect("Default.aspx"); + } + + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ViewCart.aspx.designer.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ViewCart.aspx.designer.cs" new file mode 100644 index 0000000..2604977 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/ViewCart.aspx.designer.cs" @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace Ex3 +{ + + + public partial class ViewCart + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// lblMsg 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label lblMsg; + + /// + /// chklsPet 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.CheckBoxList chklsPet; + + /// + /// btnClear 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnClear; + + /// + /// btnContinue 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button btnContinue; + } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Web.Debug.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Web.Debug.config" new file mode 100644 index 0000000..b9a9fde --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Web.Debug.config" @@ -0,0 +1,31 @@ + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Web.Release.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Web.Release.config" new file mode 100644 index 0000000..755e745 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Web.Release.config" @@ -0,0 +1,32 @@ + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Web.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Web.config" new file mode 100644 index 0000000..ab1b924 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/Web.config" @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/packages.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/packages.config" new file mode 100644 index 0000000..adef0c9 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex3/packages.config" @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite.sln" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite.sln" new file mode 100644 index 0000000..6e67e76 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite.sln" @@ -0,0 +1,42 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.33808.371 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "Ex7LinqSqlSite", "Ex7LinqSqlSite\", "{AAC39F27-9F7A-4CC5-BC92-662101D01C2E}" + ProjectSection(WebsiteProperties) = preProject + TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.8.1" + Debug.AspNetCompiler.VirtualPath = "/localhost_12239" + Debug.AspNetCompiler.PhysicalPath = "Ex7LinqSqlSite\" + Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_12239\" + Debug.AspNetCompiler.Updateable = "true" + Debug.AspNetCompiler.ForceOverwrite = "true" + Debug.AspNetCompiler.FixedNames = "false" + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.VirtualPath = "/localhost_12239" + Release.AspNetCompiler.PhysicalPath = "Ex7LinqSqlSite\" + Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_12239\" + Release.AspNetCompiler.Updateable = "true" + Release.AspNetCompiler.ForceOverwrite = "true" + Release.AspNetCompiler.FixedNames = "false" + Release.AspNetCompiler.Debug = "False" + VWDPort = "12239" + SlnRelativePath = "Ex7LinqSqlSite\" + DefaultWebSiteLanguage = "Visual C#" + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AAC39F27-9F7A-4CC5-BC92-662101D01C2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AAC39F27-9F7A-4CC5-BC92-662101D01C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {335065AB-C162-4C18-9309-CEFC2BF96492} + EndGlobalSection +EndGlobal diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.Context.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.Context.cs" new file mode 100644 index 0000000..f96a8b9 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.Context.cs" @@ -0,0 +1,48 @@ +//------------------------------------------------------------------------------ +// +// 此代码已从模板生成。 +// +// 手动更改此文件可能导致应用程序出现意外的行为。 +// 如果重新生成代码,将覆盖对此文件的手动更改。 +// +//------------------------------------------------------------------------------ + +using System; +using System.Data.Entity; +using System.Data.Entity.Infrastructure; +using System.Data.Entity.Core.Objects; +using System.Linq; + +public partial class MyPetShopEntities : DbContext +{ + public MyPetShopEntities() + : base("name=MyPetShopEntities") + { + } + + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + throw new UnintentionalCodeFirstException(); + } + + public virtual DbSet CartItem { get; set; } + public virtual DbSet Category { get; set; } + public virtual DbSet Customer { get; set; } + public virtual DbSet Order { get; set; } + public virtual DbSet OrderItem { get; set; } + public virtual DbSet Product { get; set; } + public virtual DbSet Supplier { get; set; } + + public virtual int CategoryInsert(string name, string descn) + { + var nameParameter = name != null ? + new ObjectParameter("Name", name) : + new ObjectParameter("Name", typeof(string)); + + var descnParameter = descn != null ? + new ObjectParameter("Descn", descn) : + new ObjectParameter("Descn", typeof(string)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("CategoryInsert", nameParameter, descnParameter); + } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.Context.tt" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.Context.tt" new file mode 100644 index 0000000..5bb17de --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.Context.tt" @@ -0,0 +1,636 @@ +<#@ template language="C#" debug="false" hostspecific="true"#> +<#@ include file="EF6.Utility.CS.ttinclude"#><#@ + output extension=".cs"#><# + +const string inputFile = @"MyPetShop.edmx"; +var textTransform = DynamicTextTransformation.Create(this); +var code = new CodeGenerationTools(this); +var ef = new MetadataTools(this); +var typeMapper = new TypeMapper(code, ef, textTransform.Errors); +var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors); +var itemCollection = loader.CreateEdmItemCollection(inputFile); +var modelNamespace = loader.GetModelNamespace(inputFile); +var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef); + +var container = itemCollection.OfType().FirstOrDefault(); +if (container == null) +{ + return string.Empty; +} +#> +//------------------------------------------------------------------------------ +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#> +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#> +// +//------------------------------------------------------------------------------ + +<# + +var codeNamespace = code.VsNamespaceSuggestion(); +if (!String.IsNullOrEmpty(codeNamespace)) +{ +#> +namespace <#=code.EscapeNamespace(codeNamespace)#> +{ +<# + PushIndent(" "); +} + +#> +using System; +using System.Data.Entity; +using System.Data.Entity.Infrastructure; +<# +if (container.FunctionImports.Any()) +{ +#> +using System.Data.Entity.Core.Objects; +using System.Linq; +<# +} +#> + +<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext +{ + public <#=code.Escape(container)#>() + : base("name=<#=container.Name#>") + { +<# +if (!loader.IsLazyLoadingEnabled(container)) +{ +#> + this.Configuration.LazyLoadingEnabled = false; +<# +} + +foreach (var entitySet in container.BaseEntitySets.OfType()) +{ + // Note: the DbSet members are defined below such that the getter and + // setter always have the same accessibility as the DbSet definition + if (Accessibility.ForReadOnlyProperty(entitySet) != "public") + { +#> + <#=codeStringGenerator.DbSetInitializer(entitySet)#> +<# + } +} +#> + } + + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + throw new UnintentionalCodeFirstException(); + } + +<# + foreach (var entitySet in container.BaseEntitySets.OfType()) + { +#> + <#=codeStringGenerator.DbSet(entitySet)#> +<# + } + + foreach (var edmFunction in container.FunctionImports) + { + WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false); + } +#> +} +<# + +if (!String.IsNullOrEmpty(codeNamespace)) +{ + PopIndent(); +#> +} +<# +} +#> +<#+ + +private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) +{ + if (typeMapper.IsComposable(edmFunction)) + { +#> + + [DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")] + <#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#> + { +<#+ + codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter); +#> + <#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#> + } +<#+ + } + else + { +#> + + <#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#> + { +<#+ + codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter); +#> + <#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#> + } +<#+ + if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption)) + { + WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true); + } + } +} + +public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit) +{ +#> + var <#=name#> = <#=isNotNull#> ? + <#=notNullInit#> : + <#=nullInit#>; + +<#+ +} + +public const string TemplateId = "CSharp_DbContext_Context_EF6"; + +public class CodeStringGenerator +{ + private readonly CodeGenerationTools _code; + private readonly TypeMapper _typeMapper; + private readonly MetadataTools _ef; + + public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef) + { + ArgumentNotNull(code, "code"); + ArgumentNotNull(typeMapper, "typeMapper"); + ArgumentNotNull(ef, "ef"); + + _code = code; + _typeMapper = typeMapper; + _ef = ef; + } + + public string Property(EdmProperty edmProperty) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2} {{ {3}get; {4}set; }}", + Accessibility.ForProperty(edmProperty), + _typeMapper.GetTypeName(edmProperty.TypeUsage), + _code.Escape(edmProperty), + _code.SpaceAfter(Accessibility.ForGetter(edmProperty)), + _code.SpaceAfter(Accessibility.ForSetter(edmProperty))); + } + + public string NavigationProperty(NavigationProperty navProp) + { + var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType()); + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2} {{ {3}get; {4}set; }}", + AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)), + navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType, + _code.Escape(navProp), + _code.SpaceAfter(Accessibility.ForGetter(navProp)), + _code.SpaceAfter(Accessibility.ForSetter(navProp))); + } + + public string AccessibilityAndVirtual(string accessibility) + { + return accessibility + (accessibility != "private" ? " virtual" : ""); + } + + public string EntityClassOpening(EntityType entity) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1}partial class {2}{3}", + Accessibility.ForType(entity), + _code.SpaceAfter(_code.AbstractOption(entity)), + _code.Escape(entity), + _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType))); + } + + public string EnumOpening(SimpleType enumType) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} enum {1} : {2}", + Accessibility.ForType(enumType), + _code.Escape(enumType), + _code.Escape(_typeMapper.UnderlyingClrType(enumType))); + } + + public void WriteFunctionParameters(EdmFunction edmFunction, Action writeParameter) + { + var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); + foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable)) + { + var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null"; + var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")"; + var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))"; + writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit); + } + } + + public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace) + { + var parameters = _typeMapper.GetParameters(edmFunction); + + return string.Format( + CultureInfo.InvariantCulture, + "{0} IQueryable<{1}> {2}({3})", + AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), + _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), + _code.Escape(edmFunction), + string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray())); + } + + public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace) + { + var parameters = _typeMapper.GetParameters(edmFunction); + + return string.Format( + CultureInfo.InvariantCulture, + "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});", + _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), + edmFunction.NamespaceName, + edmFunction.Name, + string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()), + _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()))); + } + + public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + { + var parameters = _typeMapper.GetParameters(edmFunction); + var returnType = _typeMapper.GetReturnType(edmFunction); + + var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()); + if (includeMergeOption) + { + paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption"; + } + + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2}({3})", + AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), + returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", + _code.Escape(edmFunction), + paramList); + } + + public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + { + var parameters = _typeMapper.GetParameters(edmFunction); + var returnType = _typeMapper.GetReturnType(edmFunction); + + var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())); + if (includeMergeOption) + { + callParams = ", mergeOption" + callParams; + } + + return string.Format( + CultureInfo.InvariantCulture, + "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});", + returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", + edmFunction.Name, + callParams); + } + + public string DbSet(EntitySet entitySet) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} virtual DbSet<{1}> {2} {{ get; set; }}", + Accessibility.ForReadOnlyProperty(entitySet), + _typeMapper.GetTypeName(entitySet.ElementType), + _code.Escape(entitySet)); + } + + public string DbSetInitializer(EntitySet entitySet) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} = Set<{1}>();", + _code.Escape(entitySet), + _typeMapper.GetTypeName(entitySet.ElementType)); + } + + public string UsingDirectives(bool inHeader, bool includeCollections = true) + { + return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion()) + ? string.Format( + CultureInfo.InvariantCulture, + "{0}using System;{1}" + + "{2}", + inHeader ? Environment.NewLine : "", + includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "", + inHeader ? "" : Environment.NewLine) + : ""; + } +} + +public class TypeMapper +{ + private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName"; + + private readonly System.Collections.IList _errors; + private readonly CodeGenerationTools _code; + private readonly MetadataTools _ef; + + public static string FixNamespaces(string typeName) + { + return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial."); + } + + public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors) + { + ArgumentNotNull(code, "code"); + ArgumentNotNull(ef, "ef"); + ArgumentNotNull(errors, "errors"); + + _code = code; + _ef = ef; + _errors = errors; + } + + public string GetTypeName(TypeUsage typeUsage) + { + return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null); + } + + public string GetTypeName(EdmType edmType) + { + return GetTypeName(edmType, isNullable: null, modelNamespace: null); + } + + public string GetTypeName(TypeUsage typeUsage, string modelNamespace) + { + return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace); + } + + public string GetTypeName(EdmType edmType, string modelNamespace) + { + return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace); + } + + public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace) + { + if (edmType == null) + { + return null; + } + + var collectionType = edmType as CollectionType; + if (collectionType != null) + { + return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace)); + } + + var typeName = _code.Escape(edmType.MetadataProperties + .Where(p => p.Name == ExternalTypeNameAttributeName) + .Select(p => (string)p.Value) + .FirstOrDefault()) + ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ? + _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) : + _code.Escape(edmType)); + + if (edmType is StructuralType) + { + return typeName; + } + + if (edmType is SimpleType) + { + var clrType = UnderlyingClrType(edmType); + if (!IsEnumType(edmType)) + { + typeName = _code.Escape(clrType); + } + + typeName = FixNamespaces(typeName); + + return clrType.IsValueType && isNullable == true ? + String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) : + typeName; + } + + throw new ArgumentException("edmType"); + } + + public Type UnderlyingClrType(EdmType edmType) + { + ArgumentNotNull(edmType, "edmType"); + + var primitiveType = edmType as PrimitiveType; + if (primitiveType != null) + { + return primitiveType.ClrEquivalentType; + } + + if (IsEnumType(edmType)) + { + return GetEnumUnderlyingType(edmType).ClrEquivalentType; + } + + return typeof(object); + } + + public object GetEnumMemberValue(MetadataItem enumMember) + { + ArgumentNotNull(enumMember, "enumMember"); + + var valueProperty = enumMember.GetType().GetProperty("Value"); + return valueProperty == null ? null : valueProperty.GetValue(enumMember, null); + } + + public string GetEnumMemberName(MetadataItem enumMember) + { + ArgumentNotNull(enumMember, "enumMember"); + + var nameProperty = enumMember.GetType().GetProperty("Name"); + return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null); + } + + public System.Collections.IEnumerable GetEnumMembers(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + var membersProperty = enumType.GetType().GetProperty("Members"); + return membersProperty != null + ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null) + : Enumerable.Empty(); + } + + public bool EnumIsFlags(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + var isFlagsProperty = enumType.GetType().GetProperty("IsFlags"); + return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null); + } + + public bool IsEnumType(GlobalItem edmType) + { + ArgumentNotNull(edmType, "edmType"); + + return edmType.GetType().Name == "EnumType"; + } + + public PrimitiveType GetEnumUnderlyingType(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null); + } + + public string CreateLiteral(object value) + { + if (value == null || value.GetType() != typeof(TimeSpan)) + { + return _code.CreateLiteral(value); + } + + return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks); + } + + public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable types, string sourceFile) + { + ArgumentNotNull(types, "types"); + ArgumentNotNull(sourceFile, "sourceFile"); + + var hash = new HashSet(StringComparer.InvariantCultureIgnoreCase); + if (types.Any(item => !hash.Add(item))) + { + _errors.Add( + new CompilerError(sourceFile, -1, -1, "6023", + String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict")))); + return false; + } + return true; + } + + public IEnumerable GetEnumItemsToGenerate(IEnumerable itemCollection) + { + return GetItemsToGenerate(itemCollection) + .Where(e => IsEnumType(e)); + } + + public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T: EdmType + { + return itemCollection + .OfType() + .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName)) + .OrderBy(i => i.Name); + } + + public IEnumerable GetAllGlobalItems(IEnumerable itemCollection) + { + return itemCollection + .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i)) + .Select(g => GetGlobalItemName(g)); + } + + public string GetGlobalItemName(GlobalItem item) + { + if (item is EdmType) + { + return ((EdmType)item).Name; + } + else + { + return ((EntityContainer)item).Name; + } + } + + public IEnumerable GetSimpleProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetSimpleProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetPropertiesWithDefaultValues(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetPropertiesWithDefaultValues(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type); + } + + public IEnumerable GetCollectionNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many); + } + + public FunctionParameter GetReturnParameter(EdmFunction edmFunction) + { + ArgumentNotNull(edmFunction, "edmFunction"); + + var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters"); + return returnParamsProperty == null + ? edmFunction.ReturnParameter + : ((IEnumerable)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault(); + } + + public bool IsComposable(EdmFunction edmFunction) + { + ArgumentNotNull(edmFunction, "edmFunction"); + + var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute"); + return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null); + } + + public IEnumerable GetParameters(EdmFunction edmFunction) + { + return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); + } + + public TypeUsage GetReturnType(EdmFunction edmFunction) + { + var returnParam = GetReturnParameter(edmFunction); + return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage); + } + + public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption) + { + var returnType = GetReturnType(edmFunction); + return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType; + } +} + +public static void ArgumentNotNull(T arg, string name) where T : class +{ + if (arg == null) + { + throw new ArgumentNullException(name); + } +} +#> \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.Designer.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.Designer.cs" new file mode 100644 index 0000000..8acaf46 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.Designer.cs" @@ -0,0 +1,10 @@ +// 为模型“F:\Documents\Tencent Files\2223195430\FileRecv\实验\Ex7LinqSqlSite\Ex7LinqSqlSite\App_Code\MyPetShop.edmx”启用了 T4 代码生成。 +// 要启用旧代码生成功能,请将“代码生成策略”设计器属性的值 +// 更改为“旧的 ObjectContext”。当在设计器中打开该模型时,此属性会出现在 +// “属性”窗口中。 + +// 如果没有生成任何上下文和实体类,可能是因为您创建了空模型但是 +// 尚未选择要使用的实体框架版本。要为您的模型生成一个上下文类和实体 +// 类,请在设计器中打开该模型,右键单击设计器图面,然后 +// 选择“从数据库更新模型...”、“从模型生成数据库...”或“添加代码生成 +// 项...”。 \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.cs" new file mode 100644 index 0000000..524890a --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.cs" @@ -0,0 +1,142 @@ +//------------------------------------------------------------------------------ +// +// 此代码已从模板生成。 +// +// 手动更改此文件可能导致应用程序出现意外的行为。 +// 如果重新生成代码,将覆盖对此文件的手动更改。 +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; + +public partial class CartItem +{ + public int CartItemId { get; set; } + public int CustomerId { get; set; } + public int ProId { get; set; } + public string ProName { get; set; } + public decimal ListPrice { get; set; } + public int Qty { get; set; } + + public virtual Customer Customer { get; set; } + public virtual Product Product { get; set; } +} + +public partial class Category +{ + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Category() + { + this.Product = new HashSet(); + } + + public int CategoryId { get; set; } + public string Name { get; set; } + public string Descn { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection Product { get; set; } +} + +public partial class Customer +{ + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Customer() + { + this.CartItem = new HashSet(); + this.Order = new HashSet(); + } + + public int CustomerId { get; set; } + public string Name { get; set; } + public string Password { get; set; } + public string Email { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection CartItem { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection Order { get; set; } +} + +public partial class Order +{ + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Order() + { + this.OrderItem = new HashSet(); + } + + public int OrderId { get; set; } + public int CustomerId { get; set; } + public string UserName { get; set; } + public System.DateTime OrderDate { get; set; } + public string Addr1 { get; set; } + public string Addr2 { get; set; } + public string City { get; set; } + public string State { get; set; } + public string Zip { get; set; } + public string Phone { get; set; } + public string Status { get; set; } + + public virtual Customer Customer { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection OrderItem { get; set; } +} + +public partial class OrderItem +{ + public int ItemId { get; set; } + public int OrderId { get; set; } + public string ProName { get; set; } + public Nullable ListPrice { get; set; } + public int Qty { get; set; } + public Nullable TotalPrice { get; set; } + + public virtual Order Order { get; set; } +} + +public partial class Product +{ + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Product() + { + this.CartItem = new HashSet(); + } + + public int ProductId { get; set; } + public int CategoryId { get; set; } + public Nullable ListPrice { get; set; } + public Nullable UnitCost { get; set; } + public Nullable SuppId { get; set; } + public string Name { get; set; } + public string Descn { get; set; } + public string Image { get; set; } + public int Qty { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection CartItem { get; set; } + public virtual Category Category { get; set; } + public virtual Supplier Supplier { get; set; } +} + +public partial class Supplier +{ + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Supplier() + { + this.Product = new HashSet(); + } + + public int SuppId { get; set; } + public string Name { get; set; } + public string Addr1 { get; set; } + public string Addr2 { get; set; } + public string City { get; set; } + public string State { get; set; } + public string Zip { get; set; } + public string Phone { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection Product { get; set; } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.edmx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.edmx" new file mode 100644 index 0000000..6f5c5c3 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.edmx" @@ -0,0 +1,526 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.edmx.diagram" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.edmx.diagram" new file mode 100644 index 0000000..253fe78 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.edmx.diagram" @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.tt" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.tt" new file mode 100644 index 0000000..e9d2ccc --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Code/MyPetShop.tt" @@ -0,0 +1,733 @@ +<#@ template language="C#" debug="false" hostspecific="true"#> +<#@ include file="EF6.Utility.CS.ttinclude"#><#@ + output extension=".cs"#><# + +const string inputFile = @"MyPetShop.edmx"; +var textTransform = DynamicTextTransformation.Create(this); +var code = new CodeGenerationTools(this); +var ef = new MetadataTools(this); +var typeMapper = new TypeMapper(code, ef, textTransform.Errors); +var fileManager = EntityFrameworkTemplateFileManager.Create(this); +var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile); +var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef); + +if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile)) +{ + return string.Empty; +} + +WriteHeader(codeStringGenerator, fileManager); + +foreach (var entity in typeMapper.GetItemsToGenerate(itemCollection)) +{ + fileManager.StartNewFile(entity.Name + ".cs"); + BeginNamespace(code); +#> +<#=codeStringGenerator.UsingDirectives(inHeader: false)#> +<#=codeStringGenerator.EntityClassOpening(entity)#> +{ +<# + var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity); + var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity); + var complexProperties = typeMapper.GetComplexProperties(entity); + + if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any()) + { +#> + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public <#=code.Escape(entity)#>() + { +<# + foreach (var edmProperty in propertiesWithDefaultValues) + { +#> + this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>; +<# + } + + foreach (var navigationProperty in collectionNavigationProperties) + { +#> + this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>(); +<# + } + + foreach (var complexProperty in complexProperties) + { +#> + this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>(); +<# + } +#> + } + +<# + } + + var simpleProperties = typeMapper.GetSimpleProperties(entity); + if (simpleProperties.Any()) + { + foreach (var edmProperty in simpleProperties) + { +#> + <#=codeStringGenerator.Property(edmProperty)#> +<# + } + } + + if (complexProperties.Any()) + { +#> + +<# + foreach(var complexProperty in complexProperties) + { +#> + <#=codeStringGenerator.Property(complexProperty)#> +<# + } + } + + var navigationProperties = typeMapper.GetNavigationProperties(entity); + if (navigationProperties.Any()) + { +#> + +<# + foreach (var navigationProperty in navigationProperties) + { + if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many) + { +#> + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] +<# + } +#> + <#=codeStringGenerator.NavigationProperty(navigationProperty)#> +<# + } + } +#> +} +<# + EndNamespace(code); +} + +foreach (var complex in typeMapper.GetItemsToGenerate(itemCollection)) +{ + fileManager.StartNewFile(complex.Name + ".cs"); + BeginNamespace(code); +#> +<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#> +<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#> +{ +<# + var complexProperties = typeMapper.GetComplexProperties(complex); + var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex); + + if (propertiesWithDefaultValues.Any() || complexProperties.Any()) + { +#> + public <#=code.Escape(complex)#>() + { +<# + foreach (var edmProperty in propertiesWithDefaultValues) + { +#> + this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>; +<# + } + + foreach (var complexProperty in complexProperties) + { +#> + this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>(); +<# + } +#> + } + +<# + } + + var simpleProperties = typeMapper.GetSimpleProperties(complex); + if (simpleProperties.Any()) + { + foreach(var edmProperty in simpleProperties) + { +#> + <#=codeStringGenerator.Property(edmProperty)#> +<# + } + } + + if (complexProperties.Any()) + { +#> + +<# + foreach(var edmProperty in complexProperties) + { +#> + <#=codeStringGenerator.Property(edmProperty)#> +<# + } + } +#> +} +<# + EndNamespace(code); +} + +foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection)) +{ + fileManager.StartNewFile(enumType.Name + ".cs"); + BeginNamespace(code); +#> +<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#> +<# + if (typeMapper.EnumIsFlags(enumType)) + { +#> +[Flags] +<# + } +#> +<#=codeStringGenerator.EnumOpening(enumType)#> +{ +<# + var foundOne = false; + + foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType)) + { + foundOne = true; +#> + <#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>, +<# + } + + if (foundOne) + { + this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1); + } +#> +} +<# + EndNamespace(code); +} + +fileManager.Process(); + +#> +<#+ + +public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager) +{ + fileManager.StartHeader(); +#> +//------------------------------------------------------------------------------ +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#> +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#> +// +//------------------------------------------------------------------------------ +<#=codeStringGenerator.UsingDirectives(inHeader: true)#> +<#+ + fileManager.EndBlock(); +} + +public void BeginNamespace(CodeGenerationTools code) +{ + var codeNamespace = code.VsNamespaceSuggestion(); + if (!String.IsNullOrEmpty(codeNamespace)) + { +#> +namespace <#=code.EscapeNamespace(codeNamespace)#> +{ +<#+ + PushIndent(" "); + } +} + +public void EndNamespace(CodeGenerationTools code) +{ + if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion())) + { + PopIndent(); +#> +} +<#+ + } +} + +public const string TemplateId = "CSharp_DbContext_Types_EF6"; + +public class CodeStringGenerator +{ + private readonly CodeGenerationTools _code; + private readonly TypeMapper _typeMapper; + private readonly MetadataTools _ef; + + public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef) + { + ArgumentNotNull(code, "code"); + ArgumentNotNull(typeMapper, "typeMapper"); + ArgumentNotNull(ef, "ef"); + + _code = code; + _typeMapper = typeMapper; + _ef = ef; + } + + public string Property(EdmProperty edmProperty) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2} {{ {3}get; {4}set; }}", + Accessibility.ForProperty(edmProperty), + _typeMapper.GetTypeName(edmProperty.TypeUsage), + _code.Escape(edmProperty), + _code.SpaceAfter(Accessibility.ForGetter(edmProperty)), + _code.SpaceAfter(Accessibility.ForSetter(edmProperty))); + } + + public string NavigationProperty(NavigationProperty navProp) + { + var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType()); + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2} {{ {3}get; {4}set; }}", + AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)), + navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType, + _code.Escape(navProp), + _code.SpaceAfter(Accessibility.ForGetter(navProp)), + _code.SpaceAfter(Accessibility.ForSetter(navProp))); + } + + public string AccessibilityAndVirtual(string accessibility) + { + return accessibility + (accessibility != "private" ? " virtual" : ""); + } + + public string EntityClassOpening(EntityType entity) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1}partial class {2}{3}", + Accessibility.ForType(entity), + _code.SpaceAfter(_code.AbstractOption(entity)), + _code.Escape(entity), + _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType))); + } + + public string EnumOpening(SimpleType enumType) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} enum {1} : {2}", + Accessibility.ForType(enumType), + _code.Escape(enumType), + _code.Escape(_typeMapper.UnderlyingClrType(enumType))); + } + + public void WriteFunctionParameters(EdmFunction edmFunction, Action writeParameter) + { + var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); + foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable)) + { + var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null"; + var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")"; + var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))"; + writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit); + } + } + + public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace) + { + var parameters = _typeMapper.GetParameters(edmFunction); + + return string.Format( + CultureInfo.InvariantCulture, + "{0} IQueryable<{1}> {2}({3})", + AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), + _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), + _code.Escape(edmFunction), + string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray())); + } + + public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace) + { + var parameters = _typeMapper.GetParameters(edmFunction); + + return string.Format( + CultureInfo.InvariantCulture, + "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});", + _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), + edmFunction.NamespaceName, + edmFunction.Name, + string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()), + _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()))); + } + + public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + { + var parameters = _typeMapper.GetParameters(edmFunction); + var returnType = _typeMapper.GetReturnType(edmFunction); + + var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()); + if (includeMergeOption) + { + paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption"; + } + + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2}({3})", + AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), + returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", + _code.Escape(edmFunction), + paramList); + } + + public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + { + var parameters = _typeMapper.GetParameters(edmFunction); + var returnType = _typeMapper.GetReturnType(edmFunction); + + var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())); + if (includeMergeOption) + { + callParams = ", mergeOption" + callParams; + } + + return string.Format( + CultureInfo.InvariantCulture, + "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});", + returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", + edmFunction.Name, + callParams); + } + + public string DbSet(EntitySet entitySet) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} virtual DbSet<{1}> {2} {{ get; set; }}", + Accessibility.ForReadOnlyProperty(entitySet), + _typeMapper.GetTypeName(entitySet.ElementType), + _code.Escape(entitySet)); + } + + public string UsingDirectives(bool inHeader, bool includeCollections = true) + { + return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion()) + ? string.Format( + CultureInfo.InvariantCulture, + "{0}using System;{1}" + + "{2}", + inHeader ? Environment.NewLine : "", + includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "", + inHeader ? "" : Environment.NewLine) + : ""; + } +} + +public class TypeMapper +{ + private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName"; + + private readonly System.Collections.IList _errors; + private readonly CodeGenerationTools _code; + private readonly MetadataTools _ef; + + public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors) + { + ArgumentNotNull(code, "code"); + ArgumentNotNull(ef, "ef"); + ArgumentNotNull(errors, "errors"); + + _code = code; + _ef = ef; + _errors = errors; + } + + public static string FixNamespaces(string typeName) + { + return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial."); + } + + public string GetTypeName(TypeUsage typeUsage) + { + return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null); + } + + public string GetTypeName(EdmType edmType) + { + return GetTypeName(edmType, isNullable: null, modelNamespace: null); + } + + public string GetTypeName(TypeUsage typeUsage, string modelNamespace) + { + return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace); + } + + public string GetTypeName(EdmType edmType, string modelNamespace) + { + return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace); + } + + public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace) + { + if (edmType == null) + { + return null; + } + + var collectionType = edmType as CollectionType; + if (collectionType != null) + { + return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace)); + } + + var typeName = _code.Escape(edmType.MetadataProperties + .Where(p => p.Name == ExternalTypeNameAttributeName) + .Select(p => (string)p.Value) + .FirstOrDefault()) + ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ? + _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) : + _code.Escape(edmType)); + + if (edmType is StructuralType) + { + return typeName; + } + + if (edmType is SimpleType) + { + var clrType = UnderlyingClrType(edmType); + if (!IsEnumType(edmType)) + { + typeName = _code.Escape(clrType); + } + + typeName = FixNamespaces(typeName); + + return clrType.IsValueType && isNullable == true ? + String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) : + typeName; + } + + throw new ArgumentException("edmType"); + } + + public Type UnderlyingClrType(EdmType edmType) + { + ArgumentNotNull(edmType, "edmType"); + + var primitiveType = edmType as PrimitiveType; + if (primitiveType != null) + { + return primitiveType.ClrEquivalentType; + } + + if (IsEnumType(edmType)) + { + return GetEnumUnderlyingType(edmType).ClrEquivalentType; + } + + return typeof(object); + } + + public object GetEnumMemberValue(MetadataItem enumMember) + { + ArgumentNotNull(enumMember, "enumMember"); + + var valueProperty = enumMember.GetType().GetProperty("Value"); + return valueProperty == null ? null : valueProperty.GetValue(enumMember, null); + } + + public string GetEnumMemberName(MetadataItem enumMember) + { + ArgumentNotNull(enumMember, "enumMember"); + + var nameProperty = enumMember.GetType().GetProperty("Name"); + return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null); + } + + public System.Collections.IEnumerable GetEnumMembers(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + var membersProperty = enumType.GetType().GetProperty("Members"); + return membersProperty != null + ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null) + : Enumerable.Empty(); + } + + public bool EnumIsFlags(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + var isFlagsProperty = enumType.GetType().GetProperty("IsFlags"); + return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null); + } + + public bool IsEnumType(GlobalItem edmType) + { + ArgumentNotNull(edmType, "edmType"); + + return edmType.GetType().Name == "EnumType"; + } + + public PrimitiveType GetEnumUnderlyingType(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null); + } + + public string CreateLiteral(object value) + { + if (value == null || value.GetType() != typeof(TimeSpan)) + { + return _code.CreateLiteral(value); + } + + return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks); + } + + public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable types, string sourceFile) + { + ArgumentNotNull(types, "types"); + ArgumentNotNull(sourceFile, "sourceFile"); + + var hash = new HashSet(StringComparer.InvariantCultureIgnoreCase); + if (types.Any(item => !hash.Add(item))) + { + _errors.Add( + new CompilerError(sourceFile, -1, -1, "6023", + String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict")))); + return false; + } + return true; + } + + public IEnumerable GetEnumItemsToGenerate(IEnumerable itemCollection) + { + return GetItemsToGenerate(itemCollection) + .Where(e => IsEnumType(e)); + } + + public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T: EdmType + { + return itemCollection + .OfType() + .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName)) + .OrderBy(i => i.Name); + } + + public IEnumerable GetAllGlobalItems(IEnumerable itemCollection) + { + return itemCollection + .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i)) + .Select(g => GetGlobalItemName(g)); + } + + public string GetGlobalItemName(GlobalItem item) + { + if (item is EdmType) + { + return ((EdmType)item).Name; + } + else + { + return ((EntityContainer)item).Name; + } + } + + public IEnumerable GetSimpleProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetSimpleProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetPropertiesWithDefaultValues(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetPropertiesWithDefaultValues(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type); + } + + public IEnumerable GetCollectionNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many); + } + + public FunctionParameter GetReturnParameter(EdmFunction edmFunction) + { + ArgumentNotNull(edmFunction, "edmFunction"); + + var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters"); + return returnParamsProperty == null + ? edmFunction.ReturnParameter + : ((IEnumerable)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault(); + } + + public bool IsComposable(EdmFunction edmFunction) + { + ArgumentNotNull(edmFunction, "edmFunction"); + + var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute"); + return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null); + } + + public IEnumerable GetParameters(EdmFunction edmFunction) + { + return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); + } + + public TypeUsage GetReturnType(EdmFunction edmFunction) + { + var returnParam = GetReturnParameter(edmFunction); + return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage); + } + + public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption) + { + var returnType = GetReturnType(edmFunction); + return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType; + } +} + +public static void ArgumentNotNull(T arg, string name) where T : class +{ + if (arg == null) + { + throw new ArgumentNullException(name); + } +} +#> \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Data/MyPetShop.mdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Data/MyPetShop.mdf" new file mode 100644 index 0000000..08e3079 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/App_Data/MyPetShop.mdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Category.xml" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Category.xml" new file mode 100644 index 0000000..d0c7355 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Category.xml" @@ -0,0 +1,33 @@ + + + + 1 + Fish + Cat Eat Fish + + + 2 + Bugs + Bugs + + + 3 + Backyard + Backyard + + + 4 + Birds + Birds + + + 5 + Endangered + Endangered + + + 11 + test + 123 + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/DataManage.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/DataManage.aspx" new file mode 100644 index 0000000..8e5965f --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/DataManage.aspx" @@ -0,0 +1,33 @@ +<%@ Page Language="C#" AutoEventWireup="true" + CodeFile="DataManage.aspx.cs" Inherits="DataManage" %> + + + + + + Linq to SQL 管理数据 + + +
+
+ 分类 Id:输入分类 Id,只用于“修改”和“删除” +
+ + + + + +
+
+ + +
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/DataManage.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/DataManage.aspx.cs" new file mode 100644 index 0000000..db5c9eb --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/DataManage.aspx.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +public partial class DataManage : System.Web.UI.Page +{ + MyPetShopEntities db = new MyPetShopEntities(); + protected void Bind() + { + var results = db.Category.ToList(); + gvCategory.DataSource = results; + gvCategory.DataBind(); + } + protected void BtnQueryAll_Click(object sender, EventArgs e) + { + Bind(); + } + protected void BtnFuzzy_Click(object sender, EventArgs e) + { + Response.Redirect("FuzzyQuery.aspx"); + } + protected void BtnInsert_Click(object sender, EventArgs e) + { + Response.Redirect("Insert.aspx"); + } + protected void BtnUpdate_Click(object sender, EventArgs e) + { + Response.Redirect("Update.aspx?CategoryId=" + txtCategoryId.Text); + } + protected void BtnDelete_Click(object sender, EventArgs e) + { + var category = db.Category.Find(int.Parse(txtCategoryId.Text)); + + db.Category.Remove(category); + db.SaveChanges(); + Bind(); + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/FuzzyQuery.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/FuzzyQuery.aspx" new file mode 100644 index 0000000..0386926 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/FuzzyQuery.aspx" @@ -0,0 +1,24 @@ +<%@ Page Language="C#" AutoEventWireup="true" + CodeFile="FuzzyQuery.aspx.cs" Inherits="FuzzyQuery" %> + + + + + + 模糊查找 + + +
+
+ 分类名: + + + + + +
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/FuzzyQuery.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/FuzzyQuery.aspx.cs" new file mode 100644 index 0000000..724355e --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/FuzzyQuery.aspx.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +public partial class FuzzyQuery : System.Web.UI.Page +{ + protected void BtnSearch_Click(object sender, EventArgs e) + { + MyPetShopEntities db = new MyPetShopEntities(); + var results = from c in db.Category.Where(c => c.Name.Contains(txtSearch.Text)).ToList()select c; + if (results.Count() != 0) + { + gvCategory.DataSource = results; + gvCategory.DataBind(); + } + else + { + lblMsg.Text = "没有满足条件的数据!"; + } + } + protected void BtnReturn_Click(object sender, EventArgs e) + { + Response.Redirect("DataManage.aspx"); + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Insert.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Insert.aspx" new file mode 100644 index 0000000..4c4dffb --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Insert.aspx" @@ -0,0 +1,44 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Insert.aspx.cs" + Inherits="Insert" %> + + + + + + 插入数据 + + + +
+
+ + + + + + + + + +
分类名: + +
描述: +
+ + +
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Insert.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Insert.aspx.cs" new file mode 100644 index 0000000..e359ba9 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Insert.aspx.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +public partial class Insert : System.Web.UI.Page +{ + protected void BtnInsert_Click(object sender, EventArgs e) + { + MyPetShopEntities db = new MyPetShopEntities(); + Category category = new Category(); + category.Name = txtName.Text; + category.Descn = txtDescn.Text; + db.Category.Add(category); + db.SaveChanges(); + } + protected void BtnReturn_Click(object sender, EventArgs e) + { + Response.Redirect("DataManage.aspx"); + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/LinqXmlInsert.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/LinqXmlInsert.aspx" new file mode 100644 index 0000000..25dd6c3 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/LinqXmlInsert.aspx" @@ -0,0 +1,46 @@ +<%@ Page Language="C#" AutoEventWireup="true" + CodeFile="LinqXmlInsert.aspx.cs" Inherits="LinqXmlInsert" %> + + + + + + Linq to XML 插入数据 + + +
+
+ + + + + + + + + + + + + +
分类 Id: + + +
分类名: + + +
描述: + + +
+ + +
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/LinqXmlInsert.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/LinqXmlInsert.aspx.cs" new file mode 100644 index 0000000..4432c42 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/LinqXmlInsert.aspx.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Xml.Linq; + +public partial class LinqXmlInsert : System.Web.UI.Page +{ + protected void btnInsert_Click(object sender, EventArgs e) + { + string xmlFilePath = Server.MapPath("~/Category.xml"); + XElement els = XElement.Load(xmlFilePath); + XElement el = new XElement("Category", + new XElement("CategoryId", txtCategoryId.Text), + new XElement("Name", txtName.Text), + new XElement("Descn", txtDescn.Text)); + els.Add(el); + els.Save(xmlFilePath); + } + protected void btnReturn_Click(object sender, EventArgs e) + { + Response.Redirect("LinqXml.aspx"); + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/TableToXml.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/TableToXml.aspx" new file mode 100644 index 0000000..f0538fd --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/TableToXml.aspx" @@ -0,0 +1,15 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TableToXml.aspx.cs" Inherits="TableToXml" %> + + + + + + 利用 LINQ 将 Category 表转换为 XML 文件 + + +
+
+
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/TableToXml.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/TableToXml.aspx.cs" new file mode 100644 index 0000000..5ede841 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/TableToXml.aspx.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Xml.Linq; + +public partial class TableToXml : System.Web.UI.Page +{ + protected void Page_Load(object sender, EventArgs e) + { + string xmlFilePath = Server.MapPath("~/Category.xml"); + XDocument doc = new XDocument + ( + new XDeclaration("1.0", "utf-8", "yes"), + new XComment("分类"), + new XElement("Categories") + ); + doc.Save(xmlFilePath); + XElement els = XElement.Load(xmlFilePath); + MyPetShopEntities db = new MyPetShopEntities(); + var results = from c in db.Category + select c; + foreach (Category category in results) + { + XElement el = new XElement("Category", + new XElement("CategoryId", category.CategoryId), + new XElement("Name", category.Name), + new XElement("Descn", category.Descn)); + els.Add(el); + } + els.Save(xmlFilePath); + Response.Redirect("~/Category.xml"); + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Update.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Update.aspx" new file mode 100644 index 0000000..c8ca903 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Update.aspx" @@ -0,0 +1,51 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Update.aspx.cs" + Inherits="Update" %> + + + + + + 编辑数据 + + + +
+
+ + + + + + + + + + + + + +
分类 Id: + +
分类名: + +
描述: +
+ + +
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Update.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Update.aspx.cs" new file mode 100644 index 0000000..a6dbc8c --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Update.aspx.cs" @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +public partial class Update : System.Web.UI.Page +{ + MyPetShopEntities db = new MyPetShopEntities(); + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + string categoryId = Request.QueryString["CategoryId"]; + var category = db.Category.Find(int.Parse(txtCategoryId.Text)); + txtCategoryId.Text = categoryId; + txtCategoryId.ReadOnly = true; + txtName.Text = category.Name; + txtDescn.Text = category.Descn; + } + } + protected void BtnUpdate_Click(object sender, EventArgs e) + { + var category = db.Category.Find(int.Parse(txtCategoryId.Text)); + category.Name = txtName.Text; + category.Descn = txtDescn.Text; + db.SaveChanges(); + } + protected void BtnReturn_Click(object sender, EventArgs e) + { + Response.Redirect("DataManage.aspx"); + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Web.Debug.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Web.Debug.config" new file mode 100644 index 0000000..755e745 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Web.Debug.config" @@ -0,0 +1,32 @@ + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Web.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Web.config" new file mode 100644 index 0000000..6a254ee --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/Web.config" @@ -0,0 +1,50 @@ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/packages.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/packages.config" new file mode 100644 index 0000000..99bce91 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/packages.config" @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/vwd.webinfo" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/vwd.webinfo" new file mode 100644 index 0000000..5342215 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex7LinqSqlSite/Ex7LinqSqlSite/vwd.webinfo" @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site.sln" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site.sln" new file mode 100644 index 0000000..fb5bca9 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site.sln" @@ -0,0 +1,42 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.33808.371 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "Ex8Site", "Ex8Site\", "{1B5BDE16-1392-4AE9-8528-0AD644EECAEA}" + ProjectSection(WebsiteProperties) = preProject + TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.8.1" + Debug.AspNetCompiler.VirtualPath = "/localhost_9157" + Debug.AspNetCompiler.PhysicalPath = "Ex8Site\" + Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_9157\" + Debug.AspNetCompiler.Updateable = "true" + Debug.AspNetCompiler.ForceOverwrite = "true" + Debug.AspNetCompiler.FixedNames = "false" + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.VirtualPath = "/localhost_9157" + Release.AspNetCompiler.PhysicalPath = "Ex8Site\" + Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_9157\" + Release.AspNetCompiler.Updateable = "true" + Release.AspNetCompiler.ForceOverwrite = "true" + Release.AspNetCompiler.FixedNames = "false" + Release.AspNetCompiler.Debug = "False" + VWDPort = "9157" + SlnRelativePath = "Ex8Site\" + DefaultWebSiteLanguage = "Visual C#" + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1B5BDE16-1392-4AE9-8528-0AD644EECAEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1B5BDE16-1392-4AE9-8528-0AD644EECAEA}.Debug|Any CPU.Build.0 = Debug|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9752096F-E569-4285-9162-01027F8597E8} + EndGlobalSection +EndGlobal diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.Context.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.Context.cs" new file mode 100644 index 0000000..f96a8b9 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.Context.cs" @@ -0,0 +1,48 @@ +//------------------------------------------------------------------------------ +// +// 此代码已从模板生成。 +// +// 手动更改此文件可能导致应用程序出现意外的行为。 +// 如果重新生成代码,将覆盖对此文件的手动更改。 +// +//------------------------------------------------------------------------------ + +using System; +using System.Data.Entity; +using System.Data.Entity.Infrastructure; +using System.Data.Entity.Core.Objects; +using System.Linq; + +public partial class MyPetShopEntities : DbContext +{ + public MyPetShopEntities() + : base("name=MyPetShopEntities") + { + } + + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + throw new UnintentionalCodeFirstException(); + } + + public virtual DbSet CartItem { get; set; } + public virtual DbSet Category { get; set; } + public virtual DbSet Customer { get; set; } + public virtual DbSet Order { get; set; } + public virtual DbSet OrderItem { get; set; } + public virtual DbSet Product { get; set; } + public virtual DbSet Supplier { get; set; } + + public virtual int CategoryInsert(string name, string descn) + { + var nameParameter = name != null ? + new ObjectParameter("Name", name) : + new ObjectParameter("Name", typeof(string)); + + var descnParameter = descn != null ? + new ObjectParameter("Descn", descn) : + new ObjectParameter("Descn", typeof(string)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("CategoryInsert", nameParameter, descnParameter); + } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.Context.tt" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.Context.tt" new file mode 100644 index 0000000..5bb17de --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.Context.tt" @@ -0,0 +1,636 @@ +<#@ template language="C#" debug="false" hostspecific="true"#> +<#@ include file="EF6.Utility.CS.ttinclude"#><#@ + output extension=".cs"#><# + +const string inputFile = @"MyPetShop.edmx"; +var textTransform = DynamicTextTransformation.Create(this); +var code = new CodeGenerationTools(this); +var ef = new MetadataTools(this); +var typeMapper = new TypeMapper(code, ef, textTransform.Errors); +var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors); +var itemCollection = loader.CreateEdmItemCollection(inputFile); +var modelNamespace = loader.GetModelNamespace(inputFile); +var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef); + +var container = itemCollection.OfType().FirstOrDefault(); +if (container == null) +{ + return string.Empty; +} +#> +//------------------------------------------------------------------------------ +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#> +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#> +// +//------------------------------------------------------------------------------ + +<# + +var codeNamespace = code.VsNamespaceSuggestion(); +if (!String.IsNullOrEmpty(codeNamespace)) +{ +#> +namespace <#=code.EscapeNamespace(codeNamespace)#> +{ +<# + PushIndent(" "); +} + +#> +using System; +using System.Data.Entity; +using System.Data.Entity.Infrastructure; +<# +if (container.FunctionImports.Any()) +{ +#> +using System.Data.Entity.Core.Objects; +using System.Linq; +<# +} +#> + +<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext +{ + public <#=code.Escape(container)#>() + : base("name=<#=container.Name#>") + { +<# +if (!loader.IsLazyLoadingEnabled(container)) +{ +#> + this.Configuration.LazyLoadingEnabled = false; +<# +} + +foreach (var entitySet in container.BaseEntitySets.OfType()) +{ + // Note: the DbSet members are defined below such that the getter and + // setter always have the same accessibility as the DbSet definition + if (Accessibility.ForReadOnlyProperty(entitySet) != "public") + { +#> + <#=codeStringGenerator.DbSetInitializer(entitySet)#> +<# + } +} +#> + } + + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + throw new UnintentionalCodeFirstException(); + } + +<# + foreach (var entitySet in container.BaseEntitySets.OfType()) + { +#> + <#=codeStringGenerator.DbSet(entitySet)#> +<# + } + + foreach (var edmFunction in container.FunctionImports) + { + WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false); + } +#> +} +<# + +if (!String.IsNullOrEmpty(codeNamespace)) +{ + PopIndent(); +#> +} +<# +} +#> +<#+ + +private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) +{ + if (typeMapper.IsComposable(edmFunction)) + { +#> + + [DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")] + <#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#> + { +<#+ + codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter); +#> + <#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#> + } +<#+ + } + else + { +#> + + <#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#> + { +<#+ + codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter); +#> + <#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#> + } +<#+ + if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption)) + { + WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true); + } + } +} + +public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit) +{ +#> + var <#=name#> = <#=isNotNull#> ? + <#=notNullInit#> : + <#=nullInit#>; + +<#+ +} + +public const string TemplateId = "CSharp_DbContext_Context_EF6"; + +public class CodeStringGenerator +{ + private readonly CodeGenerationTools _code; + private readonly TypeMapper _typeMapper; + private readonly MetadataTools _ef; + + public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef) + { + ArgumentNotNull(code, "code"); + ArgumentNotNull(typeMapper, "typeMapper"); + ArgumentNotNull(ef, "ef"); + + _code = code; + _typeMapper = typeMapper; + _ef = ef; + } + + public string Property(EdmProperty edmProperty) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2} {{ {3}get; {4}set; }}", + Accessibility.ForProperty(edmProperty), + _typeMapper.GetTypeName(edmProperty.TypeUsage), + _code.Escape(edmProperty), + _code.SpaceAfter(Accessibility.ForGetter(edmProperty)), + _code.SpaceAfter(Accessibility.ForSetter(edmProperty))); + } + + public string NavigationProperty(NavigationProperty navProp) + { + var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType()); + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2} {{ {3}get; {4}set; }}", + AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)), + navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType, + _code.Escape(navProp), + _code.SpaceAfter(Accessibility.ForGetter(navProp)), + _code.SpaceAfter(Accessibility.ForSetter(navProp))); + } + + public string AccessibilityAndVirtual(string accessibility) + { + return accessibility + (accessibility != "private" ? " virtual" : ""); + } + + public string EntityClassOpening(EntityType entity) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1}partial class {2}{3}", + Accessibility.ForType(entity), + _code.SpaceAfter(_code.AbstractOption(entity)), + _code.Escape(entity), + _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType))); + } + + public string EnumOpening(SimpleType enumType) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} enum {1} : {2}", + Accessibility.ForType(enumType), + _code.Escape(enumType), + _code.Escape(_typeMapper.UnderlyingClrType(enumType))); + } + + public void WriteFunctionParameters(EdmFunction edmFunction, Action writeParameter) + { + var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); + foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable)) + { + var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null"; + var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")"; + var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))"; + writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit); + } + } + + public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace) + { + var parameters = _typeMapper.GetParameters(edmFunction); + + return string.Format( + CultureInfo.InvariantCulture, + "{0} IQueryable<{1}> {2}({3})", + AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), + _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), + _code.Escape(edmFunction), + string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray())); + } + + public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace) + { + var parameters = _typeMapper.GetParameters(edmFunction); + + return string.Format( + CultureInfo.InvariantCulture, + "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});", + _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), + edmFunction.NamespaceName, + edmFunction.Name, + string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()), + _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()))); + } + + public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + { + var parameters = _typeMapper.GetParameters(edmFunction); + var returnType = _typeMapper.GetReturnType(edmFunction); + + var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()); + if (includeMergeOption) + { + paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption"; + } + + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2}({3})", + AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), + returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", + _code.Escape(edmFunction), + paramList); + } + + public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + { + var parameters = _typeMapper.GetParameters(edmFunction); + var returnType = _typeMapper.GetReturnType(edmFunction); + + var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())); + if (includeMergeOption) + { + callParams = ", mergeOption" + callParams; + } + + return string.Format( + CultureInfo.InvariantCulture, + "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});", + returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", + edmFunction.Name, + callParams); + } + + public string DbSet(EntitySet entitySet) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} virtual DbSet<{1}> {2} {{ get; set; }}", + Accessibility.ForReadOnlyProperty(entitySet), + _typeMapper.GetTypeName(entitySet.ElementType), + _code.Escape(entitySet)); + } + + public string DbSetInitializer(EntitySet entitySet) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} = Set<{1}>();", + _code.Escape(entitySet), + _typeMapper.GetTypeName(entitySet.ElementType)); + } + + public string UsingDirectives(bool inHeader, bool includeCollections = true) + { + return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion()) + ? string.Format( + CultureInfo.InvariantCulture, + "{0}using System;{1}" + + "{2}", + inHeader ? Environment.NewLine : "", + includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "", + inHeader ? "" : Environment.NewLine) + : ""; + } +} + +public class TypeMapper +{ + private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName"; + + private readonly System.Collections.IList _errors; + private readonly CodeGenerationTools _code; + private readonly MetadataTools _ef; + + public static string FixNamespaces(string typeName) + { + return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial."); + } + + public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors) + { + ArgumentNotNull(code, "code"); + ArgumentNotNull(ef, "ef"); + ArgumentNotNull(errors, "errors"); + + _code = code; + _ef = ef; + _errors = errors; + } + + public string GetTypeName(TypeUsage typeUsage) + { + return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null); + } + + public string GetTypeName(EdmType edmType) + { + return GetTypeName(edmType, isNullable: null, modelNamespace: null); + } + + public string GetTypeName(TypeUsage typeUsage, string modelNamespace) + { + return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace); + } + + public string GetTypeName(EdmType edmType, string modelNamespace) + { + return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace); + } + + public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace) + { + if (edmType == null) + { + return null; + } + + var collectionType = edmType as CollectionType; + if (collectionType != null) + { + return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace)); + } + + var typeName = _code.Escape(edmType.MetadataProperties + .Where(p => p.Name == ExternalTypeNameAttributeName) + .Select(p => (string)p.Value) + .FirstOrDefault()) + ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ? + _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) : + _code.Escape(edmType)); + + if (edmType is StructuralType) + { + return typeName; + } + + if (edmType is SimpleType) + { + var clrType = UnderlyingClrType(edmType); + if (!IsEnumType(edmType)) + { + typeName = _code.Escape(clrType); + } + + typeName = FixNamespaces(typeName); + + return clrType.IsValueType && isNullable == true ? + String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) : + typeName; + } + + throw new ArgumentException("edmType"); + } + + public Type UnderlyingClrType(EdmType edmType) + { + ArgumentNotNull(edmType, "edmType"); + + var primitiveType = edmType as PrimitiveType; + if (primitiveType != null) + { + return primitiveType.ClrEquivalentType; + } + + if (IsEnumType(edmType)) + { + return GetEnumUnderlyingType(edmType).ClrEquivalentType; + } + + return typeof(object); + } + + public object GetEnumMemberValue(MetadataItem enumMember) + { + ArgumentNotNull(enumMember, "enumMember"); + + var valueProperty = enumMember.GetType().GetProperty("Value"); + return valueProperty == null ? null : valueProperty.GetValue(enumMember, null); + } + + public string GetEnumMemberName(MetadataItem enumMember) + { + ArgumentNotNull(enumMember, "enumMember"); + + var nameProperty = enumMember.GetType().GetProperty("Name"); + return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null); + } + + public System.Collections.IEnumerable GetEnumMembers(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + var membersProperty = enumType.GetType().GetProperty("Members"); + return membersProperty != null + ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null) + : Enumerable.Empty(); + } + + public bool EnumIsFlags(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + var isFlagsProperty = enumType.GetType().GetProperty("IsFlags"); + return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null); + } + + public bool IsEnumType(GlobalItem edmType) + { + ArgumentNotNull(edmType, "edmType"); + + return edmType.GetType().Name == "EnumType"; + } + + public PrimitiveType GetEnumUnderlyingType(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null); + } + + public string CreateLiteral(object value) + { + if (value == null || value.GetType() != typeof(TimeSpan)) + { + return _code.CreateLiteral(value); + } + + return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks); + } + + public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable types, string sourceFile) + { + ArgumentNotNull(types, "types"); + ArgumentNotNull(sourceFile, "sourceFile"); + + var hash = new HashSet(StringComparer.InvariantCultureIgnoreCase); + if (types.Any(item => !hash.Add(item))) + { + _errors.Add( + new CompilerError(sourceFile, -1, -1, "6023", + String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict")))); + return false; + } + return true; + } + + public IEnumerable GetEnumItemsToGenerate(IEnumerable itemCollection) + { + return GetItemsToGenerate(itemCollection) + .Where(e => IsEnumType(e)); + } + + public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T: EdmType + { + return itemCollection + .OfType() + .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName)) + .OrderBy(i => i.Name); + } + + public IEnumerable GetAllGlobalItems(IEnumerable itemCollection) + { + return itemCollection + .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i)) + .Select(g => GetGlobalItemName(g)); + } + + public string GetGlobalItemName(GlobalItem item) + { + if (item is EdmType) + { + return ((EdmType)item).Name; + } + else + { + return ((EntityContainer)item).Name; + } + } + + public IEnumerable GetSimpleProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetSimpleProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetPropertiesWithDefaultValues(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetPropertiesWithDefaultValues(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type); + } + + public IEnumerable GetCollectionNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many); + } + + public FunctionParameter GetReturnParameter(EdmFunction edmFunction) + { + ArgumentNotNull(edmFunction, "edmFunction"); + + var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters"); + return returnParamsProperty == null + ? edmFunction.ReturnParameter + : ((IEnumerable)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault(); + } + + public bool IsComposable(EdmFunction edmFunction) + { + ArgumentNotNull(edmFunction, "edmFunction"); + + var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute"); + return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null); + } + + public IEnumerable GetParameters(EdmFunction edmFunction) + { + return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); + } + + public TypeUsage GetReturnType(EdmFunction edmFunction) + { + var returnParam = GetReturnParameter(edmFunction); + return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage); + } + + public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption) + { + var returnType = GetReturnType(edmFunction); + return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType; + } +} + +public static void ArgumentNotNull(T arg, string name) where T : class +{ + if (arg == null) + { + throw new ArgumentNullException(name); + } +} +#> \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.Designer" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.Designer" new file mode 100644 index 0000000..bc5c95a --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.Designer" @@ -0,0 +1 @@ +// 未知或不受支持的语言。如果这是网站项目,可能表示 .edmx 文件不在 App_Code 目录下。 \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.Designer.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.Designer.cs" new file mode 100644 index 0000000..c836e6b --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.Designer.cs" @@ -0,0 +1,10 @@ +// 为模型“F:\Documents\Tencent Files\2223195430\FileRecv\实验\Ex8Site\Ex8Site\App_Code\MyPetShop.edmx”启用了 T4 代码生成。 +// 要启用旧代码生成功能,请将“代码生成策略”设计器属性的值 +// 更改为“旧的 ObjectContext”。当在设计器中打开该模型时,此属性会出现在 +// “属性”窗口中。 + +// 如果没有生成任何上下文和实体类,可能是因为您创建了空模型但是 +// 尚未选择要使用的实体框架版本。要为您的模型生成一个上下文类和实体 +// 类,请在设计器中打开该模型,右键单击设计器图面,然后 +// 选择“从数据库更新模型...”、“从模型生成数据库...”或“添加代码生成 +// 项...”。 \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.cs" new file mode 100644 index 0000000..524890a --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.cs" @@ -0,0 +1,142 @@ +//------------------------------------------------------------------------------ +// +// 此代码已从模板生成。 +// +// 手动更改此文件可能导致应用程序出现意外的行为。 +// 如果重新生成代码,将覆盖对此文件的手动更改。 +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; + +public partial class CartItem +{ + public int CartItemId { get; set; } + public int CustomerId { get; set; } + public int ProId { get; set; } + public string ProName { get; set; } + public decimal ListPrice { get; set; } + public int Qty { get; set; } + + public virtual Customer Customer { get; set; } + public virtual Product Product { get; set; } +} + +public partial class Category +{ + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Category() + { + this.Product = new HashSet(); + } + + public int CategoryId { get; set; } + public string Name { get; set; } + public string Descn { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection Product { get; set; } +} + +public partial class Customer +{ + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Customer() + { + this.CartItem = new HashSet(); + this.Order = new HashSet(); + } + + public int CustomerId { get; set; } + public string Name { get; set; } + public string Password { get; set; } + public string Email { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection CartItem { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection Order { get; set; } +} + +public partial class Order +{ + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Order() + { + this.OrderItem = new HashSet(); + } + + public int OrderId { get; set; } + public int CustomerId { get; set; } + public string UserName { get; set; } + public System.DateTime OrderDate { get; set; } + public string Addr1 { get; set; } + public string Addr2 { get; set; } + public string City { get; set; } + public string State { get; set; } + public string Zip { get; set; } + public string Phone { get; set; } + public string Status { get; set; } + + public virtual Customer Customer { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection OrderItem { get; set; } +} + +public partial class OrderItem +{ + public int ItemId { get; set; } + public int OrderId { get; set; } + public string ProName { get; set; } + public Nullable ListPrice { get; set; } + public int Qty { get; set; } + public Nullable TotalPrice { get; set; } + + public virtual Order Order { get; set; } +} + +public partial class Product +{ + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Product() + { + this.CartItem = new HashSet(); + } + + public int ProductId { get; set; } + public int CategoryId { get; set; } + public Nullable ListPrice { get; set; } + public Nullable UnitCost { get; set; } + public Nullable SuppId { get; set; } + public string Name { get; set; } + public string Descn { get; set; } + public string Image { get; set; } + public int Qty { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection CartItem { get; set; } + public virtual Category Category { get; set; } + public virtual Supplier Supplier { get; set; } +} + +public partial class Supplier +{ + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Supplier() + { + this.Product = new HashSet(); + } + + public int SuppId { get; set; } + public string Name { get; set; } + public string Addr1 { get; set; } + public string Addr2 { get; set; } + public string City { get; set; } + public string State { get; set; } + public string Zip { get; set; } + public string Phone { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection Product { get; set; } +} diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.edmx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.edmx" new file mode 100644 index 0000000..6f5c5c3 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.edmx" @@ -0,0 +1,526 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.edmx.diagram" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.edmx.diagram" new file mode 100644 index 0000000..306ac42 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.edmx.diagram" @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.tt" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.tt" new file mode 100644 index 0000000..e9d2ccc --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Code/MyPetShop.tt" @@ -0,0 +1,733 @@ +<#@ template language="C#" debug="false" hostspecific="true"#> +<#@ include file="EF6.Utility.CS.ttinclude"#><#@ + output extension=".cs"#><# + +const string inputFile = @"MyPetShop.edmx"; +var textTransform = DynamicTextTransformation.Create(this); +var code = new CodeGenerationTools(this); +var ef = new MetadataTools(this); +var typeMapper = new TypeMapper(code, ef, textTransform.Errors); +var fileManager = EntityFrameworkTemplateFileManager.Create(this); +var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile); +var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef); + +if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile)) +{ + return string.Empty; +} + +WriteHeader(codeStringGenerator, fileManager); + +foreach (var entity in typeMapper.GetItemsToGenerate(itemCollection)) +{ + fileManager.StartNewFile(entity.Name + ".cs"); + BeginNamespace(code); +#> +<#=codeStringGenerator.UsingDirectives(inHeader: false)#> +<#=codeStringGenerator.EntityClassOpening(entity)#> +{ +<# + var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity); + var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity); + var complexProperties = typeMapper.GetComplexProperties(entity); + + if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any()) + { +#> + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public <#=code.Escape(entity)#>() + { +<# + foreach (var edmProperty in propertiesWithDefaultValues) + { +#> + this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>; +<# + } + + foreach (var navigationProperty in collectionNavigationProperties) + { +#> + this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>(); +<# + } + + foreach (var complexProperty in complexProperties) + { +#> + this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>(); +<# + } +#> + } + +<# + } + + var simpleProperties = typeMapper.GetSimpleProperties(entity); + if (simpleProperties.Any()) + { + foreach (var edmProperty in simpleProperties) + { +#> + <#=codeStringGenerator.Property(edmProperty)#> +<# + } + } + + if (complexProperties.Any()) + { +#> + +<# + foreach(var complexProperty in complexProperties) + { +#> + <#=codeStringGenerator.Property(complexProperty)#> +<# + } + } + + var navigationProperties = typeMapper.GetNavigationProperties(entity); + if (navigationProperties.Any()) + { +#> + +<# + foreach (var navigationProperty in navigationProperties) + { + if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many) + { +#> + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] +<# + } +#> + <#=codeStringGenerator.NavigationProperty(navigationProperty)#> +<# + } + } +#> +} +<# + EndNamespace(code); +} + +foreach (var complex in typeMapper.GetItemsToGenerate(itemCollection)) +{ + fileManager.StartNewFile(complex.Name + ".cs"); + BeginNamespace(code); +#> +<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#> +<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#> +{ +<# + var complexProperties = typeMapper.GetComplexProperties(complex); + var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex); + + if (propertiesWithDefaultValues.Any() || complexProperties.Any()) + { +#> + public <#=code.Escape(complex)#>() + { +<# + foreach (var edmProperty in propertiesWithDefaultValues) + { +#> + this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>; +<# + } + + foreach (var complexProperty in complexProperties) + { +#> + this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>(); +<# + } +#> + } + +<# + } + + var simpleProperties = typeMapper.GetSimpleProperties(complex); + if (simpleProperties.Any()) + { + foreach(var edmProperty in simpleProperties) + { +#> + <#=codeStringGenerator.Property(edmProperty)#> +<# + } + } + + if (complexProperties.Any()) + { +#> + +<# + foreach(var edmProperty in complexProperties) + { +#> + <#=codeStringGenerator.Property(edmProperty)#> +<# + } + } +#> +} +<# + EndNamespace(code); +} + +foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection)) +{ + fileManager.StartNewFile(enumType.Name + ".cs"); + BeginNamespace(code); +#> +<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#> +<# + if (typeMapper.EnumIsFlags(enumType)) + { +#> +[Flags] +<# + } +#> +<#=codeStringGenerator.EnumOpening(enumType)#> +{ +<# + var foundOne = false; + + foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType)) + { + foundOne = true; +#> + <#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>, +<# + } + + if (foundOne) + { + this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1); + } +#> +} +<# + EndNamespace(code); +} + +fileManager.Process(); + +#> +<#+ + +public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager) +{ + fileManager.StartHeader(); +#> +//------------------------------------------------------------------------------ +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#> +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#> +// +//------------------------------------------------------------------------------ +<#=codeStringGenerator.UsingDirectives(inHeader: true)#> +<#+ + fileManager.EndBlock(); +} + +public void BeginNamespace(CodeGenerationTools code) +{ + var codeNamespace = code.VsNamespaceSuggestion(); + if (!String.IsNullOrEmpty(codeNamespace)) + { +#> +namespace <#=code.EscapeNamespace(codeNamespace)#> +{ +<#+ + PushIndent(" "); + } +} + +public void EndNamespace(CodeGenerationTools code) +{ + if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion())) + { + PopIndent(); +#> +} +<#+ + } +} + +public const string TemplateId = "CSharp_DbContext_Types_EF6"; + +public class CodeStringGenerator +{ + private readonly CodeGenerationTools _code; + private readonly TypeMapper _typeMapper; + private readonly MetadataTools _ef; + + public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef) + { + ArgumentNotNull(code, "code"); + ArgumentNotNull(typeMapper, "typeMapper"); + ArgumentNotNull(ef, "ef"); + + _code = code; + _typeMapper = typeMapper; + _ef = ef; + } + + public string Property(EdmProperty edmProperty) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2} {{ {3}get; {4}set; }}", + Accessibility.ForProperty(edmProperty), + _typeMapper.GetTypeName(edmProperty.TypeUsage), + _code.Escape(edmProperty), + _code.SpaceAfter(Accessibility.ForGetter(edmProperty)), + _code.SpaceAfter(Accessibility.ForSetter(edmProperty))); + } + + public string NavigationProperty(NavigationProperty navProp) + { + var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType()); + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2} {{ {3}get; {4}set; }}", + AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)), + navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType, + _code.Escape(navProp), + _code.SpaceAfter(Accessibility.ForGetter(navProp)), + _code.SpaceAfter(Accessibility.ForSetter(navProp))); + } + + public string AccessibilityAndVirtual(string accessibility) + { + return accessibility + (accessibility != "private" ? " virtual" : ""); + } + + public string EntityClassOpening(EntityType entity) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1}partial class {2}{3}", + Accessibility.ForType(entity), + _code.SpaceAfter(_code.AbstractOption(entity)), + _code.Escape(entity), + _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType))); + } + + public string EnumOpening(SimpleType enumType) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} enum {1} : {2}", + Accessibility.ForType(enumType), + _code.Escape(enumType), + _code.Escape(_typeMapper.UnderlyingClrType(enumType))); + } + + public void WriteFunctionParameters(EdmFunction edmFunction, Action writeParameter) + { + var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); + foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable)) + { + var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null"; + var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")"; + var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))"; + writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit); + } + } + + public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace) + { + var parameters = _typeMapper.GetParameters(edmFunction); + + return string.Format( + CultureInfo.InvariantCulture, + "{0} IQueryable<{1}> {2}({3})", + AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), + _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), + _code.Escape(edmFunction), + string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray())); + } + + public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace) + { + var parameters = _typeMapper.GetParameters(edmFunction); + + return string.Format( + CultureInfo.InvariantCulture, + "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});", + _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), + edmFunction.NamespaceName, + edmFunction.Name, + string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()), + _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()))); + } + + public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + { + var parameters = _typeMapper.GetParameters(edmFunction); + var returnType = _typeMapper.GetReturnType(edmFunction); + + var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()); + if (includeMergeOption) + { + paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption"; + } + + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2}({3})", + AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), + returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", + _code.Escape(edmFunction), + paramList); + } + + public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + { + var parameters = _typeMapper.GetParameters(edmFunction); + var returnType = _typeMapper.GetReturnType(edmFunction); + + var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())); + if (includeMergeOption) + { + callParams = ", mergeOption" + callParams; + } + + return string.Format( + CultureInfo.InvariantCulture, + "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});", + returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", + edmFunction.Name, + callParams); + } + + public string DbSet(EntitySet entitySet) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} virtual DbSet<{1}> {2} {{ get; set; }}", + Accessibility.ForReadOnlyProperty(entitySet), + _typeMapper.GetTypeName(entitySet.ElementType), + _code.Escape(entitySet)); + } + + public string UsingDirectives(bool inHeader, bool includeCollections = true) + { + return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion()) + ? string.Format( + CultureInfo.InvariantCulture, + "{0}using System;{1}" + + "{2}", + inHeader ? Environment.NewLine : "", + includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "", + inHeader ? "" : Environment.NewLine) + : ""; + } +} + +public class TypeMapper +{ + private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName"; + + private readonly System.Collections.IList _errors; + private readonly CodeGenerationTools _code; + private readonly MetadataTools _ef; + + public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors) + { + ArgumentNotNull(code, "code"); + ArgumentNotNull(ef, "ef"); + ArgumentNotNull(errors, "errors"); + + _code = code; + _ef = ef; + _errors = errors; + } + + public static string FixNamespaces(string typeName) + { + return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial."); + } + + public string GetTypeName(TypeUsage typeUsage) + { + return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null); + } + + public string GetTypeName(EdmType edmType) + { + return GetTypeName(edmType, isNullable: null, modelNamespace: null); + } + + public string GetTypeName(TypeUsage typeUsage, string modelNamespace) + { + return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace); + } + + public string GetTypeName(EdmType edmType, string modelNamespace) + { + return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace); + } + + public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace) + { + if (edmType == null) + { + return null; + } + + var collectionType = edmType as CollectionType; + if (collectionType != null) + { + return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace)); + } + + var typeName = _code.Escape(edmType.MetadataProperties + .Where(p => p.Name == ExternalTypeNameAttributeName) + .Select(p => (string)p.Value) + .FirstOrDefault()) + ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ? + _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) : + _code.Escape(edmType)); + + if (edmType is StructuralType) + { + return typeName; + } + + if (edmType is SimpleType) + { + var clrType = UnderlyingClrType(edmType); + if (!IsEnumType(edmType)) + { + typeName = _code.Escape(clrType); + } + + typeName = FixNamespaces(typeName); + + return clrType.IsValueType && isNullable == true ? + String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) : + typeName; + } + + throw new ArgumentException("edmType"); + } + + public Type UnderlyingClrType(EdmType edmType) + { + ArgumentNotNull(edmType, "edmType"); + + var primitiveType = edmType as PrimitiveType; + if (primitiveType != null) + { + return primitiveType.ClrEquivalentType; + } + + if (IsEnumType(edmType)) + { + return GetEnumUnderlyingType(edmType).ClrEquivalentType; + } + + return typeof(object); + } + + public object GetEnumMemberValue(MetadataItem enumMember) + { + ArgumentNotNull(enumMember, "enumMember"); + + var valueProperty = enumMember.GetType().GetProperty("Value"); + return valueProperty == null ? null : valueProperty.GetValue(enumMember, null); + } + + public string GetEnumMemberName(MetadataItem enumMember) + { + ArgumentNotNull(enumMember, "enumMember"); + + var nameProperty = enumMember.GetType().GetProperty("Name"); + return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null); + } + + public System.Collections.IEnumerable GetEnumMembers(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + var membersProperty = enumType.GetType().GetProperty("Members"); + return membersProperty != null + ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null) + : Enumerable.Empty(); + } + + public bool EnumIsFlags(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + var isFlagsProperty = enumType.GetType().GetProperty("IsFlags"); + return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null); + } + + public bool IsEnumType(GlobalItem edmType) + { + ArgumentNotNull(edmType, "edmType"); + + return edmType.GetType().Name == "EnumType"; + } + + public PrimitiveType GetEnumUnderlyingType(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null); + } + + public string CreateLiteral(object value) + { + if (value == null || value.GetType() != typeof(TimeSpan)) + { + return _code.CreateLiteral(value); + } + + return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks); + } + + public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable types, string sourceFile) + { + ArgumentNotNull(types, "types"); + ArgumentNotNull(sourceFile, "sourceFile"); + + var hash = new HashSet(StringComparer.InvariantCultureIgnoreCase); + if (types.Any(item => !hash.Add(item))) + { + _errors.Add( + new CompilerError(sourceFile, -1, -1, "6023", + String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict")))); + return false; + } + return true; + } + + public IEnumerable GetEnumItemsToGenerate(IEnumerable itemCollection) + { + return GetItemsToGenerate(itemCollection) + .Where(e => IsEnumType(e)); + } + + public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T: EdmType + { + return itemCollection + .OfType() + .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName)) + .OrderBy(i => i.Name); + } + + public IEnumerable GetAllGlobalItems(IEnumerable itemCollection) + { + return itemCollection + .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i)) + .Select(g => GetGlobalItemName(g)); + } + + public string GetGlobalItemName(GlobalItem item) + { + if (item is EdmType) + { + return ((EdmType)item).Name; + } + else + { + return ((EntityContainer)item).Name; + } + } + + public IEnumerable GetSimpleProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetSimpleProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetPropertiesWithDefaultValues(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetPropertiesWithDefaultValues(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type); + } + + public IEnumerable GetCollectionNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many); + } + + public FunctionParameter GetReturnParameter(EdmFunction edmFunction) + { + ArgumentNotNull(edmFunction, "edmFunction"); + + var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters"); + return returnParamsProperty == null + ? edmFunction.ReturnParameter + : ((IEnumerable)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault(); + } + + public bool IsComposable(EdmFunction edmFunction) + { + ArgumentNotNull(edmFunction, "edmFunction"); + + var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute"); + return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null); + } + + public IEnumerable GetParameters(EdmFunction edmFunction) + { + return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); + } + + public TypeUsage GetReturnType(EdmFunction edmFunction) + { + var returnParam = GetReturnParameter(edmFunction); + return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage); + } + + public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption) + { + var returnType = GetReturnType(edmFunction); + return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType; + } +} + +public static void ArgumentNotNull(T arg, string name) where T : class +{ + if (arg == null) + { + throw new ArgumentNullException(name); + } +} +#> \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Data/MyPetShop.mdf" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Data/MyPetShop.mdf" new file mode 100644 index 0000000..9332023 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/App_Data/MyPetShop.mdf" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Insert.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Insert.aspx" new file mode 100644 index 0000000..8d894b4 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Insert.aspx" @@ -0,0 +1,63 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Insert.aspx.cs" Inherits="Insert" %> + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 商品分类: + +
+ 商品名称: +
+ 商品价格: +
+ 商品库存: +
+ 供应商: + +
+ 商品描述: +
+
+ + + + + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Insert.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Insert.aspx.cs" new file mode 100644 index 0000000..99b9ba6 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Insert.aspx.cs" @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +public partial class Insert : System.Web.UI.Page +{ + MyPetShopEntities db = new MyPetShopEntities(); + protected void Page_Load(object sender, EventArgs e) + { + + if (!IsPostBack) + { + + var categories = db.Category.ToList(); + ddlCategory.DataTextField = "Name"; + ddlCategory.DataValueField = "CategoryId"; + ddlCategory.DataSource = categories; + ddlCategory.DataBind(); + var suppliers = db.Supplier.ToList(); + ddlSupplier.DataTextField = "Name"; + ddlSupplier.DataValueField = "SuppId"; + ddlSupplier.DataSource = suppliers; + ddlSupplier.DataBind(); + } + } + + protected void btnInsert_Click(object sender, EventArgs e) + { + Product product = new Product(); + product.CategoryId = int.Parse(ddlCategory.SelectedValue); + product.Name = txtName.Text; + product.ListPrice = decimal.Parse(txtListPrice.Text); + product.Qty = int.Parse(txtQty.Text); + product.Descn = txtDescn.Text; + product.Image = "~/Prod_Images/default.jpg"; + product.UnitCost = product.ListPrice; + product.SuppId = int.Parse(ddlSupplier.SelectedValue); + db.Product.Add(product); + db.SaveChanges(); + } + + protected void btnReturn_Click(object sender, EventArgs e) + { + Response.Redirect("RepeaterForm.aspx"); + } + } \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/ProShow.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/ProShow.aspx" new file mode 100644 index 0000000..b27f957 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/ProShow.aspx" @@ -0,0 +1,71 @@ +<%@ Page Language="C#" AutoEventWireup="true" + CodeFile="ProShow.aspx.cs" Inherits="ProShow" %> + + + + + + 商品展示 + + +
+
+ 分类名: + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 商品名称: + +
商品价格: + +
商品描述: + +
库存: + +
+
+
+ +
+
+
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/ProShow.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/ProShow.aspx.cs" new file mode 100644 index 0000000..60e6566 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/ProShow.aspx.cs" @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +public partial class ProShow : System.Web.UI.Page +{ + MyPetShopEntities db = new MyPetShopEntities(); + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + var categories = db.Category.ToList(); + ddlCategory.DataSource = categories; + ddlCategory.DataBind(); + Bind(); + } + } + protected void DdlCategory_SelectedIndexChanged(object sender, EventArgs e) + { + Bind(); + } + private void Bind() + { + int categoryId = int.Parse(ddlCategory.SelectedValue); + var products = db.Product.Where(p => p.CategoryId == categoryId).ToList(); + gvProduct.DataSource = products; + gvProduct.DataBind(); + } + protected void GvProduct_PageIndexChanging(object sender, GridViewPageEventArgs e) + { + gvProduct.PageIndex = e.NewPageIndex; + Bind(); + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Backyard/200944162331icon-cat.gif" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Backyard/200944162331icon-cat.gif" new file mode 100644 index 0000000..531e343 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Backyard/200944162331icon-cat.gif" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Backyard/cat.gif" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Backyard/cat.gif" new file mode 100644 index 0000000..531e343 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Backyard/cat.gif" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Backyard/zebra.gif" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Backyard/zebra.gif" new file mode 100644 index 0000000..2149633 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Backyard/zebra.gif" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Birds/domestic.gif" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Birds/domestic.gif" new file mode 100644 index 0000000..f35c7ea Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Birds/domestic.gif" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Birds/flowerloving.gif" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Birds/flowerloving.gif" new file mode 100644 index 0000000..76a9751 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Birds/flowerloving.gif" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Bugs/ant.gif" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Bugs/ant.gif" new file mode 100644 index 0000000..777c338 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Bugs/ant.gif" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Bugs/butterfly.gif" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Bugs/butterfly.gif" new file mode 100644 index 0000000..96e8de5 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Bugs/butterfly.gif" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Endangered/201822694011icon-panda.gif" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Endangered/201822694011icon-panda.gif" new file mode 100644 index 0000000..5c78b1d Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Endangered/201822694011icon-panda.gif" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Endangered/panda.gif" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Endangered/panda.gif" new file mode 100644 index 0000000..5c78b1d Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Endangered/panda.gif" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Endangered/pointy.gif" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Endangered/pointy.gif" new file mode 100644 index 0000000..b7893e6 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Endangered/pointy.gif" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Fish/20182484834default.jpg" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Fish/20182484834default.jpg" new file mode 100644 index 0000000..f52bf06 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Fish/20182484834default.jpg" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Fish/eucalyptus.gif" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Fish/eucalyptus.gif" new file mode 100644 index 0000000..57e9948 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Fish/eucalyptus.gif" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Fish/meno.gif" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Fish/meno.gif" new file mode 100644 index 0000000..dc0c8d2 Binary files /dev/null and "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Prod_Images/Fish/meno.gif" differ diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/RepeaterForm.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/RepeaterForm.aspx" new file mode 100644 index 0000000..6ed61c2 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/RepeaterForm.aspx" @@ -0,0 +1,75 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RepeaterForm.aspx.cs" Inherits="RepeaterForm" %> + + + + + + + 利用Reater控件实现数据管理 + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + 商品名称:<%# Eval("Name") %>
商品价格:<%# Eval("ListPrice") %>
商品描述:<%# Eval("Descn") %>
库存:<%# Eval("Qty") %>
+ 新建 + 编辑 + <%--<%# %> 中可以进行字符串的拼接--%> + +
+
+
+
+
+ + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/RepeaterForm.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/RepeaterForm.aspx.cs" new file mode 100644 index 0000000..391bb2b --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/RepeaterForm.aspx.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +public partial class RepeaterForm : System.Web.UI.Page +{ + MyPetShopEntities db = new MyPetShopEntities(); + protected void Bind() + { + var products = db.Product.OrderByDescending(p => p.ProductId).ToList(); + rptProduct.DataSource = products; + rptProduct.DataBind(); + } + + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + Bind(); + } + } + + protected void BtnDelete_Click(object sender, EventArgs e) + { + LinkButton btndel = (LinkButton)sender; + var product = db.Product.Find(int.Parse(btndel.CommandArgument)); + db.Product.Remove(product); + db.SaveChanges(); + Bind(); + } + + +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Update.aspx" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Update.aspx" new file mode 100644 index 0000000..bb511d3 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Update.aspx" @@ -0,0 +1,70 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Update.aspx.cs" Inherits="Update" %> + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
商品编号: + +
+ 商品分类: + + +
+ 商品名称: +
+ 商品价格: +
+ 商品库存: +
+ 供应商: + + +
+ 商品描述: +
+
+ + + + + + diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Update.aspx.cs" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Update.aspx.cs" new file mode 100644 index 0000000..28c8178 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Update.aspx.cs" @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +public partial class Update : System.Web.UI.Page +{ + MyPetShopEntities db = new MyPetShopEntities(); + protected void Page_Load(object sender, EventArgs e) + { + + if (!IsPostBack) + { + var categories = db.Category.ToList(); + ddlCategory.DataTextField = "Name"; + ddlCategory.DataValueField = "CategoryId"; + ddlCategory.DataSource = categories; + ddlCategory.DataBind(); + var suppliers = db.Supplier.ToList(); + ddlSupplier.DataTextField = "Name"; + ddlSupplier.DataValueField = "SuppId"; + ddlSupplier.DataSource = suppliers; + ddlSupplier.DataBind(); + string productId = Request.QueryString["ProductId"]; + var product = db.Product.Find(int.Parse(productId)); + txtProductId.Text = productId; + ddlCategory.SelectedValue = product.CategoryId.ToString(); + txtProductId.ReadOnly = true; + txtName.Text = product.Name; + txtListPrice.Text = product.ListPrice.ToString(); + txtQty.Text = product.Qty.ToString(); + ddlSupplier.SelectedValue = product.SuppId.ToString(); + txtDescn.Text = product.Descn; + + } + } + + + protected void btnUpdate_Click(object sender, EventArgs e) + { + var product = db.Product.Find(int.Parse(txtProductId.Text)); + product.Name = txtName.Text; + product.CategoryId = int.Parse(ddlCategory.SelectedValue); + product.ListPrice = decimal.Parse(txtListPrice.Text); + product.Qty = int.Parse(txtQty.Text); + product.SuppId = int.Parse(ddlSupplier.SelectedValue); + product.Descn = txtDescn.Text; + db.SaveChanges(); + + } + + protected void btnReturn_Click(object sender, EventArgs e) + { + Response.Redirect("RepeaterForm.aspx"); + } +} \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Web.Debug.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Web.Debug.config" new file mode 100644 index 0000000..755e745 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Web.Debug.config" @@ -0,0 +1,32 @@ + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Web.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Web.config" new file mode 100644 index 0000000..6a254ee --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/Web.config" @@ -0,0 +1,50 @@ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/packages.config" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/packages.config" new file mode 100644 index 0000000..99bce91 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/packages.config" @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git "a/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/vwd.webinfo" "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/vwd.webinfo" new file mode 100644 index 0000000..5342215 --- /dev/null +++ "b/Web\344\277\241\346\201\257\347\256\241\347\220\206\347\263\273\347\273\237 \345\256\236\351\252\214\346\212\245\345\221\212/2024/exp/Ex8Site/Ex8Site/vwd.webinfo" @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CBook.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/CBook.cpp" new file mode 100644 index 0000000..1b26d9a --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CBook.cpp" @@ -0,0 +1,78 @@ +#include "pch.h" +#include "CBook.h" + +CBook::CBook() +{ + +} + +CBook::CBook(string sName, string sISBN, string sPublisher, int nStock, + int nPYear, int nPMonth, string sCatalog, + int nbYear, int nbMonth, int nbDay, int nBNo, string sBorrow) +{ + m_sName = sName; + m_sISBN = sISBN; + m_sPublisher = sPublisher; + m_nStock = nStock; + m_nPYear = nPYear; + m_nPMonth = nPMonth; + m_sCatalog = sCatalog; + m_nbYear = nbYear; + m_nbMonth = nbMonth; + m_nbDay = nbDay; + m_nBNo = nBNo; + m_csBorrow = sBorrow; +} + +CBook::~CBook() +{ + +} + +void CBook::SetBook(string sName, string sISBN, string sPublisher, int nStock, + int nPYear, int nPMonth, string sCatalog, + int nbYear, int nbMonth, int nbDay, int nBNo, string sBorrow) +{ + m_sName = sName; + m_sISBN = sISBN; + m_sPublisher = sPublisher; + m_nStock = nStock; + m_nPYear = nPYear; + m_nPMonth = nPMonth; + m_sCatalog = sCatalog; + m_nbYear = nbYear; + m_nbMonth = nbMonth; + m_nbDay = nbDay; + m_nBNo = nBNo; + m_csBorrow = sBorrow; +} + +void CBook::Save(ofstream& out) +{ + out << m_sName << _T("\t"); + out << m_sISBN << _T("\t"); + out << m_sPublisher << _T("\t"); + out << m_nStock << _T("\t"); + out << m_nPYear << _T("\t"); + out << m_nPMonth << _T("\t"); + out << m_sCatalog << _T("\t"); + out << m_nbYear << _T("\t"); + out << m_nbMonth << _T("\t"); + out << m_nbDay << _T("\t"); + out << m_nBNo << _T("\t"); + out << m_csBorrow << _T("\n"); +} + +void CBook::Load(ifstream& in) +{ + in >> m_sName; + in >> m_sISBN; + in >> m_sPublisher; + in >> m_nStock; + in >> m_nPYear; + in >> m_nPMonth; + in >> m_sCatalog; + in >> m_nbYear >> m_nbMonth >> m_nbDay; + in >> m_nBNo; + in >> m_csBorrow; +} diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CBook.h" "b/cpp\350\257\276\350\256\276/LibSystem/CBook.h" new file mode 100644 index 0000000..3bc028c --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CBook.h" @@ -0,0 +1,32 @@ +#pragma once + +class CBook +{ +public: + CBook(); + CBook(string sName, string sISBN, string sPublisher, int nStock, + int nPYear, int nPMonth, string sCatalog, + int nbYear, int nbMonth, int nbDay, int nBNo, string sBorrow); + ~CBook(); + void SetBook(string sName, string sISBN, string sPublisher, int nStock, + int nPYear, int nPMonth, string sCatalog, + int nbYear, int nbMonth, int nbDay, int nBNo, string sBorrow); + + void Save(ofstream &out); + void Load(ifstream& in); +public: + string m_sName; + string m_sISBN; + string m_sPublisher; + int m_nBNum; + int m_nPYear; + int m_nPMonth; + string m_sCatalog; + COleDateTime m_dtBuy; + int m_nbYear; + int m_nbMonth; + int m_nbDay; + int m_nBNo; + string m_csBorrow; + int m_nStock; +}; diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CData.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/CData.cpp" new file mode 100644 index 0000000..e8337fe --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CData.cpp" @@ -0,0 +1,187 @@ +#include "pch.h" +#include "CBook.h" +#include "CData.h" + +int CData::m_staID = 0; +CData* CData::m_sInstance = NULL; +CData::CData() +{ + if (m_staID == 0) + m_staID++; + m_listBook = list(); +} + +CData::~CData() +{ + +} + +CData* CData::CreateInstance() +{ + if (m_staID == 0) + m_sInstance = new CData(); + return m_sInstance; +} + +void CData::DeleteInstance() +{ + if (m_sInstance != NULL) + { + delete m_sInstance; + m_staID = 0; + } + m_sInstance = NULL; +} + +void CData::Save(CString csFullPath) +{ + ofstream out(csFullPath, ios::out); + if (out.is_open()) + { + out << m_listBook.size() << endl; + for (list::iterator it = m_listBook.begin(); it != m_listBook.end(); it++) + it->Save(out); + out.close(); + } +} + +void CData::Load(CString csFullPath) +{ + m_listBook.clear(); + ifstream in(csFullPath, ios::in); + if (in.is_open()) + { + int num; + in >> num; + for (int i = 0; i < num; i++) + { + CBook book = CBook(); + book.Load(in); + m_listBook.push_back(book); + } + in.close(); + } +} + +void CData::AddBook(CBook& book) +{ + m_listBook.push_back(book); +} + +void CData::AddBook(string sName, string sISBN, string sPublisher, int nStock, + int nPYear, int nPMonth, string sCatalog, + int nbYear, int nbMonth, int nbDay, int nBNo, string sBorrow) +{ + CBook Book = CBook(); + Book.SetBook(sName, sISBN, sPublisher, nStock, nPYear, nPMonth, sCatalog, + nbYear, nbMonth, nbDay, nBNo, sBorrow); + m_listBook.push_back(Book); +} + +void CData::DeleBookByNo(string sISBN, int nBNo) +{ + bool bFound = false; + for (list::iterator it = m_listBook.begin(); it != m_listBook.end(); it++) + { + if (it->m_sISBN == sISBN && it->m_nBNo == nBNo) + { + m_listBook.erase(it); + bFound = true; + break; + } + } + if (bFound == false) + { + AfxMessageBox(_T("鼮ϢԲ")); + } +} + +void CData::DeleBookByISBN(string sISBN) +{ + bool bFound = false; + for (list::iterator it = m_listBook.begin(); it != m_listBook.end(); it++) + { + + if (it->m_sISBN == sISBN) + { + m_listBook.erase(it); + it = m_listBook.begin(); + bFound = true; + } + } + list::iterator it = m_listBook.begin(); + if (it->m_sISBN == sISBN) + { + m_listBook.erase(it); + bFound = true; + } + if (bFound == false) + { + AfxMessageBox(_T("鼮ϢԲ")); + } +} + +void CData::UpdateBookInfo(string sName, string sISBN, string sPublisher, + int nStock, int nPYear, int nPMonth, string sCatalog) +{ + bool bFound = false; + for (list::iterator it = m_listBook.begin(); it != m_listBook.end(); it++) + { + if (it->m_sISBN == sISBN) + { + it->m_sName = sName; + it->m_sPublisher = sPublisher; + it->m_nPYear = nPYear; + it->m_nPMonth = nPMonth; + it->m_sCatalog = sCatalog; + it->m_nStock = nStock; + bFound = true; + } + } + if (bFound == false) + { + AfxMessageBox(_T("鼮ϢԲ")); + } +} + +void CData::UpdateBook(string sISBN, int nbYear, int nbMonth, int nbDay, + int nBNo, string sBorrow) +{ + bool bFound = false; + for (list::iterator it = m_listBook.begin(); it != m_listBook.end(); it++) + { + + if (it->m_sISBN == sISBN && it->m_nBNo == nBNo) + { + it->m_nbYear = nbYear; + it->m_nbMonth = nbMonth; + it->m_nbDay = nbDay; + it->m_nBNo = nBNo; + it->m_csBorrow = sBorrow; + bFound = true; + } + } + if (bFound == false) + { + AfxMessageBox(_T("鼮ϢԲ")); + } +} + +void CData::ReturnBook(string sISBN, int nBNo, string sBorrow) +{ + bool bFound = false; + for (list::iterator it = m_listBook.begin(); it != m_listBook.end(); it++) + { + + if (it->m_sISBN == sISBN && it->m_nBNo == nBNo) + { + it->m_nBNo = nBNo; + it->m_csBorrow = sBorrow; + bFound = true; + } + } + if (bFound == false) + { + AfxMessageBox(_T("鼮ϢԲ")); + } +} \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CData.h" "b/cpp\350\257\276\350\256\276/LibSystem/CData.h" new file mode 100644 index 0000000..14c1eb6 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CData.h" @@ -0,0 +1,32 @@ +#pragma once +#include "CBook.h" +#include "CUser.h" +class CData +{ +private: + CData(); + ~CData(); +public: + static CData* CreateInstance(); + static void DeleteInstance(); + void AddBook(CBook& book); + void AddBook(string sName, string sISBN, string sPublisher, int nStock, + int nPYear, int nPMonth, string sCatalog, + int nbYear, int nbMonth, int nbDay, int nBNo, string sBorrow); + void DeleBookByNo(string sISBN, int nBNo); + void DeleBookByISBN(string sISBN); + void UpdateBookInfo(string sName, string sISBN, string sPublisher, + int nStock, int nPYear, int nPMonth, string sCatalog); + void UpdateBook(string sISBN, int nbYear, int nbMonth, int nbDay, + int nBNo, string sBorrow); + void ReturnBook(string sISBN, int nBNo, string sBorrow); + void Save(CString csFullPath); + void Load(CString csFullPath); + + inline int GetNumOfBook() { return m_listBook.size(); } +public: + static int m_staID; + static CData* m_sInstance; + list m_listBook; +}; + diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDataAdapter.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/CDataAdapter.cpp" new file mode 100644 index 0000000..996f463 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDataAdapter.cpp" @@ -0,0 +1,197 @@ +#include "pch.h" +#include "CDataAdapter.h" + +CDataAdapter::CDataAdapter() +{ + m_pData = CData::CreateInstance(); +} +CDataAdapter::~CDataAdapter() +{ + if (m_pData) + CData::DeleteInstance(); + m_pData = NULL; +} + +void CDataAdapter::AddBook(string sName, string sISBN, string sPublisher, int nStock, + int nPYear, int nPMonth, string sCatalog, + int nbYear, int nbMonth, int nbDay, int nBNo, string sBorrow) +{ + m_pData->AddBook(sName, sISBN, sPublisher, nStock, + nPYear, nPMonth, sCatalog, nbYear, nbMonth, nbDay, nBNo, sBorrow); +} + +void CDataAdapter::DeleBookByNo(string sISBN, int nBNo) +{ + m_pData->DeleBookByNo(sISBN, nBNo); + AfxMessageBox(_T("鱾ɾɹ")); +} + +void CDataAdapter::DeleBookByISBN(string sISBN) +{ + m_pData->DeleBookByISBN(sISBN); + AfxMessageBox(_T("鼮ɾɹ")); +} + +void CDataAdapter::UpdateBookInfo(string sName, string sISBN, string sPublisher, + int nStock, int nPYear, int nPMonth, string sCatalog) +{ + m_pData->UpdateBookInfo(sName, sISBN, sPublisher,nStock, nPYear, nPMonth, sCatalog); +} + +void CDataAdapter::UpdateBook(string sISBN, int nbYear, int nbMonth, int nbDay, + int nBNo, string sBorrow) +{ + m_pData->UpdateBook(sISBN, nbYear, nbMonth, nbDay, nBNo, sBorrow); + AfxMessageBox(_T("鱾Ϣijɹ")); +} + +void CDataAdapter::ReturnBook(string sISBN, int nBNo, string sBorrow) +{ + m_pData->ReturnBook(sISBN, nBNo, sBorrow); + AfxMessageBox(_T("״̬³ɹ")); +} + +void CDataAdapter::Save() +{ + m_pData->Save(_T(".\\data.txt")); +} + +void CDataAdapter::Load() +{ + m_pData->Load(_T(".\\data.txt")); +} + +bool CDataAdapter::GetFirstBook(CBook& book) +{ + list* pList = GetListOfBook(); + if (pList->size() == 0) + return false; + + m_it = pList->begin(); + book = *m_it; + return true; +} + +bool CDataAdapter::GetPrevBook(CBook& book) +{ + list* pList = GetListOfBook(); + bool bRes = false; + + if (pList->size() != 0) + { + if (m_it != pList->begin()) + m_it--; + + book = *m_it; + bRes = true; + } + return bRes; +} + +bool CDataAdapter::GetNextBook(CBook& book) +{ + list* pList = GetListOfBook(); + bool bRes = false; + if (pList->size() != 0) + { + m_it++; + if (m_it == pList->end()) + m_it--; + book= *m_it; + bRes = true; + } + return bRes; +} + +bool CDataAdapter::GetLastBook(CBook& book) +{ + list* pList = GetListOfBook(); + if (pList->size() == 0) + return false; + + m_it = pList->end(); + m_it--; + book = *m_it; + return true; +} + +bool CDataAdapter::FindBookByNo(string sISBN, int nBNo, CBook& book) +{ + list* pList = GetListOfBook(); + if (pList->size() == 0) + return false; + + bool bFound = false; + for (list::iterator it = pList->begin(); it != pList->end(); it++) + { + if (it->m_sISBN == sISBN && it->m_nBNo == nBNo) + { + m_it = it; + book = *it; + bFound = true; + break; + } + } + if (bFound == false) + { + AfxMessageBox(_T("鼮ϢԲ")); + m_it = pList->begin(); + book = *m_it; + } + return bFound; +} + +bool CDataAdapter::FindBNumByISBN(string sISBN, CBook& book) +{ + list* pList = GetListOfBook(); + if (pList->size() == 0) + return false; + + bool bFound = false; + int nNextNo = 1; + for (list::iterator it = pList->begin(); it != pList->end(); it++) + { + if (it->m_sISBN == sISBN) + { + if (it->m_nBNo >= nNextNo) + { + nNextNo = it->m_nBNo; + m_it = it; + book = *it; + bFound = true; + } + } + } + return bFound; +} + +void CDataAdapter::FillWithBook(CBook& book, CString& sName, CString& sISBN, CString& sPublisher, + int& nStock, int& nPYear, int& nPMonth, CString& sCatalog, + COleDateTime& dtBuy, int& nBNo, CString& sBorrow) +{ + sName = book.m_sName.c_str(); + sISBN = book.m_sISBN.c_str(); + sPublisher = book.m_sPublisher.c_str(); + nStock = book.m_nStock; + nPYear = book.m_nPYear; + nPMonth = book.m_nPMonth; + dtBuy = COleDateTime(book.m_nbYear, book.m_nbMonth, book.m_nbDay, 0, 0, 0); + nBNo = book.m_nBNo; + sBorrow = book.m_csBorrow.c_str(); +} + +int CDataAdapter::ReturnNum(string sISBN) +{ + list* pList = GetListOfBook(); + if (pList->size() == 0) + return 0; + int nReturn = 0; + for (list::iterator it = pList->begin(); it != pList->end(); it++) + { + if (it->m_sISBN == sISBN && it->m_csBorrow == _T("δ")) + { + nReturn++; + } + } + return nReturn; +} \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDataAdapter.h" "b/cpp\350\257\276\350\256\276/LibSystem/CDataAdapter.h" new file mode 100644 index 0000000..d967ca6 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDataAdapter.h" @@ -0,0 +1,38 @@ +#pragma once +#include "CData.h" +class CDataAdapter +{ +public: + CDataAdapter(); + ~CDataAdapter(); + void AddBook(string sName, string sISBN, string sPublisher, int nStock, + int nPYear, int nPMonth, string sCatalog, + int nbYear, int nbMonth, int nbDay, int nBNo, string sBorrow); + void DeleBookByNo(string sISBN, int nBNo); + void DeleBookByISBN(string sISBN); + void UpdateBookInfo(string sName, string sISBN, string sPublisher, + int nStock, int nPYear, int nPMonth, string sCatalog); + void UpdateBook(string sISBN, int nbYear, int nbMonth, int nbDay, + int nBNo, string sBorrow); + void ReturnBook(string sISBN, int nBNo, string sBorrow); + + void Save(); + void Load(); + + inline int GetNumOfBook() { return m_pData->GetNumOfBook(); } + inline list* GetListOfBook() { return &m_pData->m_listBook; } + bool GetFirstBook(CBook& book); + bool GetNextBook(CBook& book); + bool GetPrevBook(CBook& book); + bool GetLastBook(CBook& book); + bool FindBookByNo(string sISBN, int nBNo, CBook& book); + bool FindBNumByISBN(string sISBN, CBook& book); + void FillWithBook(CBook& book,CString& sName, CString& sISBN, CString& sPublisher, + int& nStock, int& nPYear, int& nPMonth, CString& sCatalog, + COleDateTime& dtBuy, int& nBNo, CString& sBorrow); + int ReturnNum(string sISBN); +public: + CData* m_pData; + list::iterator m_it; +}; + diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDlgAdd.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/CDlgAdd.cpp" new file mode 100644 index 0000000..9e0d70d --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDlgAdd.cpp" @@ -0,0 +1,153 @@ +// CDlgAdd.cpp: 实现文件 +// + +#include "pch.h" +#include "globe.h" +#include "CBook.h" +#include "CData.h" +#include "CDataAdapter.h" +#include "LibSystem.h" +#include "afxdialogex.h" +#include "CDlgAdd.h" + + +// CDlgAdd 对话框 + +IMPLEMENT_DYNAMIC(CDlgAdd, CDialogEx) + +CDlgAdd::CDlgAdd(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_DIALOG_ADD, pParent) + , m_csName(_T("")) + , m_csISBN(_T("")) + , m_dtBuy(COleDateTime::GetCurrentTime()) + , m_cbCatalog() + , m_csPublisher(_T("")) + , m_nPMonth(0) + , m_nPYear(0) + , m_nBNum(0) + , m_pDA(NULL) + , m_nStock(0) +{ + +} + +CDlgAdd::~CDlgAdd() +{ + m_pDA = NULL; +} + +void CDlgAdd::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Text(pDX, IDC_EDIT_NAME, m_csName); + DDX_Text(pDX, IDC_EDIT_ISBN, m_csISBN); + DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_BUY, m_dtBuy); + DDX_Control(pDX, IDC_COMBO_CATA, m_cbCatalog); + DDX_Text(pDX, IDC_EDIT_PMONTH, m_nPMonth); + DDX_Text(pDX, IDC_EDIT_PUB, m_csPublisher); + DDX_Text(pDX, IDC_EDIT_PYEAR, m_nPYear); + DDX_Control(pDX, IDC_SPIN_MONTH, m_spinMonth); + DDX_Control(pDX, IDC_SPIN_YEAR, m_spinYear); + DDX_Text(pDX, IDC_EDIT_NUM, m_nBNum); + DDX_Control(pDX, IDC_SPIN_NUM, m_spinBNum); +} + + +BEGIN_MESSAGE_MAP(CDlgAdd, CDialogEx) + ON_BN_CLICKED(IDOK, &CDlgAdd::OnBnClickedOk) + ON_BN_CLICKED(IDABORT, &CDlgAdd::OnBnClickedAbort) +END_MESSAGE_MAP() + +// CDlgAdd 消息处理程序 + +void CDlgAdd::SetDA(CDataAdapter* pDA) +{ + m_pDA = pDA; +} + +BOOL CDlgAdd::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // TODO: 在此添加额外的初始化 + m_nBNum = 1; + m_nPYear = 2023; + m_nPMonth = 1; + m_csBorrow = _T("未借出"); + for (int i = 0; i < CataNum; i++) + m_cbCatalog.AddString(g_BookCata[i]); + m_cbCatalog.SetCurSel(0); + UpdateData(FALSE); + m_spinBNum.SetBuddy(GetDlgItem(IDC_EDIT_NUM)); + m_spinBNum.SetRange(1, 1000); + m_spinYear.SetBuddy(GetDlgItem(IDC_EDIT_PYEAR)); + m_spinYear.SetRange(1950, 2050); + m_spinMonth.SetBuddy(GetDlgItem(IDC_EDIT_PMONTH)); + m_spinMonth.SetRange(1, 12); + GetDlgItem(IDC_EDIT_NAME)->SetFocus(); + return TRUE; // return TRUE unless you set the focus to a control + // 异常: OCX 属性页应返回 FALSE +} + + +void CDlgAdd::OnBnClickedOk() +{ + // TODO: 在此添加控件通知处理程序代码 + UpdateData(TRUE); + CString csCatalog; + CBook book = CBook(); + + int nNextNo = 0; + m_pDA->FindBNumByISBN(m_csISBN.GetBuffer(), book); + if (book.m_nBNo > 0) + { + nNextNo = m_pDA->m_it->m_nBNo; + m_nStock = m_pDA->m_it->m_nStock + m_nBNum; + } + else + { + m_nStock = m_nBNum; + } + + csCatalog = g_BookCata[m_cbCatalog.GetCurSel()]; + for (int i = nNextNo; i < m_nBNum + nNextNo; i++) + { + m_nBNo = i + 1; + m_pDA->AddBook(m_csName.GetBuffer(), m_csISBN.GetBuffer(), m_csPublisher.GetBuffer(), + m_nStock, m_nPYear, m_nPMonth, csCatalog.GetBuffer(), + m_dtBuy.GetYear(), m_dtBuy.GetMonth(), m_dtBuy.GetDay(), m_nBNo, m_csBorrow.GetBuffer()); + } + m_pDA->UpdateBookInfo(m_csName.GetBuffer(), m_csISBN.GetBuffer(), m_csPublisher.GetBuffer(), + m_nStock, m_nPYear, m_nPMonth, g_BookCata[m_cbCatalog.GetCurSel()].GetBuffer()); + m_pDA->Save(); + + AfxMessageBox(_T("添加成功!")); + CDialogEx::OnOK(); +} + + +void CDlgAdd::OnBnClickedAbort() +{ + // TODO: 在此添加控件通知处理程序代码 + CBook book = CBook(); + int index = 0; + UpdateData(TRUE); + string sISBN = m_csISBN.GetBuffer(); + + if (m_pDA->FindBNumByISBN(sISBN, book)) + { + for (int i = 0; i < CataNum; i++) + if (m_pDA->m_it->m_sCatalog == g_BookCata[i].GetBuffer()) + index = i; + m_cbCatalog.SetCurSel(index); + m_csName = m_pDA->m_it->m_sName.c_str(); + m_csPublisher = m_pDA->m_it->m_sPublisher.c_str(); + m_nPYear = m_pDA->m_it->m_nPYear; + m_nPMonth = m_pDA->m_it->m_nPMonth; + UpdateData(FALSE); + } + else + { + AfxMessageBox(_T("数据库中无该ISBN号,请先录入数据!")); + } +} diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDlgAdd.h" "b/cpp\350\257\276\350\256\276/LibSystem/CDlgAdd.h" new file mode 100644 index 0000000..6989556 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDlgAdd.h" @@ -0,0 +1,46 @@ +#pragma once +#include "afxdialogex.h" + +// CDlgAdd 对话框 + +class CDlgAdd : public CDialogEx +{ + DECLARE_DYNAMIC(CDlgAdd) + +public: + CDlgAdd(CWnd* pParent = nullptr); // 标准构造函数 + virtual ~CDlgAdd(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_DIALOG_ADD }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + + DECLARE_MESSAGE_MAP() +public: + CString m_csName; + CString m_csISBN; + CString m_csPublisher; + int m_nBNum; + CSpinButtonCtrl m_spinBNum; + // PublishYear + int m_nPYear; + // PublishMonth + int m_nPMonth; + int m_nBNo; + CSpinButtonCtrl m_spinYear; + CSpinButtonCtrl m_spinMonth; + CComboBox m_cbCatalog; + COleDateTime m_dtBuy; + CString m_csBorrow; + int m_nStock; + afx_msg void OnBnClickedOk(); + virtual BOOL OnInitDialog(); +public: + CDataAdapter* m_pDA; + void SetDA(CDataAdapter* pDA); + afx_msg void OnBnClickedAbort(); +}; \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDlgDelete.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/CDlgDelete.cpp" new file mode 100644 index 0000000..09de44b --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDlgDelete.cpp" @@ -0,0 +1,175 @@ +// CDlgDelete.cpp: 实现文件 +// + +#include "pch.h" +#include "globe.h" +#include "CBook.h" +#include "CData.h" +#include "CDataAdapter.h" +#include "LibSystem.h" +#include "afxdialogex.h" +#include "CDlgDelete.h" + + +// CDlgDelete 对话框 + +IMPLEMENT_DYNAMIC(CDlgDelete, CDialogEx) + +CDlgDelete::CDlgDelete(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_DIALOG_DELETE, pParent) + , m_csName(_T("")) + , m_csISBN(_T("")) + , m_dtBuy(COleDateTime::GetCurrentTime()) + , m_cbCatalog() + , m_csPublisher(_T("")) + , m_nPMonth(0) + , m_nPYear(0) +{ + +} + +CDlgDelete::~CDlgDelete() +{ +} + +void CDlgDelete::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Control(pDX, IDC_COMBO_CATA, m_cbCatalog); + DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_BUY, m_dtBuy); + DDX_Text(pDX, IDC_EDIT_ISBN, m_csISBN); + DDX_Text(pDX, IDC_EDIT_NAME, m_csName); + DDX_Text(pDX, IDC_EDIT_BNO, m_nBNo); + DDX_Text(pDX, IDC_EDIT_PMONTH, m_nPMonth); + DDX_Text(pDX, IDC_EDIT_PUB, m_csPublisher); + DDX_Text(pDX, IDC_EDIT_PYEAR, m_nPYear); + DDX_Control(pDX, IDC_SPIN_MONTH, m_spinMonth); + DDX_Control(pDX, IDC_SPIN_NUM, m_spinBNum); + DDX_Control(pDX, IDC_SPIN_YEAR, m_spinYear); + DDX_Text(pDX, IDC_EDIT_BNO, m_nBNo); + DDX_Text(pDX, IDC_EDIT_BORROW, m_csBorrow); + DDX_Text(pDX, IDC_EDIT_STOCK, m_nStock); +} + + +BEGIN_MESSAGE_MAP(CDlgDelete, CDialogEx) + ON_BN_CLICKED(ID_ABORT_ISBN, &CDlgDelete::OnBnClickedAbortIsbn) + ON_BN_CLICKED(ID_ABORT_NO, &CDlgDelete::OnBnClickedAbortNo) + ON_BN_CLICKED(IDC_DELETEBOOK, &CDlgDelete::OnBnClickedDeletebook) + ON_BN_CLICKED(IDC_DELETEALL, &CDlgDelete::OnBnClickedDeleteall) +END_MESSAGE_MAP() + + +// CDlgDelete 消息处理程序 + +void CDlgDelete::SetDA(CDataAdapter* pDA) +{ + m_pDA = pDA; +} + +void CDlgDelete::OnBnClickedAbortIsbn() +{ + // TODO: 在此添加控件通知处理程序代码 + CBook book = CBook(); + int index = 0; + UpdateData(TRUE); + string sISBN = m_csISBN.GetBuffer(); + + if (m_pDA->FindBNumByISBN(sISBN, book)) + { + for (int i = 0; i < CataNum; i++) + if (m_pDA->m_it->m_sCatalog == g_BookCata[i].GetBuffer()) + index = i; + m_cbCatalog.SetCurSel(index); + m_csName = m_pDA->m_it->m_sName.c_str(); + m_csPublisher = m_pDA->m_it->m_sPublisher.c_str(); + m_nPYear = m_pDA->m_it->m_nPYear; + m_nPMonth = m_pDA->m_it->m_nPMonth; + UpdateData(FALSE); + } + else + { + AfxMessageBox(_T("数据库中无该ISBN号,请先录入数据!")); + } +} + + +BOOL CDlgDelete::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // TODO: 在此添加额外的初始化 + m_nPYear = 2023; + m_nPMonth = 1; + m_csBorrow = _T("未借出"); + for (int i = 0; i < CataNum; i++) + m_cbCatalog.AddString(g_BookCata[i]); + m_cbCatalog.SetCurSel(0); + UpdateData(FALSE); + m_spinBNum.SetBuddy(GetDlgItem(IDC_EDIT_BNO)); + m_spinBNum.SetRange(1, 100); + m_spinBNum.SetBuddy(GetDlgItem(IDC_EDIT_NUM)); + m_spinBNum.SetRange(1, 1000); + m_spinYear.SetBuddy(GetDlgItem(IDC_EDIT_PYEAR)); + m_spinYear.SetRange(1950, 2050); + m_spinMonth.SetBuddy(GetDlgItem(IDC_EDIT_PMONTH)); + m_spinMonth.SetRange(1, 12); + return TRUE; // return TRUE unless you set the focus to a control + // 异常: OCX 属性页应返回 FALSE +} + + + +void CDlgDelete::OnBnClickedAbortNo() +{ + // TODO: 在此添加控件通知处理程序代码 + CBook book = CBook(); + int index = 0; + UpdateData(TRUE); + int nBNo = m_nBNo; + string sISBN = m_csISBN.GetBuffer(); + + m_pDA->FindBookByNo(sISBN, nBNo, book); + m_pDA->FillWithBook(book, m_csName, m_csISBN, m_csPublisher, + m_nStock, m_nPYear, m_nPMonth, m_csCatalog, m_dtBuy, m_nBNo, m_csBorrow); + UpdateData(FALSE); + + for (int i = 0; i < CataNum; i++) + if (m_pDA->m_it->m_sCatalog == g_BookCata[i].GetBuffer()) + index = i; + m_cbCatalog.SetCurSel(index); +} + + +void CDlgDelete::OnBnClickedDeletebook() +{ + // TODO: 在此添加控件通知处理程序代码 + UpdateData(TRUE); + int nBNo = m_nBNo; + CBook book = CBook(); + string sISBN = m_csISBN.GetBuffer(); + m_pDA->DeleBookByNo(sISBN, nBNo); + m_pDA->UpdateBookInfo(m_csName.GetBuffer(), m_csISBN.GetBuffer(), m_csPublisher.GetBuffer(), + m_nStock - 1 , m_nPYear, m_nPMonth, g_BookCata[m_cbCatalog.GetCurSel()].GetBuffer()); + m_pDA->GetFirstBook(book); + m_pDA->FillWithBook(book, m_csName, m_csISBN, m_csPublisher, + m_nStock, m_nPYear, m_nPMonth, m_csCatalog, m_dtBuy, m_nBNo, m_csBorrow); + UpdateData(FALSE); + m_pDA->Save(); +} + + +void CDlgDelete::OnBnClickedDeleteall() +{ + // TODO: 在此添加控件通知处理程序代码 + UpdateData(TRUE); + int nBNo = m_nBNo; + string sISBN = m_csISBN.GetBuffer(); + CBook book = CBook(); + m_pDA->DeleBookByISBN(sISBN); + m_pDA->GetFirstBook(book); + m_pDA->FillWithBook(book, m_csName, m_csISBN, m_csPublisher, + m_nStock, m_nPYear, m_nPMonth, m_csCatalog, m_dtBuy, m_nBNo, m_csBorrow); + UpdateData(FALSE); + m_pDA->Save(); +} diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDlgDelete.h" "b/cpp\350\257\276\350\256\276/LibSystem/CDlgDelete.h" new file mode 100644 index 0000000..573768d --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDlgDelete.h" @@ -0,0 +1,48 @@ +#pragma once +#include "afxdialogex.h" + + +// CDlgDelete 对话框 + +class CDlgDelete : public CDialogEx +{ + DECLARE_DYNAMIC(CDlgDelete) + +public: + CDlgDelete(CWnd* pParent = nullptr); // 标准构造函数 + virtual ~CDlgDelete(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_DIALOG_DELETE }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + + DECLARE_MESSAGE_MAP() +public: + virtual BOOL OnInitDialog(); + CComboBox m_cbCatalog; + COleDateTime m_dtBuy; + CString m_csISBN; + CString m_csName; + int m_nPMonth; + CString m_csPublisher; + int m_nPYear; + CSpinButtonCtrl m_spinMonth; + CSpinButtonCtrl m_spinBNum; + CSpinButtonCtrl m_spinYear; + int m_nBNo; + CString m_csBorrow; + //int m_nBNum; + int m_nStock; +public: + CString m_csCatalog; + CDataAdapter* m_pDA; + void SetDA(CDataAdapter* pDA); + afx_msg void OnBnClickedAbortIsbn(); + afx_msg void OnBnClickedAbortNo(); + afx_msg void OnBnClickedDeletebook(); + afx_msg void OnBnClickedDeleteall(); +}; diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDlgFind.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/CDlgFind.cpp" new file mode 100644 index 0000000..10a12eb --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDlgFind.cpp" @@ -0,0 +1,202 @@ +// CDlgFind.cpp: 实现文件 +// + +#include "pch.h" +#include "globe.h" +#include "CBook.h" +#include "CData.h" +#include "CDataAdapter.h" +#include "LibSystem.h" +#include "afxdialogex.h" +#include "CDlgFind.h" + + +// CDlgFind 对话框 + +IMPLEMENT_DYNAMIC(CDlgFind, CDialogEx) + +CDlgFind::CDlgFind(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_DIALOG_FIND, pParent) + , m_dtBuy(COleDateTime::GetCurrentTime()) + , m_csISBN(_T("")) + , m_csName(_T("")) + , m_nPMonth(0) + , m_csPublisher(_T("")) + , m_nPYear(0) + , m_csBorrow(_T("")) + , m_cbCatalog() + , m_nStock(0) +{ + +} + +CDlgFind::~CDlgFind() +{ +} + +void CDlgFind::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Control(pDX, IDC_COMBO_CATA, m_cbCatalog); + DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_BUY, m_dtBuy); + DDX_Text(pDX, IDC_EDIT_ISBN, m_csISBN); + DDX_Text(pDX, IDC_EDIT_NAME, m_csName); + DDX_Text(pDX, IDC_EDIT_BNO, m_nBNo); + DDX_Text(pDX, IDC_EDIT_PMONTH, m_nPMonth); + DDX_Text(pDX, IDC_EDIT_PUB, m_csPublisher); + DDX_Text(pDX, IDC_EDIT_PYEAR, m_nPYear); + DDX_Control(pDX, IDC_SPIN_MONTH, m_spinMonth); + DDX_Control(pDX, IDC_SPIN_NUM, m_spinBNum); + DDX_Control(pDX, IDC_SPIN_YEAR, m_spinYear); + DDX_Text(pDX, IDC_EDIT_BNO, m_nBNo); + DDX_Text(pDX, IDC_EDIT_BORROW, m_csBorrow); + DDX_Text(pDX, IDC_EDIT_STOCK, m_nStock); +} + + +BEGIN_MESSAGE_MAP(CDlgFind, CDialogEx) + ON_BN_CLICKED(IDC_FIND, &CDlgFind::OnBnClickedFind) + ON_BN_CLICKED(IDC_PREV, &CDlgFind::OnBnClickedPrev) + ON_BN_CLICKED(IDC_NEXT, &CDlgFind::OnBnClickedNext) + ON_BN_CLICKED(IDC_UPDATEINFO, &CDlgFind::OnBnClickedUpdateinfo) + ON_BN_CLICKED(IDC_UPDATEBOOK, &CDlgFind::OnBnClickedUpdatebook) +END_MESSAGE_MAP() + + +// CDlgFind 消息处理程序 + +void CDlgFind::SetDA(CDataAdapter* pDA) +{ + m_pDA = pDA; +} + +BOOL CDlgFind::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // TODO: 在此添加额外的初始化 + if (m_pDA && m_pDA->GetNumOfBook() > 0) + { + int index = 0; + for (int i = 0; i < CataNum; i++) + { + m_cbCatalog.AddString(g_BookCata[i]); + if (m_csCatalog = g_BookCata[i]) + index = i; + } + + CBook book = CBook(); + m_pDA->GetFirstBook(book); + m_pDA->FillWithBook(book, m_csName, m_csISBN, m_csPublisher, + m_nStock, m_nPYear, m_nPMonth, m_csCatalog, m_dtBuy, m_nBNo, m_csBorrow); + + for (int i = 0; i < CataNum; i++) + if (m_pDA->m_it->m_sCatalog == g_BookCata[i].GetBuffer()) + index = i; + m_cbCatalog.SetCurSel(index); + } + UpdateData(FALSE); + m_spinBNum.SetBuddy(GetDlgItem(IDC_EDIT_BNO)); + m_spinBNum.SetRange(1, 100); + m_spinBNum.SetBuddy(GetDlgItem(IDC_EDIT_NUM)); + m_spinBNum.SetRange(1, 1000); + m_spinYear.SetBuddy(GetDlgItem(IDC_EDIT_PYEAR)); + m_spinYear.SetRange(1950, 2050); + m_spinMonth.SetBuddy(GetDlgItem(IDC_EDIT_PMONTH)); + m_spinMonth.SetRange(1, 12); + GetDlgItem(IDC_EDIT_ISBN)->SetFocus(); + return TRUE; // return TRUE unless you set the focus to a control + // 异常: OCX 属性页应返回 FALSE +} + + +void CDlgFind::OnBnClickedFind() +{ + // TODO: 在此添加控件通知处理程序代码 + CBook book = CBook(); + int index = 0; + UpdateData(TRUE); + int nBNo = m_nBNo; + string sISBN = m_csISBN.GetBuffer(); + + m_pDA->FindBookByNo(sISBN, nBNo, book); + m_pDA->FillWithBook(book, m_csName, m_csISBN, m_csPublisher, + m_nStock, m_nPYear, m_nPMonth, m_csCatalog, m_dtBuy, m_nBNo, m_csBorrow); + UpdateData(FALSE); + + for (int i = 0; i < CataNum; i++) + if (m_pDA->m_it->m_sCatalog == g_BookCata[i].GetBuffer()) + index = i; + m_cbCatalog.SetCurSel(index); +} + + +void CDlgFind::OnBnClickedPrev() +{ + // TODO: 在此添加控件通知处理程序代码 + CBook book = CBook(); + int index = 0; + m_pDA->GetPrevBook(book); + m_pDA->FillWithBook(book, m_csName, m_csISBN, m_csPublisher, + m_nStock, m_nPYear, m_nPMonth, m_csCatalog, m_dtBuy, m_nBNo, m_csBorrow); + UpdateData(FALSE); + + for (int i = 0; i < CataNum; i++) + if (m_pDA->m_it->m_sCatalog == g_BookCata[i].GetBuffer()) + index = i; + m_cbCatalog.SetCurSel(index); +} + + +void CDlgFind::OnBnClickedNext() +{ + // TODO: 在此添加控件通知处理程序代码 + CBook book = CBook(); + int index = 0; + m_pDA->GetNextBook(book); + m_pDA->FillWithBook(book, m_csName, m_csISBN, m_csPublisher, + m_nStock, m_nPYear, m_nPMonth, m_csCatalog, m_dtBuy, m_nBNo, m_csBorrow); + UpdateData(FALSE); + + for (int i = 0; i < CataNum; i++) + if (m_pDA->m_it->m_sCatalog == g_BookCata[i].GetBuffer()) + index = i; + m_cbCatalog.SetCurSel(index); +} + + +void CDlgFind::OnBnClickedUpdateinfo() +{ + // TODO: 在此添加控件通知处理程序代码 + CBook book = CBook(); + int index = 0; + UpdateData(TRUE); + for (int i = 0; i < CataNum; i++) + { + if (m_cbCatalog.GetCurSel() == i) + { + index = i; + break; + } + } + m_cbCatalog.SetCurSel(index); + + m_pDA->UpdateBookInfo(m_csName.GetBuffer(), m_csISBN.GetBuffer(), m_csPublisher.GetBuffer(), + m_nStock, m_nPYear, m_nPMonth, g_BookCata[m_cbCatalog.GetCurSel()].GetBuffer()); + AfxMessageBox(_T("书籍信息更改成功!")); + m_pDA->Save(); +} + + +void CDlgFind::OnBnClickedUpdatebook() +{ + // TODO: 在此添加控件通知处理程序代码 + CBook book = CBook(); + int index = 0; + UpdateData(TRUE); + + m_pDA->UpdateBook(m_csISBN.GetBuffer(), m_dtBuy.GetYear(), m_dtBuy.GetMonth(), + m_dtBuy.GetDay(), m_nBNo, m_csBorrow.GetBuffer()); + + m_pDA->Save(); +} diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDlgFind.h" "b/cpp\350\257\276\350\256\276/LibSystem/CDlgFind.h" new file mode 100644 index 0000000..293e5d2 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDlgFind.h" @@ -0,0 +1,49 @@ +#pragma once +#include "afxdialogex.h" + + +// CDlgFind 对话框 + +class CDlgFind : public CDialogEx +{ + DECLARE_DYNAMIC(CDlgFind) + +public: + CDlgFind(CWnd* pParent = nullptr); // 标准构造函数 + virtual ~CDlgFind(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_DIALOG_FIND }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + + DECLARE_MESSAGE_MAP() +public: + CComboBox m_cbCatalog; + COleDateTime m_dtBuy; + CString m_csISBN; + CString m_csName; + int m_nPMonth; + CString m_csPublisher; + int m_nPYear; + CSpinButtonCtrl m_spinMonth; + CSpinButtonCtrl m_spinBNum; + CSpinButtonCtrl m_spinYear; + int m_nBNo; + CString m_csBorrow; + //int m_nBNum; + int m_nStock; + virtual BOOL OnInitDialog(); + afx_msg void OnBnClickedFind(); + afx_msg void OnBnClickedPrev(); + afx_msg void OnBnClickedNext(); +public: + CString m_csCatalog; + CDataAdapter* m_pDA; + void SetDA(CDataAdapter* pDA); + afx_msg void OnBnClickedUpdateinfo(); + afx_msg void OnBnClickedUpdatebook(); +}; diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDlgIndex.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/CDlgIndex.cpp" new file mode 100644 index 0000000..b8ff900 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDlgIndex.cpp" @@ -0,0 +1,125 @@ +// CDlgIndex.cpp: 实现文件 +// + +#include "pch.h" +#include "CDlgIndex.h" +#include "CDlgAdd.h" +#include "CDlgFind.h" +#include "CDlgDelete.h" +#include "CDlgLend.h" +#include "LibSystemDlg.h" +#include "LibSystem.h" +#include "afxdialogex.h" + + +// CDlgIndex 对话框 + +IMPLEMENT_DYNAMIC(CDlgIndex, CDialogEx) + +CDlgIndex::CDlgIndex(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_DIALOG_INDEX, pParent) +{ + +} + +CDlgIndex::~CDlgIndex() +{ +} + +void CDlgIndex::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CDlgIndex, CDialogEx) + ON_BN_CLICKED(IDC_BUTTON_ADD, &CDlgIndex::OnBnClickedButtonAdd) + ON_BN_CLICKED(IDC_BUTTON_FIND, &CDlgIndex::OnBnClickedButtonFind) + ON_BN_CLICKED(IDC_BUTTON_DELETE, &CDlgIndex::OnBnClickedButtonDelete) + ON_BN_CLICKED(IDC_BUTTON_INPUT, &CDlgIndex::OnBnClickedButtonInput) + ON_BN_CLICKED(IDCANCEL, &CDlgIndex::OnBnClickedCancel) +END_MESSAGE_MAP() + + +// CDlgIndex 消息处理程序 + + +void CDlgIndex::OnBnClickedButtonAdd() +{ + // TODO: 在此添加控件通知处理程序代码 + //CDlgAdd dlg; + //dlg.SetDA(m_da); + //dlg.DoModal(); + CDlgAdd* dlg = new CDlgAdd(this); + CDataAdapter* cd = m_da; + dlg->SetDA(cd); + dlg->DoModal(); + delete dlg; +} + + +void CDlgIndex::OnBnClickedButtonFind() +{ + // TODO: 在此添加控件通知处理程序代码 + if (m_da->GetNumOfBook() == 0) + { + AfxMessageBox(_T("请先录入数据!")); + return; + } + + CDlgFind dlg; + dlg.SetDA(m_da); + dlg.DoModal(); +} + + +void CDlgIndex::OnBnClickedButtonDelete() +{ + // TODO: 在此添加控件通知处理程序代码 + if (m_da->GetNumOfBook() == 0) + { + AfxMessageBox(_T("请先录入数据!")); + return; + } + + CDlgDelete dlg; + dlg.SetDA(m_da); + dlg.DoModal(); +} + + +void CDlgIndex::OnBnClickedButtonInput() +{ + // TODO: 在此添加控件通知处理程序代码 + if (m_da->GetNumOfBook() == 0) + { + AfxMessageBox(_T("请先录入数据!")); + return; + } + + CDlgLend dlg; + dlg.SetDA(m_da); + dlg.DoModal(); +} + + +BOOL CDlgIndex::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // TODO: 在此添加额外的初始化 + m_da = new CDataAdapter(); + m_da->Load(); + return TRUE; // return TRUE unless you set the focus to a control + // 异常: OCX 属性页应返回 FALSE +} + + + +void CDlgIndex::OnBnClickedCancel() +{ + // TODO: 在此添加控件通知处理程序代码 + CDialogEx::OnCancel(); + CLibSystemDlg dlg; + dlg.DoModal(); +} diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDlgIndex.h" "b/cpp\350\257\276\350\256\276/LibSystem/CDlgIndex.h" new file mode 100644 index 0000000..799860c --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDlgIndex.h" @@ -0,0 +1,33 @@ +#pragma once +#include "afxdialogex.h" +#include "CDataAdapter.h" + +// CDlgIndex 对话框 + +class CDlgIndex : public CDialogEx +{ + DECLARE_DYNAMIC(CDlgIndex) + +public: + CDlgIndex(CWnd* pParent = nullptr); // 标准构造函数 + virtual ~CDlgIndex(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_DIALOG_INDEX }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedButtonAdd(); + afx_msg void OnBnClickedButtonFind(); + afx_msg void OnBnClickedButtonDelete(); + afx_msg void OnBnClickedButtonInput(); + virtual BOOL OnInitDialog(); +public: + CDataAdapter* m_da; + afx_msg void OnBnClickedCancel(); +}; diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDlgLend.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/CDlgLend.cpp" new file mode 100644 index 0000000..35e6217 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDlgLend.cpp" @@ -0,0 +1,175 @@ +// CDlgLend.cpp: 实现文件 +// + +#include "pch.h" +#include "globe.h" +#include "CBook.h" +#include "CData.h" +#include "CDataAdapter.h" +#include "LibSystem.h" +#include "afxdialogex.h" +#include "CDlgLend.h" + + +// CDlgLend 对话框 + +IMPLEMENT_DYNAMIC(CDlgLend, CDialogEx) + +CDlgLend::CDlgLend(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_DIALOG_LEND, pParent) + , m_nBNo(1) + , m_csBorrow(_T("")) + , m_csISBN(_T("")) + , m_csName(_T("")) + , m_csPublisher(_T("")) + , m_nReturn(0) +{ + +} + +CDlgLend::~CDlgLend() +{ +} + +void CDlgLend::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Control(pDX, IDC_COMBO_CATA, m_cbCatalog); + DDX_Text(pDX, IDC_EDIT_BNO, m_nBNo); + DDX_Text(pDX, IDC_EDIT_BORROW, m_csBorrow); + DDX_Text(pDX, IDC_EDIT_ISBN, m_csISBN); + DDX_Text(pDX, IDC_EDIT_NAME, m_csName); + DDX_Text(pDX, IDC_EDIT_PUB, m_csPublisher); + DDX_Text(pDX, IDC_EDIT_RETRUN, m_nReturn); + DDX_Control(pDX, IDC_SPIN_NUM, m_spinBNum); +} + + +BEGIN_MESSAGE_MAP(CDlgLend, CDialogEx) + ON_BN_CLICKED(ID_ABORT, &CDlgLend::OnBnClickedAbort) + ON_BN_CLICKED(IDC_LEND, &CDlgLend::OnBnClickedLend) + ON_BN_CLICKED(IDC_RETURN, &CDlgLend::OnBnClickedReturn) +END_MESSAGE_MAP() + + +// CDlgLend 消息处理程序 + +void CDlgLend::SetDA(CDataAdapter* pDA) +{ + m_pDA = pDA; +} + +BOOL CDlgLend::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // TODO: 在此添加额外的初始化 + m_nPYear = 2023; + m_nPMonth = 1; + m_csBorrow = _T(""); + for (int i = 0; i < CataNum; i++) + m_cbCatalog.AddString(g_BookCata[i]); + m_cbCatalog.SetCurSel(0); + UpdateData(FALSE); + m_spinBNum.SetBuddy(GetDlgItem(IDC_EDIT_BNO)); + m_spinBNum.SetRange(1, 100); + LoadHistory(_T(".//history.txt")); + m_dtLTime = COleDateTime::GetCurrentTime(); + pList = &m_listHistory; + return TRUE; // return TRUE unless you set the focus to a control + // 异常: OCX 属性页应返回 FALSE +} + + +void CDlgLend::OnBnClickedAbort() +{ + // TODO: 在此添加控件通知处理程序代码 + CBook book = CBook(); + int index = 0; + UpdateData(TRUE); + int nBNo = m_nBNo; + string sISBN = m_csISBN.GetBuffer(); + + m_pDA->FindBookByNo(sISBN, nBNo, book); + m_pDA->FillWithBook(book, m_csName, m_csISBN, m_csPublisher, + m_nStock, m_nPYear, m_nPMonth, m_csCatalog, m_dtBuy, m_nBNo, m_csBorrow); + m_nReturn = m_pDA->ReturnNum(sISBN); + UpdateData(FALSE); + + for (int i = 0; i < CataNum; i++) + if (m_pDA->m_it->m_sCatalog == g_BookCata[i].GetBuffer()) + index = i; + m_cbCatalog.SetCurSel(index); +} + + +void CDlgLend::OnBnClickedLend() +{ + // TODO: 在此添加控件通知处理程序代码 + CBook book = CBook(); + int index = 0; + UpdateData(TRUE); + + m_pDA->ReturnBook(m_csISBN.GetBuffer(), m_nBNo, m_csBorrow.GetBuffer()); + m_pDA->Save(); + m_nReturn = m_pDA->ReturnNum(m_csISBN.GetBuffer()); + AddHistory(m_csISBN.GetBuffer(), m_nBNo, m_csBorrow.GetBuffer(), + m_dtLTime.GetYear(), m_dtLTime.GetMonth(), m_dtLTime.GetDay()); + SaveHistory(_T(".//history.txt")); + UpdateData(FALSE); +} + + +void CDlgLend::OnBnClickedReturn() +{ + // TODO: 在此添加控件通知处理程序代码 + CBook book = CBook(); + int index = 0; + m_csBorrow = _T("未借出"); + + m_pDA->ReturnBook(m_csISBN.GetBuffer(), m_nBNo, m_csBorrow.GetBuffer()); + m_pDA->Save(); + m_nReturn = m_pDA->ReturnNum(m_csISBN.GetBuffer()); + AddHistory(m_csISBN.GetBuffer(), m_nBNo, _T("归还"), + m_dtLTime.GetYear(), m_dtLTime.GetMonth(), m_dtLTime.GetDay()); + SaveHistory(_T(".//history.txt")); + UpdateData(FALSE); +} + +void CDlgLend::AddHistory(string sISBN, int nNo, string sBorrow, + int nLYear, int nLMonth, int nLDay) +{ + CHistory hist = CHistory(); + hist.SetHistory(sISBN, nNo, sBorrow, nLYear, nLMonth, nLDay); + m_listHistory.push_back(hist); +} + +void CDlgLend::LoadHistory(CString csFullPath) +{ + m_listHistory.clear(); + ifstream in(csFullPath, ios::in); + if (in.is_open()) + { + int num; + in >> num; + for (int i = 0; i < num; i++) + { + CHistory hist = CHistory(); + hist.Load(in); + m_listHistory.push_back(hist); + } + in.close(); + } +} + +void CDlgLend::SaveHistory(CString csFullPath) +{ + ofstream out(csFullPath, ios::out); + if (out.is_open()) + { + out << m_listHistory.size() << endl; + for (list::iterator it = m_listHistory.begin(); it != m_listHistory.end(); it++) + it->Save(out); + out.close(); + } +} \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDlgLend.h" "b/cpp\350\257\276\350\256\276/LibSystem/CDlgLend.h" new file mode 100644 index 0000000..2ce2ae5 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDlgLend.h" @@ -0,0 +1,55 @@ +#pragma once +#include "afxdialogex.h" +#include "CHistory.h" + +// CDlgLend 对话框 + +class CDlgLend : public CDialogEx +{ + DECLARE_DYNAMIC(CDlgLend) + +public: + CDlgLend(CWnd* pParent = nullptr); // 标准构造函数 + virtual ~CDlgLend(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_DIALOG_LEND }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + + DECLARE_MESSAGE_MAP() +public: + CString m_csCatalog; + CDataAdapter* m_pDA; + void SetDA(CDataAdapter* pDA); + virtual BOOL OnInitDialog(); + CComboBox m_cbCatalog; + int m_nBNo; + CString m_csBorrow; + CString m_csISBN; + CString m_csName; + CString m_csPublisher; + int m_nReturn; + int m_nStock; + int m_nPMonth; + int m_nPYear; + COleDateTime m_dtBuy; + COleDateTime m_dtLTime; + CSpinButtonCtrl m_spinBNum; + + afx_msg void OnBnClickedAbort(); + afx_msg void OnBnClickedLend(); + afx_msg void OnBnClickedReturn(); + + void AddHistory(string sISBN, int nNo, string sBorrow, + int nLYear, int nLMonth, int nLDay); + void LoadHistory(CString csFullPath); + void SaveHistory(CString csFullPath); + + list m_listHistory; + list* pList; + list::iterator m_it; +}; diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDlgUserIndex.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/CDlgUserIndex.cpp" new file mode 100644 index 0000000..e3487b9 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDlgUserIndex.cpp" @@ -0,0 +1,74 @@ +// CDlgUserIndex.cpp: 实现文件 +// + +#include "pch.h" +#include "CDlgUserIndex.h" +#include "CDlgLend.h" +#include "LibSystemDlg.h" +#include "LibSystem.h" +#include "afxdialogex.h" + + +// CDlgUserIndex 对话框 + +IMPLEMENT_DYNAMIC(CDlgUserIndex, CDialogEx) + +CDlgUserIndex::CDlgUserIndex(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_DIALOG_USER_INDEX, pParent) +{ + +} + +CDlgUserIndex::~CDlgUserIndex() +{ +} + +void CDlgUserIndex::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CDlgUserIndex, CDialogEx) + ON_BN_CLICKED(IDC_BUTTON_INPUT, &CDlgUserIndex::OnBnClickedButtonInput) + ON_BN_CLICKED(IDCANCEL, &CDlgUserIndex::OnBnClickedCancel) +END_MESSAGE_MAP() + + +// CDlgUserIndex 消息处理程序 + + +void CDlgUserIndex::OnBnClickedButtonInput() +{ + // TODO: 在此添加控件通知处理程序代码 + if (m_da->GetNumOfBook() == 0) + { + AfxMessageBox(_T("请先录入数据!")); + return; + } + + CDlgLend dlg; + dlg.SetDA(m_da); + dlg.DoModal(); +} + + +BOOL CDlgUserIndex::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // TODO: 在此添加额外的初始化 + m_da = new CDataAdapter(); + m_da->Load(); + return TRUE; // return TRUE unless you set the focus to a control + // 异常: OCX 属性页应返回 FALSE +} + + +void CDlgUserIndex::OnBnClickedCancel() +{ + // TODO: 在此添加控件通知处理程序代码 + CDialogEx::OnCancel(); + CLibSystemDlg dlg; + dlg.DoModal(); +} diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CDlgUserIndex.h" "b/cpp\350\257\276\350\256\276/LibSystem/CDlgUserIndex.h" new file mode 100644 index 0000000..4eafc7d --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CDlgUserIndex.h" @@ -0,0 +1,29 @@ +#pragma once +#include "afxdialogex.h" +#include "CDataAdapter.h" + +// CDlgUserIndex 对话框 + +class CDlgUserIndex : public CDialogEx +{ + DECLARE_DYNAMIC(CDlgUserIndex) + +public: + CDlgUserIndex(CWnd* pParent = nullptr); // 标准构造函数 + virtual ~CDlgUserIndex(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_DIALOG_USER_INDEX }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + + DECLARE_MESSAGE_MAP() +public: + CDataAdapter* m_da; + afx_msg void OnBnClickedButtonInput(); + virtual BOOL OnInitDialog(); + afx_msg void OnBnClickedCancel(); +}; diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CHistory.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/CHistory.cpp" new file mode 100644 index 0000000..55b2466 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CHistory.cpp" @@ -0,0 +1,52 @@ +#include "pch.h" +#include "CHistory.h" + +CHistory::CHistory() +{ + +} + +CHistory::CHistory(string sISBN, int nNo, string sBorrow, + int nLYear, int nLMonth, int nLDay) +{ + m_sISBN = sISBN; + m_nNo= nNo; + m_sBorrow = sBorrow; + m_nLYear = nLYear; + m_nLMonth = nLMonth; + m_nLDay = nLDay; +} + +CHistory::~CHistory() +{ + +} + +void CHistory::SetHistory(string sISBN, int nNo, string sBorrow, + int nLYear, int nLMonth, int nLDay) +{ + m_sISBN = sISBN; + m_nNo = nNo; + m_sBorrow = sBorrow; + m_nLYear = nLYear; + m_nLMonth = nLMonth; + m_nLDay = nLDay; +} + +void CHistory::Save(ofstream& out) +{ + out << m_sISBN << _T("\t"); + out << m_nNo << _T("\t"); + out << m_sBorrow << _T("\t"); + out << m_nLYear << _T("\t"); + out << m_nLMonth << _T("\t"); + out << m_nLDay << _T("\n"); +} + +void CHistory::Load(ifstream& in) +{ + in >> m_sISBN; + in >> m_nNo; + in >> m_sBorrow; + in >> m_nLYear >> m_nLMonth >> m_nLDay; +} diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CHistory.h" "b/cpp\350\257\276\350\256\276/LibSystem/CHistory.h" new file mode 100644 index 0000000..2908a3b --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CHistory.h" @@ -0,0 +1,22 @@ +#pragma once +class CHistory +{ +public: + CHistory(); + CHistory(string sISBN, int nNo, string sBorrow, + int nLYear, int nLMonth, int nLDay); + ~CHistory(); + void SetHistory(string sISBN, int nNo, string sBorrow, + int nLYear, int nLMonth, int nLDay); + + void Save(ofstream& out); + void Load(ifstream& in); +public: + string m_sISBN; + int m_nNo; + string m_sBorrow; + int m_nLYear; + int m_nLMonth; + int m_nLDay; +}; + diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CUser.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/CUser.cpp" new file mode 100644 index 0000000..9b70c0f --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CUser.cpp" @@ -0,0 +1,40 @@ +#include "pch.h" +#include "CUser.h" + +CUser::CUser() +{ + +} + +CUser::CUser(string sUName, string sPwd, int nAuthority) +{ + m_sUName = sUName; + m_sPwd = sPwd; + m_nAuthority = nAuthority; +} + +CUser::~CUser() +{ + +} + +void CUser::SetUser(string sUName, string sPwd, int nAuthority) +{ + m_sUName = sUName; + m_sPwd = sPwd; + m_nAuthority = nAuthority; +} + +void CUser::Save(ofstream& out) +{ + out << m_sUName << _T("\t"); + out << m_sPwd << _T("\t"); + out << m_nAuthority << _T("\n"); +} + +void CUser::Load(ifstream& in) +{ + in >> m_sUName; + in >> m_sPwd; + in >> m_nAuthority; +} diff --git "a/cpp\350\257\276\350\256\276/LibSystem/CUser.h" "b/cpp\350\257\276\350\256\276/LibSystem/CUser.h" new file mode 100644 index 0000000..92bc9d3 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/CUser.h" @@ -0,0 +1,16 @@ +#pragma once +class CUser +{ +public: + CUser(); + CUser(string sUName, string sUPwd, int nAuthority); + ~CUser(); + void SetUser(string sUName, string sUPwd, int nAuthority); + + void Save(ofstream& out); + void Load(ifstream& in); +public: + string m_sUName; + string m_sPwd; + int m_nAuthority; +}; diff --git "a/cpp\350\257\276\350\256\276/LibSystem/LibSystem.aps" "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.aps" new file mode 100644 index 0000000..5cc6410 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.aps" differ diff --git "a/cpp\350\257\276\350\256\276/LibSystem/LibSystem.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.cpp" new file mode 100644 index 0000000..031271a --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.cpp" @@ -0,0 +1,107 @@ + +// LibSystem.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "LibSystem.h" +#include "LibSystemDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CLibSystemApp + +BEGIN_MESSAGE_MAP(CLibSystemApp, CWinApp) + ON_COMMAND(ID_HELP, &CWinApp::OnHelp) +END_MESSAGE_MAP() + + +// CLibSystemApp 构造 + +CLibSystemApp::CLibSystemApp() +{ + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + + +// 唯一的 CLibSystemApp 对象 + +CLibSystemApp theApp; + + +// CLibSystemApp 初始化 + +BOOL CLibSystemApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinApp::InitInstance(); + + + AfxEnableControlContainer(); + + // 创建 shell 管理器,以防对话框包含 + // 任何 shell 树视图控件或 shell 列表视图控件。 + CShellManager *pShellManager = new CShellManager; + + // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题 + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + + CLibSystemDlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: 在此放置处理何时用 + // “确定”来关闭对话框的代码 + } + else if (nResponse == IDCANCEL) + { + // TODO: 在此放置处理何时用 + // “取消”来关闭对话框的代码 + } + else if (nResponse == -1) + { + TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n"); + TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n"); + } + + // 删除上面创建的 shell 管理器。 + if (pShellManager != nullptr) + { + delete pShellManager; + } + +#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS) + ControlBarCleanUp(); +#endif + + // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, + // 而不是启动应用程序的消息泵。 + return FALSE; +} + diff --git "a/cpp\350\257\276\350\256\276/LibSystem/LibSystem.exe" "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.exe" new file mode 100644 index 0000000..3dc6791 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.exe" differ diff --git "a/cpp\350\257\276\350\256\276/LibSystem/LibSystem.h" "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.h" new file mode 100644 index 0000000..c8fc213 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.h" @@ -0,0 +1,32 @@ + +// LibSystem.h: PROJECT_NAME 应用程序的主头文件 +// + +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// CLibSystemApp: +// 有关此类的实现,请参阅 LibSystem.cpp +// + +class CLibSystemApp : public CWinApp +{ +public: + CLibSystemApp(); + +// 重写 +public: + virtual BOOL InitInstance(); + +// 实现 + + DECLARE_MESSAGE_MAP() +}; + +extern CLibSystemApp theApp; diff --git "a/cpp\350\257\276\350\256\276/LibSystem/LibSystem.rc" "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.rc" new file mode 100644 index 0000000..7c7cf8c Binary files /dev/null and "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.rc" differ diff --git "a/cpp\350\257\276\350\256\276/LibSystem/LibSystem.sln" "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.sln" new file mode 100644 index 0000000..a768b88 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibSystem", "LibSystem.vcxproj", "{0F183104-6610-42C9-81D9-9063F086DEF6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0F183104-6610-42C9-81D9-9063F086DEF6}.Debug|x64.ActiveCfg = Debug|x64 + {0F183104-6610-42C9-81D9-9063F086DEF6}.Debug|x64.Build.0 = Debug|x64 + {0F183104-6610-42C9-81D9-9063F086DEF6}.Debug|x86.ActiveCfg = Debug|Win32 + {0F183104-6610-42C9-81D9-9063F086DEF6}.Debug|x86.Build.0 = Debug|Win32 + {0F183104-6610-42C9-81D9-9063F086DEF6}.Release|x64.ActiveCfg = Release|x64 + {0F183104-6610-42C9-81D9-9063F086DEF6}.Release|x64.Build.0 = Release|x64 + {0F183104-6610-42C9-81D9-9063F086DEF6}.Release|x86.ActiveCfg = Release|Win32 + {0F183104-6610-42C9-81D9-9063F086DEF6}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8D6C5548-DB7D-4DB2-AE0B-255956470048} + EndGlobalSection +EndGlobal diff --git "a/cpp\350\257\276\350\256\276/LibSystem/LibSystem.vcxproj" "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.vcxproj" new file mode 100644 index 0000000..1442961 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.vcxproj" @@ -0,0 +1,244 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {0F183104-6610-42C9-81D9-9063F086DEF6} + MFCProj + LibSystem + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + MultiByte + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/LibSystem/LibSystem.vcxproj.filters" "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.vcxproj.filters" new file mode 100644 index 0000000..3aaccaa --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.vcxproj.filters" @@ -0,0 +1,140 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + + + 资源文件 + + + + + + + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/LibSystem/LibSystem.vcxproj.user" "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.vcxproj.user" new file mode 100644 index 0000000..7e4a1ae --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/LibSystem.vcxproj.user" @@ -0,0 +1,6 @@ + + + + LibSystem.rc + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/LibSystem/LibSystemDlg.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/LibSystemDlg.cpp" new file mode 100644 index 0000000..c79ac95 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/LibSystemDlg.cpp" @@ -0,0 +1,254 @@ + +// LibSystemDlg.cpp: 实现文件 +// + +#include "pch.h" +#include "CDlgIndex.h" +#include "CDlgUserIndex.h" +#include "CDataAdapter.h" +#include "CUser.h" +#include "framework.h" +#include "LibSystem.h" +#include "LibSystemDlg.h" +#include "afxdialogex.h" + + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + + +// CLibSystemDlg 对话框 + + + +CLibSystemDlg::CLibSystemDlg(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_LIBSYSTEM_DIALOG, pParent) + , m_csName(_T("")) + , m_csPwd(_T("")) +{ + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); +} + +void CLibSystemDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Text(pDX, IDC_NAME, m_csName); + DDX_Text(pDX, IDC_PWD, m_csPwd); +} + +BEGIN_MESSAGE_MAP(CLibSystemDlg, CDialogEx) + ON_WM_SYSCOMMAND() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDOK, &CLibSystemDlg::OnBnClickedOk) + ON_EN_CHANGE(IDC_PWD, &CLibSystemDlg::OnEnChangePwd) +END_MESSAGE_MAP() + + +// CLibSystemDlg 消息处理程序 + +BOOL CLibSystemDlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // 将“关于...”菜单项添加到系统菜单中。 + + // IDM_ABOUTBOX 必须在系统命令范围内。 + ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); + ASSERT(IDM_ABOUTBOX < 0xF000); + + CMenu* pSysMenu = GetSystemMenu(FALSE); + if (pSysMenu != nullptr) + { + BOOL bNameValid; + CString strAboutMenu; + bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); + ASSERT(bNameValid); + if (!strAboutMenu.IsEmpty()) + { + pSysMenu->AppendMenu(MF_SEPARATOR); + pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); + } + } + + // 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动 + // 执行此操作 + SetIcon(m_hIcon, TRUE); // 设置大图标 + SetIcon(m_hIcon, FALSE); // 设置小图标 + + // TODO: 在此添加额外的初始化代码 + m_csName = "admin"; + m_csPwd = "123"; + UpdateData(FALSE); + GetDlgItem(IDOK)->SetFocus(); + //GetDlgItem(IDOK)->EnableWindow(FALSE); + LoadUser(_T(".//user.txt")); + pList = &m_listUser; + return TRUE; // 除非将焦点设置到控件,否则返回 TRUE +} + +void CLibSystemDlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) + { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } + else + { + CDialogEx::OnSysCommand(nID, lParam); + } +} + +// 如果向对话框添加最小化按钮,则需要下面的代码 +// 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序, +// 这将由框架自动完成。 + +void CLibSystemDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // 用于绘制的设备上下文 + + SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); + + // 使图标在工作区矩形中居中 + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // 绘制图标 + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CDialogEx::OnPaint(); + } +} + +//当用户拖动最小化窗口时系统调用此函数取得光标 +//显示。 +HCURSOR CLibSystemDlg::OnQueryDragIcon() +{ + return static_cast(m_hIcon); +} + + + +void CLibSystemDlg::OnBnClickedOk() +{ + // TODO: 在此添加控件通知处理程序代码 + UpdateData(TRUE); + CheckUser(m_csName); + if (m_csName.GetBuffer() == m_it->m_sUName + && m_csPwd.GetBuffer() == m_it->m_sPwd) + { + if (m_it->m_nAuthority == 1) + { + CDialogEx::OnCancel(); + CDlgIndex dlg; + dlg.DoModal(); + CDialogEx::OnOK(); + } + else if (m_it->m_nAuthority == 0) + { + CDialogEx::OnCancel(); + CDlgUserIndex dlg; + dlg.DoModal(); + CDialogEx::OnOK(); + } + } + else + { + AfxMessageBox(_T("Anything wrong!")); + } +} + + +void CLibSystemDlg::OnEnChangePwd() +{ + // TODO: 如果该控件是 RICHEDIT 控件,它将不 + // 发送此通知,除非重写 CDialogEx::OnInitDialog() + // 函数并调用 CRichEditCtrl().SetEventMask(), + // 同时将 ENM_CHANGE 标志“或”运算到掩码中。 + + // TODO: 在此添加控件通知处理程序代码 + GetDlgItem(IDOK)->EnableWindow(TRUE); +} + +void CLibSystemDlg::LoadUser(CString csFullPath) +{ + m_listUser.clear(); + ifstream in(csFullPath, ios::in); + if (in.is_open()) + { + int num; + in >> num; + for (int i = 0; i < num; i++) + { + CUser user = CUser(); + user.Load(in); + m_listUser.push_back(user); + } + in.close(); + } +} + +void CLibSystemDlg::CheckUser(CString csUName) +{ + if (pList->size() == 0) + { + bFound = false; + AfxMessageBox(_T("请保证user.txt与工程文件在同一路径下")); + } + for (list::iterator it = pList->begin(); it != pList->end(); it++) + { + if (it->m_sUName == csUName.GetBuffer()) + { + m_it = it; + bFound = true; + break; + } + } + if (bFound == false) + { + m_it = pList->begin(); + } +} diff --git "a/cpp\350\257\276\350\256\276/LibSystem/LibSystemDlg.h" "b/cpp\350\257\276\350\256\276/LibSystem/LibSystemDlg.h" new file mode 100644 index 0000000..e26313c --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/LibSystemDlg.h" @@ -0,0 +1,48 @@ + +// LibSystemDlg.h: 头文件 +// + +#pragma once +#include "CUser.h" +#include "CDataAdapter.h" +// CLibSystemDlg 对话框 +class CLibSystemDlg : public CDialogEx +{ +// 构造 +public: + CLibSystemDlg(CWnd* pParent = nullptr); // 标准构造函数 + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_LIBSYSTEM_DIALOG }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +public: + CDataAdapter m_da; +// 实现 +protected: + HICON m_hIcon; + + // 生成的消息映射函数 + virtual BOOL OnInitDialog(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + DECLARE_MESSAGE_MAP() +public: + // username + CString m_csName; + // password + CString m_csPwd; + list m_listUser; + afx_msg void OnBnClickedOk(); + afx_msg void OnEnChangePwd(); + void LoadUser(CString csFullPath); + void CheckUser(CString csUName); + list* pList; + list::iterator m_it; + bool bFound; +}; diff --git "a/cpp\350\257\276\350\256\276/LibSystem/data.txt" "b/cpp\350\257\276\350\256\276/LibSystem/data.txt" new file mode 100644 index 0000000..35205ac --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/data.txt" @@ -0,0 +1,6 @@ +5 +ɢѧ 9787805130699 Ϻѧ׳ 5 2023 1 ȻӦÿѧ 2023 1 16 2 test +ɢѧ 9787805130699 Ϻѧ׳ 5 2023 1 ȻӦÿѧ 2023 1 18 3 δ +ɢѧ 9787805130699 Ϻѧ׳ 5 2023 1 ȻӦÿѧ 2023 1 18 4 δ +ɢѧ 9787805130699 Ϻѧ׳ 5 2023 1 ȻӦÿѧ 2023 1 18 5 δ +ɢѧ 9787805130699 Ϻѧ׳ 5 2023 1 ȻӦÿѧ 2023 1 18 6 δ diff --git "a/cpp\350\257\276\350\256\276/LibSystem/framework.h" "b/cpp\350\257\276\350\256\276/LibSystem/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/cpp\350\257\276\350\256\276/LibSystem/globe.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/globe.cpp" new file mode 100644 index 0000000..ab90d3f --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/globe.cpp" @@ -0,0 +1,5 @@ +#include "pch.h" +#include "globe.h" + +CString g_BookCata[] = {_T("ѧ"),_T("ѧ") ,_T("ѧ&") ,_T("ʷ&") ,_T("ȻӦÿѧ")}; +const int CataNum = 5; \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/LibSystem/globe.h" "b/cpp\350\257\276\350\256\276/LibSystem/globe.h" new file mode 100644 index 0000000..206e177 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/globe.h" @@ -0,0 +1,3 @@ +#pragma once +extern CString g_BookCata[]; +extern const int CataNum; \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/LibSystem/pch.cpp" "b/cpp\350\257\276\350\256\276/LibSystem/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/cpp\350\257\276\350\256\276/LibSystem/pch.h" "b/cpp\350\257\276\350\256\276/LibSystem/pch.h" new file mode 100644 index 0000000..1b732ff --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/pch.h" @@ -0,0 +1,15 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" +#include +#include +using namespace std; +#endif //PCH_H diff --git "a/cpp\350\257\276\350\256\276/LibSystem/res/LibSystem.ico" "b/cpp\350\257\276\350\256\276/LibSystem/res/LibSystem.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/cpp\350\257\276\350\256\276/LibSystem/res/LibSystem.ico" differ diff --git "a/cpp\350\257\276\350\256\276/LibSystem/res/LibSystem.rc2" "b/cpp\350\257\276\350\256\276/LibSystem/res/LibSystem.rc2" new file mode 100644 index 0000000..b77c452 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/LibSystem/res/LibSystem.rc2" differ diff --git "a/cpp\350\257\276\350\256\276/LibSystem/resource.h" "b/cpp\350\257\276\350\256\276/LibSystem/resource.h" new file mode 100644 index 0000000..777bde8 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/resource.h" @@ -0,0 +1,67 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ 生成的包含文件。 +// 供 LibSystem.rc 使用 +// +#define IDM_ABOUTBOX 0x0010 +#define IDD_ABOUTBOX 100 +#define IDS_ABOUTBOX 101 +#define IDD_LIBSYSTEM_DIALOG 102 +#define IDR_MAINFRAME 128 +#define IDD_DIALOG_INDEX 130 +#define IDD_DIALOG_ADD 146 +#define IDD_DIALOG_DELETE 148 +#define IDD_DIALOG_FIND 149 +#define IDD_DIALOG_LEND 150 +#define IDD_DIALOG_USER_INDEX 151 +#define IDC_NAME 1000 +#define IDC_PWD 1001 +#define IDC_BUTTON1 1001 +#define IDC_BUTTON_ADD 1001 +#define IDC_PREV 1001 +#define IDC_BUTTON2 1002 +#define IDC_BUTTON_SEARCH 1002 +#define IDC_DATETIMEPICKER_BUY 1002 +#define IDC_BUTTON_FIND 1002 +#define IDC_BUTTON3 1003 +#define IDC_BUTTON_MODIFY 1003 +#define IDC_NEXT 1003 +#define IDC_BUTTON4 1004 +#define IDC_BUTTON_DELETE 1004 +#define IDC_BUTTON5 1005 +#define IDC_BUTTON_INPUT 1005 +#define IDC_BUTTON_OUTPUT 1007 +#define IDC_COMBO_CATA 1007 +#define IDC_EDIT_NAME 1008 +#define IDC_EDIT_ISBN 1009 +#define IDC_EDIT_PUB 1010 +#define IDC_EDIT_BORROW 1011 +#define IDC_EDIT_PYEAR 1012 +#define IDC_SPIN_YEAR 1013 +#define IDC_SPIN_MONTH 1014 +#define IDC_EDIT_PMONTH 1015 +#define IDC_EDIT_NUM 1016 +#define IDC_EDIT_STOCK 1016 +#define IDC_SPIN_NUM 1017 +#define IDC_FIND 1018 +#define IDC_EDIT_BNO 1019 +#define IDC_UPDATEINFO 1020 +#define IDC_UPDATEBOOK 1021 +#define IDC_DELETEALL 1022 +#define IDC_DELETEBOOK 1023 +#define ID_ABORT_ISBN 1024 +#define ID_ABORT_NO 1025 +#define IDC_LEND 1026 +#define IDC_RETURN 1027 +#define ID_ABORT 1028 +#define IDC_EDIT_RETRUN 1029 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 150 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1030 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git "a/cpp\350\257\276\350\256\276/LibSystem/targetver.h" "b/cpp\350\257\276\350\256\276/LibSystem/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/cpp\350\257\276\350\256\276/LibSystem/user.txt" "b/cpp\350\257\276\350\256\276/LibSystem/user.txt" new file mode 100644 index 0000000..98b0b81 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/LibSystem/user.txt" @@ -0,0 +1,3 @@ +2 +admin 123 1 +user 1 0 \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys.sln" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys.sln" new file mode 100644 index 0000000..015b809 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31605.320 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StuMgrSys", "StuMgrSys\StuMgrSys.vcxproj", "{469107F9-978A-4F70-905D-E204E9144973}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {469107F9-978A-4F70-905D-E204E9144973}.Debug|x64.ActiveCfg = Debug|x64 + {469107F9-978A-4F70-905D-E204E9144973}.Debug|x64.Build.0 = Debug|x64 + {469107F9-978A-4F70-905D-E204E9144973}.Debug|x86.ActiveCfg = Debug|Win32 + {469107F9-978A-4F70-905D-E204E9144973}.Debug|x86.Build.0 = Debug|Win32 + {469107F9-978A-4F70-905D-E204E9144973}.Release|x64.ActiveCfg = Release|x64 + {469107F9-978A-4F70-905D-E204E9144973}.Release|x64.Build.0 = Release|x64 + {469107F9-978A-4F70-905D-E204E9144973}.Release|x86.ActiveCfg = Release|Win32 + {469107F9-978A-4F70-905D-E204E9144973}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3DBF366B-5224-4F4D-BD01-E153C23CA2B8} + EndGlobalSection +EndGlobal diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CData.cpp" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CData.cpp" new file mode 100644 index 0000000..aeb011f --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CData.cpp" @@ -0,0 +1,130 @@ +#include "pch.h" +#include "CStudent.h" +#include "CData.h" + +int CData::m_sID = 0; +CData* CData::m_sInstance = NULL; +CData::CData() +{ + if (m_sID == 0) + m_sID++; +} + +CData::~CData() +{ + +} + +CData* CData::CreateInstance() +{ + if (m_sID == 0) + m_sInstance = new CData(); + return m_sInstance; +} + +void CData::DeleteInstance() +{ + if (m_sInstance != NULL) + { + delete m_sInstance; + m_sID = 0; + } + m_sInstance = NULL; +} + +void CData::Save(CString csFullPath) +{ + ofstream out(csFullPath, ios::out); + if (out.is_open()) + { + out << m_listStudent.size() << endl; + for (list::iterator it = m_listStudent.begin(); it != m_listStudent.end(); it++) + it->Save(out); + out.close(); + } +} + +void CData::Load(CString csFullPath) +{ + m_listStudent.clear(); + ifstream in(csFullPath, ios::in); + if (in.is_open()) + { + int num; + in >> num; + for (int i = 0; i < num; i++) + { + CStudent stu; + stu.Load(in); + m_listStudent.push_back(stu); + } + in.close(); + } +} + +void CData::AddStudent(CStudent& stu) +{ + m_listStudent.push_back(stu); +} + +void CData::AddStudent(string sNo, string sName, BOOL bGender, + int nYear, int nMonth, int nDay, + int nGrade, string sMajor) +{ + CStudent stu; + stu.SetStudent(sNo, sName, bGender, nYear, nMonth, nDay, nGrade, sMajor); + m_listStudent.push_back(stu); +} + +bool SortByNoAscent(CStudent &stu1, CStudent&stu2) +{ + return (stu1.m_sNo < stu2.m_sNo); +} + +bool CData::FindStudentByNo(string& sNo, string& sName, BOOL& bGender, + int& nYear, int& nMonth, int& nDay, + int& nGrade, string& sMajor) +{ + bool bFound = false; + for (list::iterator it = m_listStudent.begin(); it != m_listStudent.end(); it++) + { + if (it->m_sNo == sNo) + { + sName = it->m_sName; + bGender = it->m_bGender; + nYear = it->m_nYear; + nMonth = it->m_nMonth; + nDay = it->m_nDay; + nGrade = it->m_nGrade; + sMajor = it->m_sMajor; + + bFound = true; + break; + } + } + return bFound; +} +void CData::DeleStudentByNo(string sNo) +{ + for (list::iterator it = m_listStudent.begin(); it != m_listStudent.end(); it++) + { + if (it->m_sNo == sNo) + { + m_listStudent.erase(it); + break; + } + } +} +void CData::UpdateStudent(string sNo, string sName, BOOL bGender, + int nYear, int nMonth, int nDay, + int nGrade, string sMajor) +{ + for (list::iterator it = m_listStudent.begin(); it != m_listStudent.end(); it++) + { + if (it->m_sNo == sNo) + { + it->SetStudent(sNo, sName, bGender, nYear, nMonth, nDay, nGrade, sMajor); + break; + } + } +} \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CData.h" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CData.h" new file mode 100644 index 0000000..bb17461 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CData.h" @@ -0,0 +1,30 @@ +#pragma once +#include "CStudent.h" +class CData +{ +private: + CData(); + ~CData(); +public: + static CData* CreateInstance(); + static void DeleteInstance(); + void AddStudent(CStudent& stu); + void AddStudent(string sNo, string sName, BOOL bGender, + int nYear, int nMonth, int nDay, + int nGrade, string sMajor); + bool FindStudentByNo(string& sNo, string& sName, BOOL& bGender, + int& nYear, int& nMonth, int& nDay, + int& nGrade, string& sMajor); + void DeleStudentByNo(string sNo); + void UpdateStudent(string sNo, string sName, BOOL bGender, + int nYear, int nMonth, int nDay, + int nGrade, string sMajor); + void Save(CString csFullPath); + void Load(CString csFullPath); + inline int GetNumOfStudent() { return m_listStudent.size(); } +public: + static int m_sID; + static CData* m_sInstance; + list m_listStudent; +}; + diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDataAdapter.cpp" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDataAdapter.cpp" new file mode 100644 index 0000000..695b89f --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDataAdapter.cpp" @@ -0,0 +1,138 @@ +#include "pch.h" +#include "CDataAdapter.h" +CDataAdapter::CDataAdapter() +{ + m_pData = CData::CreateInstance(); +} +CDataAdapter::~CDataAdapter() +{ + if (m_pData) + CData::DeleteInstance(); + m_pData = NULL; +} + +void CDataAdapter::AddStudent(string sNo, string sName, BOOL bGender, + int nYear, int nMonth, int nDay, + int nGrade, string sMajor) +{ + m_pData->AddStudent(sNo, sName, bGender, nYear, nMonth, nDay, + nGrade, sMajor); + +} + +bool CDataAdapter::FindStudentByNo(string& sNo, string& sName, BOOL& bGender, + int& nYear, int& nMonth, int& nDay, + int& nGrade, string& sMajor) +{ + return m_pData->FindStudentByNo(sNo, sName, bGender, nYear, nMonth, nDay, + nGrade, sMajor); +} + +void CDataAdapter::DeleStudentByNo(string sNo) +{ + m_pData->DeleStudentByNo(sNo); +} + +void CDataAdapter::UpdateStudent(string sNo, string sName, BOOL bGender, + int nYear, int nMonth, int nDay, + int nGrade, string sMajor) +{ + m_pData->UpdateStudent(sNo, sName, bGender, nYear, nMonth, nDay, + nGrade, sMajor); +} + +void CDataAdapter::Save() +{ + m_pData->Save(_T("D:\\data.txt")); +} + +void CDataAdapter::Load() +{ + m_pData->Load(_T("D:\\data.txt")); +} + +bool CDataAdapter::GetFirstStudent(CStudent& stu) +{ + list* pList = GetListOfStudent(); + if (pList->size() == 0) + return false; + + m_it = pList->begin(); + stu = *m_it; + return true; +} +bool CDataAdapter::GetNextStudent(CStudent& stu) +{ + list* pList = GetListOfStudent(); + bool bRes = false; + if (pList->size() != 0) + { + m_it++; + if (m_it == pList->end()) + m_it--; + stu = *m_it; + bRes = true; + } + return bRes; +} + +bool CDataAdapter::GetPrevStudent(CStudent& stu) +{ + list* pList = GetListOfStudent(); + bool bRes = false; + + if (pList->size() != 0) + { + if (m_it != pList->begin()) + m_it--; + + stu = *m_it; + bRes = true; + } + return bRes; +} +bool CDataAdapter::GetLastStudent(CStudent& stu) +{ + list* pList = GetListOfStudent(); + if (pList->size() == 0) + return false; + + m_it = pList->end(); + m_it--; + stu = *m_it; + return true; +} + +bool CDataAdapter::FindStudentByNo(string sNo, CStudent& stu) +{ + list* pList = GetListOfStudent(); + if (pList->size() == 0) + return false; + + bool bFound = false; + for (list::iterator it = pList->begin(); it != pList->end(); it++) + { + if (it->m_sNo == sNo) + { + m_it = it; + stu = *it; + bFound = true; + break; + } + } + if (bFound == false) + stu = *m_it; + return bFound; +} + + +void CDataAdapter::FillWithStudent(CStudent& stu, CString& csNo, CString& csName, + BOOL& bGender, COleDateTime& tmBirth, int& nGrade, CString& csMajor) +{ + csNo = stu.m_sNo.c_str(); + csName = stu.m_sName.c_str(); + bGender = stu.m_bGender; + tmBirth = COleDateTime(stu.m_nYear, stu.m_nMonth, stu.m_nDay, 0, 0, 0); + nGrade = stu.m_nGrade; + csMajor = stu.m_sMajor.c_str(); +} \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDataAdapter.h" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDataAdapter.h" new file mode 100644 index 0000000..229496b --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDataAdapter.h" @@ -0,0 +1,37 @@ +#pragma once +#include "CData.h" +class CDataAdapter +{ +public: + CDataAdapter(); + ~CDataAdapter(); + void AddStudent(string sNo, string sName, BOOL bGender, + int nYear, int nMonth, int nDay, + int nGrade, string sMajor); + + bool FindStudentByNo(string& sNo, string& sName, BOOL& bGender, + int& nYear, int& nMonth, int& nDay, + int& nGrade, string& sMajor); + void DeleStudentByNo(string sNo); + void UpdateStudent(string sNo, string sName, BOOL bGender, + int nYear, int nMonth, int nDay, + int nGrade, string sMajor); + + void Save(); + void Load(); + + inline int GetNumOfStudent() { return m_pData->GetNumOfStudent(); } + inline list* GetListOfStudent() { return &m_pData->m_listStudent; } + bool GetFirstStudent(CStudent& stu); + bool GetNextStudent(CStudent& stu); + bool GetPrevStudent(CStudent& stu); + bool GetLastStudent(CStudent& stu); + bool FindStudentByNo(string sNo, CStudent& stu); + + void FillWithStudent(CStudent& stu, CString& csNo, CString& sName, BOOL& bGender, + COleDateTime& tmBirth, int& nGrade, CString& csMajor); +public: + CData* m_pData; + list::iterator m_it; +}; + diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDlgAdd.cpp" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDlgAdd.cpp" new file mode 100644 index 0000000..a2a726b --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDlgAdd.cpp" @@ -0,0 +1,91 @@ +// CDlgAdd.cpp: 实现文件 +// + +#include "pch.h" +#include "globe.h" +#include "CStudent.h" +#include "CData.h" +#include "CDataAdapter.h" +#include "StuMgrSys.h" +#include "CDlgAdd.h" +#include "afxdialogex.h" + + +// CDlgAdd 对话框 + +IMPLEMENT_DYNAMIC(CDlgAdd, CDialogEx) + +CDlgAdd::CDlgAdd(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_DIALOG_ADD, pParent) + , m_csNo(_T("")) + , m_csName(_T("")) + , m_bGender(FALSE) + , m_tmBirth(COleDateTime::GetCurrentTime()) + , m_nGrade(0) +{ + +} + +CDlgAdd::~CDlgAdd() +{ +} + +void CDlgAdd::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Text(pDX, IDC_NO, m_csNo); + DDV_MaxChars(pDX, m_csNo, 8); + DDX_Text(pDX, IDC_NAME, m_csName); + DDX_Radio(pDX, IDC_RADIO_GENDER, m_bGender); + DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_BIRTH, m_tmBirth); + DDX_Text(pDX, IDC_GRADE, m_nGrade); + DDV_MinMaxInt(pDX, m_nGrade, 1978, 2050); + DDX_Control(pDX, IDC_COMBO_MAJOR, m_comboMajor); + DDX_Control(pDX, IDC_SPIN1, m_spinGrade); +} + + +BEGIN_MESSAGE_MAP(CDlgAdd, CDialogEx) + ON_BN_CLICKED(IDOK, &CDlgAdd::OnBnClickedOk) +END_MESSAGE_MAP() + + +// CDlgAdd 消息处理程序 +void CDlgAdd::SetDA(CDataAdapter* pDA) +{ + m_pDA = pDA; +} + +BOOL CDlgAdd::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // TODO: 在此添加额外的初始化 + m_bGender = GENDER_MALE; + m_nGrade = 2021; + for (int i = 0; i < MAJORS_NUM ; i++) + m_comboMajor.AddString(g_csMajors[i]); + m_comboMajor.SetCurSel(0); + UpdateData(FALSE); + m_spinGrade.SetBuddy(GetDlgItem(IDC_GRADE)); + m_spinGrade.SetRange(1978, 2050); + GetDlgItem(IDC_NO)->SetFocus(); + return FALSE; // return TRUE unless you set the focus to a control + // 异常: OCX 属性页应返回 FALSE +} + + +void CDlgAdd::OnBnClickedOk() +{ + // TODO: 在此添加控件通知处理程序代码 + UpdateData(TRUE); + CString csMajor; + csMajor = g_csMajors[m_comboMajor.GetCurSel()]; + m_pDA->AddStudent(m_csNo.GetBuffer(), m_csName.GetBuffer(), m_bGender, + m_tmBirth.GetYear(), m_tmBirth.GetMonth(), m_tmBirth.GetDay(), + m_nGrade, csMajor.GetBuffer()); + + m_pDA->Save(); + + CDialogEx::OnOK(); +} diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDlgAdd.h" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDlgAdd.h" new file mode 100644 index 0000000..44f0065 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDlgAdd.h" @@ -0,0 +1,36 @@ +#pragma once + + +// CDlgAdd 对话框 + +class CDlgAdd : public CDialogEx +{ + DECLARE_DYNAMIC(CDlgAdd) + +public: + CDlgAdd(CWnd* pParent = nullptr); // 标准构造函数 + virtual ~CDlgAdd(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_DIALOG_ADD }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + + DECLARE_MESSAGE_MAP() +public: + CString m_csNo; + CString m_csName; + BOOL m_bGender; + COleDateTime m_tmBirth; + int m_nGrade; + CComboBox m_comboMajor; + virtual BOOL OnInitDialog(); + CSpinButtonCtrl m_spinGrade; + afx_msg void OnBnClickedOk(); +public: + CDataAdapter* m_pDA; + void SetDA(CDataAdapter* pDA); +}; diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDlgFind.cpp" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDlgFind.cpp" new file mode 100644 index 0000000..ca1a91e --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDlgFind.cpp" @@ -0,0 +1,139 @@ +// CDlgFind.cpp: 实现文件 +// + +#include "pch.h" +#include "globe.h" +#include "CStudent.h" +#include "CData.h" +#include "CDataAdapter.h" +#include "StuMgrSys.h" +#include "CDlgFind.h" +#include "afxdialogex.h" + + +// CDlgFind 对话框 + +IMPLEMENT_DYNAMIC(CDlgFind, CDialogEx) + +CDlgFind::CDlgFind(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_DIALOG_FIND, pParent) + , m_csNo(_T("")) + , m_csName(_T("")) + , m_tmBirth(COleDateTime::GetCurrentTime()) + , m_nGrade(0) + , m_bGender(FALSE) +{ + +} + +CDlgFind::~CDlgFind() +{ +} + +void CDlgFind::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Text(pDX, IDC_NO, m_csNo); + DDV_MaxChars(pDX, m_csNo, 8); + DDX_Text(pDX, IDC_NAME, m_csName); + DDX_Control(pDX, IDC_COMBO_MAJOR, m_comboMajor); + DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_BIRTH, m_tmBirth); + DDX_Text(pDX, IDC_GRADE, m_nGrade); + DDV_MinMaxInt(pDX, m_nGrade, 1978, 2050); + DDX_Radio(pDX, IDC_RADIO_GENDER, m_bGender); + DDX_Control(pDX, IDC_SPIN1, m_spinGrade); +} + + +BEGIN_MESSAGE_MAP(CDlgFind, CDialogEx) + ON_BN_CLICKED(IDC_PREV, &CDlgFind::OnBnClickedPrev) + ON_BN_CLICKED(IDC_NEXT, &CDlgFind::OnBnClickedNext) + ON_BN_CLICKED(IDC_FIND, &CDlgFind::OnBnClickedFind) +END_MESSAGE_MAP() + + +// CDlgFind 消息处理程序 + +void CDlgFind::SetDA(CDataAdapter* pDA) +{ + m_pDA = pDA; +} + +BOOL CDlgFind::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // TODO: 在此添加额外的初始化 + if (m_pDA && m_pDA->GetNumOfStudent()>0) + { + CStudent stu; + int index=0; + m_pDA->GetFirstStudent(stu); + m_pDA->FillWithStudent(stu, m_csNo, m_csName, m_bGender, m_tmBirth, m_nGrade, m_csMajor); + for (int i = 0; i < MAJORS_NUM; i++) + { + m_comboMajor.AddString(g_csMajors[i]); + if (m_csMajor == g_csMajors[i]) + index = i; + } + m_comboMajor.SetCurSel(index); + } + UpdateData(FALSE); + m_spinGrade.SetBuddy(GetDlgItem(IDC_GRADE)); + m_spinGrade.SetRange(1978, 2050); + GetDlgItem(IDC_NO)->SetFocus(); + + return TRUE; // return TRUE unless you set the focus to a control + // 异常: OCX 属性页应返回 FALSE +} + + +void CDlgFind::OnBnClickedPrev() +{ + // TODO: 在此添加控件通知处理程序代码 + CStudent stu; + int index = 0; + m_pDA->GetPrevStudent(stu); + m_pDA->FillWithStudent(stu, m_csNo, m_csName, m_bGender, m_tmBirth, m_nGrade, m_csMajor); + UpdateData(FALSE); + + for (int i = 0; i < MAJORS_NUM; i++) + if (m_csMajor == g_csMajors[i]) + index = i; + m_comboMajor.SetCurSel(index); +} + + +void CDlgFind::OnBnClickedNext() +{ + // TODO: 在此添加控件通知处理程序代码 + CStudent stu; + int index = 0; + m_pDA->GetNextStudent(stu); + m_pDA->FillWithStudent(stu, m_csNo, m_csName, m_bGender, m_tmBirth, m_nGrade, m_csMajor); + UpdateData(FALSE); + + for (int i = 0; i < MAJORS_NUM; i++) + if (m_csMajor == g_csMajors[i]) + index = i; + m_comboMajor.SetCurSel(index); + +} + + +void CDlgFind::OnBnClickedFind() +{ + // TODO: 在此添加控件通知处理程序代码 + CStudent stu; + int index = 0; + UpdateData(TRUE); + string sNo = m_csNo.GetBuffer(); + m_pDA->FindStudentByNo(sNo,stu); + m_pDA->FillWithStudent(stu, m_csNo, m_csName, m_bGender, m_tmBirth, m_nGrade, m_csMajor); + UpdateData(FALSE); + + for (int i = 0; i < MAJORS_NUM; i++) + if (m_csMajor == g_csMajors[i]) + index = i; + m_comboMajor.SetCurSel(index); +} diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDlgFind.h" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDlgFind.h" new file mode 100644 index 0000000..e65c7cd --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CDlgFind.h" @@ -0,0 +1,40 @@ +#pragma once + + +// CDlgFind 对话框 + +class CDlgFind : public CDialogEx +{ + DECLARE_DYNAMIC(CDlgFind) + +public: + CDlgFind(CWnd* pParent = nullptr); // 标准构造函数 + virtual ~CDlgFind(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_DIALOG_FIND }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + + DECLARE_MESSAGE_MAP() +public: + virtual BOOL OnInitDialog(); + afx_msg void OnBnClickedPrev(); + afx_msg void OnBnClickedNext(); + afx_msg void OnBnClickedFind(); + CString m_csNo; + CString m_csName; + CComboBox m_comboMajor; + COleDateTime m_tmBirth; + int m_nGrade; + BOOL m_bGender; + CSpinButtonCtrl m_spinGrade; + +public: + CString m_csMajor; + CDataAdapter* m_pDA; + void SetDA(CDataAdapter* pDA); +}; diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CStudent.cpp" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CStudent.cpp" new file mode 100644 index 0000000..0179661 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CStudent.cpp" @@ -0,0 +1,62 @@ +#include "pch.h" +#include "CStudent.h" + +CStudent::CStudent() +{ + +} + +CStudent::CStudent(string sNo, string sName, BOOL bGender, + int nYear, int nMonth, int nDay, + int nGrade, string sMajor) +{ + m_sNo = sNo; + m_sName = sName; + m_bGender = bGender; + m_nYear = nYear; + m_nMonth = nMonth; + m_nDay = nDay; + m_nGrade =nGrade; + m_sMajor = sMajor; +} + +CStudent::~CStudent() +{ + +} + +void CStudent::SetStudent(string sNo, string sName, BOOL bGender, + int nYear, int nMonth, int nDay, + int nGrade, string sMajor) +{ + m_sNo = sNo; + m_sName = sName; + m_bGender = bGender; + m_nYear = nYear; + m_nMonth = nMonth; + m_nDay = nDay; + m_nGrade = nGrade; + m_sMajor = sMajor; +} + +void CStudent::Save(ofstream& out) +{ + out << m_sNo << _T("\t"); + out << m_sName << _T("\t"); + out << m_bGender << _T("\t"); + out << m_nYear << _T("\t"); + out << m_nMonth << _T("\t"); + out << m_nDay << _T("\t"); + out << m_nGrade << _T("\t"); + out << m_sMajor << _T("\n"); +} + +void CStudent::Load(ifstream& in) +{ + in >> m_sNo; + in >> m_sName; + in >> m_bGender; + in >> m_nYear >> m_nMonth >> m_nDay; + in >> m_nGrade; + in >> m_sMajor; +} \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CStudent.h" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CStudent.h" new file mode 100644 index 0000000..6591dee --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/CStudent.h" @@ -0,0 +1,28 @@ +#pragma once + +class CStudent +{ +public: + CStudent(); + CStudent(string sNo,string sName,BOOL bGender, + int nYear, int nMonth, int nDay, + int nGrade,string sMajor); + ~CStudent(); + + void SetStudent(string sNo, string sName, BOOL bGender, + int nYear, int nMonth, int nDay, + int nGrade, string sMajor); + + void Save(ofstream &out); + void Load(ifstream& in); +public: + string m_sNo; + string m_sName; + BOOL m_bGender; + int m_nYear; + int m_nMonth; + int m_nDay; + int m_nGrade; + string m_sMajor; +}; + diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.aps" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.aps" new file mode 100644 index 0000000..ba3016f Binary files /dev/null and "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.aps" differ diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.cpp" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.cpp" new file mode 100644 index 0000000..4309281 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.cpp" @@ -0,0 +1,107 @@ + +// StuMgrSys.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "StuMgrSys.h" +#include "StuMgrSysDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CStuMgrSysApp + +BEGIN_MESSAGE_MAP(CStuMgrSysApp, CWinApp) + ON_COMMAND(ID_HELP, &CWinApp::OnHelp) +END_MESSAGE_MAP() + + +// CStuMgrSysApp 构造 + +CStuMgrSysApp::CStuMgrSysApp() +{ + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + + +// 唯一的 CStuMgrSysApp 对象 + +CStuMgrSysApp theApp; + + +// CStuMgrSysApp 初始化 + +BOOL CStuMgrSysApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinApp::InitInstance(); + + + AfxEnableControlContainer(); + + // 创建 shell 管理器,以防对话框包含 + // 任何 shell 树视图控件或 shell 列表视图控件。 + CShellManager *pShellManager = new CShellManager; + + // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题 + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + + CStuMgrSysDlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: 在此放置处理何时用 + // “确定”来关闭对话框的代码 + } + else if (nResponse == IDCANCEL) + { + // TODO: 在此放置处理何时用 + // “取消”来关闭对话框的代码 + } + else if (nResponse == -1) + { + TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n"); + TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n"); + } + + // 删除上面创建的 shell 管理器。 + if (pShellManager != nullptr) + { + delete pShellManager; + } + +#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS) + ControlBarCleanUp(); +#endif + + // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, + // 而不是启动应用程序的消息泵。 + return FALSE; +} + diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.h" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.h" new file mode 100644 index 0000000..408ffd3 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.h" @@ -0,0 +1,32 @@ + +// StuMgrSys.h: PROJECT_NAME 应用程序的主头文件 +// + +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// CStuMgrSysApp: +// 有关此类的实现,请参阅 StuMgrSys.cpp +// + +class CStuMgrSysApp : public CWinApp +{ +public: + CStuMgrSysApp(); + +// 重写 +public: + virtual BOOL InitInstance(); + +// 实现 + + DECLARE_MESSAGE_MAP() +}; + +extern CStuMgrSysApp theApp; diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.rc" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.rc" new file mode 100644 index 0000000..ef835ad Binary files /dev/null and "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.rc" differ diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.vcxproj" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.vcxproj" new file mode 100644 index 0000000..0c47b6c --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.vcxproj" @@ -0,0 +1,227 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {469107F9-978A-4F70-905D-E204E9144973} + MFCProj + StuMgrSys + 10.0 + + + + Application + true + v143 + MultiByte + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + MultiByte + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.vcxproj.filters" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.vcxproj.filters" new file mode 100644 index 0000000..9be7ac4 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.vcxproj.filters" @@ -0,0 +1,99 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.vcxproj.user" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.vcxproj.user" new file mode 100644 index 0000000..2044d89 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSys.vcxproj.user" @@ -0,0 +1,6 @@ + + + + StuMgrSys.rc + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSysDlg.cpp" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSysDlg.cpp" new file mode 100644 index 0000000..699546f --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSysDlg.cpp" @@ -0,0 +1,181 @@ + +// StuMgrSysDlg.cpp: 实现文件 +// + +#include "pch.h" +#include "CDataAdapter.h" +#include "CDlgAdd.h" +#include "CDlgFind.h" +#include "framework.h" +#include "StuMgrSys.h" +#include "StuMgrSysDlg.h" +#include "afxdialogex.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + + +// CStuMgrSysDlg 对话框 + + + +CStuMgrSysDlg::CStuMgrSysDlg(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_STUMGRSYS_DIALOG, pParent) +{ + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); +} + +void CStuMgrSysDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CStuMgrSysDlg, CDialogEx) + ON_WM_SYSCOMMAND() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDC_BUTTON_ADD, &CStuMgrSysDlg::OnBnClickedButtonAdd) + ON_BN_CLICKED(IDC_BUTTON_SEEK, &CStuMgrSysDlg::OnBnClickedButtonSeek) +END_MESSAGE_MAP() + + +// CStuMgrSysDlg 消息处理程序 + +BOOL CStuMgrSysDlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // 将“关于...”菜单项添加到系统菜单中。 + + // IDM_ABOUTBOX 必须在系统命令范围内。 + ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); + ASSERT(IDM_ABOUTBOX < 0xF000); + + CMenu* pSysMenu = GetSystemMenu(FALSE); + if (pSysMenu != nullptr) + { + BOOL bNameValid; + CString strAboutMenu; + bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); + ASSERT(bNameValid); + if (!strAboutMenu.IsEmpty()) + { + pSysMenu->AppendMenu(MF_SEPARATOR); + pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); + } + } + + // 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动 + // 执行此操作 + SetIcon(m_hIcon, TRUE); // 设置大图标 + SetIcon(m_hIcon, FALSE); // 设置小图标 + + // TODO: 在此添加额外的初始化代码 + m_da.Load(); + return TRUE; // 除非将焦点设置到控件,否则返回 TRUE +} + +void CStuMgrSysDlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) + { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } + else + { + CDialogEx::OnSysCommand(nID, lParam); + } +} + +// 如果向对话框添加最小化按钮,则需要下面的代码 +// 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序, +// 这将由框架自动完成。 + +void CStuMgrSysDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // 用于绘制的设备上下文 + + SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); + + // 使图标在工作区矩形中居中 + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // 绘制图标 + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CDialogEx::OnPaint(); + } +} + +//当用户拖动最小化窗口时系统调用此函数取得光标 +//显示。 +HCURSOR CStuMgrSysDlg::OnQueryDragIcon() +{ + return static_cast(m_hIcon); +} + + + +void CStuMgrSysDlg::OnBnClickedButtonAdd() +{ + // TODO: 在此添加控件通知处理程序代码 + CDlgAdd dlg; + dlg.SetDA(&m_da); + dlg.DoModal(); +} + + +void CStuMgrSysDlg::OnBnClickedButtonSeek() +{ + // TODO: 在此添加控件通知处理程序代码 + if (m_da.GetNumOfStudent() == 0) + return; + + CDlgFind dlg; + dlg.SetDA(&m_da); + dlg.DoModal(); +} diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSysDlg.h" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSysDlg.h" new file mode 100644 index 0000000..80fa252 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/StuMgrSysDlg.h" @@ -0,0 +1,38 @@ + +// StuMgrSysDlg.h: 头文件 +// + +#pragma once + +#include "CDataAdapter.h" +// CStuMgrSysDlg 对话框 +class CStuMgrSysDlg : public CDialogEx +{ +// 构造 +public: + CStuMgrSysDlg(CWnd* pParent = nullptr); // 标准构造函数 + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_STUMGRSYS_DIALOG }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +public: + CDataAdapter m_da; +// 实现 +protected: + HICON m_hIcon; + + // 生成的消息映射函数 + virtual BOOL OnInitDialog(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedButtonAdd(); + afx_msg void OnBnClickedButtonSeek(); +}; diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/framework.h" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/globe.cpp" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/globe.cpp" new file mode 100644 index 0000000..87ed24b --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/globe.cpp" @@ -0,0 +1,9 @@ +#include "pch.h" +#include "globe.h" + +const int GENDER_MALE = 0; +const int GENDER_FEMALE = 1; + +const int MAJORS_NUM = 6; +CString g_csMajors[MAJORS_NUM] = { _T("ѧ뼼"),_T("ѧѧ"), + _T("Զ"),_T("㲥ӹ"),_T("̼Զ"),_T("˹ܿѧ뼼") }; \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/globe.h" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/globe.h" new file mode 100644 index 0000000..c7d5628 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/globe.h" @@ -0,0 +1,5 @@ +#pragma once +extern const int GENDER_MALE; +extern const int GENDER_FEMALE; +extern const int MAJORS_NUM; +extern CString g_csMajors[]; \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/pch.cpp" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/pch.h" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/pch.h" new file mode 100644 index 0000000..1b732ff --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/pch.h" @@ -0,0 +1,15 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" +#include +#include +using namespace std; +#endif //PCH_H diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/res/StuMgrSys.ico" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/res/StuMgrSys.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/res/StuMgrSys.ico" differ diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/res/StuMgrSys.rc2" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/res/StuMgrSys.rc2" new file mode 100644 index 0000000..60fdb61 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/res/StuMgrSys.rc2" differ diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/resource.h" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/resource.h" new file mode 100644 index 0000000..12ad671 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/resource.h" @@ -0,0 +1,38 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ 生成的包含文件。 +// 供 StuMgrSys.rc 使用 +// +#define IDM_ABOUTBOX 0x0010 +#define IDD_ABOUTBOX 100 +#define IDS_ABOUTBOX 101 +#define IDD_STUMGRSYS_DIALOG 102 +#define IDR_MAINFRAME 128 +#define IDD_DIALOG_ADD 130 +#define IDD_DIALOG_FIND 131 +#define IDC_BUTTON_ADD 1000 +#define IDC_BUTTON_SEEK 1001 +#define IDC_NAME 1001 +#define IDC_BUTTON_MODIFY 1002 +#define IDC_NO 1002 +#define IDC_BUTTON_DELETE 1003 +#define IDC_DATETIMEPICKER_BIRTH 1003 +#define IDC_RADIO_GENDER 1004 +#define IDC_RADIO2 1005 +#define IDC_GRADE 1006 +#define IDC_SPIN1 1007 +#define IDC_COMBO_MAJOR 1008 +#define IDC_FIND 1009 +#define IDC_PREV 1010 +#define IDC_NEXT 1011 +#define IDC_RICHEDIT21 1016 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 132 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1017 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git "a/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/targetver.h" "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/StuMgrSys/StuMgrSys/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.cpp" "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.cpp" new file mode 100644 index 0000000..0d43c5a --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.cpp" @@ -0,0 +1,107 @@ + +// ex1-Login.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "ex1-Login.h" +#include "ex1-LoginDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cex1LoginApp + +BEGIN_MESSAGE_MAP(Cex1LoginApp, CWinApp) + ON_COMMAND(ID_HELP, &CWinApp::OnHelp) +END_MESSAGE_MAP() + + +// Cex1LoginApp 构造 + +Cex1LoginApp::Cex1LoginApp() +{ + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + + +// 唯一的 Cex1LoginApp 对象 + +Cex1LoginApp theApp; + + +// Cex1LoginApp 初始化 + +BOOL Cex1LoginApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinApp::InitInstance(); + + + AfxEnableControlContainer(); + + // 创建 shell 管理器,以防对话框包含 + // 任何 shell 树视图控件或 shell 列表视图控件。 + CShellManager *pShellManager = new CShellManager; + + // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题 + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + + Cex1LoginDlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: 在此放置处理何时用 + // “确定”来关闭对话框的代码 + } + else if (nResponse == IDCANCEL) + { + // TODO: 在此放置处理何时用 + // “取消”来关闭对话框的代码 + } + else if (nResponse == -1) + { + TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n"); + TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n"); + } + + // 删除上面创建的 shell 管理器。 + if (pShellManager != nullptr) + { + delete pShellManager; + } + +#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS) + ControlBarCleanUp(); +#endif + + // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, + // 而不是启动应用程序的消息泵。 + return FALSE; +} + diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.h" "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.h" new file mode 100644 index 0000000..3ab634b --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.h" @@ -0,0 +1,32 @@ + +// ex1-Login.h: PROJECT_NAME 应用程序的主头文件 +// + +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// Cex1LoginApp: +// 有关此类的实现,请参阅 ex1-Login.cpp +// + +class Cex1LoginApp : public CWinApp +{ +public: + Cex1LoginApp(); + +// 重写 +public: + virtual BOOL InitInstance(); + +// 实现 + + DECLARE_MESSAGE_MAP() +}; + +extern Cex1LoginApp theApp; diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.sln" "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.sln" new file mode 100644 index 0000000..fc6bd69 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ex1-Login", "ex1-Login.vcxproj", "{BE513DF5-54C0-4536-B38C-90682B341D57}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BE513DF5-54C0-4536-B38C-90682B341D57}.Debug|x64.ActiveCfg = Debug|x64 + {BE513DF5-54C0-4536-B38C-90682B341D57}.Debug|x64.Build.0 = Debug|x64 + {BE513DF5-54C0-4536-B38C-90682B341D57}.Debug|x86.ActiveCfg = Debug|Win32 + {BE513DF5-54C0-4536-B38C-90682B341D57}.Debug|x86.Build.0 = Debug|Win32 + {BE513DF5-54C0-4536-B38C-90682B341D57}.Release|x64.ActiveCfg = Release|x64 + {BE513DF5-54C0-4536-B38C-90682B341D57}.Release|x64.Build.0 = Release|x64 + {BE513DF5-54C0-4536-B38C-90682B341D57}.Release|x86.ActiveCfg = Release|Win32 + {BE513DF5-54C0-4536-B38C-90682B341D57}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E035E00C-A3E0-4C20-82F7-9580330A7BA4} + EndGlobalSection +EndGlobal diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.vcxproj" "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.vcxproj" new file mode 100644 index 0000000..12167ff --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.vcxproj" @@ -0,0 +1,215 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {BE513DF5-54C0-4536-B38C-90682B341D57} + MFCProj + ex1Login + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.vcxproj.filters" "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.vcxproj.filters" new file mode 100644 index 0000000..2f56ffe --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.vcxproj.filters" @@ -0,0 +1,63 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.vcxproj.user" "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.vcxproj.user" new file mode 100644 index 0000000..b197076 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-Login.vcxproj.user" @@ -0,0 +1,6 @@ + + + + ex1Login.rc + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/ex1-LoginDlg.cpp" "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-LoginDlg.cpp" new file mode 100644 index 0000000..1a080e4 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-LoginDlg.cpp" @@ -0,0 +1,197 @@ + +// ex1-LoginDlg.cpp: 实现文件 +// + +#include "pch.h" +#include "framework.h" +#include "ex1-Login.h" +#include "ex1-LoginDlg.h" +#include "afxdialogex.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + + +// Cex1LoginDlg 对话框 + + + +Cex1LoginDlg::Cex1LoginDlg(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_EX1LOGIN_DIALOG, pParent) + , m_csName(_T("")) + , m_csPwd(_T("")) +{ + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); +} + +void Cex1LoginDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Text(pDX, IDC_NAME, m_csName); + DDV_MaxChars(pDX, m_csName, 6); + DDX_Text(pDX, IDC_PWD, m_csPwd); + DDV_MaxChars(pDX, m_csPwd, 6); +} + +BEGIN_MESSAGE_MAP(Cex1LoginDlg, CDialogEx) + ON_WM_SYSCOMMAND() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDOK, &Cex1LoginDlg::OnBnClickedOk) + ON_EN_CHANGE(IDC_PWD, &Cex1LoginDlg::OnEnChangePwd) +END_MESSAGE_MAP() + + +// Cex1LoginDlg 消息处理程序 + +BOOL Cex1LoginDlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // 将“关于...”菜单项添加到系统菜单中。 + + // IDM_ABOUTBOX 必须在系统命令范围内。 + ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); + ASSERT(IDM_ABOUTBOX < 0xF000); + + CMenu* pSysMenu = GetSystemMenu(FALSE); + if (pSysMenu != nullptr) + { + BOOL bNameValid; + CString strAboutMenu; + bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); + ASSERT(bNameValid); + if (!strAboutMenu.IsEmpty()) + { + pSysMenu->AppendMenu(MF_SEPARATOR); + pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); + } + } + + // 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动 + // 执行此操作 + SetIcon(m_hIcon, TRUE); // 设置大图标 + SetIcon(m_hIcon, FALSE); // 设置小图标 + + // TODO: 在此添加额外的初始化代码 + m_csName = "test"; + m_csPwd = ""; + UpdateData(FALSE); + + GetDlgItem(IDC_PWD)->SetFocus(); + GetDlgItem(IDOK)->EnableWindow(FALSE); + return FALSE; // 除非将焦点设置到控件,否则返回 TRUE +} + +void Cex1LoginDlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) + { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } + else + { + CDialogEx::OnSysCommand(nID, lParam); + } +} + +// 如果向对话框添加最小化按钮,则需要下面的代码 +// 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序, +// 这将由框架自动完成。 + +void Cex1LoginDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // 用于绘制的设备上下文 + + SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); + + // 使图标在工作区矩形中居中 + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // 绘制图标 + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CDialogEx::OnPaint(); + } +} + +//当用户拖动最小化窗口时系统调用此函数取得光标 +//显示。 +HCURSOR Cex1LoginDlg::OnQueryDragIcon() +{ + return static_cast(m_hIcon); +} + + + +void Cex1LoginDlg::OnBnClickedOk() +{ + // TODO: 在此添加控件通知处理程序代码 + UpdateData(TRUE); + //MessageBox(m_csName + _T(":") + m_csPwd); + if (m_csName == _T("test") && m_csPwd == _T("123")) + { + AfxMessageBox(_T("It's OK!")); + CDialogEx::OnOK(); + } + else + { + AfxMessageBox(_T("It's wrong!")); + } +} + + +void Cex1LoginDlg::OnEnChangePwd() +{ + // TODO: 如果该控件是 RICHEDIT 控件,它将不 + // 发送此通知,除非重写 CDialogEx::OnInitDialog() + // 函数并调用 CRichEditCtrl().SetEventMask(), + // 同时将 ENM_CHANGE 标志“或”运算到掩码中。 + + // TODO: 在此添加控件通知处理程序代码 + GetDlgItem(IDOK)->EnableWindow(TRUE); +} diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/ex1-LoginDlg.h" "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-LoginDlg.h" new file mode 100644 index 0000000..37aa0dc --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/ex1-LoginDlg.h" @@ -0,0 +1,165 @@ + +// ex1-LoginDlg.h: 头文件 +// + +#pragma once + + +// Cex1LoginDlg 对话框 +class Cex1LoginDlg : public CDialogEx +{ +// 构造 +public: + Cex1LoginDlg(CWnd* pParent = nullptr); // 标准构造函数 + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_EX1LOGIN_DIALOG }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + + +// 实现 +protected: + HICON m_hIcon; + + // 生成的消息映射函数 + virtual BOOL OnInitDialog(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + DECLARE_MESSAGE_MAP() +public: + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + // user name + CString m_csName; + // Password + // Password + CString m_csPwd; + afx_msg void OnBnClickedOk(); + afx_msg void OnStnClickedName(); + afx_msg void OnEnChangeEdit1(); + afx_msg void OnEnChangePwd(); +}; diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/ex1Login.aps" "b/cpp\350\257\276\350\256\276/ex1-Login/ex1Login.aps" new file mode 100644 index 0000000..bfa46c5 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/ex1-Login/ex1Login.aps" differ diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/ex1Login.rc" "b/cpp\350\257\276\350\256\276/ex1-Login/ex1Login.rc" new file mode 100644 index 0000000..fc1e649 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/ex1-Login/ex1Login.rc" differ diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/framework.h" "b/cpp\350\257\276\350\256\276/ex1-Login/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/pch.cpp" "b/cpp\350\257\276\350\256\276/ex1-Login/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/pch.h" "b/cpp\350\257\276\350\256\276/ex1-Login/pch.h" new file mode 100644 index 0000000..9660927 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/pch.h" @@ -0,0 +1,13 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" + +#endif //PCH_H diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/res/ex1-Login.ico" "b/cpp\350\257\276\350\256\276/ex1-Login/res/ex1-Login.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/cpp\350\257\276\350\256\276/ex1-Login/res/ex1-Login.ico" differ diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/res/ex1Login.rc2" "b/cpp\350\257\276\350\256\276/ex1-Login/res/ex1Login.rc2" new file mode 100644 index 0000000..8327a3a Binary files /dev/null and "b/cpp\350\257\276\350\256\276/ex1-Login/res/ex1Login.rc2" differ diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/resource.h" "b/cpp\350\257\276\350\256\276/ex1-Login/resource.h" new file mode 100644 index 0000000..76e9138 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/resource.h" @@ -0,0 +1,23 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ 生成的包含文件。 +// 供 ex1Login.rc 使用 +// +#define IDM_ABOUTBOX 0x0010 +#define IDD_ABOUTBOX 100 +#define IDS_ABOUTBOX 101 +#define IDD_EX1LOGIN_DIALOG 102 +#define IDR_MAINFRAME 128 +#define IDC_NAME 1000 +#define IDC_PWD 1001 +#define IDC_2 1003 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1004 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git "a/cpp\350\257\276\350\256\276/ex1-Login/targetver.h" "b/cpp\350\257\276\350\256\276/ex1-Login/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex1-Login/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.cpp" "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.cpp" new file mode 100644 index 0000000..2095acb --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.cpp" @@ -0,0 +1,107 @@ + +// ex2-Selector.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "ex2-Selector.h" +#include "ex2-SelectorDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cex2SelectorApp + +BEGIN_MESSAGE_MAP(Cex2SelectorApp, CWinApp) + ON_COMMAND(ID_HELP, &CWinApp::OnHelp) +END_MESSAGE_MAP() + + +// Cex2SelectorApp 构造 + +Cex2SelectorApp::Cex2SelectorApp() +{ + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + + +// 唯一的 Cex2SelectorApp 对象 + +Cex2SelectorApp theApp; + + +// Cex2SelectorApp 初始化 + +BOOL Cex2SelectorApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinApp::InitInstance(); + + + AfxEnableControlContainer(); + + // 创建 shell 管理器,以防对话框包含 + // 任何 shell 树视图控件或 shell 列表视图控件。 + CShellManager *pShellManager = new CShellManager; + + // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题 + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + + Cex2SelectorDlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: 在此放置处理何时用 + // “确定”来关闭对话框的代码 + } + else if (nResponse == IDCANCEL) + { + // TODO: 在此放置处理何时用 + // “取消”来关闭对话框的代码 + } + else if (nResponse == -1) + { + TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n"); + TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n"); + } + + // 删除上面创建的 shell 管理器。 + if (pShellManager != nullptr) + { + delete pShellManager; + } + +#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS) + ControlBarCleanUp(); +#endif + + // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, + // 而不是启动应用程序的消息泵。 + return FALSE; +} + diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.h" "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.h" new file mode 100644 index 0000000..35278cb --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.h" @@ -0,0 +1,32 @@ + +// ex2-Selector.h: PROJECT_NAME 应用程序的主头文件 +// + +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// Cex2SelectorApp: +// 有关此类的实现,请参阅 ex2-Selector.cpp +// + +class Cex2SelectorApp : public CWinApp +{ +public: + Cex2SelectorApp(); + +// 重写 +public: + virtual BOOL InitInstance(); + +// 实现 + + DECLARE_MESSAGE_MAP() +}; + +extern Cex2SelectorApp theApp; diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.sln" "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.sln" new file mode 100644 index 0000000..43e5b06 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ex2-Selector", "ex2-Selector.vcxproj", "{F95AB4CC-CF5F-4098-BB38-E08ADF4DFEEC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F95AB4CC-CF5F-4098-BB38-E08ADF4DFEEC}.Debug|x64.ActiveCfg = Debug|x64 + {F95AB4CC-CF5F-4098-BB38-E08ADF4DFEEC}.Debug|x64.Build.0 = Debug|x64 + {F95AB4CC-CF5F-4098-BB38-E08ADF4DFEEC}.Debug|x86.ActiveCfg = Debug|Win32 + {F95AB4CC-CF5F-4098-BB38-E08ADF4DFEEC}.Debug|x86.Build.0 = Debug|Win32 + {F95AB4CC-CF5F-4098-BB38-E08ADF4DFEEC}.Release|x64.ActiveCfg = Release|x64 + {F95AB4CC-CF5F-4098-BB38-E08ADF4DFEEC}.Release|x64.Build.0 = Release|x64 + {F95AB4CC-CF5F-4098-BB38-E08ADF4DFEEC}.Release|x86.ActiveCfg = Release|Win32 + {F95AB4CC-CF5F-4098-BB38-E08ADF4DFEEC}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8796C615-78F6-4926-9C47-721418C70039} + EndGlobalSection +EndGlobal diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.vcxproj" "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.vcxproj" new file mode 100644 index 0000000..7d03c30 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.vcxproj" @@ -0,0 +1,215 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {F95AB4CC-CF5F-4098-BB38-E08ADF4DFEEC} + MFCProj + ex2Selector + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.vcxproj.filters" "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.vcxproj.filters" new file mode 100644 index 0000000..0f382a1 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.vcxproj.filters" @@ -0,0 +1,63 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.vcxproj.user" "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.vcxproj.user" new file mode 100644 index 0000000..927e10f --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-Selector.vcxproj.user" @@ -0,0 +1,6 @@ + + + + ex2Selector.rc + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/ex2-SelectorDlg.cpp" "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-SelectorDlg.cpp" new file mode 100644 index 0000000..2577b48 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-SelectorDlg.cpp" @@ -0,0 +1,215 @@ + +// ex2-SelectorDlg.cpp: 实现文件 +// + +#include "pch.h" +#include "framework.h" +#include "ex2-Selector.h" +#include "ex2-SelectorDlg.h" +#include "afxdialogex.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + + +// Cex2SelectorDlg 对话框 + + + +Cex2SelectorDlg::Cex2SelectorDlg(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_EX2SELECTOR_DIALOG, pParent) + , m_nSelA(0) + , m_nSelB(0) + , m_bChkA(FALSE) + , m_bChkB(FALSE) +{ + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); +} + +void Cex2SelectorDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Radio(pDX, IDC_RADIO1, m_nSelA); + DDX_Radio(pDX, IDC_RADIO4, m_nSelB); + DDX_Check(pDX, IDC_CHECK1, m_bChkA); + DDX_Check(pDX, IDC_CHECK2, m_bChkB); +} + +BEGIN_MESSAGE_MAP(Cex2SelectorDlg, CDialogEx) + ON_WM_SYSCOMMAND() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDOK, &Cex2SelectorDlg::OnBnClickedOk) + ON_BN_CLICKED(IDC_CHECK1, &Cex2SelectorDlg::OnBnClickedCheck1) + ON_BN_CLICKED(IDC_CHECK2, &Cex2SelectorDlg::OnBnClickedCheck2) +END_MESSAGE_MAP() + + +// Cex2SelectorDlg 消息处理程序 + +BOOL Cex2SelectorDlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // 将“关于...”菜单项添加到系统菜单中。 + + // IDM_ABOUTBOX 必须在系统命令范围内。 + ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); + ASSERT(IDM_ABOUTBOX < 0xF000); + + CMenu* pSysMenu = GetSystemMenu(FALSE); + if (pSysMenu != nullptr) + { + BOOL bNameValid; + CString strAboutMenu; + bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); + ASSERT(bNameValid); + if (!strAboutMenu.IsEmpty()) + { + pSysMenu->AppendMenu(MF_SEPARATOR); + pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); + } + } + + // 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动 + // 执行此操作 + SetIcon(m_hIcon, TRUE); // 设置大图标 + SetIcon(m_hIcon, FALSE); // 设置小图标 + + // TODO: 在此添加额外的初始化代码 + m_bChkA = TRUE; + GetDlgItem(IDC_RADIO1)->EnableWindow(TRUE); + GetDlgItem(IDC_RADIO2)->EnableWindow(TRUE); + GetDlgItem(IDC_RADIO3)->EnableWindow(TRUE); + + m_bChkB = FALSE; + GetDlgItem(IDC_RADIO4)->EnableWindow(FALSE); + GetDlgItem(IDC_RADIO5)->EnableWindow(FALSE); + GetDlgItem(IDC_RADIO6)->EnableWindow(FALSE); + + m_nSelA = 0; + m_nSelB = 0; + UpdateData(FALSE); + return TRUE; // 除非将焦点设置到控件,否则返回 TRUE +} + +void Cex2SelectorDlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) + { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } + else + { + CDialogEx::OnSysCommand(nID, lParam); + } +} + +// 如果向对话框添加最小化按钮,则需要下面的代码 +// 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序, +// 这将由框架自动完成。 + +void Cex2SelectorDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // 用于绘制的设备上下文 + + SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); + + // 使图标在工作区矩形中居中 + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // 绘制图标 + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CDialogEx::OnPaint(); + } +} + +//当用户拖动最小化窗口时系统调用此函数取得光标 +//显示。 +HCURSOR Cex2SelectorDlg::OnQueryDragIcon() +{ + return static_cast(m_hIcon); +} + + + +void Cex2SelectorDlg::OnBnClickedOk() +{ + // TODO: 在此添加控件通知处理程序代码 + CString csGroupA[] = { _T("美国"),_T("日本") ,_T("韩国") }; + CString csGroupB[] = { _T("英国"),_T("巴西") ,_T("法国") }; + + UpdateData(TRUE); + CString csMsg; + if (m_bChkA == TRUE) + csMsg = csGroupA[m_nSelA] + _T("\n"); + if (m_bChkB == TRUE) + csMsg += csGroupB[m_nSelB]; + MessageBox(csMsg); + CDialogEx::OnOK(); +} + + +void Cex2SelectorDlg::OnBnClickedCheck1() +{ + // TODO: 在此添加控件通知处理程序代码 + UpdateData(TRUE); + GetDlgItem(IDC_RADIO1)->EnableWindow(m_bChkA); + GetDlgItem(IDC_RADIO2)->EnableWindow(m_bChkA); + GetDlgItem(IDC_RADIO3)->EnableWindow(m_bChkA); +} + + +void Cex2SelectorDlg::OnBnClickedCheck2() +{ + // TODO: 在此添加控件通知处理程序代码 + UpdateData(TRUE); + GetDlgItem(IDC_RADIO4)->EnableWindow(m_bChkB); + GetDlgItem(IDC_RADIO5)->EnableWindow(m_bChkB); + GetDlgItem(IDC_RADIO6)->EnableWindow(m_bChkB); +} diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/ex2-SelectorDlg.h" "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-SelectorDlg.h" new file mode 100644 index 0000000..d71d38c --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2-SelectorDlg.h" @@ -0,0 +1,42 @@ + +// ex2-SelectorDlg.h: 头文件 +// + +#pragma once + + +// Cex2SelectorDlg 对话框 +class Cex2SelectorDlg : public CDialogEx +{ +// 构造 +public: + Cex2SelectorDlg(CWnd* pParent = nullptr); // 标准构造函数 + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_EX2SELECTOR_DIALOG }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + + +// 实现 +protected: + HICON m_hIcon; + + // 生成的消息映射函数 + virtual BOOL OnInitDialog(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + DECLARE_MESSAGE_MAP() +public: + INT m_nSelA; + INT m_nSelB; + BOOL m_bChkA; + BOOL m_bChkB; + afx_msg void OnBnClickedOk(); + afx_msg void OnBnClickedCheck1(); + afx_msg void OnBnClickedCheck2(); +}; diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/ex2Selector.aps" "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2Selector.aps" new file mode 100644 index 0000000..7d9eae0 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2Selector.aps" differ diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/ex2Selector.rc" "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2Selector.rc" new file mode 100644 index 0000000..c505dbf Binary files /dev/null and "b/cpp\350\257\276\350\256\276/ex2-Selector/ex2Selector.rc" differ diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/framework.h" "b/cpp\350\257\276\350\256\276/ex2-Selector/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/pch.cpp" "b/cpp\350\257\276\350\256\276/ex2-Selector/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/pch.h" "b/cpp\350\257\276\350\256\276/ex2-Selector/pch.h" new file mode 100644 index 0000000..9660927 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/pch.h" @@ -0,0 +1,13 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" + +#endif //PCH_H diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/res/ex2-Selector.ico" "b/cpp\350\257\276\350\256\276/ex2-Selector/res/ex2-Selector.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/cpp\350\257\276\350\256\276/ex2-Selector/res/ex2-Selector.ico" differ diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/res/ex2Selector.rc2" "b/cpp\350\257\276\350\256\276/ex2-Selector/res/ex2Selector.rc2" new file mode 100644 index 0000000..17cd1b3 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/ex2-Selector/res/ex2Selector.rc2" differ diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/resource.h" "b/cpp\350\257\276\350\256\276/ex2-Selector/resource.h" new file mode 100644 index 0000000..111b5f3 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/resource.h" @@ -0,0 +1,28 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ 生成的包含文件。 +// 供 ex2Selector.rc 使用 +// +#define IDM_ABOUTBOX 0x0010 +#define IDD_ABOUTBOX 100 +#define IDS_ABOUTBOX 101 +#define IDD_EX2SELECTOR_DIALOG 102 +#define IDR_MAINFRAME 128 +#define IDC_RADIO1 1000 +#define IDC_RADIO2 1001 +#define IDC_RADIO3 1002 +#define IDC_RADIO4 1003 +#define IDC_RADIO5 1004 +#define IDC_RADIO6 1005 +#define IDC_CHECK1 1006 +#define IDC_CHECK2 1007 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1007 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git "a/cpp\350\257\276\350\256\276/ex2-Selector/targetver.h" "b/cpp\350\257\276\350\256\276/ex2-Selector/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex2-Selector/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.cpp" "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.cpp" new file mode 100644 index 0000000..6eb89f8 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.cpp" @@ -0,0 +1,107 @@ + +// ex3-Calculator.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "ex3-Calculator.h" +#include "ex3-CalculatorDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cex3CalculatorApp + +BEGIN_MESSAGE_MAP(Cex3CalculatorApp, CWinApp) + ON_COMMAND(ID_HELP, &CWinApp::OnHelp) +END_MESSAGE_MAP() + + +// Cex3CalculatorApp 构造 + +Cex3CalculatorApp::Cex3CalculatorApp() +{ + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + + +// 唯一的 Cex3CalculatorApp 对象 + +Cex3CalculatorApp theApp; + + +// Cex3CalculatorApp 初始化 + +BOOL Cex3CalculatorApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinApp::InitInstance(); + + + AfxEnableControlContainer(); + + // 创建 shell 管理器,以防对话框包含 + // 任何 shell 树视图控件或 shell 列表视图控件。 + CShellManager *pShellManager = new CShellManager; + + // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题 + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + + Cex3CalculatorDlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: 在此放置处理何时用 + // “确定”来关闭对话框的代码 + } + else if (nResponse == IDCANCEL) + { + // TODO: 在此放置处理何时用 + // “取消”来关闭对话框的代码 + } + else if (nResponse == -1) + { + TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n"); + TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n"); + } + + // 删除上面创建的 shell 管理器。 + if (pShellManager != nullptr) + { + delete pShellManager; + } + +#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS) + ControlBarCleanUp(); +#endif + + // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, + // 而不是启动应用程序的消息泵。 + return FALSE; +} + diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.h" "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.h" new file mode 100644 index 0000000..655ae3e --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.h" @@ -0,0 +1,32 @@ + +// ex3-Calculator.h: PROJECT_NAME 应用程序的主头文件 +// + +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// Cex3CalculatorApp: +// 有关此类的实现,请参阅 ex3-Calculator.cpp +// + +class Cex3CalculatorApp : public CWinApp +{ +public: + Cex3CalculatorApp(); + +// 重写 +public: + virtual BOOL InitInstance(); + +// 实现 + + DECLARE_MESSAGE_MAP() +}; + +extern Cex3CalculatorApp theApp; diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.sln" "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.sln" new file mode 100644 index 0000000..1662472 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32210.238 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ex3-Calculator", "ex3-Calculator.vcxproj", "{A9748399-89C9-416A-948E-FB0D17B3D0DF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A9748399-89C9-416A-948E-FB0D17B3D0DF}.Debug|x64.ActiveCfg = Debug|x64 + {A9748399-89C9-416A-948E-FB0D17B3D0DF}.Debug|x64.Build.0 = Debug|x64 + {A9748399-89C9-416A-948E-FB0D17B3D0DF}.Debug|x86.ActiveCfg = Debug|Win32 + {A9748399-89C9-416A-948E-FB0D17B3D0DF}.Debug|x86.Build.0 = Debug|Win32 + {A9748399-89C9-416A-948E-FB0D17B3D0DF}.Release|x64.ActiveCfg = Release|x64 + {A9748399-89C9-416A-948E-FB0D17B3D0DF}.Release|x64.Build.0 = Release|x64 + {A9748399-89C9-416A-948E-FB0D17B3D0DF}.Release|x86.ActiveCfg = Release|Win32 + {A9748399-89C9-416A-948E-FB0D17B3D0DF}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9E4120BC-CFBD-4E6E-9927-CBC1D7FC620F} + EndGlobalSection +EndGlobal diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.vcxproj" "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.vcxproj" new file mode 100644 index 0000000..657cdff --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.vcxproj" @@ -0,0 +1,215 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {A9748399-89C9-416A-948E-FB0D17B3D0DF} + MFCProj + ex3Calculator + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.vcxproj.filters" "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.vcxproj.filters" new file mode 100644 index 0000000..663f6a5 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.vcxproj.filters" @@ -0,0 +1,63 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.vcxproj.user" "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.vcxproj.user" new file mode 100644 index 0000000..9bc6c5b --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-Calculator.vcxproj.user" @@ -0,0 +1,6 @@ + + + + ex3Calculator.rc + + \ No newline at end of file diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-CalculatorDlg.cpp" "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-CalculatorDlg.cpp" new file mode 100644 index 0000000..93c8b1e --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-CalculatorDlg.cpp" @@ -0,0 +1,386 @@ + +// ex3-CalculatorDlg.cpp: 实现文件 +// + +#include "pch.h" +#include "framework.h" +#include "ex3-Calculator.h" +#include "ex3-CalculatorDlg.h" +#include "afxdialogex.h" +#include "cstring" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +const int OP_TYPE_ADD = 1; +const int OP_TYPE_SUB = 2; +const int OP_TYPE_MUL = 3; +const int OP_TYPE_DIV = 4; +const int OP_TYPE_NONE = 0; +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + + +// Cex3CalculatorDlg 对话框 + + + +Cex3CalculatorDlg::Cex3CalculatorDlg(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_EX3CALCULATOR_DIALOG, pParent) + , m_csRes(_T("")) +{ + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); +} + +void Cex3CalculatorDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Text(pDX, IDC_EDIT_RES, m_csRes); +} + +BEGIN_MESSAGE_MAP(Cex3CalculatorDlg, CDialogEx) + ON_WM_SYSCOMMAND() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDC_BUTTON1, &Cex3CalculatorDlg::OnBnClickedButton1) + ON_BN_CLICKED(IDC_BUTTON2, &Cex3CalculatorDlg::OnBnClickedButton2) + ON_BN_CLICKED(IDC_BUTTON3, &Cex3CalculatorDlg::OnBnClickedButton3) + ON_BN_CLICKED(IDC_BUTTON4, &Cex3CalculatorDlg::OnBnClickedButton4) + ON_BN_CLICKED(IDC_BUTTON5, &Cex3CalculatorDlg::OnBnClickedButton5) + ON_BN_CLICKED(IDC_BUTTON6, &Cex3CalculatorDlg::OnBnClickedButton6) + ON_BN_CLICKED(IDC_BUTTON7, &Cex3CalculatorDlg::OnBnClickedButton7) + ON_BN_CLICKED(IDC_BUTTON8, &Cex3CalculatorDlg::OnBnClickedButton8) + ON_BN_CLICKED(IDC_BUTTON9, &Cex3CalculatorDlg::OnBnClickedButton9) + ON_BN_CLICKED(IDC_BUTTON0, &Cex3CalculatorDlg::OnBnClickedButton0) + ON_BN_CLICKED(IDC_BUTTON_ADD, &Cex3CalculatorDlg::OnBnClickedButtonAdd) + ON_BN_CLICKED(IDC_BUTTON_SUB, &Cex3CalculatorDlg::OnBnClickedButtonSub) + ON_BN_CLICKED(IDC_BUTTON_MUL, &Cex3CalculatorDlg::OnBnClickedButtonMul) + ON_BN_CLICKED(IDC_BUTTON_DIV, &Cex3CalculatorDlg::OnBnClickedButtonDiv) + ON_BN_CLICKED(IDC_BUTTON_CALC, &Cex3CalculatorDlg::OnBnClickedButtonCalc) + ON_BN_CLICKED(IDC_BUTTON_DOT, &Cex3CalculatorDlg::OnBnClickedButtonDot) +END_MESSAGE_MAP() + + +// Cex3CalculatorDlg 消息处理程序 + +BOOL Cex3CalculatorDlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // 将“关于...”菜单项添加到系统菜单中。 + + // IDM_ABOUTBOX 必须在系统命令范围内。 + ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); + ASSERT(IDM_ABOUTBOX < 0xF000); + + CMenu* pSysMenu = GetSystemMenu(FALSE); + if (pSysMenu != nullptr) + { + BOOL bNameValid; + CString strAboutMenu; + bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); + ASSERT(bNameValid); + if (!strAboutMenu.IsEmpty()) + { + pSysMenu->AppendMenu(MF_SEPARATOR); + pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); + } + } + + // 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动 + // 执行此操作 + SetIcon(m_hIcon, TRUE); // 设置大图标 + SetIcon(m_hIcon, FALSE); // 设置小图标 + + // TODO: 在此添加额外的初始化代码 + m_nOpType = OP_TYPE_NONE; + m_bNew = true; + m_csRes = _T("0"); + GetDlgItem(IDC_BUTTON_CALC)->EnableWindow(FALSE); + UpdateData(FALSE); + return TRUE; // 除非将焦点设置到控件,否则返回 TRUE +} + +void Cex3CalculatorDlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) + { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } + else + { + CDialogEx::OnSysCommand(nID, lParam); + } +} + +// 如果向对话框添加最小化按钮,则需要下面的代码 +// 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序, +// 这将由框架自动完成。 + +void Cex3CalculatorDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // 用于绘制的设备上下文 + + SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); + + // 使图标在工作区矩形中居中 + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // 绘制图标 + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CDialogEx::OnPaint(); + } +} + +//当用户拖动最小化窗口时系统调用此函数取得光标 +//显示。 +HCURSOR Cex3CalculatorDlg::OnQueryDragIcon() +{ + return static_cast(m_hIcon); +} + + + +void Cex3CalculatorDlg::OnBnClickedButton1() +{ + // TODO: 在此添加控件通知处理程序代码 + PressDigit(1); +} + + +void Cex3CalculatorDlg::OnBnClickedButton2() +{ + // TODO: 在此添加控件通知处理程序代码 + PressDigit(2); +} + + +void Cex3CalculatorDlg::OnBnClickedButton3() +{ + // TODO: 在此添加控件通知处理程序代码 + PressDigit(3); +} + + +void Cex3CalculatorDlg::OnBnClickedButton4() +{ + // TODO: 在此添加控件通知处理程序代码 + PressDigit(4); +} + + +void Cex3CalculatorDlg::OnBnClickedButton5() +{ + // TODO: 在此添加控件通知处理程序代码 + PressDigit(5); +} + + +void Cex3CalculatorDlg::OnBnClickedButton6() +{ + // TODO: 在此添加控件通知处理程序代码 + PressDigit(6); +} + + +void Cex3CalculatorDlg::OnBnClickedButton7() +{ + // TODO: 在此添加控件通知处理程序代码 + PressDigit(7); +} + + +void Cex3CalculatorDlg::OnBnClickedButton8() +{ + // TODO: 在此添加控件通知处理程序代码 + PressDigit(8); +} + + +void Cex3CalculatorDlg::OnBnClickedButton9() +{ + // TODO: 在此添加控件通知处理程序代码 + PressDigit(9); +} + + +void Cex3CalculatorDlg::OnBnClickedButton0() +{ + // TODO: 在此添加控件通知处理程序代码 + PressDigit(0); +} + +void Cex3CalculatorDlg::OnBnClickedButtonDot() +{ + // TODO: 在此添加控件通知处理程序代码 + if (m_bNew) + { + m_bNew = false; + m_csRes = _T("0"); + } + else + UpdateData(TRUE); + + CString str; + str=_T("."); + m_csRes += str; + GetDlgItem(IDC_BUTTON_DOT)->EnableWindow(FALSE); + UpdateData(FALSE); +} + +void Cex3CalculatorDlg::PressDigit(int nDigit) +{ + if (m_bNew) + { + m_bNew = false; + m_csRes = _T("0"); + } + else + UpdateData(TRUE); + + CString str; + str.Format(_T("%d"), nDigit); + if (m_csRes == CString(_T("0"))) + m_csRes = _T(""); + m_csRes += str; + + UpdateData(FALSE); +} +void Cex3CalculatorDlg::PressOp(int nType) +{ + m_nOpType = nType; + m_csOpA = m_csRes; + m_csRes = _T("0"); + UpdateData(FALSE); + + GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON2)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON3)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON4)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON5)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON6)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON7)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON8)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON9)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON0)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON_DOT)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON_CALC)->EnableWindow(TRUE); + + GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON_SUB)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON_MUL)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON_DIV)->EnableWindow(FALSE); +} + +void Cex3CalculatorDlg::OnBnClickedButtonAdd() +{ + // TODO: 在此添加控件通知处理程序代码 + PressOp(OP_TYPE_ADD); +} + + +void Cex3CalculatorDlg::OnBnClickedButtonSub() +{ + // TODO: 在此添加控件通知处理程序代码 + PressOp(OP_TYPE_SUB); +} + + +void Cex3CalculatorDlg::OnBnClickedButtonMul() +{ + // TODO: 在此添加控件通知处理程序代码 + PressOp(OP_TYPE_MUL); +} + + +void Cex3CalculatorDlg::OnBnClickedButtonDiv() +{ + // TODO: 在此添加控件通知处理程序代码 + PressOp(OP_TYPE_DIV); +} + + +void Cex3CalculatorDlg::OnBnClickedButtonCalc() +{ + // TODO: 在此添加控件通知处理程序代码 + m_csOpB = m_csRes; + float nOpA = _tstof(m_csOpA); + float nOpB = _tstof(m_csOpB); + float nRes; + switch (m_nOpType) + { + case OP_TYPE_ADD: + nRes = nOpA + nOpB; + break; + case OP_TYPE_SUB: + nRes = nOpA - nOpB; + break; + case OP_TYPE_MUL: + nRes = nOpA * nOpB; + break; + case OP_TYPE_DIV: + nRes = nOpA / nOpB; + break; + } + m_csRes.Format(_T("%g"), nRes); + UpdateData(FALSE); + m_nOpType = OP_TYPE_NONE; + m_bNew = true; + GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON3)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON4)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON5)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON6)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON7)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON8)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON9)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON0)->EnableWindow(FALSE); + GetDlgItem(IDC_BUTTON_DOT)->EnableWindow(FALSE); + + GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON_SUB)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON_MUL)->EnableWindow(TRUE); + GetDlgItem(IDC_BUTTON_DIV)->EnableWindow(TRUE); +} diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-CalculatorDlg.h" "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-CalculatorDlg.h" new file mode 100644 index 0000000..7d5432e --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3-CalculatorDlg.h" @@ -0,0 +1,60 @@ + +// ex3-CalculatorDlg.h: 头文件 +// + +#pragma once + + +// Cex3CalculatorDlg 对话框 +class Cex3CalculatorDlg : public CDialogEx +{ +// 构造 +public: + Cex3CalculatorDlg(CWnd* pParent = nullptr); // 标准构造函数 + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_EX3CALCULATOR_DIALOG }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +public: + CString m_csOpA;//operator A + CString m_csOpB;//operator B + int m_nOpType;//type of operator + bool m_bNew; +public: + void PressDigit(int nDigit); + void PressOp(int nType); + +// 实现 +protected: + HICON m_hIcon; + + // 生成的消息映射函数 + virtual BOOL OnInitDialog(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedButton1(); + afx_msg void OnBnClickedButton2(); + afx_msg void OnBnClickedButton3(); + afx_msg void OnBnClickedButton4(); + afx_msg void OnBnClickedButton5(); + afx_msg void OnBnClickedButton6(); + afx_msg void OnBnClickedButton7(); + afx_msg void OnBnClickedButton8(); + afx_msg void OnBnClickedButton9(); + afx_msg void OnBnClickedButton0(); + afx_msg void OnBnClickedButtonAdd(); + afx_msg void OnBnClickedButtonSub(); + afx_msg void OnBnClickedButtonMul(); + afx_msg void OnBnClickedButtonDiv(); + afx_msg void OnBnClickedButtonCalc(); + afx_msg void OnBnClickedButtonDot(); + CString m_csRes; +}; diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/ex3Calculator.aps" "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3Calculator.aps" new file mode 100644 index 0000000..5e20b41 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3Calculator.aps" differ diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/ex3Calculator.rc" "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3Calculator.rc" new file mode 100644 index 0000000..5843c07 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/ex3-Calculator/ex3Calculator.rc" differ diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/framework.h" "b/cpp\350\257\276\350\256\276/ex3-Calculator/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/pch.cpp" "b/cpp\350\257\276\350\256\276/ex3-Calculator/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/pch.h" "b/cpp\350\257\276\350\256\276/ex3-Calculator/pch.h" new file mode 100644 index 0000000..9660927 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/pch.h" @@ -0,0 +1,13 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" + +#endif //PCH_H diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/res/ex3-Calculator.ico" "b/cpp\350\257\276\350\256\276/ex3-Calculator/res/ex3-Calculator.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/cpp\350\257\276\350\256\276/ex3-Calculator/res/ex3-Calculator.ico" differ diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/res/ex3Calculator.rc2" "b/cpp\350\257\276\350\256\276/ex3-Calculator/res/ex3Calculator.rc2" new file mode 100644 index 0000000..2269b88 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/ex3-Calculator/res/ex3Calculator.rc2" differ diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/resource.h" "b/cpp\350\257\276\350\256\276/ex3-Calculator/resource.h" new file mode 100644 index 0000000..15209c1 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/resource.h" @@ -0,0 +1,39 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ 生成的包含文件。 +// 供 ex3Calculator.rc 使用 +// +#define IDM_ABOUTBOX 0x0010 +#define IDD_ABOUTBOX 100 +#define IDS_ABOUTBOX 101 +#define IDD_EX3CALCULATOR_DIALOG 102 +#define IDR_MAINFRAME 128 +#define IDC_EDIT_RES 1001 +#define IDC_BUTTON1 1002 +#define IDC_BUTTON2 1003 +#define IDC_BUTTON3 1004 +#define IDC_BUTTON4 1005 +#define IDC_BUTTON5 1006 +#define IDC_BUTTON6 1007 +#define IDC_BUTTON7 1008 +#define IDC_BUTTON8 1009 +#define IDC_BUTTON9 1010 +#define IDC_BUTTON0 1011 +#define IDC_BUTTON_ADD 1012 +#define IDC_BUTTON_SUB 1013 +#define IDC_BUTTON_MUL 1014 +#define IDC_BUTTON_DIV 1015 +#define IDC_BUTTON_EQU 1016 +#define IDC_BUTTON_CALC 1016 +#define IDC_BUTTON10 1017 +#define IDC_BUTTON_DOT 1017 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1003 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git "a/cpp\350\257\276\350\256\276/ex3-Calculator/targetver.h" "b/cpp\350\257\276\350\256\276/ex3-Calculator/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/cpp\350\257\276\350\256\276/ex3-Calculator/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/cpp\350\257\276\350\256\276/quiz.png" "b/cpp\350\257\276\350\256\276/quiz.png" new file mode 100644 index 0000000..773de6b Binary files /dev/null and "b/cpp\350\257\276\350\256\276/quiz.png" differ diff --git "a/cpp\350\257\276\350\256\276/\345\217\202\350\200\203\346\250\241\346\235\277/\345\217\202\350\200\203\346\250\241\346\235\277-\347\224\250\346\210\267\351\234\200\346\261\202\345\210\206\346\236\220\346\212\245\345\221\212.doc" "b/cpp\350\257\276\350\256\276/\345\217\202\350\200\203\346\250\241\346\235\277/\345\217\202\350\200\203\346\250\241\346\235\277-\347\224\250\346\210\267\351\234\200\346\261\202\345\210\206\346\236\220\346\212\245\345\221\212.doc" new file mode 100644 index 0000000..2d49f79 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/\345\217\202\350\200\203\346\250\241\346\235\277/\345\217\202\350\200\203\346\250\241\346\235\277-\347\224\250\346\210\267\351\234\200\346\261\202\345\210\206\346\236\220\346\212\245\345\221\212.doc" differ diff --git "a/cpp\350\257\276\350\256\276/\345\217\202\350\200\203\346\250\241\346\235\277/\345\217\202\350\200\203\346\250\241\346\235\277-\347\274\226\347\240\201\351\230\266\346\256\265\346\226\207\346\241\243.docx" "b/cpp\350\257\276\350\256\276/\345\217\202\350\200\203\346\250\241\346\235\277/\345\217\202\350\200\203\346\250\241\346\235\277-\347\274\226\347\240\201\351\230\266\346\256\265\346\226\207\346\241\243.docx" new file mode 100644 index 0000000..edc77f5 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/\345\217\202\350\200\203\346\250\241\346\235\277/\345\217\202\350\200\203\346\250\241\346\235\277-\347\274\226\347\240\201\351\230\266\346\256\265\346\226\207\346\241\243.docx" differ diff --git "a/cpp\350\257\276\350\256\276/\345\217\202\350\200\203\346\250\241\346\235\277/\345\217\202\350\200\203\346\250\241\346\235\277-\350\275\257\344\273\266\346\246\202\350\246\201\350\256\276\350\256\241\346\250\241\346\235\277.doc" "b/cpp\350\257\276\350\256\276/\345\217\202\350\200\203\346\250\241\346\235\277/\345\217\202\350\200\203\346\250\241\346\235\277-\350\275\257\344\273\266\346\246\202\350\246\201\350\256\276\350\256\241\346\250\241\346\235\277.doc" new file mode 100644 index 0000000..ebd8176 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/\345\217\202\350\200\203\346\250\241\346\235\277/\345\217\202\350\200\203\346\250\241\346\235\277-\350\275\257\344\273\266\346\246\202\350\246\201\350\256\276\350\256\241\346\250\241\346\235\277.doc" differ diff --git "a/cpp\350\257\276\350\256\276/\345\217\202\350\200\203\346\250\241\346\235\277/\345\217\202\350\200\203\346\250\241\346\235\277-\350\275\257\344\273\266\350\257\246\347\273\206\350\256\276\350\256\241\350\257\264\346\230\216\344\271\246\346\250\241\346\235\277.doc" "b/cpp\350\257\276\350\256\276/\345\217\202\350\200\203\346\250\241\346\235\277/\345\217\202\350\200\203\346\250\241\346\235\277-\350\275\257\344\273\266\350\257\246\347\273\206\350\256\276\350\256\241\350\257\264\346\230\216\344\271\246\346\250\241\346\235\277.doc" new file mode 100644 index 0000000..065f015 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/\345\217\202\350\200\203\346\250\241\346\235\277/\345\217\202\350\200\203\346\250\241\346\235\277-\350\275\257\344\273\266\350\257\246\347\273\206\350\256\276\350\256\241\350\257\264\346\230\216\344\271\246\346\250\241\346\235\277.doc" differ diff --git "a/cpp\350\257\276\350\256\276/\346\212\245\345\221\212.pdf" "b/cpp\350\257\276\350\256\276/\346\212\245\345\221\212.pdf" new file mode 100644 index 0000000..b252c3e Binary files /dev/null and "b/cpp\350\257\276\350\256\276/\346\212\245\345\221\212.pdf" differ diff --git "a/cpp\350\257\276\350\256\276/\346\265\201\347\250\213\345\233\276.png" "b/cpp\350\257\276\350\256\276/\346\265\201\347\250\213\345\233\276.png" new file mode 100644 index 0000000..1b88ad8 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/\346\265\201\347\250\213\345\233\276.png" differ diff --git "a/cpp\350\257\276\350\256\276/\347\224\250\346\210\267\351\234\200\346\261\202\350\257\264\346\230\216\344\271\246.doc" "b/cpp\350\257\276\350\256\276/\347\224\250\346\210\267\351\234\200\346\261\202\350\257\264\346\230\216\344\271\246.doc" new file mode 100644 index 0000000..9695ab6 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/\347\224\250\346\210\267\351\234\200\346\261\202\350\257\264\346\230\216\344\271\246.doc" differ diff --git "a/cpp\350\257\276\350\256\276/\350\257\276\347\250\213\346\212\245\345\221\212.pdf" "b/cpp\350\257\276\350\256\276/\350\257\276\347\250\213\346\212\245\345\221\212.pdf" new file mode 100644 index 0000000..80ec39b Binary files /dev/null and "b/cpp\350\257\276\350\256\276/\350\257\276\347\250\213\346\212\245\345\221\212.pdf" differ diff --git "a/cpp\350\257\276\350\256\276/\350\257\276\350\256\276\350\277\233\345\272\24601-13.docx" "b/cpp\350\257\276\350\256\276/\350\257\276\350\256\276\350\277\233\345\272\24601-13.docx" new file mode 100644 index 0000000..9aa0d54 Binary files /dev/null and "b/cpp\350\257\276\350\256\276/\350\257\276\350\256\276\350\277\233\345\272\24601-13.docx" differ diff --git "a/\345\210\266\351\200\240\346\212\200\346\234\257\345\237\272\347\241\200\345\256\236\344\271\240B\343\200\201C\345\256\236\344\271\240\346\212\245\345\221\2122017\347\211\210\345\217\202\350\200\203\347\255\224\346\241\210.pdf" "b/\345\210\266\351\200\240\346\212\200\346\234\257\345\237\272\347\241\200\345\256\236\344\271\240B\343\200\201C\345\256\236\344\271\240\346\212\245\345\221\2122017\347\211\210\345\217\202\350\200\203\347\255\224\346\241\210.pdf" new file mode 100644 index 0000000..5e042ee Binary files /dev/null and "b/\345\210\266\351\200\240\346\212\200\346\234\257\345\237\272\347\241\200\345\256\236\344\271\240B\343\200\201C\345\256\236\344\271\240\346\212\245\345\221\2122017\347\211\210\345\217\202\350\200\203\347\255\224\346\241\210.pdf" differ diff --git "a/\345\244\247\345\255\246\347\211\251\347\220\206/\345\212\233\345\255\246\344\275\234\344\270\232.pdf" "b/\345\244\247\345\255\246\347\211\251\347\220\206/\345\212\233\345\255\246\344\275\234\344\270\232.pdf" new file mode 100644 index 0000000..e0d056d Binary files /dev/null and "b/\345\244\247\345\255\246\347\211\251\347\220\206/\345\212\233\345\255\246\344\275\234\344\270\232.pdf" differ diff --git "a/\345\244\247\345\255\246\347\211\251\347\220\206/\347\224\265\347\243\201\344\275\234\344\270\232.pdf" "b/\345\244\247\345\255\246\347\211\251\347\220\206/\347\224\265\347\243\201\344\275\234\344\270\232.pdf" new file mode 100644 index 0000000..e5f6dac Binary files /dev/null and "b/\345\244\247\345\255\246\347\211\251\347\220\206/\347\224\265\347\243\201\344\275\234\344\270\232.pdf" differ diff --git "a/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex1.c" "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex1.c" new file mode 100644 index 0000000..d947473 --- /dev/null +++ "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex1.c" @@ -0,0 +1,42 @@ +#include "stm32f10x.h" +void LED0_Config(){ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); + GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8; + GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz; + GPIO_Init(GPIOA, &GPIO_InitStructure); +} +void LED0_On(){ + GPIO_ResetBits(GPIOA, GPIO_Pin_8); +} +void LED0_Off(){ + GPIO_SetBits(GPIOA, GPIO_Pin_8); +} +void KEY0_Config(){ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); + GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU; + GPIO_InitStructure.GPIO_Pin=GPIO_Pin_5; + GPIO_Init(GPIOC, &GPIO_InitStructure); +} +unsigned int Key0_Read(){ + if(!GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_5)) + return 1; + else + return 0; +} +int main(){ + unsigned int key_no=0; + LED0_Config(); + KEY0_Config(); + LED0_Off(); + while(1) + { + key_no=Key0_Read(); + if(key_no) + LED0_On(); + else + LED0_Off(); + } +} diff --git "a/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex1p.c" "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex1p.c" new file mode 100644 index 0000000..5d5c18f --- /dev/null +++ "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex1p.c" @@ -0,0 +1,65 @@ +#include "stm32f10x.h" +void LED0_Config(){ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); + GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8; + GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz; + GPIO_Init(GPIOA, &GPIO_InitStructure); +} +void LED0_On(){ + GPIO_ResetBits(GPIOA, GPIO_Pin_8); +} +void LED0_Off(){ + GPIO_SetBits(GPIOA, GPIO_Pin_8); +} +void KEY0_Config(){ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); + GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU; + GPIO_InitStructure.GPIO_Pin=GPIO_Pin_5; + GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz; + GPIO_Init(GPIOC, &GPIO_InitStructure); +} +unsigned int Key0_Read(){ + if(!GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_5)) + return 1; + else + return 0; +} +int main(){ + //unsigned int key0=0; + int flag=0; + LED0_Config(); + KEY0_Config(); + LED0_Off(); + while (1) + { + if(Key0_Read()) + { + while(Key0_Read()); + while(!Key0_Read()); + if(flag == 0) + { + while(1) + { + LED0_On(); + if(!Key0_Read()) + break; + } + flag=1; + } + else + { + while(1) + { + LED0_Off(); + if(!Key0_Read()) + break; + } + flag=0; + } + } + } +} + diff --git "a/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex2.c" "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex2.c" new file mode 100644 index 0000000..1745be9 --- /dev/null +++ "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex2.c" @@ -0,0 +1,59 @@ +#include "stm32f10x.h" +#include +#define ITM_Port8(n) (*((volatile unsigned char*)(0xE0000000+4*n))) +#define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n))) +#define ITM_Port32(n) (*((volatile unsigned long*)(0xE0000000+4*n))) +#define DEMCR (*((volatile unsigned long*)(0xE000EDFC))) +#define TRCENA 0x01000000 +struct __FILE{ + int handle; +}; +FILE __stdout; +FILE __stdin; +int fputc(int ch, FILE *f){ + if(DEMCR & TRCENA) + { + while(ITM_Port32(0)==0); + ITM_Port8(0)=ch; + } + return(ch); +} +unsigned int CountOfToggle=0; +void LED0_Config(){ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); + GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8; + GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz; + GPIO_Init(GPIOA, &GPIO_InitStructure); +} +void LED0_On(){ + GPIO_ResetBits(GPIOA, GPIO_Pin_8); +} +void LED0_Off(){ + GPIO_SetBits(GPIOA, GPIO_Pin_8); +} +void TIM2_Delay500MS(){ + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); + TIM_TimeBaseStructure.TIM_Prescaler=36000-1; + TIM_TimeBaseStructure.TIM_Period=6160-1; + TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up; + TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure); + TIM_ClearFlag(TIM2, TIM_FLAG_Update); + TIM_Cmd(TIM2, ENABLE); + while(TIM_GetFlagStatus(TIM2, TIM_FLAG_Update)==RESET); +} +int main (void){ + LED0_Config(); + while(1) + { + LED0_On(); + TIM2_Delay500MS(); + LED0_Off(); + TIM2_Delay500MS(); + CountOfToggle++; + printf("The Count of Toggle is %d\n", CountOfToggle); + } +} + diff --git "a/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex2p.c" "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex2p.c" new file mode 100644 index 0000000..955b2d6 --- /dev/null +++ "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex2p.c" @@ -0,0 +1,38 @@ +#include "stm32f10x.h" +void delay(int n){ + int i; + for (i = 0; i < n; i++); +} +void LED0_Config(){ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE); + GPIO_InitStructure.GPIO_Pin=GPIO_Pin_2; + GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz; + GPIO_Init(GPIOD, &GPIO_InitStructure); +} +void LED0_On(){ + GPIO_ResetBits(GPIOD, GPIO_Pin_2); +} +void LED0_Off(){ + GPIO_SetBits(GPIOD, GPIO_Pin_2); +} +int main (void){ + LED0_Config(); + while(1) + { + int i; + for (i = 0; i < 2500; i++) { + LED0_Off(); + delay(i+500); + LED0_On(); + delay(2500 - i-500); + } + for (i = 0; i < 2500; i++) { + LED0_Off(); + delay(2500 - i-500); + LED0_On(); + delay(i+500); + } + } +} diff --git "a/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex3.c" "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex3.c" new file mode 100644 index 0000000..f399367 --- /dev/null +++ "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex3.c" @@ -0,0 +1,44 @@ +#include "stm32f10x.h" +void TIM1_PWMInit(){ + GPIO_InitTypeDef GPIO_InitStructure; + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + TIM_OCInitTypeDef TimOCInitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE) ; + GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8; + GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP; + GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; + GPIO_Init(GPIOA, &GPIO_InitStructure); + RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); + TIM_TimeBaseStructure.TIM_Prescaler= 72-1; + TIM_TimeBaseStructure.TIM_Period= 50-1; + TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up; + TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure); + TimOCInitStructure.TIM_OCMode=TIM_OCMode_PWM1; + TimOCInitStructure.TIM_OCPolarity=TIM_OCPolarity_High; + TimOCInitStructure.TIM_Pulse= 47; + TimOCInitStructure.TIM_OutputState=TIM_OutputState_Enable; + TIM_OC1Init(TIM1, &TimOCInitStructure); + TIM_OC1PreloadConfig(TIM1, TIM_OCPreload_Enable); + TIM_ARRPreloadConfig(TIM1, ENABLE); + TIM_Cmd(TIM1, ENABLE); + TIM_CtrlPWMOutputs(TIM1, ENABLE); +} +void LED1_Config(){ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE); + GPIO_InitStructure.GPIO_Pin=GPIO_Pin_2; + GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz; + GPIO_Init(GPIOD, &GPIO_InitStructure); +} +void LED1_On(){ + GPIO_ResetBits(GPIOD, GPIO_Pin_2); +} +int main(void){ + TIM1_PWMInit(); + LED1_Config(); + while(1) + { + LED1_On(); + } +} diff --git "a/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex3p.c" "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex3p.c" new file mode 100644 index 0000000..d675ade --- /dev/null +++ "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/ex3p.c" @@ -0,0 +1,143 @@ +#include "stm32f10x.h" +void delay(long n){ + long i; + for (i = 0; i < n; i++); +} +void LED0_Config(){ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); + GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8; + GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz; + GPIO_Init(GPIOA, &GPIO_InitStructure); +} +void LED0_On(){ + GPIO_ResetBits(GPIOA, GPIO_Pin_8); +} +void LED0_Off(){ + GPIO_SetBits(GPIOA, GPIO_Pin_8); +} +void KEY0_Config(){ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); + GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU; + GPIO_InitStructure.GPIO_Pin=GPIO_Pin_5; + GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz; + GPIO_Init(GPIOC, &GPIO_InitStructure); +} +unsigned int Key0_Read(){ + if(!GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_5)) + return 1; + else + return 0; +} +void KEY1_Config(){ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); + GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU; + GPIO_InitStructure.GPIO_Pin=GPIO_Pin_15; + GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz; + GPIO_Init(GPIOA, &GPIO_InitStructure); +} +unsigned int Key1_Read(){ + if(!GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_15)) + return 1; + else + return 0; +} +void LED1_Config(){ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE); + GPIO_InitStructure.GPIO_Pin=GPIO_Pin_2; + GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz; + GPIO_Init(GPIOD, &GPIO_InitStructure); +} +void LED1_On(){ + GPIO_ResetBits(GPIOD, GPIO_Pin_2); +} +void LED1_Off(){ + GPIO_SetBits(GPIOD, GPIO_Pin_2); +} +int main(){ + unsigned int key0, key1; + long i=0; + LED0_Config(); + LED1_Config(); + KEY0_Config(); + KEY1_Config(); + LED0_Off(); + LED1_Off(); + key0=Key0_Read(); + i=0; + while(1) + { + if(Key0_Read()==1) + { + LED1_Off(); + for(i; i<3000; i++) + { + LED0_On(); + delay(i); + LED0_Off(); + delay(3000 - i); + key0=Key0_Read(); + if(Key0_Read()==0) + break; + } + while(1) + { + LED0_On(); + delay(i); + LED0_Off(); + delay(3000 - i); + if(Key0_Read()==0) + break; + } + while(Key0_Read()==0) + { + LED0_On(); + delay(i); + LED0_Off(); + delay(3000 - i); + if(Key1_Read()==1) + break; + } + } + + if(Key1_Read()==1) + { + + for(i; i>=0; i--) + { + + LED0_On(); + delay(i); + LED0_Off(); + delay(3000 - i); + key1=Key1_Read(); + if(Key1_Read()==0) + break; + } + while(1) + { + LED0_On(); + delay(i); + LED0_Off(); + delay(3000 - i); + if(Key1_Read()==0) + break; + } + while(Key1_Read()==0) + { + LED0_On(); + delay(i); + LED0_Off(); + delay(3000 - i); + if(Key0_Read()==1) + break; + } + } + } +} + diff --git "a/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/\345\255\246\344\271\240\351\200\232\344\275\234\344\270\232.pdf" "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/\345\255\246\344\271\240\351\200\232\344\275\234\344\270\232.pdf" new file mode 100644 index 0000000..d6a48d4 Binary files /dev/null and "b/\345\265\214\345\205\245\345\274\217\347\263\273\347\273\237\345\257\274\350\256\272/\345\255\246\344\271\240\351\200\232\344\275\234\344\270\232.pdf" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/2020-2021\357\274\2101\357\274\211\346\223\215\344\275\234\347\263\273\347\273\237\346\234\237\347\273\210\350\257\225\345\215\267-A\350\257\204\345\210\206\346\240\207\345\207\206.pdf" "b/\346\223\215\344\275\234\347\263\273\347\273\237/2020-2021\357\274\2101\357\274\211\346\223\215\344\275\234\347\263\273\347\273\237\346\234\237\347\273\210\350\257\225\345\215\267-A\350\257\204\345\210\206\346\240\207\345\207\206.pdf" new file mode 100644 index 0000000..a9381a4 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/2020-2021\357\274\2101\357\274\211\346\223\215\344\275\234\347\263\273\347\273\237\346\234\237\347\273\210\350\257\225\345\215\267-A\350\257\204\345\210\206\346\240\207\345\207\206.pdf" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/2020-2021\357\274\2101\357\274\211\346\223\215\344\275\234\347\263\273\347\273\237\346\234\237\347\273\210\350\257\225\345\215\267-B\350\257\204\345\210\206\346\240\207\345\207\206.pdf" "b/\346\223\215\344\275\234\347\263\273\347\273\237/2020-2021\357\274\2101\357\274\211\346\223\215\344\275\234\347\263\273\347\273\237\346\234\237\347\273\210\350\257\225\345\215\267-B\350\257\204\345\210\206\346\240\207\345\207\206.pdf" new file mode 100644 index 0000000..79c8202 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/2020-2021\357\274\2101\357\274\211\346\223\215\344\275\234\347\263\273\347\273\237\346\234\237\347\273\210\350\257\225\345\215\267-B\350\257\204\345\210\206\346\240\207\345\207\206.pdf" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/OS-\350\257\276\345\240\202\346\265\213\351\252\214.pdf" "b/\346\223\215\344\275\234\347\263\273\347\273\237/OS-\350\257\276\345\240\202\346\265\213\351\252\214.pdf" new file mode 100644 index 0000000..745f6ee Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/OS-\350\257\276\345\240\202\346\265\213\351\252\214.pdf" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\345\256\213\350\200\201\345\270\210-\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\351\242\230.pdf" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\345\256\213\350\200\201\345\270\210-\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\351\242\230.pdf" new file mode 100644 index 0000000..a7f8b61 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\345\256\213\350\200\201\345\270\210-\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\351\242\230.pdf" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\216\250\350\215\220\350\257\276\347\250\213\350\247\206\351\242\221.txt" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\216\250\350\215\220\350\257\276\347\250\213\350\247\206\351\242\221.txt" new file mode 100644 index 0000000..2b75939 --- /dev/null +++ "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\216\250\350\215\220\350\257\276\347\250\213\350\247\206\351\242\221.txt" @@ -0,0 +1 @@ +https://www.bilibili.com/video/BV18741137LS?p=67 \ No newline at end of file diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (1).jpeg" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (1).jpeg" new file mode 100644 index 0000000..3f91188 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (1).jpeg" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (1).png" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (1).png" new file mode 100644 index 0000000..8b6981e Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (1).png" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (2).jpeg" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (2).jpeg" new file mode 100644 index 0000000..90fe126 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (2).jpeg" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (2).png" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (2).png" new file mode 100644 index 0000000..1eae63d Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (2).png" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (3).png" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (3).png" new file mode 100644 index 0000000..94a41a0 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (3).png" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (4).png" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (4).png" new file mode 100644 index 0000000..459ab23 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (4).png" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (5).png" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (5).png" new file mode 100644 index 0000000..3e6d6d9 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (5).png" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (6).png" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (6).png" new file mode 100644 index 0000000..42e0936 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\346\233\264\346\255\243\344\270\216\350\241\245\345\205\205 (6).png" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\350\223\235\345\244\232\345\244\232-\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\351\242\230\357\274\210\347\256\200\346\230\223\347\211\210\357\274\211.pdf" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\350\223\235\345\244\232\345\244\232-\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\351\242\230\357\274\210\347\256\200\346\230\223\347\211\210\357\274\211.pdf" new file mode 100644 index 0000000..a2a0321 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\357\274\210ldd\357\274\211/\350\223\235\345\244\232\345\244\232-\346\223\215\344\275\234\347\263\273\347\273\237\345\244\215\344\271\240\351\242\230\357\274\210\347\256\200\346\230\223\347\211\210\357\274\211.pdf" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2141.pdf" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2141.pdf" new file mode 100644 index 0000000..72a4229 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2141.pdf" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2143.pdf" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2143.pdf" new file mode 100644 index 0000000..f26c830 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2143.pdf" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2144.pdf" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2144.pdf" new file mode 100644 index 0000000..f53c6a8 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2144.pdf" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2145.pdf" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2145.pdf" new file mode 100644 index 0000000..22a8d7d Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2145.pdf" differ diff --git "a/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2146.pdf" "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2146.pdf" new file mode 100644 index 0000000..187f5e9 Binary files /dev/null and "b/\346\223\215\344\275\234\347\263\273\347\273\237/\346\223\215\344\275\234\347\263\273\347\273\237\345\256\236\351\252\2146.pdf" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\200--RSA\345\212\240\345\257\206\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/my_RSAoutput.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\200--RSA\345\212\240\345\257\206\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/my_RSAoutput.m" new file mode 100644 index 0000000..73dff7f --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\200--RSA\345\212\240\345\257\206\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/my_RSAoutput.m" @@ -0,0 +1,15 @@ +%%RSA㷨 +function my_RSAoutput(key1) +disp('ַ£'); +disp(key1); +length_key1=length(key1);%ַ +key=[];%ڷ÷ָ +m=1; +j=1; +for i=1:j:length_key1%ָģֳɵַ + key(m)=abs(key1(i));%ĵĸASCIIʮ + m=m+1; +end +[p,q,n,Q,e,d]=rsa_pq(); +rsa1=rsa_encrypt(key,e,n); +end diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\200--RSA\345\212\240\345\257\206\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/rsa_encrypt.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\200--RSA\345\212\240\345\257\206\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/rsa_encrypt.m" new file mode 100644 index 0000000..c088f13 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\200--RSA\345\212\240\345\257\206\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/rsa_encrypt.m" @@ -0,0 +1,26 @@ +%RSA㷨,key1-->key2 +function rsa1=rsa_encrypt(key1,e,n) +length_key=length(key1); +bin_e=dec2bin(e); +length_e=length(bin_e); +for j=1:1:length_key% + x=0; + c=1; + for i=1:1:length_e + x=2*x; + c=mod(c*c,n);%ⲿΪԶ + if bin_e(i)=='1' + x=x+1; + c=mod(c*key1(j),n);%RSA㷨 + end + end + key2(j)=c; %modcյֵkey2 +end +disp('˵RSA㷨:'); +disp('Ϊ'); +disp(key1); +disp('Ϊ'); +disp(key2); +rsa1=key2; + + diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\200--RSA\345\212\240\345\257\206\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/rsa_pq.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\200--RSA\345\212\240\345\257\206\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/rsa_pq.m" new file mode 100644 index 0000000..96ea9a1 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\200--RSA\345\212\240\345\257\206\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/rsa_pq.m" @@ -0,0 +1,42 @@ +%RSA㷨p q n Q e d +%1.ѡĴp,q +%2.㹫Կ˽ԿĹģn=p*q +%3.ģnŷQ=(p-1)*(q-1)ѡһeʹ1=0 && max(chunk(:))<=1); + % If the chunk is an RGB image, test the whole image + if y + y = (min(x(:))>=0 && max(x(:))<=1); + end + end +end \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/key.bmp" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/key.bmp" new file mode 100644 index 0000000..8ebefc2 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/key.bmp" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lena.bmp" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lena.bmp" new file mode 100644 index 0000000..69d0f4a Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lena.bmp" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lena3.gif" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lena3.gif" new file mode 100644 index 0000000..6c4aebb Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lena3.gif" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lsb_embed.asv" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lsb_embed.asv" new file mode 100644 index 0000000..f0b10f5 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lsb_embed.asv" @@ -0,0 +1,76 @@ +%Name: Chris Shoemaker +%Course: EER-280 - Digital Watermarking +%Project: Least Significant Bit Substitution +% Watermark Embeding + +clear all; + +% save start time +start_time=cputime; + +% read in the cover object +file_name='lena.bmp'; +[cover_object,map]=imread(file_name); + +% read in the message image +file_name='key.bmp'; +[message,map1]=imread(file_name); +message1=message; + +% convert to double for normalization, then back again +message=double(message); +message=fix(message./2); +message=uint8(message); + +% determine size of cover object +Mc=size(cover_object,1); %Height +Nc=size(cover_object,2); %Width + +% determine size of message object +Mm=size(message,1); %Height +Nm=size(message,2); %Width + +% title the message object out to cover object size to generate watermark +for ii = 1:Mc + for jj = 1:Nc + watermark(ii,jj)=message(mod(ii,Mm)+1,mod(jj,Nm)+1); + end +end + +% now we set the lsb of cover_object(ii,jj) to the value of watermark(ii,jj) +watermarked_image=cover_object; +for ii = 1:Mc + for jj = 1:Nc + watermarked_image(ii,jj)=bitset(watermarked_image(ii,jj),1,watermark(ii,jj)); + end +end + +% write the watermarked image out to a file +imwrite(watermarked_image,'lsb_watermarked.bmp','bmp'); + +% display processing time +elapsed_time=cputime-start_time; + +% calculate the PSNR +psnr=psnr(cover_object,watermarked_image,Mc,Nc); + +% display watermarked image +figure(1) +imshow(watermarked_image,[]) +title('Watermarked Image') +figure(2) +imshow(cover_object,[]) +title('original image') +for ii = 1:Mc + for jj = 1:Nc + watermark1(ii,jj)=message1(mod(ii,Mm)+1,mod(jj,Nm)+1); + end +end +%watermark1=watermark1*256; +%message1=message1*256; +figure(3) +imshow(watermark1,[]) +title('the watermark') +figure(4) +imshow(message1,[]) +title('the watermark') \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lsb_embed.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lsb_embed.m" new file mode 100644 index 0000000..7efc1aa --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lsb_embed.m" @@ -0,0 +1,77 @@ +%Name: Chris Shoemaker +%Course: EER-280 - Digital Watermarking +%Project: Least Significant Bit Substitution +% Watermark Embeding + +clear all; +clc; +% save start time +start_time=cputime; + +% read in the cover object +file_name='lena.bmp'; +[cover_object,map]=imread(file_name); + +% read in the message image +file_name='key.bmp'; +[message,map1]=imread(file_name); +message1=message; + +% convert to double for normalization, then back again +message=double(message); +message=fix(message./2); +message=uint8(message); + +% determine size of cover object +Mc=size(cover_object,1); %Height +Nc=size(cover_object,2); %Width + +% determine size of message object +Mm=size(message,1); %Height +Nm=size(message,2); %Width + +% title the message object out to cover object size to generate watermark +for ii = 1:Mc + for jj = 1:Nc + watermark(ii,jj)=message(mod(ii,Mm)+1,mod(jj,Nm)+1); + end +end + +% now we set the lsb of cover_object(ii,jj) to the value of watermark(ii,jj) +watermarked_image=cover_object; +for ii = 1:Mc + for jj = 1:Nc + watermarked_image(ii,jj)=bitset(watermarked_image(ii,jj),1,watermark(ii,jj)); + end +end + +% write the watermarked image out to a file +imwrite(watermarked_image,'lsb_watermarked.bmp','bmp'); + +% display processing time +elapsed_time=cputime-start_time; + +% calculate the PSNR +psnr=PSNR(cover_object,watermarked_image); +disp('PSNR='); +disp(psnr); +% display watermarked image +figure(1) +imshow(watermarked_image,[]) +title('Watermarked Image') +figure(2) +imshow(cover_object,[]) +title('original image') +for ii = 1:Mc + for jj = 1:Nc + watermark1(ii,jj)=message1(mod(ii,Mm)+1,mod(jj,Nm)+1); + end +end +%watermark1=watermark1*256; +%message1=message1*256; +figure(3) +imshow(watermark1,[]) +title('the watermark embedded') +figure(4) +imshow(message1,[]) +title('the original watermark') \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lsb_recover.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lsb_recover.m" new file mode 100644 index 0000000..3fd0a39 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lsb_recover.m" @@ -0,0 +1,40 @@ +%Name: Chris Shoemaker +%Course: EER-280 - Digital Watermarking +%Project: Least Significant Bit Substitution +% Watermark Recovery + +clear all; + +% save start time +start_time=cputime; + +% read in watermarked image +file_name='lsb_watermarked.bmp'; +%file_name='_lena_std_bw.bmp'; +watermarked_image=imread(file_name); + +% determine size of watermarked image +Mw=size(watermarked_image,1); %Height +Nw=size(watermarked_image,2); %Width + +% use lsb of watermarked image to recover watermark +for ii = 1:Mw + for jj = 1:Nw + watermark(ii,jj)=bitget(watermarked_image(ii,jj),1); + end +end + +% scale the recovered watermark +watermark=2*double(watermark); + +% display processing time +elapsed_time=cputime-start_time, + +% read in original watermark +%file_name='_copyright_large.bmp'; +%orig_watermark=imread(file_name); + +% scale and display recovered watermark +figure(2) +imshow(watermark,[]) +title('Recovered Watermark') \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lsb_watermarked.bmp" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lsb_watermarked.bmp" new file mode 100644 index 0000000..0b5c007 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/lsb_watermarked.bmp" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/test.jpg" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/test.jpg" new file mode 100644 index 0000000..2a1bd71 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/LSB/test.jpg" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/Watermark.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/Watermark.m" new file mode 100644 index 0000000..fc290c2 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/Watermark.m" @@ -0,0 +1,13 @@ +str = 'Li Jia xing will go home tommorrow'; +length = size(str, 2); +a=18; +b = dec2bin(a); +format = ['%0' num2str(length) 's']; +a_bin = sprintf(format, b); +for i=1:length + if a_bin(1,i) == '0' + text(0.2+0.05*i, 0.2, str(1,i), 'color','k','FontSize',5); + else + text(0.2+0.05*i, 0.2, str(1,i), 'color','r','FontSize',5); + end +end diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/watermark_c.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/watermark_c.m" new file mode 100644 index 0000000..964f3c5 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/\345\256\236\351\252\214\344\273\243\347\240\201matlab/watermark_c.m" @@ -0,0 +1,20 @@ +function watermark_c(str,w) +%ʵҪ'The meeting will be held at 9 o''clock'; +%s=sizeA%һssĵһԪǾڶԪǾ +%sizeһn12Ϊnֵ sizeؾ +%r=size(A,1)䷵صǾA c=size(A,2) ䷵صǾA +b = dec2bin(w); +%Ϊʹˮӡijıijͬformat'%08s',8λ,08λ0 +format = ['%0' num2str(size(str, 2)) 's']; +%bijתformat'%0?s'?Ӧij(ıĴСǰ油0) +a_bin = sprintf(format, b); +fprintf('ǶıΪ') +for i=1:size(str, 2) + if a_bin(1,i) == '0'%0עһҪΪ1 + cprintf('Black',str(1,i)); + else + cprintf('-Red',str(1,i)); + end +end +end + diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211.pdf" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211.pdf" new file mode 100644 index 0000000..4ef9682 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211--\346\226\207\346\234\254\346\260\264\345\215\260\347\256\227\346\263\225/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\270\211.pdf" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/matlab\345\270\270\347\224\250\345\233\276\345\203\217\345\244\204\347\220\206\345\207\275\346\225\260.pdf" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/matlab\345\270\270\347\224\250\345\233\276\345\203\217\345\244\204\347\220\206\345\207\275\346\225\260.pdf" new file mode 100644 index 0000000..3cbc948 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/matlab\345\270\270\347\224\250\345\233\276\345\203\217\345\244\204\347\220\206\345\207\275\346\225\260.pdf" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/CRW_4901_JFRtamp25.jpg" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/CRW_4901_JFRtamp25.jpg" new file mode 100644 index 0000000..a90a9ff Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/CRW_4901_JFRtamp25.jpg" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/DSCN41tamp27.jpg" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/DSCN41tamp27.jpg" new file mode 100644 index 0000000..77e542c Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/DSCN41tamp27.jpg" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/DSC_0812tamp25.jpg" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/DSC_0812tamp25.jpg" new file mode 100644 index 0000000..91d46c4 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/DSC_0812tamp25.jpg" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/DSC_1568tamp37.jpg" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/DSC_1568tamp37.jpg" new file mode 100644 index 0000000..a55c4b6 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/DSC_1568tamp37.jpg" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/QQ\346\210\252\345\233\27620160221171821.png" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/QQ\346\210\252\345\233\27620160221171821.png" new file mode 100644 index 0000000..38b53e8 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/QQ\346\210\252\345\233\27620160221171821.png" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/copyMoveDetection.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/copyMoveDetection.m" new file mode 100644 index 0000000..3b2ef94 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/copyMoveDetection.m" @@ -0,0 +1,50 @@ +function copyMoveDetection(imageName,threshold) +%%:ͬһͼиճ +%: +% imageName:ͼļ(չ):'CRW_4901_JFRtamp25.jpg' +% threshold:ֵΧΪ(0,1)ĬΪ0.4 +%: +% + +%SIFT㷨 +[im, des, loc] = sift(imageName); + +% +if nargin<2 + threshold= 0.4; %Ĭֵ +end + match = ones(1,size(des,1)); + %ѭƥ + for i = 1 : size(des,1) + %des(i,:) desÿһŷþ + distance_I_other = distanceVectorMatrix(des(i,:),des); + %ĽС + [vals,indx] = sort(distance_I_other); + %ƥ + if (vals(2) < threshold * vals(3)) + match(i) = indx(2);%iʹıֵСֵthresholdĻ + else %Ϊ indx(2)iƥ䡣 + match(i) = 0; %ȥindx(1)Ϊõi + end + end + +% ʾյĵƥͼ. +%ǰʾԭʼҶͼ + figure('Position', [100 100 size(im,2) size(im,1)]); + colormap('gray'); + imagesc(im); +%ԭͼϼ + hold on; + % + for i = 1: size(des,1) + if (match(i) > 0) + %line([꣬յ],[꣬յ],...) + line([loc(i,2) loc(match(i),2)], [loc(i,1) loc(match(i),1)], 'Color', 'c'); + end + end + %ƥ + num = sum(match > 0); + %num + fprintf('Finding %d matches.\n', num); + + \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/distanceVectorMatrix.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/distanceVectorMatrix.m" new file mode 100644 index 0000000..0d3df6b --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/distanceVectorMatrix.m" @@ -0,0 +1,31 @@ +function result = distanceVectorMatrix(vector,matrix) +%%ܣvector matrixÿһŷþ +%˵ +% +%룺 +% vector +% matrix(vectorijһ) +% +% result() + +%% +%vectorij +lengthVector = length(vector); + +%matrixijߴ +[rowMatrix,colMatrix] = size(matrix); + +%ǷҪ +if(lengthVector ~= colMatrix) + error('distance_I_otherߴ粻ȷ룡'); +end + +%ΪrowMatrix +colVec = ones(rowMatrix,1); + +%Ʊ(colVec*vector-matrix)ÿƽ +matTemp = (colVec*vector-matrix).^2; + +%matTemoÿеĺͣƽȵս +result = sqrt(sum(matTemp,2)); + diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/ldd.jpg" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/ldd.jpg" new file mode 100644 index 0000000..e7a94bc Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/ldd.jpg" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/sift.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/sift.m" new file mode 100644 index 0000000..35aecf3 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/sift.m" @@ -0,0 +1,80 @@ +function [imageRGB, descriptors, locs] = sift(imageFile) +%%ܣȡһͼ񣬲SIFTؼϢ +% : +% imageFile: ͼƬļ +% +% : +% imageRGB: ԭʼͼ +% descriptors: һKx128Сľ; kҵĹؼ;ÿһжΪλ +% locs:һKx4Сľ, ÿаؼĸֵ(ؼ߶Ȱ뾶) + +%ͼ +image = imread(imageFile); +imageRGB = image; +%ԭͼDzɫͼĻѲɫͼתΪҶͼ +if size(image,3) + image = rgb2gray(image); +end +%ȡͼijߴ +[rows, cols] = size(image); + + +% תPGMļ,Ϊʹ "keypoints" ִ +f = fopen('tmp.pgm', 'w'); +if f == -1 + error('ܶȡtmp.pgmļ'); +end +fprintf(f, 'P5\n%d\n%d\n255\n', cols, rows); +fwrite(f, image', 'uint8'); +fclose(f); + +% "keypoints" ִ +if isunix + command = '!./sift '; +else + command = '!siftWin32 '; +end +command = [command ' tmp.key']; +eval(command); + +% tmp.keyͷļ +g = fopen('tmp.key', 'r'); +if g == -1 + error('ܴtmp.keyļ'); +end +[header, count] = fscanf(g, '%d %d', [1 2]); +if count ~= 2 + error('Чġkeypointļ'); +end +num = header(1); +len = header(2); +if len ~= 128 + error('ؼӳȲԣӦ128'); +end + +% ʹ֪ͼߴ紴ͼ +locs = double(zeros(num, 4)); +descriptors = double(zeros(num, 128)); + +% tmp.key +for i = 1:num + [vector, count] = fscanf(g, '%f %f %f %f', [1 4]); %߶Ȱ뾶 + if count ~= 4 + error('Чġkeypointļʽ'); + end + locs(i, :) = vector(1, :); + + [descrip, count] = fscanf(g, '%d', [1 len]); + if (count ~= 128) + error('Чġkeypointļֵ'); + end + % λÿ + descrip = descrip / sqrt(sum(descrip.^2)); + descriptors(i, :) = descrip(1, :); +end +%رļ +fclose(g); +delete tmp.key +delete tmp.pgm + + diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/sony_61tamp37.jpg" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/sony_61tamp37.jpg" new file mode 100644 index 0000000..da67600 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/sony_61tamp37.jpg" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/\347\244\272\344\276\213.avi" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/\347\244\272\344\276\213.avi" new file mode 100644 index 0000000..6e04e5b Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/\347\244\272\344\276\213.avi" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/\350\257\264\346\230\216\346\226\207\346\241\243.pdf" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/\350\257\264\346\230\216\346\226\207\346\241\243.pdf" new file mode 100644 index 0000000..ba6aa0a Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/copyMoveDetection/\350\257\264\346\230\216\346\226\207\346\241\243.pdf" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/\345\217\246\344\270\200\347\247\215\344\273\243\347\240\201/A.png" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/\345\217\246\344\270\200\347\247\215\344\273\243\347\240\201/A.png" new file mode 100644 index 0000000..29c4868 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/\345\217\246\344\270\200\347\247\215\344\273\243\347\240\201/A.png" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/\345\217\246\344\270\200\347\247\215\344\273\243\347\240\201/B.png" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/\345\217\246\344\270\200\347\247\215\344\273\243\347\240\201/B.png" new file mode 100644 index 0000000..10ca79b Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/\345\217\246\344\270\200\347\247\215\344\273\243\347\240\201/B.png" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/\345\217\246\344\270\200\347\247\215\344\273\243\347\240\201/plan1.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/\345\217\246\344\270\200\347\247\215\344\273\243\347\240\201/plan1.m" new file mode 100644 index 0000000..38b9a77 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\345\256\236\351\252\214\344\273\243\347\240\201matlab/\345\217\246\344\270\200\347\247\215\344\273\243\347\240\201/plan1.m" @@ -0,0 +1,25 @@ +clc;clear;close all; +fixed = rgb2gray(imread('A.png')); %ͼתΪҶͼ +moving = rgb2gray(imread('B.png')); + +[optimizer,metric] = imregconfig('multimodal'); + optimizer.MaximumIterations = 15; % + optimizer.InitialRadius = optimizer.InitialRadius/100; + +movingRegister = imregister(moving,fixed,'translation',optimizer,metric);%׼ + +tformSimilarity = imregtform(moving,fixed,'translation',optimizer,metric);%任 +Rfixed = imref2d(size(fixed)); +movingRegisteredRigid = imwarp(moving,tformSimilarity,'OutputView',Rfixed);%moving 任 + +I=(movingRegisteredRigid-fixed)+(fixed-movingRegisteredRigid);%ͼ +thresh = 0.1; %ֵֵ +BW = im2bw(I,thresh); %ͼֵ +% % % imshowpair(fixed,movingRegisteredRigid,'falsecolor'); +subplot(2,2,1),imshow(fixed);title('ҶԭʼͼA'); +subplot(2,2,2),imshow(moving);title('ҶԭʼͼB'); +subplot(2,2,3),imshow(I);title('۸IJҶͼ'); +subplot(2,2,4),imshow(BW);title('۸IJֵͼ'); + + + diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214.pdf" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214.pdf" new file mode 100644 index 0000000..16acb72 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214.pdf" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266_\347\262\230\350\264\264\347\257\241\346\224\271\346\243\200\346\265\213\344\270\216\345\256\232\344\275\215\347\256\227\346\263\225_\350\256\270\346\233\274\346\233\274.pdf" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266_\347\262\230\350\264\264\347\257\241\346\224\271\346\243\200\346\265\213\344\270\216\345\256\232\344\275\215\347\256\227\346\263\225_\350\256\270\346\233\274\346\233\274.pdf" new file mode 100644 index 0000000..07eec1f Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\214--\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266\347\262\230\350\264\264\346\243\200\346\265\213/\346\225\260\345\255\227\345\233\276\345\203\217\345\244\215\345\210\266_\347\262\230\350\264\264\347\257\241\346\224\271\346\243\200\346\265\213\344\270\216\345\256\232\344\275\215\347\256\227\346\263\225_\350\256\270\346\233\274\346\233\274.pdf" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/embed.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/embed.m" new file mode 100644 index 0000000..dd73ad1 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/embed.m" @@ -0,0 +1,63 @@ +wavin='recoder.wav'; +wavout='recoder_embed.wav'; +%Header of wav = 1:40, Length of wav = 41:43, Data part = 44:end +fid = fopen(wavin,'r'); +header = fread(fid,40,'uint8=>char'); +dsize = fread(fid,1,'uint32'); +[cover,len_cover] = fread(fid,inf,'uint16');%ָļÿ16bitȡcover,¼coverij +fclose(fid); +[sy,fs]=audioread('shuiyin.wav');%ˮӡ +sy=sy(:,1); +symax=max(abs(sy)) ; % +symin=min(abs(sy)) ; %С +len2=size(sy); %ƵܳȣFFTƵ +t2=(0:length(sy)-1)/fs; +lhsy=abs(sy)/symax; %һ, +lhsy=lhsy*255; %Χ0~255 +lhsy=fix(lhsy); %ֵȡ +%-----------------ˮӡתΪ +for i=1:len2 %l2ˮӡij + if sy(i)<0 %һλʾλ + k=0; + else k=1; + end + fdsy(9*i-8)=k; + fdsy(9*i-7)=bitand(lhsy(i),1); + fdsy(9*i-6)=bitand(lhsy(i),2)/2; + fdsy(9*i-5)=bitand(lhsy(i),4)/4; + fdsy(9*i-4)=bitand(lhsy(i),8)/8; + fdsy(9*i-3)=bitand(lhsy(i),16)/16; + fdsy(9*i-2)=bitand(lhsy(i),32)/32; + fdsy(9*i-1)=bitand(lhsy(i),64)/64; + fdsy(9*i)=bitand(lhsy(i),128)/128; +end +%------------------ԭʼǶsymax +symax1=fix(symax*100);%92 +for i=1:8 + kk(i)=bitand(symax1,2^(i-1))/(2^(i-1)); + %qrh(i)=bitor(xx1(i),kk(i)); +end + +%---------------------Ƕˮӡl2 +%lenthl2=dec2base(l2,2,24);%ˮӡת24λ +yyy=len2(:,1); + +for i=1:24 + kk(i+8)=bitand(yyy,2^(i-1))/(2^(i-1)); + %qrh(8+i)=bitor(xx1(8+i),lenthl2(i)); +end +%-------------Ƕˮӡźţλ +for i=1:(9*len2) + kk(i+32)=fdsy(i); +end +%---------------------ǶˮӡƵʣ16λ +for i=1:16 + kk(i+9*len2+32)=bitand(fs,2^(i-1))/(2^(i-1)); +end +len_sy=size(kk,2);%ؾˮӡĶλ +cover(1:len_sy)=bitset(cover(1:len_sy),1,kk(1:len_sy)'); +out = fopen(wavout,'w'); +fwrite(out,header,'uint8'); +fwrite(out,dsize,'uint32'); +fwrite(out,cover,'uint16'); +fclose(out); diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/extracting.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/extracting.m" new file mode 100644 index 0000000..074b16b --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/extracting.m" @@ -0,0 +1,47 @@ +wavin = 'recoder_embed.wav'; +[x1,fs1]=audioread(wavin); +fid = fopen(wavin,'r'); +header = fread(fid,40,'uint8=>char'); +dsize = fread(fid,1,'uint32'); +stego = fread(fid,inf,'uint16');%Ƶļ +fclose(fid); +symax_bit = bitget(stego(1:8),1)';%bitget(y,1)ȡyĶλ +sy_length_bit=bitget(stego(9:32),1)'; +symax=0; +for i=1:8 + symax=symax+2^(i-1)*symax_bit(i); +end +symax=symax./100;%ԭ +sy_length = 0; +for i=1:24 + sy_length=sy_length+2^(i-1)*sy_length_bit(i); +end + +fs_bit=bitget(stego((33+9*sy_length):(48+9*sy_length)),1)';%ȡfs_bitԣΪ1400W +fs=0; +for i=1:16 + fs=fs+2^(i-1)*fs_bit(i); +end + +global sy_data_bit; +global qshuiyin; +sy_data_bit=bitget(stego(33:(32+(9*sy_length))),1)'; +for i=1:sy_length + wei0=sy_data_bit(9*i-8); + wei1=sy_data_bit(9*i-7); + wei2=sy_data_bit(9*i-6)*2; + wei3=sy_data_bit(9*i-5)*4; + wei4=sy_data_bit(9*i-4)*8; + wei5=sy_data_bit(9*i-3)*16; + wei6=sy_data_bit(9*i-2)*32; + wei7=sy_data_bit(9*i-1)*64; + wei8=sy_data_bit(9*i)*128; + qshuiyin(i)=wei1+wei2+wei3+wei4+wei5+wei6+wei7+wei8; + %ƥ + if wei0==0 + qshuiyin(i)=-qshuiyin(i); + end +end +lh=255/symax; +Qshuiyin=qshuiyin/lh; +audiowrite('extracting_shuiyin.wav',Qshuiyin,fs); \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/extracting_shuiyin.wav" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/extracting_shuiyin.wav" new file mode 100644 index 0000000..2d5be5e Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/extracting_shuiyin.wav" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/recoder.wav" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/recoder.wav" new file mode 100644 index 0000000..cab5b58 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/recoder.wav" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/recoder_embed.wav" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/recoder_embed.wav" new file mode 100644 index 0000000..97f92bf Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/recoder_embed.wav" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/shuiyin.wav" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/shuiyin.wav" new file mode 100644 index 0000000..8e11353 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\2542/shuiyin.wav" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\254\344\270\211.jpg" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\254\344\270\211.jpg" new file mode 100644 index 0000000..5087d89 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\351\237\263\351\242\221\347\211\210\346\234\254\344\270\211.jpg" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224.pdf" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224.pdf" new file mode 100644 index 0000000..b245854 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224.pdf" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/\350\207\252\345\267\261\347\232\204matlab\344\273\243\347\240\201/lsb_mysong.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/\350\207\252\345\267\261\347\232\204matlab\344\273\243\347\240\201/lsb_mysong.m" new file mode 100644 index 0000000..0ac6197 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\344\272\224--\351\237\263\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/\350\207\252\345\267\261\347\232\204matlab\344\273\243\347\240\201/lsb_mysong.m" @@ -0,0 +1,33 @@ + +clc; +clear; +org_voice='recoder.wav'; +info = audioinfo(org_voice) +[y,Fs] = audioread(org_voice); % y ԼݵIJ Fs +len_key=size(y,1); %Ƶܳ +key=randsrc(len_key,1,[0,1]);%ɼܾ +y_change=round((y(:,1))*(10^7));%Ŵ +ymax=max(y_change); % +ymin=min(y_change); %С + for i=1:len_key %LSBǶˮӡ + if y_change(i)>=0 %ֵΪ + x(i)=bitor(y_change(i),key(i)); + else %ֵΪ + x(i)=-bitor(abs(y_change(i)),key(i)); + end + end +x=(x.')/(10^7); +t = 0:seconds(1/Fs):seconds(info.Duration); +t = t(1:end-1); +figure; +subplot(2,1,1); +plot(t,y); +xlabel('Time'); +ylabel('ԭʼƵ'); +subplot(2,1,2); +plot(t,x); +xlabel('Time'); +ylabel('ǶˮӡƵ'); + + + diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/goal.bmp" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/goal.bmp" new file mode 100644 index 0000000..13be722 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/goal.bmp" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/lww.avi" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/lww.avi" new file mode 100644 index 0000000..238bb68 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/lww.avi" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/message.txt" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/message.txt" new file mode 100644 index 0000000..19c7bdb --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/message.txt" @@ -0,0 +1 @@ +16 \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randinterval.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randinterval.m" new file mode 100644 index 0000000..1e2a152 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randinterval.m" @@ -0,0 +1,50 @@ +%ļ:randinterval.m +%Ա: +%дʱ:2004.2.23 +%:нм,ѡϢλ. +%ʽ:[row,col]=randinterval(test,60,1983) +%˵: +%matrixΪ +%countΪҪǶϢ(Ҫѡ) +%keyΪԿ +%rowΪαб +%colΪαб +function [row,col]=randinterval(matrix,count,key) +%λ +[m,n]=size(matrix); +interval1=floor(m*n/count)+1; +interval2=interval1-2; +if interval2<=0 + error( '̫СܽϢؽȥ!' ); +end +% +rand('twister',key); +a=rand(1,count); +%ʼ +row=zeros([1 count]); +col=zeros([1 count]); +%rowcol +r=1; +c=1; +row(1,1)=r; +col(1,1)=c; +for i=2:count + if a(i)>=0.5 + c=c+interval1; + else + c=c+interval2; + end + if c>n + r=r+1; + if r>m + error( '̫СܽϢؽȥ!' ); + end + c=mod(c,n); + if c==0 + c=1; + end + end + +row(1,i)=r; +col(1,i)=c; +end diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randlsbget.asv" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randlsbget.asv" new file mode 100644 index 0000000..359855b --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randlsbget.asv" @@ -0,0 +1,35 @@ +%ļ:randlsbget.m +%Ա:Ρ +%дʱ:2004.2.29 +%:ȡLSBϵϢ +%ʽ:result=randlsbget('d.jpg',50,'secret.txt',1988) +%˵: +%outputϢغͼ +%len_totalϢij +%goalfileȡϢļ +%keyԿ +%resultȡϢ +function result=randlsbget(output,len_total,goalfile,key) + +ste_cover=double(output); +%жǶϢǷ +[m,n]=size(ste_cover); +frr=fopen(goalfile,'a'); +%pΪϢǶλ,Ϣдıļ +p=1; +%ѡȡص +[row,col]=randinterval(ste_cover,len_total,key); +for i=1:len_total + if bitand(ste_cover(row(i),col(i)),1)==1 + fwrite(frr,1,'bit1'); + result(p,1)=1; + else + fwrite(frr,0,'bit1'); + result(p,1)=0; + end + if p==len_total + break; + end + p=p+1; +end +fclose(frr); diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randlsbget.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randlsbget.m" new file mode 100644 index 0000000..359855b --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randlsbget.m" @@ -0,0 +1,35 @@ +%ļ:randlsbget.m +%Ա:Ρ +%дʱ:2004.2.29 +%:ȡLSBϵϢ +%ʽ:result=randlsbget('d.jpg',50,'secret.txt',1988) +%˵: +%outputϢغͼ +%len_totalϢij +%goalfileȡϢļ +%keyԿ +%resultȡϢ +function result=randlsbget(output,len_total,goalfile,key) + +ste_cover=double(output); +%жǶϢǷ +[m,n]=size(ste_cover); +frr=fopen(goalfile,'a'); +%pΪϢǶλ,Ϣдıļ +p=1; +%ѡȡص +[row,col]=randinterval(ste_cover,len_total,key); +for i=1:len_total + if bitand(ste_cover(row(i),col(i)),1)==1 + fwrite(frr,1,'bit1'); + result(p,1)=1; + else + fwrite(frr,0,'bit1'); + result(p,1)=0; + end + if p==len_total + break; + end + p=p+1; +end +fclose(frr); diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randlsbhide.asv" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randlsbhide.asv" new file mode 100644 index 0000000..ae22ee5 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randlsbhide.asv" @@ -0,0 +1,42 @@ +%ļ:randlsbhide.m +%Ա:Ρ +%дʱ:2004.3.2 +%:ѡLSBϢ +%ʽ:[ste_cover,len_total]=randlsbhide('lena.bmp','message.txt','hided.bmp',213) +%˵: +%inputϢͼ +%fileϢļ +%outputϢغͼ +%keyԿ +%ste_coverϢغͼ +%len_totalϢijȣ +function [ste_cover,len_total]=randlsbhide(input,file,output,key) +%ͼ +cover=imread(input); +ste_cover=cover; +ste_cover=double(ste_cover); +%ıļתΪ +f_id=fopen(file,'r'); +[msg,len_total]=fread(f_id,'ubit1'); +%жǶϢǷ +[m,n]=size(ste_cover); +if len_total>m*n + error('ǶϢͼ'); +end +%pΪϢǶλ +p=1; +%ѡȡص +[row,col]=randinterval(ste_cover,len_total,key); +%LSBϢ +for i=1:len_total + ste_cover(row(i),col(i))=ste_cover(row(i),col(i))-mod(ste_cover(row(i),col(i)),2)+msg(p,1); + if p==len_total + break; + end + p=p+1; +end +ste_cover=uint8(ste_cover); +imwrite(ste_cover,output); +%ʾʵ + +subplot(3,3,2);imshow(output);title('Ϣͼ'); diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randlsbhide.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randlsbhide.m" new file mode 100644 index 0000000..0223d07 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/randlsbhide.m" @@ -0,0 +1,42 @@ +%ļ:randlsbhide.m +%Ա:Ρ +%дʱ:2004.3.2 +%:ѡLSBϢ +%ʽ:[ste_cover,len_total]=randlsbhide('lena.bmp','message.txt','hided.bmp',213) +%˵: +%inputϢͼ +%fileϢļ +%outputϢغͼ +%keyԿ +%ste_coverϢغͼ +%len_totalϢijȣ +function [ste_cover,len_total]=randlsbhide(input,file,output,key) +%ͼ + +ste_cover=input; +ste_cover=double(ste_cover); +%ıļתΪ +f_id=fopen(file,'r'); +[msg,len_total]=fread(f_id,'ubit1'); +%жǶϢǷ +[m,n]=size(ste_cover); +if len_total>m*n + error('ǶϢͼ'); +end +%pΪϢǶλ +p=1; +%ѡȡص +[row,col]=randinterval(ste_cover,len_total,key); +%LSBϢ +for i=1:len_total + ste_cover(row(i),col(i))=ste_cover(row(i),col(i))-mod(ste_cover(row(i),col(i)),2)+msg(p,1); + if p==len_total + break; + end + p=p+1; +end +ste_cover=uint8(ste_cover); +imwrite(ste_cover,output); +%ʾʵ + + diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/secret.txt" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/secret.txt" new file mode 100644 index 0000000..e69de29 diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/vedioget.asv" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/vedioget.asv" new file mode 100644 index 0000000..10ee757 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/vedioget.asv" @@ -0,0 +1,15 @@ +clear all; +clc; +clf; +start_time=cputime; +mov=aviread('withed11.avi',1); + %ת֡ΪYUVͼʽ + mov1=ind2rgb(mov.cdata,mov.colormap); + movi=uint8(round(mov1*255)); + a=movi; + imwrite(' + +[ste_cover,len_total]=randlsbget(a,50,'secret.txt',213); + + + diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/vedioget.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/vedioget.m" new file mode 100644 index 0000000..a0c2698 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/vedioget.m" @@ -0,0 +1,30 @@ +clear all; +clc; +clf; +start_time=cputime; + + + + + + +%ÿ֡ˮӡǶ + %ȡƵеÿһ֡ + + + +mov=aviread('withed11.avi',1); + + + + %ת֡ΪYUVͼʽ + mov1=ind2rgb(mov.cdata,mov.colormap); + movi=uint8(round(mov1*255)); + a=movi; + + + +[ste_cover,len_total]=randlsbget(a,50,'secret.txt',213); + + + diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/vediowatermark.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/vediowatermark.m" new file mode 100644 index 0000000..bef3d99 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/vediowatermark.m" @@ -0,0 +1,62 @@ +clear all; +clc; +clf; +start_time=cputime; + +aviobj = avifile('withed11.avi','fps',15,'quality',85,'compression','RLE'); + +movI=aviread('lww.avi'); +subplot(2,2,1);title('ԭʼƵ'); +movie(movI); + + +fileinfo = aviinfo('lww.avi'); +%ÿ֡ˮӡǶ + %ȡƵеÿһ֡ + +for r=1:fileinfo.NumFrames + +mov=aviread('lww.avi',r); +movII=aviread('lww.avi',r); + + + %ת֡ΪYUVͼʽ + mov1=ind2rgb(mov.cdata,mov.colormap); + movi=uint8(round(mov1*255)); + a=movi; + + + +[ste_cover,len_total]=randlsbhide(a,'message.txt','goal.bmp',213); + + + + a1=blkproc('goal.bmp',[8,8],'idct2'); + [x1,x2]=size(a1); + %a_1=double(a1); + movII.cdata=uint8(a1); + + %movII.cdata=a1 + [x3,x4]=size(movII.cdata); + %movII.colormap=movI.colormap + + %movII.colormap=movI.colormap; + + aviobj = addframe(aviobj,movII); + +end +aviobj = close(aviobj); +pause(10) +%Ե +%finishfileinfo = aviinfo('withwater8.avi') + +fileinfo = aviinfo('withed11.avi'); + +pause(3); +movIII=aviread('withed11.avi',2); +[l1,l2]=size(movIII.cdata); + +subplot(2,2,2);title('ˮӡƵ: '); +mov2 = aviread('withed11.avi'); +%[s1,s2]=size(mov2.cdata) +movie(mov2); diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/videowatermark.asv" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/videowatermark.asv" new file mode 100644 index 0000000..f7328f3 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/videowatermark.asv" @@ -0,0 +1,61 @@ +clear all; +clc; +clf; +start_time=cputime; + +aviobj = avifile('withed11.avi','fps',15,'quality',85,'compression','RLE'); + +movI=aviread('lww.avi'); +subplot(2,2,1);title('ԭʼƵ'); +movie(movI); + + +fileinfo = aviinfo('lww.avi'); +%ÿ֡ˮӡǶ + %ȡƵеÿһ֡ + +for p=1:fileinfo.NumFrames + +mov=aviread('lww.avi',p); +movII=aviread('lww.avi',p); + + + %ת֡ΪYUVͼʽ + mov1=ind2rgb(mov.cdata,mov.colormap); + movi=uint8(round(mov1*255)); + a=movi; + + +[ste_cover,len_total]=randlsbhide(a,'message.txt','goal.bmp',213); + + + + a1=blkproc('goal.bmp',[8,8],'idct2'); + [x1,x2]=size(a1); + %a_1=double(a1); + movII.cdata=uint8(a1); + + %movII.cdata=a1 + [x3,x4]=size(movII.cdata); + %movII.colormap=movI.colormap + + %movII.colormap=movI.colormap; + + aviobj = addframe(aviobj,movII); + +end +aviobj = close(aviobj); +pause(10) +%Ե +%finishfileinfo = aviinfo('withwater8.avi') + +fileinfo = aviinfo('withed11.avi'); + +pause(3); +movIII=aviread('withed11.avi',2); +[l1,l2]=size(movIII.cdata); + +subplot(2,2,2);title('ˮӡƵ: '); +mov2 = aviread('withed11.avi'); +%[s1,s2]=size(mov2.cdata) +movie(mov2); diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/withed11.avi" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/withed11.avi" new file mode 100644 index 0000000..bf1347e Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/LSB\350\247\206\351\242\221\347\211\210\346\234\2542/lsb/withed11.avi" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/lsb\350\200\201\345\270\210\347\211\210\346\234\254.jpg" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/lsb\350\200\201\345\270\210\347\211\210\346\234\254.jpg" new file mode 100644 index 0000000..78c435b Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/lsb\350\200\201\345\270\210\347\211\210\346\234\254.jpg" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255.pdf" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255.pdf" new file mode 100644 index 0000000..cd0925a Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255.pdf" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/\350\207\252\345\267\261\347\232\204matlab\344\273\243\347\240\201/lsbvideo.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/\350\207\252\345\267\261\347\232\204matlab\344\273\243\347\240\201/lsbvideo.m" new file mode 100644 index 0000000..07170c6 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\205\255--\350\247\206\351\242\221\346\260\264\345\215\260\347\256\227\346\263\225/\350\207\252\345\267\261\347\232\204matlab\344\273\243\347\240\201/lsbvideo.m" @@ -0,0 +1,26 @@ +v = VideoReader('ljx_avi.avi'); +while hasFrame(v) + video = readFrame(v); +end +vd = video(:,:,1);%һ֡ˮӡ +row = size(vd,1); +col = size(vd,2); +key=randsrc(row,col,[0,1]);%ɼܾ +result_key=ones(row,col)*nan; +for i=1:row + for j=1:col + result_key(i,j)=bitset(vd(i,j),1,key(i,j));%LSB㷨IJ + end +end +video(:,:,1) = result_key; +newframe = im2frame(video); +org_v = VideoWriter('lsb_video.avi'); +open(org_v) +v = VideoReader('ljx_avi.avi'); +for k = 1:v.Duration-1 + video = read(v,k); + writeVideo(org_v,video); +end +writeVideo(org_v,newframe); +close(org_v); + \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/DCT.zip" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/DCT.zip" new file mode 100644 index 0000000..3da1bdf Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/DCT.zip" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/LSB\347\211\210\346\234\2541/LSB_embed.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/LSB\347\211\210\346\234\2541/LSB_embed.m" new file mode 100644 index 0000000..80c3090 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/LSB\347\211\210\346\234\2541/LSB_embed.m" @@ -0,0 +1,47 @@ +function [] = LSB_embed(name, message) +% LSBembed(name, message, lsb) +% name: the picture's path and name +% message: the data you want to hide in the picture +% LSB in steganography (embed) +% +% Author: Moming +% 2016-03-20 + +lsb = 3; +image = imread(name); +msg_origin = unicode2native(message, 'UTF-8'); % UTF-8 encode +msg_bin = dec2bin(msg_origin, 8); % convert to binary +msg = blanks(9); +for i = 1 : size(msg_bin, 1) + msg(i, :) = strcat(msg_bin(i, :), char(mod(i, 2) + '0')); +end +msg = strjoin(cellstr(msg)',''); +msg(end) = char(mod(size(msg_bin, 1) + 1, 2) + '0'); % change the last bit as the end tag + +len = length(msg) / lsb; +tmp = blanks(len); +for i = 1 : len + tmp(i) = char(bin2dec(msg((i - 1) * lsb + 1 : i * lsb)) + '0'); % convert to decimal +end + +% use RGB +result = image; +rgb = 1; +[len_R, len_G, len_B] = size(result); + +for R = 1 : len_R + for G = 1 : len_G + for B = 1 : len_B + if rgb <= len + % only to be consistent with front: '0' + result(R, G, B) = result(R, G, B) - mod(result(R, G, B), 2^lsb) + double(tmp(rgb) - '0'); + rgb = rgb + 1; + end + end + end +end + +imshow(result); +imwrite(result, 'result.png'); % jpg would lose some information + +end \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/LSB\347\211\210\346\234\2541/LSB_extract.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/LSB\347\211\210\346\234\2541/LSB_extract.m" new file mode 100644 index 0000000..d550e35 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/LSB\347\211\210\346\234\2541/LSB_extract.m" @@ -0,0 +1,34 @@ +function [msg_origin] = LSB_extract(name) +% LSB_extract(name, lsb) +% name: the picture's path and name +% LSB in steganography (extract) +% +% Author: Moming +% 2016-03-20 + +image = imread(name); + +lsb = 3; +index = 1; +rgb = zeros(0); +[len_R, len_G, len_B] = size(image); +flag = char('0'); % use to detect the end tag + +for R = 1 : len_R + for G = 1 : len_G + tmp = blanks(0); + for B = 1 : len_B + tmp = strcat(tmp, mod(image(R, G, B), 2^lsb) + '0'); % '0' is useful!!! Placeholder... + end + tmp_bin = dec2bin(tmp - '0', 3)'; + rgb(index) = bin2dec(tmp_bin(1 : 8)); + if flag + tmp_bin(9) ~= 97 % '0'/'1' is the end tag + msg_origin = native2unicode(rgb, 'UTF-8'); + return; + end + index = index + 1; + flag = tmp_bin(9); + end +end + +end \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/LSB\347\211\210\346\234\2542/LSB.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/LSB\347\211\210\346\234\2542/LSB.m" new file mode 100644 index 0000000..512eb0d --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/LSB\347\211\210\346\234\2542/LSB.m" @@ -0,0 +1,71 @@ + + +%ary ʾǸ,1ͱλ +ary = 1; + +file_name1 = '4.PNG'; +cover_object = imread(file_name1); %ȡƬϢ +cover_object = rgb2gray(cover_object); %õҶͼϢ +cover_object_ll = bitget(cover_object, ary); %õ1λ + +figure; %һ +imshow(cover_object); +title('origin host picture'); %չʾԭͼγɵĻҶͼ + +figure; +imshow(255*cover_object_ll); %λƵλ +title('origin hot pic`lowest bit'); %չʾԭͼλ + +file_name2 = 'Finger.bmp'; +message = imread(file_name2); + +figure; +imshow(message); + +message = im2bw(message, graythresh(message)); %ָͼΪֵͼ + +figure; +imshow(message); +title('hidden picture'); + +Mc = size(cover_object, 1); %Height ȡͼƬĴС +Nc = size(cover_object, 2); %Width + +message = imresize(message, [Mc Nc]); %ʹͼƬͼƬȳ + +watermarked_image = cover_object; + +%ʹͼƬһλ뱻ͼƬ +for ii = 1 : Mc + for jj = 1 : Nc + if ii*jj < Mc * Nc %СָϢͼƬС + if cover_object_ll(ii, jj) ~= message(ii, jj) %˲ȣΪһ + if cover_object_ll(ii, jj) == 1 + watermarked_image(ii, jj) = bitset(watermarked_image(ii,jj), ary, 0); %ȸΪ0 + else + watermarked_image(ii, jj) = bitset(watermarked_image(ii,jj), ary, 1); + end + end + end + end +end + +figure; +imshow(watermarked_image); +title('watermarked picture'); +saveas(gcf, 'ok.bmp'); +figure; +watermarked_image_ll = bitget(watermarked_image, ary); +imshow(255 * watermarked_image_ll); +title('watermarked picture`s lowest bit'); + +file = 'ok.bmp' +water_pic = imread(file); %ȡͼ +water_pic_1 = bitget(water_pic, 1); %õ1λ + +figure; +imshow(water_pic); + +figure; +imshow(255*water_pic_1); +saveas(gcf, 'abstarct.bmp'); diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/LSB\347\211\210\346\234\2543.rar" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/LSB\347\211\210\346\234\2543.rar" new file mode 100644 index 0000000..4ed9db5 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/LSB\347\211\210\346\234\2543.rar" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/Arnold1.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/Arnold1.m" new file mode 100644 index 0000000..402ae90 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/Arnold1.m" @@ -0,0 +1,24 @@ +function [randwater] = Arnold1(waterpath) +water = imread(waterpath); +I=rgb2gray(water); +[h w]=size(I); +%븴ԭĹͬ +n=10; +a=3;b=5; +N=h; +% +C=zeros(h,w); +for i=1:n + for y=1:h + for x=1:w + xx=mod((x-1)+b*(y-1),N)+1; %λ + yy=mod(a*(x-1)+(a*b+1)*(y-1),N)+1; %λ + C(xx,yy)=I(x,y); + end + end + I=C; +end +randwater = C; +end +%figure; +%imshow(C,[]) \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/Arnold2.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/Arnold2.m" new file mode 100644 index 0000000..0749b3a --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/Arnold2.m" @@ -0,0 +1,22 @@ +function [realwater] = Arnold1(waterpath) +C = imread(waterpath); +[h w]=size(C); +%븴ԭĹͬ +n=10; +a=3;b=5; +N=h; + +%ԭ +D=zeros(h,w); +for i=1:n + for y=1:h + for x=1:w + xx=mod((a*b+1)*(x-1)-b*(y-1),N)+1; %λ + yy=mod(-a*(x-1)+(y-1),N)+1 ; %λ + D(xx,yy)=C(x,y); + end + end + C=D; +end +realwater = D; +end diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/HYASUO.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/HYASUO.m" new file mode 100644 index 0000000..c77444e --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/HYASUO.m" @@ -0,0 +1,20 @@ +function result=HYASUO(I) +yuzhi=50; +A=I(:,:,1); +B=I(:,:,2); +C=I(:,:,3); +[c,k]=size(A); +for i=1:c + for j=1:k + if A(i,j)<=yuzhi + A(i,j)=0; + end + if B(i,j)<=yuzhi + B(i,j)=0; + end + if C(i,j)<=yuzhi + C(i,j)=0; + end + end +end +result=cat(3,A,B,C); \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/attack.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/attack.m" new file mode 100644 index 0000000..e64606a --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/attack.m" @@ -0,0 +1,45 @@ +function [ after_attack ] = attack(choice ,pathfile3) + +watermark = imread(pathfile3); +switch choice +%ֱȡ +case 1 +after_attack = watermark; + +% +case 2 +result=watermark; +noise=10*randn(size(result)); +result=double(result)+noise; +after_attack=uint8(result); + +%й +case 3 +result=watermark; +A=result(:,:,1); +B=result(:,:,2); +C=result(:,:,3); +A(1:64,1:400)=512; +B(1:64,1:400)=512; +C(1:64,1:400)=512; +after_attack=cat(3,A,B,C); + +%ѹ +case 4 +[cA1,cH1,cV1,cD1]=dwt2(watermark,'Haar'); +cA1=HYASUO(cA1); +cH1=HYASUO(cH1); +cV1=HYASUO(cV1); +cD1=HYASUO(cD1); +result=idwt2(cA1,cH1,cV1,cD1,'Haar'); +after_attack=uint8(result); + +%ת +case 5 +result=watermark; +after_attack=imrotate(watermark,10,'bilinear','crop'); + +end + +end + diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/carry1.bmp" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/carry1.bmp" new file mode 100644 index 0000000..c8d659d Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/carry1.bmp" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/carry2.bmp" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/carry2.bmp" new file mode 100644 index 0000000..387b55f Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/carry2.bmp" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/ispsnr.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/ispsnr.m" new file mode 100644 index 0000000..667766d --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/ispsnr.m" @@ -0,0 +1,15 @@ +%ֵPSNRֵ +%IΪԭʼͼJΪͼ + +function [ PSNR ] = ispsnr( I,J ) +width = size(I,2); +heigh = size(I,1); +if( width ~= size(J,2) || heigh ~= size(J,1) ) + disp('Please check the input image have the same size'); + return +end +K = (I-J).*(I-J); +PSNR = sum(sum(K,1)); +PSNR = PSNR / (width * heigh); +PSNR=10*log10(255*255/PSNR); +end \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/main.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/main.m" new file mode 100644 index 0000000..c9d4d0b --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/main.m" @@ -0,0 +1,16 @@ +clc; +clear; +close; +%%% ߣPI %%% +global pathfile1;%ͼƬַ +global pathfile2;%ˮӡͼƬַ +global pathfile3;%ˮӡͼƬͼƬַ +global pathfile4;%ȡˮӡͼƬַ +global pathfile5;%ˮӡͼƬַ +global pathfile6;%ҵˮӡͼƬַ +global pathfre;%ǰ׺ +global k1; +k1=randn(1,8); +global k2; +k2=randn(1,8); +test(); \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/nc.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/nc.m" new file mode 100644 index 0000000..8db7c6a --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/nc.m" @@ -0,0 +1,24 @@ +%һϵNCֵ +%ImageAImageBΪͼƬ +function dNC = nc(ImageA,ImageB) +if (size(ImageA,1) ~= size(ImageB,1)) or (size(ImageA,2) ~= size(ImageB,2)) +error('ImageA <> ImageB'); +dNC = 0; +return ; +end +ImageA=double(ImageA); +ImageB=double(ImageB); +M = size(ImageA,1); +N = size(ImageA,2); +d1=0 ; +d2=0; +d3=0; +for i = 1:M +for j = 1:N +d1=d1+ImageA(i,j)*ImageB(i,j) ; +d2=d2+ImageA(i,j)*ImageA(i,j) ; +d3=d3+ImageB(i,j)*ImageB(i,j) ; +end +end +dNC=d1/(sqrt(d2)*sqrt(d3)); +return \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/qianru.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/qianru.m" new file mode 100644 index 0000000..cb83e9b --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/qianru.m" @@ -0,0 +1,49 @@ +function [waterimage] = qianru( path1,path2,k1,k2 ) + +carry = imread(path1); +water = imread(path2) +watermark = water +%watermark = rgb2gray(water); +mark = im2bw(watermark); +marksize = size(mark); +rm = marksize(1); +cm = marksize(2); + +I = mark; +alpha=30; + +yuv=rgb2ycbcr(carry); +Y=yuv(:,:,1); +U=yuv(:,:,2); +V=yuv(:,:,3); +before=blkproc(U,[8 8],'dct2'); + +after=before; +for i=1:rm + for j=1:cm + x=(i-1)*8; + y=(j-1)*8; + if mark(i,j)==1 + k=k1; + else + k=k2; + end; + after(x+1,y+8)=before(x+1,y+8)+alpha*k(1); + after(x+2,y+7)=before(x+2,y+7)+alpha*k(2); + after(x+3,y+6)=before(x+3,y+6)+alpha*k(3); + after(x+4,y+5)=before(x+4,y+5)+alpha*k(4); + after(x+5,y+4)=before(x+5,y+4)+alpha*k(5); + after(x+6,y+3)=before(x+6,y+3)+alpha*k(6); + after(x+7,y+2)=before(x+7,y+2)+alpha*k(7); + after(x+8,y+1)=before(x+8,y+1)+alpha*k(8); + end; +end; +result=blkproc(after,[8 8],'idct2'); +yuv_after=cat(3,Y,result,V); +waterimage=ycbcr2rgb(yuv_after); +global pathfile3; +global pathfre; +pathfile3=fullfile(pathfre, 'waterimage.bmp'); +imwrite(waterimage,pathfile3); + +end \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/readme.txt" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/readme.txt" new file mode 100644 index 0000000..4ec0452 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/readme.txt" @@ -0,0 +1,16 @@ +DCT任ˮӡ㷨 + +carry_x.bmp ΪͼƬ +water_x.bmp ΪˮӡͼƬ + +test.fig Ϊͼν +main.m Ϊִ +test.m Ϊ +ispsnr.m ΪֵȺٳ֣ +nc.m Ϊһϵٳ֣ +Arnold1.m ΪˮӡҺ +Arnold2.m Ϊˮӡԭ +qianru.m ΪˮӡǶ뺯 +tiqu.m Ϊˮӡȡ +attack.m Ϊˮӡ +HYASUO.m ΪСѹ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/test.fig" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/test.fig" new file mode 100644 index 0000000..ab96314 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/test.fig" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/test.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/test.m" new file mode 100644 index 0000000..091194d --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/test.m" @@ -0,0 +1,137 @@ +function varargout = test(varargin) + +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @test_OpeningFcn, ... + 'gui_OutputFcn', @test_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before test is made visible. +function test_OpeningFcn(hObject, eventdata, handles, varargin) +handles.output = hObject; +% Update handles structure +guidata(hObject, handles); + +% --- Outputs from this function are returned to the command line. +function varargout = test_OutputFcn(hObject, eventdata, handles) +varargout{1} = handles.output; + +% --- Executes on button press in pushbutton1. +function pushbutton1_Callback(hObject, eventdata, handles) + +[filename1, pathname1] = uigetfile('*.bmp', 'ѡͼƬ'); +global pathfile1; +global pathfre; +pathfile1=fullfile(pathname1, filename1); +pathfre = pathname1; +img=imread(pathfile1); +axes(handles.axes1); +image(img); + +% --- Executes on button press in pushbutton2. +function pushbutton2_Callback(hObject, eventdata, handles) + +[filename2, pathname2] = uigetfile('*.bmp', 'ѡˮӡͼƬ'); +global pathfile2; +pathfile2=fullfile(pathname2, filename2); +img=imread(pathfile2); +axes(handles.axes2); +image(img); + +%ˮӡ +function pushbutton6_Callback(hObject, eventdata, handles) +global pathfile2; +%global pathfile6; +global pathfre; +img = Arnold1(pathfile2); +%pathfile6=fullfile(pathfre, 'randwater.bmp'); +pathfile2=fullfile(pathfre,'randwater.bmp'); +imwrite(img,pathfile2); +axes(handles.axes2); +imshow(img); + +% --- Executes on button press in pushbutton3.ˮӡǶ +function pushbutton3_Callback(hObject, eventdata, handles) +global pathfile1; +global pathfile2; +global k1; +global k2; +img = qianru(pathfile1,pathfile2,k1,k2); +axes(handles.axes3); +image(img); + + +% --- Executes on selection change in popupmenu2.ˮӡ +function popupmenu2_Callback(hObject, eventdata, handles) +global pathfile3; +global pathfre; +var=get(handles.popupmenu2,'value'); +axes(handles.axes4); + +switch var + case 1 + after_attack = attack(var,pathfile3); + imwrite(after_attack,fullfile(pathfre,'.bmp')); + case 2 + after_attack = attack(var,pathfile3); + imwrite(after_attack,fullfile(pathfre,'.bmp')); + case 3 + after_attack = attack(var,pathfile3); + imwrite(after_attack,fullfile(pathfre,'ּ.bmp')); + case 4 + after_attack = attack(var,pathfile3); + imwrite(after_attack,fullfile(pathfre,'Сѹ.bmp')); + case 5 + after_attack = attack(var,pathfile3); + imwrite(after_attack,fullfile(pathfre,'ת.bmp')); +end +img = after_attack; +global pathfile5; +pathfile5=fullfile(pathfre, 'after_attack.bmp'); +imwrite(after_attack,pathfile5); +axes(handles.axes4); +imshow(img) + +% --- Executes on button press in pushbutton5.ˮӡȡ +function pushbutton5_Callback(hObject, eventdata, handles) +global pathfile4; +global pathfile5; +global k1; +global k2; +tiqu(pathfile5,k1,k2); +img = imread(pathfile4); +axes(handles.axes5); +imshow(img) + +% --- Executes on button press in pushbutton7.ˮӡԭ +function pushbutton7_Callback(hObject, eventdata, handles) + +global pathfile4; +global pathfre; +tmppath = fullfile(pathfre,'realmark.bmp'); +img = Arnold2(pathfile4); +imwrite(img,tmppath); +axes(handles.axes5); +imshow(img); + +function popupmenu2_CreateFcn(hObject, eventdata, handles) +% hObject handle to popupmenu2 (see GCBO) + +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + +function popupmenu2_DeleteFcn(hObject, eventdata, handles) diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/tiqu.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/tiqu.m" new file mode 100644 index 0000000..aa78a28 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/tiqu.m" @@ -0,0 +1,31 @@ +function [ water ] = tiqu(path3,k1,k2) + +watermark = imread(path3); +imshow(watermark); +U_2=watermark(:,:,2); +after_2=blkproc(U_2,[8,8],'dct2'); + +p=zeros(1,8); +for i=1:64 +for j=1:64 +x=(i-1)*8;y=(j-1)*8; +p(1)=after_2(x+1,y+8); +p(2)=after_2(x+2,y+7); +p(3)=after_2(x+3,y+6); +p(4)=after_2(x+4,y+5); +p(5)=after_2(x+5,y+4); +p(6)=after_2(x+6,y+3); +p(7)=after_2(x+7,y+2); +p(8)=after_2(x+8,y+1); +if corr2(p,k1)>corr2(p,k2) +water(i,j)=0; +else +water(i,j)=1; +end +end +end +global pathfile4; +global pathfre; +pathfile4=fullfile(pathfre, 'randmark.bmp'); +imwrite(water,pathfile4) +end \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/water.bmp" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/water.bmp" new file mode 100644 index 0000000..c1b1d6d Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\345\237\272\344\272\216DCT\345\217\230\346\215\242\347\232\204\346\225\260\345\255\227\346\260\264\345\215\260\347\256\227\346\263\225/water.bmp" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233.pdf" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233.pdf" new file mode 100644 index 0000000..3fc853b Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233.pdf" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\350\207\252\345\267\261\347\232\204\344\273\243\347\240\201matlab/my_lsb.m" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\350\207\252\345\267\261\347\232\204\344\273\243\347\240\201matlab/my_lsb.m" new file mode 100644 index 0000000..da8fc64 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2021/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\345\233\233--\345\233\276\345\203\217\346\260\264\345\215\260\347\256\227\346\263\225/\350\207\252\345\267\261\347\232\204\344\273\243\347\240\201matlab/my_lsb.m" @@ -0,0 +1,34 @@ + +Figure_name = 'mxt.png';%ëͮͼ +rgb_fig = imread(Figure_name); +gray = rgb2gray(rgb_fig);%ҶȾ +[m,n]=size(gray);%ҶȾ +key=randsrc(m,n,[0,1]);%ɼܾ +t_gray=ones(m,n)*nan;%Ԥȷռ +t_key=ones(m,n)*nan; +result_key=ones(m,n)*nan; +for i=1:m + for j=1:n + t_gray(i,j)=str2double(dec2bin(gray(i,j)));%ҶȾΪƣ˴ +% b=num2str(t_gray(i,j)); +% b=replaceBetween(b,size(b,2),size(b,2),num2str(key(i,j)));%ÿصֵĶλһλΪԿ + result_key(i,j)=bin2dec(num2str(bitor(t_gray(i,j),key(i,j))));%bitorܾͻҶȾƵһλ㣨LSB㷨IJ֣ +% t_key(i,j)=str2double(b); +% result_key(i,j)=bin2dec(b); + end +end +gray_result=mat2gray(result_key); +sub_key=double(gray)-result_key;%Ϊ˳ֳͼ΢С仯ֵͨ +%ͼ +subplot(2,2,1); +imshow('mxt.png'); +title('ԭʼɫͼ'); %չʾԭͼ +subplot(2,2,2);%121 +imshow(gray); +title('ԭʼҶͼ'); %չʾԭͼγɵĻҶͼ +subplot(2,2,3) +imshow(gray_result); +title('ˮӡܺĻҶͼ'); +subplot(2,2,4) +imshow(mat2gray(abs(sub_key))); +title('ˮӡ'); \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex1-RSA/main.py" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex1-RSA/main.py" new file mode 100644 index 0000000..c676a32 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex1-RSA/main.py" @@ -0,0 +1,96 @@ +import random +import math + + +# 生成一个素数 +def generate_prime_number(): + while True: + prime = random.randint(2 ** 10, 2 ** 11) + if is_prime(prime): + return prime + + +# 判断一个数是否为素数 +def is_prime(n): + if n < 2: + return False + for i in range(2, int(math.sqrt(n)) + 1): + if n % i == 0: + return False + return True + + +# 计算欧拉函数的值 +def euler_func(p, q): + return (p - 1) * (q - 1) + + +# 计算最大公因数 +def gcd(a, b): + while b: + a, b = b, a % b + return a + + +# 计算模反元素 +def mod_inverse(e, phi): + d = 0 + x1 = 0 + x2 = 1 + y1 = 1 + temp_phi = phi + + while e > 0: + temp1 = temp_phi // e + temp2 = temp_phi - temp1 * e + temp_phi = e + e = temp2 + + x = x2 - temp1 * x1 + y = d - temp1 * y1 + + x2 = x1 + x1 = x + d = y1 + y1 = y + + if temp_phi == 1: + return d + phi + + +# 生成密钥 +def generate_keypair(): + p = generate_prime_number() + q = generate_prime_number() + n = p * q + phi = euler_func(p, q) + e = random.randint(1, phi - 1) + while gcd(e, phi) != 1: + e = random.randint(1, phi - 1) + d = mod_inverse(e, phi) + return ((p, q), (e, n), (d, n)) + + +# 加密 +def encrypt(public_key, message): + e, n = public_key + cipher_text = [pow(ord(char), e, n) for char in message] + return cipher_text + + +# 解密 +def decrypt(private_key, cipher_text): + d, n = private_key + plain_text = [chr(pow(char, d, n)) for char in cipher_text] + return ''.join(plain_text) + + +message = input("输入原文:") +prime, public_key, private_key = generate_keypair() +cipher_text = encrypt(public_key, message) +print('素数对:', prime) +print('公钥:', public_key) +print('私钥:', private_key) +print('密文:', cipher_text) +plain_text = decrypt(private_key, cipher_text) +print('解密后的明文:', plain_text) diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex2-PicCopyCheck/Ex2_image.jpg" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex2-PicCopyCheck/Ex2_image.jpg" new file mode 100644 index 0000000..91d46c4 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex2-PicCopyCheck/Ex2_image.jpg" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex2-PicCopyCheck/main.py" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex2-PicCopyCheck/main.py" new file mode 100644 index 0000000..88f0dab --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex2-PicCopyCheck/main.py" @@ -0,0 +1,36 @@ +import numpy as np +import matplotlib.pyplot as plt +from skimage.feature import plot_matches +from skimage.feature import ORB +from skimage.color import rgb2gray +from skimage import io + + +def detect_copy_paste(image_path): + image = io.imread(image_path) + image_gray = rgb2gray(image) + sift = ORB(n_keypoints=200) + sift.detect_and_extract(image_gray) + keypoints = sift.keypoints + descriptors = sift.descriptors + + distance_matrix = np.sqrt(np.sum((descriptors[:, np.newaxis, :] ^ descriptors[np.newaxis, :, :]) ** 2, axis=-1)) + + threshold = 0.5 + matches = np.argwhere(distance_matrix < threshold) + + fig, ax = plt.subplots(nrows=1, ncols=1) + plt.gray() + plot_matches(ax, image_gray, image_gray, keypoints, keypoints, matches) + ax.axis('off') + ax.set_title("Copy-paste detection") + plt.show() + + if matches.size > 0: + print("Image has been copy-pasted") + else: + print("Image has not been copy-pasted") + + +if __name__ == '__main__': + detect_copy_paste("Ex2_image.jpg") diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex3-TextWaterMark/main.py" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex3-TextWaterMark/main.py" new file mode 100644 index 0000000..1253a29 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex3-TextWaterMark/main.py" @@ -0,0 +1,15 @@ +def embedded_watermark(text: str, mark_num: int): + mark_num_bin = bin(mark_num)[2:].zfill(len(text)) + mark_num_bin = list(mark_num_bin) + for i in range(len(text)): + if mark_num_bin[i] == '1': + print('\033[31m' + text[i] + '\033[0m', end='') + else: + print(text[i], end='') + print() + + +if __name__ == "__main__": + text = input("Input the text:") + mark_num = int(input("Input the mark number: ")) + embedded_watermark(text, mark_num) diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/3430.JPG" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/3430.JPG" new file mode 100644 index 0000000..6834660 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/3430.JPG" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/DCT.png" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/DCT.png" new file mode 100644 index 0000000..e19df80 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/DCT.png" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/DCT.py" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/DCT.py" new file mode 100644 index 0000000..f3b5f8d --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/DCT.py" @@ -0,0 +1,33 @@ +from PIL import Image +import numpy as np + + +def rgb2gray(rgb): + return np.dot(rgb[..., :3], [0.299, 0.587, 0.114]) + + +def dct2(block): + return np.array([[np.cos((2*i+1)*j*np.pi/16)*np.cos((2*k+1)*l*np.pi/16) for l in range(8)] for k in range(8) for j in range(8) for i in range(8)]) + + +def idct2(block): + return np.round(np.fft.ifftn(block, norm="ortho").real, 4) + + +image = Image.open("3430.JPG") +gray_image = rgb2gray(np.asarray(image)) +dct_blocks = np.zeros_like(gray_image) +for i in range(0, gray_image.shape[0], 8): + for j in range(0, gray_image.shape[1], 8): + dct_blocks[i:i + 8, j:j + 8] = dct2(gray_image[i:i + 8, j:j + 8]) +watermark = Image.open("watermark.png") +watermark = watermark.resize(image.size) +gray_watermark = rgb2gray(np.asarray(watermark)) +alpha = 0.1 +dct_blocks[4:12, 4:12] += alpha * gray_watermark[4:12, 4:12] +watermarked_image = np.zeros_like(gray_image) +watermark.save("dct_watermark.png") +for i in range(0, gray_image.shape[0], 8): + for j in range(0, gray_image.shape[1], 8): + watermarked_image[i:i + 8, j:j + 8] = idct2(dct_blocks[i:i + 8, j:j + 8]) +Image.fromarray(watermarked_image.astype('uint8')).save("dct_watermarked.png") \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/dct_watermark.png" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/dct_watermark.png" new file mode 100644 index 0000000..5a003fd Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/dct_watermark.png" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/gray.png" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/gray.png" new file mode 100644 index 0000000..2416047 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/gray.png" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/main.py" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/main.py" new file mode 100644 index 0000000..3c85509 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/main.py" @@ -0,0 +1,28 @@ +from PIL import Image + + +def add_watermark(image_file, watermark_file): + image = Image.open(image_file) + watermark = Image.open(watermark_file).convert("1") + width, height = image.size + watermark = watermark.resize((width, height)) + watermark.save("gray.png") + for x in range(width): + for y in range(height): + pixel = list(image.getpixel((x, y))) + if watermark.getpixel((x, y)): + pixel[-1] |= 1 + else: + pixel[-1] &= ~1 + image.putpixel((x, y), tuple(pixel)) + image.save("watermarked.png") + + +def test_lsb_watermarking(): + image_file = "3430.JPG" + watermark_file = "watermark.png" + add_watermark(image_file, watermark_file) + + +if __name__ == "__main__": + test_lsb_watermarking() \ No newline at end of file diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/watermark.png" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/watermark.png" new file mode 100644 index 0000000..7eadc02 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/watermark.png" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/watermarked.png" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/watermarked.png" new file mode 100644 index 0000000..671a5d0 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex4-ImgWatMark/watermarked.png" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex5-Voice/main.py" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex5-Voice/main.py" new file mode 100644 index 0000000..d346732 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex5-Voice/main.py" @@ -0,0 +1,72 @@ +import wave +import matplotlib.pyplot as plt +import numpy as np + + +def audio_to_binary(audio_file): + with open(audio_file, "r") as f: + binary_data = f.read() + return binary_data + + +def lsb_encrypt(audio_file, watertext): + binary_message = audio_to_binary(audio_file) + binary_key = bin(watertext)[2:] + padding_size = len(binary_key) - len(binary_message) % len(binary_key) + binary_message += "0" * padding_size + message_blocks = [binary_message[i:i + len(binary_key)] for i in range(0, len(binary_message), len(binary_key))] + encrypted_blocks = [] + for block in message_blocks: + block_int = int(block, 2) + key_int = int(binary_key, 2) + encrypted_int = block_int ^ key_int + encrypted_block = format(encrypted_int, '0{}b'.format(len(block)))[2:] + encrypted_blocks.append(encrypted_block) + encrypted_binary_message = "".join(encrypted_blocks) + encrypted_message = "" + for i in range(0, len(encrypted_binary_message), 8): + byte = encrypted_binary_message[i:i + 8] + char = chr(int(byte, 2)) + encrypted_message += char + return encrypted_message + + +def binary_to_wav(audio_file, watertext, output_file): + with wave.open(audio_file, 'rb') as wav_in: + num_channels = wav_in.getnchannels() + sample_width = wav_in.getsampwidth() + frame_rate = wav_in.getframerate() + binary_data = lsb_encrypt(audio_file, watertext) + with wave.open(output_file, 'wb') as wav_out: + wav_out.setnchannels(num_channels) + wav_out.setsampwidth(sample_width) + wav_out.setframerate(frame_rate) + wav_out.writeframes(bytes(int(binary_data[i:i + 8], 2) for i in range(0, len(binary_data), 8))) + + +def draw_wav(file1, file2): + with wave.open(file1, 'rb') as wav1: + frames1 = wav1.readframes(-1) + with wave.open(file2, 'rb') as wav2: + frames2 = wav2.readframes(-1) + samples1 = np.frombuffer(frames1, dtype='int16') + samples2 = np.frombuffer(frames2, dtype='int16') + plt.figure(figsize=(15, 5)) + plt.subplot(2, 1, 1) + plt.plot(samples1, 'b') + plt.title('Waveform of File1') + plt.xlabel('Samples') + plt.ylabel('Amplitude') + plt.subplot(2, 1, 2) + plt.plot(samples2, 'r') + plt.title('Waveform of File2') + plt.xlabel('Samples') + plt.ylabel('Amplitude') + plt.tight_layout() + plt.show() + + +if __name__ == '__main__': + watertext = "028121308" + binary_to_wav("test.wav", watertext, "watermarked_audio.wav") + draw_wav("test.wav", "watermarked_audio.wav") diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex5-Voice/test.wav" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex5-Voice/test.wav" new file mode 100644 index 0000000..3a8d070 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex5-Voice/test.wav" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex5-Voice/watermarked_audio.wav" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex5-Voice/watermarked_audio.wav" new file mode 100644 index 0000000..3a8d070 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex5-Voice/watermarked_audio.wav" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex6-VideoMark/ehan.mp4" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex6-VideoMark/ehan.mp4" new file mode 100644 index 0000000..165ed98 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex6-VideoMark/ehan.mp4" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex6-VideoMark/main.py" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex6-VideoMark/main.py" new file mode 100644 index 0000000..9ca7e76 --- /dev/null +++ "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex6-VideoMark/main.py" @@ -0,0 +1,32 @@ +import cv2 +import numpy as np + +def LSB_video_watermark(cover_video_path, watermark_path, output_video_path): + cap = cv2.VideoCapture(cover_video_path) + watermark = cv2.imread(watermark_path, cv2.IMREAD_GRAYSCALE) + fps = int(cap.get(cv2.CAP_PROP_FPS)) + width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) + height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) + watermark_resized = cv2.resize(watermark, (int(width/4), int(height/4))) + message = np.zeros((watermark_resized.size + 32 + 907200,), dtype=np.uint8) + message[:32] = np.frombuffer(np.array([width, height, watermark_resized.shape[0], watermark_resized.shape[1]], dtype=np.int64).tobytes(), dtype=np.uint8) + message[32:] = np.unpackbits(watermark_resized.flatten(), axis=0) + fourcc = cv2.VideoWriter_fourcc(*'mp4v') + out = cv2.VideoWriter(output_video_path, fourcc, fps, (width, height)) + while True: + ret, frame = cap.read() + if not ret: + break + encoded_frame = np.copy(frame) + for i, bit in enumerate(np.unpackbits(message)): + x = i % width + y = 1000 + encoded_frame[y, x] = (encoded_frame[y, x] & ~1) | bit + blurred = cv2.GaussianBlur(encoded_frame, (5, 5), 0) + sharpened = cv2.addWeighted(encoded_frame, 1.5, blurred, -0.5, 0) + out.write(sharpened) + cap.release() + out.release() + +if __name__ == '__main__': + LSB_video_watermark('ehan.mp4', 'watermark.png', 'output_video.mp4') diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex6-VideoMark/output_video.mp4" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex6-VideoMark/output_video.mp4" new file mode 100644 index 0000000..e9a2ede Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex6-VideoMark/output_video.mp4" differ diff --git "a/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex6-VideoMark/watermark.png" "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex6-VideoMark/watermark.png" new file mode 100644 index 0000000..7eadc02 Binary files /dev/null and "b/\346\225\260\345\255\227\345\206\205\345\256\271\345\256\211\345\205\250\345\256\236\351\252\214\346\212\245\345\221\212/2023/ex6-VideoMark/watermark.png" differ diff --git "a/\346\225\260\346\215\256\345\272\223\345\216\237\347\220\206/\346\225\260\346\215\256\345\272\223\345\216\237\347\220\206\350\200\203\345\215\267(1).pdf" "b/\346\225\260\346\215\256\345\272\223\345\216\237\347\220\206/\346\225\260\346\215\256\345\272\223\345\216\237\347\220\206\350\200\203\345\215\267(1).pdf" new file mode 100644 index 0000000..fba0f0d Binary files /dev/null and "b/\346\225\260\346\215\256\345\272\223\345\216\237\347\220\206/\346\225\260\346\215\256\345\272\223\345\216\237\347\220\206\350\200\203\345\215\267(1).pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/2020 A\345\215\267.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/2020 A\345\215\267.pdf" new file mode 100644 index 0000000..baeb965 Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/2020 A\345\215\267.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/2020 maybe.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/2020 maybe.pdf" new file mode 100644 index 0000000..d8279e4 Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/2020 maybe.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/2020 \350\276\205\344\277\256A\345\215\267.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/2020 \350\276\205\344\277\256A\345\215\267.pdf" new file mode 100644 index 0000000..692753d Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/2020 \350\276\205\344\277\256A\345\215\267.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/2022 A\345\215\267.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/2022 A\345\215\267.pdf" new file mode 100644 index 0000000..13723b5 Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/2022 A\345\215\267.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/CMakeLists.txt" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/CMakeLists.txt" new file mode 100644 index 0000000..2c813f1 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/CMakeLists.txt" @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.24) +project(ex1_parity_change) + +set(CMAKE_CXX_STANDARD 17) + +add_executable(ex1 combine.cpp parity_change.cpp ListMax.cpp ListScore.cpp DecimalConvert.cpp Palindrome.cpp CircularQueue.cpp HospitalSys.cpp) diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/CircularQueue.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/CircularQueue.cpp" new file mode 100644 index 0000000..f53f653 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/CircularQueue.cpp" @@ -0,0 +1,46 @@ +#include +#define QueueSize 10 +typedef int ElementType; +typedef struct{ + ElementType Data[QueueSize]; + int front; + int rear; +}SqQueue; +void PrintQueue(SqQueue qu) { + int i = qu.front; + printf("Queue:"); + while (i != qu.rear) { + printf("%d ", qu.Data[i]); + i = (i + 1) % QueueSize; + } + printf("\n"); +} +int main(){ + ElementType a,x; + SqQueue qu; + qu.rear=qu.front=0; + printf("Input queue(end with 0, InQueue with positive, DeQueue with negative)\n"); + scanf("%d",&a); + while(a!=0){ + if(a>0){ + if((qu.rear+1)%QueueSize==qu.front){ + printf("Full Queue!\n"); + PrintQueue(qu); + return 0; + } + qu.Data[qu.rear]=a; + qu.rear=(qu.rear+1)%QueueSize; + }else{ + if(qu.rear==qu.front){ + printf("NUll Queue!\n"); + return 0; + } + x=qu.Data[qu.front]; + qu.front=(qu.front+1)%QueueSize; + printf("%dDeQueue\n",x); + } + scanf("%d",&a); + } + PrintQueue(qu); + return 0; +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/DecimalConvert.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/DecimalConvert.cpp" new file mode 100644 index 0000000..be6eac4 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/DecimalConvert.cpp" @@ -0,0 +1,50 @@ +#include +#define MaxSize 100 +typedef char ElemType; +typedef struct{ + ElemType data[MaxSize]; + int top; +} SqStack; +int trans(int num,int sys,char string[]){ + SqStack str; + char ch; + int r,i=0; + str.top=-1; + if(num<=-1){ + printf("Negative number! "); + return 0; + } + while(num!=0){ + r=num%sys; + ch=r+(r<10?'0':'A'-10); + str.top++; + str.data[str.top]=ch; + num/=sys; + } + while(str.top!=-1){ + string[i++]=str.data[str.top]; + str.top--; + } + string[i]='\0'; + return 1; +} +int main(){ + char str[10]; + int num,t; + printf("Input the number and non-negative:"); + scanf("%d",&num); + t=trans(num,8,str); + if(t==0){ + printf("ERROR\n"); + }else{ + printf("OCT:%s\n",str); + } + t=trans(num,16,str); + if(t==0){ + printf("ERROR\n"); + } + else{ + printf("HEX:%s\n",str); + } + return 0; +} diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/HospitalSys.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/HospitalSys.cpp" new file mode 100644 index 0000000..348d4e5 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/HospitalSys.cpp" @@ -0,0 +1,72 @@ +#include +#include +#include "malloc.h" + +typedef char ElemType; +typedef struct QNode +{ + ElemType data[15]; + struct QNode *next; +} QNode,*QueuePtr; +typedef struct{ + QueuePtr front; + QueuePtr rear; +}LinkQueue; +int main() +{ + int choice,flag=1; + LinkQueue lq; + QNode *s,*p; + char name[15]; + lq.front=( QueuePtr)malloc(sizeof(QNode)); + lq.front->next=NULL; + lq.rear=lq.front; + while(flag==1) + { + printf("1.Ŷ 2. 3.鿴Ŷ 0.°\n"); + printf("ѡ"); + scanf("%d",&choice); + switch(choice) + { + case 0: + if (lq.front!=lq.rear) printf(">>°ˣŶӵĻ߸ҽ\n"); + flag=0; break; + case 1: + printf("뻼"); + scanf("%s",name); + s=( QueuePtr)malloc(sizeof(QNode)); + strcpy(s->data,name); + s->next=NULL; + lq.rear->next=s; lq.rear=s; + break; + case 2: + if (lq.front==lq.rear) + printf(">>ûŶӵĻ\n"); + else + { + s=lq.front->next; + lq.front->next=s->next; + if (lq.rear==s) lq.rear=lq.front; + printf("%>>s\n",s->data); + free(s); + } + break; + case 3: + if (lq.front==lq.rear) + printf(">>ûŶӵĻ\n"); + else + { + p=lq.front->next; + printf(">>ŶӵĻߣ"); + while(p!=NULL) + { + printf("%s ",p->data); + p=p->next; + } + printf("\n"); + } + break; + } + } + return 0; +} diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/ListMax.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/ListMax.cpp" new file mode 100644 index 0000000..d3e5864 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/ListMax.cpp" @@ -0,0 +1,81 @@ +#include +#include +#define N 1000 +typedef int ElementType; +typedef struct LNode{ + ElementType data; + struct LNode *Next; +}LNode,*LinkList; +void CreateLink(LinkList &h, ElementType a[], int n) +{ + LNode *s, *r; int i; + h = (LNode *)malloc(sizeof(LNode)); + r = h; + for (i = 0; i < n; i++) + { + s = (LNode *)malloc(sizeof(LNode)); + s->data = a[i]; + r->Next = s; + r = s; + } + r->Next = NULL; +} +int MaxNode(LinkList h){ + int j,k; + LNode *p,*q; + if(h->Next==NULL){ + return 0; + } + q=h->Next; + p=q->Next; + k=1; + j=2; + while(p!=NULL){ + if(p->data>q->data){ + q=p; + k=j; + } + p=p->Next; + j++; + } + return k; +} +int Print(LinkList h){ + LNode *q; + if(h->Next==NULL){ + return 0; + } + q=h->Next; + while(q!=NULL){ + printf("%d ",q->data); + q=q->Next; + } +} +int main(){ + LinkList head; + ElementType a[N]; + int i,k,num,flag=0; + printf("Enter the size of the list:\n"); + scanf("%d",&num); + fflush(stdin); + printf("Input a list of number:\n"); + for(i = 0; i < num; i++){ + scanf("%d",&a[i]); + for (int j = 0; j < i; ++j) { + if(a[i]==a[j]){ + flag = 1; + i--; + num--; + } + } + } + if(flag == 1) printf("Anything repeated and deleted\n"); + CreateLink(head,a,num); + printf("Elements in list:\n"); + Print(head); + printf("\n"); + printf("The No. of the max element\n"); + k=MaxNode(head); + printf("%d",k); + return 0; +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/ListScore.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/ListScore.cpp" new file mode 100644 index 0000000..48d20e7 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/ListScore.cpp" @@ -0,0 +1,61 @@ +#include +#include +typedef int ElemType; +typedef struct node +{ + ElemType data; + struct node *next; +} StudNode, *StudLink; + +void create(StudLink &sl) +{ + int i, n, score; + StudNode *s, *r; + sl = (StudNode*)malloc(sizeof(StudNode)); + r = sl; + printf("Input the number of students:\n"); + scanf("%d", &n); + fflush(stdin); + printf("Input scores of students:\n"); + for (i = 0; i < n; i++){ + s = (StudNode*)malloc(sizeof(StudNode)); + scanf("%d", &score); + s->data = score; + r->next = s; + r = s; + } + r->next = NULL; +} +int output(StudLink sl) +{ + StudNode *q; + if (sl->next == NULL) return 0; + q = sl->next; + while (q != NULL) + { + printf("%d\t", q->data); + q = q->next; + } +} +int count(StudLink sl) +{ + int n = 0; + StudNode *p = sl->next; + while (p != NULL) + { + if (p->data < 60) n++; + p = p->next; + } + return n; +} +int main() +{ + int n; + StudLink h; + create(h); + n = count(h); + printf("The list of their scores:\n"); + output(h); + printf("\nThe number of fail students:\n%d", n); + return 0; +} diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/Palindrome.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/Palindrome.cpp" new file mode 100644 index 0000000..b7f0a13 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/Palindrome.cpp" @@ -0,0 +1,46 @@ +#include +#include +#define ElementType char +typedef struct lineStack{ + ElementType data; + struct lineStack * next; +}lineStack; +lineStack* push(lineStack * stack,char a){ + lineStack * line=(lineStack*)malloc(sizeof(lineStack)); + line->data=a; + line->next=stack; + stack=line; + return stack; +} +int palindrome(ElementType X[]){ + lineStack * stack=NULL; + int i; + for(i=0;X[i]!='\0';i++){ + stack=push(stack,X[i]); + } + char str; + lineStack *p; + for(i=0;X[i]!='\0'&&stack!=NULL;i++){ + p=stack; + str=p->data; + stack=stack->next; + free(p); + if(X[i]!=str){ + return 0; + } + } + return 1; +} +int main(){ + char ch[20]; + printf("Input a string:\n"); + scanf("%s",&ch); + int i=palindrome(ch); + if(i==1){ + printf("%s is palindrome\n",ch); + } + else{ + printf("%s is not palindrome\n",ch); + } + return 0; +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/combine.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/combine.cpp" new file mode 100644 index 0000000..7f44936 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/combine.cpp" @@ -0,0 +1,108 @@ +#include +#define MAXSIZE 100 +typedef int ElemType; +typedef struct +{ + ElemType data[MAXSIZE]; + int Len; +}SqList; +void InitList(SqList &sq) +{ + sq={0}; + sq.Len=0; +} +void CreateList(SqList &sq, int n) +{ + ElemType x; + for (int i = 0; i < n; i++) { + scanf("%d", &x); + sq.data[i] = x; + sq.Len++; + } + fflush(stdin); +} +void merge(SqList sqA,SqList sqB,SqList &sqC) +{ + int i=0,j=0,k=0,flag=0; + while(isqB.data[j]) + { + sqC.data[k]=sqB.data[j]; + j++; + } + else + { + sqC.data[k]=sqA.data[i]; + i++; + j++; + flag=1; + } + k++; + sqC.Len++; + } + while(i=sq.data[i]) + { + printf("Not in ascending order\n"); + InitList(sq); + printf("Enter the elements again:"); + CreateList(sq,j); + break; + } + i++; + } +} +int main() { + SqList sqA,sqB,sqC; + int len; + InitList(sqA); + InitList(sqB); + InitList(sqC); + printf("Enter the size of the table A:"); + scanf("%d",&len); + fflush(stdin); + printf("Enter the elements of the table A:"); + CreateList(sqA,len); + OrderCheck(sqA); + printf("Enter the size of the table B:"); + scanf("%d",&len); + fflush(stdin); + printf("Enter the elements of the table B:"); + CreateList(sqB,len); + OrderCheck(sqB); + merge(sqA,sqB,sqC); + for (int i = 0; i < sqC.Len; ++i) + { + printf("%5d",sqC.data[i]); + } + return 0; +} diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/parity_change.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/parity_change.cpp" new file mode 100644 index 0000000..49c3e81 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex1/parity_change.cpp" @@ -0,0 +1,45 @@ +#include +#define MAXSIZE 20 +typedef int ElemType; +typedef struct { + ElemType data[MAXSIZE]; + int len; +}SqList; +void move(SqList &sq) { + ElemType t; + int i=0,j=sq.len-1; + while(i<=j) { + while(sq.data[i]%2==1) i++; + while(sq.data[j]%2==0) j--; + if(i +#include + +typedef struct node{ + char data ; + struct node * lchild; + struct node * rchild; +}BiTree; + +BiTree * CreatTree(){ + BiTree *t; + char ch ; + ch = getchar(); + if (ch != '#'){ + t = (BiTree *)malloc(sizeof(BiTree)); + t ->data = ch ; + t->lchild = CreatTree(); + t->rchild = CreatTree(); + } + else{ + t=NULL; + } + return t; +} + +int Count(BiTree * top){ + if(top == NULL){ + return 0; + } + else if ((top->lchild==NULL) && (top->rchild==NULL)){ + return 1; + } + else{ + return Count(top->lchild)+Count(top->rchild); + } +} + +void Preorder(BiTree * top ){ + if(top != NULL){ + printf("%c ",top->data); + Preorder(top->lchild); + Preorder(top->rchild); + } +} + +int main(){ + BiTree * top = NULL; + printf("ȸ"); + top = CreatTree(); + printf("ȸ"); + Preorder(top); + putchar('\n'); + printf("Ҷӽڵĸ %d\n",Count(top)); + return 0; +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex2/main.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex2/main.cpp" new file mode 100644 index 0000000..55427ba --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex2/main.cpp" @@ -0,0 +1,66 @@ +#include +using namespace std; + +typedef char ElemType; +typedef struct node { + ElemType data; + struct node* LChild, * RChild; +}BNode,*BTree; + +void InitBTree(BTree& BT) { + BT = NULL; +} + +void CreateBTree(BTree& BT) { + ElemType data; + cin >> data; + if (data == '#') + BT = NULL; + else { + BT = (BTree)malloc(sizeof(BNode)); + BT->data = data; + CreateBTree(BT->LChild); + CreateBTree(BT->RChild); + } +} + +void PreOrder(BTree p) { + if (p != NULL) { + cout << p->data << "\t"; + PreOrder(p->LChild); + PreOrder(p->RChild); + } +} + +void InOrder(BTree p) { + if (p != NULL) { + InOrder(p->LChild); + cout << p->data << "\t"; + InOrder(p->RChild); + } +} + +void PostOrder(BTree p) { + if (p != NULL) { + PostOrder(p->LChild); + PostOrder(p->RChild); + cout << p->data << "\t"; + } +} + +int main() { + BTree p; + InitBTree(p); + cout << "Input the preorder of the BTree:"; + CreateBTree(p); + cout << "The preorder of the BTree:\n"; + PreOrder(p); + cout << endl; + cout << "The inorder of the BTree:\n"; + InOrder(p); + cout << endl; + cout << "The postorder of the BTree:\n"; + PostOrder(p); + cout << endl; + return 0; +} diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex2/\345\256\236\351\252\214\344\272\214.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex2/\345\256\236\351\252\214\344\272\214.pdf" new file mode 100644 index 0000000..9c47d23 Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex2/\345\256\236\351\252\214\344\272\214.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex3/CMakeLists.txt" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex3/CMakeLists.txt" new file mode 100644 index 0000000..8496c39 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex3/CMakeLists.txt" @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.24) +project(ex3) + +set(CMAKE_CXX_STANDARD 17) + +add_executable(ex3 main.cpp dfs.cpp) diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex3/dfs.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex3/dfs.cpp" new file mode 100644 index 0000000..dbeb852 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex3/dfs.cpp" @@ -0,0 +1,106 @@ +#include +#include + +#define MaxVertexNum 100 +typedef int Vertex; +typedef int WeightType; +typedef char DataType; +int Visited[MaxVertexNum]; +typedef struct ENode *PtrToENode; +struct ENode{ + Vertex V1, V2; + WeightType Weight; +}; +typedef PtrToENode Edge; + +typedef struct AdjVNode *PtrToAdjVNode; +struct AdjVNode{ + Vertex AdjV; + WeightType Weight; + PtrToAdjVNode Next; +}; + +typedef struct Vnode{ + PtrToAdjVNode FirstEdge; + DataType Data; +} AdjList[MaxVertexNum]; + +typedef struct GNode *PtrToGNode; +struct GNode{ + int Nv; + int Ne; + AdjList G; +}; +typedef PtrToGNode LGraph; + +LGraph CreateGraph( int VertexNum ) +{ + Vertex V; + LGraph Graph; + + Graph = (LGraph)malloc( sizeof(struct GNode) ); + Graph->Nv = VertexNum; + Graph->Ne = 0; + for (V=0; VNv; V++) + Graph->G[V].FirstEdge = NULL; + + return Graph; +} + +void InsertEdge( LGraph Graph, Edge E ) +{ + PtrToAdjVNode NewNode; + NewNode = (PtrToAdjVNode)malloc(sizeof(struct AdjVNode)); + NewNode->AdjV = E->V2; + NewNode->Weight = E->Weight; + NewNode->Next = Graph->G[E->V1].FirstEdge; + Graph->G[E->V1].FirstEdge = NewNode; + NewNode = (PtrToAdjVNode)malloc(sizeof(struct AdjVNode)); + NewNode->AdjV = E->V1; + NewNode->Weight = E->Weight; + NewNode->Next = Graph->G[E->V2].FirstEdge; + Graph->G[E->V2].FirstEdge = NewNode; +} + +LGraph BuildGraph() +{ + LGraph Graph; + Edge E; + int Nv, i; + printf("붥"); + scanf("%d", &Nv); + Graph = CreateGraph(Nv); + printf(""); + scanf("%d", &(Graph->Ne)); + if ( Graph->Ne != 0 ) { + E = (Edge)malloc(sizeof(struct ENode)); + printf("(㣬յ㣬Ȩ)\n"); + for (i=0; iNe; i++) { + + scanf("%d %d %d", &E->V1, &E->V2, &E->Weight); + InsertEdge( Graph, E ); + } + } + return Graph; +} +void Visit( Vertex V ) +{ + printf("ڷʶ%d\n", V); +} + +void DFS( LGraph Graph, Vertex V, void (*Visit)(Vertex) ) +{ + PtrToAdjVNode W; + + Visit( V ); + Visited[V] = true; + + for( W=Graph->G[V].FirstEdge; W; W=W->Next ) + if ( !Visited[W->AdjV] ) + DFS( Graph, W->AdjV, Visit ); +} +int main(){ + LGraph Graph=BuildGraph(); + DFS(Graph,1,Visit); + return 0; +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex3/main.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex3/main.cpp" new file mode 100644 index 0000000..81d1fb8 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex3/main.cpp" @@ -0,0 +1,105 @@ +#include +#include + +#define MaxVertexNum 100 +#define INFINITY 65535 +typedef int Vertex; +typedef int WeightType; +typedef char DataType; + +typedef struct ENode *PtrToENode; +struct ENode{ + Vertex V1, V2; + WeightType Weight; +}; +typedef PtrToENode Edge; + +typedef struct GNode *PtrToGNode; +struct GNode{ + int Nv; + int Ne; + WeightType G[MaxVertexNum][MaxVertexNum]; + DataType Data[MaxVertexNum]; +}; +typedef PtrToGNode MGraph; +MGraph CreateGraph( int VertexNum ) +{ + Vertex V, W; + MGraph Graph; + + Graph = (MGraph)malloc(sizeof(struct GNode)); + Graph->Nv = VertexNum; + Graph->Ne = 0; + for (V=0; VNv; V++) + for (W=0; WNv; W++) + Graph->G[V][W] = INFINITY; + + return Graph; +} + +void InsertEdge( MGraph Graph, Edge E ) +{ + Graph->G[E->V1][E->V2] = E->Weight; + Graph->G[E->V2][E->V1] = E->Weight; +} + +MGraph BuildGraph() +{ + MGraph Graph; + Edge E; + int Nv, i; + printf("붥"); + scanf("%d", &Nv); + Graph = CreateGraph(Nv); + printf("ߵĸ"); + scanf("%d", &(Graph->Ne)); + if ( Graph->Ne != 0 ) { + E = (Edge)malloc(sizeof(struct ENode)); + printf("Ϣ( յ Ȩ)\n"); + for (i=0; iNe; i++) { + scanf("%d %d %d", &E->V1, &E->V2, &E->Weight); + InsertEdge(Graph, E); + } + } + + return Graph; +} + +void ShowGraph(MGraph Graph){ + printf("ڽӾΪ:\n"); + int i,j; + for(i=0;iNv;i++){ + for(j=0;jNv;j++){ + if(Graph->G[i][j]==INFINITY){ + printf("INF\t"); + }else{ + printf("%d\t",Graph->G[i][j]); + } + } + printf("\n"); + } +} + +void NodeDegree(MGraph Graph){ + MGraph temp=Graph; + int i,j; + int count; + for(i=0;iNv;i++){ + count=0; + for(j=0;jNv;j++){ + if(temp->G[i][j]!=INFINITY){ + count++; + } + } + printf("%d\n",count); + } + +} +int main(){ + MGraph Graph=BuildGraph(); + ShowGraph(Graph); + printf("\n"); + printf("ĶΪ():\n"); + NodeDegree(Graph); + return 0; +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex3/\345\256\236\351\252\214\344\270\211.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex3/\345\256\236\351\252\214\344\270\211.pdf" new file mode 100644 index 0000000..94c55e1 Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex3/\345\256\236\351\252\214\344\270\211.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex4/CMakeLists.txt" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex4/CMakeLists.txt" new file mode 100644 index 0000000..af8a1f8 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex4/CMakeLists.txt" @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.24) +project(ex4) + +set(CMAKE_CXX_STANDARD 17) + +add_executable(ex4 main.cpp OrderTree.cpp) diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex4/OrderTree.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex4/OrderTree.cpp" new file mode 100644 index 0000000..94acdb5 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex4/OrderTree.cpp" @@ -0,0 +1,44 @@ +#include +#include +typedef int ElementType; +typedef struct BinSearchTreeNode{ + ElementType data; + struct BinSearchTreeNode *left; + struct BinSearchTreeNode *right; +}BSTNode,*PNode; +PNode insertBST(ElementType data,PNode root){ + if(root == NULL) + { + root = (PNode)malloc(sizeof(BSTNode)); + root->data = data; + root->left = NULL; + root->right = NULL; + printf("%d ",data); + return root; + } + if(data < root->data) + root->left = insertBST(data,root->left); + else if(data > root->data) + root->right = insertBST(data,root->right); + return root; +} +void print(PNode root){ + if(root!=NULL){ + print(root->left); + printf("%d ",root->data); + print(root->right); + } +} +int main(){ + ElementType data[8]={16,5,17,29,11,3,15,20}; + int i; + PNode root=NULL; + for(i=0;i<8;i++){ + root=insertBST(data[i],root); + } + printf("ȫ\n"); + printf("Ϊ:\n"); + print(root); + printf("\n"); + return 0; +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex4/main.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex4/main.cpp" new file mode 100644 index 0000000..fa77f07 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex4/main.cpp" @@ -0,0 +1,81 @@ +#include +#include +typedef int ElementType; +typedef struct LNode *List; +struct LNode{ + ElementType Data[20]; + int last; +}; + +int BinSearch(List L,ElementType X){ + int left; + int right; + int mid; + if(L->last){ + left=0; + right=L->last; + while(left<=right){ + mid=(left+right)/2; + if(X==L->Data[mid]){ + return mid; + }else if(X>L->Data[mid]){ + left=mid+1; + }else if(XData[mid]){ + right=mid-1; + } + } + return -1; + } + return -1; +} +List MakeEmpty(){ + List PtrL; + PtrL=(List)malloc(sizeof(struct LNode)); + PtrL->last=-1; + return PtrL; +} +void Insert(List PtrL,int length){ + int i; + ElementType X; + printf("еԪ\n"); + for(i=0;iData[i]=X; + PtrL->last++; + } +} +void OrderCheck(List &L, int length) +{ + int i=1; + while(ilast) + { + if(L->Data[i-1]>=L->Data[i]) + { + printf("\n"); + printf(""); + Insert(L,length); + break; + } + i++; + } +} +int main(){ + List PtrL; + PtrL=MakeEmpty(); + int length; + printf("еij\n"); + scanf("%d",&length); + Insert(PtrL,length); + OrderCheck(PtrL,length); + ElementType target; + printf("ҪѰҵԪ\n"); + scanf("%d",&target); + int position; + position=BinSearch(PtrL,target); + if(position!=-1){ + printf("Ԫڵ%dλ\n",position+1); + }else{ + printf("ûҵ\n"); + } + return 0; +} diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex4/\345\256\236\351\252\214\345\233\233.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex4/\345\256\236\351\252\214\345\233\233.pdf" new file mode 100644 index 0000000..1385021 Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex4/\345\256\236\351\252\214\345\233\233.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/CMakeLists.txt" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/CMakeLists.txt" new file mode 100644 index 0000000..9475499 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/CMakeLists.txt" @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.24) +project(ex5) + +set(CMAKE_CXX_STANDARD 17) + +add_executable(ex5 main.cpp quicksort.cpp selectsort.cpp) diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/main.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/main.cpp" new file mode 100644 index 0000000..8f9f7bc --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/main.cpp" @@ -0,0 +1,55 @@ +#include +#include +typedef int ElementType; +typedef struct LNode *List; +struct LNode{ + ElementType Data[20]; + int Last; +}; +List Creat(){ + List PtrL; + PtrL = (List)malloc(sizeof(struct LNode)); + PtrL->Last = -1; + return PtrL; +} +void Insert(ElementType X,int i,List PtrL){ + PtrL->Data[i]=X; + PtrL->Last++; +} +void ShellSort(List PtrL){ + int i=0,j=0; + int temp=0; + int incre=0; + for(incre=(PtrL->Last+1)/2;incre>0;incre/=2){ + for(i=incre;iLast+1;i++){ + temp=PtrL->Data[i]; + j=i-incre; + while(j>=0 && tempData[j]){ + PtrL->Data[j+incre]=PtrL->Data[j]; + j-=incre; + } + PtrL->Data[j+incre]=temp; + } + } +} +int main(){ + List SqList=Creat(); + int i, data=0, num; + printf("ݸ\n"); + scanf("%d",&num); + printf("ݣ\n"); + for(i=0;iData[i]); + } + printf("\nShellΪ\n"); + ShellSort(SqList); + for(i=0;iData[i]); + } + return 0; +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/quicksort.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/quicksort.cpp" new file mode 100644 index 0000000..02c895e --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/quicksort.cpp" @@ -0,0 +1,63 @@ +#include +#include +typedef int ElementType; +typedef struct LNode *List; +struct LNode{ + ElementType Data[20]; + int Last; +}; +List Creat(){ + List PtrL; + PtrL = (List)malloc(sizeof(struct LNode)); + PtrL->Last = -1; + return PtrL; +} +void Insert(ElementType X,int i,List PtrL){ + PtrL->Data[i]=X; + PtrL->Last++; +} +void QuickSort(List PtrL, int start, int end) +{ + if (start > end) + return; + int tmp = PtrL->Data[start]; + int i = start; + int j = end; + while (i != j) { + while (PtrL->Data[j] >= tmp && j > i) + j--; + while (PtrL->Data[i] <= tmp && j > i) + i++; + if (j > i) { + int t = PtrL->Data[i]; + PtrL->Data[i] = PtrL->Data[j]; + PtrL->Data[j] = t; + } + } + PtrL->Data[start] = PtrL->Data[i]; + PtrL->Data[i] = tmp; + QuickSort(PtrL, start, i - 1); + QuickSort(PtrL, i + 1, end); +} +int main(){ + List SqList=Creat(); + int i, data=0, num; + printf("ݸ\n"); + scanf("%d",&num); + printf("ݣ\n"); + for(i=0;iData[i]); + } + printf("\n:\n"); + QuickSort(SqList, 0, num - 1); + for(i=0;iData[i]); + } + return 0; +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/selectsort.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/selectsort.cpp" new file mode 100644 index 0000000..9fcc0da --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/selectsort.cpp" @@ -0,0 +1,55 @@ +#include +#include +typedef int ElementType; +typedef struct LNode *List; +struct LNode{ + ElementType Data[20]; + int Last; +}; +List Creat(){ + List PtrL; + PtrL = (List)malloc(sizeof(struct LNode)); + PtrL->Last = -1; + return PtrL; +} +void Insert(ElementType X,int i,List PtrL){ + PtrL->Data[i]=X; + PtrL->Last++; +} +void StraightSelectionSort(List PtrL){ + int i=0,j=0; + int temp=0; + int index; + for(i=0;iLast;i++){ + index=i; + for(j=i+1;jLast+1;j++){ + if(PtrL->Data[index]>PtrL->Data[j]){ + index=j; + } + } + temp=PtrL->Data[i]; + PtrL->Data[i]=PtrL->Data[index]; + PtrL->Data[index]=temp; + } +} +int main(){ + List SqList=Creat(); + int i, data=0, num; + printf("ݸ\n"); + scanf("%d",&num); + printf("ݣ\n"); + for(i=0;iData[i]); + } + printf("\nֱѡ:\n"); + StraightSelectionSort(SqList); + for(i=0;iData[i]); + } + return 0; +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/\345\256\236\351\252\214\344\272\224-\346\250\241\346\235\277.doc" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/\345\256\236\351\252\214\344\272\224-\346\250\241\346\235\277.doc" new file mode 100644 index 0000000..f547af7 Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/\345\256\236\351\252\214\344\272\224-\346\250\241\346\235\277.doc" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/\345\256\236\351\252\214\344\272\224-\346\250\241\346\235\277.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/\345\256\236\351\252\214\344\272\224-\346\250\241\346\235\277.pdf" new file mode 100644 index 0000000..455cf76 Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/ex5/\345\256\236\351\252\214\344\272\224-\346\250\241\346\235\277.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/\343\200\212\347\256\227\346\263\225\344\270\216\346\225\260\346\215\256\347\273\223\346\236\204\343\200\213\345\256\236\351\252\21422-02.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/\343\200\212\347\256\227\346\263\225\344\270\216\346\225\260\346\215\256\347\273\223\346\236\204\343\200\213\345\256\236\351\252\21422-02.pdf" new file mode 100644 index 0000000..dab78ae Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/\343\200\212\347\256\227\346\263\225\344\270\216\346\225\260\346\215\256\347\273\223\346\236\204\343\200\213\345\256\236\351\252\21422-02.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\346\234\237\346\234\253\345\244\215\344\271\240\357\274\2102023\345\271\264\357\274\211.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\346\234\237\346\234\253\345\244\215\344\271\240\357\274\2102023\345\271\264\357\274\211.pdf" new file mode 100644 index 0000000..cdf1318 Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\346\234\237\346\234\253\345\244\215\344\271\240\357\274\2102023\345\271\264\357\274\211.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2541\347\253\240 \347\273\252\350\256\272.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2541\347\253\240 \347\273\252\350\256\272.pdf" new file mode 100644 index 0000000..970c2d3 Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2541\347\253\240 \347\273\252\350\256\272.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2542\347\253\240 \347\272\277\346\200\247\350\241\250.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2542\347\253\240 \347\272\277\346\200\247\350\241\250.pdf" new file mode 100644 index 0000000..8e5397f Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2542\347\253\240 \347\272\277\346\200\247\350\241\250.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2543\347\253\240 \346\240\210.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2543\347\253\240 \346\240\210.pdf" new file mode 100644 index 0000000..c8768ee Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2543\347\253\240 \346\240\210.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2544\347\253\240 \351\230\237\345\210\227.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2544\347\253\240 \351\230\237\345\210\227.pdf" new file mode 100644 index 0000000..2448a3a Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2544\347\253\240 \351\230\237\345\210\227.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2546\347\253\240 \346\240\221\345\222\214\344\272\214\345\217\211\346\240\221.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2546\347\253\240 \346\240\221\345\222\214\344\272\214\345\217\211\346\240\221.pdf" new file mode 100644 index 0000000..8859eab Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2546\347\253\240 \346\240\221\345\222\214\344\272\214\345\217\211\346\240\221.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2547\347\253\240 \345\233\276.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2547\347\253\240 \345\233\276.pdf" new file mode 100644 index 0000000..f35ba1d Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2547\347\253\240 \345\233\276.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2548\347\253\240 \346\237\245\346\211\276.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2548\347\253\240 \346\237\245\346\211\276.pdf" new file mode 100644 index 0000000..ef251b8 Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2548\347\253\240 \346\237\245\346\211\276.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2549\347\253\240 \346\216\222\345\272\217.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2549\347\253\240 \346\216\222\345\272\217.pdf" new file mode 100644 index 0000000..332820f Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\347\254\2549\347\253\240 \346\216\222\345\272\217.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\350\257\276\345\206\205\345\256\236\351\252\214\345\244\247\347\272\262-\347\256\227\346\263\225\344\270\216\346\225\260\346\215\256\347\273\223\346\236\204.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\350\257\276\345\206\205\345\256\236\351\252\214\345\244\247\347\272\262-\347\256\227\346\263\225\344\270\216\346\225\260\346\215\256\347\273\223\346\236\204.pdf" new file mode 100644 index 0000000..123f03b Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\344\273\266-2019-1-3/\350\257\276\345\206\205\345\256\236\351\252\214\345\244\247\347\272\262-\347\256\227\346\263\225\344\270\216\346\225\260\346\215\256\347\273\223\346\236\204.pdf" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/1.txt" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/1.txt" new file mode 100644 index 0000000..d39b1ed --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/1.txt" @@ -0,0 +1 @@ +helloworldhelloworldhelloworldhelloworld \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/contacts.txt" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/contacts.txt" new file mode 100644 index 0000000..ec319d7 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/contacts.txt" @@ -0,0 +1,10 @@ +-1 -1 -1 +136011231241 user ·333 +-1 -1 -1 +-1 -1 -1 +-1 -1 -1 +1234567890 +9876543210 Ϻ +-1 -1 -1 +-1 -1 -1 +-1 -1 -1 diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/data.txt" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/data.txt" new file mode 100644 index 0000000..56ba64e --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/data.txt" @@ -0,0 +1,8 @@ +7 +d 4 +e 4 +h 4 +l 12 +o 8 +r 4 +w 4 diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex3-EightQueen.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex3-EightQueen.cpp" new file mode 100644 index 0000000..c14e862 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex3-EightQueen.cpp" @@ -0,0 +1,54 @@ +#include +#define N 8 + +void printBoard(int board[N][N]) { + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + printf("%c ", board[i][j] ? 'Q' : '-'); + } + printf("\n"); + } +} + +bool isSafe(int board[N][N], int row, int col) { + int i, j; + // + for (i = 0; i < row; i++) + if (board[i][col]) + return false; + // ϶Խ + for (i = row, j = col; i >= 0 && j >= 0; i--, j--) + if (board[i][j]) + return false; + // ϶Խ + for (i = row, j = col; i >= 0 && j < N; i--, j++) + if (board[i][j]) + return false; + return true; +} + +bool solveNQueens(int board[N][N], int row) { + if (row == N) + return true; + for (int col = 0; col < N; col++) { + if (isSafe(board, row, col)) { + board[row][col] = 1; + if (solveNQueens(board, row + 1)) + return true; + board[row][col] = 0; + } + } + return false; +} + +int main() { + int board[N][N] = {0}; + printf("ڵһѡһΪʺijʼ꣬꣺\n"); + int x; + scanf("%d", &x); + board[0][x] = 1; + if (solveNQueens(board, 1)) { + printBoard(board); + } + return 0; +} diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex3-EightQueen.exe" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex3-EightQueen.exe" new file mode 100644 index 0000000..0750bfe Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex3-EightQueen.exe" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex4-Flight.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex4-Flight.cpp" new file mode 100644 index 0000000..9caa547 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex4-Flight.cpp" @@ -0,0 +1,250 @@ +#include +#include +#include +#include +#define MAX_FLIGHTS 100 + +typedef struct { + char flightNo[10] = "-1"; + char departure[20] = "-1"; + char destination[20] = "-1"; + char departureTime[10] = "-1"; + char arrivalTime[10] = "-1"; + char aircraftModel[20] = "-1"; + float ticketPrice = 0; +} FlightRecord; + +int binarySearch(FlightRecord records[], int numRecords, char searchFlightNo[]) { + int low = 0, high = numRecords - 1, mid; + + while (low <= high) { + mid = (low + high) / 2; + if (strcmp(records[mid].flightNo, searchFlightNo) == 0) { + return mid; + } + if (strcmp(records[mid].flightNo, searchFlightNo) < 0) { + low = mid + 1; + } else { + high = mid - 1; + } + } + return -1; +} + +void sortByFlightNo(FlightRecord records[], int numRecords) { + int i, j; + FlightRecord temp; + for (i = 0; i < numRecords - 1; i++) { + for (j = 0; j < numRecords - i - 1; j++) { + if (strcmp(records[j].flightNo, records[j + 1].flightNo) > 0) { + temp = records[j]; + records[j] = records[j + 1]; + records[j + 1] = temp; + } + } + } +} + +void displayFlightRecord(FlightRecord record) { + printf("ţ%s\n", record.flightNo); + printf("վ%s\n", record.departure); + printf("յվ%s\n", record.destination); + printf("ʱ䣺%s\n", record.departureTime); + printf("ʱ䣺%s\n", record.arrivalTime); + printf("ɻͺţ%s\n", record.aircraftModel); + printf("Ʊۣ%.2f\n", record.ticketPrice); + printf("-----------------------------\n"); +} + +void save(int numRecords, FlightRecord fight[]){ + std::ofstream ofs; + ofs.open("flight.txt", std::ios::out); + ofs<>*numRecords; + for (int i = 0; i < *numRecords; i++) { + ifs>>fight[i].flightNo + >>fight[i].departure + >>fight[i].destination + >>fight[i].departureTime + >>fight[i].arrivalTime + >>fight[i].aircraftModel + >>fight[i].ticketPrice; + } + } else { + printf("flight.txt"); + } + ifs.close(); +} + +int main() { + FlightRecord flightRecords[MAX_FLIGHTS]; + int numRecords; + while (true) { + system("cls"); + load(&numRecords, flightRecords); + char fno[10]; + char depart[20]; + char des[20]; + char departTime[10]; + char arriTime[10]; + char airModel[20]; + float tkPrice; + + int choice; + printf("------[1]¼--------\n"); + printf("------[2]Ųѯ------\n"); + printf("------[3]ѯ--------\n"); + printf("------[4]˳ϵͳ--------\n"); + scanf("%d", &choice); + switch (choice) { + case 1: { + printf("뺽ţ"); + scanf(" %s", &fno); + printf("㣺"); + scanf(" %s", &depart); + printf("յ㣺"); + scanf(" %s", &des); + printf("ʱ䣺"); + scanf(" %s", &departTime); + printf("뵽ʱ䣺"); + scanf(" %s", &arriTime); + printf("ɻͺţ"); + scanf(" %s", &airModel); + printf("Ʊۣ"); + scanf("%f", &tkPrice); + + strcpy(flightRecords[numRecords].flightNo,fno); + strcpy(flightRecords[numRecords].departure,depart); + strcpy(flightRecords[numRecords].destination,des); + strcpy(flightRecords[numRecords].departureTime,departTime); + strcpy(flightRecords[numRecords].aircraftModel,airModel); + strcpy(flightRecords[numRecords].arrivalTime,arriTime); + flightRecords[numRecords].ticketPrice=tkPrice; + numRecords++; + + save(numRecords, flightRecords); + system("pause"); + break; + } + case 2: { + printf("뺽ţ"); + scanf(" %s", &fno); + sortByFlightNo(flightRecords,numRecords); + int i = binarySearch(flightRecords,numRecords,fno); + if(i==-1){ + printf("޸ú"); + }else{ + displayFlightRecord(flightRecords[i]); + } + system("pause"); + break; + } + case 3:{ + int sort; + system("cls"); + printf("ѡѯݣ\n"); + printf("------[1]--------\n"); + printf("------[2]յ--------\n"); + printf("------[3]--------\n"); + printf("------[4]--------\n"); + printf("------[5]ͺ--------\n"); + printf("------[6]Ʊ--------\n"); + printf("------[7]˳--------\n"); + scanf("%d", &sort); + switch (sort) { + case 1:{ + printf("㣺"); + scanf(" %s", &depart); + for (int i = 0; i < numRecords; ++i) { + if(strcmp(flightRecords[i].departure, depart) == 0){ + displayFlightRecord(flightRecords[i]); + } + } + system("pause"); + break; + } + case 2:{ + printf("յ㣺"); + scanf(" %s", &des); + for (int i = 0; i < numRecords; ++i) { + if(strcmp(flightRecords[i].destination, des) == 0){ + displayFlightRecord(flightRecords[i]); + } + } + system("pause"); + break; + } + case 3:{ + printf("ʱ䣺"); + scanf(" %s", &departTime); + for (int i = 0; i < numRecords; ++i) { + if(strcmp(flightRecords[i].departureTime, departTime) == 0){ + displayFlightRecord(flightRecords[i]); + } + } + system("pause"); + break; + } + case 4:{ + printf("뵽ʱ䣺"); + scanf(" %s", &arriTime); + for (int i = 0; i < numRecords; ++i) { + if(strcmp(flightRecords[i].arrivalTime, arriTime) == 0){ + displayFlightRecord(flightRecords[i]); + } + } + system("pause"); + break; + } + case 5:{ + printf("ɻͺţ"); + scanf(" %s", &airModel); + for (int i = 0; i < numRecords; ++i) { + if(strcmp(flightRecords[i].aircraftModel, airModel) == 0){ + displayFlightRecord(flightRecords[i]); + } + } + system("pause"); + break; + } + case 6:{ + printf("Ʊۣ"); + scanf("%f", &tkPrice); + for (int i = 0; i < numRecords; ++i) { + if(flightRecords[i].ticketPrice==tkPrice){ + displayFlightRecord(flightRecords[i]); + } + } + system("pause"); + break; + } + default:{ + system("pause"); + break; + } + } + } + default: { + return 0; + } + } + } +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex4-Flight.exe" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex4-Flight.exe" new file mode 100644 index 0000000..0107b3f Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex4-Flight.exe" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex5-SortComp.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex5-SortComp.cpp" new file mode 100644 index 0000000..007dd74 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex5-SortComp.cpp" @@ -0,0 +1,318 @@ +#include +#include +#include +#include +#include + +int* generateRandomArray(int size) { + int* arr = (int*)malloc(size * sizeof(int)); + srand(time(NULL)); + for (int i = 0; i < size; i++) { + arr[i] = rand() % 1000; + } + return arr; +} + +void swap(int* a, int* b) { + int temp = *a; + *a = *b; + *b = temp; +} + +void bubbleSort(int arr[], int size, int* comparisons, int* moves) { + for (int i = 0; i < size - 1; i++) { + for (int j = 0; j < size - i - 1; j++) { + (*comparisons)++; + if (arr[j] > arr[j+1]) { + (*moves)++; + swap(&arr[j], &arr[j+1]); + } + } + } +} + +void selectionSort(int arr[], int size, int* comparisons, int* moves) { + for (int i = 0; i < size - 1; i++) { + int minIndex = i; + for (int j = i + 1; j < size; j++) { + (*comparisons)++; + if (arr[j] < arr[minIndex]) { + minIndex = j; + } + } + if (minIndex != i) { + (*moves)++; + swap(&arr[i], &arr[minIndex]); + } + } +} + +void insertionSort(int arr[], int size, int* comparisons, int* moves) { + for (int i = 1; i < size; i++) { + int key = arr[i]; + int j = i - 1; + while (j >= 0 && arr[j] > key) { + (*comparisons)++; + (*moves)++; + arr[j+1] = arr[j]; + j--; + } + (*comparisons)++; + arr[j+1] = key; + } +} + +int partition(int arr[], int low, int high, int* comparisons, int* moves) { + int pivot = arr[high]; + int i = low - 1; + for (int j = low; j <= high - 1; j++) { + (*comparisons)++; + if (arr[j] < pivot) { + i++; + (*moves)++; + swap(&arr[i], &arr[j]); + } + } + (*moves)++; + swap(&arr[i+1], &arr[high]); + return (i + 1); +} + +void quickSort(int arr[], int low, int high, int* comparisons, int* moves) { + if (low < high) { + int pi = partition(arr, low, high, comparisons, moves); + quickSort(arr, low, pi - 1, comparisons, moves); + quickSort(arr, pi + 1, high, comparisons, moves); + } +} + +void shellSort(int arr[], int size, int* comparisons, int* moves) { + for (int gap = size / 2; gap > 0; gap /= 2) { + for (int i = gap; i < size; i++) { + int key = arr[i]; + int j = i; + while (j >= gap && arr[j - gap] > key) { + (*comparisons)++; + (*moves)++; + arr[j] = arr[j - gap]; + j -= gap; + } + (*comparisons)++; + arr[j] = key; + } + } +} + +void heapify(int arr[], int n, int i, int* comparisons, int* moves) { + int largest = i; + int left = 2 * i + 1; + int right = 2 * i + 2; + if (left < n && arr[left] > arr[largest]) { + *comparisons += 1; + largest = left; + } + if (right < n && arr[right] > arr[largest]) { + *comparisons += 1; + largest = right; + } + if (largest != i) { + *moves += 3; + swap(&arr[i], &arr[largest]); + heapify(arr, n, largest, comparisons, moves); + } +} + +void heapSort(int arr[], int n, int* comparisons, int* moves) { + for (int i = n / 2 - 1; i >= 0; i--) { + heapify(arr, n, i, comparisons, moves); + } + for (int i = n - 1; i >= 0; i--) { + *moves += 3; + swap(&arr[0], &arr[i]); + heapify(arr, i, 0, comparisons, moves); + } +} + +void merge(int* arr, int left, int mid, int right, int* compareCount, int* moveCount) { + int i = left; + int j = mid + 1; + int k = 0; + int* temp = (int*)malloc((right - left + 1) * sizeof(int)); + while (i <= mid && j <= right) { + *compareCount += 1; + if (arr[i] <= arr[j]) { + temp[k++] = arr[i++]; + } else { + temp[k++] = arr[j++]; + } + *moveCount += 1; + } + while (i <= mid) { + temp[k++] = arr[i++]; + *moveCount += 1; + } + while (j <= right) { + temp[k++] = arr[j++]; + *moveCount += 1; + } + for (int m = 0; m < k; m++) { + arr[left + m] = temp[m]; + *moveCount += 1; + } + free(temp); +} + +void mergeSort(int* arr, int left, int right, int* compareCount, int* moveCount) { + if (left < right) { + int mid = (left + right) / 2; + mergeSort(arr, left, mid, compareCount, moveCount); + mergeSort(arr, mid + 1, right, compareCount, moveCount); + merge(arr, left, mid, right, compareCount, moveCount); + } +} + +struct cmp{ + double time=0; + int cmpcnt=0; + int movcnt=0; +}; + +int main(){ + int dataSize = 10000; + int* arr; + cmp cmpSort[7]; + //ð + for (int i = 0; i < 5; i++) { + arr = generateRandomArray(dataSize); + int compareCount = 0; + int moveCount = 0; + clock_t start = clock(); + bubbleSort(arr, dataSize, &compareCount, &moveCount); + clock_t end = clock(); + cmpSort[0].time=cmpSort[0].time+(double)(end - start) / CLOCKS_PER_SEC; + cmpSort[0].cmpcnt=cmpSort[0].cmpcnt+compareCount; + cmpSort[0].movcnt=cmpSort[0].movcnt+moveCount; + free(arr); + } + cmpSort[0].time=cmpSort[0].time/5; + cmpSort[0].cmpcnt=cmpSort[0].cmpcnt/5; + cmpSort[0].movcnt=cmpSort[0].movcnt/5; + + //ѡ + for (int i = 0; i < 5; i++) { + arr = generateRandomArray(dataSize); + int compareCount = 0; + int moveCount = 0; + clock_t start = clock(); + selectionSort(arr, dataSize, &compareCount, &moveCount); + clock_t end = clock(); + cmpSort[1].time=cmpSort[1].time+(double)(end - start) / CLOCKS_PER_SEC; + cmpSort[1].cmpcnt=cmpSort[1].cmpcnt+compareCount; + cmpSort[1].movcnt=cmpSort[1].movcnt+moveCount; + free(arr); + } + cmpSort[1].time=cmpSort[1].time/5; + cmpSort[1].cmpcnt=cmpSort[1].cmpcnt/5; + cmpSort[1].movcnt=cmpSort[1].movcnt/5; + + //ֱѡ + for (int i = 0; i < 5; i++) { + arr = generateRandomArray(dataSize); + int compareCount = 0; + int moveCount = 0; + clock_t start = clock(); + insertionSort(arr, dataSize - 1, &compareCount, &moveCount); + clock_t end = clock(); + cmpSort[2].time=cmpSort[2].time+(double)(end - start) / CLOCKS_PER_SEC; + cmpSort[2].cmpcnt=cmpSort[2].cmpcnt+compareCount; + cmpSort[2].movcnt=cmpSort[2].movcnt+moveCount; + free(arr); + } + cmpSort[2].time=cmpSort[2].time/5; + cmpSort[2].cmpcnt=cmpSort[2].cmpcnt/5; + cmpSort[2].movcnt=cmpSort[2].movcnt/5; + + // + for (int i = 0; i < 5; i++) { + arr = generateRandomArray(dataSize); + int compareCount = 0; + int moveCount = 0; + clock_t start = clock(); + quickSort(arr,0, dataSize - 1, &compareCount, &moveCount); + clock_t end = clock(); + cmpSort[3].time=cmpSort[3].time+(double)(end - start) / CLOCKS_PER_SEC; + cmpSort[3].cmpcnt=cmpSort[3].cmpcnt+compareCount; + cmpSort[3].movcnt=cmpSort[3].movcnt+moveCount; + free(arr); + } + cmpSort[3].time=cmpSort[3].time/5; + cmpSort[3].cmpcnt=cmpSort[3].cmpcnt/5; + cmpSort[3].movcnt=cmpSort[3].movcnt/5; + + //ϣ + for (int i = 0; i < 5; i++) { + arr = generateRandomArray(dataSize); + int compareCount = 0; + int moveCount = 0; + clock_t start = clock(); + shellSort(arr, dataSize, &compareCount, &moveCount); + clock_t end = clock(); + cmpSort[4].time=cmpSort[4].time+(double)(end - start) / CLOCKS_PER_SEC; + cmpSort[4].cmpcnt=cmpSort[4].cmpcnt+compareCount; + cmpSort[4].movcnt=cmpSort[4].movcnt+moveCount; + free(arr); + } + cmpSort[4].time=cmpSort[4].time/5; + cmpSort[4].cmpcnt=cmpSort[4].cmpcnt/5; + cmpSort[4].movcnt=cmpSort[4].movcnt/5; + + // + for (int i = 0; i < 5; i++) { + arr = generateRandomArray(dataSize); + int compareCount = 0; + int moveCount = 0; + clock_t start = clock(); + heapSort(arr, dataSize, &compareCount, &moveCount); + clock_t end = clock(); + cmpSort[5].time=cmpSort[5].time+(double)(end - start) / CLOCKS_PER_SEC; + cmpSort[5].cmpcnt=cmpSort[5].cmpcnt+compareCount; + cmpSort[5].movcnt=cmpSort[5].movcnt+moveCount; + free(arr); + } + cmpSort[5].time=cmpSort[5].time/5; + cmpSort[5].cmpcnt=cmpSort[5].cmpcnt/5; + cmpSort[5].movcnt=cmpSort[5].movcnt/5; + + // 鲢 + for (int i = 0; i < 5; i++) { + arr = generateRandomArray(dataSize); + int compareCount = 0; + int moveCount = 0; + clock_t start = clock(); + mergeSort(arr, 0, dataSize - 1, &compareCount, &moveCount); + clock_t end = clock(); + cmpSort[6].time=cmpSort[6].time+(double)(end - start) / CLOCKS_PER_SEC; + cmpSort[6].cmpcnt=cmpSort[6].cmpcnt+compareCount; + cmpSort[6].movcnt=cmpSort[6].movcnt+moveCount; + free(arr); + } + cmpSort[6].time=cmpSort[6].time/5; + cmpSort[6].cmpcnt=cmpSort[6].cmpcnt/5; + cmpSort[6].movcnt=cmpSort[6].movcnt/5; + std::cout< +#include +#define MAX_NODES 11 + +typedef struct { + char name[50]; + std::string description; +} Node; + +int adjacencyMatrix[MAX_NODES][MAX_NODES]={ + {0,1,2,3,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f}, + {1,0,1,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f}, + {2,1,0,3,0x3f,0x3f,0x3f,5,0x3f,7,0x3f}, + {3,0x3f,3,0,4,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f}, + {0x3f,0x3f,0x3f,4,0,6,6,0x3f,0x3f,5,0x3f}, + {0x3f,0x3f,0x3f,0x3f,6,0,0x3f,0x3f,0x3f,0x3f,0x3f}, + {0x3f,0x3f,0x3f,0x3f,6,0x3f,0,0x3f,0x3f,0x3f,0x3f}, + {0x3f,0x3f,5,0x3f,0x3f,0x3f,0x3f,0,2,5,0x3f}, + {0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,2,0,0x3f,6}, + {0x3f,0x3f,7,0x3f,5,0x3f,0x3f,5,0x3f,0,0x3f}, + {0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,6,2,0} +}; + +Node nodes[MAX_NODES]={ + {"ͨ¥","ȫΪִͨģҪΪѧԺʵңԼ칫\n"}, + {"","Ϻɽ㸻·2793š\n"}, + {"ʵѵ","ʵѵ¥ѧճʹûʵγ̵Ĺܡ\n"}, + {"ͼ","佨Ϊ27000ƽʵȫܽĺͼ7ĺһרҵҼ1⡣\n"}, + {"¥","֯װѧԺѧԺ¥\n"}, + {"ʳ","ʳãʳáʳá\n"}, + {"","ϺɽĻ·800Ū\n"}, + {"¥","׳齫¥һ19¥ߵ¥3ȹ¥ѧУ󲿷ֵİ칫Ŷڴ¥\n"}, + {"","Ϻɽ·333ţΪѧУš\n"}, + {"ѧ¥","A~F6¥е󲿷ճѧ\n"}, + {"һʳ","ѧ¥ʳã˽̹ʳá\n"} +}; + +bool visited[MAX_NODES]; +int dist[MAX_NODES]; +int last[MAX_NODES]; + +typedef struct { + int queue[MAX_NODES]; + int front, rear; +} Queue; + +void initQueue(Queue* q) { + q->front = 0; + q->rear = -1; +} + +bool isQueueEmpty(Queue* q) { + return (q->front > q->rear); +} + +void enqueue(Queue* q, int node) { + q->queue[++(q->rear)] = node; +} + +int dequeue(Queue* q) { + return q->queue[(q->front)++]; +} + +int breadthFirstSearch(int eNode, int numNodes) { + Queue q; + initQueue(&q); + printf("BFS: "); + visited[0] = true; + enqueue(&q, 0); + while (!isQueueEmpty(&q)) { + int currentNode = dequeue(&q); + printf("%d ", currentNode); + if(currentNode==eNode) return currentNode; + for (int i = 0; i < numNodes; i++) { + if (adjacencyMatrix[currentNode][i]!=0x3f && !visited[i]) { + enqueue(&q, i); + visited[i] = true; + } + } + } + return -1; +} + +void depthFirstSearch(int startNode, int eNode, int numNodes) { + visited[startNode] = true; + printf("%d ", startNode); + for (int i = 0; i < numNodes; i++) { + if (adjacencyMatrix[startNode][i]!=0x3f && !visited[i]) { + depthFirstSearch(i, eNode, numNodes); + } + } + +} + +void dijkstra(int start, int end) { + for (int i = 0; i < MAX_NODES; i++) { + dist[i] = 0x3f; + visited[i] = false; + } + + dist[start] = 0; + + for (int count = 0; count < MAX_NODES - 1; count++) { + int minDist = 0x3f; + int minIndex = -1; + + for (int i = 0; i < MAX_NODES; i++) { + if (!visited[i] && dist[i] < minDist) { + minDist = dist[i]; + minIndex = i; + } + } + + if (minIndex == -1) { + break; + } + + visited[minIndex] = true; + + // ¾ + for (int i = 0; i < MAX_NODES; i++) { + if (!visited[i] && adjacencyMatrix[minIndex][i] != 0x3f + && dist[minIndex] + adjacencyMatrix[minIndex][i] < dist[i]) { + dist[i] = dist[minIndex] + adjacencyMatrix[minIndex][i]; + last[i] = minIndex; + } + } + } + printf(" %s %s ̾: %d\n", nodes[end].name, nodes[start].name, dist[end]); +} + +int way(int start, int end){ + if(last[end] == start){ + printf("%s ", nodes[start].name); + return start; + }else{ + printf("%s ", nodes[last[end]].name); + return way(start, last[end]); + } +} + +void mapshow(){ + printf(" 1.\n\n"); + printf("0.ͨ¥ 2.ʵѵ¥ 8.¥ 9.\n\n"); + printf(" 3.ͼ\n\n"); + printf(" 4.¥ 9.ѧ¥ 10.һʳ\n\n"); + printf("5.ʳ\n\n"); + printf(" 6.\n\n"); +} + +int main() { + while (true) { + system("cls"); + mapshow(); + int choice; + printf("-------[1]ڵѯ-------\n"); + printf("-------[2]ڵ㵼-------\n"); + printf("-------[3]˳ͼ-------\n"); + scanf("%d", &choice); + switch (choice) { + case 1: { + printf("ҪѯĽڵţ"); + int eNode; + scanf("%d", &eNode); + + for (int i = 0; i < MAX_NODES; i++) { + visited[i] = false; + } + int bfs = breadthFirstSearch(eNode, MAX_NODES); + + for (int i = 0; i < MAX_NODES; i++) { + visited[i] = false; + } + + printf("\nDFS: "); + depthFirstSearch(0, eNode, MAX_NODES); + + if (bfs > 10 || bfs < 0) { + printf("޸ýڵ"); + } + else { + printf("\n%dλã", bfs); + printf("%s ", nodes[bfs].name); + printf("%s", nodes[bfs].description.c_str()); + } + system("pause"); + break; + } + case 2: { + printf("\n뵼 յţ"); + int startNode, endNode; + scanf("%d %d", &startNode, &endNode); + dijkstra(endNode, startNode); + printf(" %s %s ·: ", nodes[startNode].name, nodes[endNode].name); + printf("%s ", nodes[startNode].name); + way(endNode, startNode); + printf("\n"); + system("pause"); + break; + } + default: { + system("cls"); + return 0; + } + } + } +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex6-Map.exe" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex6-Map.exe" new file mode 100644 index 0000000..206eb0b Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex6-Map.exe" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex7-HashContacts.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex7-HashContacts.cpp" new file mode 100644 index 0000000..3078721 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex7-HashContacts.cpp" @@ -0,0 +1,129 @@ +#include +#include +#include +#define TABLE_SIZE 10 + +typedef struct { + char name[50] = "-1"; + char address[100] = "-1"; +} Contact; + +typedef struct { + char phoneNum[20] = "-1"; + Contact contact; +} HashNode; + +void initHash(HashNode hashTable[]) { + for (int i = 0; i < TABLE_SIZE; i++) { + strcpy(hashTable[i].phoneNum, "-1"); + } +} + +int hashFunction(char phoneNum[]) { + int sum = 0; + for (int i = 0; i < strlen(phoneNum); i++) { + sum += phoneNum[i]; + } + return sum % TABLE_SIZE; +} + +void insertContact(HashNode hashTable[], char phoneNum[], char name[], char address[]) { + int index = hashFunction(phoneNum); + while (strcmp(hashTable[index].phoneNum, "-1") != 0) { + index = (index + 1) % TABLE_SIZE; + } + + strcpy(hashTable[index].phoneNum, phoneNum); + strcpy(hashTable[index].contact.name, name); + strcpy(hashTable[index].contact.address, address); +} + +void save(HashNode hashTable[]){ + std::ofstream ofs; + ofs.open("contacts.txt", std::ios::out); + for (int i = 0; i < TABLE_SIZE; i++) + { + ofs<>hashTable[i].phoneNum + >>hashTable[i].contact.name + >>hashTable[i].contact.address; + } + }else{ + printf("δҵcontacts.txt"); + } + ifs.close(); + +} + +void findContact(HashNode hashTable[], char phoneNum[]) { + int index = hashFunction(phoneNum); + while (strcmp(hashTable[index].phoneNum, phoneNum) != 0) { + index = (index + 1) % TABLE_SIZE; + if (strcmp(hashTable[index].phoneNum, "") == 0 || index == hashFunction(phoneNum)) { + printf("δҵֻӦͨѶϢ\n"); + return; + } + } + + printf("%s\n", hashTable[index].contact.name); + printf("ַ%s\n", hashTable[index].contact.address); +} + +int main() { + HashNode hashTable[TABLE_SIZE]; + initHash(hashTable); + + while (true) { + system("cls"); + load(hashTable); + char name[50]; + char address[100]; + char phoneNum[20]; + int choice; + printf("-------[1]¼-------\n"); + printf("-------[2]ѯ-------\n"); + printf("-------[3]˳ϵͳ-------\n"); + scanf("%d", &choice); + switch (choice) { + case 1: { + printf("ֻţ"); + scanf(" %s", &phoneNum); + printf(""); + scanf(" %s", &name); + printf("ַ"); + scanf(" %s", &address); + insertContact(hashTable, phoneNum, name, address); + + save(hashTable); + system("pause"); + break; + } + case 2: { + printf("ֻţ"); + scanf(" %s", &phoneNum); + findContact(hashTable, phoneNum); + printf("\n"); + system("pause"); + break; + } + default: { + return 0; + } + } + } +} diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex7-HashContacts.exe" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex7-HashContacts.exe" new file mode 100644 index 0000000..7bb511c Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex7-HashContacts.exe" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex8-Huffman.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex8-Huffman.cpp" new file mode 100644 index 0000000..1550cac --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex8-Huffman.cpp" @@ -0,0 +1,400 @@ +#include +#include +#include +#include + +#define MAXVAL 10000.0 +struct HuffmanTreeNode{ + char data; + double weight; + int parent,lchild,rchild; +}; +struct HuffmanTree{ + HuffmanTreeNode *node; + int n; +}; +struct Codetype{ + char *bits; + int start; +}; +void SortHufmtree(HuffmanTree *tree){ + int i,j,k; + HuffmanTreeNode temp; + if (tree==NULL) + return; + for (i=0;in;i++) + { + k=i; + for(j=i+1;jn;j++) + if (tree->node[j].weight>tree->node[k].weight) + k=j; + if (k!=i) + { + temp=tree->node[i]; + tree->node[i]=tree->node[k]; + tree->node[k]=temp; + } + } +} +Codetype* HuffmanCode(HuffmanTree *tree){ + int i,j,p,k; + Codetype *code; + if (tree==NULL) + return NULL; + code=(Codetype*)malloc(tree->n*sizeof(Codetype)); + for (i=0;in;i++) + { + printf("%c ",tree->node[i].data); + code[i].bits=(char*)malloc(tree->n*sizeof(char)); + code[i].start=tree->n-1; + j=i; + p=tree->node[i].parent; + while(p!=-1){ + if (tree->node[p].lchild==j) + code[i].bits[code[i].start]='0'; + else + code[i].bits[code[i].start]='1'; + + code[i].start--; + j=p; + p=tree->node[p].parent; + } + for (k=code[i].start+1;kn;k++) + printf("%c",code[i].bits[k]); + printf("\n"); + } + return code; +} +HuffmanTree* BuildHuffmanTree(HuffmanTree *tree){ + int i,j,p1,p2,m; + float small1,small2; + m=2*(tree->n)-1; + for (i=tree->n;inode[i].parent=-1; + tree->node[i].lchild=-1; + tree->node[i].rchild=-1; + tree->node[i].weight=0.0; + } + for (i=tree->n;inode[j].parent==-1 && tree->node[j].weight<=small1) + { + small1=tree->node[j].weight; + p1=j; + } + } + for (j=0;j<=i-1;j++) + { + if (tree->node[j].parent==-1 && tree->node[j].weight<=small2 && (j!=p1)) + { + small2=tree->node[j].weight; + p2=j; + } + } + tree->node[p1].parent=tree->node[p2].parent=i; + tree->node[i].weight=tree->node[p1].weight+tree->node[p2].weight; + + tree->node[i].lchild=p1; + tree->node[i].rchild=p2; + } + return tree; +} +HuffmanTree* CreateHuffmanTreeFromSourceFile(){ + FILE *textfile,*datafile; + char ch; + int i,j=0,n=0; + float count[128]; + HuffmanTree *tree; + + if ((textfile=fopen("1.txt","r"))==NULL){ + printf("\nҲ1.txt"); + return NULL; + } + for(i=0;i<128;i++) + count[i]=0; + + ch=fgetc(textfile); + while(!feof(textfile)){ + for(i=0;i<128;i++) + if (ch==char(i)){ + count[i]++; + break; + } + ch=fgetc(textfile); + } + + datafile=fopen("data.txt","w"); + for (i=0;i<128;i++) + if (count[i]!=0) + n++; + fprintf(datafile,"%d\n",n); + tree=(HuffmanTree*)malloc(sizeof(HuffmanTree)); + tree->node=(HuffmanTreeNode*)malloc((2*n-1)*sizeof(HuffmanTreeNode)); + + tree->n=n; + + printf("\nԴļַȨֵϢ£\n"); + + for(i=0;i<128;i++) + if (count[i]!=0) + { + fprintf(datafile,"%c %.0f\n",char(i),count[i]); + printf("%c %.0f\n",char(i),count[i]); + tree->node[j].data=char(i); + tree->node[j].weight=count[i]; + tree->node[j].parent=-1; + tree->node[j].lchild=-1; + tree->node[j].rchild=-1; + j++; + } + SortHufmtree(tree); + BuildHuffmanTree(tree); + fclose(textfile); + fclose(datafile); + printf("\nϣѽȨֵϢdata.txt\n"); + return tree; +} + +HuffmanTree* CreateHuffmanTreeByInput(){ + int n; + HuffmanTree *tree; + int i; + FILE *datafile; + tree=(HuffmanTree*)malloc(sizeof(HuffmanTree)); + datafile=fopen("data.txt","w"); + + printf("ַ"); + scanf("%d",&n); + if (n<=0) + { + printf("\n\n"); + return NULL; + } + tree->node=(HuffmanTreeNode*)malloc((2*n-1)*sizeof(HuffmanTreeNode)); + tree->n=n; + + for (i=0;inode[i].parent=-1; + tree->node[i].lchild=-1; + tree->node[i].rchild=-1; + tree->node[i].weight=0.0; + } + fprintf(datafile,"%d\n",n); + for (i=0;i>tree->node[i].data; + std::cin>>tree->node[i].weight; + fprintf(datafile,"%c %.3f\n",tree->node[i].data,tree->node[i].weight); + } + fclose(datafile); + + SortHufmtree(tree); + BuildHuffmanTree(tree); + printf("\nϣѽȨֵϢdata.txt\n"); + return tree; +} +HuffmanTree* CreateHuffmanTreeFromDataFile(){ + FILE *datafile; + int i,n; + HuffmanTree *tree; + if ((datafile=fopen("data.txt","r"))==NULL){ + printf("\nδ\n"); + return NULL; + } + + fscanf(datafile,"%d",&n); + fgetc(datafile); + tree=(HuffmanTree*)malloc(sizeof(HuffmanTree)); + tree->node=(HuffmanTreeNode*)malloc((2*n-1)*sizeof(HuffmanTreeNode)); + tree->n=n; + for (i=0;inode[i].data=fgetc(datafile); + fscanf(datafile,"%f\n",&tree->node[i].weight); + tree->node[i].parent=-1; + tree->node[i].lchild=-1; + tree->node[i].rchild=-1; + } + fclose(datafile); + + SortHufmtree(tree); + BuildHuffmanTree(tree); + return tree; +} + + +HuffmanTree* Encoding(HuffmanTree *tree){ + FILE *textfile,*codefile; + char ch; + int i,j; + Codetype *code; + + if (tree==NULL) + { + tree=CreateHuffmanTreeFromDataFile(); + if (tree==NULL) + return NULL; + } + + if ((textfile=fopen("1.txt","r"))==NULL){ + printf("\nҲļ1.txt\n"); + return NULL; + } + + printf("\nԴļԭ£\n"); + ch=fgetc(textfile); + while(!feof(textfile)){ + printf("%c",ch); + ch=fgetc(textfile); + } + + printf("\nַĹ£\n"); + code=HuffmanCode(tree); + codefile=fopen("CodeFile.txt","w"); + fseek(textfile,0,SEEK_SET); + ch=fgetc(textfile); + while (!feof(textfile)) + { + for(i=0;in;i++) + if (ch==tree->node[i].data){ + for(j=code[i].start+1;jn;j++) + fputc(code[i].bits[j],codefile); + break; + } + if (i==tree->n) + { + fclose(codefile); + return NULL; + } + ch=fgetc(textfile); + } + fclose(codefile); + + printf("\nɹ,ѽдCodeFile.txt,£\n"); + codefile=fopen("CodeFile.txt","r"); + ch=fgetc(codefile); + while(!feof(codefile)){ + printf("%c",ch); + ch=fgetc(codefile); + } + printf("\n"); + fclose(textfile); + fclose(codefile); + return tree; +} + +void Decoding(HuffmanTree *tree){ + FILE *codefile,*decodefile; + char ch; + int i; + + if (tree==NULL){ + tree=CreateHuffmanTreeFromDataFile(); + if (tree==NULL) + return ; + } + + if ((codefile=fopen("CodeFile.txt","r"))==NULL){ + printf("\nҲļCodeFile.txt\n"); + return; + } + + printf("\nļԭ£\n"); + ch=fgetc(codefile); + while(!feof(codefile)){ + printf("%c",ch); + ch=fgetc(codefile); + } + + decodefile=fopen("DecodeFile.txt","w"); + fseek(codefile,0,SEEK_SET); + ch=fgetc(codefile); + while(!feof(codefile)) + { + for(i=2*tree->n-2;tree->node[i].lchild>=0 && tree->node[i].rchild>=0 && ch!=EOF;) + { + if(ch=='0') + i = tree->node[i].lchild; + else if(ch=='1') + i = tree->node[i].rchild; + else{ + printf("\n쳣ַ%cȷ롣\n",ch); + return ; + } + if (i==-1){ + printf("\n뵱ǰṹȷ롣\n",ch); + fclose(decodefile); + return; + } + ch=fgetc(codefile); + } + if (tree->node[i].lchild>=0 && tree->node[i].rchild>=0){ + printf("\nļݲ롣\n",ch); + fclose(decodefile); + return; + } + + fputc(tree->node[i].data,decodefile); + } + fclose(decodefile); + + printf("\n\nɹѱDecodeFile.txt\n"); + printf("£\n"); + decodefile=fopen("DecodeFile.txt","r"); + ch=fgetc(decodefile); + while(!feof(decodefile)){ + printf("%c",ch); + ch=fgetc(decodefile); + } + printf("\n"); + fclose(codefile); + fclose(decodefile); +} + +int main(){ + HuffmanTree *tree=NULL; + int choice; + while(true) { + system("cls"); + printf("------[1]ļб--------\n"); + printf("------[2]б--------\n"); + printf("------[3]ݽ--------\n"); + printf("------[4]˳ϵͳ--------\n"); + scanf("%d", &choice); + printf("\n"); + switch (choice) + { + case 1:{ + tree=CreateHuffmanTreeFromSourceFile(); + tree=Encoding(tree); + system("pause"); + break; + } + case 2:{ + tree=CreateHuffmanTreeByInput(); + tree=Encoding(tree); + system("pause"); + break; + } + case 3:{ + Decoding(tree); + system("pause"); + break; + } + case 4:{ + return 0; + } + default:{ + printf("Чѡ\n"); + system("pause"); + break; + } + } + } +} + diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex8-Huffman.exe" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex8-Huffman.exe" new file mode 100644 index 0000000..e28ceae Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/ex8-Huffman.exe" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/flight.txt" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/flight.txt" new file mode 100644 index 0000000..bc09ca6 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/flight.txt" @@ -0,0 +1,5 @@ +4 +MU0123 Ϻ 08:00 10:00 Boeing737 800 +CZ0456 Ϻ 12:00 14:00 AirbusA320 1000 +9C0789 15:00 16:00 Boeing747 500 +3u8633 sha pvg 1200 1230 c919 2000 diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/main.cpp" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/main.cpp" new file mode 100644 index 0000000..fbccc80 --- /dev/null +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/main.cpp" @@ -0,0 +1,85 @@ +#include +#include + +typedef struct Node { + int data; + int pos; + struct Node* next; +} Node; + +Node* createNode(int data, int pos) { + Node* newNode = (Node*)malloc(sizeof(Node)); + newNode->data = data; + newNode->pos = pos; + newNode->next = NULL; + return newNode; +} + +void insertAtEnd(Node** head, int data, int pos) { + Node* newNode = createNode(data, pos); + if (*head == NULL) { + *head = newNode; + newNode->next = *head; + } else { + Node* temp = *head; + while (temp->next != *head) { + temp = temp->next; + } + temp->next = newNode; + newNode->next = *head; + } +} + +void printList(Node* head) { + Node* temp = head; + do { + printf("%d ", temp->data); + temp = temp->next; + } while (temp != head); + printf("\n"); +} + +void deleteKthNode(Node** head, int k) { + if (k == 1) { + Node* temp = *head; + *head = (*head)->next; + free(temp); + return; + } + Node* curr = (*head)->next; + int count = 2; + while (curr != NULL) { + if (count == k) { + (*head)->next = curr->next; + printf("ߣ%d ", curr->data); + printf("λã%d\n", curr->pos); + free(curr); + return; + } else { + *head = curr; + curr = curr->next; + count++; + } + } +} + +int main(){ + int N, k, pos; + printf("˿(N)"); + scanf("%d", &N); + printf("(k)"); + scanf("%d", &k); + Node* head = NULL; + for (int i = 1; i <= N; i++) { + pos = i; + insertAtEnd(&head, i, pos); + } + printf("\n"); + struct Node* current = head; + for(int i = N; i > N/2;current = current->next, i--){ + deleteKthNode(¤t, k); + } + printf("Ҵ\n"); + printList(current); + return 0; +} \ No newline at end of file diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/main.exe" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/main.exe" new file mode 100644 index 0000000..57ae184 Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/main.exe" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/\347\256\227\346\263\225\344\270\216\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276.pdf" "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/\347\256\227\346\263\225\344\270\216\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276.pdf" new file mode 100644 index 0000000..357280b Binary files /dev/null and "b/\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276/\347\256\227\346\263\225\344\270\216\346\225\260\346\215\256\347\273\223\346\236\204\350\257\276\350\256\276.pdf" differ diff --git "a/\347\246\273\346\225\243\346\225\260\345\255\246/2020 A\345\215\267.pdf" "b/\347\246\273\346\225\243\346\225\260\345\255\246/2020 A\345\215\267.pdf" new file mode 100644 index 0000000..555d04b Binary files /dev/null and "b/\347\246\273\346\225\243\346\225\260\345\255\246/2020 A\345\215\267.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/1-\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246\345\257\274\350\256\272\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/1-\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246\345\257\274\350\256\272\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" new file mode 100644 index 0000000..4ed41b2 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/1-\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246\345\257\274\350\256\272\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2-\347\273\230\345\233\276\345\237\272\347\241\200\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2-\347\273\230\345\233\276\345\237\272\347\241\200\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" new file mode 100644 index 0000000..54cec81 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2-\347\273\230\345\233\276\345\237\272\347\241\200\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2023\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246- 5\357\274\210\346\212\225\345\275\261\344\270\216\346\266\210\351\232\220\357\274\211.pptx" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2023\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246- 5\357\274\210\346\212\225\345\275\261\344\270\216\346\266\210\351\232\220\357\274\211.pptx" new file mode 100644 index 0000000..f8ad3cf Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2023\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246- 5\357\274\210\346\212\225\345\275\261\344\270\216\346\266\210\351\232\220\357\274\211.pptx" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2023\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246- 6\357\274\210\350\241\250\351\235\242\346\250\241\345\236\213\357\274\211.pptx" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2023\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246- 6\357\274\210\350\241\250\351\235\242\346\250\241\345\236\213\357\274\211.pptx" new file mode 100644 index 0000000..ccaaf69 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2023\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246- 6\357\274\210\350\241\250\351\235\242\346\250\241\345\236\213\357\274\211.pptx" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2023\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246- 7\357\274\210\345\205\211\347\205\247\346\250\241\345\236\213\357\274\211.pptx" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2023\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246- 7\357\274\210\345\205\211\347\205\247\346\250\241\345\236\213\357\274\211.pptx" new file mode 100644 index 0000000..c7f57a6 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2023\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246- 7\357\274\210\345\205\211\347\205\247\346\250\241\345\236\213\357\274\211.pptx" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2023\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246- 8\357\274\210\347\272\271\347\220\206\346\250\241\345\236\213\357\274\211.pptx" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2023\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246- 8\357\274\210\347\272\271\347\220\206\346\250\241\345\236\213\357\274\211.pptx" new file mode 100644 index 0000000..0da0e9e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/2023\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246- 8\357\274\210\347\272\271\347\220\206\346\250\241\345\236\213\357\274\211.pptx" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/3-\345\237\272\346\234\254\345\233\276\345\275\242\347\232\204\346\211\253\346\217\217\350\275\254\346\215\242\357\274\2102\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/3-\345\237\272\346\234\254\345\233\276\345\275\242\347\232\204\346\211\253\346\217\217\350\275\254\346\215\242\357\274\2102\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" new file mode 100644 index 0000000..0af737a Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/3-\345\237\272\346\234\254\345\233\276\345\275\242\347\232\204\346\211\253\346\217\217\350\275\254\346\215\242\357\274\2102\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/4-\345\207\240\344\275\225\345\217\230\346\215\242\357\274\2103\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/4-\345\207\240\344\275\225\345\217\230\346\215\242\357\274\2103\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" new file mode 100644 index 0000000..2c0e957 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/4-\345\207\240\344\275\225\345\217\230\346\215\242\357\274\2103\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/5-\350\207\252\347\224\261\346\233\262\351\235\242\345\273\272\346\250\241\357\274\2103\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/5-\350\207\252\347\224\261\346\233\262\351\235\242\345\273\272\346\250\241\357\274\2103\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" new file mode 100644 index 0000000..d5c077e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/5-\350\207\252\347\224\261\346\233\262\351\235\242\345\273\272\346\250\241\357\274\2103\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/6-1-\346\212\225\345\275\261\344\270\216\346\266\210\351\232\220-\346\212\225\345\275\261\351\203\250\345\210\206\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/6-1-\346\212\225\345\275\261\344\270\216\346\266\210\351\232\220-\346\212\225\345\275\261\351\203\250\345\210\206\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" new file mode 100644 index 0000000..7fa7356 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/6-1-\346\212\225\345\275\261\344\270\216\346\266\210\351\232\220-\346\212\225\345\275\261\351\203\250\345\210\206\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/6-2-\346\212\225\345\275\261\344\270\216\346\266\210\351\232\220-\346\266\210\351\232\220\345\217\212\345\256\236\351\252\214\357\274\2102\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/6-2-\346\212\225\345\275\261\344\270\216\346\266\210\351\232\220-\346\266\210\351\232\220\345\217\212\345\256\236\351\252\214\357\274\2102\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" new file mode 100644 index 0000000..73e0173 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/6-2-\346\212\225\345\275\261\344\270\216\346\266\210\351\232\220-\346\266\210\351\232\220\345\217\212\345\256\236\351\252\214\357\274\2102\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/7-\350\241\250\351\235\242\346\250\241\345\236\213-\345\220\253\351\235\242\346\266\210\351\232\220\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/7-\350\241\250\351\235\242\346\250\241\345\236\213-\345\220\253\351\235\242\346\266\210\351\232\220\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" new file mode 100644 index 0000000..3e06b95 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/7-\350\241\250\351\235\242\346\250\241\345\236\213-\345\220\253\351\235\242\346\266\210\351\232\220\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/8-1-\347\234\237\345\256\236\346\204\237\345\233\276\345\275\242-\351\242\234\350\211\262\346\250\241\345\236\213+\345\205\211\347\205\247\346\250\241\345\236\213\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/8-1-\347\234\237\345\256\236\346\204\237\345\233\276\345\275\242-\351\242\234\350\211\262\346\250\241\345\236\213+\345\205\211\347\205\247\346\250\241\345\236\213\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" new file mode 100644 index 0000000..d91c056 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/8-1-\347\234\237\345\256\236\346\204\237\345\233\276\345\275\242-\351\242\234\350\211\262\346\250\241\345\236\213+\345\205\211\347\205\247\346\250\241\345\236\213\357\274\2102\345\255\246\346\227\266\357\274\211.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/8-2-\347\234\237\345\256\236\346\204\237\345\233\276\345\275\242-\347\272\271\347\220\206\345\217\212\345\256\236\351\252\214\357\274\2102\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/8-2-\347\234\237\345\256\236\346\204\237\345\233\276\345\275\242-\347\272\271\347\220\206\345\217\212\345\256\236\351\252\214\357\274\2102\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" new file mode 100644 index 0000000..6482f9c Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/8-2-\347\234\237\345\256\236\346\204\237\345\233\276\345\275\242-\347\272\271\347\220\206\345\217\212\345\256\236\351\252\214\357\274\2102\345\255\246\346\227\266+2\345\255\246\346\227\266\357\274\211.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.aps" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.aps" new file mode 100644 index 0000000..08f501a Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.aps" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.cpp" new file mode 100644 index 0000000..141ba98 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.cpp" @@ -0,0 +1,219 @@ + +// Bresenham.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "afxwinappex.h" +#include "afxdialogex.h" +#include "Bresenham.h" +#include "MainFrm.h" + +#include "BresenhamDoc.h" +#include "BresenhamView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CBresenhamApp + +BEGIN_MESSAGE_MAP(CBresenhamApp, CWinAppEx) + ON_COMMAND(ID_APP_ABOUT, &CBresenhamApp::OnAppAbout) + // 基于文件的标准文档命令 + ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) + // 标准打印设置命令 + ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup) +END_MESSAGE_MAP() + + +// CBresenhamApp 构造 + +CBresenhamApp::CBresenhamApp() noexcept +{ + m_bHiColorIcons = TRUE; + + + m_nAppLook = 0; + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; +#ifdef _MANAGED + // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则: + // 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。 + // 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。 + System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); +#endif + + // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式 + //为 CompanyName.ProductName.SubProduct.VersionInformation + SetAppID(_T("Bresenham.AppID.NoVersion")); + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + +// 唯一的 CBresenhamApp 对象 + +CBresenhamApp theApp; + + +// CBresenhamApp 初始化 + +BOOL CBresenhamApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinAppEx::InitInstance(); + + + // 初始化 OLE 库 + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + + AfxEnableControlContainer(); + + EnableTaskbarInteraction(FALSE); + + // 使用 RichEdit 控件需要 AfxInitRichEdit2() + // AfxInitRichEdit2(); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) + + + InitContextMenuManager(); + + InitKeyboardManager(); + + InitTooltipManager(); + CMFCToolTipInfo ttParams; + ttParams.m_bVislManagerTheme = TRUE; + theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, + RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); + + // 注册应用程序的文档模板。 文档模板 + // 将用作文档、框架窗口和视图之间的连接 + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(CBresenhamDoc), + RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 + RUNTIME_CLASS(CBresenhamView)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + + + // 分析标准 shell 命令、DDE、打开文件操作的命令行 + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + + + // 调度在命令行中指定的命令。 如果 + // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + + // 唯一的一个窗口已初始化,因此显示它并对其进行更新 + m_pMainWnd->ShowWindow(SW_SHOW); + m_pMainWnd->UpdateWindow(); + return TRUE; +} + +int CBresenhamApp::ExitInstance() +{ + //TODO: 处理可能已添加的附加资源 + AfxOleTerm(FALSE); + + return CWinAppEx::ExitInstance(); +} + +// CBresenhamApp 消息处理程序 + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg() noexcept; + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + +// 用于运行对话框的应用程序命令 +void CBresenhamApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +// CBresenhamApp 自定义加载/保存方法 + +void CBresenhamApp::PreLoadState() +{ + BOOL bNameValid; + CString strName; + bNameValid = strName.LoadString(IDS_EDIT_MENU); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); + bNameValid = strName.LoadString(IDS_EXPLORER); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EXPLORER); +} + +void CBresenhamApp::LoadCustomState() +{ +} + +void CBresenhamApp::SaveCustomState() +{ +} + +// CBresenhamApp 消息处理程序 + + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.h" new file mode 100644 index 0000000..ad0ea4e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.h" @@ -0,0 +1,40 @@ + +// Bresenham.h: Bresenham 应用程序的主头文件 +// +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// CBresenhamApp: +// 有关此类的实现,请参阅 Bresenham.cpp +// + +class CBresenhamApp : public CWinAppEx +{ +public: + CBresenhamApp() noexcept; + + +// 重写 +public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + +// 实现 + UINT m_nAppLook; + BOOL m_bHiColorIcons; + + virtual void PreLoadState(); + virtual void LoadCustomState(); + virtual void SaveCustomState(); + + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern CBresenhamApp theApp; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.rc" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.rc" new file mode 100644 index 0000000..06067f5 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.rc" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.sln" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.sln" new file mode 100644 index 0000000..cb7374b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33414.496 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Bresenham", "Bresenham.vcxproj", "{EF8BD9EA-E79E-4FD7-A1DD-950A6F217942}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EF8BD9EA-E79E-4FD7-A1DD-950A6F217942}.Debug|x64.ActiveCfg = Debug|x64 + {EF8BD9EA-E79E-4FD7-A1DD-950A6F217942}.Debug|x64.Build.0 = Debug|x64 + {EF8BD9EA-E79E-4FD7-A1DD-950A6F217942}.Debug|x86.ActiveCfg = Debug|Win32 + {EF8BD9EA-E79E-4FD7-A1DD-950A6F217942}.Debug|x86.Build.0 = Debug|Win32 + {EF8BD9EA-E79E-4FD7-A1DD-950A6F217942}.Release|x64.ActiveCfg = Release|x64 + {EF8BD9EA-E79E-4FD7-A1DD-950A6F217942}.Release|x64.Build.0 = Release|x64 + {EF8BD9EA-E79E-4FD7-A1DD-950A6F217942}.Release|x86.ActiveCfg = Release|Win32 + {EF8BD9EA-E79E-4FD7-A1DD-950A6F217942}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {23C34393-4BCA-4501-B708-C018352C4C10} + EndGlobalSection +EndGlobal diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.vcxproj" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.vcxproj" new file mode 100644 index 0000000..47f3bba --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.vcxproj" @@ -0,0 +1,255 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {EF8BD9EA-E79E-4FD7-A1DD-950A6F217942} + MFCProj + Bresenham + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.vcxproj.filters" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.vcxproj.filters" new file mode 100644 index 0000000..958335b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.vcxproj.filters" @@ -0,0 +1,183 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.vcxproj.user" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.vcxproj.user" new file mode 100644 index 0000000..2caab17 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Bresenham.vcxproj.user" @@ -0,0 +1,6 @@ + + + + Bresenham.rc + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/BresenhamDoc.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/BresenhamDoc.cpp" new file mode 100644 index 0000000..cf8095c --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/BresenhamDoc.cpp" @@ -0,0 +1,138 @@ + +// BresenhamDoc.cpp: CBresenhamDoc 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "Bresenham.h" +#endif + +#include "BresenhamDoc.h" + +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CBresenhamDoc + +IMPLEMENT_DYNCREATE(CBresenhamDoc, CDocument) + +BEGIN_MESSAGE_MAP(CBresenhamDoc, CDocument) +END_MESSAGE_MAP() + + +// CBresenhamDoc 构造/析构 + +CBresenhamDoc::CBresenhamDoc() noexcept +{ + // TODO: 在此添加一次性构造代码 + +} + +CBresenhamDoc::~CBresenhamDoc() +{ +} + +BOOL CBresenhamDoc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: 在此添加重新初始化代码 + // (SDI 文档将重用该文档) + + return TRUE; +} + + + + +// CBresenhamDoc 序列化 + +void CBresenhamDoc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: 在此添加存储代码 + } + else + { + // TODO: 在此添加加载代码 + } +} + +#ifdef SHARED_HANDLERS + +// 缩略图的支持 +void CBresenhamDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds) +{ + // 修改此代码以绘制文档数据 + dc.FillSolidRect(lprcBounds, RGB(255, 255, 255)); + + CString strText = _T("TODO: implement thumbnail drawing here"); + LOGFONT lf; + + CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + pDefaultGUIFont->GetLogFont(&lf); + lf.lfHeight = 36; + + CFont fontDraw; + fontDraw.CreateFontIndirect(&lf); + + CFont* pOldFont = dc.SelectObject(&fontDraw); + dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK); + dc.SelectObject(pOldFont); +} + +// 搜索处理程序的支持 +void CBresenhamDoc::InitializeSearchContent() +{ + CString strSearchContent; + // 从文档数据设置搜索内容。 + // 内容部分应由“;”分隔 + + // 例如: strSearchContent = _T("point;rectangle;circle;ole object;"); + SetSearchContent(strSearchContent); +} + +void CBresenhamDoc::SetSearchContent(const CString& value) +{ + if (value.IsEmpty()) + { + RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); + } + else + { + CMFCFilterChunkValueImpl *pChunk = nullptr; + ATLTRY(pChunk = new CMFCFilterChunkValueImpl); + if (pChunk != nullptr) + { + pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT); + SetChunkValue(pChunk); + } + } +} + +#endif // SHARED_HANDLERS + +// CBresenhamDoc 诊断 + +#ifdef _DEBUG +void CBresenhamDoc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CBresenhamDoc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// CBresenhamDoc 命令 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/BresenhamDoc.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/BresenhamDoc.h" new file mode 100644 index 0000000..13f0013 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/BresenhamDoc.h" @@ -0,0 +1,48 @@ + +// BresenhamDoc.h: CBresenhamDoc 类的接口 +// + + +#pragma once + + +class CBresenhamDoc : public CDocument +{ +protected: // 仅从序列化创建 + CBresenhamDoc() noexcept; + DECLARE_DYNCREATE(CBresenhamDoc) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); +#ifdef SHARED_HANDLERS + virtual void InitializeSearchContent(); + virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds); +#endif // SHARED_HANDLERS + +// 实现 +public: + virtual ~CBresenhamDoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// 生成的消息映射函数 +protected: + DECLARE_MESSAGE_MAP() + +#ifdef SHARED_HANDLERS + // 用于为搜索处理程序设置搜索内容的 Helper 函数 + void SetSearchContent(const CString& value); +#endif // SHARED_HANDLERS +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/BresenhamView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/BresenhamView.cpp" new file mode 100644 index 0000000..817ea99 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/BresenhamView.cpp" @@ -0,0 +1,149 @@ + +// BresenhamView.cpp: CBresenhamView 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "Bresenham.h" +#endif + +#include "BresenhamDoc.h" +#include "BresenhamView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CBresenhamView + +IMPLEMENT_DYNCREATE(CBresenhamView, CView) + +BEGIN_MESSAGE_MAP(CBresenhamView, CView) + // 标准打印命令 + ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CBresenhamView::OnFilePrintPreview) + ON_WM_CONTEXTMENU() + ON_WM_RBUTTONUP() + ON_WM_LBUTTONDOWN() + ON_WM_LBUTTONUP() +END_MESSAGE_MAP() + +// CBresenhamView 构造/析构 + +CBresenhamView::CBresenhamView() noexcept +{ + // TODO: 在此处添加构造代码 + +} + +CBresenhamView::~CBresenhamView() +{ +} + +BOOL CBresenhamView::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return CView::PreCreateWindow(cs); +} + +// CBresenhamView 绘图 + +void CBresenhamView::OnDraw(CDC* /*pDC*/) +{ + CBresenhamDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + + // TODO: 在此处为本机数据添加绘制代码 +} + + +// CBresenhamView 打印 + + +void CBresenhamView::OnFilePrintPreview() +{ +#ifndef SHARED_HANDLERS + AFXPrintPreview(this); +#endif +} + +BOOL CBresenhamView::OnPreparePrinting(CPrintInfo* pInfo) +{ + // 默认准备 + return DoPreparePrinting(pInfo); +} + +void CBresenhamView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加额外的打印前进行的初始化过程 +} + +void CBresenhamView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加打印后进行的清理过程 +} + +void CBresenhamView::OnRButtonUp(UINT /* nFlags */, CPoint point) +{ + ClientToScreen(&point); + OnContextMenu(this, point); +} + +void CBresenhamView::OnContextMenu(CWnd* /* pWnd */, CPoint point) +{ +#ifndef SHARED_HANDLERS + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE); +#endif +} + + +// CBresenhamView 诊断 + +#ifdef _DEBUG +void CBresenhamView::AssertValid() const +{ + CView::AssertValid(); +} + +void CBresenhamView::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +CBresenhamDoc* CBresenhamView::GetDocument() const // 非调试版本是内联的 +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBresenhamDoc))); + return (CBresenhamDoc*)m_pDocument; +} +#endif //_DEBUG + + +// CBresenhamView 消息处理程序 + + +void CBresenhamView::OnLButtonDown(UINT nFlags, CPoint point) +{ + // TODO: 在此添加消息处理程序代码和/或调用默认值 + line.SetStart(point); + CView::OnLButtonDown(nFlags, point); +} + + +void CBresenhamView::OnLButtonUp(UINT nFlags, CPoint point) +{ + // TODO: 在此添加消息处理程序代码和/或调用默认值 + line.SetEnd(point); + CDC* pDC = GetDC(); + line.BresenhamLine(pDC); + ReleaseDC(pDC); + CView::OnLButtonUp(nFlags, point); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/BresenhamView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/BresenhamView.h" new file mode 100644 index 0000000..42eeee5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/BresenhamView.h" @@ -0,0 +1,59 @@ + +// BresenhamView.h: CBresenhamView 类的接口 +// + +#pragma once +#include "CLineColor.h" + +class CBresenhamView : public CView +{ +protected: // 仅从序列化创建 + CBresenhamView() noexcept; + DECLARE_DYNCREATE(CBresenhamView) + +// 特性 +public: + CBresenhamDoc* GetDocument() const; + +// 操作 +public: + +// 重写 +public: + virtual void OnDraw(CDC* pDC); // 重写以绘制该视图 + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// 实现 +public: + virtual ~CBresenhamView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// 生成的消息映射函数 +protected: + afx_msg void OnFilePrintPreview(); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); +private: + CLineColor line; +public: + bool k; +}; + +#ifndef _DEBUG // BresenhamView.cpp 中的调试版本 +inline CBresenhamDoc* CBresenhamView::GetDocument() const + { return reinterpret_cast(m_pDocument); } +#endif + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/CLineColor.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/CLineColor.cpp" new file mode 100644 index 0000000..7144b83 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/CLineColor.cpp" @@ -0,0 +1,64 @@ +#include "pch.h" +#include "CLineColor.h" +CLineColor::CLineColor() +{ +} +CLineColor::CLineColor(CPoint p0, CPoint p1) +{ + P0 = p0; + P1 = p1; +} +CLineColor::~CLineColor() +{ +} +void CLineColor::SetStart(CPoint p0) +{ + P0 = p0; +} +void CLineColor::SetEnd(CPoint p1) +{ + P1 = p1; +} +CPoint CLineColor::GetEnd() +{ + return P1; +} +CPoint CLineColor::GetStart() +{ + return P0; +} +void CLineColor::BresenhamLine(CDC* pDC)//ֱ߻㷨ֱ +{ + int dx = abs(P1.x - P0.x); + int dy = abs(P1.y - P0.y); + bool bInterChange = TRUE; + int e, signX, signY, temp; + signX = (P1.x > P0.x) ? 1 : ((P1.x < P0.x) ? -1 : 0); + signY = (P1.y > P0.y) ? 1 : ((P1.y < P0.y) ? -1 : 0); + if (dy > dx) + { + temp = dx; + dx = dy; + dy = temp; + bInterChange = FALSE; + } + e = -dx; + CPoint p = P0; + for (int i = 1; i <= dx; i++) + { + pDC->SetPixelV(p.x, p.y, RGB(20, 60, 100)); + if (bInterChange) + p.x += signX; + else + p.y += signY; + e += 2 * dy; + if (e >= 0) + { + if (bInterChange) + p.y += signY; + else + p.x += signX; + e -= 2 * dx; + } + } +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/CLineColor.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/CLineColor.h" new file mode 100644 index 0000000..cbd977c --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/CLineColor.h" @@ -0,0 +1,16 @@ +#pragma once +class CLineColor +{ +private: + CPoint P0, P1; +public: + CLineColor(); + CLineColor(CPoint p0, CPoint p1); + void SetStart(CPoint p0); + void SetEnd(CPoint p1); + CPoint GetStart(); + CPoint GetEnd(); + ~CLineColor(); + void BresenhamLine(CDC* pDC); +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/ClassView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/ClassView.cpp" new file mode 100644 index 0000000..d66f9f5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/ClassView.cpp" @@ -0,0 +1,323 @@ + +#include "pch.h" +#include "framework.h" +#include "MainFrm.h" +#include "ClassView.h" +#include "Resource.h" +#include "Bresenham.h" + +class CClassViewMenuButton : public CMFCToolBarMenuButton +{ + friend class CClassView; + + DECLARE_SERIAL(CClassViewMenuButton) + +public: + CClassViewMenuButton(HMENU hMenu = nullptr) noexcept : CMFCToolBarMenuButton((UINT)-1, hMenu, -1) + { + } + + virtual void OnDraw(CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz = TRUE, + BOOL bCustomizeMode = FALSE, BOOL bHighlight = FALSE, BOOL bDrawBorder = TRUE, BOOL bGrayDisabledButtons = TRUE) + { + pImages = CMFCToolBar::GetImages(); + + CAfxDrawState ds; + pImages->PrepareDrawImage(ds); + + CMFCToolBarMenuButton::OnDraw(pDC, rect, pImages, bHorz, bCustomizeMode, bHighlight, bDrawBorder, bGrayDisabledButtons); + + pImages->EndDrawImage(ds); + } +}; + +IMPLEMENT_SERIAL(CClassViewMenuButton, CMFCToolBarMenuButton, 1) + +////////////////////////////////////////////////////////////////////// +// 构造/析构 +////////////////////////////////////////////////////////////////////// + +CClassView::CClassView() noexcept +{ + m_nCurrSort = ID_SORTING_GROUPBYTYPE; +} + +CClassView::~CClassView() +{ +} + +BEGIN_MESSAGE_MAP(CClassView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_CLASS_ADD_MEMBER_FUNCTION, OnClassAddMemberFunction) + ON_COMMAND(ID_CLASS_ADD_MEMBER_VARIABLE, OnClassAddMemberVariable) + ON_COMMAND(ID_CLASS_DEFINITION, OnClassDefinition) + ON_COMMAND(ID_CLASS_PROPERTIES, OnClassProperties) + ON_COMMAND(ID_NEW_FOLDER, OnNewFolder) + ON_WM_PAINT() + ON_WM_SETFOCUS() + ON_COMMAND_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnSort) + ON_UPDATE_COMMAND_UI_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnUpdateSort) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClassView 消息处理程序 + +int CClassView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndClassView.Create(dwViewStyle, rectDummy, this, 2)) + { + TRACE0("未能创建类视图\n"); + return -1; // 未能创建 + } + + // 加载图像: + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_SORT); + m_wndToolBar.LoadToolBar(IDR_SORT, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + CMenu menuSort; + menuSort.LoadMenu(IDR_POPUP_SORT); + + m_wndToolBar.ReplaceButton(ID_SORT_MENU, CClassViewMenuButton(menuSort.GetSubMenu(0)->GetSafeHmenu())); + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->m_bText = FALSE; + pButton->m_bImage = TRUE; + pButton->SetImage(GetCmdMgr()->GetCmdImage(m_nCurrSort)); + pButton->SetMessageWnd(this); + } + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillClassView(); + + return 0; +} + +void CClassView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CClassView::FillClassView() +{ + HTREEITEM hRoot = m_wndClassView.InsertItem(_T("FakeApp 类"), 0, 0); + m_wndClassView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hClass = m_wndClassView.InsertItem(_T("CFakeAboutDlg"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAboutDlg()"), 3, 3, hClass); + + m_wndClassView.Expand(hRoot, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeApp"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeApp()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("InitInstance()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnAppAbout()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppDoc"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppDoc()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppDoc()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnNewDocument()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppView"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppView()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppView()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("GetDocument()"), 3, 3, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppFrame"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("m_wndMenuBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndToolBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndStatusBar"), 6, 6, hClass); + + hClass = m_wndClassView.InsertItem(_T("Globals"), 2, 2, hRoot); + m_wndClassView.InsertItem(_T("theFakeApp"), 5, 5, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); +} + +void CClassView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndClassView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + CMenu menu; + menu.LoadMenu(IDR_POPUP_SORT); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } +} + +void CClassView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndClassView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +BOOL CClassView::PreTranslateMessage(MSG* pMsg) +{ + return CDockablePane::PreTranslateMessage(pMsg); +} + +void CClassView::OnSort(UINT id) +{ + if (m_nCurrSort == id) + { + return; + } + + m_nCurrSort = id; + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->SetImage(GetCmdMgr()->GetCmdImage(id)); + m_wndToolBar.Invalidate(); + m_wndToolBar.UpdateWindow(); + } +} + +void CClassView::OnUpdateSort(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(pCmdUI->m_nID == m_nCurrSort); +} + +void CClassView::OnClassAddMemberFunction() +{ + AfxMessageBox(_T("添加成员函数...")); +} + +void CClassView::OnClassAddMemberVariable() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassDefinition() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassProperties() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnNewFolder() +{ + AfxMessageBox(_T("新建文件夹...")); +} + +void CClassView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndClassView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CClassView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndClassView.SetFocus(); +} + +void CClassView::OnChangeVisualStyle() +{ + m_ClassViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_CLASS_VIEW_24 : IDB_CLASS_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_ClassViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_ClassViewImages.Add(&bmp, RGB(255, 0, 0)); + + m_wndClassView.SetImageList(&m_ClassViewImages, TVSIL_NORMAL); + + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_SORT_24 : IDR_SORT, 0, 0, TRUE /* 锁定*/); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/ClassView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/ClassView.h" new file mode 100644 index 0000000..786c278 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/ClassView.h" @@ -0,0 +1,54 @@ + +#pragma once + +#include "ViewTree.h" + +class CClassToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CClassView : public CDockablePane +{ +public: + CClassView() noexcept; + virtual ~CClassView(); + + void AdjustLayout(); + void OnChangeVisualStyle(); + +protected: + CClassToolBar m_wndToolBar; + CViewTree m_wndClassView; + CImageList m_ClassViewImages; + UINT m_nCurrSort; + + void FillClassView(); + +// 重写 +public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnClassAddMemberFunction(); + afx_msg void OnClassAddMemberVariable(); + afx_msg void OnClassDefinition(); + afx_msg void OnClassProperties(); + afx_msg void OnNewFolder(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg LRESULT OnChangeActiveTab(WPARAM, LPARAM); + afx_msg void OnSort(UINT id); + afx_msg void OnUpdateSort(CCmdUI* pCmdUI); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/FileView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/FileView.cpp" new file mode 100644 index 0000000..7bf57f8 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/FileView.cpp" @@ -0,0 +1,257 @@ + +#include "pch.h" +#include "framework.h" +#include "mainfrm.h" +#include "FileView.h" +#include "Resource.h" +#include "Bresenham.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CFileView + +CFileView::CFileView() noexcept +{ +} + +CFileView::~CFileView() +{ +} + +BEGIN_MESSAGE_MAP(CFileView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_PROPERTIES, OnProperties) + ON_COMMAND(ID_OPEN, OnFileOpen) + ON_COMMAND(ID_OPEN_WITH, OnFileOpenWith) + ON_COMMAND(ID_DUMMY_COMPILE, OnDummyCompile) + ON_COMMAND(ID_EDIT_CUT, OnEditCut) + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_WM_PAINT() + ON_WM_SETFOCUS() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CWorkspaceBar 消息处理程序 + +int CFileView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; + + if (!m_wndFileView.Create(dwViewStyle, rectDummy, this, 4)) + { + TRACE0("未能创建文件视图\n"); + return -1; // 未能创建 + } + + // 加载视图图像: + m_FileViewImages.Create(IDB_FILE_VIEW, 16, 0, RGB(255, 0, 255)); + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_EXPLORER); + m_wndToolBar.LoadToolBar(IDR_EXPLORER, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillFileView(); + AdjustLayout(); + + return 0; +} + +void CFileView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CFileView::FillFileView() +{ + HTREEITEM hRoot = m_wndFileView.InsertItem(_T("FakeApp 文件"), 0, 0); + m_wndFileView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hSrc = m_wndFileView.InsertItem(_T("FakeApp 源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeApp.rc"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppDoc.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppView.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("MainFrm.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("pch.cpp"), 1, 1, hSrc); + + HTREEITEM hInc = m_wndFileView.InsertItem(_T("FakeApp 头文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppDoc.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppView.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("Resource.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("MainFrm.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("pch.h"), 2, 2, hInc); + + HTREEITEM hRes = m_wndFileView.InsertItem(_T("FakeApp 资源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeApp.rc2"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeAppDoc.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeToolbar.bmp"), 2, 2, hRes); + + m_wndFileView.Expand(hRoot, TVE_EXPAND); + m_wndFileView.Expand(hSrc, TVE_EXPAND); + m_wndFileView.Expand(hInc, TVE_EXPAND); +} + +void CFileView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE); +} + +void CFileView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndFileView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +void CFileView::OnProperties() +{ + AfxMessageBox(_T("属性....")); + +} + +void CFileView::OnFileOpen() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnFileOpenWith() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnDummyCompile() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCut() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCopy() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditClear() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndFileView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CFileView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndFileView.SetFocus(); +} + +void CFileView::OnChangeVisualStyle() +{ + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_EXPLORER_24 : IDR_EXPLORER, 0, 0, TRUE /* 锁定*/); + + m_FileViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_FILE_VIEW_24 : IDB_FILE_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_FileViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_FileViewImages.Add(&bmp, RGB(255, 0, 255)); + + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); +} + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/FileView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/FileView.h" new file mode 100644 index 0000000..e39a7c9 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/FileView.h" @@ -0,0 +1,55 @@ + +#pragma once + +#include "ViewTree.h" + +class CFileViewToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CFileView : public CDockablePane +{ +// 构造 +public: + CFileView() noexcept; + + void AdjustLayout(); + void OnChangeVisualStyle(); + +// 特性 +protected: + + CViewTree m_wndFileView; + CImageList m_FileViewImages; + CFileViewToolBar m_wndToolBar; + +protected: + void FillFileView(); + +// 实现 +public: + virtual ~CFileView(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnProperties(); + afx_msg void OnFileOpen(); + afx_msg void OnFileOpenWith(); + afx_msg void OnDummyCompile(); + afx_msg void OnEditCut(); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/MainFrm.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/MainFrm.cpp" new file mode 100644 index 0000000..5ab8cd3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/MainFrm.cpp" @@ -0,0 +1,408 @@ + +// MainFrm.cpp: CMainFrame 类的实现 +// + +#include "pch.h" +#include "framework.h" +#include "Bresenham.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) + +const int iMaxUserToolbars = 10; +const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; +const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) + ON_WM_CREATE() + ON_COMMAND(ID_VIEW_CUSTOMIZE, &CMainFrame::OnViewCustomize) + ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, &CMainFrame::OnToolbarCreateNew) + ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook) + ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook) + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // 状态行指示器 + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +// CMainFrame 构造/析构 + +CMainFrame::CMainFrame() noexcept +{ + // TODO: 在此添加成员初始化代码 + theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2008); +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) + return -1; + + BOOL bNameValid; + + if (!m_wndMenuBar.Create(this)) + { + TRACE0("未能创建菜单栏\n"); + return -1; // 未能创建 + } + + m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); + + // 防止菜单栏在激活时获得焦点 + CMFCPopupMenu::SetForceMenuFocus(FALSE); + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) + { + TRACE0("未能创建工具栏\n"); + return -1; // 未能创建 + } + + CString strToolBarName; + bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); + ASSERT(bNameValid); + m_wndToolBar.SetWindowText(strToolBarName); + + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + + // 允许用户定义的工具栏操作: + InitUserToolbars(nullptr, uiFirstUserToolBarId, uiLastUserToolBarId); + + if (!m_wndStatusBar.Create(this)) + { + TRACE0("未能创建状态栏\n"); + return -1; // 未能创建 + } + m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); + + // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行 + m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndMenuBar); + DockPane(&m_wndToolBar); + + + // 启用 Visual Studio 2005 样式停靠窗口行为 + CDockingManager::SetDockingMode(DT_SMART); + // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 + EnableAutoHidePanes(CBRS_ALIGN_ANY); + + // 加载菜单项图像(不在任何标准工具栏上): + CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); + + // 创建停靠窗口 + if (!CreateDockingWindows()) + { + TRACE0("未能创建停靠窗口\n"); + return -1; + } + + m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); + m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndFileView); + CDockablePane* pTabbedBar = nullptr; + m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); + m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndOutput); + m_wndProperties.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndProperties); + + // 基于持久值设置视觉管理器和样式 + OnApplicationLook(theApp.m_nAppLook); + + // 启用工具栏和停靠窗口菜单替换 + EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); + + // 启用快速(按住 Alt 拖动)工具栏自定义 + CMFCToolBar::EnableQuickCustomization(); + + if (CMFCToolBar::GetUserImages() == nullptr) + { + // 加载用户定义的工具栏图像 + if (m_UserImages.Load(_T(".\\UserImages.bmp"))) + { + CMFCToolBar::SetUserImages(&m_UserImages); + } + } + + // 启用菜单个性化(最近使用的命令) + // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 + CList lstBasicCommands; + + lstBasicCommands.AddTail(ID_FILE_NEW); + lstBasicCommands.AddTail(ID_FILE_OPEN); + lstBasicCommands.AddTail(ID_FILE_SAVE); + lstBasicCommands.AddTail(ID_FILE_PRINT); + lstBasicCommands.AddTail(ID_APP_EXIT); + lstBasicCommands.AddTail(ID_EDIT_CUT); + lstBasicCommands.AddTail(ID_EDIT_PASTE); + lstBasicCommands.AddTail(ID_EDIT_UNDO); + lstBasicCommands.AddTail(ID_APP_ABOUT); + lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); + lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7); + lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); + lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); + lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); + lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); + + CMFCToolBar::SetBasicCommands(lstBasicCommands); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWndEx::PreCreateWindow(cs) ) + return FALSE; + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return TRUE; +} + +BOOL CMainFrame::CreateDockingWindows() +{ + BOOL bNameValid; + + // 创建类视图 + CString strClassView; + bNameValid = strClassView.LoadString(IDS_CLASS_VIEW); + ASSERT(bNameValid); + if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“类视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建文件视图 + CString strFileView; + bNameValid = strFileView.LoadString(IDS_FILE_VIEW); + ASSERT(bNameValid); + if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“文件视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建输出窗口 + CString strOutputWnd; + bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND); + ASSERT(bNameValid); + if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建输出窗口\n"); + return FALSE; // 未能创建 + } + + // 创建属性窗口 + CString strPropertiesWnd; + bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND); + ASSERT(bNameValid); + if (!m_wndProperties.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“属性”窗口\n"); + return FALSE; // 未能创建 + } + + SetDockingWindowIcons(theApp.m_bHiColorIcons); + return TRUE; +} + +void CMainFrame::SetDockingWindowIcons(BOOL bHiColorIcons) +{ + HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_FILE_VIEW_HC : IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndFileView.SetIcon(hFileViewIcon, FALSE); + + HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_CLASS_VIEW_HC : IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndClassView.SetIcon(hClassViewIcon, FALSE); + + HICON hOutputBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_OUTPUT_WND_HC : IDI_OUTPUT_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndOutput.SetIcon(hOutputBarIcon, FALSE); + + HICON hPropertiesBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_PROPERTIES_WND_HC : IDI_PROPERTIES_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndProperties.SetIcon(hPropertiesBarIcon, FALSE); + +} + +// CMainFrame 诊断 + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWndEx::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWndEx::Dump(dc); +} +#endif //_DEBUG + + +// CMainFrame 消息处理程序 + +void CMainFrame::OnViewCustomize() +{ + CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* 扫描菜单*/); + pDlgCust->EnableUserDefinedToolbars(); + pDlgCust->Create(); +} + +LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) +{ + LRESULT lres = CFrameWndEx::OnToolbarCreateNew(wp,lp); + if (lres == 0) + { + return 0; + } + + CMFCToolBar* pUserToolbar = (CMFCToolBar*)lres; + ASSERT_VALID(pUserToolbar); + + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + return lres; +} + +void CMainFrame::OnApplicationLook(UINT id) +{ + CWaitCursor wait; + + theApp.m_nAppLook = id; + + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_WIN_2000: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); + break; + + case ID_VIEW_APPLOOK_OFF_XP: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); + break; + + case ID_VIEW_APPLOOK_WIN_XP: + CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + break; + + case ID_VIEW_APPLOOK_OFF_2003: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2005: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2008: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_WINDOWS_7: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + default: + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_OFF_2007_BLUE: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); + break; + + case ID_VIEW_APPLOOK_OFF_2007_BLACK: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); + break; + + case ID_VIEW_APPLOOK_OFF_2007_SILVER: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); + break; + + case ID_VIEW_APPLOOK_OFF_2007_AQUA: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); + break; + } + + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); + CDockingManager::SetDockingMode(DT_SMART); + } + + m_wndOutput.UpdateFonts(); + RedrawWindow(nullptr, nullptr, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); + + theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); +} + +void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI) +{ + pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID); +} + + +BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) +{ + // 基类将执行真正的工作 + + if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) + { + return FALSE; + } + + + // 为所有用户工具栏启用自定义按钮 + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + for (int i = 0; i < iMaxUserToolbars; i ++) + { + CMFCToolBar* pUserToolbar = GetUserToolBarByIndex(i); + if (pUserToolbar != nullptr) + { + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + } + } + + return TRUE; +} + + +void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CFrameWndEx::OnSettingChange(uFlags, lpszSection); + m_wndOutput.UpdateFonts(); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/MainFrm.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/MainFrm.h" new file mode 100644 index 0000000..02feb8e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/MainFrm.h" @@ -0,0 +1,61 @@ + +// MainFrm.h: CMainFrame 类的接口 +// + +#pragma once +#include "FileView.h" +#include "ClassView.h" +#include "OutputWnd.h" +#include "PropertiesWnd.h" + +class CMainFrame : public CFrameWndEx +{ + +protected: // 仅从序列化创建 + CMainFrame() noexcept; + DECLARE_DYNCREATE(CMainFrame) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = nullptr, CCreateContext* pContext = nullptr); + +// 实现 +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // 控件条嵌入成员 + CMFCMenuBar m_wndMenuBar; + CMFCToolBar m_wndToolBar; + CMFCStatusBar m_wndStatusBar; + CMFCToolBarImages m_UserImages; + CFileView m_wndFileView; + CClassView m_wndClassView; + COutputWnd m_wndOutput; + CPropertiesWnd m_wndProperties; + +// 生成的消息映射函数 +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnViewCustomize(); + afx_msg LRESULT OnToolbarCreateNew(WPARAM wp, LPARAM lp); + afx_msg void OnApplicationLook(UINT id); + afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + DECLARE_MESSAGE_MAP() + + BOOL CreateDockingWindows(); + void SetDockingWindowIcons(BOOL bHiColorIcons); +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/OutputWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/OutputWnd.cpp" new file mode 100644 index 0000000..e3f4901 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/OutputWnd.cpp" @@ -0,0 +1,200 @@ + +#include "pch.h" +#include "framework.h" + +#include "OutputWnd.h" +#include "Resource.h" +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// COutputBar + +COutputWnd::COutputWnd() noexcept +{ +} + +COutputWnd::~COutputWnd() +{ +} + +BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() +END_MESSAGE_MAP() + +int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建选项卡窗口: + if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1)) + { + TRACE0("未能创建输出选项卡窗口\n"); + return -1; // 未能创建 + } + + // 创建输出窗格: + const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; + + if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) || + !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) || + !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4)) + { + TRACE0("未能创建输出窗口\n"); + return -1; // 未能创建 + } + + UpdateFonts(); + + CString strTabName; + BOOL bNameValid; + + // 将列表窗口附加到选项卡: + bNameValid = strTabName.LoadString(IDS_BUILD_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0); + bNameValid = strTabName.LoadString(IDS_DEBUG_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1); + bNameValid = strTabName.LoadString(IDS_FIND_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2); + + // 使用一些虚拟文本填写输出选项卡(无需复杂数据) + FillBuildWindow(); + FillDebugWindow(); + FillFindWindow(); + + return 0; +} + +void COutputWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + + // 选项卡控件应覆盖整个工作区: + m_wndTabs.SetWindowPos (nullptr, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); +} + +void COutputWnd::AdjustHorzScroll(CListBox& wndListBox) +{ + CClientDC dc(this); + CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular); + + int cxExtentMax = 0; + + for (int i = 0; i < wndListBox.GetCount(); i ++) + { + CString strItem; + wndListBox.GetText(i, strItem); + + cxExtentMax = max(cxExtentMax, (int)dc.GetTextExtent(strItem).cx); + } + + wndListBox.SetHorizontalExtent(cxExtentMax); + dc.SelectObject(pOldFont); +} + +void COutputWnd::FillBuildWindow() +{ + m_wndOutputBuild.AddString(_T("生成输出正显示在此处。")); + m_wndOutputBuild.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputBuild.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillDebugWindow() +{ + m_wndOutputDebug.AddString(_T("调试输出正显示在此处。")); + m_wndOutputDebug.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputDebug.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillFindWindow() +{ + m_wndOutputFind.AddString(_T("查找输出正显示在此处。")); + m_wndOutputFind.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputFind.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::UpdateFonts() +{ + m_wndOutputBuild.SetFont(&afxGlobalData.fontRegular); + m_wndOutputDebug.SetFont(&afxGlobalData.fontRegular); + m_wndOutputFind.SetFont(&afxGlobalData.fontRegular); +} + +///////////////////////////////////////////////////////////////////////////// +// COutputList1 + +COutputList::COutputList() noexcept +{ +} + +COutputList::~COutputList() +{ +} + +BEGIN_MESSAGE_MAP(COutputList, CListBox) + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput) + ON_WM_WINDOWPOSCHANGING() +END_MESSAGE_MAP() +///////////////////////////////////////////////////////////////////////////// +// COutputList 消息处理程序 + +void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) +{ + CMenu menu; + menu.LoadMenu(IDR_OUTPUT_POPUP); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } + + SetFocus(); +} + +void COutputList::OnEditCopy() +{ + MessageBox(_T("复制输出")); +} + +void COutputList::OnEditClear() +{ + MessageBox(_T("清除输出")); +} + +void COutputList::OnViewOutput() +{ + CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner()); + CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame()); + + if (pMainFrame != nullptr && pParentBar != nullptr) + { + pMainFrame->SetFocus(); + pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE); + pMainFrame->RecalcLayout(); + + } +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/OutputWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/OutputWnd.h" new file mode 100644 index 0000000..4d773c3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/OutputWnd.h" @@ -0,0 +1,59 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// COutputList 窗口 + +class COutputList : public CListBox +{ +// 构造 +public: + COutputList() noexcept; + +// 实现 +public: + virtual ~COutputList(); + +protected: + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnViewOutput(); + + DECLARE_MESSAGE_MAP() +}; + +class COutputWnd : public CDockablePane +{ +// 构造 +public: + COutputWnd() noexcept; + + void UpdateFonts(); + +// 特性 +protected: + CMFCTabCtrl m_wndTabs; + + COutputList m_wndOutputBuild; + COutputList m_wndOutputDebug; + COutputList m_wndOutputFind; + +protected: + void FillBuildWindow(); + void FillDebugWindow(); + void FillFindWindow(); + + void AdjustHorzScroll(CListBox& wndListBox); + +// 实现 +public: + virtual ~COutputWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/PropertiesWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/PropertiesWnd.cpp" new file mode 100644 index 0000000..311e484 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/PropertiesWnd.cpp" @@ -0,0 +1,273 @@ + +#include "pch.h" +#include "framework.h" + +#include "PropertiesWnd.h" +#include "Resource.h" +#include "MainFrm.h" +#include "Bresenham.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar + +CPropertiesWnd::CPropertiesWnd() noexcept +{ + m_nComboHeight = 0; +} + +CPropertiesWnd::~CPropertiesWnd() +{ +} + +BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties) + ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties) + ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties) + ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties) + ON_COMMAND(ID_PROPERTIES1, OnProperties1) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1) + ON_COMMAND(ID_PROPERTIES2, OnProperties2) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2) + ON_WM_SETFOCUS() + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar 消息处理程序 + +void CPropertiesWnd::AdjustLayout() +{ + if (GetSafeHwnd () == nullptr || (AfxGetMainWnd() != nullptr && AfxGetMainWnd()->IsIconic())) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndObjectCombo.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndPropList.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight + cyTlb, rectClient.Width(), rectClient.Height() -(m_nComboHeight+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER); +} + +int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建组合: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1)) + { + TRACE0("未能创建属性组合 \n"); + return -1; // 未能创建 + } + + m_wndObjectCombo.AddString(_T("应用程序")); + m_wndObjectCombo.AddString(_T("属性窗口")); + m_wndObjectCombo.SetCurSel(0); + + CRect rectCombo; + m_wndObjectCombo.GetClientRect (&rectCombo); + + m_nComboHeight = rectCombo.Height(); + + if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2)) + { + TRACE0("未能创建属性网格\n"); + return -1; // 未能创建 + } + + InitPropList(); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES); + m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* 已锁定*/); + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* 锁定*/); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + AdjustLayout(); + return 0; +} + +void CPropertiesWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CPropertiesWnd::OnExpandAllProperties() +{ + m_wndPropList.ExpandAll(); +} + +void CPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* /* pCmdUI */) +{ +} + +void CPropertiesWnd::OnSortProperties() +{ + m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnProperties1() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::OnProperties2() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::InitPropList() +{ + SetPropListFont(); + + m_wndPropList.EnableHeaderCtrl(FALSE); + m_wndPropList.EnableDescriptionArea(); + m_wndPropList.SetVSDotNetLook(); + m_wndPropList.MarkModifiedProperties(); + + CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("外观")); + + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("三维外观"), (_variant_t) false, _T("指定窗口的字体不使用粗体,并且控件将使用三维边框"))); + + CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("边框"), _T("对话框外框"), _T("其中之一: “无”、“细”、“可调整大小”或“对话框外框”")); + pProp->AddOption(_T("无")); + pProp->AddOption(_T("细")); + pProp->AddOption(_T("可调整大小")); + pProp->AddOption(_T("对话框外框")); + pProp->AllowEdit(FALSE); + + pGroup1->AddSubItem(pProp); + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("标题"), (_variant_t) _T("关于"), _T("指定窗口标题栏中显示的文本"))); + + m_wndPropList.AddProperty(pGroup1); + + CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("窗口大小"), 0, TRUE); + + pProp = new CMFCPropertyGridProperty(_T("高度"), (_variant_t) 250l, _T("指定窗口的高度")); + pProp->EnableSpinControl(TRUE, 50, 300); + pSize->AddSubItem(pProp); + + pProp = new CMFCPropertyGridProperty( _T("宽度"), (_variant_t) 150l, _T("指定窗口的宽度")); + pProp->EnableSpinControl(TRUE, 50, 200); + pSize->AddSubItem(pProp); + + m_wndPropList.AddProperty(pSize); + + CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("字体")); + + LOGFONT lf; + CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + font->GetLogFont(&lf); + + _tcscpy_s(lf.lfFaceName, _T("宋体, Arial")); + + pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("字体"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("指定窗口的默认字体"))); + pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("使用系统字体"), (_variant_t) true, _T("指定窗口使用“MS Shell Dlg”字体"))); + + m_wndPropList.AddProperty(pGroup2); + + CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("杂项")); + pProp = new CMFCPropertyGridProperty(_T("(名称)"), _T("应用程序")); + pProp->Enable(FALSE); + pGroup3->AddSubItem(pProp); + + CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("窗口颜色"), RGB(210, 192, 254), nullptr, _T("指定默认的窗口颜色")); + pColorProp->EnableOtherButton(_T("其他...")); + pColorProp->EnableAutomaticButton(_T("默认"), ::GetSysColor(COLOR_3DFACE)); + pGroup3->AddSubItem(pColorProp); + + static const TCHAR szFilter[] = _T("图标文件(*.ico)|*.ico|所有文件(*.*)|*.*||"); + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("图标"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("指定窗口图标"))); + + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("文件夹"), _T("c:\\"))); + + m_wndPropList.AddProperty(pGroup3); + + CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("层次结构")); + + CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("第一个子级")); + pGroup4->AddSubItem(pGroup41); + + CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("第二个子级")); + pGroup41->AddSubItem(pGroup411); + + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 1"), (_variant_t) _T("值 1"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 2"), (_variant_t) _T("值 2"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 3"), (_variant_t) _T("值 3"), _T("此为说明"))); + + pGroup4->Expand(FALSE); + m_wndPropList.AddProperty(pGroup4); +} + +void CPropertiesWnd::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + m_wndPropList.SetFocus(); +} + +void CPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CDockablePane::OnSettingChange(uFlags, lpszSection); + SetPropListFont(); +} + +void CPropertiesWnd::SetPropListFont() +{ + ::DeleteObject(m_fntPropList.Detach()); + + LOGFONT lf; + afxGlobalData.fontRegular.GetLogFont(&lf); + + NONCLIENTMETRICS info; + info.cbSize = sizeof(info); + + afxGlobalData.GetNonClientMetrics(info); + + lf.lfHeight = info.lfMenuFont.lfHeight; + lf.lfWeight = info.lfMenuFont.lfWeight; + lf.lfItalic = info.lfMenuFont.lfItalic; + + m_fntPropList.CreateFontIndirect(&lf); + + m_wndPropList.SetFont(&m_fntPropList); + m_wndObjectCombo.SetFont(&m_fntPropList); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/PropertiesWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/PropertiesWnd.h" new file mode 100644 index 0000000..e056430 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/PropertiesWnd.h" @@ -0,0 +1,62 @@ + +#pragma once + +class CPropertiesToolBar : public CMFCToolBar +{ +public: + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CPropertiesWnd : public CDockablePane +{ +// 构造 +public: + CPropertiesWnd() noexcept; + + void AdjustLayout(); + +// 特性 +public: + void SetVSDotNetLook(BOOL bSet) + { + m_wndPropList.SetVSDotNetLook(bSet); + m_wndPropList.SetGroupNameFullWidth(bSet); + } + +protected: + CFont m_fntPropList; + CComboBox m_wndObjectCombo; + CPropertiesToolBar m_wndToolBar; + CMFCPropertyGridCtrl m_wndPropList; + +// 实现 +public: + virtual ~CPropertiesWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnExpandAllProperties(); + afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI); + afx_msg void OnSortProperties(); + afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI); + afx_msg void OnProperties1(); + afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI); + afx_msg void OnProperties2(); + afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + + DECLARE_MESSAGE_MAP() + + void InitPropList(); + void SetPropListFont(); + + int m_nComboHeight; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Resource.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Resource.h" new file mode 100644 index 0000000..e3971b0 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/Resource.h" @@ -0,0 +1,97 @@ +//{{NO_DEPENDENCIES}} +// 生成的 Microsoft Visual C++ 包含文件。 +// 由 Bresenham.rc 使用 +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_POPUP_EDIT 119 +#define ID_STATUSBAR_PANE1 120 +#define ID_STATUSBAR_PANE2 121 +#define IDS_STATUS_PANE1 122 +#define IDS_STATUS_PANE2 123 +#define IDS_TOOLBAR_STANDARD 124 +#define IDS_TOOLBAR_CUSTOMIZE 125 +#define ID_VIEW_CUSTOMIZE 126 +#define IDR_MAINFRAME 128 +#define IDR_MAINFRAME_256 129 +#define IDR_BresenhamTYPE 130 +#define ID_WINDOW_MANAGER 131 +#define ID_VIEW_FILEVIEW 133 +#define ID_VIEW_CLASSVIEW 134 +#define ID_PROPERTIES 135 +#define ID_OPEN 136 +#define ID_OPEN_WITH 137 +#define ID_DUMMY_COMPILE 138 +#define ID_CLASS_ADD_MEMBER_FUNCTION 139 +#define ID_CLASS_ADD_MEMBER_VARIABLE 140 +#define ID_CLASS_DEFINITION 141 +#define ID_CLASS_PROPERTIES 142 +#define ID_NEW_FOLDER 143 +#define ID_SORT_MENU 144 +#define ID_SORTING_GROUPBYTYPE 145 +#define ID_SORTING_SORTALPHABETIC 146 +#define ID_SORTING_SORTBYTYPE 147 +#define ID_SORTING_SORTBYACCESS 148 +#define ID_VIEW_OUTPUTWND 149 +#define ID_VIEW_PROPERTIESWND 150 +#define ID_SORTPROPERTIES 151 +#define ID_PROPERTIES1 152 +#define ID_PROPERTIES2 153 +#define ID_EXPAND_ALL 154 +#define IDS_FILE_VIEW 155 +#define IDS_CLASS_VIEW 156 +#define IDS_OUTPUT_WND 157 +#define IDS_PROPERTIES_WND 158 +#define IDI_FILE_VIEW 161 +#define IDI_FILE_VIEW_HC 162 +#define IDI_CLASS_VIEW 163 +#define IDI_CLASS_VIEW_HC 164 +#define IDI_OUTPUT_WND 165 +#define IDI_OUTPUT_WND_HC 166 +#define IDI_PROPERTIES_WND 167 +#define IDI_PROPERTIES_WND_HC 168 +#define IDR_EXPLORER 169 +#define IDB_EXPLORER_24 170 +#define IDR_SORT 171 +#define IDB_SORT_24 172 +#define IDR_POPUP_SORT 173 +#define IDR_POPUP_EXPLORER 174 +#define IDB_FILE_VIEW 175 +#define IDB_FILE_VIEW_24 176 +#define IDB_CLASS_VIEW 177 +#define IDB_CLASS_VIEW_24 178 +#define IDR_MENU_IMAGES 179 +#define IDB_MENU_IMAGES_24 180 +#define ID_TOOLS_MACRO 181 +#define IDR_OUTPUT_POPUP 182 +#define IDR_PROPERTIES 183 +#define IDB_PROPERTIES_HC 184 +#define IDR_THEME_MENU 200 +#define ID_SET_STYLE 201 +#define ID_VIEW_APPLOOK_WIN_2000 205 +#define ID_VIEW_APPLOOK_OFF_XP 206 +#define ID_VIEW_APPLOOK_WIN_XP 207 +#define ID_VIEW_APPLOOK_OFF_2003 208 +#define ID_VIEW_APPLOOK_VS_2005 209 +#define ID_VIEW_APPLOOK_VS_2008 210 +#define ID_VIEW_APPLOOK_OFF_2007_BLUE 215 +#define ID_VIEW_APPLOOK_OFF_2007_BLACK 216 +#define ID_VIEW_APPLOOK_OFF_2007_SILVER 217 +#define ID_VIEW_APPLOOK_OFF_2007_AQUA 218 +#define ID_VIEW_APPLOOK_WINDOWS_7 219 +#define IDS_BUILD_TAB 300 +#define IDS_DEBUG_TAB 301 +#define IDS_FIND_TAB 302 +#define IDS_EXPLORER 305 +#define IDS_EDIT_MENU 306 + +// 新对象的下一组默认值 +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 310 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 310 +#define _APS_NEXT_COMMAND_VALUE 32771 +#endif +#endif diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/ViewTree.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/ViewTree.cpp" new file mode 100644 index 0000000..84996cb --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/ViewTree.cpp" @@ -0,0 +1,43 @@ + +#include "pch.h" +#include "framework.h" +#include "ViewTree.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CViewTree + +CViewTree::CViewTree() noexcept +{ +} + +CViewTree::~CViewTree() +{ +} + +BEGIN_MESSAGE_MAP(CViewTree, CTreeCtrl) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 消息处理程序 + +BOOL CViewTree::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult); + + NMHDR* pNMHDR = (NMHDR*)lParam; + ASSERT(pNMHDR != nullptr); + +#pragma warning(suppress : 26454) + if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips() != nullptr) + { + GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); + } + + return bRes; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/ViewTree.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/ViewTree.h" new file mode 100644 index 0000000..0267d80 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/ViewTree.h" @@ -0,0 +1,23 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 窗口 + +class CViewTree : public CTreeCtrl +{ +// 构造 +public: + CViewTree() noexcept; + +// 重写 +protected: + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + +// 实现 +public: + virtual ~CViewTree(); + +protected: + DECLARE_MESSAGE_MAP() +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/framework.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/pch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/pch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/pch.h" new file mode 100644 index 0000000..9660927 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/pch.h" @@ -0,0 +1,13 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" + +#endif //PCH_H diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/Bresenham.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/Bresenham.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/Bresenham.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/Bresenham.rc2" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/Bresenham.rc2" new file mode 100644 index 0000000..d320ebf Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/Bresenham.rc2" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/BresenhamDoc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/BresenhamDoc.ico" new file mode 100644 index 0000000..96365d4 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/BresenhamDoc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/Toolbar.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/Toolbar.bmp" new file mode 100644 index 0000000..d501723 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/Toolbar.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/Toolbar256.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/Toolbar256.bmp" new file mode 100644 index 0000000..91a2553 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/Toolbar256.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/class_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/class_view.ico" new file mode 100644 index 0000000..bf6b0dd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/class_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/class_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/class_view_hc.ico" new file mode 100644 index 0000000..3112bf2 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/class_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/classview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/classview.bmp" new file mode 100644 index 0000000..1e02aa1 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/classview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/classview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/classview_hc.bmp" new file mode 100644 index 0000000..6b22e78 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/classview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/explorer.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/explorer.bmp" new file mode 100644 index 0000000..01298ba Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/explorer.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/explorer_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/explorer_hc.bmp" new file mode 100644 index 0000000..697199d Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/explorer_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/file_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/file_view.ico" new file mode 100644 index 0000000..0f93f52 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/file_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/file_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/file_view_hc.ico" new file mode 100644 index 0000000..42ec435 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/file_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/fileview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/fileview.bmp" new file mode 100644 index 0000000..a2d62d0 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/fileview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/fileview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/fileview_hc.bmp" new file mode 100644 index 0000000..b60f483 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/fileview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/menuimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/menuimages.bmp" new file mode 100644 index 0000000..7771841 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/menuimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/menuimages_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/menuimages_hc.bmp" new file mode 100644 index 0000000..577926e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/menuimages_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/output_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/output_wnd.ico" new file mode 100644 index 0000000..d14f991 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/output_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/output_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/output_wnd_hc.ico" new file mode 100644 index 0000000..fdd27e8 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/output_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/properties.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/properties.bmp" new file mode 100644 index 0000000..72e2b29 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/properties.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/properties_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/properties_hc.bmp" new file mode 100644 index 0000000..d18a7ca Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/properties_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/properties_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/properties_wnd.ico" new file mode 100644 index 0000000..3611766 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/properties_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/properties_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/properties_wnd_hc.ico" new file mode 100644 index 0000000..1e06b64 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/properties_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/sort.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/sort.bmp" new file mode 100644 index 0000000..0307301 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/sort.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/sort_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/sort_hc.bmp" new file mode 100644 index 0000000..720e742 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/sort_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/userimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/userimages.bmp" new file mode 100644 index 0000000..affe657 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/res/userimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/targetver.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/Bresenham/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/ClassView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/ClassView.cpp" new file mode 100644 index 0000000..88fb841 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/ClassView.cpp" @@ -0,0 +1,323 @@ + +#include "pch.h" +#include "framework.h" +#include "MainFrm.h" +#include "ClassView.h" +#include "Resource.h" +#include "DDA.h" + +class CClassViewMenuButton : public CMFCToolBarMenuButton +{ + friend class CClassView; + + DECLARE_SERIAL(CClassViewMenuButton) + +public: + CClassViewMenuButton(HMENU hMenu = nullptr) noexcept : CMFCToolBarMenuButton((UINT)-1, hMenu, -1) + { + } + + virtual void OnDraw(CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz = TRUE, + BOOL bCustomizeMode = FALSE, BOOL bHighlight = FALSE, BOOL bDrawBorder = TRUE, BOOL bGrayDisabledButtons = TRUE) + { + pImages = CMFCToolBar::GetImages(); + + CAfxDrawState ds; + pImages->PrepareDrawImage(ds); + + CMFCToolBarMenuButton::OnDraw(pDC, rect, pImages, bHorz, bCustomizeMode, bHighlight, bDrawBorder, bGrayDisabledButtons); + + pImages->EndDrawImage(ds); + } +}; + +IMPLEMENT_SERIAL(CClassViewMenuButton, CMFCToolBarMenuButton, 1) + +////////////////////////////////////////////////////////////////////// +// 构造/析构 +////////////////////////////////////////////////////////////////////// + +CClassView::CClassView() noexcept +{ + m_nCurrSort = ID_SORTING_GROUPBYTYPE; +} + +CClassView::~CClassView() +{ +} + +BEGIN_MESSAGE_MAP(CClassView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_CLASS_ADD_MEMBER_FUNCTION, OnClassAddMemberFunction) + ON_COMMAND(ID_CLASS_ADD_MEMBER_VARIABLE, OnClassAddMemberVariable) + ON_COMMAND(ID_CLASS_DEFINITION, OnClassDefinition) + ON_COMMAND(ID_CLASS_PROPERTIES, OnClassProperties) + ON_COMMAND(ID_NEW_FOLDER, OnNewFolder) + ON_WM_PAINT() + ON_WM_SETFOCUS() + ON_COMMAND_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnSort) + ON_UPDATE_COMMAND_UI_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnUpdateSort) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClassView 消息处理程序 + +int CClassView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndClassView.Create(dwViewStyle, rectDummy, this, 2)) + { + TRACE0("未能创建类视图\n"); + return -1; // 未能创建 + } + + // 加载图像: + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_SORT); + m_wndToolBar.LoadToolBar(IDR_SORT, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + CMenu menuSort; + menuSort.LoadMenu(IDR_POPUP_SORT); + + m_wndToolBar.ReplaceButton(ID_SORT_MENU, CClassViewMenuButton(menuSort.GetSubMenu(0)->GetSafeHmenu())); + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->m_bText = FALSE; + pButton->m_bImage = TRUE; + pButton->SetImage(GetCmdMgr()->GetCmdImage(m_nCurrSort)); + pButton->SetMessageWnd(this); + } + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillClassView(); + + return 0; +} + +void CClassView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CClassView::FillClassView() +{ + HTREEITEM hRoot = m_wndClassView.InsertItem(_T("FakeApp 类"), 0, 0); + m_wndClassView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hClass = m_wndClassView.InsertItem(_T("CFakeAboutDlg"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAboutDlg()"), 3, 3, hClass); + + m_wndClassView.Expand(hRoot, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeApp"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeApp()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("InitInstance()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnAppAbout()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppDoc"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppDoc()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppDoc()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnNewDocument()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppView"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppView()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppView()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("GetDocument()"), 3, 3, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppFrame"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("m_wndMenuBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndToolBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndStatusBar"), 6, 6, hClass); + + hClass = m_wndClassView.InsertItem(_T("Globals"), 2, 2, hRoot); + m_wndClassView.InsertItem(_T("theFakeApp"), 5, 5, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); +} + +void CClassView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndClassView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + CMenu menu; + menu.LoadMenu(IDR_POPUP_SORT); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } +} + +void CClassView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndClassView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +BOOL CClassView::PreTranslateMessage(MSG* pMsg) +{ + return CDockablePane::PreTranslateMessage(pMsg); +} + +void CClassView::OnSort(UINT id) +{ + if (m_nCurrSort == id) + { + return; + } + + m_nCurrSort = id; + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->SetImage(GetCmdMgr()->GetCmdImage(id)); + m_wndToolBar.Invalidate(); + m_wndToolBar.UpdateWindow(); + } +} + +void CClassView::OnUpdateSort(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(pCmdUI->m_nID == m_nCurrSort); +} + +void CClassView::OnClassAddMemberFunction() +{ + AfxMessageBox(_T("添加成员函数...")); +} + +void CClassView::OnClassAddMemberVariable() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassDefinition() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassProperties() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnNewFolder() +{ + AfxMessageBox(_T("新建文件夹...")); +} + +void CClassView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndClassView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CClassView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndClassView.SetFocus(); +} + +void CClassView::OnChangeVisualStyle() +{ + m_ClassViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_CLASS_VIEW_24 : IDB_CLASS_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_ClassViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_ClassViewImages.Add(&bmp, RGB(255, 0, 0)); + + m_wndClassView.SetImageList(&m_ClassViewImages, TVSIL_NORMAL); + + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_SORT_24 : IDR_SORT, 0, 0, TRUE /* 锁定*/); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/ClassView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/ClassView.h" new file mode 100644 index 0000000..786c278 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/ClassView.h" @@ -0,0 +1,54 @@ + +#pragma once + +#include "ViewTree.h" + +class CClassToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CClassView : public CDockablePane +{ +public: + CClassView() noexcept; + virtual ~CClassView(); + + void AdjustLayout(); + void OnChangeVisualStyle(); + +protected: + CClassToolBar m_wndToolBar; + CViewTree m_wndClassView; + CImageList m_ClassViewImages; + UINT m_nCurrSort; + + void FillClassView(); + +// 重写 +public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnClassAddMemberFunction(); + afx_msg void OnClassAddMemberVariable(); + afx_msg void OnClassDefinition(); + afx_msg void OnClassProperties(); + afx_msg void OnNewFolder(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg LRESULT OnChangeActiveTab(WPARAM, LPARAM); + afx_msg void OnSort(UINT id); + afx_msg void OnUpdateSort(CCmdUI* pCmdUI); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.APS" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.APS" new file mode 100644 index 0000000..6af6571 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.APS" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.cpp" new file mode 100644 index 0000000..0651ee7 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.cpp" @@ -0,0 +1,219 @@ + +// DDA.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "afxwinappex.h" +#include "afxdialogex.h" +#include "DDA.h" +#include "MainFrm.h" + +#include "DDADoc.h" +#include "DDAView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CDDAApp + +BEGIN_MESSAGE_MAP(CDDAApp, CWinAppEx) + ON_COMMAND(ID_APP_ABOUT, &CDDAApp::OnAppAbout) + // 基于文件的标准文档命令 + ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) + // 标准打印设置命令 + ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup) +END_MESSAGE_MAP() + + +// CDDAApp 构造 + +CDDAApp::CDDAApp() noexcept +{ + m_bHiColorIcons = TRUE; + + + m_nAppLook = 0; + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; +#ifdef _MANAGED + // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则: + // 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。 + // 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。 + System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); +#endif + + // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式 + //为 CompanyName.ProductName.SubProduct.VersionInformation + SetAppID(_T("DDA.AppID.NoVersion")); + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + +// 唯一的 CDDAApp 对象 + +CDDAApp theApp; + + +// CDDAApp 初始化 + +BOOL CDDAApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinAppEx::InitInstance(); + + + // 初始化 OLE 库 + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + + AfxEnableControlContainer(); + + EnableTaskbarInteraction(FALSE); + + // 使用 RichEdit 控件需要 AfxInitRichEdit2() + // AfxInitRichEdit2(); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) + + + InitContextMenuManager(); + + InitKeyboardManager(); + + InitTooltipManager(); + CMFCToolTipInfo ttParams; + ttParams.m_bVislManagerTheme = TRUE; + theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, + RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); + + // 注册应用程序的文档模板。 文档模板 + // 将用作文档、框架窗口和视图之间的连接 + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(CDDADoc), + RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 + RUNTIME_CLASS(CDDAView)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + + + // 分析标准 shell 命令、DDE、打开文件操作的命令行 + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + + + // 调度在命令行中指定的命令。 如果 + // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + + // 唯一的一个窗口已初始化,因此显示它并对其进行更新 + m_pMainWnd->ShowWindow(SW_SHOW); + m_pMainWnd->UpdateWindow(); + return TRUE; +} + +int CDDAApp::ExitInstance() +{ + //TODO: 处理可能已添加的附加资源 + AfxOleTerm(FALSE); + + return CWinAppEx::ExitInstance(); +} + +// CDDAApp 消息处理程序 + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg() noexcept; + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + +// 用于运行对话框的应用程序命令 +void CDDAApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +// CDDAApp 自定义加载/保存方法 + +void CDDAApp::PreLoadState() +{ + BOOL bNameValid; + CString strName; + bNameValid = strName.LoadString(IDS_EDIT_MENU); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); + bNameValid = strName.LoadString(IDS_EXPLORER); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EXPLORER); +} + +void CDDAApp::LoadCustomState() +{ +} + +void CDDAApp::SaveCustomState() +{ +} + +// CDDAApp 消息处理程序 + + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.h" new file mode 100644 index 0000000..75fea20 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.h" @@ -0,0 +1,40 @@ + +// DDA.h: DDA 应用程序的主头文件 +// +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// CDDAApp: +// 有关此类的实现,请参阅 DDA.cpp +// + +class CDDAApp : public CWinAppEx +{ +public: + CDDAApp() noexcept; + + +// 重写 +public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + +// 实现 + UINT m_nAppLook; + BOOL m_bHiColorIcons; + + virtual void PreLoadState(); + virtual void LoadCustomState(); + virtual void SaveCustomState(); + + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern CDDAApp theApp; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.rc" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.rc" new file mode 100644 index 0000000..63d4b48 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.rc" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.sln" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.sln" new file mode 100644 index 0000000..91dc3e6 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33414.496 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DDA", "DDA.vcxproj", "{7C69B1BA-6893-489E-A005-C9E632F6B16F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7C69B1BA-6893-489E-A005-C9E632F6B16F}.Debug|x64.ActiveCfg = Debug|x64 + {7C69B1BA-6893-489E-A005-C9E632F6B16F}.Debug|x64.Build.0 = Debug|x64 + {7C69B1BA-6893-489E-A005-C9E632F6B16F}.Debug|x86.ActiveCfg = Debug|Win32 + {7C69B1BA-6893-489E-A005-C9E632F6B16F}.Debug|x86.Build.0 = Debug|Win32 + {7C69B1BA-6893-489E-A005-C9E632F6B16F}.Release|x64.ActiveCfg = Release|x64 + {7C69B1BA-6893-489E-A005-C9E632F6B16F}.Release|x64.Build.0 = Release|x64 + {7C69B1BA-6893-489E-A005-C9E632F6B16F}.Release|x86.ActiveCfg = Release|Win32 + {7C69B1BA-6893-489E-A005-C9E632F6B16F}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DDB201D1-2C5C-4B7B-AEC2-E4793F9B3D1D} + EndGlobalSection +EndGlobal diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.vcxproj" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.vcxproj" new file mode 100644 index 0000000..bbab95c --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.vcxproj" @@ -0,0 +1,255 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {7C69B1BA-6893-489E-A005-C9E632F6B16F} + MFCProj + DDA + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.vcxproj.filters" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.vcxproj.filters" new file mode 100644 index 0000000..c929e51 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.vcxproj.filters" @@ -0,0 +1,183 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.vcxproj.user" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.vcxproj.user" new file mode 100644 index 0000000..8c33bd2 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDA.vcxproj.user" @@ -0,0 +1,6 @@ + + + + DDA.rc + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDADoc.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDADoc.cpp" new file mode 100644 index 0000000..1d37ddc --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDADoc.cpp" @@ -0,0 +1,138 @@ + +// DDADoc.cpp: CDDADoc 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "DDA.h" +#endif + +#include "DDADoc.h" + +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CDDADoc + +IMPLEMENT_DYNCREATE(CDDADoc, CDocument) + +BEGIN_MESSAGE_MAP(CDDADoc, CDocument) +END_MESSAGE_MAP() + + +// CDDADoc 构造/析构 + +CDDADoc::CDDADoc() noexcept +{ + // TODO: 在此添加一次性构造代码 + +} + +CDDADoc::~CDDADoc() +{ +} + +BOOL CDDADoc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: 在此添加重新初始化代码 + // (SDI 文档将重用该文档) + + return TRUE; +} + + + + +// CDDADoc 序列化 + +void CDDADoc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: 在此添加存储代码 + } + else + { + // TODO: 在此添加加载代码 + } +} + +#ifdef SHARED_HANDLERS + +// 缩略图的支持 +void CDDADoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds) +{ + // 修改此代码以绘制文档数据 + dc.FillSolidRect(lprcBounds, RGB(255, 255, 255)); + + CString strText = _T("TODO: implement thumbnail drawing here"); + LOGFONT lf; + + CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + pDefaultGUIFont->GetLogFont(&lf); + lf.lfHeight = 36; + + CFont fontDraw; + fontDraw.CreateFontIndirect(&lf); + + CFont* pOldFont = dc.SelectObject(&fontDraw); + dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK); + dc.SelectObject(pOldFont); +} + +// 搜索处理程序的支持 +void CDDADoc::InitializeSearchContent() +{ + CString strSearchContent; + // 从文档数据设置搜索内容。 + // 内容部分应由“;”分隔 + + // 例如: strSearchContent = _T("point;rectangle;circle;ole object;"); + SetSearchContent(strSearchContent); +} + +void CDDADoc::SetSearchContent(const CString& value) +{ + if (value.IsEmpty()) + { + RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); + } + else + { + CMFCFilterChunkValueImpl *pChunk = nullptr; + ATLTRY(pChunk = new CMFCFilterChunkValueImpl); + if (pChunk != nullptr) + { + pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT); + SetChunkValue(pChunk); + } + } +} + +#endif // SHARED_HANDLERS + +// CDDADoc 诊断 + +#ifdef _DEBUG +void CDDADoc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CDDADoc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// CDDADoc 命令 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDADoc.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDADoc.h" new file mode 100644 index 0000000..0cdbe04 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDADoc.h" @@ -0,0 +1,48 @@ + +// DDADoc.h: CDDADoc 类的接口 +// + + +#pragma once + + +class CDDADoc : public CDocument +{ +protected: // 仅从序列化创建 + CDDADoc() noexcept; + DECLARE_DYNCREATE(CDDADoc) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); +#ifdef SHARED_HANDLERS + virtual void InitializeSearchContent(); + virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds); +#endif // SHARED_HANDLERS + +// 实现 +public: + virtual ~CDDADoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// 生成的消息映射函数 +protected: + DECLARE_MESSAGE_MAP() + +#ifdef SHARED_HANDLERS + // 用于为搜索处理程序设置搜索内容的 Helper 函数 + void SetSearchContent(const CString& value); +#endif // SHARED_HANDLERS +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDALine.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDALine.cpp" new file mode 100644 index 0000000..1f0cbd7 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDALine.cpp" @@ -0,0 +1,45 @@ +#include "pch.h" +#include "DDALine.h" +void DDALine::SetStart(CPoint p0) +{ + P0 = p0; +} +void DDALine::SetEnd(CPoint p1) +{ + P1 = p1; +} +CPoint DDALine::GetStart() +{ + return P1; +} +CPoint DDALine::GetEnd() +{ + return P0; +} +void DDALine::CDDALine(CDC* pDC) +{ + float dx, dy, x, y, steps; + int i; + + dx = P1.x - P0.x; + dy = P1.y - P0.y; + + if (abs(dx) > abs(dy)) { + steps = abs(dx); + } + else { + steps = abs(dy); + } + + float xIncrement = dx / steps; + float yIncrement = dy / steps; + + x = P0.x; + y = P0.y; + + for (i = 0; i < steps; i++) { + pDC->SetPixel(x, y, RGB(255, 100, 20)); + x += xIncrement; + y += yIncrement; + } +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDALine.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDALine.h" new file mode 100644 index 0000000..e66255b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDALine.h" @@ -0,0 +1,12 @@ +#pragma once +class DDALine +{ +private: + CPoint P0, P1; +public: + void SetStart(CPoint p0); + void SetEnd(CPoint p1); + CPoint GetStart(); + CPoint GetEnd(); + void CDDALine(CDC* pDC); +}; \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDAView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDAView.cpp" new file mode 100644 index 0000000..1a33bad --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDAView.cpp" @@ -0,0 +1,148 @@ + +// DDAView.cpp: CDDAView 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "DDA.h" +#endif + +#include "DDADoc.h" +#include "DDAView.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CDDAView + +IMPLEMENT_DYNCREATE(CDDAView, CView) + +BEGIN_MESSAGE_MAP(CDDAView, CView) + // 标准打印命令 + ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CDDAView::OnFilePrintPreview) + ON_WM_CONTEXTMENU() + ON_WM_RBUTTONUP() + ON_WM_LBUTTONUP() + ON_WM_LBUTTONDOWN() +END_MESSAGE_MAP() + +// CDDAView 构造/析构 + +CDDAView::CDDAView() noexcept +{ + // TODO: 在此处添加构造代码 + +} + +CDDAView::~CDDAView() +{ +} + +BOOL CDDAView::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return CView::PreCreateWindow(cs); +} + +// CDDAView 绘图 + +void CDDAView::OnDraw(CDC* /*pDC*/) +{ + CDDADoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + + // TODO: 在此处为本机数据添加绘制代码 +} + + +// CDDAView 打印 + + +void CDDAView::OnFilePrintPreview() +{ +#ifndef SHARED_HANDLERS + AFXPrintPreview(this); +#endif +} + +BOOL CDDAView::OnPreparePrinting(CPrintInfo* pInfo) +{ + // 默认准备 + return DoPreparePrinting(pInfo); +} + +void CDDAView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加额外的打印前进行的初始化过程 +} + +void CDDAView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加打印后进行的清理过程 +} + +void CDDAView::OnRButtonUp(UINT /* nFlags */, CPoint point) +{ + ClientToScreen(&point); + OnContextMenu(this, point); +} + +void CDDAView::OnContextMenu(CWnd* /* pWnd */, CPoint point) +{ +#ifndef SHARED_HANDLERS + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE); +#endif +} + + +// CDDAView 诊断 + +#ifdef _DEBUG +void CDDAView::AssertValid() const +{ + CView::AssertValid(); +} + +void CDDAView::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +CDDADoc* CDDAView::GetDocument() const // 非调试版本是内联的 +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDDADoc))); + return (CDDADoc*)m_pDocument; +} +#endif //_DEBUG + + +// CDDAView 消息处理程序 + + +void CDDAView::OnLButtonDown(UINT nFlags, CPoint point) +{ + // TODO: 在此添加消息处理程序代码和/或调用默认值 + line.SetStart(point); + CView::OnLButtonDown(nFlags, point); +} + + +void CDDAView::OnLButtonUp(UINT nFlags, CPoint point) +{ + // TODO: 在此添加消息处理程序代码和/或调用默认值 + line.SetEnd(point); + CDC* pDC = GetDC(); + line.CDDALine(pDC); + ReleaseDC(pDC); + CView::OnLButtonUp(nFlags, point); +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDAView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDAView.h" new file mode 100644 index 0000000..25044bb --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/DDAView.h" @@ -0,0 +1,56 @@ + +// DDAView.h: CDDAView 类的接口 +// + +#pragma once +#include "DDALine.h" + +class CDDAView : public CView +{ +protected: // 仅从序列化创建 + CDDAView() noexcept; + DECLARE_DYNCREATE(CDDAView) + +// 特性 +public: + CDDADoc* GetDocument() const; + +// 操作 +public: + +// 重写 +public: + virtual void OnDraw(CDC* pDC); // 重写以绘制该视图 + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// 实现 +public: + virtual ~CDDAView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// 生成的消息映射函数 +protected: + afx_msg void OnFilePrintPreview(); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + DDALine line; +}; + +#ifndef _DEBUG // DDAView.cpp 中的调试版本 +inline CDDADoc* CDDAView::GetDocument() const + { return reinterpret_cast(m_pDocument); } +#endif + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/FileView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/FileView.cpp" new file mode 100644 index 0000000..97c4478 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/FileView.cpp" @@ -0,0 +1,257 @@ + +#include "pch.h" +#include "framework.h" +#include "mainfrm.h" +#include "FileView.h" +#include "Resource.h" +#include "DDA.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CFileView + +CFileView::CFileView() noexcept +{ +} + +CFileView::~CFileView() +{ +} + +BEGIN_MESSAGE_MAP(CFileView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_PROPERTIES, OnProperties) + ON_COMMAND(ID_OPEN, OnFileOpen) + ON_COMMAND(ID_OPEN_WITH, OnFileOpenWith) + ON_COMMAND(ID_DUMMY_COMPILE, OnDummyCompile) + ON_COMMAND(ID_EDIT_CUT, OnEditCut) + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_WM_PAINT() + ON_WM_SETFOCUS() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CWorkspaceBar 消息处理程序 + +int CFileView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; + + if (!m_wndFileView.Create(dwViewStyle, rectDummy, this, 4)) + { + TRACE0("未能创建文件视图\n"); + return -1; // 未能创建 + } + + // 加载视图图像: + m_FileViewImages.Create(IDB_FILE_VIEW, 16, 0, RGB(255, 0, 255)); + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_EXPLORER); + m_wndToolBar.LoadToolBar(IDR_EXPLORER, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillFileView(); + AdjustLayout(); + + return 0; +} + +void CFileView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CFileView::FillFileView() +{ + HTREEITEM hRoot = m_wndFileView.InsertItem(_T("FakeApp 文件"), 0, 0); + m_wndFileView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hSrc = m_wndFileView.InsertItem(_T("FakeApp 源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeApp.rc"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppDoc.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppView.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("MainFrm.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("pch.cpp"), 1, 1, hSrc); + + HTREEITEM hInc = m_wndFileView.InsertItem(_T("FakeApp 头文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppDoc.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppView.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("Resource.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("MainFrm.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("pch.h"), 2, 2, hInc); + + HTREEITEM hRes = m_wndFileView.InsertItem(_T("FakeApp 资源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeApp.rc2"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeAppDoc.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeToolbar.bmp"), 2, 2, hRes); + + m_wndFileView.Expand(hRoot, TVE_EXPAND); + m_wndFileView.Expand(hSrc, TVE_EXPAND); + m_wndFileView.Expand(hInc, TVE_EXPAND); +} + +void CFileView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE); +} + +void CFileView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndFileView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +void CFileView::OnProperties() +{ + AfxMessageBox(_T("属性....")); + +} + +void CFileView::OnFileOpen() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnFileOpenWith() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnDummyCompile() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCut() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCopy() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditClear() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndFileView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CFileView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndFileView.SetFocus(); +} + +void CFileView::OnChangeVisualStyle() +{ + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_EXPLORER_24 : IDR_EXPLORER, 0, 0, TRUE /* 锁定*/); + + m_FileViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_FILE_VIEW_24 : IDB_FILE_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_FileViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_FileViewImages.Add(&bmp, RGB(255, 0, 255)); + + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); +} + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/FileView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/FileView.h" new file mode 100644 index 0000000..e39a7c9 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/FileView.h" @@ -0,0 +1,55 @@ + +#pragma once + +#include "ViewTree.h" + +class CFileViewToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CFileView : public CDockablePane +{ +// 构造 +public: + CFileView() noexcept; + + void AdjustLayout(); + void OnChangeVisualStyle(); + +// 特性 +protected: + + CViewTree m_wndFileView; + CImageList m_FileViewImages; + CFileViewToolBar m_wndToolBar; + +protected: + void FillFileView(); + +// 实现 +public: + virtual ~CFileView(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnProperties(); + afx_msg void OnFileOpen(); + afx_msg void OnFileOpenWith(); + afx_msg void OnDummyCompile(); + afx_msg void OnEditCut(); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/MainFrm.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/MainFrm.cpp" new file mode 100644 index 0000000..d3e60f4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/MainFrm.cpp" @@ -0,0 +1,408 @@ + +// MainFrm.cpp: CMainFrame 类的实现 +// + +#include "pch.h" +#include "framework.h" +#include "DDA.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) + +const int iMaxUserToolbars = 10; +const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; +const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) + ON_WM_CREATE() + ON_COMMAND(ID_VIEW_CUSTOMIZE, &CMainFrame::OnViewCustomize) + ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, &CMainFrame::OnToolbarCreateNew) + ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook) + ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook) + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // 状态行指示器 + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +// CMainFrame 构造/析构 + +CMainFrame::CMainFrame() noexcept +{ + // TODO: 在此添加成员初始化代码 + theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2008); +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) + return -1; + + BOOL bNameValid; + + if (!m_wndMenuBar.Create(this)) + { + TRACE0("未能创建菜单栏\n"); + return -1; // 未能创建 + } + + m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); + + // 防止菜单栏在激活时获得焦点 + CMFCPopupMenu::SetForceMenuFocus(FALSE); + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) + { + TRACE0("未能创建工具栏\n"); + return -1; // 未能创建 + } + + CString strToolBarName; + bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); + ASSERT(bNameValid); + m_wndToolBar.SetWindowText(strToolBarName); + + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + + // 允许用户定义的工具栏操作: + InitUserToolbars(nullptr, uiFirstUserToolBarId, uiLastUserToolBarId); + + if (!m_wndStatusBar.Create(this)) + { + TRACE0("未能创建状态栏\n"); + return -1; // 未能创建 + } + m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); + + // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行 + m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndMenuBar); + DockPane(&m_wndToolBar); + + + // 启用 Visual Studio 2005 样式停靠窗口行为 + CDockingManager::SetDockingMode(DT_SMART); + // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 + EnableAutoHidePanes(CBRS_ALIGN_ANY); + + // 加载菜单项图像(不在任何标准工具栏上): + CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); + + // 创建停靠窗口 + if (!CreateDockingWindows()) + { + TRACE0("未能创建停靠窗口\n"); + return -1; + } + + m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); + m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndFileView); + CDockablePane* pTabbedBar = nullptr; + m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); + m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndOutput); + m_wndProperties.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndProperties); + + // 基于持久值设置视觉管理器和样式 + OnApplicationLook(theApp.m_nAppLook); + + // 启用工具栏和停靠窗口菜单替换 + EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); + + // 启用快速(按住 Alt 拖动)工具栏自定义 + CMFCToolBar::EnableQuickCustomization(); + + if (CMFCToolBar::GetUserImages() == nullptr) + { + // 加载用户定义的工具栏图像 + if (m_UserImages.Load(_T(".\\UserImages.bmp"))) + { + CMFCToolBar::SetUserImages(&m_UserImages); + } + } + + // 启用菜单个性化(最近使用的命令) + // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 + CList lstBasicCommands; + + lstBasicCommands.AddTail(ID_FILE_NEW); + lstBasicCommands.AddTail(ID_FILE_OPEN); + lstBasicCommands.AddTail(ID_FILE_SAVE); + lstBasicCommands.AddTail(ID_FILE_PRINT); + lstBasicCommands.AddTail(ID_APP_EXIT); + lstBasicCommands.AddTail(ID_EDIT_CUT); + lstBasicCommands.AddTail(ID_EDIT_PASTE); + lstBasicCommands.AddTail(ID_EDIT_UNDO); + lstBasicCommands.AddTail(ID_APP_ABOUT); + lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); + lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7); + lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); + lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); + lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); + lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); + + CMFCToolBar::SetBasicCommands(lstBasicCommands); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWndEx::PreCreateWindow(cs) ) + return FALSE; + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return TRUE; +} + +BOOL CMainFrame::CreateDockingWindows() +{ + BOOL bNameValid; + + // 创建类视图 + CString strClassView; + bNameValid = strClassView.LoadString(IDS_CLASS_VIEW); + ASSERT(bNameValid); + if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“类视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建文件视图 + CString strFileView; + bNameValid = strFileView.LoadString(IDS_FILE_VIEW); + ASSERT(bNameValid); + if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“文件视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建输出窗口 + CString strOutputWnd; + bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND); + ASSERT(bNameValid); + if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建输出窗口\n"); + return FALSE; // 未能创建 + } + + // 创建属性窗口 + CString strPropertiesWnd; + bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND); + ASSERT(bNameValid); + if (!m_wndProperties.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“属性”窗口\n"); + return FALSE; // 未能创建 + } + + SetDockingWindowIcons(theApp.m_bHiColorIcons); + return TRUE; +} + +void CMainFrame::SetDockingWindowIcons(BOOL bHiColorIcons) +{ + HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_FILE_VIEW_HC : IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndFileView.SetIcon(hFileViewIcon, FALSE); + + HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_CLASS_VIEW_HC : IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndClassView.SetIcon(hClassViewIcon, FALSE); + + HICON hOutputBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_OUTPUT_WND_HC : IDI_OUTPUT_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndOutput.SetIcon(hOutputBarIcon, FALSE); + + HICON hPropertiesBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_PROPERTIES_WND_HC : IDI_PROPERTIES_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndProperties.SetIcon(hPropertiesBarIcon, FALSE); + +} + +// CMainFrame 诊断 + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWndEx::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWndEx::Dump(dc); +} +#endif //_DEBUG + + +// CMainFrame 消息处理程序 + +void CMainFrame::OnViewCustomize() +{ + CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* 扫描菜单*/); + pDlgCust->EnableUserDefinedToolbars(); + pDlgCust->Create(); +} + +LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) +{ + LRESULT lres = CFrameWndEx::OnToolbarCreateNew(wp,lp); + if (lres == 0) + { + return 0; + } + + CMFCToolBar* pUserToolbar = (CMFCToolBar*)lres; + ASSERT_VALID(pUserToolbar); + + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + return lres; +} + +void CMainFrame::OnApplicationLook(UINT id) +{ + CWaitCursor wait; + + theApp.m_nAppLook = id; + + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_WIN_2000: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); + break; + + case ID_VIEW_APPLOOK_OFF_XP: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); + break; + + case ID_VIEW_APPLOOK_WIN_XP: + CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + break; + + case ID_VIEW_APPLOOK_OFF_2003: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2005: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2008: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_WINDOWS_7: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + default: + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_OFF_2007_BLUE: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); + break; + + case ID_VIEW_APPLOOK_OFF_2007_BLACK: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); + break; + + case ID_VIEW_APPLOOK_OFF_2007_SILVER: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); + break; + + case ID_VIEW_APPLOOK_OFF_2007_AQUA: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); + break; + } + + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); + CDockingManager::SetDockingMode(DT_SMART); + } + + m_wndOutput.UpdateFonts(); + RedrawWindow(nullptr, nullptr, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); + + theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); +} + +void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI) +{ + pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID); +} + + +BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) +{ + // 基类将执行真正的工作 + + if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) + { + return FALSE; + } + + + // 为所有用户工具栏启用自定义按钮 + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + for (int i = 0; i < iMaxUserToolbars; i ++) + { + CMFCToolBar* pUserToolbar = GetUserToolBarByIndex(i); + if (pUserToolbar != nullptr) + { + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + } + } + + return TRUE; +} + + +void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CFrameWndEx::OnSettingChange(uFlags, lpszSection); + m_wndOutput.UpdateFonts(); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/MainFrm.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/MainFrm.h" new file mode 100644 index 0000000..02feb8e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/MainFrm.h" @@ -0,0 +1,61 @@ + +// MainFrm.h: CMainFrame 类的接口 +// + +#pragma once +#include "FileView.h" +#include "ClassView.h" +#include "OutputWnd.h" +#include "PropertiesWnd.h" + +class CMainFrame : public CFrameWndEx +{ + +protected: // 仅从序列化创建 + CMainFrame() noexcept; + DECLARE_DYNCREATE(CMainFrame) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = nullptr, CCreateContext* pContext = nullptr); + +// 实现 +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // 控件条嵌入成员 + CMFCMenuBar m_wndMenuBar; + CMFCToolBar m_wndToolBar; + CMFCStatusBar m_wndStatusBar; + CMFCToolBarImages m_UserImages; + CFileView m_wndFileView; + CClassView m_wndClassView; + COutputWnd m_wndOutput; + CPropertiesWnd m_wndProperties; + +// 生成的消息映射函数 +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnViewCustomize(); + afx_msg LRESULT OnToolbarCreateNew(WPARAM wp, LPARAM lp); + afx_msg void OnApplicationLook(UINT id); + afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + DECLARE_MESSAGE_MAP() + + BOOL CreateDockingWindows(); + void SetDockingWindowIcons(BOOL bHiColorIcons); +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/OutputWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/OutputWnd.cpp" new file mode 100644 index 0000000..e3f4901 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/OutputWnd.cpp" @@ -0,0 +1,200 @@ + +#include "pch.h" +#include "framework.h" + +#include "OutputWnd.h" +#include "Resource.h" +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// COutputBar + +COutputWnd::COutputWnd() noexcept +{ +} + +COutputWnd::~COutputWnd() +{ +} + +BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() +END_MESSAGE_MAP() + +int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建选项卡窗口: + if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1)) + { + TRACE0("未能创建输出选项卡窗口\n"); + return -1; // 未能创建 + } + + // 创建输出窗格: + const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; + + if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) || + !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) || + !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4)) + { + TRACE0("未能创建输出窗口\n"); + return -1; // 未能创建 + } + + UpdateFonts(); + + CString strTabName; + BOOL bNameValid; + + // 将列表窗口附加到选项卡: + bNameValid = strTabName.LoadString(IDS_BUILD_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0); + bNameValid = strTabName.LoadString(IDS_DEBUG_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1); + bNameValid = strTabName.LoadString(IDS_FIND_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2); + + // 使用一些虚拟文本填写输出选项卡(无需复杂数据) + FillBuildWindow(); + FillDebugWindow(); + FillFindWindow(); + + return 0; +} + +void COutputWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + + // 选项卡控件应覆盖整个工作区: + m_wndTabs.SetWindowPos (nullptr, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); +} + +void COutputWnd::AdjustHorzScroll(CListBox& wndListBox) +{ + CClientDC dc(this); + CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular); + + int cxExtentMax = 0; + + for (int i = 0; i < wndListBox.GetCount(); i ++) + { + CString strItem; + wndListBox.GetText(i, strItem); + + cxExtentMax = max(cxExtentMax, (int)dc.GetTextExtent(strItem).cx); + } + + wndListBox.SetHorizontalExtent(cxExtentMax); + dc.SelectObject(pOldFont); +} + +void COutputWnd::FillBuildWindow() +{ + m_wndOutputBuild.AddString(_T("生成输出正显示在此处。")); + m_wndOutputBuild.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputBuild.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillDebugWindow() +{ + m_wndOutputDebug.AddString(_T("调试输出正显示在此处。")); + m_wndOutputDebug.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputDebug.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillFindWindow() +{ + m_wndOutputFind.AddString(_T("查找输出正显示在此处。")); + m_wndOutputFind.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputFind.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::UpdateFonts() +{ + m_wndOutputBuild.SetFont(&afxGlobalData.fontRegular); + m_wndOutputDebug.SetFont(&afxGlobalData.fontRegular); + m_wndOutputFind.SetFont(&afxGlobalData.fontRegular); +} + +///////////////////////////////////////////////////////////////////////////// +// COutputList1 + +COutputList::COutputList() noexcept +{ +} + +COutputList::~COutputList() +{ +} + +BEGIN_MESSAGE_MAP(COutputList, CListBox) + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput) + ON_WM_WINDOWPOSCHANGING() +END_MESSAGE_MAP() +///////////////////////////////////////////////////////////////////////////// +// COutputList 消息处理程序 + +void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) +{ + CMenu menu; + menu.LoadMenu(IDR_OUTPUT_POPUP); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } + + SetFocus(); +} + +void COutputList::OnEditCopy() +{ + MessageBox(_T("复制输出")); +} + +void COutputList::OnEditClear() +{ + MessageBox(_T("清除输出")); +} + +void COutputList::OnViewOutput() +{ + CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner()); + CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame()); + + if (pMainFrame != nullptr && pParentBar != nullptr) + { + pMainFrame->SetFocus(); + pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE); + pMainFrame->RecalcLayout(); + + } +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/OutputWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/OutputWnd.h" new file mode 100644 index 0000000..4d773c3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/OutputWnd.h" @@ -0,0 +1,59 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// COutputList 窗口 + +class COutputList : public CListBox +{ +// 构造 +public: + COutputList() noexcept; + +// 实现 +public: + virtual ~COutputList(); + +protected: + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnViewOutput(); + + DECLARE_MESSAGE_MAP() +}; + +class COutputWnd : public CDockablePane +{ +// 构造 +public: + COutputWnd() noexcept; + + void UpdateFonts(); + +// 特性 +protected: + CMFCTabCtrl m_wndTabs; + + COutputList m_wndOutputBuild; + COutputList m_wndOutputDebug; + COutputList m_wndOutputFind; + +protected: + void FillBuildWindow(); + void FillDebugWindow(); + void FillFindWindow(); + + void AdjustHorzScroll(CListBox& wndListBox); + +// 实现 +public: + virtual ~COutputWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/PropertiesWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/PropertiesWnd.cpp" new file mode 100644 index 0000000..203dbf6 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/PropertiesWnd.cpp" @@ -0,0 +1,273 @@ + +#include "pch.h" +#include "framework.h" + +#include "PropertiesWnd.h" +#include "Resource.h" +#include "MainFrm.h" +#include "DDA.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar + +CPropertiesWnd::CPropertiesWnd() noexcept +{ + m_nComboHeight = 0; +} + +CPropertiesWnd::~CPropertiesWnd() +{ +} + +BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties) + ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties) + ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties) + ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties) + ON_COMMAND(ID_PROPERTIES1, OnProperties1) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1) + ON_COMMAND(ID_PROPERTIES2, OnProperties2) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2) + ON_WM_SETFOCUS() + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar 消息处理程序 + +void CPropertiesWnd::AdjustLayout() +{ + if (GetSafeHwnd () == nullptr || (AfxGetMainWnd() != nullptr && AfxGetMainWnd()->IsIconic())) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndObjectCombo.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndPropList.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight + cyTlb, rectClient.Width(), rectClient.Height() -(m_nComboHeight+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER); +} + +int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建组合: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1)) + { + TRACE0("未能创建属性组合 \n"); + return -1; // 未能创建 + } + + m_wndObjectCombo.AddString(_T("应用程序")); + m_wndObjectCombo.AddString(_T("属性窗口")); + m_wndObjectCombo.SetCurSel(0); + + CRect rectCombo; + m_wndObjectCombo.GetClientRect (&rectCombo); + + m_nComboHeight = rectCombo.Height(); + + if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2)) + { + TRACE0("未能创建属性网格\n"); + return -1; // 未能创建 + } + + InitPropList(); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES); + m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* 已锁定*/); + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* 锁定*/); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + AdjustLayout(); + return 0; +} + +void CPropertiesWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CPropertiesWnd::OnExpandAllProperties() +{ + m_wndPropList.ExpandAll(); +} + +void CPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* /* pCmdUI */) +{ +} + +void CPropertiesWnd::OnSortProperties() +{ + m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnProperties1() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::OnProperties2() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::InitPropList() +{ + SetPropListFont(); + + m_wndPropList.EnableHeaderCtrl(FALSE); + m_wndPropList.EnableDescriptionArea(); + m_wndPropList.SetVSDotNetLook(); + m_wndPropList.MarkModifiedProperties(); + + CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("外观")); + + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("三维外观"), (_variant_t) false, _T("指定窗口的字体不使用粗体,并且控件将使用三维边框"))); + + CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("边框"), _T("对话框外框"), _T("其中之一: “无”、“细”、“可调整大小”或“对话框外框”")); + pProp->AddOption(_T("无")); + pProp->AddOption(_T("细")); + pProp->AddOption(_T("可调整大小")); + pProp->AddOption(_T("对话框外框")); + pProp->AllowEdit(FALSE); + + pGroup1->AddSubItem(pProp); + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("标题"), (_variant_t) _T("关于"), _T("指定窗口标题栏中显示的文本"))); + + m_wndPropList.AddProperty(pGroup1); + + CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("窗口大小"), 0, TRUE); + + pProp = new CMFCPropertyGridProperty(_T("高度"), (_variant_t) 250l, _T("指定窗口的高度")); + pProp->EnableSpinControl(TRUE, 50, 300); + pSize->AddSubItem(pProp); + + pProp = new CMFCPropertyGridProperty( _T("宽度"), (_variant_t) 150l, _T("指定窗口的宽度")); + pProp->EnableSpinControl(TRUE, 50, 200); + pSize->AddSubItem(pProp); + + m_wndPropList.AddProperty(pSize); + + CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("字体")); + + LOGFONT lf; + CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + font->GetLogFont(&lf); + + _tcscpy_s(lf.lfFaceName, _T("宋体, Arial")); + + pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("字体"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("指定窗口的默认字体"))); + pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("使用系统字体"), (_variant_t) true, _T("指定窗口使用“MS Shell Dlg”字体"))); + + m_wndPropList.AddProperty(pGroup2); + + CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("杂项")); + pProp = new CMFCPropertyGridProperty(_T("(名称)"), _T("应用程序")); + pProp->Enable(FALSE); + pGroup3->AddSubItem(pProp); + + CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("窗口颜色"), RGB(210, 192, 254), nullptr, _T("指定默认的窗口颜色")); + pColorProp->EnableOtherButton(_T("其他...")); + pColorProp->EnableAutomaticButton(_T("默认"), ::GetSysColor(COLOR_3DFACE)); + pGroup3->AddSubItem(pColorProp); + + static const TCHAR szFilter[] = _T("图标文件(*.ico)|*.ico|所有文件(*.*)|*.*||"); + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("图标"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("指定窗口图标"))); + + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("文件夹"), _T("c:\\"))); + + m_wndPropList.AddProperty(pGroup3); + + CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("层次结构")); + + CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("第一个子级")); + pGroup4->AddSubItem(pGroup41); + + CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("第二个子级")); + pGroup41->AddSubItem(pGroup411); + + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 1"), (_variant_t) _T("值 1"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 2"), (_variant_t) _T("值 2"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 3"), (_variant_t) _T("值 3"), _T("此为说明"))); + + pGroup4->Expand(FALSE); + m_wndPropList.AddProperty(pGroup4); +} + +void CPropertiesWnd::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + m_wndPropList.SetFocus(); +} + +void CPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CDockablePane::OnSettingChange(uFlags, lpszSection); + SetPropListFont(); +} + +void CPropertiesWnd::SetPropListFont() +{ + ::DeleteObject(m_fntPropList.Detach()); + + LOGFONT lf; + afxGlobalData.fontRegular.GetLogFont(&lf); + + NONCLIENTMETRICS info; + info.cbSize = sizeof(info); + + afxGlobalData.GetNonClientMetrics(info); + + lf.lfHeight = info.lfMenuFont.lfHeight; + lf.lfWeight = info.lfMenuFont.lfWeight; + lf.lfItalic = info.lfMenuFont.lfItalic; + + m_fntPropList.CreateFontIndirect(&lf); + + m_wndPropList.SetFont(&m_fntPropList); + m_wndObjectCombo.SetFont(&m_fntPropList); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/PropertiesWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/PropertiesWnd.h" new file mode 100644 index 0000000..e056430 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/PropertiesWnd.h" @@ -0,0 +1,62 @@ + +#pragma once + +class CPropertiesToolBar : public CMFCToolBar +{ +public: + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CPropertiesWnd : public CDockablePane +{ +// 构造 +public: + CPropertiesWnd() noexcept; + + void AdjustLayout(); + +// 特性 +public: + void SetVSDotNetLook(BOOL bSet) + { + m_wndPropList.SetVSDotNetLook(bSet); + m_wndPropList.SetGroupNameFullWidth(bSet); + } + +protected: + CFont m_fntPropList; + CComboBox m_wndObjectCombo; + CPropertiesToolBar m_wndToolBar; + CMFCPropertyGridCtrl m_wndPropList; + +// 实现 +public: + virtual ~CPropertiesWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnExpandAllProperties(); + afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI); + afx_msg void OnSortProperties(); + afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI); + afx_msg void OnProperties1(); + afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI); + afx_msg void OnProperties2(); + afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + + DECLARE_MESSAGE_MAP() + + void InitPropList(); + void SetPropListFont(); + + int m_nComboHeight; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/Resource.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/Resource.h" new file mode 100644 index 0000000..a8a44ef --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/Resource.h" @@ -0,0 +1,97 @@ +//{{NO_DEPENDENCIES}} +// 生成的 Microsoft Visual C++ 包含文件。 +// 由 DDA.rc 使用 +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_POPUP_EDIT 119 +#define ID_STATUSBAR_PANE1 120 +#define ID_STATUSBAR_PANE2 121 +#define IDS_STATUS_PANE1 122 +#define IDS_STATUS_PANE2 123 +#define IDS_TOOLBAR_STANDARD 124 +#define IDS_TOOLBAR_CUSTOMIZE 125 +#define ID_VIEW_CUSTOMIZE 126 +#define IDR_MAINFRAME 128 +#define IDR_MAINFRAME_256 129 +#define IDR_DDATYPE 130 +#define ID_WINDOW_MANAGER 131 +#define ID_VIEW_FILEVIEW 133 +#define ID_VIEW_CLASSVIEW 134 +#define ID_PROPERTIES 135 +#define ID_OPEN 136 +#define ID_OPEN_WITH 137 +#define ID_DUMMY_COMPILE 138 +#define ID_CLASS_ADD_MEMBER_FUNCTION 139 +#define ID_CLASS_ADD_MEMBER_VARIABLE 140 +#define ID_CLASS_DEFINITION 141 +#define ID_CLASS_PROPERTIES 142 +#define ID_NEW_FOLDER 143 +#define ID_SORT_MENU 144 +#define ID_SORTING_GROUPBYTYPE 145 +#define ID_SORTING_SORTALPHABETIC 146 +#define ID_SORTING_SORTBYTYPE 147 +#define ID_SORTING_SORTBYACCESS 148 +#define ID_VIEW_OUTPUTWND 149 +#define ID_VIEW_PROPERTIESWND 150 +#define ID_SORTPROPERTIES 151 +#define ID_PROPERTIES1 152 +#define ID_PROPERTIES2 153 +#define ID_EXPAND_ALL 154 +#define IDS_FILE_VIEW 155 +#define IDS_CLASS_VIEW 156 +#define IDS_OUTPUT_WND 157 +#define IDS_PROPERTIES_WND 158 +#define IDI_FILE_VIEW 161 +#define IDI_FILE_VIEW_HC 162 +#define IDI_CLASS_VIEW 163 +#define IDI_CLASS_VIEW_HC 164 +#define IDI_OUTPUT_WND 165 +#define IDI_OUTPUT_WND_HC 166 +#define IDI_PROPERTIES_WND 167 +#define IDI_PROPERTIES_WND_HC 168 +#define IDR_EXPLORER 169 +#define IDB_EXPLORER_24 170 +#define IDR_SORT 171 +#define IDB_SORT_24 172 +#define IDR_POPUP_SORT 173 +#define IDR_POPUP_EXPLORER 174 +#define IDB_FILE_VIEW 175 +#define IDB_FILE_VIEW_24 176 +#define IDB_CLASS_VIEW 177 +#define IDB_CLASS_VIEW_24 178 +#define IDR_MENU_IMAGES 179 +#define IDB_MENU_IMAGES_24 180 +#define ID_TOOLS_MACRO 181 +#define IDR_OUTPUT_POPUP 182 +#define IDR_PROPERTIES 183 +#define IDB_PROPERTIES_HC 184 +#define IDR_THEME_MENU 200 +#define ID_SET_STYLE 201 +#define ID_VIEW_APPLOOK_WIN_2000 205 +#define ID_VIEW_APPLOOK_OFF_XP 206 +#define ID_VIEW_APPLOOK_WIN_XP 207 +#define ID_VIEW_APPLOOK_OFF_2003 208 +#define ID_VIEW_APPLOOK_VS_2005 209 +#define ID_VIEW_APPLOOK_VS_2008 210 +#define ID_VIEW_APPLOOK_OFF_2007_BLUE 215 +#define ID_VIEW_APPLOOK_OFF_2007_BLACK 216 +#define ID_VIEW_APPLOOK_OFF_2007_SILVER 217 +#define ID_VIEW_APPLOOK_OFF_2007_AQUA 218 +#define ID_VIEW_APPLOOK_WINDOWS_7 219 +#define IDS_BUILD_TAB 300 +#define IDS_DEBUG_TAB 301 +#define IDS_FIND_TAB 302 +#define IDS_EXPLORER 305 +#define IDS_EDIT_MENU 306 + +// 新对象的下一组默认值 +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 310 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 310 +#define _APS_NEXT_COMMAND_VALUE 32771 +#endif +#endif diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/ViewTree.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/ViewTree.cpp" new file mode 100644 index 0000000..84996cb --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/ViewTree.cpp" @@ -0,0 +1,43 @@ + +#include "pch.h" +#include "framework.h" +#include "ViewTree.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CViewTree + +CViewTree::CViewTree() noexcept +{ +} + +CViewTree::~CViewTree() +{ +} + +BEGIN_MESSAGE_MAP(CViewTree, CTreeCtrl) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 消息处理程序 + +BOOL CViewTree::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult); + + NMHDR* pNMHDR = (NMHDR*)lParam; + ASSERT(pNMHDR != nullptr); + +#pragma warning(suppress : 26454) + if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips() != nullptr) + { + GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); + } + + return bRes; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/ViewTree.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/ViewTree.h" new file mode 100644 index 0000000..0267d80 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/ViewTree.h" @@ -0,0 +1,23 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 窗口 + +class CViewTree : public CTreeCtrl +{ +// 构造 +public: + CViewTree() noexcept; + +// 重写 +protected: + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + +// 实现 +public: + virtual ~CViewTree(); + +protected: + DECLARE_MESSAGE_MAP() +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/framework.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/pch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/pch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/pch.h" new file mode 100644 index 0000000..9660927 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/pch.h" @@ -0,0 +1,13 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" + +#endif //PCH_H diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/DDA.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/DDA.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/DDA.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/DDA.rc2" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/DDA.rc2" new file mode 100644 index 0000000..fa524f8 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/DDA.rc2" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/DDADoc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/DDADoc.ico" new file mode 100644 index 0000000..96365d4 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/DDADoc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/Toolbar.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/Toolbar.bmp" new file mode 100644 index 0000000..d501723 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/Toolbar.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/Toolbar256.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/Toolbar256.bmp" new file mode 100644 index 0000000..91a2553 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/Toolbar256.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/class_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/class_view.ico" new file mode 100644 index 0000000..bf6b0dd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/class_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/class_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/class_view_hc.ico" new file mode 100644 index 0000000..3112bf2 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/class_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/classview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/classview.bmp" new file mode 100644 index 0000000..1e02aa1 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/classview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/classview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/classview_hc.bmp" new file mode 100644 index 0000000..6b22e78 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/classview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/explorer.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/explorer.bmp" new file mode 100644 index 0000000..01298ba Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/explorer.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/explorer_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/explorer_hc.bmp" new file mode 100644 index 0000000..697199d Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/explorer_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/file_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/file_view.ico" new file mode 100644 index 0000000..0f93f52 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/file_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/file_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/file_view_hc.ico" new file mode 100644 index 0000000..42ec435 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/file_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/fileview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/fileview.bmp" new file mode 100644 index 0000000..a2d62d0 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/fileview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/fileview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/fileview_hc.bmp" new file mode 100644 index 0000000..b60f483 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/fileview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/menuimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/menuimages.bmp" new file mode 100644 index 0000000..7771841 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/menuimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/menuimages_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/menuimages_hc.bmp" new file mode 100644 index 0000000..577926e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/menuimages_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/output_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/output_wnd.ico" new file mode 100644 index 0000000..d14f991 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/output_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/output_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/output_wnd_hc.ico" new file mode 100644 index 0000000..fdd27e8 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/output_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/properties.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/properties.bmp" new file mode 100644 index 0000000..72e2b29 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/properties.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/properties_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/properties_hc.bmp" new file mode 100644 index 0000000..d18a7ca Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/properties_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/properties_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/properties_wnd.ico" new file mode 100644 index 0000000..3611766 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/properties_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/properties_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/properties_wnd_hc.ico" new file mode 100644 index 0000000..1e06b64 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/properties_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/sort.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/sort.bmp" new file mode 100644 index 0000000..0307301 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/sort.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/sort_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/sort_hc.bmp" new file mode 100644 index 0000000..720e742 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/sort_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/userimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/userimages.bmp" new file mode 100644 index 0000000..affe657 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/res/userimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/targetver.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/DDA/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ClassView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ClassView.cpp" new file mode 100644 index 0000000..bc321a0 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ClassView.cpp" @@ -0,0 +1,323 @@ + +#include "pch.h" +#include "framework.h" +#include "MainFrm.h" +#include "ClassView.h" +#include "Resource.h" +#include "ex1.h" + +class CClassViewMenuButton : public CMFCToolBarMenuButton +{ + friend class CClassView; + + DECLARE_SERIAL(CClassViewMenuButton) + +public: + CClassViewMenuButton(HMENU hMenu = nullptr) noexcept : CMFCToolBarMenuButton((UINT)-1, hMenu, -1) + { + } + + virtual void OnDraw(CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz = TRUE, + BOOL bCustomizeMode = FALSE, BOOL bHighlight = FALSE, BOOL bDrawBorder = TRUE, BOOL bGrayDisabledButtons = TRUE) + { + pImages = CMFCToolBar::GetImages(); + + CAfxDrawState ds; + pImages->PrepareDrawImage(ds); + + CMFCToolBarMenuButton::OnDraw(pDC, rect, pImages, bHorz, bCustomizeMode, bHighlight, bDrawBorder, bGrayDisabledButtons); + + pImages->EndDrawImage(ds); + } +}; + +IMPLEMENT_SERIAL(CClassViewMenuButton, CMFCToolBarMenuButton, 1) + +////////////////////////////////////////////////////////////////////// +// 构造/析构 +////////////////////////////////////////////////////////////////////// + +CClassView::CClassView() noexcept +{ + m_nCurrSort = ID_SORTING_GROUPBYTYPE; +} + +CClassView::~CClassView() +{ +} + +BEGIN_MESSAGE_MAP(CClassView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_CLASS_ADD_MEMBER_FUNCTION, OnClassAddMemberFunction) + ON_COMMAND(ID_CLASS_ADD_MEMBER_VARIABLE, OnClassAddMemberVariable) + ON_COMMAND(ID_CLASS_DEFINITION, OnClassDefinition) + ON_COMMAND(ID_CLASS_PROPERTIES, OnClassProperties) + ON_COMMAND(ID_NEW_FOLDER, OnNewFolder) + ON_WM_PAINT() + ON_WM_SETFOCUS() + ON_COMMAND_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnSort) + ON_UPDATE_COMMAND_UI_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnUpdateSort) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClassView 消息处理程序 + +int CClassView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndClassView.Create(dwViewStyle, rectDummy, this, 2)) + { + TRACE0("未能创建类视图\n"); + return -1; // 未能创建 + } + + // 加载图像: + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_SORT); + m_wndToolBar.LoadToolBar(IDR_SORT, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + CMenu menuSort; + menuSort.LoadMenu(IDR_POPUP_SORT); + + m_wndToolBar.ReplaceButton(ID_SORT_MENU, CClassViewMenuButton(menuSort.GetSubMenu(0)->GetSafeHmenu())); + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->m_bText = FALSE; + pButton->m_bImage = TRUE; + pButton->SetImage(GetCmdMgr()->GetCmdImage(m_nCurrSort)); + pButton->SetMessageWnd(this); + } + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillClassView(); + + return 0; +} + +void CClassView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CClassView::FillClassView() +{ + HTREEITEM hRoot = m_wndClassView.InsertItem(_T("FakeApp 类"), 0, 0); + m_wndClassView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hClass = m_wndClassView.InsertItem(_T("CFakeAboutDlg"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAboutDlg()"), 3, 3, hClass); + + m_wndClassView.Expand(hRoot, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeApp"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeApp()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("InitInstance()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnAppAbout()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppDoc"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppDoc()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppDoc()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnNewDocument()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppView"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppView()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppView()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("GetDocument()"), 3, 3, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppFrame"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("m_wndMenuBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndToolBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndStatusBar"), 6, 6, hClass); + + hClass = m_wndClassView.InsertItem(_T("Globals"), 2, 2, hRoot); + m_wndClassView.InsertItem(_T("theFakeApp"), 5, 5, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); +} + +void CClassView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndClassView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + CMenu menu; + menu.LoadMenu(IDR_POPUP_SORT); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } +} + +void CClassView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndClassView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +BOOL CClassView::PreTranslateMessage(MSG* pMsg) +{ + return CDockablePane::PreTranslateMessage(pMsg); +} + +void CClassView::OnSort(UINT id) +{ + if (m_nCurrSort == id) + { + return; + } + + m_nCurrSort = id; + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->SetImage(GetCmdMgr()->GetCmdImage(id)); + m_wndToolBar.Invalidate(); + m_wndToolBar.UpdateWindow(); + } +} + +void CClassView::OnUpdateSort(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(pCmdUI->m_nID == m_nCurrSort); +} + +void CClassView::OnClassAddMemberFunction() +{ + AfxMessageBox(_T("添加成员函数...")); +} + +void CClassView::OnClassAddMemberVariable() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassDefinition() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassProperties() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnNewFolder() +{ + AfxMessageBox(_T("新建文件夹...")); +} + +void CClassView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndClassView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CClassView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndClassView.SetFocus(); +} + +void CClassView::OnChangeVisualStyle() +{ + m_ClassViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_CLASS_VIEW_24 : IDB_CLASS_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_ClassViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_ClassViewImages.Add(&bmp, RGB(255, 0, 0)); + + m_wndClassView.SetImageList(&m_ClassViewImages, TVSIL_NORMAL); + + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_SORT_24 : IDR_SORT, 0, 0, TRUE /* 锁定*/); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ClassView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ClassView.h" new file mode 100644 index 0000000..786c278 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ClassView.h" @@ -0,0 +1,54 @@ + +#pragma once + +#include "ViewTree.h" + +class CClassToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CClassView : public CDockablePane +{ +public: + CClassView() noexcept; + virtual ~CClassView(); + + void AdjustLayout(); + void OnChangeVisualStyle(); + +protected: + CClassToolBar m_wndToolBar; + CViewTree m_wndClassView; + CImageList m_ClassViewImages; + UINT m_nCurrSort; + + void FillClassView(); + +// 重写 +public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnClassAddMemberFunction(); + afx_msg void OnClassAddMemberVariable(); + afx_msg void OnClassDefinition(); + afx_msg void OnClassProperties(); + afx_msg void OnNewFolder(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg LRESULT OnChangeActiveTab(WPARAM, LPARAM); + afx_msg void OnSort(UINT id); + afx_msg void OnUpdateSort(CCmdUI* pCmdUI); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/FileView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/FileView.cpp" new file mode 100644 index 0000000..a5240b8 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/FileView.cpp" @@ -0,0 +1,257 @@ + +#include "pch.h" +#include "framework.h" +#include "mainfrm.h" +#include "FileView.h" +#include "Resource.h" +#include "ex1.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CFileView + +CFileView::CFileView() noexcept +{ +} + +CFileView::~CFileView() +{ +} + +BEGIN_MESSAGE_MAP(CFileView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_PROPERTIES, OnProperties) + ON_COMMAND(ID_OPEN, OnFileOpen) + ON_COMMAND(ID_OPEN_WITH, OnFileOpenWith) + ON_COMMAND(ID_DUMMY_COMPILE, OnDummyCompile) + ON_COMMAND(ID_EDIT_CUT, OnEditCut) + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_WM_PAINT() + ON_WM_SETFOCUS() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CWorkspaceBar 消息处理程序 + +int CFileView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; + + if (!m_wndFileView.Create(dwViewStyle, rectDummy, this, 4)) + { + TRACE0("未能创建文件视图\n"); + return -1; // 未能创建 + } + + // 加载视图图像: + m_FileViewImages.Create(IDB_FILE_VIEW, 16, 0, RGB(255, 0, 255)); + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_EXPLORER); + m_wndToolBar.LoadToolBar(IDR_EXPLORER, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillFileView(); + AdjustLayout(); + + return 0; +} + +void CFileView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CFileView::FillFileView() +{ + HTREEITEM hRoot = m_wndFileView.InsertItem(_T("FakeApp 文件"), 0, 0); + m_wndFileView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hSrc = m_wndFileView.InsertItem(_T("FakeApp 源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeApp.rc"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppDoc.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppView.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("MainFrm.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("pch.cpp"), 1, 1, hSrc); + + HTREEITEM hInc = m_wndFileView.InsertItem(_T("FakeApp 头文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppDoc.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppView.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("Resource.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("MainFrm.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("pch.h"), 2, 2, hInc); + + HTREEITEM hRes = m_wndFileView.InsertItem(_T("FakeApp 资源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeApp.rc2"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeAppDoc.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeToolbar.bmp"), 2, 2, hRes); + + m_wndFileView.Expand(hRoot, TVE_EXPAND); + m_wndFileView.Expand(hSrc, TVE_EXPAND); + m_wndFileView.Expand(hInc, TVE_EXPAND); +} + +void CFileView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE); +} + +void CFileView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndFileView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +void CFileView::OnProperties() +{ + AfxMessageBox(_T("属性....")); + +} + +void CFileView::OnFileOpen() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnFileOpenWith() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnDummyCompile() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCut() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCopy() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditClear() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndFileView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CFileView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndFileView.SetFocus(); +} + +void CFileView::OnChangeVisualStyle() +{ + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_EXPLORER_24 : IDR_EXPLORER, 0, 0, TRUE /* 锁定*/); + + m_FileViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_FILE_VIEW_24 : IDB_FILE_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_FileViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_FileViewImages.Add(&bmp, RGB(255, 0, 255)); + + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); +} + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/FileView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/FileView.h" new file mode 100644 index 0000000..e39a7c9 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/FileView.h" @@ -0,0 +1,55 @@ + +#pragma once + +#include "ViewTree.h" + +class CFileViewToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CFileView : public CDockablePane +{ +// 构造 +public: + CFileView() noexcept; + + void AdjustLayout(); + void OnChangeVisualStyle(); + +// 特性 +protected: + + CViewTree m_wndFileView; + CImageList m_FileViewImages; + CFileViewToolBar m_wndToolBar; + +protected: + void FillFileView(); + +// 实现 +public: + virtual ~CFileView(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnProperties(); + afx_msg void OnFileOpen(); + afx_msg void OnFileOpenWith(); + afx_msg void OnDummyCompile(); + afx_msg void OnEditCut(); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/MainFrm.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/MainFrm.cpp" new file mode 100644 index 0000000..139e5d6 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/MainFrm.cpp" @@ -0,0 +1,408 @@ + +// MainFrm.cpp: CMainFrame 类的实现 +// + +#include "pch.h" +#include "framework.h" +#include "ex1.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) + +const int iMaxUserToolbars = 10; +const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; +const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) + ON_WM_CREATE() + ON_COMMAND(ID_VIEW_CUSTOMIZE, &CMainFrame::OnViewCustomize) + ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, &CMainFrame::OnToolbarCreateNew) + ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook) + ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook) + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // 状态行指示器 + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +// CMainFrame 构造/析构 + +CMainFrame::CMainFrame() noexcept +{ + // TODO: 在此添加成员初始化代码 + theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2008); +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) + return -1; + + BOOL bNameValid; + + if (!m_wndMenuBar.Create(this)) + { + TRACE0("未能创建菜单栏\n"); + return -1; // 未能创建 + } + + m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); + + // 防止菜单栏在激活时获得焦点 + CMFCPopupMenu::SetForceMenuFocus(FALSE); + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) + { + TRACE0("未能创建工具栏\n"); + return -1; // 未能创建 + } + + CString strToolBarName; + bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); + ASSERT(bNameValid); + m_wndToolBar.SetWindowText(strToolBarName); + + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + + // 允许用户定义的工具栏操作: + InitUserToolbars(nullptr, uiFirstUserToolBarId, uiLastUserToolBarId); + + if (!m_wndStatusBar.Create(this)) + { + TRACE0("未能创建状态栏\n"); + return -1; // 未能创建 + } + m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); + + // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行 + m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndMenuBar); + DockPane(&m_wndToolBar); + + + // 启用 Visual Studio 2005 样式停靠窗口行为 + CDockingManager::SetDockingMode(DT_SMART); + // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 + EnableAutoHidePanes(CBRS_ALIGN_ANY); + + // 加载菜单项图像(不在任何标准工具栏上): + CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); + + // 创建停靠窗口 + if (!CreateDockingWindows()) + { + TRACE0("未能创建停靠窗口\n"); + return -1; + } + + m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); + m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndFileView); + CDockablePane* pTabbedBar = nullptr; + m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); + m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndOutput); + m_wndProperties.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndProperties); + + // 基于持久值设置视觉管理器和样式 + OnApplicationLook(theApp.m_nAppLook); + + // 启用工具栏和停靠窗口菜单替换 + EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); + + // 启用快速(按住 Alt 拖动)工具栏自定义 + CMFCToolBar::EnableQuickCustomization(); + + if (CMFCToolBar::GetUserImages() == nullptr) + { + // 加载用户定义的工具栏图像 + if (m_UserImages.Load(_T(".\\UserImages.bmp"))) + { + CMFCToolBar::SetUserImages(&m_UserImages); + } + } + + // 启用菜单个性化(最近使用的命令) + // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 + CList lstBasicCommands; + + lstBasicCommands.AddTail(ID_FILE_NEW); + lstBasicCommands.AddTail(ID_FILE_OPEN); + lstBasicCommands.AddTail(ID_FILE_SAVE); + lstBasicCommands.AddTail(ID_FILE_PRINT); + lstBasicCommands.AddTail(ID_APP_EXIT); + lstBasicCommands.AddTail(ID_EDIT_CUT); + lstBasicCommands.AddTail(ID_EDIT_PASTE); + lstBasicCommands.AddTail(ID_EDIT_UNDO); + lstBasicCommands.AddTail(ID_APP_ABOUT); + lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); + lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7); + lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); + lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); + lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); + lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); + + CMFCToolBar::SetBasicCommands(lstBasicCommands); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWndEx::PreCreateWindow(cs) ) + return FALSE; + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return TRUE; +} + +BOOL CMainFrame::CreateDockingWindows() +{ + BOOL bNameValid; + + // 创建类视图 + CString strClassView; + bNameValid = strClassView.LoadString(IDS_CLASS_VIEW); + ASSERT(bNameValid); + if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“类视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建文件视图 + CString strFileView; + bNameValid = strFileView.LoadString(IDS_FILE_VIEW); + ASSERT(bNameValid); + if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“文件视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建输出窗口 + CString strOutputWnd; + bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND); + ASSERT(bNameValid); + if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建输出窗口\n"); + return FALSE; // 未能创建 + } + + // 创建属性窗口 + CString strPropertiesWnd; + bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND); + ASSERT(bNameValid); + if (!m_wndProperties.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“属性”窗口\n"); + return FALSE; // 未能创建 + } + + SetDockingWindowIcons(theApp.m_bHiColorIcons); + return TRUE; +} + +void CMainFrame::SetDockingWindowIcons(BOOL bHiColorIcons) +{ + HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_FILE_VIEW_HC : IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndFileView.SetIcon(hFileViewIcon, FALSE); + + HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_CLASS_VIEW_HC : IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndClassView.SetIcon(hClassViewIcon, FALSE); + + HICON hOutputBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_OUTPUT_WND_HC : IDI_OUTPUT_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndOutput.SetIcon(hOutputBarIcon, FALSE); + + HICON hPropertiesBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_PROPERTIES_WND_HC : IDI_PROPERTIES_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndProperties.SetIcon(hPropertiesBarIcon, FALSE); + +} + +// CMainFrame 诊断 + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWndEx::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWndEx::Dump(dc); +} +#endif //_DEBUG + + +// CMainFrame 消息处理程序 + +void CMainFrame::OnViewCustomize() +{ + CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* 扫描菜单*/); + pDlgCust->EnableUserDefinedToolbars(); + pDlgCust->Create(); +} + +LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) +{ + LRESULT lres = CFrameWndEx::OnToolbarCreateNew(wp,lp); + if (lres == 0) + { + return 0; + } + + CMFCToolBar* pUserToolbar = (CMFCToolBar*)lres; + ASSERT_VALID(pUserToolbar); + + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + return lres; +} + +void CMainFrame::OnApplicationLook(UINT id) +{ + CWaitCursor wait; + + theApp.m_nAppLook = id; + + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_WIN_2000: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); + break; + + case ID_VIEW_APPLOOK_OFF_XP: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); + break; + + case ID_VIEW_APPLOOK_WIN_XP: + CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + break; + + case ID_VIEW_APPLOOK_OFF_2003: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2005: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2008: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_WINDOWS_7: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + default: + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_OFF_2007_BLUE: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); + break; + + case ID_VIEW_APPLOOK_OFF_2007_BLACK: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); + break; + + case ID_VIEW_APPLOOK_OFF_2007_SILVER: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); + break; + + case ID_VIEW_APPLOOK_OFF_2007_AQUA: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); + break; + } + + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); + CDockingManager::SetDockingMode(DT_SMART); + } + + m_wndOutput.UpdateFonts(); + RedrawWindow(nullptr, nullptr, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); + + theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); +} + +void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI) +{ + pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID); +} + + +BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) +{ + // 基类将执行真正的工作 + + if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) + { + return FALSE; + } + + + // 为所有用户工具栏启用自定义按钮 + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + for (int i = 0; i < iMaxUserToolbars; i ++) + { + CMFCToolBar* pUserToolbar = GetUserToolBarByIndex(i); + if (pUserToolbar != nullptr) + { + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + } + } + + return TRUE; +} + + +void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CFrameWndEx::OnSettingChange(uFlags, lpszSection); + m_wndOutput.UpdateFonts(); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/MainFrm.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/MainFrm.h" new file mode 100644 index 0000000..02feb8e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/MainFrm.h" @@ -0,0 +1,61 @@ + +// MainFrm.h: CMainFrame 类的接口 +// + +#pragma once +#include "FileView.h" +#include "ClassView.h" +#include "OutputWnd.h" +#include "PropertiesWnd.h" + +class CMainFrame : public CFrameWndEx +{ + +protected: // 仅从序列化创建 + CMainFrame() noexcept; + DECLARE_DYNCREATE(CMainFrame) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = nullptr, CCreateContext* pContext = nullptr); + +// 实现 +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // 控件条嵌入成员 + CMFCMenuBar m_wndMenuBar; + CMFCToolBar m_wndToolBar; + CMFCStatusBar m_wndStatusBar; + CMFCToolBarImages m_UserImages; + CFileView m_wndFileView; + CClassView m_wndClassView; + COutputWnd m_wndOutput; + CPropertiesWnd m_wndProperties; + +// 生成的消息映射函数 +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnViewCustomize(); + afx_msg LRESULT OnToolbarCreateNew(WPARAM wp, LPARAM lp); + afx_msg void OnApplicationLook(UINT id); + afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + DECLARE_MESSAGE_MAP() + + BOOL CreateDockingWindows(); + void SetDockingWindowIcons(BOOL bHiColorIcons); +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/OutputWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/OutputWnd.cpp" new file mode 100644 index 0000000..e3f4901 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/OutputWnd.cpp" @@ -0,0 +1,200 @@ + +#include "pch.h" +#include "framework.h" + +#include "OutputWnd.h" +#include "Resource.h" +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// COutputBar + +COutputWnd::COutputWnd() noexcept +{ +} + +COutputWnd::~COutputWnd() +{ +} + +BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() +END_MESSAGE_MAP() + +int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建选项卡窗口: + if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1)) + { + TRACE0("未能创建输出选项卡窗口\n"); + return -1; // 未能创建 + } + + // 创建输出窗格: + const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; + + if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) || + !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) || + !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4)) + { + TRACE0("未能创建输出窗口\n"); + return -1; // 未能创建 + } + + UpdateFonts(); + + CString strTabName; + BOOL bNameValid; + + // 将列表窗口附加到选项卡: + bNameValid = strTabName.LoadString(IDS_BUILD_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0); + bNameValid = strTabName.LoadString(IDS_DEBUG_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1); + bNameValid = strTabName.LoadString(IDS_FIND_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2); + + // 使用一些虚拟文本填写输出选项卡(无需复杂数据) + FillBuildWindow(); + FillDebugWindow(); + FillFindWindow(); + + return 0; +} + +void COutputWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + + // 选项卡控件应覆盖整个工作区: + m_wndTabs.SetWindowPos (nullptr, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); +} + +void COutputWnd::AdjustHorzScroll(CListBox& wndListBox) +{ + CClientDC dc(this); + CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular); + + int cxExtentMax = 0; + + for (int i = 0; i < wndListBox.GetCount(); i ++) + { + CString strItem; + wndListBox.GetText(i, strItem); + + cxExtentMax = max(cxExtentMax, (int)dc.GetTextExtent(strItem).cx); + } + + wndListBox.SetHorizontalExtent(cxExtentMax); + dc.SelectObject(pOldFont); +} + +void COutputWnd::FillBuildWindow() +{ + m_wndOutputBuild.AddString(_T("生成输出正显示在此处。")); + m_wndOutputBuild.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputBuild.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillDebugWindow() +{ + m_wndOutputDebug.AddString(_T("调试输出正显示在此处。")); + m_wndOutputDebug.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputDebug.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillFindWindow() +{ + m_wndOutputFind.AddString(_T("查找输出正显示在此处。")); + m_wndOutputFind.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputFind.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::UpdateFonts() +{ + m_wndOutputBuild.SetFont(&afxGlobalData.fontRegular); + m_wndOutputDebug.SetFont(&afxGlobalData.fontRegular); + m_wndOutputFind.SetFont(&afxGlobalData.fontRegular); +} + +///////////////////////////////////////////////////////////////////////////// +// COutputList1 + +COutputList::COutputList() noexcept +{ +} + +COutputList::~COutputList() +{ +} + +BEGIN_MESSAGE_MAP(COutputList, CListBox) + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput) + ON_WM_WINDOWPOSCHANGING() +END_MESSAGE_MAP() +///////////////////////////////////////////////////////////////////////////// +// COutputList 消息处理程序 + +void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) +{ + CMenu menu; + menu.LoadMenu(IDR_OUTPUT_POPUP); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } + + SetFocus(); +} + +void COutputList::OnEditCopy() +{ + MessageBox(_T("复制输出")); +} + +void COutputList::OnEditClear() +{ + MessageBox(_T("清除输出")); +} + +void COutputList::OnViewOutput() +{ + CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner()); + CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame()); + + if (pMainFrame != nullptr && pParentBar != nullptr) + { + pMainFrame->SetFocus(); + pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE); + pMainFrame->RecalcLayout(); + + } +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/OutputWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/OutputWnd.h" new file mode 100644 index 0000000..4d773c3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/OutputWnd.h" @@ -0,0 +1,59 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// COutputList 窗口 + +class COutputList : public CListBox +{ +// 构造 +public: + COutputList() noexcept; + +// 实现 +public: + virtual ~COutputList(); + +protected: + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnViewOutput(); + + DECLARE_MESSAGE_MAP() +}; + +class COutputWnd : public CDockablePane +{ +// 构造 +public: + COutputWnd() noexcept; + + void UpdateFonts(); + +// 特性 +protected: + CMFCTabCtrl m_wndTabs; + + COutputList m_wndOutputBuild; + COutputList m_wndOutputDebug; + COutputList m_wndOutputFind; + +protected: + void FillBuildWindow(); + void FillDebugWindow(); + void FillFindWindow(); + + void AdjustHorzScroll(CListBox& wndListBox); + +// 实现 +public: + virtual ~COutputWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/PropertiesWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/PropertiesWnd.cpp" new file mode 100644 index 0000000..2862e16 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/PropertiesWnd.cpp" @@ -0,0 +1,273 @@ + +#include "pch.h" +#include "framework.h" + +#include "PropertiesWnd.h" +#include "Resource.h" +#include "MainFrm.h" +#include "ex1.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar + +CPropertiesWnd::CPropertiesWnd() noexcept +{ + m_nComboHeight = 0; +} + +CPropertiesWnd::~CPropertiesWnd() +{ +} + +BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties) + ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties) + ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties) + ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties) + ON_COMMAND(ID_PROPERTIES1, OnProperties1) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1) + ON_COMMAND(ID_PROPERTIES2, OnProperties2) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2) + ON_WM_SETFOCUS() + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar 消息处理程序 + +void CPropertiesWnd::AdjustLayout() +{ + if (GetSafeHwnd () == nullptr || (AfxGetMainWnd() != nullptr && AfxGetMainWnd()->IsIconic())) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndObjectCombo.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndPropList.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight + cyTlb, rectClient.Width(), rectClient.Height() -(m_nComboHeight+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER); +} + +int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建组合: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1)) + { + TRACE0("未能创建属性组合 \n"); + return -1; // 未能创建 + } + + m_wndObjectCombo.AddString(_T("应用程序")); + m_wndObjectCombo.AddString(_T("属性窗口")); + m_wndObjectCombo.SetCurSel(0); + + CRect rectCombo; + m_wndObjectCombo.GetClientRect (&rectCombo); + + m_nComboHeight = rectCombo.Height(); + + if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2)) + { + TRACE0("未能创建属性网格\n"); + return -1; // 未能创建 + } + + InitPropList(); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES); + m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* 已锁定*/); + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* 锁定*/); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + AdjustLayout(); + return 0; +} + +void CPropertiesWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CPropertiesWnd::OnExpandAllProperties() +{ + m_wndPropList.ExpandAll(); +} + +void CPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* /* pCmdUI */) +{ +} + +void CPropertiesWnd::OnSortProperties() +{ + m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnProperties1() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::OnProperties2() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::InitPropList() +{ + SetPropListFont(); + + m_wndPropList.EnableHeaderCtrl(FALSE); + m_wndPropList.EnableDescriptionArea(); + m_wndPropList.SetVSDotNetLook(); + m_wndPropList.MarkModifiedProperties(); + + CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("外观")); + + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("三维外观"), (_variant_t) false, _T("指定窗口的字体不使用粗体,并且控件将使用三维边框"))); + + CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("边框"), _T("对话框外框"), _T("其中之一: “无”、“细”、“可调整大小”或“对话框外框”")); + pProp->AddOption(_T("无")); + pProp->AddOption(_T("细")); + pProp->AddOption(_T("可调整大小")); + pProp->AddOption(_T("对话框外框")); + pProp->AllowEdit(FALSE); + + pGroup1->AddSubItem(pProp); + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("标题"), (_variant_t) _T("关于"), _T("指定窗口标题栏中显示的文本"))); + + m_wndPropList.AddProperty(pGroup1); + + CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("窗口大小"), 0, TRUE); + + pProp = new CMFCPropertyGridProperty(_T("高度"), (_variant_t) 250l, _T("指定窗口的高度")); + pProp->EnableSpinControl(TRUE, 50, 300); + pSize->AddSubItem(pProp); + + pProp = new CMFCPropertyGridProperty( _T("宽度"), (_variant_t) 150l, _T("指定窗口的宽度")); + pProp->EnableSpinControl(TRUE, 50, 200); + pSize->AddSubItem(pProp); + + m_wndPropList.AddProperty(pSize); + + CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("字体")); + + LOGFONT lf; + CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + font->GetLogFont(&lf); + + _tcscpy_s(lf.lfFaceName, _T("宋体, Arial")); + + pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("字体"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("指定窗口的默认字体"))); + pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("使用系统字体"), (_variant_t) true, _T("指定窗口使用“MS Shell Dlg”字体"))); + + m_wndPropList.AddProperty(pGroup2); + + CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("杂项")); + pProp = new CMFCPropertyGridProperty(_T("(名称)"), _T("应用程序")); + pProp->Enable(FALSE); + pGroup3->AddSubItem(pProp); + + CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("窗口颜色"), RGB(210, 192, 254), nullptr, _T("指定默认的窗口颜色")); + pColorProp->EnableOtherButton(_T("其他...")); + pColorProp->EnableAutomaticButton(_T("默认"), ::GetSysColor(COLOR_3DFACE)); + pGroup3->AddSubItem(pColorProp); + + static const TCHAR szFilter[] = _T("图标文件(*.ico)|*.ico|所有文件(*.*)|*.*||"); + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("图标"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("指定窗口图标"))); + + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("文件夹"), _T("c:\\"))); + + m_wndPropList.AddProperty(pGroup3); + + CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("层次结构")); + + CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("第一个子级")); + pGroup4->AddSubItem(pGroup41); + + CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("第二个子级")); + pGroup41->AddSubItem(pGroup411); + + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 1"), (_variant_t) _T("值 1"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 2"), (_variant_t) _T("值 2"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 3"), (_variant_t) _T("值 3"), _T("此为说明"))); + + pGroup4->Expand(FALSE); + m_wndPropList.AddProperty(pGroup4); +} + +void CPropertiesWnd::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + m_wndPropList.SetFocus(); +} + +void CPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CDockablePane::OnSettingChange(uFlags, lpszSection); + SetPropListFont(); +} + +void CPropertiesWnd::SetPropListFont() +{ + ::DeleteObject(m_fntPropList.Detach()); + + LOGFONT lf; + afxGlobalData.fontRegular.GetLogFont(&lf); + + NONCLIENTMETRICS info; + info.cbSize = sizeof(info); + + afxGlobalData.GetNonClientMetrics(info); + + lf.lfHeight = info.lfMenuFont.lfHeight; + lf.lfWeight = info.lfMenuFont.lfWeight; + lf.lfItalic = info.lfMenuFont.lfItalic; + + m_fntPropList.CreateFontIndirect(&lf); + + m_wndPropList.SetFont(&m_fntPropList); + m_wndObjectCombo.SetFont(&m_fntPropList); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/PropertiesWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/PropertiesWnd.h" new file mode 100644 index 0000000..e056430 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/PropertiesWnd.h" @@ -0,0 +1,62 @@ + +#pragma once + +class CPropertiesToolBar : public CMFCToolBar +{ +public: + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CPropertiesWnd : public CDockablePane +{ +// 构造 +public: + CPropertiesWnd() noexcept; + + void AdjustLayout(); + +// 特性 +public: + void SetVSDotNetLook(BOOL bSet) + { + m_wndPropList.SetVSDotNetLook(bSet); + m_wndPropList.SetGroupNameFullWidth(bSet); + } + +protected: + CFont m_fntPropList; + CComboBox m_wndObjectCombo; + CPropertiesToolBar m_wndToolBar; + CMFCPropertyGridCtrl m_wndPropList; + +// 实现 +public: + virtual ~CPropertiesWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnExpandAllProperties(); + afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI); + afx_msg void OnSortProperties(); + afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI); + afx_msg void OnProperties1(); + afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI); + afx_msg void OnProperties2(); + afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + + DECLARE_MESSAGE_MAP() + + void InitPropList(); + void SetPropListFont(); + + int m_nComboHeight; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/Resource.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/Resource.h" new file mode 100644 index 0000000..8970702 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/Resource.h" @@ -0,0 +1,97 @@ +//{{NO_DEPENDENCIES}} +// 生成的 Microsoft Visual C++ 包含文件。 +// 由 ex1.rc 使用 +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_POPUP_EDIT 119 +#define ID_STATUSBAR_PANE1 120 +#define ID_STATUSBAR_PANE2 121 +#define IDS_STATUS_PANE1 122 +#define IDS_STATUS_PANE2 123 +#define IDS_TOOLBAR_STANDARD 124 +#define IDS_TOOLBAR_CUSTOMIZE 125 +#define ID_VIEW_CUSTOMIZE 126 +#define IDR_MAINFRAME 128 +#define IDR_MAINFRAME_256 129 +#define IDR_ex1TYPE 130 +#define ID_WINDOW_MANAGER 131 +#define ID_VIEW_FILEVIEW 133 +#define ID_VIEW_CLASSVIEW 134 +#define ID_PROPERTIES 135 +#define ID_OPEN 136 +#define ID_OPEN_WITH 137 +#define ID_DUMMY_COMPILE 138 +#define ID_CLASS_ADD_MEMBER_FUNCTION 139 +#define ID_CLASS_ADD_MEMBER_VARIABLE 140 +#define ID_CLASS_DEFINITION 141 +#define ID_CLASS_PROPERTIES 142 +#define ID_NEW_FOLDER 143 +#define ID_SORT_MENU 144 +#define ID_SORTING_GROUPBYTYPE 145 +#define ID_SORTING_SORTALPHABETIC 146 +#define ID_SORTING_SORTBYTYPE 147 +#define ID_SORTING_SORTBYACCESS 148 +#define ID_VIEW_OUTPUTWND 149 +#define ID_VIEW_PROPERTIESWND 150 +#define ID_SORTPROPERTIES 151 +#define ID_PROPERTIES1 152 +#define ID_PROPERTIES2 153 +#define ID_EXPAND_ALL 154 +#define IDS_FILE_VIEW 155 +#define IDS_CLASS_VIEW 156 +#define IDS_OUTPUT_WND 157 +#define IDS_PROPERTIES_WND 158 +#define IDI_FILE_VIEW 161 +#define IDI_FILE_VIEW_HC 162 +#define IDI_CLASS_VIEW 163 +#define IDI_CLASS_VIEW_HC 164 +#define IDI_OUTPUT_WND 165 +#define IDI_OUTPUT_WND_HC 166 +#define IDI_PROPERTIES_WND 167 +#define IDI_PROPERTIES_WND_HC 168 +#define IDR_EXPLORER 169 +#define IDB_EXPLORER_24 170 +#define IDR_SORT 171 +#define IDB_SORT_24 172 +#define IDR_POPUP_SORT 173 +#define IDR_POPUP_EXPLORER 174 +#define IDB_FILE_VIEW 175 +#define IDB_FILE_VIEW_24 176 +#define IDB_CLASS_VIEW 177 +#define IDB_CLASS_VIEW_24 178 +#define IDR_MENU_IMAGES 179 +#define IDB_MENU_IMAGES_24 180 +#define ID_TOOLS_MACRO 181 +#define IDR_OUTPUT_POPUP 182 +#define IDR_PROPERTIES 183 +#define IDB_PROPERTIES_HC 184 +#define IDR_THEME_MENU 200 +#define ID_SET_STYLE 201 +#define ID_VIEW_APPLOOK_WIN_2000 205 +#define ID_VIEW_APPLOOK_OFF_XP 206 +#define ID_VIEW_APPLOOK_WIN_XP 207 +#define ID_VIEW_APPLOOK_OFF_2003 208 +#define ID_VIEW_APPLOOK_VS_2005 209 +#define ID_VIEW_APPLOOK_VS_2008 210 +#define ID_VIEW_APPLOOK_OFF_2007_BLUE 215 +#define ID_VIEW_APPLOOK_OFF_2007_BLACK 216 +#define ID_VIEW_APPLOOK_OFF_2007_SILVER 217 +#define ID_VIEW_APPLOOK_OFF_2007_AQUA 218 +#define ID_VIEW_APPLOOK_WINDOWS_7 219 +#define IDS_BUILD_TAB 300 +#define IDS_DEBUG_TAB 301 +#define IDS_FIND_TAB 302 +#define IDS_EXPLORER 305 +#define IDS_EDIT_MENU 306 + +// 新对象的下一组默认值 +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 310 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 310 +#define _APS_NEXT_COMMAND_VALUE 32771 +#endif +#endif diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ViewTree.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ViewTree.cpp" new file mode 100644 index 0000000..84996cb --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ViewTree.cpp" @@ -0,0 +1,43 @@ + +#include "pch.h" +#include "framework.h" +#include "ViewTree.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CViewTree + +CViewTree::CViewTree() noexcept +{ +} + +CViewTree::~CViewTree() +{ +} + +BEGIN_MESSAGE_MAP(CViewTree, CTreeCtrl) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 消息处理程序 + +BOOL CViewTree::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult); + + NMHDR* pNMHDR = (NMHDR*)lParam; + ASSERT(pNMHDR != nullptr); + +#pragma warning(suppress : 26454) + if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips() != nullptr) + { + GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); + } + + return bRes; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ViewTree.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ViewTree.h" new file mode 100644 index 0000000..0267d80 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ViewTree.h" @@ -0,0 +1,23 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 窗口 + +class CViewTree : public CTreeCtrl +{ +// 构造 +public: + CViewTree() noexcept; + +// 重写 +protected: + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + +// 实现 +public: + virtual ~CViewTree(); + +protected: + DECLARE_MESSAGE_MAP() +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.aps" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.aps" new file mode 100644 index 0000000..952896d Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.aps" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.cpp" new file mode 100644 index 0000000..725e886 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.cpp" @@ -0,0 +1,219 @@ + +// ex1.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "afxwinappex.h" +#include "afxdialogex.h" +#include "ex1.h" +#include "MainFrm.h" + +#include "ex1Doc.h" +#include "ex1View.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cex1App + +BEGIN_MESSAGE_MAP(Cex1App, CWinAppEx) + ON_COMMAND(ID_APP_ABOUT, &Cex1App::OnAppAbout) + // 基于文件的标准文档命令 + ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) + // 标准打印设置命令 + ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup) +END_MESSAGE_MAP() + + +// Cex1App 构造 + +Cex1App::Cex1App() noexcept +{ + m_bHiColorIcons = TRUE; + + + m_nAppLook = 0; + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; +#ifdef _MANAGED + // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则: + // 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。 + // 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。 + System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); +#endif + + // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式 + //为 CompanyName.ProductName.SubProduct.VersionInformation + SetAppID(_T("ex1.AppID.NoVersion")); + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + +// 唯一的 Cex1App 对象 + +Cex1App theApp; + + +// Cex1App 初始化 + +BOOL Cex1App::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinAppEx::InitInstance(); + + + // 初始化 OLE 库 + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + + AfxEnableControlContainer(); + + EnableTaskbarInteraction(FALSE); + + // 使用 RichEdit 控件需要 AfxInitRichEdit2() + // AfxInitRichEdit2(); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) + + + InitContextMenuManager(); + + InitKeyboardManager(); + + InitTooltipManager(); + CMFCToolTipInfo ttParams; + ttParams.m_bVislManagerTheme = TRUE; + theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, + RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); + + // 注册应用程序的文档模板。 文档模板 + // 将用作文档、框架窗口和视图之间的连接 + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(Cex1Doc), + RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 + RUNTIME_CLASS(Cex1View)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + + + // 分析标准 shell 命令、DDE、打开文件操作的命令行 + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + + + // 调度在命令行中指定的命令。 如果 + // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + + // 唯一的一个窗口已初始化,因此显示它并对其进行更新 + m_pMainWnd->ShowWindow(SW_SHOW); + m_pMainWnd->UpdateWindow(); + return TRUE; +} + +int Cex1App::ExitInstance() +{ + //TODO: 处理可能已添加的附加资源 + AfxOleTerm(FALSE); + + return CWinAppEx::ExitInstance(); +} + +// Cex1App 消息处理程序 + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg() noexcept; + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + +// 用于运行对话框的应用程序命令 +void Cex1App::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +// Cex1App 自定义加载/保存方法 + +void Cex1App::PreLoadState() +{ + BOOL bNameValid; + CString strName; + bNameValid = strName.LoadString(IDS_EDIT_MENU); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); + bNameValid = strName.LoadString(IDS_EXPLORER); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EXPLORER); +} + +void Cex1App::LoadCustomState() +{ +} + +void Cex1App::SaveCustomState() +{ +} + +// Cex1App 消息处理程序 + + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.h" new file mode 100644 index 0000000..d8ed342 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.h" @@ -0,0 +1,40 @@ + +// ex1.h: ex1 应用程序的主头文件 +// +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// Cex1App: +// 有关此类的实现,请参阅 ex1.cpp +// + +class Cex1App : public CWinAppEx +{ +public: + Cex1App() noexcept; + + +// 重写 +public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + +// 实现 + UINT m_nAppLook; + BOOL m_bHiColorIcons; + + virtual void PreLoadState(); + virtual void LoadCustomState(); + virtual void SaveCustomState(); + + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern Cex1App theApp; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.rc" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.rc" new file mode 100644 index 0000000..017e0f2 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.rc" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.sln" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.sln" new file mode 100644 index 0000000..ffbbb0b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ex1", "ex1.vcxproj", "{BDF5AFCE-777B-40ED-A189-31EAD5DC8232}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BDF5AFCE-777B-40ED-A189-31EAD5DC8232}.Debug|x64.ActiveCfg = Debug|x64 + {BDF5AFCE-777B-40ED-A189-31EAD5DC8232}.Debug|x64.Build.0 = Debug|x64 + {BDF5AFCE-777B-40ED-A189-31EAD5DC8232}.Debug|x86.ActiveCfg = Debug|Win32 + {BDF5AFCE-777B-40ED-A189-31EAD5DC8232}.Debug|x86.Build.0 = Debug|Win32 + {BDF5AFCE-777B-40ED-A189-31EAD5DC8232}.Release|x64.ActiveCfg = Release|x64 + {BDF5AFCE-777B-40ED-A189-31EAD5DC8232}.Release|x64.Build.0 = Release|x64 + {BDF5AFCE-777B-40ED-A189-31EAD5DC8232}.Release|x86.ActiveCfg = Release|Win32 + {BDF5AFCE-777B-40ED-A189-31EAD5DC8232}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {92D41AA5-B313-42D5-81FA-A7337E2FAC76} + EndGlobalSection +EndGlobal diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.vcxproj" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.vcxproj" new file mode 100644 index 0000000..f9bfc05 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.vcxproj" @@ -0,0 +1,253 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {BDF5AFCE-777B-40ED-A189-31EAD5DC8232} + MFCProj + ex1 + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.vcxproj.filters" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.vcxproj.filters" new file mode 100644 index 0000000..372d48b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.vcxproj.filters" @@ -0,0 +1,177 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.vcxproj.user" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.vcxproj.user" new file mode 100644 index 0000000..c14e901 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1.vcxproj.user" @@ -0,0 +1,6 @@ + + + + ex1.rc + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1Doc.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1Doc.cpp" new file mode 100644 index 0000000..cfd7302 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1Doc.cpp" @@ -0,0 +1,138 @@ + +// ex1Doc.cpp: Cex1Doc 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "ex1.h" +#endif + +#include "ex1Doc.h" + +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// Cex1Doc + +IMPLEMENT_DYNCREATE(Cex1Doc, CDocument) + +BEGIN_MESSAGE_MAP(Cex1Doc, CDocument) +END_MESSAGE_MAP() + + +// Cex1Doc 构造/析构 + +Cex1Doc::Cex1Doc() noexcept +{ + // TODO: 在此添加一次性构造代码 + +} + +Cex1Doc::~Cex1Doc() +{ +} + +BOOL Cex1Doc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: 在此添加重新初始化代码 + // (SDI 文档将重用该文档) + + return TRUE; +} + + + + +// Cex1Doc 序列化 + +void Cex1Doc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: 在此添加存储代码 + } + else + { + // TODO: 在此添加加载代码 + } +} + +#ifdef SHARED_HANDLERS + +// 缩略图的支持 +void Cex1Doc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds) +{ + // 修改此代码以绘制文档数据 + dc.FillSolidRect(lprcBounds, RGB(255, 255, 255)); + + CString strText = _T("TODO: implement thumbnail drawing here"); + LOGFONT lf; + + CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + pDefaultGUIFont->GetLogFont(&lf); + lf.lfHeight = 36; + + CFont fontDraw; + fontDraw.CreateFontIndirect(&lf); + + CFont* pOldFont = dc.SelectObject(&fontDraw); + dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK); + dc.SelectObject(pOldFont); +} + +// 搜索处理程序的支持 +void Cex1Doc::InitializeSearchContent() +{ + CString strSearchContent; + // 从文档数据设置搜索内容。 + // 内容部分应由“;”分隔 + + // 例如: strSearchContent = _T("point;rectangle;circle;ole object;"); + SetSearchContent(strSearchContent); +} + +void Cex1Doc::SetSearchContent(const CString& value) +{ + if (value.IsEmpty()) + { + RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); + } + else + { + CMFCFilterChunkValueImpl *pChunk = nullptr; + ATLTRY(pChunk = new CMFCFilterChunkValueImpl); + if (pChunk != nullptr) + { + pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT); + SetChunkValue(pChunk); + } + } +} + +#endif // SHARED_HANDLERS + +// Cex1Doc 诊断 + +#ifdef _DEBUG +void Cex1Doc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void Cex1Doc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// Cex1Doc 命令 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1Doc.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1Doc.h" new file mode 100644 index 0000000..d54df90 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1Doc.h" @@ -0,0 +1,48 @@ + +// ex1Doc.h: Cex1Doc 类的接口 +// + + +#pragma once + + +class Cex1Doc : public CDocument +{ +protected: // 仅从序列化创建 + Cex1Doc() noexcept; + DECLARE_DYNCREATE(Cex1Doc) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); +#ifdef SHARED_HANDLERS + virtual void InitializeSearchContent(); + virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds); +#endif // SHARED_HANDLERS + +// 实现 +public: + virtual ~Cex1Doc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// 生成的消息映射函数 +protected: + DECLARE_MESSAGE_MAP() + +#ifdef SHARED_HANDLERS + // 用于为搜索处理程序设置搜索内容的 Helper 函数 + void SetSearchContent(const CString& value); +#endif // SHARED_HANDLERS +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1View.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1View.cpp" new file mode 100644 index 0000000..3a070c4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1View.cpp" @@ -0,0 +1,161 @@ + +// ex1View.cpp: Cex1View 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "ex1.h" +#endif + +#include "ex1Doc.h" +#include "ex1View.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cex1View + +IMPLEMENT_DYNCREATE(Cex1View, CView) + +BEGIN_MESSAGE_MAP(Cex1View, CView) + // 标准打印命令 + ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, &Cex1View::OnFilePrintPreview) + ON_WM_CONTEXTMENU() + ON_WM_RBUTTONUP() + ON_WM_LBUTTONDOWN() + ON_WM_LBUTTONUP() +END_MESSAGE_MAP() + +// Cex1View 构造/析构 + +Cex1View::Cex1View() noexcept +{ + // TODO: 在此处添加构造代码 + +} + +Cex1View::~Cex1View() +{ +} + +BOOL Cex1View::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return CView::PreCreateWindow(cs); +} + +// Cex1View 绘图 + +void Cex1View::OnDraw(CDC* /*pDC*/) +{ + Cex1Doc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + + // TODO: 在此处为本机数据添加绘制代码 +} + + +// Cex1View 打印 + + +void Cex1View::OnFilePrintPreview() +{ +#ifndef SHARED_HANDLERS + AFXPrintPreview(this); +#endif +} + +BOOL Cex1View::OnPreparePrinting(CPrintInfo* pInfo) +{ + // 默认准备 + return DoPreparePrinting(pInfo); +} + +void Cex1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加额外的打印前进行的初始化过程 +} + +void Cex1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加打印后进行的清理过程 +} + +void Cex1View::OnRButtonUp(UINT /* nFlags */, CPoint point) +{ + ClientToScreen(&point); + OnContextMenu(this, point); +} + +void Cex1View::OnContextMenu(CWnd* /* pWnd */, CPoint point) +{ +#ifndef SHARED_HANDLERS + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE); +#endif +} + + +// Cex1View 诊断 + +#ifdef _DEBUG +void Cex1View::AssertValid() const +{ + CView::AssertValid(); +} + +void Cex1View::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +Cex1Doc* Cex1View::GetDocument() const // 非调试版本是内联的 +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(Cex1Doc))); + return (Cex1Doc*)m_pDocument; +} +#endif //_DEBUG + + +// Cex1View 消息处理程序 + + +void Cex1View::OnLButtonDown(UINT nFlags, CPoint point) +{ + // TODO: 在此添加消息处理程序代码和/或调用默认值 + P0 = point; + CView::OnLButtonDown(nFlags, point); +} + + +void Cex1View::OnLButtonUp(UINT nFlags, CPoint point) +{ + // TODO: 在此添加消息处理程序代码和/或调用默认值 + P1 = point; + CDC* pDC = GetDC(); + + CPen pen(PS_SOLID, 6, RGB(100, 20, 80)); + pDC->SelectObject(&pen); + pDC->MoveTo(P0); + pDC->LineTo(P1); + DeleteObject(&pen); + ReleaseDC(pDC); + + //CBrush brush; + //brush.CreateSolidBrush(RGB(120, 50, 60)); + //pDC->Rectangle(CRect(P0, P1)); + //pDC->FillRect(CRect(P0, P1),&brush); + //DeleteObject(&brush); + //ReleaseDC(pDC); + CView::OnLButtonUp(nFlags, point); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1View.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1View.h" new file mode 100644 index 0000000..dd6aa92 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/ex1View.h" @@ -0,0 +1,56 @@ + +// ex1View.h: Cex1View 类的接口 +// + +#pragma once + + +class Cex1View : public CView +{ +protected: // 仅从序列化创建 + Cex1View() noexcept; + DECLARE_DYNCREATE(Cex1View) + +// 特性 +public: + Cex1Doc* GetDocument() const; + +// 操作 +public: + +// 重写 +public: + virtual void OnDraw(CDC* pDC); // 重写以绘制该视图 + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// 实现 +public: + virtual ~Cex1View(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// 生成的消息映射函数 +protected: + afx_msg void OnFilePrintPreview(); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + DECLARE_MESSAGE_MAP() + CPoint P0, P1; +public: + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); +}; + +#ifndef _DEBUG // ex1View.cpp 中的调试版本 +inline Cex1Doc* Cex1View::GetDocument() const + { return reinterpret_cast(m_pDocument); } +#endif + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/framework.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/pch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/pch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/pch.h" new file mode 100644 index 0000000..9660927 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/pch.h" @@ -0,0 +1,13 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" + +#endif //PCH_H diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/Toolbar.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/Toolbar.bmp" new file mode 100644 index 0000000..d501723 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/Toolbar.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/Toolbar256.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/Toolbar256.bmp" new file mode 100644 index 0000000..91a2553 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/Toolbar256.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/class_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/class_view.ico" new file mode 100644 index 0000000..bf6b0dd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/class_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/class_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/class_view_hc.ico" new file mode 100644 index 0000000..3112bf2 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/class_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/classview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/classview.bmp" new file mode 100644 index 0000000..1e02aa1 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/classview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/classview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/classview_hc.bmp" new file mode 100644 index 0000000..6b22e78 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/classview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/ex1.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/ex1.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/ex1.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/ex1.rc2" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/ex1.rc2" new file mode 100644 index 0000000..e2bb610 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/ex1.rc2" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/ex1Doc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/ex1Doc.ico" new file mode 100644 index 0000000..96365d4 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/ex1Doc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/explorer.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/explorer.bmp" new file mode 100644 index 0000000..01298ba Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/explorer.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/explorer_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/explorer_hc.bmp" new file mode 100644 index 0000000..697199d Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/explorer_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/file_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/file_view.ico" new file mode 100644 index 0000000..0f93f52 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/file_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/file_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/file_view_hc.ico" new file mode 100644 index 0000000..42ec435 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/file_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/fileview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/fileview.bmp" new file mode 100644 index 0000000..a2d62d0 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/fileview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/fileview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/fileview_hc.bmp" new file mode 100644 index 0000000..b60f483 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/fileview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/menuimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/menuimages.bmp" new file mode 100644 index 0000000..7771841 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/menuimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/menuimages_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/menuimages_hc.bmp" new file mode 100644 index 0000000..577926e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/menuimages_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/output_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/output_wnd.ico" new file mode 100644 index 0000000..d14f991 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/output_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/output_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/output_wnd_hc.ico" new file mode 100644 index 0000000..fdd27e8 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/output_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/properties.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/properties.bmp" new file mode 100644 index 0000000..72e2b29 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/properties.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/properties_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/properties_hc.bmp" new file mode 100644 index 0000000..d18a7ca Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/properties_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/properties_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/properties_wnd.ico" new file mode 100644 index 0000000..3611766 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/properties_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/properties_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/properties_wnd_hc.ico" new file mode 100644 index 0000000..1e06b64 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/properties_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/sort.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/sort.bmp" new file mode 100644 index 0000000..0307301 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/sort.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/sort_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/sort_hc.bmp" new file mode 100644 index 0000000..720e742 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/sort_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/userimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/userimages.bmp" new file mode 100644 index 0000000..affe657 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/res/userimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/targetver.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/MFC/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246-\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\344\270\200.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246-\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\344\270\200.pdf" new file mode 100644 index 0000000..6f8f29e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex1/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246-\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\344\270\200.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.cpp" new file mode 100644 index 0000000..41a662b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.cpp" @@ -0,0 +1,219 @@ + +// 2DTrans.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "afxwinappex.h" +#include "afxdialogex.h" +#include "2DTrans.h" +#include "MainFrm.h" + +#include "2DTransDoc.h" +#include "2DTransView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CMy2DTransApp + +BEGIN_MESSAGE_MAP(CMy2DTransApp, CWinAppEx) + ON_COMMAND(ID_APP_ABOUT, &CMy2DTransApp::OnAppAbout) + // 基于文件的标准文档命令 + ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) + // 标准打印设置命令 + ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup) +END_MESSAGE_MAP() + + +// CMy2DTransApp 构造 + +CMy2DTransApp::CMy2DTransApp() noexcept +{ + m_bHiColorIcons = TRUE; + + + m_nAppLook = 0; + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; +#ifdef _MANAGED + // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则: + // 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。 + // 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。 + System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); +#endif + + // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式 + //为 CompanyName.ProductName.SubProduct.VersionInformation + SetAppID(_T("My2DTrans.AppID.NoVersion")); + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + +// 唯一的 CMy2DTransApp 对象 + +CMy2DTransApp theApp; + + +// CMy2DTransApp 初始化 + +BOOL CMy2DTransApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinAppEx::InitInstance(); + + + // 初始化 OLE 库 + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + + AfxEnableControlContainer(); + + EnableTaskbarInteraction(FALSE); + + // 使用 RichEdit 控件需要 AfxInitRichEdit2() + // AfxInitRichEdit2(); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) + + + InitContextMenuManager(); + + InitKeyboardManager(); + + InitTooltipManager(); + CMFCToolTipInfo ttParams; + ttParams.m_bVislManagerTheme = TRUE; + theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, + RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); + + // 注册应用程序的文档模板。 文档模板 + // 将用作文档、框架窗口和视图之间的连接 + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(CMy2DTransDoc), + RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 + RUNTIME_CLASS(CMy2DTransView)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + + + // 分析标准 shell 命令、DDE、打开文件操作的命令行 + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + + + // 调度在命令行中指定的命令。 如果 + // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + + // 唯一的一个窗口已初始化,因此显示它并对其进行更新 + m_pMainWnd->ShowWindow(SW_SHOW); + m_pMainWnd->UpdateWindow(); + return TRUE; +} + +int CMy2DTransApp::ExitInstance() +{ + //TODO: 处理可能已添加的附加资源 + AfxOleTerm(FALSE); + + return CWinAppEx::ExitInstance(); +} + +// CMy2DTransApp 消息处理程序 + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg() noexcept; + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + +// 用于运行对话框的应用程序命令 +void CMy2DTransApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +// CMy2DTransApp 自定义加载/保存方法 + +void CMy2DTransApp::PreLoadState() +{ + BOOL bNameValid; + CString strName; + bNameValid = strName.LoadString(IDS_EDIT_MENU); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); + bNameValid = strName.LoadString(IDS_EXPLORER); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EXPLORER); +} + +void CMy2DTransApp::LoadCustomState() +{ +} + +void CMy2DTransApp::SaveCustomState() +{ +} + +// CMy2DTransApp 消息处理程序 + + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.h" new file mode 100644 index 0000000..dc014ec --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.h" @@ -0,0 +1,40 @@ + +// 2DTrans.h: 2DTrans 应用程序的主头文件 +// +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// CMy2DTransApp: +// 有关此类的实现,请参阅 2DTrans.cpp +// + +class CMy2DTransApp : public CWinAppEx +{ +public: + CMy2DTransApp() noexcept; + + +// 重写 +public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + +// 实现 + UINT m_nAppLook; + BOOL m_bHiColorIcons; + + virtual void PreLoadState(); + virtual void LoadCustomState(); + virtual void SaveCustomState(); + + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern CMy2DTransApp theApp; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.sln" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.sln" new file mode 100644 index 0000000..13b31ed --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33414.496 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "2DTrans", "2DTrans.vcxproj", "{EF855793-B112-41CF-9187-73A3BE81AA5F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EF855793-B112-41CF-9187-73A3BE81AA5F}.Debug|x64.ActiveCfg = Debug|x64 + {EF855793-B112-41CF-9187-73A3BE81AA5F}.Debug|x64.Build.0 = Debug|x64 + {EF855793-B112-41CF-9187-73A3BE81AA5F}.Debug|x86.ActiveCfg = Debug|Win32 + {EF855793-B112-41CF-9187-73A3BE81AA5F}.Debug|x86.Build.0 = Debug|Win32 + {EF855793-B112-41CF-9187-73A3BE81AA5F}.Release|x64.ActiveCfg = Release|x64 + {EF855793-B112-41CF-9187-73A3BE81AA5F}.Release|x64.Build.0 = Release|x64 + {EF855793-B112-41CF-9187-73A3BE81AA5F}.Release|x86.ActiveCfg = Release|Win32 + {EF855793-B112-41CF-9187-73A3BE81AA5F}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8DCDDC40-9BA6-4C9A-86DA-E1A9309F6D14} + EndGlobalSection +EndGlobal diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.vcxproj" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.vcxproj" new file mode 100644 index 0000000..e76a718 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.vcxproj" @@ -0,0 +1,259 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {EF855793-B112-41CF-9187-73A3BE81AA5F} + MFCProj + My2DTrans + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.vcxproj.filters" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.vcxproj.filters" new file mode 100644 index 0000000..963b9d2 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.vcxproj.filters" @@ -0,0 +1,195 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.vcxproj.user" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.vcxproj.user" new file mode 100644 index 0000000..351e02b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTrans.vcxproj.user" @@ -0,0 +1,6 @@ + + + + My2DTrans.rc + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTransDoc.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTransDoc.cpp" new file mode 100644 index 0000000..fdf5bdb --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTransDoc.cpp" @@ -0,0 +1,138 @@ + +// 2DTransDoc.cpp: CMy2DTransDoc 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "2DTrans.h" +#endif + +#include "2DTransDoc.h" + +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CMy2DTransDoc + +IMPLEMENT_DYNCREATE(CMy2DTransDoc, CDocument) + +BEGIN_MESSAGE_MAP(CMy2DTransDoc, CDocument) +END_MESSAGE_MAP() + + +// CMy2DTransDoc 构造/析构 + +CMy2DTransDoc::CMy2DTransDoc() noexcept +{ + // TODO: 在此添加一次性构造代码 + +} + +CMy2DTransDoc::~CMy2DTransDoc() +{ +} + +BOOL CMy2DTransDoc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: 在此添加重新初始化代码 + // (SDI 文档将重用该文档) + + return TRUE; +} + + + + +// CMy2DTransDoc 序列化 + +void CMy2DTransDoc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: 在此添加存储代码 + } + else + { + // TODO: 在此添加加载代码 + } +} + +#ifdef SHARED_HANDLERS + +// 缩略图的支持 +void CMy2DTransDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds) +{ + // 修改此代码以绘制文档数据 + dc.FillSolidRect(lprcBounds, RGB(255, 255, 255)); + + CString strText = _T("TODO: implement thumbnail drawing here"); + LOGFONT lf; + + CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + pDefaultGUIFont->GetLogFont(&lf); + lf.lfHeight = 36; + + CFont fontDraw; + fontDraw.CreateFontIndirect(&lf); + + CFont* pOldFont = dc.SelectObject(&fontDraw); + dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK); + dc.SelectObject(pOldFont); +} + +// 搜索处理程序的支持 +void CMy2DTransDoc::InitializeSearchContent() +{ + CString strSearchContent; + // 从文档数据设置搜索内容。 + // 内容部分应由“;”分隔 + + // 例如: strSearchContent = _T("point;rectangle;circle;ole object;"); + SetSearchContent(strSearchContent); +} + +void CMy2DTransDoc::SetSearchContent(const CString& value) +{ + if (value.IsEmpty()) + { + RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); + } + else + { + CMFCFilterChunkValueImpl *pChunk = nullptr; + ATLTRY(pChunk = new CMFCFilterChunkValueImpl); + if (pChunk != nullptr) + { + pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT); + SetChunkValue(pChunk); + } + } +} + +#endif // SHARED_HANDLERS + +// CMy2DTransDoc 诊断 + +#ifdef _DEBUG +void CMy2DTransDoc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CMy2DTransDoc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// CMy2DTransDoc 命令 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTransDoc.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTransDoc.h" new file mode 100644 index 0000000..843d65d --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTransDoc.h" @@ -0,0 +1,48 @@ + +// 2DTransDoc.h: CMy2DTransDoc 类的接口 +// + + +#pragma once + + +class CMy2DTransDoc : public CDocument +{ +protected: // 仅从序列化创建 + CMy2DTransDoc() noexcept; + DECLARE_DYNCREATE(CMy2DTransDoc) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); +#ifdef SHARED_HANDLERS + virtual void InitializeSearchContent(); + virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds); +#endif // SHARED_HANDLERS + +// 实现 +public: + virtual ~CMy2DTransDoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// 生成的消息映射函数 +protected: + DECLARE_MESSAGE_MAP() + +#ifdef SHARED_HANDLERS + // 用于为搜索处理程序设置搜索内容的 Helper 函数 + void SetSearchContent(const CString& value); +#endif // SHARED_HANDLERS +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTransView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTransView.cpp" new file mode 100644 index 0000000..2e5f059 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTransView.cpp" @@ -0,0 +1,170 @@ + +// 2DTransView.cpp: CMy2DTransView 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "2DTrans.h" +#endif + +#include "2DTransDoc.h" +#include "2DTransView.h" +#include "CFence.h" +#include "CP2.h" +#include "CTransform2.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CMy2DTransView + +IMPLEMENT_DYNCREATE(CMy2DTransView, CView) + +BEGIN_MESSAGE_MAP(CMy2DTransView, CView) + // 标准打印命令 + ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CMy2DTransView::OnFilePrintPreview) + ON_WM_CONTEXTMENU() + ON_WM_RBUTTONUP() + ON_COMMAND(ID_GRAPHIC_ANIMATION, &CMy2DTransView::OnGraphicAnimation) +END_MESSAGE_MAP() + +// CMy2DTransView 构造/析构 + +CMy2DTransView::CMy2DTransView() noexcept +{ + // TODO: 在此处添加构造代码 + bPlay = FALSE; + double a = 30; + double b = 4.5 * a; + CenterPoint[0] = CP2(0, 0); + CenterPoint[1] = CP2(-b, -b); + CenterPoint[2] = CP2(b, -b); + CenterPoint[3] = CP2(b, b); + CenterPoint[4] = CP2(-b, b); + for (int i = 0; i < 5; i++) + { + fence[i].ReadPoint(); + transform[i].SetMatrix(fence[i].P, 12); + transform[i].Scale(a, a); + transform[i].Translate(CenterPoint[i].x, CenterPoint[i].y); + } +} + +CMy2DTransView::~CMy2DTransView() +{ +} + +BOOL CMy2DTransView::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return CView::PreCreateWindow(cs); +} + +// CMy2DTransView 绘图 + +void CMy2DTransView::DrawObject(CDC* pDC) +{ + if (FALSE == bPlay) + fence[0].Draw(pDC); + else + for (int i = 0; i < 5; i++) + fence[i].Draw(pDC); +} + + +void CMy2DTransView::OnDraw(CDC* pDC) +{ + CMy2DTransDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + + // TODO: 在此处为本机数据添加绘制代码 + CRect rect; + GetClientRect(&rect); + pDC->SetMapMode(MM_ANISOTROPIC); + pDC->SetWindowExt(rect.Width(), rect.Height()); + pDC->SetViewportExt(rect.Width(), -rect.Height()); + pDC->SetViewportOrg(rect.Width() / 2, rect.Height() / 2); + DrawObject(pDC); +} + + +// CMy2DTransView 打印 + + +void CMy2DTransView::OnFilePrintPreview() +{ +#ifndef SHARED_HANDLERS + AFXPrintPreview(this); +#endif +} + +BOOL CMy2DTransView::OnPreparePrinting(CPrintInfo* pInfo) +{ + // 默认准备 + return DoPreparePrinting(pInfo); +} + +void CMy2DTransView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加额外的打印前进行的初始化过程 +} + +void CMy2DTransView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加打印后进行的清理过程 +} + +void CMy2DTransView::OnRButtonUp(UINT /* nFlags */, CPoint point) +{ + ClientToScreen(&point); + OnContextMenu(this, point); +} + +void CMy2DTransView::OnContextMenu(CWnd* /* pWnd */, CPoint point) +{ +#ifndef SHARED_HANDLERS + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE); +#endif +} + + +// CMy2DTransView 诊断 + +#ifdef _DEBUG +void CMy2DTransView::AssertValid() const +{ + CView::AssertValid(); +} + +void CMy2DTransView::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +CMy2DTransDoc* CMy2DTransView::GetDocument() const // 非调试版本是内联的 +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMy2DTransDoc))); + return (CMy2DTransDoc*)m_pDocument; +} +#endif //_DEBUG + + +// CMy2DTransView 消息处理程序 + + +void CMy2DTransView::OnGraphicAnimation() +{ + // TODO: 在此添加命令处理程序代码 + bPlay = TRUE; + Invalidate(FALSE); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTransView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTransView.h" new file mode 100644 index 0000000..a3aacd5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/2DTransView.h" @@ -0,0 +1,62 @@ + +// 2DTransView.h: CMy2DTransView 类的接口 +// + +#include "CFence.h" +#include "CP2.h" +#include "CTransform2.h" +#pragma once + + +class CMy2DTransView : public CView +{ +protected: // 仅从序列化创建 + CMy2DTransView() noexcept; + DECLARE_DYNCREATE(CMy2DTransView) + +// 特性 +public: + CMy2DTransDoc* GetDocument() const; + +// 操作 +public: + +// 重写 +public: + virtual void OnDraw(CDC* pDC); // 重写以绘制该视图 + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// 实现 +public: + virtual ~CMy2DTransView(); + void DrawObject(CDC* pDC); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + bool bPlay; + CP2 CenterPoint[5]; + CFence fence[5]; + CTransform2 transform[5]; + +// 生成的消息映射函数 +protected: + afx_msg void OnFilePrintPreview(); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnGraphicAnimation(); +}; + +#ifndef _DEBUG // 2DTransView.cpp 中的调试版本 +inline CMy2DTransDoc* CMy2DTransView::GetDocument() const + { return reinterpret_cast(m_pDocument); } +#endif + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CFence.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CFence.cpp" new file mode 100644 index 0000000..462229b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CFence.cpp" @@ -0,0 +1,47 @@ +#include "pch.h" +#include "CFence.h" +#define ROUND(d) int(d + 0.5) +CFence::CFence(void) +{ +} +CFence::~CFence(void) +{ +} +void CFence::ReadPoint(void) +{ + P[0] = CP2(-1, -1); + P[1] = CP2(1, -1); + P[2] = CP2(1, 1); + P[3] = CP2(-1, 1); + P[4] = CP2(-2.5, -2.5); + P[5] = CP2(2.5, -2.5); + P[6] = CP2(2.5, 2.5); + P[7] = CP2(-2.5, 2.5); + P[8] = CP2((P[4].x + P[7].x) / 2 - 2, (P[4].y + P[7].y) / 2); + P[9] = CP2((P[4].x + P[5].x) / 2, (P[4].y + P[5].y) / 2 - 2); + P[10] = CP2((P[5].x + P[6].x) / 2 + 2, (P[5].y + P[6].y) / 2); + P[11] = CP2((P[6].x + P[7].x) / 2, (P[6].y + P[7].y) / 2 + 2); +} +void CFence::Draw(CDC* pDC) +{ + CPen NewPen(PS_SOLID, 3, RGB(0, 0, 0)); + CPen* pOldPen = pDC->SelectObject(&NewPen); + + pDC->MoveTo(ROUND(P[0].x), ROUND(P[0].y)); + pDC->LineTo(ROUND(P[1].x), ROUND(P[1].y)); + pDC->LineTo(ROUND(P[2].x), ROUND(P[2].y)); + pDC->LineTo(ROUND(P[3].x), ROUND(P[3].y)); + pDC->LineTo(ROUND(P[0].x), ROUND(P[0].y)); + + pDC->MoveTo(ROUND(P[4].x), ROUND(P[4].y)); + pDC->LineTo(ROUND(P[5].x), ROUND(P[5].y)); + pDC->LineTo(ROUND(P[6].x), ROUND(P[6].y)); + pDC->LineTo(ROUND(P[7].x), ROUND(P[7].y)); + pDC->LineTo(ROUND(P[4].x), ROUND(P[4].y)); + + pDC->MoveTo(ROUND(P[8].x), ROUND(P[8].y)); + pDC->LineTo(ROUND(P[10].x), ROUND(P[10].y)); + pDC->MoveTo(ROUND(P[9].x), ROUND(P[9].y)); + pDC->LineTo(ROUND(P[11].x), ROUND(P[11].y)); + pDC->SelectObject(pOldPen); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CFence.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CFence.h" new file mode 100644 index 0000000..0713449 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CFence.h" @@ -0,0 +1,13 @@ +#pragma once +#include "CP2.h" +class CFence +{ +public: + CFence(void); + virtual ~CFence(void); + void ReadPoint(void); + void Draw(CDC* pDC); +public: + CP2 P[12]; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CP2.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CP2.cpp" new file mode 100644 index 0000000..3bd0d69 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CP2.cpp" @@ -0,0 +1,74 @@ +#include "pch.h" +#include "CP2.h" +CP2::CP2(void) +{ + x = 0.0; + y = 0.0; + w = 1.0; +} +CP2::~CP2(void) +{ +} +CP2::CP2(double x, double y) +{ + this->x = x; + this->y = y; + this->w = 1.0; +} +CP2 operator + (const CP2& p0, const CP2& p1) +{ + CP2 result; + result.x = p0.x + p1.x; + result.y = p0.y + p1.y; + return result; +} +CP2 operator - (const CP2& p0, const CP2& p1) +{ + CP2 result; + result.x = p0.x - p1.x; + result.y = p0.y - p1.y; + return result; +} +CP2 operator * (const CP2& p, double scalar) +{ + return CP2(p.x * scalar, p.y * scalar); +} +CP2 operator * (double scalar, const CP2& p) +{ + return CP2(p.x * scalar, p.y * scalar); +} +CP2 operator / (const CP2& p, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + CP2 result; + result.x = p.x / scalar; + result.y = p.y / scalar; + return result; +} +CP2 operator+=(CP2& p0, CP2& p1) +{ + p0.x += p1.x; + p0.y += p1.y; + return p0; +} +CP2 operator-=(CP2& p0, CP2& p1) +{ + p0.x -= p1.x; + p0.y -= p1.y; + return p0; +} +CP2 operator*=(CP2& p, double scalar) +{ + p.x *= scalar; + p.y *= scalar; + return p; +} +CP2 operator/=(CP2& p, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + p.x /= scalar; + p.y /= scalar; + return p; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CP2.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CP2.h" new file mode 100644 index 0000000..85ae45e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CP2.h" @@ -0,0 +1,23 @@ +#pragma once +class CP2 +{ +public: + CP2(void); + virtual ~CP2(void); + CP2(double x, double y); + friend CP2 operator + (const CP2& p0, const CP2& p1); + friend CP2 operator - (const CP2& p0, const CP2& p1); + friend CP2 operator * (const CP2& p, double scalar); + friend CP2 operator * (double scalar, const CP2& p); + friend CP2 operator / (const CP2& p, double scalar); + friend CP2 operator += (CP2& p0, CP2& p1); + friend CP2 operator -= (CP2& p0, CP2& p1); + friend CP2 operator *= (CP2& p, double scalar); + friend CP2 operator /= (CP2& p, double scalar); +public: + double x; + double y; + double w; +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CTransform2.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CTransform2.cpp" new file mode 100644 index 0000000..9f69839 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CTransform2.cpp" @@ -0,0 +1,94 @@ +#include "pch.h" +#include "CTransform2.h" +#define PI 3.1415926 +CTransform2::CTransform2(void) +{ +} +CTransform2::~CTransform2(void) +{ +} +void CTransform2::SetMatrix(CP2* P, int ptNumber) +{ + this->P = P; + this->ptNumber = ptNumber; +} +void CTransform2::Identity(void) +{ + T[0][0] = 1.0; T[0][1] = 0.0; T[0][2] = 0.0; + T[1][0] = 0.0; T[1][1] = 1.0; T[1][2] = 0.0; + T[2][0] = 0.0; T[2][1] = 0.0; T[2][2] = 1.0; +} +void CTransform2::Translate(double tx, double ty) +{ + Identity(); + T[0][2] = tx; + T[1][2] = ty; + MultiplyMatrix(); +} +void CTransform2::Scale(double sx, double sy) +{ + Identity(); + T[0][0] = sx; + T[1][1] = sy; + MultiplyMatrix(); +} +void CTransform2::Scale(double sx, double sy, CP2 p) +{ + Translate(-p.x, -p.y); + Scale(sx, sy); + Translate(p.x, p.y); +} +void CTransform2::Rotate(double beta) +{ + Identity(); + T[0][0] = cos(beta * PI / 180); T[0][1] = -sin(beta * PI / 180); + T[1][0] = sin(beta * PI / 180); T[1][1] = cos(beta * PI / 180); + MultiplyMatrix(); +} +void CTransform2::Rotate(double beta, CP2 p) +{ + Translate(-p.x, -p.y); + Rotate(beta); + Translate(p.x, p.y); +} +void CTransform2::ReflectOrg(void) +{ + Identity(); + T[0][0] = -1; + T[1][1] = -1; + MultiplyMatrix(); +} +void CTransform2::ReflectX(void) +{ + Identity(); + T[0][0] = 1; + T[1][1] = -1; + MultiplyMatrix(); +} +void CTransform2::ReflectY(void) +{ + Identity(); + T[0][0] = -1; + T[1][1] = 1; + MultiplyMatrix(); +} +void CTransform2::Shear(double b, double c) +{ + Identity(); + T[0][1] = b; + T[1][0] = c; + MultiplyMatrix(); +} +void CTransform2::MultiplyMatrix(void) +{ + CP2* PTemp = new CP2[ptNumber]; + for (int i = 0; i < ptNumber; i++) + PTemp[i] = P[i]; + for (int i = 0; i < ptNumber; i++) + { + P[i].x = T[0][0] * PTemp[i].x + T[0][1] * PTemp[i].y + T[0][2] * PTemp[i].w; + P[i].y = T[1][0] * PTemp[i].x + T[1][1] * PTemp[i].y + T[1][2] * PTemp[i].w; + P[i].w = T[2][0] * PTemp[i].x + T[2][1] * PTemp[i].y + T[2][2] * PTemp[i].w; + } + delete[]PTemp; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CTransform2.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CTransform2.h" new file mode 100644 index 0000000..e81d37e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/CTransform2.h" @@ -0,0 +1,24 @@ +#pragma once +#include "CP2.h" +class CTransform2 +{ +public: + CTransform2(void); + virtual ~CTransform2(void); + void SetMatrix(CP2* P, int ptNumber); + void Identity(void); + void Translate(double tx, double ty); + void Scale(double sx, double sy); + void Scale(double sx, double sy, CP2 p); + void Rotate(double beta); + void Rotate(double beta, CP2 p); + void ReflectOrg(void); + void ReflectX(void); + void ReflectY(void); + void Shear(double b, double c); + void MultiplyMatrix(void); +private: + double T[3][3]; + CP2* P; + int ptNumber; +}; \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/ClassView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/ClassView.cpp" new file mode 100644 index 0000000..e0b0309 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/ClassView.cpp" @@ -0,0 +1,323 @@ + +#include "pch.h" +#include "framework.h" +#include "MainFrm.h" +#include "ClassView.h" +#include "Resource.h" +#include "2DTrans.h" + +class CClassViewMenuButton : public CMFCToolBarMenuButton +{ + friend class CClassView; + + DECLARE_SERIAL(CClassViewMenuButton) + +public: + CClassViewMenuButton(HMENU hMenu = nullptr) noexcept : CMFCToolBarMenuButton((UINT)-1, hMenu, -1) + { + } + + virtual void OnDraw(CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz = TRUE, + BOOL bCustomizeMode = FALSE, BOOL bHighlight = FALSE, BOOL bDrawBorder = TRUE, BOOL bGrayDisabledButtons = TRUE) + { + pImages = CMFCToolBar::GetImages(); + + CAfxDrawState ds; + pImages->PrepareDrawImage(ds); + + CMFCToolBarMenuButton::OnDraw(pDC, rect, pImages, bHorz, bCustomizeMode, bHighlight, bDrawBorder, bGrayDisabledButtons); + + pImages->EndDrawImage(ds); + } +}; + +IMPLEMENT_SERIAL(CClassViewMenuButton, CMFCToolBarMenuButton, 1) + +////////////////////////////////////////////////////////////////////// +// 构造/析构 +////////////////////////////////////////////////////////////////////// + +CClassView::CClassView() noexcept +{ + m_nCurrSort = ID_SORTING_GROUPBYTYPE; +} + +CClassView::~CClassView() +{ +} + +BEGIN_MESSAGE_MAP(CClassView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_CLASS_ADD_MEMBER_FUNCTION, OnClassAddMemberFunction) + ON_COMMAND(ID_CLASS_ADD_MEMBER_VARIABLE, OnClassAddMemberVariable) + ON_COMMAND(ID_CLASS_DEFINITION, OnClassDefinition) + ON_COMMAND(ID_CLASS_PROPERTIES, OnClassProperties) + ON_COMMAND(ID_NEW_FOLDER, OnNewFolder) + ON_WM_PAINT() + ON_WM_SETFOCUS() + ON_COMMAND_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnSort) + ON_UPDATE_COMMAND_UI_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnUpdateSort) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClassView 消息处理程序 + +int CClassView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndClassView.Create(dwViewStyle, rectDummy, this, 2)) + { + TRACE0("未能创建类视图\n"); + return -1; // 未能创建 + } + + // 加载图像: + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_SORT); + m_wndToolBar.LoadToolBar(IDR_SORT, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + CMenu menuSort; + menuSort.LoadMenu(IDR_POPUP_SORT); + + m_wndToolBar.ReplaceButton(ID_SORT_MENU, CClassViewMenuButton(menuSort.GetSubMenu(0)->GetSafeHmenu())); + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->m_bText = FALSE; + pButton->m_bImage = TRUE; + pButton->SetImage(GetCmdMgr()->GetCmdImage(m_nCurrSort)); + pButton->SetMessageWnd(this); + } + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillClassView(); + + return 0; +} + +void CClassView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CClassView::FillClassView() +{ + HTREEITEM hRoot = m_wndClassView.InsertItem(_T("FakeApp 类"), 0, 0); + m_wndClassView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hClass = m_wndClassView.InsertItem(_T("CFakeAboutDlg"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAboutDlg()"), 3, 3, hClass); + + m_wndClassView.Expand(hRoot, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeApp"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeApp()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("InitInstance()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnAppAbout()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppDoc"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppDoc()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppDoc()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnNewDocument()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppView"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppView()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppView()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("GetDocument()"), 3, 3, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppFrame"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("m_wndMenuBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndToolBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndStatusBar"), 6, 6, hClass); + + hClass = m_wndClassView.InsertItem(_T("Globals"), 2, 2, hRoot); + m_wndClassView.InsertItem(_T("theFakeApp"), 5, 5, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); +} + +void CClassView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndClassView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + CMenu menu; + menu.LoadMenu(IDR_POPUP_SORT); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } +} + +void CClassView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndClassView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +BOOL CClassView::PreTranslateMessage(MSG* pMsg) +{ + return CDockablePane::PreTranslateMessage(pMsg); +} + +void CClassView::OnSort(UINT id) +{ + if (m_nCurrSort == id) + { + return; + } + + m_nCurrSort = id; + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->SetImage(GetCmdMgr()->GetCmdImage(id)); + m_wndToolBar.Invalidate(); + m_wndToolBar.UpdateWindow(); + } +} + +void CClassView::OnUpdateSort(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(pCmdUI->m_nID == m_nCurrSort); +} + +void CClassView::OnClassAddMemberFunction() +{ + AfxMessageBox(_T("添加成员函数...")); +} + +void CClassView::OnClassAddMemberVariable() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassDefinition() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassProperties() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnNewFolder() +{ + AfxMessageBox(_T("新建文件夹...")); +} + +void CClassView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndClassView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CClassView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndClassView.SetFocus(); +} + +void CClassView::OnChangeVisualStyle() +{ + m_ClassViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_CLASS_VIEW_24 : IDB_CLASS_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_ClassViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_ClassViewImages.Add(&bmp, RGB(255, 0, 0)); + + m_wndClassView.SetImageList(&m_ClassViewImages, TVSIL_NORMAL); + + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_SORT_24 : IDR_SORT, 0, 0, TRUE /* 锁定*/); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/ClassView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/ClassView.h" new file mode 100644 index 0000000..786c278 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/ClassView.h" @@ -0,0 +1,54 @@ + +#pragma once + +#include "ViewTree.h" + +class CClassToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CClassView : public CDockablePane +{ +public: + CClassView() noexcept; + virtual ~CClassView(); + + void AdjustLayout(); + void OnChangeVisualStyle(); + +protected: + CClassToolBar m_wndToolBar; + CViewTree m_wndClassView; + CImageList m_ClassViewImages; + UINT m_nCurrSort; + + void FillClassView(); + +// 重写 +public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnClassAddMemberFunction(); + afx_msg void OnClassAddMemberVariable(); + afx_msg void OnClassDefinition(); + afx_msg void OnClassProperties(); + afx_msg void OnNewFolder(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg LRESULT OnChangeActiveTab(WPARAM, LPARAM); + afx_msg void OnSort(UINT id); + afx_msg void OnUpdateSort(CCmdUI* pCmdUI); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/FileView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/FileView.cpp" new file mode 100644 index 0000000..9ec5783 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/FileView.cpp" @@ -0,0 +1,257 @@ + +#include "pch.h" +#include "framework.h" +#include "mainfrm.h" +#include "FileView.h" +#include "Resource.h" +#include "2DTrans.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CFileView + +CFileView::CFileView() noexcept +{ +} + +CFileView::~CFileView() +{ +} + +BEGIN_MESSAGE_MAP(CFileView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_PROPERTIES, OnProperties) + ON_COMMAND(ID_OPEN, OnFileOpen) + ON_COMMAND(ID_OPEN_WITH, OnFileOpenWith) + ON_COMMAND(ID_DUMMY_COMPILE, OnDummyCompile) + ON_COMMAND(ID_EDIT_CUT, OnEditCut) + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_WM_PAINT() + ON_WM_SETFOCUS() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CWorkspaceBar 消息处理程序 + +int CFileView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; + + if (!m_wndFileView.Create(dwViewStyle, rectDummy, this, 4)) + { + TRACE0("未能创建文件视图\n"); + return -1; // 未能创建 + } + + // 加载视图图像: + m_FileViewImages.Create(IDB_FILE_VIEW, 16, 0, RGB(255, 0, 255)); + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_EXPLORER); + m_wndToolBar.LoadToolBar(IDR_EXPLORER, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillFileView(); + AdjustLayout(); + + return 0; +} + +void CFileView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CFileView::FillFileView() +{ + HTREEITEM hRoot = m_wndFileView.InsertItem(_T("FakeApp 文件"), 0, 0); + m_wndFileView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hSrc = m_wndFileView.InsertItem(_T("FakeApp 源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeApp.rc"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppDoc.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppView.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("MainFrm.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("pch.cpp"), 1, 1, hSrc); + + HTREEITEM hInc = m_wndFileView.InsertItem(_T("FakeApp 头文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppDoc.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppView.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("Resource.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("MainFrm.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("pch.h"), 2, 2, hInc); + + HTREEITEM hRes = m_wndFileView.InsertItem(_T("FakeApp 资源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeApp.rc2"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeAppDoc.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeToolbar.bmp"), 2, 2, hRes); + + m_wndFileView.Expand(hRoot, TVE_EXPAND); + m_wndFileView.Expand(hSrc, TVE_EXPAND); + m_wndFileView.Expand(hInc, TVE_EXPAND); +} + +void CFileView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE); +} + +void CFileView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndFileView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +void CFileView::OnProperties() +{ + AfxMessageBox(_T("属性....")); + +} + +void CFileView::OnFileOpen() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnFileOpenWith() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnDummyCompile() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCut() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCopy() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditClear() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndFileView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CFileView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndFileView.SetFocus(); +} + +void CFileView::OnChangeVisualStyle() +{ + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_EXPLORER_24 : IDR_EXPLORER, 0, 0, TRUE /* 锁定*/); + + m_FileViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_FILE_VIEW_24 : IDB_FILE_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_FileViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_FileViewImages.Add(&bmp, RGB(255, 0, 255)); + + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); +} + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/FileView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/FileView.h" new file mode 100644 index 0000000..e39a7c9 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/FileView.h" @@ -0,0 +1,55 @@ + +#pragma once + +#include "ViewTree.h" + +class CFileViewToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CFileView : public CDockablePane +{ +// 构造 +public: + CFileView() noexcept; + + void AdjustLayout(); + void OnChangeVisualStyle(); + +// 特性 +protected: + + CViewTree m_wndFileView; + CImageList m_FileViewImages; + CFileViewToolBar m_wndToolBar; + +protected: + void FillFileView(); + +// 实现 +public: + virtual ~CFileView(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnProperties(); + afx_msg void OnFileOpen(); + afx_msg void OnFileOpenWith(); + afx_msg void OnDummyCompile(); + afx_msg void OnEditCut(); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/MainFrm.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/MainFrm.cpp" new file mode 100644 index 0000000..e663bfe --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/MainFrm.cpp" @@ -0,0 +1,408 @@ + +// MainFrm.cpp: CMainFrame 类的实现 +// + +#include "pch.h" +#include "framework.h" +#include "2DTrans.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) + +const int iMaxUserToolbars = 10; +const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; +const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) + ON_WM_CREATE() + ON_COMMAND(ID_VIEW_CUSTOMIZE, &CMainFrame::OnViewCustomize) + ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, &CMainFrame::OnToolbarCreateNew) + ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook) + ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook) + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // 状态行指示器 + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +// CMainFrame 构造/析构 + +CMainFrame::CMainFrame() noexcept +{ + // TODO: 在此添加成员初始化代码 + theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2008); +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) + return -1; + + BOOL bNameValid; + + if (!m_wndMenuBar.Create(this)) + { + TRACE0("未能创建菜单栏\n"); + return -1; // 未能创建 + } + + m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); + + // 防止菜单栏在激活时获得焦点 + CMFCPopupMenu::SetForceMenuFocus(FALSE); + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) + { + TRACE0("未能创建工具栏\n"); + return -1; // 未能创建 + } + + CString strToolBarName; + bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); + ASSERT(bNameValid); + m_wndToolBar.SetWindowText(strToolBarName); + + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + + // 允许用户定义的工具栏操作: + InitUserToolbars(nullptr, uiFirstUserToolBarId, uiLastUserToolBarId); + + if (!m_wndStatusBar.Create(this)) + { + TRACE0("未能创建状态栏\n"); + return -1; // 未能创建 + } + m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); + + // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行 + m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndMenuBar); + DockPane(&m_wndToolBar); + + + // 启用 Visual Studio 2005 样式停靠窗口行为 + CDockingManager::SetDockingMode(DT_SMART); + // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 + EnableAutoHidePanes(CBRS_ALIGN_ANY); + + // 加载菜单项图像(不在任何标准工具栏上): + CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); + + // 创建停靠窗口 + if (!CreateDockingWindows()) + { + TRACE0("未能创建停靠窗口\n"); + return -1; + } + + m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); + m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndFileView); + CDockablePane* pTabbedBar = nullptr; + m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); + m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndOutput); + m_wndProperties.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndProperties); + + // 基于持久值设置视觉管理器和样式 + OnApplicationLook(theApp.m_nAppLook); + + // 启用工具栏和停靠窗口菜单替换 + EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); + + // 启用快速(按住 Alt 拖动)工具栏自定义 + CMFCToolBar::EnableQuickCustomization(); + + if (CMFCToolBar::GetUserImages() == nullptr) + { + // 加载用户定义的工具栏图像 + if (m_UserImages.Load(_T(".\\UserImages.bmp"))) + { + CMFCToolBar::SetUserImages(&m_UserImages); + } + } + + // 启用菜单个性化(最近使用的命令) + // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 + CList lstBasicCommands; + + lstBasicCommands.AddTail(ID_FILE_NEW); + lstBasicCommands.AddTail(ID_FILE_OPEN); + lstBasicCommands.AddTail(ID_FILE_SAVE); + lstBasicCommands.AddTail(ID_FILE_PRINT); + lstBasicCommands.AddTail(ID_APP_EXIT); + lstBasicCommands.AddTail(ID_EDIT_CUT); + lstBasicCommands.AddTail(ID_EDIT_PASTE); + lstBasicCommands.AddTail(ID_EDIT_UNDO); + lstBasicCommands.AddTail(ID_APP_ABOUT); + lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); + lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7); + lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); + lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); + lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); + lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); + + CMFCToolBar::SetBasicCommands(lstBasicCommands); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWndEx::PreCreateWindow(cs) ) + return FALSE; + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return TRUE; +} + +BOOL CMainFrame::CreateDockingWindows() +{ + BOOL bNameValid; + + // 创建类视图 + CString strClassView; + bNameValid = strClassView.LoadString(IDS_CLASS_VIEW); + ASSERT(bNameValid); + if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“类视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建文件视图 + CString strFileView; + bNameValid = strFileView.LoadString(IDS_FILE_VIEW); + ASSERT(bNameValid); + if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“文件视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建输出窗口 + CString strOutputWnd; + bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND); + ASSERT(bNameValid); + if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建输出窗口\n"); + return FALSE; // 未能创建 + } + + // 创建属性窗口 + CString strPropertiesWnd; + bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND); + ASSERT(bNameValid); + if (!m_wndProperties.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“属性”窗口\n"); + return FALSE; // 未能创建 + } + + SetDockingWindowIcons(theApp.m_bHiColorIcons); + return TRUE; +} + +void CMainFrame::SetDockingWindowIcons(BOOL bHiColorIcons) +{ + HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_FILE_VIEW_HC : IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndFileView.SetIcon(hFileViewIcon, FALSE); + + HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_CLASS_VIEW_HC : IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndClassView.SetIcon(hClassViewIcon, FALSE); + + HICON hOutputBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_OUTPUT_WND_HC : IDI_OUTPUT_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndOutput.SetIcon(hOutputBarIcon, FALSE); + + HICON hPropertiesBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_PROPERTIES_WND_HC : IDI_PROPERTIES_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndProperties.SetIcon(hPropertiesBarIcon, FALSE); + +} + +// CMainFrame 诊断 + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWndEx::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWndEx::Dump(dc); +} +#endif //_DEBUG + + +// CMainFrame 消息处理程序 + +void CMainFrame::OnViewCustomize() +{ + CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* 扫描菜单*/); + pDlgCust->EnableUserDefinedToolbars(); + pDlgCust->Create(); +} + +LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) +{ + LRESULT lres = CFrameWndEx::OnToolbarCreateNew(wp,lp); + if (lres == 0) + { + return 0; + } + + CMFCToolBar* pUserToolbar = (CMFCToolBar*)lres; + ASSERT_VALID(pUserToolbar); + + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + return lres; +} + +void CMainFrame::OnApplicationLook(UINT id) +{ + CWaitCursor wait; + + theApp.m_nAppLook = id; + + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_WIN_2000: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); + break; + + case ID_VIEW_APPLOOK_OFF_XP: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); + break; + + case ID_VIEW_APPLOOK_WIN_XP: + CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + break; + + case ID_VIEW_APPLOOK_OFF_2003: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2005: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2008: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_WINDOWS_7: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + default: + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_OFF_2007_BLUE: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); + break; + + case ID_VIEW_APPLOOK_OFF_2007_BLACK: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); + break; + + case ID_VIEW_APPLOOK_OFF_2007_SILVER: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); + break; + + case ID_VIEW_APPLOOK_OFF_2007_AQUA: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); + break; + } + + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); + CDockingManager::SetDockingMode(DT_SMART); + } + + m_wndOutput.UpdateFonts(); + RedrawWindow(nullptr, nullptr, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); + + theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); +} + +void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI) +{ + pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID); +} + + +BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) +{ + // 基类将执行真正的工作 + + if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) + { + return FALSE; + } + + + // 为所有用户工具栏启用自定义按钮 + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + for (int i = 0; i < iMaxUserToolbars; i ++) + { + CMFCToolBar* pUserToolbar = GetUserToolBarByIndex(i); + if (pUserToolbar != nullptr) + { + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + } + } + + return TRUE; +} + + +void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CFrameWndEx::OnSettingChange(uFlags, lpszSection); + m_wndOutput.UpdateFonts(); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/MainFrm.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/MainFrm.h" new file mode 100644 index 0000000..02feb8e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/MainFrm.h" @@ -0,0 +1,61 @@ + +// MainFrm.h: CMainFrame 类的接口 +// + +#pragma once +#include "FileView.h" +#include "ClassView.h" +#include "OutputWnd.h" +#include "PropertiesWnd.h" + +class CMainFrame : public CFrameWndEx +{ + +protected: // 仅从序列化创建 + CMainFrame() noexcept; + DECLARE_DYNCREATE(CMainFrame) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = nullptr, CCreateContext* pContext = nullptr); + +// 实现 +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // 控件条嵌入成员 + CMFCMenuBar m_wndMenuBar; + CMFCToolBar m_wndToolBar; + CMFCStatusBar m_wndStatusBar; + CMFCToolBarImages m_UserImages; + CFileView m_wndFileView; + CClassView m_wndClassView; + COutputWnd m_wndOutput; + CPropertiesWnd m_wndProperties; + +// 生成的消息映射函数 +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnViewCustomize(); + afx_msg LRESULT OnToolbarCreateNew(WPARAM wp, LPARAM lp); + afx_msg void OnApplicationLook(UINT id); + afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + DECLARE_MESSAGE_MAP() + + BOOL CreateDockingWindows(); + void SetDockingWindowIcons(BOOL bHiColorIcons); +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/My2DTrans.aps" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/My2DTrans.aps" new file mode 100644 index 0000000..21ed60e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/My2DTrans.aps" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/My2DTrans.rc" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/My2DTrans.rc" new file mode 100644 index 0000000..0f65096 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/My2DTrans.rc" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/OutputWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/OutputWnd.cpp" new file mode 100644 index 0000000..e3f4901 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/OutputWnd.cpp" @@ -0,0 +1,200 @@ + +#include "pch.h" +#include "framework.h" + +#include "OutputWnd.h" +#include "Resource.h" +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// COutputBar + +COutputWnd::COutputWnd() noexcept +{ +} + +COutputWnd::~COutputWnd() +{ +} + +BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() +END_MESSAGE_MAP() + +int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建选项卡窗口: + if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1)) + { + TRACE0("未能创建输出选项卡窗口\n"); + return -1; // 未能创建 + } + + // 创建输出窗格: + const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; + + if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) || + !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) || + !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4)) + { + TRACE0("未能创建输出窗口\n"); + return -1; // 未能创建 + } + + UpdateFonts(); + + CString strTabName; + BOOL bNameValid; + + // 将列表窗口附加到选项卡: + bNameValid = strTabName.LoadString(IDS_BUILD_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0); + bNameValid = strTabName.LoadString(IDS_DEBUG_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1); + bNameValid = strTabName.LoadString(IDS_FIND_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2); + + // 使用一些虚拟文本填写输出选项卡(无需复杂数据) + FillBuildWindow(); + FillDebugWindow(); + FillFindWindow(); + + return 0; +} + +void COutputWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + + // 选项卡控件应覆盖整个工作区: + m_wndTabs.SetWindowPos (nullptr, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); +} + +void COutputWnd::AdjustHorzScroll(CListBox& wndListBox) +{ + CClientDC dc(this); + CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular); + + int cxExtentMax = 0; + + for (int i = 0; i < wndListBox.GetCount(); i ++) + { + CString strItem; + wndListBox.GetText(i, strItem); + + cxExtentMax = max(cxExtentMax, (int)dc.GetTextExtent(strItem).cx); + } + + wndListBox.SetHorizontalExtent(cxExtentMax); + dc.SelectObject(pOldFont); +} + +void COutputWnd::FillBuildWindow() +{ + m_wndOutputBuild.AddString(_T("生成输出正显示在此处。")); + m_wndOutputBuild.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputBuild.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillDebugWindow() +{ + m_wndOutputDebug.AddString(_T("调试输出正显示在此处。")); + m_wndOutputDebug.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputDebug.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillFindWindow() +{ + m_wndOutputFind.AddString(_T("查找输出正显示在此处。")); + m_wndOutputFind.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputFind.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::UpdateFonts() +{ + m_wndOutputBuild.SetFont(&afxGlobalData.fontRegular); + m_wndOutputDebug.SetFont(&afxGlobalData.fontRegular); + m_wndOutputFind.SetFont(&afxGlobalData.fontRegular); +} + +///////////////////////////////////////////////////////////////////////////// +// COutputList1 + +COutputList::COutputList() noexcept +{ +} + +COutputList::~COutputList() +{ +} + +BEGIN_MESSAGE_MAP(COutputList, CListBox) + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput) + ON_WM_WINDOWPOSCHANGING() +END_MESSAGE_MAP() +///////////////////////////////////////////////////////////////////////////// +// COutputList 消息处理程序 + +void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) +{ + CMenu menu; + menu.LoadMenu(IDR_OUTPUT_POPUP); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } + + SetFocus(); +} + +void COutputList::OnEditCopy() +{ + MessageBox(_T("复制输出")); +} + +void COutputList::OnEditClear() +{ + MessageBox(_T("清除输出")); +} + +void COutputList::OnViewOutput() +{ + CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner()); + CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame()); + + if (pMainFrame != nullptr && pParentBar != nullptr) + { + pMainFrame->SetFocus(); + pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE); + pMainFrame->RecalcLayout(); + + } +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/OutputWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/OutputWnd.h" new file mode 100644 index 0000000..4d773c3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/OutputWnd.h" @@ -0,0 +1,59 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// COutputList 窗口 + +class COutputList : public CListBox +{ +// 构造 +public: + COutputList() noexcept; + +// 实现 +public: + virtual ~COutputList(); + +protected: + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnViewOutput(); + + DECLARE_MESSAGE_MAP() +}; + +class COutputWnd : public CDockablePane +{ +// 构造 +public: + COutputWnd() noexcept; + + void UpdateFonts(); + +// 特性 +protected: + CMFCTabCtrl m_wndTabs; + + COutputList m_wndOutputBuild; + COutputList m_wndOutputDebug; + COutputList m_wndOutputFind; + +protected: + void FillBuildWindow(); + void FillDebugWindow(); + void FillFindWindow(); + + void AdjustHorzScroll(CListBox& wndListBox); + +// 实现 +public: + virtual ~COutputWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/PropertiesWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/PropertiesWnd.cpp" new file mode 100644 index 0000000..1c50634 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/PropertiesWnd.cpp" @@ -0,0 +1,273 @@ + +#include "pch.h" +#include "framework.h" + +#include "PropertiesWnd.h" +#include "Resource.h" +#include "MainFrm.h" +#include "2DTrans.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar + +CPropertiesWnd::CPropertiesWnd() noexcept +{ + m_nComboHeight = 0; +} + +CPropertiesWnd::~CPropertiesWnd() +{ +} + +BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties) + ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties) + ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties) + ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties) + ON_COMMAND(ID_PROPERTIES1, OnProperties1) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1) + ON_COMMAND(ID_PROPERTIES2, OnProperties2) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2) + ON_WM_SETFOCUS() + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar 消息处理程序 + +void CPropertiesWnd::AdjustLayout() +{ + if (GetSafeHwnd () == nullptr || (AfxGetMainWnd() != nullptr && AfxGetMainWnd()->IsIconic())) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndObjectCombo.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndPropList.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight + cyTlb, rectClient.Width(), rectClient.Height() -(m_nComboHeight+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER); +} + +int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建组合: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1)) + { + TRACE0("未能创建属性组合 \n"); + return -1; // 未能创建 + } + + m_wndObjectCombo.AddString(_T("应用程序")); + m_wndObjectCombo.AddString(_T("属性窗口")); + m_wndObjectCombo.SetCurSel(0); + + CRect rectCombo; + m_wndObjectCombo.GetClientRect (&rectCombo); + + m_nComboHeight = rectCombo.Height(); + + if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2)) + { + TRACE0("未能创建属性网格\n"); + return -1; // 未能创建 + } + + InitPropList(); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES); + m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* 已锁定*/); + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* 锁定*/); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + AdjustLayout(); + return 0; +} + +void CPropertiesWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CPropertiesWnd::OnExpandAllProperties() +{ + m_wndPropList.ExpandAll(); +} + +void CPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* /* pCmdUI */) +{ +} + +void CPropertiesWnd::OnSortProperties() +{ + m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnProperties1() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::OnProperties2() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::InitPropList() +{ + SetPropListFont(); + + m_wndPropList.EnableHeaderCtrl(FALSE); + m_wndPropList.EnableDescriptionArea(); + m_wndPropList.SetVSDotNetLook(); + m_wndPropList.MarkModifiedProperties(); + + CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("外观")); + + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("三维外观"), (_variant_t) false, _T("指定窗口的字体不使用粗体,并且控件将使用三维边框"))); + + CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("边框"), _T("对话框外框"), _T("其中之一: “无”、“细”、“可调整大小”或“对话框外框”")); + pProp->AddOption(_T("无")); + pProp->AddOption(_T("细")); + pProp->AddOption(_T("可调整大小")); + pProp->AddOption(_T("对话框外框")); + pProp->AllowEdit(FALSE); + + pGroup1->AddSubItem(pProp); + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("标题"), (_variant_t) _T("关于"), _T("指定窗口标题栏中显示的文本"))); + + m_wndPropList.AddProperty(pGroup1); + + CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("窗口大小"), 0, TRUE); + + pProp = new CMFCPropertyGridProperty(_T("高度"), (_variant_t) 250l, _T("指定窗口的高度")); + pProp->EnableSpinControl(TRUE, 50, 300); + pSize->AddSubItem(pProp); + + pProp = new CMFCPropertyGridProperty( _T("宽度"), (_variant_t) 150l, _T("指定窗口的宽度")); + pProp->EnableSpinControl(TRUE, 50, 200); + pSize->AddSubItem(pProp); + + m_wndPropList.AddProperty(pSize); + + CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("字体")); + + LOGFONT lf; + CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + font->GetLogFont(&lf); + + _tcscpy_s(lf.lfFaceName, _T("宋体, Arial")); + + pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("字体"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("指定窗口的默认字体"))); + pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("使用系统字体"), (_variant_t) true, _T("指定窗口使用“MS Shell Dlg”字体"))); + + m_wndPropList.AddProperty(pGroup2); + + CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("杂项")); + pProp = new CMFCPropertyGridProperty(_T("(名称)"), _T("应用程序")); + pProp->Enable(FALSE); + pGroup3->AddSubItem(pProp); + + CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("窗口颜色"), RGB(210, 192, 254), nullptr, _T("指定默认的窗口颜色")); + pColorProp->EnableOtherButton(_T("其他...")); + pColorProp->EnableAutomaticButton(_T("默认"), ::GetSysColor(COLOR_3DFACE)); + pGroup3->AddSubItem(pColorProp); + + static const TCHAR szFilter[] = _T("图标文件(*.ico)|*.ico|所有文件(*.*)|*.*||"); + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("图标"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("指定窗口图标"))); + + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("文件夹"), _T("c:\\"))); + + m_wndPropList.AddProperty(pGroup3); + + CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("层次结构")); + + CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("第一个子级")); + pGroup4->AddSubItem(pGroup41); + + CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("第二个子级")); + pGroup41->AddSubItem(pGroup411); + + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 1"), (_variant_t) _T("值 1"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 2"), (_variant_t) _T("值 2"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 3"), (_variant_t) _T("值 3"), _T("此为说明"))); + + pGroup4->Expand(FALSE); + m_wndPropList.AddProperty(pGroup4); +} + +void CPropertiesWnd::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + m_wndPropList.SetFocus(); +} + +void CPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CDockablePane::OnSettingChange(uFlags, lpszSection); + SetPropListFont(); +} + +void CPropertiesWnd::SetPropListFont() +{ + ::DeleteObject(m_fntPropList.Detach()); + + LOGFONT lf; + afxGlobalData.fontRegular.GetLogFont(&lf); + + NONCLIENTMETRICS info; + info.cbSize = sizeof(info); + + afxGlobalData.GetNonClientMetrics(info); + + lf.lfHeight = info.lfMenuFont.lfHeight; + lf.lfWeight = info.lfMenuFont.lfWeight; + lf.lfItalic = info.lfMenuFont.lfItalic; + + m_fntPropList.CreateFontIndirect(&lf); + + m_wndPropList.SetFont(&m_fntPropList); + m_wndObjectCombo.SetFont(&m_fntPropList); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/PropertiesWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/PropertiesWnd.h" new file mode 100644 index 0000000..e056430 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/PropertiesWnd.h" @@ -0,0 +1,62 @@ + +#pragma once + +class CPropertiesToolBar : public CMFCToolBar +{ +public: + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CPropertiesWnd : public CDockablePane +{ +// 构造 +public: + CPropertiesWnd() noexcept; + + void AdjustLayout(); + +// 特性 +public: + void SetVSDotNetLook(BOOL bSet) + { + m_wndPropList.SetVSDotNetLook(bSet); + m_wndPropList.SetGroupNameFullWidth(bSet); + } + +protected: + CFont m_fntPropList; + CComboBox m_wndObjectCombo; + CPropertiesToolBar m_wndToolBar; + CMFCPropertyGridCtrl m_wndPropList; + +// 实现 +public: + virtual ~CPropertiesWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnExpandAllProperties(); + afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI); + afx_msg void OnSortProperties(); + afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI); + afx_msg void OnProperties1(); + afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI); + afx_msg void OnProperties2(); + afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + + DECLARE_MESSAGE_MAP() + + void InitPropList(); + void SetPropListFont(); + + int m_nComboHeight; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/ViewTree.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/ViewTree.cpp" new file mode 100644 index 0000000..84996cb --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/ViewTree.cpp" @@ -0,0 +1,43 @@ + +#include "pch.h" +#include "framework.h" +#include "ViewTree.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CViewTree + +CViewTree::CViewTree() noexcept +{ +} + +CViewTree::~CViewTree() +{ +} + +BEGIN_MESSAGE_MAP(CViewTree, CTreeCtrl) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 消息处理程序 + +BOOL CViewTree::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult); + + NMHDR* pNMHDR = (NMHDR*)lParam; + ASSERT(pNMHDR != nullptr); + +#pragma warning(suppress : 26454) + if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips() != nullptr) + { + GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); + } + + return bRes; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/ViewTree.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/ViewTree.h" new file mode 100644 index 0000000..0267d80 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/ViewTree.h" @@ -0,0 +1,23 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 窗口 + +class CViewTree : public CTreeCtrl +{ +// 构造 +public: + CViewTree() noexcept; + +// 重写 +protected: + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + +// 实现 +public: + virtual ~CViewTree(); + +protected: + DECLARE_MESSAGE_MAP() +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/framework.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/pch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/pch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/pch.h" new file mode 100644 index 0000000..9660927 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/pch.h" @@ -0,0 +1,13 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" + +#endif //PCH_H diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/2DTrans.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/2DTrans.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/2DTrans.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/2DTransDoc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/2DTransDoc.ico" new file mode 100644 index 0000000..96365d4 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/2DTransDoc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/My2DTrans.rc2" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/My2DTrans.rc2" new file mode 100644 index 0000000..03005a3 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/My2DTrans.rc2" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/Toolbar.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/Toolbar.bmp" new file mode 100644 index 0000000..d501723 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/Toolbar.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/Toolbar256.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/Toolbar256.bmp" new file mode 100644 index 0000000..91a2553 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/Toolbar256.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/class_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/class_view.ico" new file mode 100644 index 0000000..bf6b0dd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/class_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/class_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/class_view_hc.ico" new file mode 100644 index 0000000..3112bf2 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/class_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/classview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/classview.bmp" new file mode 100644 index 0000000..1e02aa1 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/classview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/classview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/classview_hc.bmp" new file mode 100644 index 0000000..6b22e78 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/classview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/explorer.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/explorer.bmp" new file mode 100644 index 0000000..01298ba Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/explorer.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/explorer_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/explorer_hc.bmp" new file mode 100644 index 0000000..697199d Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/explorer_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/file_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/file_view.ico" new file mode 100644 index 0000000..0f93f52 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/file_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/file_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/file_view_hc.ico" new file mode 100644 index 0000000..42ec435 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/file_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/fileview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/fileview.bmp" new file mode 100644 index 0000000..a2d62d0 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/fileview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/fileview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/fileview_hc.bmp" new file mode 100644 index 0000000..b60f483 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/fileview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/menuimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/menuimages.bmp" new file mode 100644 index 0000000..7771841 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/menuimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/menuimages_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/menuimages_hc.bmp" new file mode 100644 index 0000000..577926e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/menuimages_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/output_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/output_wnd.ico" new file mode 100644 index 0000000..d14f991 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/output_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/output_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/output_wnd_hc.ico" new file mode 100644 index 0000000..fdd27e8 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/output_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/properties.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/properties.bmp" new file mode 100644 index 0000000..72e2b29 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/properties.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/properties_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/properties_hc.bmp" new file mode 100644 index 0000000..d18a7ca Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/properties_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/properties_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/properties_wnd.ico" new file mode 100644 index 0000000..3611766 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/properties_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/properties_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/properties_wnd_hc.ico" new file mode 100644 index 0000000..1e06b64 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/properties_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/sort.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/sort.bmp" new file mode 100644 index 0000000..0307301 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/sort.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/sort_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/sort_hc.bmp" new file mode 100644 index 0000000..720e742 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/sort_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/userimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/userimages.bmp" new file mode 100644 index 0000000..affe657 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/res/userimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/resource.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/resource.h" new file mode 100644 index 0000000..bc0a2a9 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/resource.h" @@ -0,0 +1,99 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ 生成的包含文件。 +// 供 My2DTrans.rc 使用 +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_POPUP_EDIT 119 +#define ID_STATUSBAR_PANE1 120 +#define ID_STATUSBAR_PANE2 121 +#define IDS_STATUS_PANE1 122 +#define IDS_STATUS_PANE2 123 +#define IDS_TOOLBAR_STANDARD 124 +#define IDS_TOOLBAR_CUSTOMIZE 125 +#define ID_VIEW_CUSTOMIZE 126 +#define IDR_MAINFRAME 128 +#define IDR_MAINFRAME_256 129 +#define IDR_My2DTransTYPE 130 +#define ID_WINDOW_MANAGER 131 +#define ID_VIEW_FILEVIEW 133 +#define ID_VIEW_CLASSVIEW 134 +#define ID_PROPERTIES 135 +#define ID_OPEN 136 +#define ID_OPEN_WITH 137 +#define ID_DUMMY_COMPILE 138 +#define ID_CLASS_ADD_MEMBER_FUNCTION 139 +#define ID_CLASS_ADD_MEMBER_VARIABLE 140 +#define ID_CLASS_DEFINITION 141 +#define ID_CLASS_PROPERTIES 142 +#define ID_NEW_FOLDER 143 +#define ID_SORT_MENU 144 +#define ID_SORTING_GROUPBYTYPE 145 +#define ID_SORTING_SORTALPHABETIC 146 +#define ID_SORTING_SORTBYTYPE 147 +#define ID_SORTING_SORTBYACCESS 148 +#define ID_VIEW_OUTPUTWND 149 +#define ID_VIEW_PROPERTIESWND 150 +#define ID_SORTPROPERTIES 151 +#define ID_PROPERTIES1 152 +#define ID_PROPERTIES2 153 +#define ID_EXPAND_ALL 154 +#define IDS_FILE_VIEW 155 +#define IDS_CLASS_VIEW 156 +#define IDS_OUTPUT_WND 157 +#define IDS_PROPERTIES_WND 158 +#define IDI_FILE_VIEW 161 +#define IDI_FILE_VIEW_HC 162 +#define IDI_CLASS_VIEW 163 +#define IDI_CLASS_VIEW_HC 164 +#define IDI_OUTPUT_WND 165 +#define IDI_OUTPUT_WND_HC 166 +#define IDI_PROPERTIES_WND 167 +#define IDI_PROPERTIES_WND_HC 168 +#define IDR_EXPLORER 169 +#define IDB_EXPLORER_24 170 +#define IDR_SORT 171 +#define IDB_SORT_24 172 +#define IDR_POPUP_SORT 173 +#define IDR_POPUP_EXPLORER 174 +#define IDB_FILE_VIEW 175 +#define IDB_FILE_VIEW_24 176 +#define IDB_CLASS_VIEW 177 +#define IDB_CLASS_VIEW_24 178 +#define IDR_MENU_IMAGES 179 +#define IDB_MENU_IMAGES_24 180 +#define ID_TOOLS_MACRO 181 +#define IDR_OUTPUT_POPUP 182 +#define IDR_PROPERTIES 183 +#define IDB_PROPERTIES_HC 184 +#define IDR_THEME_MENU 200 +#define ID_SET_STYLE 201 +#define ID_VIEW_APPLOOK_WIN_2000 205 +#define ID_VIEW_APPLOOK_OFF_XP 206 +#define ID_VIEW_APPLOOK_WIN_XP 207 +#define ID_VIEW_APPLOOK_OFF_2003 208 +#define ID_VIEW_APPLOOK_VS_2005 209 +#define ID_VIEW_APPLOOK_VS_2008 210 +#define ID_VIEW_APPLOOK_OFF_2007_BLUE 215 +#define ID_VIEW_APPLOOK_OFF_2007_BLACK 216 +#define ID_VIEW_APPLOOK_OFF_2007_SILVER 217 +#define ID_VIEW_APPLOOK_OFF_2007_AQUA 218 +#define ID_VIEW_APPLOOK_WINDOWS_7 219 +#define IDS_BUILD_TAB 300 +#define IDS_DEBUG_TAB 301 +#define IDS_FIND_TAB 302 +#define IDS_EXPLORER 305 +#define IDS_EDIT_MENU 306 +#define ID_32771 32771 +#define ID_GRAPHIC_ANIMATION 32772 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 310 +#define _APS_NEXT_COMMAND_VALUE 32773 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 310 +#endif +#endif diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/targetver.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/2DTrans/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.cpp" new file mode 100644 index 0000000..deecabf --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.cpp" @@ -0,0 +1,219 @@ + +// 3DTrans.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "afxwinappex.h" +#include "afxdialogex.h" +#include "3DTrans.h" +#include "MainFrm.h" + +#include "3DTransDoc.h" +#include "3DTransView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CMy3DTransApp + +BEGIN_MESSAGE_MAP(CMy3DTransApp, CWinAppEx) + ON_COMMAND(ID_APP_ABOUT, &CMy3DTransApp::OnAppAbout) + // 基于文件的标准文档命令 + ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) + // 标准打印设置命令 + ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup) +END_MESSAGE_MAP() + + +// CMy3DTransApp 构造 + +CMy3DTransApp::CMy3DTransApp() noexcept +{ + m_bHiColorIcons = TRUE; + + + m_nAppLook = 0; + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; +#ifdef _MANAGED + // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则: + // 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。 + // 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。 + System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); +#endif + + // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式 + //为 CompanyName.ProductName.SubProduct.VersionInformation + SetAppID(_T("My3DTrans.AppID.NoVersion")); + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + +// 唯一的 CMy3DTransApp 对象 + +CMy3DTransApp theApp; + + +// CMy3DTransApp 初始化 + +BOOL CMy3DTransApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinAppEx::InitInstance(); + + + // 初始化 OLE 库 + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + + AfxEnableControlContainer(); + + EnableTaskbarInteraction(FALSE); + + // 使用 RichEdit 控件需要 AfxInitRichEdit2() + // AfxInitRichEdit2(); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) + + + InitContextMenuManager(); + + InitKeyboardManager(); + + InitTooltipManager(); + CMFCToolTipInfo ttParams; + ttParams.m_bVislManagerTheme = TRUE; + theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, + RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); + + // 注册应用程序的文档模板。 文档模板 + // 将用作文档、框架窗口和视图之间的连接 + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(CMy3DTransDoc), + RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 + RUNTIME_CLASS(CMy3DTransView)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + + + // 分析标准 shell 命令、DDE、打开文件操作的命令行 + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + + + // 调度在命令行中指定的命令。 如果 + // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + + // 唯一的一个窗口已初始化,因此显示它并对其进行更新 + m_pMainWnd->ShowWindow(SW_SHOW); + m_pMainWnd->UpdateWindow(); + return TRUE; +} + +int CMy3DTransApp::ExitInstance() +{ + //TODO: 处理可能已添加的附加资源 + AfxOleTerm(FALSE); + + return CWinAppEx::ExitInstance(); +} + +// CMy3DTransApp 消息处理程序 + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg() noexcept; + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + +// 用于运行对话框的应用程序命令 +void CMy3DTransApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +// CMy3DTransApp 自定义加载/保存方法 + +void CMy3DTransApp::PreLoadState() +{ + BOOL bNameValid; + CString strName; + bNameValid = strName.LoadString(IDS_EDIT_MENU); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); + bNameValid = strName.LoadString(IDS_EXPLORER); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EXPLORER); + } + +void CMy3DTransApp::LoadCustomState() +{ +} + +void CMy3DTransApp::SaveCustomState() +{ +} + +// CMy3DTransApp 消息处理程序 + + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.h" new file mode 100644 index 0000000..abbc895 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.h" @@ -0,0 +1,40 @@ + +// 3DTrans.h: 3DTrans 应用程序的主头文件 +// +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// CMy3DTransApp: +// 有关此类的实现,请参阅 3DTrans.cpp +// + +class CMy3DTransApp : public CWinAppEx +{ +public: + CMy3DTransApp() noexcept; + + +// 重写 +public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + +// 实现 + UINT m_nAppLook; + BOOL m_bHiColorIcons; + + virtual void PreLoadState(); + virtual void LoadCustomState(); + virtual void SaveCustomState(); + + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern CMy3DTransApp theApp; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.sln" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.sln" new file mode 100644 index 0000000..38c88ed --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33414.496 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "3DTrans", "3DTrans.vcxproj", "{E5059928-7AEC-4E3B-AA45-C02399CC7C28}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E5059928-7AEC-4E3B-AA45-C02399CC7C28}.Debug|x64.ActiveCfg = Debug|x64 + {E5059928-7AEC-4E3B-AA45-C02399CC7C28}.Debug|x64.Build.0 = Debug|x64 + {E5059928-7AEC-4E3B-AA45-C02399CC7C28}.Debug|x86.ActiveCfg = Debug|Win32 + {E5059928-7AEC-4E3B-AA45-C02399CC7C28}.Debug|x86.Build.0 = Debug|Win32 + {E5059928-7AEC-4E3B-AA45-C02399CC7C28}.Release|x64.ActiveCfg = Release|x64 + {E5059928-7AEC-4E3B-AA45-C02399CC7C28}.Release|x64.Build.0 = Release|x64 + {E5059928-7AEC-4E3B-AA45-C02399CC7C28}.Release|x86.ActiveCfg = Release|Win32 + {E5059928-7AEC-4E3B-AA45-C02399CC7C28}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9D57AD97-9CAA-4D0D-A36A-26B356B8705C} + EndGlobalSection +EndGlobal diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.vcxproj" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.vcxproj" new file mode 100644 index 0000000..924ca8b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.vcxproj" @@ -0,0 +1,263 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {E5059928-7AEC-4E3B-AA45-C02399CC7C28} + MFCProj + My3DTrans + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.vcxproj.filters" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.vcxproj.filters" new file mode 100644 index 0000000..7458e5e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.vcxproj.filters" @@ -0,0 +1,207 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.vcxproj.user" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.vcxproj.user" new file mode 100644 index 0000000..c926414 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTrans.vcxproj.user" @@ -0,0 +1,6 @@ + + + + My3DTrans.rc + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTransDoc.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTransDoc.cpp" new file mode 100644 index 0000000..bed72ce --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTransDoc.cpp" @@ -0,0 +1,138 @@ + +// 3DTransDoc.cpp: CMy3DTransDoc 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "3DTrans.h" +#endif + +#include "3DTransDoc.h" + +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CMy3DTransDoc + +IMPLEMENT_DYNCREATE(CMy3DTransDoc, CDocument) + +BEGIN_MESSAGE_MAP(CMy3DTransDoc, CDocument) +END_MESSAGE_MAP() + + +// CMy3DTransDoc 构造/析构 + +CMy3DTransDoc::CMy3DTransDoc() noexcept +{ + // TODO: 在此添加一次性构造代码 + +} + +CMy3DTransDoc::~CMy3DTransDoc() +{ +} + +BOOL CMy3DTransDoc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: 在此添加重新初始化代码 + // (SDI 文档将重用该文档) + + return TRUE; +} + + + + +// CMy3DTransDoc 序列化 + +void CMy3DTransDoc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: 在此添加存储代码 + } + else + { + // TODO: 在此添加加载代码 + } +} + +#ifdef SHARED_HANDLERS + +// 缩略图的支持 +void CMy3DTransDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds) +{ + // 修改此代码以绘制文档数据 + dc.FillSolidRect(lprcBounds, RGB(255, 255, 255)); + + CString strText = _T("TODO: implement thumbnail drawing here"); + LOGFONT lf; + + CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + pDefaultGUIFont->GetLogFont(&lf); + lf.lfHeight = 36; + + CFont fontDraw; + fontDraw.CreateFontIndirect(&lf); + + CFont* pOldFont = dc.SelectObject(&fontDraw); + dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK); + dc.SelectObject(pOldFont); +} + +// 搜索处理程序的支持 +void CMy3DTransDoc::InitializeSearchContent() +{ + CString strSearchContent; + // 从文档数据设置搜索内容。 + // 内容部分应由“;”分隔 + + // 例如: strSearchContent = _T("point;rectangle;circle;ole object;"); + SetSearchContent(strSearchContent); +} + +void CMy3DTransDoc::SetSearchContent(const CString& value) +{ + if (value.IsEmpty()) + { + RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); + } + else + { + CMFCFilterChunkValueImpl *pChunk = nullptr; + ATLTRY(pChunk = new CMFCFilterChunkValueImpl); + if (pChunk != nullptr) + { + pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT); + SetChunkValue(pChunk); + } + } +} + +#endif // SHARED_HANDLERS + +// CMy3DTransDoc 诊断 + +#ifdef _DEBUG +void CMy3DTransDoc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CMy3DTransDoc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// CMy3DTransDoc 命令 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTransDoc.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTransDoc.h" new file mode 100644 index 0000000..30720a9 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTransDoc.h" @@ -0,0 +1,48 @@ + +// 3DTransDoc.h: CMy3DTransDoc 类的接口 +// + + +#pragma once + + +class CMy3DTransDoc : public CDocument +{ +protected: // 仅从序列化创建 + CMy3DTransDoc() noexcept; + DECLARE_DYNCREATE(CMy3DTransDoc) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); +#ifdef SHARED_HANDLERS + virtual void InitializeSearchContent(); + virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds); +#endif // SHARED_HANDLERS + +// 实现 +public: + virtual ~CMy3DTransDoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// 生成的消息映射函数 +protected: + DECLARE_MESSAGE_MAP() + +#ifdef SHARED_HANDLERS + // 用于为搜索处理程序设置搜索内容的 Helper 函数 + void SetSearchContent(const CString& value); +#endif // SHARED_HANDLERS +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTransView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTransView.cpp" new file mode 100644 index 0000000..572962b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTransView.cpp" @@ -0,0 +1,195 @@ + +// 3DTransView.cpp: CMy3DTransView 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "3DTrans.h" +#endif + +#include "3DTransDoc.h" +#include "3DTransView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CMy3DTransView + +IMPLEMENT_DYNCREATE(CMy3DTransView, CView) + +BEGIN_MESSAGE_MAP(CMy3DTransView, CView) + // 标准打印命令 + ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CMy3DTransView::OnFilePrintPreview) + ON_WM_CONTEXTMENU() + ON_WM_RBUTTONUP() + ON_WM_KEYDOWN() +END_MESSAGE_MAP() + +// CMy3DTransView 构造/析构 + +CMy3DTransView::CMy3DTransView() noexcept +{ + // TODO: 在此处添加构造代码 + cube.ReadPoint(); + cube.ReadFacet(); + transform.SetMatrix(cube.GetVertexArrayName(), 8); + double nEdge = 400; + transform.Scale(nEdge, nEdge, nEdge); + transform.Translate(-nEdge / 2, -nEdge / 2, -nEdge / 2); +} + +CMy3DTransView::~CMy3DTransView() +{ +} + +BOOL CMy3DTransView::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return CView::PreCreateWindow(cs); +} + +// CMy3DTransView 绘图 + +void CMy3DTransView::OnDraw(CDC* pDC) +{ + CMy3DTransDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + // TODO: 在此处为本机数据添加绘制代码 + DoubleBuffer(pDC); +} + + +// CMy3DTransView 打印 + + +void CMy3DTransView::OnFilePrintPreview() +{ +#ifndef SHARED_HANDLERS + AFXPrintPreview(this); +#endif +} + +BOOL CMy3DTransView::OnPreparePrinting(CPrintInfo* pInfo) +{ + // 默认准备 + return DoPreparePrinting(pInfo); +} + +void CMy3DTransView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加额外的打印前进行的初始化过程 +} + +void CMy3DTransView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加打印后进行的清理过程 +} + +void CMy3DTransView::OnRButtonUp(UINT /* nFlags */, CPoint point) +{ + ClientToScreen(&point); + OnContextMenu(this, point); +} + +void CMy3DTransView::OnContextMenu(CWnd* /* pWnd */, CPoint point) +{ +#ifndef SHARED_HANDLERS + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE); +#endif +} + + +// CMy3DTransView 诊断 + +#ifdef _DEBUG +void CMy3DTransView::AssertValid() const +{ + CView::AssertValid(); +} + +void CMy3DTransView::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +CMy3DTransDoc* CMy3DTransView::GetDocument() const // 非调试版本是内联的 +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMy3DTransDoc))); + return (CMy3DTransDoc*)m_pDocument; +} + +void CMy3DTransView::DrawObject(CDC* pDC)//正交投影 +{ + cube.Draw(pDC); +} +void CMy3DTransView::DoubleBuffer(CDC* pDC)//双缓冲绘图 +{ + CRect rect; + GetClientRect(&rect); + pDC->SetMapMode(MM_ANISOTROPIC); + pDC->SetWindowExt(rect.Width(), rect.Height()); + pDC->SetViewportExt(rect.Width(), -rect.Height()); + pDC->SetViewportOrg(rect.Width() / 2, rect.Height() / 2); + CDC memDC;//声明内存DC + memDC.CreateCompatibleDC(pDC);//创建一个与显示DC兼容的内存DC + CBitmap NewBitmap, * pOldBitmap; + NewBitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());//创建兼容内存位图 + pOldBitmap = memDC.SelectObject(&NewBitmap);//将兼容位图选入内存DC + memDC.FillSolidRect(rect, pDC->GetBkColor());//设置客户区背景色 + rect.OffsetRect(-rect.Width() / 2, -rect.Height() / 2); + memDC.SetMapMode(MM_ANISOTROPIC);//内存DC自定义坐标系 + memDC.SetWindowExt(rect.Width(), rect.Height()); + memDC.SetViewportExt(rect.Width(), -rect.Height()); + memDC.SetViewportOrg(rect.Width() / 2, rect.Height() / 2); + DrawObject(&memDC);//绘制图形 + pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memDC, -rect.Width() / 2, -rect.Height() / 2, SRCCOPY); //将内存DC中的位图拷贝到显示DC + memDC.SelectObject(pOldBitmap); + NewBitmap.DeleteObject(); + memDC.DeleteDC(); +} + +#endif //_DEBUG + + +// CMy3DTransView 消息处理程序 + + + +void CMy3DTransView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + // TODO: 在此添加消息处理程序代码和/或调用默认值 + switch (nChar) + { + case VK_UP: + Alpha = -5; + transform.RotateX(Alpha); + break; + case VK_DOWN: + Alpha = +5; + transform.RotateX(Alpha); + break; + case VK_LEFT: + Beta = -5; + transform.RotateY(Beta); + break; + case VK_RIGHT: + Beta = +5; + transform.RotateY(Beta); + break; + default: + break; + } + Invalidate(FALSE); + CView::OnKeyDown(nChar, nRepCnt, nFlags); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTransView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTransView.h" new file mode 100644 index 0000000..7c1f209 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/3DTransView.h" @@ -0,0 +1,61 @@ + +// 3DTransView.h: CMy3DTransView 类的接口 +// + +#pragma once +#include"CCube.h" +#include"CTrans3.h" + +class CMy3DTransView : public CView +{ +protected: // 仅从序列化创建 + CMy3DTransView() noexcept; + DECLARE_DYNCREATE(CMy3DTransView) + +// 特性 +public: + CMy3DTransDoc* GetDocument() const; + +// 操作 +public: + +// 重写 +public: + virtual void OnDraw(CDC* pDC); // 重写以绘制该视图 + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// 实现 +public: + virtual ~CMy3DTransView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + CCube cube; + CTrans3 transform; + void DrawObject(CDC* pDC); + void DoubleBuffer(CDC* pDC); + int Alpha; + int Beta; + +// 生成的消息映射函数 +protected: + afx_msg void OnFilePrintPreview(); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); +}; + +#ifndef _DEBUG // 3DTransView.cpp 中的调试版本 +inline CMy3DTransDoc* CMy3DTransView::GetDocument() const + { return reinterpret_cast(m_pDocument); } +#endif + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CCube.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CCube.cpp" new file mode 100644 index 0000000..aa8ddc5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CCube.cpp" @@ -0,0 +1,55 @@ +#include "pch.h" +#include "CCube.h" +#define ROUND(d) int(d + 0.5) +CCube::CCube(void) +{ +} +CCube::~CCube(void) +{ +} +CP3* CCube::GetVertexArrayName(void) +{ + return P; +} +void CCube::ReadPoint(void) +{ + P[0].x = 0, P[0].y = 0, P[0].z = 0; + P[1].x = 1, P[1].y = 0, P[1].z = 0; + P[2].x = 1, P[2].y = 1, P[2].z = 0; + P[3].x = 0, P[3].y = 1, P[3].z = 0; + P[4].x = 0, P[4].y = 0, P[4].z = 1; + P[5].x = 1, P[5].y = 0, P[5].z = 1; + P[6].x = 1, P[6].y = 1, P[6].z = 1; + P[7].x = 0, P[7].y = 1, P[7].z = 1; +} +void CCube::ReadFacet(void) +{ + F[0].Index[0] = 4; F[0].Index[1] = 5; F[0].Index[2] = 6; F[0].Index[3] = 7; + F[1].Index[0] = 0; F[1].Index[1] = 3; F[1].Index[2] = 2; F[1].Index[3] = 1; + F[2].Index[0] = 0; F[2].Index[1] = 4; F[2].Index[2] = 7; F[2].Index[3] = 3; + F[3].Index[0] = 1; F[3].Index[1] = 2; F[3].Index[2] = 6; F[3].Index[3] = 5; + F[4].Index[0] = 2; F[4].Index[1] = 3; F[4].Index[2] = 7; F[4].Index[3] = 6; + F[5].Index[0] = 0; F[5].Index[1] = 1; F[5].Index[2] = 5; F[5].Index[3] = 4; +} +void CCube::Draw(CDC* pDC) +{ + CP2 ScreenPoint, temp; + for (int nFacet = 0; nFacet < 6; nFacet++) + { + for (int nPoint = 0; nPoint < 4; nPoint++) + { + ScreenPoint.x = P[F[nFacet].Index[nPoint]].x; + ScreenPoint.y = P[F[nFacet].Index[nPoint]].y; + if (0 == nPoint) + { + pDC->MoveTo(ROUND(ScreenPoint.x), ROUND(ScreenPoint.y)); + temp = ScreenPoint; + } + else + { + pDC->LineTo(ROUND(ScreenPoint.x), ROUND(ScreenPoint.y)); + } + } + pDC->LineTo(ROUND(temp.x), ROUND(temp.y)); + } +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CCube.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CCube.h" new file mode 100644 index 0000000..8dc9d49 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CCube.h" @@ -0,0 +1,16 @@ +#pragma once +#include "CFacet.h" +#include "CP3.h" +class CCube +{ +public: + CCube(void); + virtual ~CCube(void); + void ReadPoint(void); + void ReadFacet(void); + CP3* GetVertexArrayName(void); + void Draw(CDC* pDC); + CP3 P[8]; + CFacet F[6]; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CFacet.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CFacet.cpp" new file mode 100644 index 0000000..07bad5c --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CFacet.cpp" @@ -0,0 +1,2 @@ +#include "pch.h" +#include "CFacet.h" diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CFacet.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CFacet.h" new file mode 100644 index 0000000..a3a97ae --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CFacet.h" @@ -0,0 +1,12 @@ +#pragma once +class CFacet +{ +public: + CFacet(void) {} + virtual ~CFacet(void) {} +public: + int Number; + int Index[4]; +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CP2.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CP2.cpp" new file mode 100644 index 0000000..a537eb7 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CP2.cpp" @@ -0,0 +1,74 @@ +#include "pch.h" +#include "CP2.h" +CP2::CP2(void) +{ + x = 0.0; + y = 0.0; + w = 1.0; +} +CP2::~CP2(void) +{ +} +CP2::CP2(double x, double y) +{ + this->x = x; + this->y = y; + this->w = 1.0; +} +CP2 operator + (const CP2& p0, const CP2& p1)// +{ + CP2 result; + result.x = p0.x + p1.x; + result.y = p0.y + p1.y; + return result; +} +CP2 operator - (const CP2& p0, const CP2& p1)// +{ + CP2 result; + result.x = p0.x - p1.x; + result.y = p0.y - p1.y; + return result; +} +CP2 operator * (const CP2& p, double scalar)//ͳĻ +{ + return CP2(p.x * scalar, p.y * scalar); +} +CP2 operator * (double scalar, const CP2& p)//ͳĻ +{ + return CP2(p.x * scalar, p.y * scalar); +} +CP2 operator / (const CP2& p, double scalar)// +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + CP2 result; + result.x = p.x / scalar; + result.y = p.y / scalar; + return result; +} +CP2 operator+=(CP2& p0, CP2& p1) +{ + p0.x += p1.x; + p0.y += p1.y; + return p0; +} +CP2 operator-=(CP2& p0, CP2& p1) +{ + p0.x -= p1.x; + p0.y -= p1.y; + return p0; +} +CP2 operator*=(CP2& p, double scalar) +{ + p.x *= scalar; + p.y *= scalar; + return p; +} +CP2 operator/=(CP2& p, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + p.x /= scalar; + p.y /= scalar; + return p; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CP2.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CP2.h" new file mode 100644 index 0000000..fc32cb4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CP2.h" @@ -0,0 +1,23 @@ +#pragma once +class CP2 +{ +public: + CP2(void); + virtual ~CP2(void); + CP2(double x, double y); + friend CP2 operator + (const CP2& p0, const CP2& p1);// + friend CP2 operator - (const CP2& p0, const CP2& p1); + friend CP2 operator * (const CP2& p, double scalar); + friend CP2 operator * (double scalar, const CP2& p); + friend CP2 operator / (const CP2& p, double scalar); + friend CP2 operator += (CP2& p0, CP2& p1); + friend CP2 operator -= (CP2& p0, CP2& p1); + friend CP2 operator *= (CP2& p, double scalar); + friend CP2 operator /= (CP2& p, double scalar); +public: + double x;//ֱ߶ζ˵x + double y;//ֱ߶ζ˵y + double w;// +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CP3.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CP3.cpp" new file mode 100644 index 0000000..a6fa48f --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CP3.cpp" @@ -0,0 +1,13 @@ +#include "pch.h" +#include "CP3.h" +CP3::CP3(void) +{ + x = 0, y = 0, z = 0, w = 1; +} +CP3::CP3(double x, double y, double z) :CP2(x, y) +{ + this->z = z; +} +CP3::~CP3(void) +{ +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CP3.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CP3.h" new file mode 100644 index 0000000..47bff82 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CP3.h" @@ -0,0 +1,12 @@ +#pragma once +#include "CP2.h" +class CP3 :public CP2 +{ +public: + CP3(void); + virtual ~CP3(void); + CP3(double x, double y, double z); +public: + double z; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CTrans3.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CTrans3.cpp" new file mode 100644 index 0000000..746c3fc --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CTrans3.cpp" @@ -0,0 +1,150 @@ +#include "pch.h" +#include "CTrans3.h" +#define PI 3.1415926 +void CTrans3::Identity(void) +{ + M[0][0] = 1.0; M[0][1] = 0.0; M[0][2] = 0.0; M[0][3] = 0.0; + M[1][0] = 0.0; M[1][1] = 1.0; M[1][2] = 0.0; M[1][3] = 0.0; + M[2][0] = 0.0; M[2][1] = 0.0; M[2][2] = 1.0; M[2][3] = 0.0; + M[3][0] = 0.0; M[3][1] = 0.0; M[3][2] = 0.0; M[3][3] = 1.0; +} +void CTrans3::SetMatrix(CP3* P, int ptNumber) +{ + this->P = P; + this->ptNumber = ptNumber; +} +void CTrans3::Translate(double tx, double ty, double tz) +{ + Identity(); + M[0][3] = tx; + M[1][3] = ty; + M[2][3] = tz; + MultiplyMatrix(); +} +void CTrans3::Scale(double sx, double sy, double sz) +{ + Identity(); + M[0][0] = sx; + M[1][1] = sy; + M[2][2] = sz; + MultiplyMatrix(); +} +void CTrans3::Scale(double sx, double sy, double sz, CP3 p) +{ + Translate(-p.x, -p.y, -p.z); + Scale(sx, sy, sz); + Translate(p.x, p.y, p.z); +} +void CTrans3::RotateX(double beta) +{ + Identity(); + double rad = beta * PI / 180; + M[1][1] = cos(rad); M[1][2] = -sin(rad); + M[2][1] = sin(rad); M[2][2] = cos(rad); + MultiplyMatrix(); +} +void CTrans3::RotateY(double beta) +{ + Identity(); + double rad = beta * PI / 180; + M[0][0] = cos(rad); M[0][2] = sin(rad); + M[2][0] = -sin(rad); M[2][2] = cos(rad); + MultiplyMatrix(); +} +void CTrans3::RotateZ(double beta) +{ + Identity(); + double rad = beta * PI / 180; + M[0][0] = cos(rad); M[0][1] = -sin(rad); + M[1][0] = sin(rad); M[1][1] = cos(rad); + MultiplyMatrix(); +} +void CTrans3::RotateX(double beta, CP3 p) +{ + Translate(-p.x, -p.y, -p.z); + RotateX(beta); + Translate(p.x, p.y, p.z); +} +void CTrans3::RotateY(double beta, CP3 p) +{ + Translate(-p.x, -p.y, -p.z); + RotateY(beta); + Translate(p.x, p.y, p.z); +} +void CTrans3::RotateZ(double beta, CP3 p) +{ + Translate(-p.x, -p.y, -p.z); + RotateZ(beta); + Translate(p.x, p.y, p.z); +} +void CTrans3::ReflectX(void) +{ + Identity(); + M[1][1] = -1; + M[2][2] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectY(void) +{ + Identity(); + M[0][0] = -1; + M[2][2] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectZ(void) +{ + Identity(); + M[0][0] = -1; + M[1][1] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectXOY(void) +{ + Identity(); + M[2][2] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectYOZ(void) +{ + Identity(); + M[0][0] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectZOX(void) +{ + Identity(); + M[1][1] = -1; + MultiplyMatrix(); +} +void CTrans3::ShearX(double b, double c) +{ + Identity(); + M[0][1] = b; M[0][2] = c; + MultiplyMatrix(); +} +void CTrans3::ShearY(double d, double f) +{ + Identity(); + M[1][0] = d; M[1][2] = f; + MultiplyMatrix(); +} +void CTrans3::ShearZ(double g, double h) +{ + Identity(); + M[2][0] = g; M[2][1] = h; + MultiplyMatrix(); +} +void CTrans3::MultiplyMatrix(void) +{ + CP3* PTemp = new CP3[ptNumber]; + for (int i = 0; i < ptNumber; i++) + PTemp[i] = P[i]; + for (int i = 0; i < ptNumber; i++) + { + P[i].x = M[0][0] * PTemp[i].x + M[0][1] * PTemp[i].y + M[0][2] * PTemp[i].z + M[0][3] * PTemp[i].w; + P[i].y = M[1][0] * PTemp[i].x + M[1][1] * PTemp[i].y + M[1][2] * PTemp[i].z + M[1][3] * PTemp[i].w; + P[i].z = M[2][0] * PTemp[i].x + M[2][1] * PTemp[i].y + M[2][2] * PTemp[i].z + M[2][3] * PTemp[i].w; + P[i].w = M[3][0] * PTemp[i].x + M[3][1] * PTemp[i].y + M[3][2] * PTemp[i].z + M[3][3] * PTemp[i].w; + } + delete[]PTemp; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CTrans3.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CTrans3.h" new file mode 100644 index 0000000..d6d24a2 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/CTrans3.h" @@ -0,0 +1,34 @@ +#pragma once +#include "CP3.h" +class CTrans3 +{ +public: + CTrans3(void) {}; + virtual ~CTrans3(void) {}; + void Identity(void); + void SetMatrix(CP3* P, int ptNumber); + void Translate(double tx, double ty, double tz); + void Scale(double sx, double sy, double sz); + void Scale(double sx, double sy, double sz, CP3 p); + void RotateX(double beta); + void RotateY(double beta); + void RotateZ(double beta); + void RotateX(double beta, CP3 p); + void RotateY(double beta, CP3 p); + void RotateZ(double beta, CP3 p); + void ReflectX(void); + void ReflectY(void); + void ReflectZ(void); + void ReflectXOY(void); + void ReflectYOZ(void); + void ReflectZOX(void); + void ShearX(double b, double c); + void ShearY(double d, double f); + void ShearZ(double g, double h); + void MultiplyMatrix(void); +private: + double M[4][4]; + CP3* P; + int ptNumber; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/ClassView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/ClassView.cpp" new file mode 100644 index 0000000..835d672 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/ClassView.cpp" @@ -0,0 +1,323 @@ + +#include "pch.h" +#include "framework.h" +#include "MainFrm.h" +#include "ClassView.h" +#include "Resource.h" +#include "3DTrans.h" + +class CClassViewMenuButton : public CMFCToolBarMenuButton +{ + friend class CClassView; + + DECLARE_SERIAL(CClassViewMenuButton) + +public: + CClassViewMenuButton(HMENU hMenu = nullptr) noexcept : CMFCToolBarMenuButton((UINT)-1, hMenu, -1) + { + } + + virtual void OnDraw(CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz = TRUE, + BOOL bCustomizeMode = FALSE, BOOL bHighlight = FALSE, BOOL bDrawBorder = TRUE, BOOL bGrayDisabledButtons = TRUE) + { + pImages = CMFCToolBar::GetImages(); + + CAfxDrawState ds; + pImages->PrepareDrawImage(ds); + + CMFCToolBarMenuButton::OnDraw(pDC, rect, pImages, bHorz, bCustomizeMode, bHighlight, bDrawBorder, bGrayDisabledButtons); + + pImages->EndDrawImage(ds); + } +}; + +IMPLEMENT_SERIAL(CClassViewMenuButton, CMFCToolBarMenuButton, 1) + +////////////////////////////////////////////////////////////////////// +// 构造/析构 +////////////////////////////////////////////////////////////////////// + +CClassView::CClassView() noexcept +{ + m_nCurrSort = ID_SORTING_GROUPBYTYPE; +} + +CClassView::~CClassView() +{ +} + +BEGIN_MESSAGE_MAP(CClassView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_CLASS_ADD_MEMBER_FUNCTION, OnClassAddMemberFunction) + ON_COMMAND(ID_CLASS_ADD_MEMBER_VARIABLE, OnClassAddMemberVariable) + ON_COMMAND(ID_CLASS_DEFINITION, OnClassDefinition) + ON_COMMAND(ID_CLASS_PROPERTIES, OnClassProperties) + ON_COMMAND(ID_NEW_FOLDER, OnNewFolder) + ON_WM_PAINT() + ON_WM_SETFOCUS() + ON_COMMAND_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnSort) + ON_UPDATE_COMMAND_UI_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnUpdateSort) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClassView 消息处理程序 + +int CClassView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndClassView.Create(dwViewStyle, rectDummy, this, 2)) + { + TRACE0("未能创建类视图\n"); + return -1; // 未能创建 + } + + // 加载图像: + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_SORT); + m_wndToolBar.LoadToolBar(IDR_SORT, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + CMenu menuSort; + menuSort.LoadMenu(IDR_POPUP_SORT); + + m_wndToolBar.ReplaceButton(ID_SORT_MENU, CClassViewMenuButton(menuSort.GetSubMenu(0)->GetSafeHmenu())); + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->m_bText = FALSE; + pButton->m_bImage = TRUE; + pButton->SetImage(GetCmdMgr()->GetCmdImage(m_nCurrSort)); + pButton->SetMessageWnd(this); + } + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillClassView(); + + return 0; +} + +void CClassView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CClassView::FillClassView() +{ + HTREEITEM hRoot = m_wndClassView.InsertItem(_T("FakeApp 类"), 0, 0); + m_wndClassView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hClass = m_wndClassView.InsertItem(_T("CFakeAboutDlg"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAboutDlg()"), 3, 3, hClass); + + m_wndClassView.Expand(hRoot, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeApp"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeApp()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("InitInstance()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnAppAbout()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppDoc"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppDoc()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppDoc()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnNewDocument()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppView"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppView()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppView()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("GetDocument()"), 3, 3, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppFrame"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("m_wndMenuBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndToolBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndStatusBar"), 6, 6, hClass); + + hClass = m_wndClassView.InsertItem(_T("Globals"), 2, 2, hRoot); + m_wndClassView.InsertItem(_T("theFakeApp"), 5, 5, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); +} + +void CClassView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndClassView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + CMenu menu; + menu.LoadMenu(IDR_POPUP_SORT); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } +} + +void CClassView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndClassView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +BOOL CClassView::PreTranslateMessage(MSG* pMsg) +{ + return CDockablePane::PreTranslateMessage(pMsg); +} + +void CClassView::OnSort(UINT id) +{ + if (m_nCurrSort == id) + { + return; + } + + m_nCurrSort = id; + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->SetImage(GetCmdMgr()->GetCmdImage(id)); + m_wndToolBar.Invalidate(); + m_wndToolBar.UpdateWindow(); + } +} + +void CClassView::OnUpdateSort(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(pCmdUI->m_nID == m_nCurrSort); +} + +void CClassView::OnClassAddMemberFunction() +{ + AfxMessageBox(_T("添加成员函数...")); +} + +void CClassView::OnClassAddMemberVariable() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassDefinition() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassProperties() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnNewFolder() +{ + AfxMessageBox(_T("新建文件夹...")); +} + +void CClassView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndClassView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CClassView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndClassView.SetFocus(); +} + +void CClassView::OnChangeVisualStyle() +{ + m_ClassViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_CLASS_VIEW_24 : IDB_CLASS_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_ClassViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_ClassViewImages.Add(&bmp, RGB(255, 0, 0)); + + m_wndClassView.SetImageList(&m_ClassViewImages, TVSIL_NORMAL); + + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_SORT_24 : IDR_SORT, 0, 0, TRUE /* 锁定*/); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/ClassView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/ClassView.h" new file mode 100644 index 0000000..786c278 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/ClassView.h" @@ -0,0 +1,54 @@ + +#pragma once + +#include "ViewTree.h" + +class CClassToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CClassView : public CDockablePane +{ +public: + CClassView() noexcept; + virtual ~CClassView(); + + void AdjustLayout(); + void OnChangeVisualStyle(); + +protected: + CClassToolBar m_wndToolBar; + CViewTree m_wndClassView; + CImageList m_ClassViewImages; + UINT m_nCurrSort; + + void FillClassView(); + +// 重写 +public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnClassAddMemberFunction(); + afx_msg void OnClassAddMemberVariable(); + afx_msg void OnClassDefinition(); + afx_msg void OnClassProperties(); + afx_msg void OnNewFolder(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg LRESULT OnChangeActiveTab(WPARAM, LPARAM); + afx_msg void OnSort(UINT id); + afx_msg void OnUpdateSort(CCmdUI* pCmdUI); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/FileView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/FileView.cpp" new file mode 100644 index 0000000..b7382c8 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/FileView.cpp" @@ -0,0 +1,257 @@ + +#include "pch.h" +#include "framework.h" +#include "mainfrm.h" +#include "FileView.h" +#include "Resource.h" +#include "3DTrans.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CFileView + +CFileView::CFileView() noexcept +{ +} + +CFileView::~CFileView() +{ +} + +BEGIN_MESSAGE_MAP(CFileView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_PROPERTIES, OnProperties) + ON_COMMAND(ID_OPEN, OnFileOpen) + ON_COMMAND(ID_OPEN_WITH, OnFileOpenWith) + ON_COMMAND(ID_DUMMY_COMPILE, OnDummyCompile) + ON_COMMAND(ID_EDIT_CUT, OnEditCut) + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_WM_PAINT() + ON_WM_SETFOCUS() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CWorkspaceBar 消息处理程序 + +int CFileView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; + + if (!m_wndFileView.Create(dwViewStyle, rectDummy, this, 4)) + { + TRACE0("未能创建文件视图\n"); + return -1; // 未能创建 + } + + // 加载视图图像: + m_FileViewImages.Create(IDB_FILE_VIEW, 16, 0, RGB(255, 0, 255)); + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_EXPLORER); + m_wndToolBar.LoadToolBar(IDR_EXPLORER, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillFileView(); + AdjustLayout(); + + return 0; +} + +void CFileView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CFileView::FillFileView() +{ + HTREEITEM hRoot = m_wndFileView.InsertItem(_T("FakeApp 文件"), 0, 0); + m_wndFileView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hSrc = m_wndFileView.InsertItem(_T("FakeApp 源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeApp.rc"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppDoc.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppView.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("MainFrm.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("pch.cpp"), 1, 1, hSrc); + + HTREEITEM hInc = m_wndFileView.InsertItem(_T("FakeApp 头文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppDoc.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppView.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("Resource.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("MainFrm.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("pch.h"), 2, 2, hInc); + + HTREEITEM hRes = m_wndFileView.InsertItem(_T("FakeApp 资源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeApp.rc2"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeAppDoc.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeToolbar.bmp"), 2, 2, hRes); + + m_wndFileView.Expand(hRoot, TVE_EXPAND); + m_wndFileView.Expand(hSrc, TVE_EXPAND); + m_wndFileView.Expand(hInc, TVE_EXPAND); +} + +void CFileView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE); +} + +void CFileView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndFileView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +void CFileView::OnProperties() +{ + AfxMessageBox(_T("属性....")); + +} + +void CFileView::OnFileOpen() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnFileOpenWith() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnDummyCompile() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCut() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCopy() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditClear() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndFileView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CFileView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndFileView.SetFocus(); +} + +void CFileView::OnChangeVisualStyle() +{ + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_EXPLORER_24 : IDR_EXPLORER, 0, 0, TRUE /* 锁定*/); + + m_FileViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_FILE_VIEW_24 : IDB_FILE_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_FileViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_FileViewImages.Add(&bmp, RGB(255, 0, 255)); + + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); +} + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/FileView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/FileView.h" new file mode 100644 index 0000000..e39a7c9 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/FileView.h" @@ -0,0 +1,55 @@ + +#pragma once + +#include "ViewTree.h" + +class CFileViewToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CFileView : public CDockablePane +{ +// 构造 +public: + CFileView() noexcept; + + void AdjustLayout(); + void OnChangeVisualStyle(); + +// 特性 +protected: + + CViewTree m_wndFileView; + CImageList m_FileViewImages; + CFileViewToolBar m_wndToolBar; + +protected: + void FillFileView(); + +// 实现 +public: + virtual ~CFileView(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnProperties(); + afx_msg void OnFileOpen(); + afx_msg void OnFileOpenWith(); + afx_msg void OnDummyCompile(); + afx_msg void OnEditCut(); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/MainFrm.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/MainFrm.cpp" new file mode 100644 index 0000000..740ad74 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/MainFrm.cpp" @@ -0,0 +1,408 @@ + +// MainFrm.cpp: CMainFrame 类的实现 +// + +#include "pch.h" +#include "framework.h" +#include "3DTrans.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) + +const int iMaxUserToolbars = 10; +const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; +const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) + ON_WM_CREATE() + ON_COMMAND(ID_VIEW_CUSTOMIZE, &CMainFrame::OnViewCustomize) + ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, &CMainFrame::OnToolbarCreateNew) + ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook) + ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook) + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // 状态行指示器 + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +// CMainFrame 构造/析构 + +CMainFrame::CMainFrame() noexcept +{ + // TODO: 在此添加成员初始化代码 + theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2008); +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) + return -1; + + BOOL bNameValid; + + if (!m_wndMenuBar.Create(this)) + { + TRACE0("未能创建菜单栏\n"); + return -1; // 未能创建 + } + + m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); + + // 防止菜单栏在激活时获得焦点 + CMFCPopupMenu::SetForceMenuFocus(FALSE); + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) + { + TRACE0("未能创建工具栏\n"); + return -1; // 未能创建 + } + + CString strToolBarName; + bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); + ASSERT(bNameValid); + m_wndToolBar.SetWindowText(strToolBarName); + + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + + // 允许用户定义的工具栏操作: + InitUserToolbars(nullptr, uiFirstUserToolBarId, uiLastUserToolBarId); + + if (!m_wndStatusBar.Create(this)) + { + TRACE0("未能创建状态栏\n"); + return -1; // 未能创建 + } + m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); + + // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行 + m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndMenuBar); + DockPane(&m_wndToolBar); + + + // 启用 Visual Studio 2005 样式停靠窗口行为 + CDockingManager::SetDockingMode(DT_SMART); + // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 + EnableAutoHidePanes(CBRS_ALIGN_ANY); + + // 加载菜单项图像(不在任何标准工具栏上): + CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); + + // 创建停靠窗口 + if (!CreateDockingWindows()) + { + TRACE0("未能创建停靠窗口\n"); + return -1; + } + + m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); + m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndFileView); + CDockablePane* pTabbedBar = nullptr; + m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); + m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndOutput); + m_wndProperties.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndProperties); + + // 基于持久值设置视觉管理器和样式 + OnApplicationLook(theApp.m_nAppLook); + + // 启用工具栏和停靠窗口菜单替换 + EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); + + // 启用快速(按住 Alt 拖动)工具栏自定义 + CMFCToolBar::EnableQuickCustomization(); + + if (CMFCToolBar::GetUserImages() == nullptr) + { + // 加载用户定义的工具栏图像 + if (m_UserImages.Load(_T(".\\UserImages.bmp"))) + { + CMFCToolBar::SetUserImages(&m_UserImages); + } + } + + // 启用菜单个性化(最近使用的命令) + // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 + CList lstBasicCommands; + + lstBasicCommands.AddTail(ID_FILE_NEW); + lstBasicCommands.AddTail(ID_FILE_OPEN); + lstBasicCommands.AddTail(ID_FILE_SAVE); + lstBasicCommands.AddTail(ID_FILE_PRINT); + lstBasicCommands.AddTail(ID_APP_EXIT); + lstBasicCommands.AddTail(ID_EDIT_CUT); + lstBasicCommands.AddTail(ID_EDIT_PASTE); + lstBasicCommands.AddTail(ID_EDIT_UNDO); + lstBasicCommands.AddTail(ID_APP_ABOUT); + lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); + lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7); + lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); + lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); + lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); + lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); + + CMFCToolBar::SetBasicCommands(lstBasicCommands); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWndEx::PreCreateWindow(cs) ) + return FALSE; + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return TRUE; +} + +BOOL CMainFrame::CreateDockingWindows() +{ + BOOL bNameValid; + + // 创建类视图 + CString strClassView; + bNameValid = strClassView.LoadString(IDS_CLASS_VIEW); + ASSERT(bNameValid); + if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“类视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建文件视图 + CString strFileView; + bNameValid = strFileView.LoadString(IDS_FILE_VIEW); + ASSERT(bNameValid); + if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“文件视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建输出窗口 + CString strOutputWnd; + bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND); + ASSERT(bNameValid); + if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建输出窗口\n"); + return FALSE; // 未能创建 + } + + // 创建属性窗口 + CString strPropertiesWnd; + bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND); + ASSERT(bNameValid); + if (!m_wndProperties.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“属性”窗口\n"); + return FALSE; // 未能创建 + } + + SetDockingWindowIcons(theApp.m_bHiColorIcons); + return TRUE; +} + +void CMainFrame::SetDockingWindowIcons(BOOL bHiColorIcons) +{ + HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_FILE_VIEW_HC : IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndFileView.SetIcon(hFileViewIcon, FALSE); + + HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_CLASS_VIEW_HC : IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndClassView.SetIcon(hClassViewIcon, FALSE); + + HICON hOutputBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_OUTPUT_WND_HC : IDI_OUTPUT_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndOutput.SetIcon(hOutputBarIcon, FALSE); + + HICON hPropertiesBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_PROPERTIES_WND_HC : IDI_PROPERTIES_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndProperties.SetIcon(hPropertiesBarIcon, FALSE); + +} + +// CMainFrame 诊断 + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWndEx::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWndEx::Dump(dc); +} +#endif //_DEBUG + + +// CMainFrame 消息处理程序 + +void CMainFrame::OnViewCustomize() +{ + CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* 扫描菜单*/); + pDlgCust->EnableUserDefinedToolbars(); + pDlgCust->Create(); +} + +LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) +{ + LRESULT lres = CFrameWndEx::OnToolbarCreateNew(wp,lp); + if (lres == 0) + { + return 0; + } + + CMFCToolBar* pUserToolbar = (CMFCToolBar*)lres; + ASSERT_VALID(pUserToolbar); + + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + return lres; +} + +void CMainFrame::OnApplicationLook(UINT id) +{ + CWaitCursor wait; + + theApp.m_nAppLook = id; + + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_WIN_2000: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); + break; + + case ID_VIEW_APPLOOK_OFF_XP: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); + break; + + case ID_VIEW_APPLOOK_WIN_XP: + CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + break; + + case ID_VIEW_APPLOOK_OFF_2003: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2005: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2008: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_WINDOWS_7: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + default: + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_OFF_2007_BLUE: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); + break; + + case ID_VIEW_APPLOOK_OFF_2007_BLACK: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); + break; + + case ID_VIEW_APPLOOK_OFF_2007_SILVER: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); + break; + + case ID_VIEW_APPLOOK_OFF_2007_AQUA: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); + break; + } + + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); + CDockingManager::SetDockingMode(DT_SMART); + } + + m_wndOutput.UpdateFonts(); + RedrawWindow(nullptr, nullptr, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); + + theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); +} + +void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI) +{ + pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID); +} + + +BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) +{ + // 基类将执行真正的工作 + + if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) + { + return FALSE; + } + + + // 为所有用户工具栏启用自定义按钮 + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + for (int i = 0; i < iMaxUserToolbars; i ++) + { + CMFCToolBar* pUserToolbar = GetUserToolBarByIndex(i); + if (pUserToolbar != nullptr) + { + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + } + } + + return TRUE; +} + + +void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CFrameWndEx::OnSettingChange(uFlags, lpszSection); + m_wndOutput.UpdateFonts(); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/MainFrm.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/MainFrm.h" new file mode 100644 index 0000000..02feb8e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/MainFrm.h" @@ -0,0 +1,61 @@ + +// MainFrm.h: CMainFrame 类的接口 +// + +#pragma once +#include "FileView.h" +#include "ClassView.h" +#include "OutputWnd.h" +#include "PropertiesWnd.h" + +class CMainFrame : public CFrameWndEx +{ + +protected: // 仅从序列化创建 + CMainFrame() noexcept; + DECLARE_DYNCREATE(CMainFrame) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = nullptr, CCreateContext* pContext = nullptr); + +// 实现 +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // 控件条嵌入成员 + CMFCMenuBar m_wndMenuBar; + CMFCToolBar m_wndToolBar; + CMFCStatusBar m_wndStatusBar; + CMFCToolBarImages m_UserImages; + CFileView m_wndFileView; + CClassView m_wndClassView; + COutputWnd m_wndOutput; + CPropertiesWnd m_wndProperties; + +// 生成的消息映射函数 +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnViewCustomize(); + afx_msg LRESULT OnToolbarCreateNew(WPARAM wp, LPARAM lp); + afx_msg void OnApplicationLook(UINT id); + afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + DECLARE_MESSAGE_MAP() + + BOOL CreateDockingWindows(); + void SetDockingWindowIcons(BOOL bHiColorIcons); +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/My3DTrans.aps" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/My3DTrans.aps" new file mode 100644 index 0000000..d068387 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/My3DTrans.aps" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/My3DTrans.rc" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/My3DTrans.rc" new file mode 100644 index 0000000..2b47c4f Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/My3DTrans.rc" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/OutputWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/OutputWnd.cpp" new file mode 100644 index 0000000..e3f4901 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/OutputWnd.cpp" @@ -0,0 +1,200 @@ + +#include "pch.h" +#include "framework.h" + +#include "OutputWnd.h" +#include "Resource.h" +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// COutputBar + +COutputWnd::COutputWnd() noexcept +{ +} + +COutputWnd::~COutputWnd() +{ +} + +BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() +END_MESSAGE_MAP() + +int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建选项卡窗口: + if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1)) + { + TRACE0("未能创建输出选项卡窗口\n"); + return -1; // 未能创建 + } + + // 创建输出窗格: + const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; + + if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) || + !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) || + !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4)) + { + TRACE0("未能创建输出窗口\n"); + return -1; // 未能创建 + } + + UpdateFonts(); + + CString strTabName; + BOOL bNameValid; + + // 将列表窗口附加到选项卡: + bNameValid = strTabName.LoadString(IDS_BUILD_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0); + bNameValid = strTabName.LoadString(IDS_DEBUG_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1); + bNameValid = strTabName.LoadString(IDS_FIND_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2); + + // 使用一些虚拟文本填写输出选项卡(无需复杂数据) + FillBuildWindow(); + FillDebugWindow(); + FillFindWindow(); + + return 0; +} + +void COutputWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + + // 选项卡控件应覆盖整个工作区: + m_wndTabs.SetWindowPos (nullptr, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); +} + +void COutputWnd::AdjustHorzScroll(CListBox& wndListBox) +{ + CClientDC dc(this); + CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular); + + int cxExtentMax = 0; + + for (int i = 0; i < wndListBox.GetCount(); i ++) + { + CString strItem; + wndListBox.GetText(i, strItem); + + cxExtentMax = max(cxExtentMax, (int)dc.GetTextExtent(strItem).cx); + } + + wndListBox.SetHorizontalExtent(cxExtentMax); + dc.SelectObject(pOldFont); +} + +void COutputWnd::FillBuildWindow() +{ + m_wndOutputBuild.AddString(_T("生成输出正显示在此处。")); + m_wndOutputBuild.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputBuild.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillDebugWindow() +{ + m_wndOutputDebug.AddString(_T("调试输出正显示在此处。")); + m_wndOutputDebug.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputDebug.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillFindWindow() +{ + m_wndOutputFind.AddString(_T("查找输出正显示在此处。")); + m_wndOutputFind.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputFind.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::UpdateFonts() +{ + m_wndOutputBuild.SetFont(&afxGlobalData.fontRegular); + m_wndOutputDebug.SetFont(&afxGlobalData.fontRegular); + m_wndOutputFind.SetFont(&afxGlobalData.fontRegular); +} + +///////////////////////////////////////////////////////////////////////////// +// COutputList1 + +COutputList::COutputList() noexcept +{ +} + +COutputList::~COutputList() +{ +} + +BEGIN_MESSAGE_MAP(COutputList, CListBox) + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput) + ON_WM_WINDOWPOSCHANGING() +END_MESSAGE_MAP() +///////////////////////////////////////////////////////////////////////////// +// COutputList 消息处理程序 + +void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) +{ + CMenu menu; + menu.LoadMenu(IDR_OUTPUT_POPUP); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } + + SetFocus(); +} + +void COutputList::OnEditCopy() +{ + MessageBox(_T("复制输出")); +} + +void COutputList::OnEditClear() +{ + MessageBox(_T("清除输出")); +} + +void COutputList::OnViewOutput() +{ + CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner()); + CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame()); + + if (pMainFrame != nullptr && pParentBar != nullptr) + { + pMainFrame->SetFocus(); + pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE); + pMainFrame->RecalcLayout(); + + } +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/OutputWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/OutputWnd.h" new file mode 100644 index 0000000..4d773c3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/OutputWnd.h" @@ -0,0 +1,59 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// COutputList 窗口 + +class COutputList : public CListBox +{ +// 构造 +public: + COutputList() noexcept; + +// 实现 +public: + virtual ~COutputList(); + +protected: + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnViewOutput(); + + DECLARE_MESSAGE_MAP() +}; + +class COutputWnd : public CDockablePane +{ +// 构造 +public: + COutputWnd() noexcept; + + void UpdateFonts(); + +// 特性 +protected: + CMFCTabCtrl m_wndTabs; + + COutputList m_wndOutputBuild; + COutputList m_wndOutputDebug; + COutputList m_wndOutputFind; + +protected: + void FillBuildWindow(); + void FillDebugWindow(); + void FillFindWindow(); + + void AdjustHorzScroll(CListBox& wndListBox); + +// 实现 +public: + virtual ~COutputWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/PropertiesWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/PropertiesWnd.cpp" new file mode 100644 index 0000000..8d8bc08 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/PropertiesWnd.cpp" @@ -0,0 +1,273 @@ + +#include "pch.h" +#include "framework.h" + +#include "PropertiesWnd.h" +#include "Resource.h" +#include "MainFrm.h" +#include "3DTrans.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar + +CPropertiesWnd::CPropertiesWnd() noexcept +{ + m_nComboHeight = 0; +} + +CPropertiesWnd::~CPropertiesWnd() +{ +} + +BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties) + ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties) + ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties) + ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties) + ON_COMMAND(ID_PROPERTIES1, OnProperties1) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1) + ON_COMMAND(ID_PROPERTIES2, OnProperties2) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2) + ON_WM_SETFOCUS() + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar 消息处理程序 + +void CPropertiesWnd::AdjustLayout() +{ + if (GetSafeHwnd () == nullptr || (AfxGetMainWnd() != nullptr && AfxGetMainWnd()->IsIconic())) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndObjectCombo.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndPropList.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight + cyTlb, rectClient.Width(), rectClient.Height() -(m_nComboHeight+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER); +} + +int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建组合: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1)) + { + TRACE0("未能创建属性组合 \n"); + return -1; // 未能创建 + } + + m_wndObjectCombo.AddString(_T("应用程序")); + m_wndObjectCombo.AddString(_T("属性窗口")); + m_wndObjectCombo.SetCurSel(0); + + CRect rectCombo; + m_wndObjectCombo.GetClientRect (&rectCombo); + + m_nComboHeight = rectCombo.Height(); + + if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2)) + { + TRACE0("未能创建属性网格\n"); + return -1; // 未能创建 + } + + InitPropList(); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES); + m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* 已锁定*/); + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* 锁定*/); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + AdjustLayout(); + return 0; +} + +void CPropertiesWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CPropertiesWnd::OnExpandAllProperties() +{ + m_wndPropList.ExpandAll(); +} + +void CPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* /* pCmdUI */) +{ +} + +void CPropertiesWnd::OnSortProperties() +{ + m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnProperties1() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::OnProperties2() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::InitPropList() +{ + SetPropListFont(); + + m_wndPropList.EnableHeaderCtrl(FALSE); + m_wndPropList.EnableDescriptionArea(); + m_wndPropList.SetVSDotNetLook(); + m_wndPropList.MarkModifiedProperties(); + + CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("外观")); + + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("三维外观"), (_variant_t) false, _T("指定窗口的字体不使用粗体,并且控件将使用三维边框"))); + + CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("边框"), _T("对话框外框"), _T("其中之一: “无”、“细”、“可调整大小”或“对话框外框”")); + pProp->AddOption(_T("无")); + pProp->AddOption(_T("细")); + pProp->AddOption(_T("可调整大小")); + pProp->AddOption(_T("对话框外框")); + pProp->AllowEdit(FALSE); + + pGroup1->AddSubItem(pProp); + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("标题"), (_variant_t) _T("关于"), _T("指定窗口标题栏中显示的文本"))); + + m_wndPropList.AddProperty(pGroup1); + + CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("窗口大小"), 0, TRUE); + + pProp = new CMFCPropertyGridProperty(_T("高度"), (_variant_t) 250l, _T("指定窗口的高度")); + pProp->EnableSpinControl(TRUE, 50, 300); + pSize->AddSubItem(pProp); + + pProp = new CMFCPropertyGridProperty( _T("宽度"), (_variant_t) 150l, _T("指定窗口的宽度")); + pProp->EnableSpinControl(TRUE, 50, 200); + pSize->AddSubItem(pProp); + + m_wndPropList.AddProperty(pSize); + + CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("字体")); + + LOGFONT lf; + CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + font->GetLogFont(&lf); + + _tcscpy_s(lf.lfFaceName, _T("宋体, Arial")); + + pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("字体"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("指定窗口的默认字体"))); + pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("使用系统字体"), (_variant_t) true, _T("指定窗口使用“MS Shell Dlg”字体"))); + + m_wndPropList.AddProperty(pGroup2); + + CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("杂项")); + pProp = new CMFCPropertyGridProperty(_T("(名称)"), _T("应用程序")); + pProp->Enable(FALSE); + pGroup3->AddSubItem(pProp); + + CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("窗口颜色"), RGB(210, 192, 254), nullptr, _T("指定默认的窗口颜色")); + pColorProp->EnableOtherButton(_T("其他...")); + pColorProp->EnableAutomaticButton(_T("默认"), ::GetSysColor(COLOR_3DFACE)); + pGroup3->AddSubItem(pColorProp); + + static const TCHAR szFilter[] = _T("图标文件(*.ico)|*.ico|所有文件(*.*)|*.*||"); + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("图标"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("指定窗口图标"))); + + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("文件夹"), _T("c:\\"))); + + m_wndPropList.AddProperty(pGroup3); + + CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("层次结构")); + + CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("第一个子级")); + pGroup4->AddSubItem(pGroup41); + + CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("第二个子级")); + pGroup41->AddSubItem(pGroup411); + + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 1"), (_variant_t) _T("值 1"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 2"), (_variant_t) _T("值 2"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 3"), (_variant_t) _T("值 3"), _T("此为说明"))); + + pGroup4->Expand(FALSE); + m_wndPropList.AddProperty(pGroup4); +} + +void CPropertiesWnd::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + m_wndPropList.SetFocus(); +} + +void CPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CDockablePane::OnSettingChange(uFlags, lpszSection); + SetPropListFont(); +} + +void CPropertiesWnd::SetPropListFont() +{ + ::DeleteObject(m_fntPropList.Detach()); + + LOGFONT lf; + afxGlobalData.fontRegular.GetLogFont(&lf); + + NONCLIENTMETRICS info; + info.cbSize = sizeof(info); + + afxGlobalData.GetNonClientMetrics(info); + + lf.lfHeight = info.lfMenuFont.lfHeight; + lf.lfWeight = info.lfMenuFont.lfWeight; + lf.lfItalic = info.lfMenuFont.lfItalic; + + m_fntPropList.CreateFontIndirect(&lf); + + m_wndPropList.SetFont(&m_fntPropList); + m_wndObjectCombo.SetFont(&m_fntPropList); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/PropertiesWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/PropertiesWnd.h" new file mode 100644 index 0000000..e056430 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/PropertiesWnd.h" @@ -0,0 +1,62 @@ + +#pragma once + +class CPropertiesToolBar : public CMFCToolBar +{ +public: + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CPropertiesWnd : public CDockablePane +{ +// 构造 +public: + CPropertiesWnd() noexcept; + + void AdjustLayout(); + +// 特性 +public: + void SetVSDotNetLook(BOOL bSet) + { + m_wndPropList.SetVSDotNetLook(bSet); + m_wndPropList.SetGroupNameFullWidth(bSet); + } + +protected: + CFont m_fntPropList; + CComboBox m_wndObjectCombo; + CPropertiesToolBar m_wndToolBar; + CMFCPropertyGridCtrl m_wndPropList; + +// 实现 +public: + virtual ~CPropertiesWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnExpandAllProperties(); + afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI); + afx_msg void OnSortProperties(); + afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI); + afx_msg void OnProperties1(); + afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI); + afx_msg void OnProperties2(); + afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + + DECLARE_MESSAGE_MAP() + + void InitPropList(); + void SetPropListFont(); + + int m_nComboHeight; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/Resource.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/Resource.h" new file mode 100644 index 0000000..3b0061c --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/Resource.h" @@ -0,0 +1,97 @@ +//{{NO_DEPENDENCIES}} +// 生成的 Microsoft Visual C++ 包含文件。 +// 由 My3DTrans.rc 使用 +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_POPUP_EDIT 119 +#define ID_STATUSBAR_PANE1 120 +#define ID_STATUSBAR_PANE2 121 +#define IDS_STATUS_PANE1 122 +#define IDS_STATUS_PANE2 123 +#define IDS_TOOLBAR_STANDARD 124 +#define IDS_TOOLBAR_CUSTOMIZE 125 +#define ID_VIEW_CUSTOMIZE 126 +#define IDR_MAINFRAME 128 +#define IDR_MAINFRAME_256 129 +#define IDR_My3DTransTYPE 130 +#define ID_WINDOW_MANAGER 131 +#define ID_VIEW_FILEVIEW 133 +#define ID_VIEW_CLASSVIEW 134 +#define ID_PROPERTIES 135 +#define ID_OPEN 136 +#define ID_OPEN_WITH 137 +#define ID_DUMMY_COMPILE 138 +#define ID_CLASS_ADD_MEMBER_FUNCTION 139 +#define ID_CLASS_ADD_MEMBER_VARIABLE 140 +#define ID_CLASS_DEFINITION 141 +#define ID_CLASS_PROPERTIES 142 +#define ID_NEW_FOLDER 143 +#define ID_SORT_MENU 144 +#define ID_SORTING_GROUPBYTYPE 145 +#define ID_SORTING_SORTALPHABETIC 146 +#define ID_SORTING_SORTBYTYPE 147 +#define ID_SORTING_SORTBYACCESS 148 +#define ID_VIEW_OUTPUTWND 149 +#define ID_VIEW_PROPERTIESWND 150 +#define ID_SORTPROPERTIES 151 +#define ID_PROPERTIES1 152 +#define ID_PROPERTIES2 153 +#define ID_EXPAND_ALL 154 +#define IDS_FILE_VIEW 155 +#define IDS_CLASS_VIEW 156 +#define IDS_OUTPUT_WND 157 +#define IDS_PROPERTIES_WND 158 +#define IDI_FILE_VIEW 161 +#define IDI_FILE_VIEW_HC 162 +#define IDI_CLASS_VIEW 163 +#define IDI_CLASS_VIEW_HC 164 +#define IDI_OUTPUT_WND 165 +#define IDI_OUTPUT_WND_HC 166 +#define IDI_PROPERTIES_WND 167 +#define IDI_PROPERTIES_WND_HC 168 +#define IDR_EXPLORER 169 +#define IDB_EXPLORER_24 170 +#define IDR_SORT 171 +#define IDB_SORT_24 172 +#define IDR_POPUP_SORT 173 +#define IDR_POPUP_EXPLORER 174 +#define IDB_FILE_VIEW 175 +#define IDB_FILE_VIEW_24 176 +#define IDB_CLASS_VIEW 177 +#define IDB_CLASS_VIEW_24 178 +#define IDR_MENU_IMAGES 179 +#define IDB_MENU_IMAGES_24 180 +#define ID_TOOLS_MACRO 181 +#define IDR_OUTPUT_POPUP 182 +#define IDR_PROPERTIES 183 +#define IDB_PROPERTIES_HC 184 +#define IDR_THEME_MENU 200 +#define ID_SET_STYLE 201 +#define ID_VIEW_APPLOOK_WIN_2000 205 +#define ID_VIEW_APPLOOK_OFF_XP 206 +#define ID_VIEW_APPLOOK_WIN_XP 207 +#define ID_VIEW_APPLOOK_OFF_2003 208 +#define ID_VIEW_APPLOOK_VS_2005 209 +#define ID_VIEW_APPLOOK_VS_2008 210 +#define ID_VIEW_APPLOOK_OFF_2007_BLUE 215 +#define ID_VIEW_APPLOOK_OFF_2007_BLACK 216 +#define ID_VIEW_APPLOOK_OFF_2007_SILVER 217 +#define ID_VIEW_APPLOOK_OFF_2007_AQUA 218 +#define ID_VIEW_APPLOOK_WINDOWS_7 219 +#define IDS_BUILD_TAB 300 +#define IDS_DEBUG_TAB 301 +#define IDS_FIND_TAB 302 +#define IDS_EXPLORER 305 +#define IDS_EDIT_MENU 306 + +// 新对象的下一组默认值 +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 310 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 310 +#define _APS_NEXT_COMMAND_VALUE 32771 +#endif +#endif diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/ViewTree.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/ViewTree.cpp" new file mode 100644 index 0000000..84996cb --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/ViewTree.cpp" @@ -0,0 +1,43 @@ + +#include "pch.h" +#include "framework.h" +#include "ViewTree.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CViewTree + +CViewTree::CViewTree() noexcept +{ +} + +CViewTree::~CViewTree() +{ +} + +BEGIN_MESSAGE_MAP(CViewTree, CTreeCtrl) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 消息处理程序 + +BOOL CViewTree::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult); + + NMHDR* pNMHDR = (NMHDR*)lParam; + ASSERT(pNMHDR != nullptr); + +#pragma warning(suppress : 26454) + if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips() != nullptr) + { + GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); + } + + return bRes; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/ViewTree.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/ViewTree.h" new file mode 100644 index 0000000..0267d80 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/ViewTree.h" @@ -0,0 +1,23 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 窗口 + +class CViewTree : public CTreeCtrl +{ +// 构造 +public: + CViewTree() noexcept; + +// 重写 +protected: + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + +// 实现 +public: + virtual ~CViewTree(); + +protected: + DECLARE_MESSAGE_MAP() +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/framework.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/pch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/pch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/pch.h" new file mode 100644 index 0000000..9660927 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/pch.h" @@ -0,0 +1,13 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" + +#endif //PCH_H diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/3DTrans.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/3DTrans.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/3DTrans.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/3DTransDoc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/3DTransDoc.ico" new file mode 100644 index 0000000..96365d4 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/3DTransDoc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/My3DTrans.rc2" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/My3DTrans.rc2" new file mode 100644 index 0000000..bd2416b Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/My3DTrans.rc2" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/Toolbar.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/Toolbar.bmp" new file mode 100644 index 0000000..d501723 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/Toolbar.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/Toolbar256.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/Toolbar256.bmp" new file mode 100644 index 0000000..91a2553 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/Toolbar256.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/class_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/class_view.ico" new file mode 100644 index 0000000..bf6b0dd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/class_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/class_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/class_view_hc.ico" new file mode 100644 index 0000000..3112bf2 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/class_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/classview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/classview.bmp" new file mode 100644 index 0000000..1e02aa1 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/classview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/classview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/classview_hc.bmp" new file mode 100644 index 0000000..6b22e78 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/classview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/explorer.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/explorer.bmp" new file mode 100644 index 0000000..01298ba Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/explorer.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/explorer_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/explorer_hc.bmp" new file mode 100644 index 0000000..697199d Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/explorer_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/file_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/file_view.ico" new file mode 100644 index 0000000..0f93f52 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/file_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/file_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/file_view_hc.ico" new file mode 100644 index 0000000..42ec435 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/file_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/fileview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/fileview.bmp" new file mode 100644 index 0000000..a2d62d0 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/fileview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/fileview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/fileview_hc.bmp" new file mode 100644 index 0000000..b60f483 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/fileview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/menuimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/menuimages.bmp" new file mode 100644 index 0000000..7771841 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/menuimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/menuimages_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/menuimages_hc.bmp" new file mode 100644 index 0000000..577926e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/menuimages_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/output_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/output_wnd.ico" new file mode 100644 index 0000000..d14f991 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/output_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/output_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/output_wnd_hc.ico" new file mode 100644 index 0000000..fdd27e8 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/output_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/properties.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/properties.bmp" new file mode 100644 index 0000000..72e2b29 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/properties.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/properties_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/properties_hc.bmp" new file mode 100644 index 0000000..d18a7ca Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/properties_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/properties_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/properties_wnd.ico" new file mode 100644 index 0000000..3611766 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/properties_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/properties_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/properties_wnd_hc.ico" new file mode 100644 index 0000000..1e06b64 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/properties_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/sort.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/sort.bmp" new file mode 100644 index 0000000..0307301 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/sort.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/sort_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/sort_hc.bmp" new file mode 100644 index 0000000..720e742 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/sort_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/userimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/userimages.bmp" new file mode 100644 index 0000000..affe657 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/res/userimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/targetver.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/3DTrans/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\344\272\214.doc" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\344\272\214.doc" new file mode 100644 index 0000000..2c2a813 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex2/\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\344\272\214.doc" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.aps" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.aps" new file mode 100644 index 0000000..d8c7c31 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.aps" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.cpp" new file mode 100644 index 0000000..dcd5b63 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.cpp" @@ -0,0 +1,219 @@ + +// BezierCircle.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "afxwinappex.h" +#include "afxdialogex.h" +#include "BezierCircle.h" +#include "MainFrm.h" + +#include "BezierCircleDoc.h" +#include "BezierCircleView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CBezierCircleApp + +BEGIN_MESSAGE_MAP(CBezierCircleApp, CWinAppEx) + ON_COMMAND(ID_APP_ABOUT, &CBezierCircleApp::OnAppAbout) + // 基于文件的标准文档命令 + ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) + // 标准打印设置命令 + ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup) +END_MESSAGE_MAP() + + +// CBezierCircleApp 构造 + +CBezierCircleApp::CBezierCircleApp() noexcept +{ + m_bHiColorIcons = TRUE; + + + m_nAppLook = 0; + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; +#ifdef _MANAGED + // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则: + // 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。 + // 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。 + System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); +#endif + + // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式 + //为 CompanyName.ProductName.SubProduct.VersionInformation + SetAppID(_T("BezierCircle.AppID.NoVersion")); + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + +// 唯一的 CBezierCircleApp 对象 + +CBezierCircleApp theApp; + + +// CBezierCircleApp 初始化 + +BOOL CBezierCircleApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinAppEx::InitInstance(); + + + // 初始化 OLE 库 + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + + AfxEnableControlContainer(); + + EnableTaskbarInteraction(FALSE); + + // 使用 RichEdit 控件需要 AfxInitRichEdit2() + // AfxInitRichEdit2(); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) + + + InitContextMenuManager(); + + InitKeyboardManager(); + + InitTooltipManager(); + CMFCToolTipInfo ttParams; + ttParams.m_bVislManagerTheme = TRUE; + theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, + RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); + + // 注册应用程序的文档模板。 文档模板 + // 将用作文档、框架窗口和视图之间的连接 + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(CBezierCircleDoc), + RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 + RUNTIME_CLASS(CBezierCircleView)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + + + // 分析标准 shell 命令、DDE、打开文件操作的命令行 + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + + + // 调度在命令行中指定的命令。 如果 + // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + + // 唯一的一个窗口已初始化,因此显示它并对其进行更新 + m_pMainWnd->ShowWindow(SW_SHOW); + m_pMainWnd->UpdateWindow(); + return TRUE; +} + +int CBezierCircleApp::ExitInstance() +{ + //TODO: 处理可能已添加的附加资源 + AfxOleTerm(FALSE); + + return CWinAppEx::ExitInstance(); +} + +// CBezierCircleApp 消息处理程序 + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg() noexcept; + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + +// 用于运行对话框的应用程序命令 +void CBezierCircleApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +// CBezierCircleApp 自定义加载/保存方法 + +void CBezierCircleApp::PreLoadState() +{ + BOOL bNameValid; + CString strName; + bNameValid = strName.LoadString(IDS_EDIT_MENU); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); + bNameValid = strName.LoadString(IDS_EXPLORER); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EXPLORER); +} + +void CBezierCircleApp::LoadCustomState() +{ +} + +void CBezierCircleApp::SaveCustomState() +{ +} + +// CBezierCircleApp 消息处理程序 + + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.h" new file mode 100644 index 0000000..6f40e7a --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.h" @@ -0,0 +1,40 @@ + +// BezierCircle.h: BezierCircle 应用程序的主头文件 +// +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// CBezierCircleApp: +// 有关此类的实现,请参阅 BezierCircle.cpp +// + +class CBezierCircleApp : public CWinAppEx +{ +public: + CBezierCircleApp() noexcept; + + +// 重写 +public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + +// 实现 + UINT m_nAppLook; + BOOL m_bHiColorIcons; + + virtual void PreLoadState(); + virtual void LoadCustomState(); + virtual void SaveCustomState(); + + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern CBezierCircleApp theApp; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.rc" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.rc" new file mode 100644 index 0000000..3a2f632 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.rc" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.sln" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.sln" new file mode 100644 index 0000000..f5af565 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BezierCircle", "BezierCircle.vcxproj", "{E246676F-4A74-42BB-A23F-21C824E2E37C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E246676F-4A74-42BB-A23F-21C824E2E37C}.Debug|x64.ActiveCfg = Debug|x64 + {E246676F-4A74-42BB-A23F-21C824E2E37C}.Debug|x64.Build.0 = Debug|x64 + {E246676F-4A74-42BB-A23F-21C824E2E37C}.Debug|x86.ActiveCfg = Debug|Win32 + {E246676F-4A74-42BB-A23F-21C824E2E37C}.Debug|x86.Build.0 = Debug|Win32 + {E246676F-4A74-42BB-A23F-21C824E2E37C}.Release|x64.ActiveCfg = Release|x64 + {E246676F-4A74-42BB-A23F-21C824E2E37C}.Release|x64.Build.0 = Release|x64 + {E246676F-4A74-42BB-A23F-21C824E2E37C}.Release|x86.ActiveCfg = Release|Win32 + {E246676F-4A74-42BB-A23F-21C824E2E37C}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7846A3A0-E194-4F99-A232-B68F91D62516} + EndGlobalSection +EndGlobal diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.vcxproj" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.vcxproj" new file mode 100644 index 0000000..d31386b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.vcxproj" @@ -0,0 +1,261 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {E246676F-4A74-42BB-A23F-21C824E2E37C} + MFCProj + BezierCircle + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.vcxproj.filters" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.vcxproj.filters" new file mode 100644 index 0000000..e3e7f06 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.vcxproj.filters" @@ -0,0 +1,201 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.vcxproj.user" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.vcxproj.user" new file mode 100644 index 0000000..a610ca8 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircle.vcxproj.user" @@ -0,0 +1,6 @@ + + + + BezierCircle.rc + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircleDoc.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircleDoc.cpp" new file mode 100644 index 0000000..a5df4c8 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircleDoc.cpp" @@ -0,0 +1,138 @@ + +// BezierCircleDoc.cpp: CBezierCircleDoc 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "BezierCircle.h" +#endif + +#include "BezierCircleDoc.h" + +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CBezierCircleDoc + +IMPLEMENT_DYNCREATE(CBezierCircleDoc, CDocument) + +BEGIN_MESSAGE_MAP(CBezierCircleDoc, CDocument) +END_MESSAGE_MAP() + + +// CBezierCircleDoc 构造/析构 + +CBezierCircleDoc::CBezierCircleDoc() noexcept +{ + // TODO: 在此添加一次性构造代码 + +} + +CBezierCircleDoc::~CBezierCircleDoc() +{ +} + +BOOL CBezierCircleDoc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: 在此添加重新初始化代码 + // (SDI 文档将重用该文档) + + return TRUE; +} + + + + +// CBezierCircleDoc 序列化 + +void CBezierCircleDoc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: 在此添加存储代码 + } + else + { + // TODO: 在此添加加载代码 + } +} + +#ifdef SHARED_HANDLERS + +// 缩略图的支持 +void CBezierCircleDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds) +{ + // 修改此代码以绘制文档数据 + dc.FillSolidRect(lprcBounds, RGB(255, 255, 255)); + + CString strText = _T("TODO: implement thumbnail drawing here"); + LOGFONT lf; + + CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + pDefaultGUIFont->GetLogFont(&lf); + lf.lfHeight = 36; + + CFont fontDraw; + fontDraw.CreateFontIndirect(&lf); + + CFont* pOldFont = dc.SelectObject(&fontDraw); + dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK); + dc.SelectObject(pOldFont); +} + +// 搜索处理程序的支持 +void CBezierCircleDoc::InitializeSearchContent() +{ + CString strSearchContent; + // 从文档数据设置搜索内容。 + // 内容部分应由“;”分隔 + + // 例如: strSearchContent = _T("point;rectangle;circle;ole object;"); + SetSearchContent(strSearchContent); +} + +void CBezierCircleDoc::SetSearchContent(const CString& value) +{ + if (value.IsEmpty()) + { + RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); + } + else + { + CMFCFilterChunkValueImpl *pChunk = nullptr; + ATLTRY(pChunk = new CMFCFilterChunkValueImpl); + if (pChunk != nullptr) + { + pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT); + SetChunkValue(pChunk); + } + } +} + +#endif // SHARED_HANDLERS + +// CBezierCircleDoc 诊断 + +#ifdef _DEBUG +void CBezierCircleDoc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CBezierCircleDoc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// CBezierCircleDoc 命令 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircleDoc.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircleDoc.h" new file mode 100644 index 0000000..fd51cda --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircleDoc.h" @@ -0,0 +1,48 @@ + +// BezierCircleDoc.h: CBezierCircleDoc 类的接口 +// + + +#pragma once + + +class CBezierCircleDoc : public CDocument +{ +protected: // 仅从序列化创建 + CBezierCircleDoc() noexcept; + DECLARE_DYNCREATE(CBezierCircleDoc) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); +#ifdef SHARED_HANDLERS + virtual void InitializeSearchContent(); + virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds); +#endif // SHARED_HANDLERS + +// 实现 +public: + virtual ~CBezierCircleDoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// 生成的消息映射函数 +protected: + DECLARE_MESSAGE_MAP() + +#ifdef SHARED_HANDLERS + // 用于为搜索处理程序设置搜索内容的 Helper 函数 + void SetSearchContent(const CString& value); +#endif // SHARED_HANDLERS +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircleView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircleView.cpp" new file mode 100644 index 0000000..60430ab --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircleView.cpp" @@ -0,0 +1,137 @@ + +// BezierCircleView.cpp: CBezierCircleView 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "BezierCircle.h" +#endif + +#include "BezierCircleDoc.h" +#include "BezierCircleView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CBezierCircleView + +IMPLEMENT_DYNCREATE(CBezierCircleView, CView) + +BEGIN_MESSAGE_MAP(CBezierCircleView, CView) + // 标准打印命令 + ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CBezierCircleView::OnFilePrintPreview) + ON_WM_CONTEXTMENU() + ON_WM_RBUTTONUP() +END_MESSAGE_MAP() + +// CBezierCircleView 构造/析构 + +CBezierCircleView::CBezierCircleView() noexcept +{ + // TODO: 在此处添加构造代码 + circle.ReadPoint(); + transform.SetMatrix(circle.GetVertexArrayName(), 12); + double R = 200; + transform.Scale(R, R); +} + +CBezierCircleView::~CBezierCircleView() +{ +} + +BOOL CBezierCircleView::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return CView::PreCreateWindow(cs); +} + +// CBezierCircleView 绘图 + +void CBezierCircleView::OnDraw(CDC* pDC) +{ + CBezierCircleDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + // TODO: 在此处为本机数据添加绘制代码 + CRect rect; + GetClientRect(&rect); + pDC->SetMapMode(MM_ANISOTROPIC); + pDC->SetWindowExt(rect.Width(), rect.Height()); + pDC->SetViewportExt(rect.Width(), -rect.Height()); + pDC->SetViewportOrg(rect.Width() / 2, rect.Height() / 2); + circle.Draw(pDC); +} + + +// CBezierCircleView 打印 + + +void CBezierCircleView::OnFilePrintPreview() +{ +#ifndef SHARED_HANDLERS + AFXPrintPreview(this); +#endif +} + +BOOL CBezierCircleView::OnPreparePrinting(CPrintInfo* pInfo) +{ + // 默认准备 + return DoPreparePrinting(pInfo); +} + +void CBezierCircleView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加额外的打印前进行的初始化过程 +} + +void CBezierCircleView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加打印后进行的清理过程 +} + +void CBezierCircleView::OnRButtonUp(UINT /* nFlags */, CPoint point) +{ + ClientToScreen(&point); + OnContextMenu(this, point); +} + +void CBezierCircleView::OnContextMenu(CWnd* /* pWnd */, CPoint point) +{ +#ifndef SHARED_HANDLERS + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE); +#endif +} + + +// CBezierCircleView 诊断 + +#ifdef _DEBUG +void CBezierCircleView::AssertValid() const +{ + CView::AssertValid(); +} + +void CBezierCircleView::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +CBezierCircleDoc* CBezierCircleView::GetDocument() const // 非调试版本是内联的 +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBezierCircleDoc))); + return (CBezierCircleDoc*)m_pDocument; +} +#endif //_DEBUG + + +// CBezierCircleView 消息处理程序 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircleView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircleView.h" new file mode 100644 index 0000000..fa17599 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/BezierCircleView.h" @@ -0,0 +1,54 @@ + +// BezierCircleView.h: CBezierCircleView 类的接口 +// + +#pragma once +#include "CTransform2.h" +#include "CCircle.h" + +class CBezierCircleView : public CView +{ +protected: // 仅从序列化创建 + CBezierCircleView() noexcept; + DECLARE_DYNCREATE(CBezierCircleView) + +// 特性 +public: + CBezierCircleDoc* GetDocument() const; + +// 操作 +public: + +// 重写 +public: + virtual void OnDraw(CDC* pDC); + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// 实现 +public: + virtual ~CBezierCircleView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + CCircle circle; + CTransform2 transform; +// 生成的消息映射函数 +protected: + afx_msg void OnFilePrintPreview(); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + DECLARE_MESSAGE_MAP() +}; + +#ifndef _DEBUG // BezierCircleView.cpp 中的调试版本 +inline CBezierCircleDoc* CBezierCircleView::GetDocument() const + { return reinterpret_cast(m_pDocument); } +#endif + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CBezierCurve.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CBezierCurve.cpp" new file mode 100644 index 0000000..2278fc8 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CBezierCurve.cpp" @@ -0,0 +1,54 @@ +#include "pch.h" +#include "CBezierCurve.h" +#define ROUND(d) int(d + 0.5) +CBezierCurve::CBezierCurve(void) +{ +} +CBezierCurve::~CBezierCurve(void) +{ +} +void CBezierCurve::ReadPoint(CP2* P) +{ + for (int i = 0; i < 4; i++) + this->P[i] = P[i]; +} +void CBezierCurve::DrawCurve(CDC* pDC)//de Casteljau 㷨 +{ + CPen NewPen, * pOldPen; + NewPen.CreatePen(PS_SOLID, 1, RGB(255, 0, 0)); + pOldPen = pDC->SelectObject(&NewPen); + CP2 p00 = P[0], p10 = P[1], p20 = P[2], p30 = P[3]; + CP2 p01, p11, p21, p02, p12, p03; + double tStep = 0.1;// + pDC->MoveTo(ROUND(P[0].x), ROUND(P[0].y)); + for (double t = 0.0; t < 1; t += tStep) + { + p01 = (1 - t) * p00 + t * p10; + p11 = (1 - t) * p10 + t * p20; + p21 = (1 - t) * p20 + t * p30; + p02 = (1 - t) * p01 + t * p11; + p12 = (1 - t) * p11 + t * p21; + p03 = (1 - t) * p02 + t * p12; + pDC->LineTo(ROUND(p03.x), ROUND(p03.y)); + } + pDC->LineTo(ROUND(P[3].x), ROUND(P[3].y)); + pDC->SelectObject(pOldPen); + NewPen.DeleteObject(); +} +void CBezierCurve::DrawPolygon(CDC* pDC) +{ + CPen pen(PS_SOLID, 3, RGB(0, 0, 255)); + CPen* pOldPen = pDC->SelectObject(&pen); + CBrush brush(RGB(0, 0, 255)); + CBrush* pOldBrush = pDC->SelectObject(&brush); + int i = 0; + pDC->MoveTo(ROUND(P[i].x), ROUND(P[i].y)); + pDC->Ellipse(ROUND(P[i].x) - 5, ROUND(P[i].y) - 5, ROUND(P[i].x) + 5, ROUND(P[i].y) + 5); + for (i = 1; i < 4; i++) + { + pDC->LineTo(ROUND(P[i].x), ROUND(P[i].y)); + pDC->Ellipse(ROUND(P[i].x) - 5, ROUND(P[i].y) - 5, ROUND(P[i].x) + 5, ROUND(P[i].y) + 5); + } + pDC->SelectObject(pOldBrush); + pDC->SelectObject(pOldPen); +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CBezierCurve.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CBezierCurve.h" new file mode 100644 index 0000000..245d91d --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CBezierCurve.h" @@ -0,0 +1,13 @@ +#pragma once +#include"CP2.h" +class CBezierCurve +{ +public: + CBezierCurve(); + virtual ~CBezierCurve(); + void ReadPoint(CP2* P); + void DrawCurve(CDC* pDC); + void DrawPolygon(CDC* pDC); +private: + CP2 P[4]; +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CCircle.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CCircle.cpp" new file mode 100644 index 0000000..300c5ec --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CCircle.cpp" @@ -0,0 +1,52 @@ +#include "pch.h" +#include "CCircle.h" +CCircle::CCircle(void) +{ +} +CCircle::~CCircle(void) +{ +} +CP2* CCircle::GetVertexArrayName(void) +{ + return P; +} +void CCircle::ReadPoint(void) +{ + double m = 0.5523; + P[0].x = 1, P[0].y = 0; + P[1].x = 1, P[1].y = m; + P[2].x = m, P[2].y = 1; + P[3].x = 0, P[3].y = 1; + P[4].x = -m, P[4].y = 1; + P[5].x = -1, P[5].y = m; + P[6].x = -1, P[6].y = 0; + P[7].x = -1, P[7].y = -m; + P[8].x = -m, P[8].y = -1; + P[9].x = 0, P[9].y = -1; + P[10].x = m, P[10].y = -1; + P[11].x = 1, P[11].y = -m; +} +void CCircle::Draw(CDC* pDC) +{ + CP2 CtrP[4]; + //һ + CtrP[0] = P[0], CtrP[1] = P[1], CtrP[2] = P[2], CtrP[3] = P[3]; + bezier[0].ReadPoint(CtrP); + bezier[0].DrawCurve(pDC); + bezier[0].DrawPolygon(pDC); + //ڶ + CtrP[0] = P[3], CtrP[1] = P[4], CtrP[2] = P[5], CtrP[3] = P[6]; + bezier[1].ReadPoint(CtrP); + bezier[1].DrawCurve(pDC); + bezier[1].DrawPolygon(pDC); + // + CtrP[0] = P[6], CtrP[1] = P[7], CtrP[2] = P[8], CtrP[3] = P[9]; + bezier[2].ReadPoint(CtrP); + bezier[2].DrawCurve(pDC); + bezier[2].DrawPolygon(pDC); + //Ķ + CtrP[0] = P[9], CtrP[1] = P[10], CtrP[2] = P[11], CtrP[3] = P[0]; + bezier[3].ReadPoint(CtrP); + bezier[3].DrawCurve(pDC); + bezier[3].DrawPolygon(pDC); +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CCircle.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CCircle.h" new file mode 100644 index 0000000..b17664d --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CCircle.h" @@ -0,0 +1,14 @@ +#pragma once +#include"CBezierCurve.h" +class CCircle +{ +public: + CCircle(void); + virtual ~CCircle(void); + void ReadPoint(void); + CP2* GetVertexArrayName(void); + void Draw(CDC* pDC); +private: + CP2 P[12]; + CBezierCurve bezier[4]; +}; \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CP2.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CP2.cpp" new file mode 100644 index 0000000..3bd0d69 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CP2.cpp" @@ -0,0 +1,74 @@ +#include "pch.h" +#include "CP2.h" +CP2::CP2(void) +{ + x = 0.0; + y = 0.0; + w = 1.0; +} +CP2::~CP2(void) +{ +} +CP2::CP2(double x, double y) +{ + this->x = x; + this->y = y; + this->w = 1.0; +} +CP2 operator + (const CP2& p0, const CP2& p1) +{ + CP2 result; + result.x = p0.x + p1.x; + result.y = p0.y + p1.y; + return result; +} +CP2 operator - (const CP2& p0, const CP2& p1) +{ + CP2 result; + result.x = p0.x - p1.x; + result.y = p0.y - p1.y; + return result; +} +CP2 operator * (const CP2& p, double scalar) +{ + return CP2(p.x * scalar, p.y * scalar); +} +CP2 operator * (double scalar, const CP2& p) +{ + return CP2(p.x * scalar, p.y * scalar); +} +CP2 operator / (const CP2& p, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + CP2 result; + result.x = p.x / scalar; + result.y = p.y / scalar; + return result; +} +CP2 operator+=(CP2& p0, CP2& p1) +{ + p0.x += p1.x; + p0.y += p1.y; + return p0; +} +CP2 operator-=(CP2& p0, CP2& p1) +{ + p0.x -= p1.x; + p0.y -= p1.y; + return p0; +} +CP2 operator*=(CP2& p, double scalar) +{ + p.x *= scalar; + p.y *= scalar; + return p; +} +CP2 operator/=(CP2& p, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + p.x /= scalar; + p.y /= scalar; + return p; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CP2.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CP2.h" new file mode 100644 index 0000000..85ae45e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CP2.h" @@ -0,0 +1,23 @@ +#pragma once +class CP2 +{ +public: + CP2(void); + virtual ~CP2(void); + CP2(double x, double y); + friend CP2 operator + (const CP2& p0, const CP2& p1); + friend CP2 operator - (const CP2& p0, const CP2& p1); + friend CP2 operator * (const CP2& p, double scalar); + friend CP2 operator * (double scalar, const CP2& p); + friend CP2 operator / (const CP2& p, double scalar); + friend CP2 operator += (CP2& p0, CP2& p1); + friend CP2 operator -= (CP2& p0, CP2& p1); + friend CP2 operator *= (CP2& p, double scalar); + friend CP2 operator /= (CP2& p, double scalar); +public: + double x; + double y; + double w; +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CTransform2.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CTransform2.cpp" new file mode 100644 index 0000000..9f69839 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CTransform2.cpp" @@ -0,0 +1,94 @@ +#include "pch.h" +#include "CTransform2.h" +#define PI 3.1415926 +CTransform2::CTransform2(void) +{ +} +CTransform2::~CTransform2(void) +{ +} +void CTransform2::SetMatrix(CP2* P, int ptNumber) +{ + this->P = P; + this->ptNumber = ptNumber; +} +void CTransform2::Identity(void) +{ + T[0][0] = 1.0; T[0][1] = 0.0; T[0][2] = 0.0; + T[1][0] = 0.0; T[1][1] = 1.0; T[1][2] = 0.0; + T[2][0] = 0.0; T[2][1] = 0.0; T[2][2] = 1.0; +} +void CTransform2::Translate(double tx, double ty) +{ + Identity(); + T[0][2] = tx; + T[1][2] = ty; + MultiplyMatrix(); +} +void CTransform2::Scale(double sx, double sy) +{ + Identity(); + T[0][0] = sx; + T[1][1] = sy; + MultiplyMatrix(); +} +void CTransform2::Scale(double sx, double sy, CP2 p) +{ + Translate(-p.x, -p.y); + Scale(sx, sy); + Translate(p.x, p.y); +} +void CTransform2::Rotate(double beta) +{ + Identity(); + T[0][0] = cos(beta * PI / 180); T[0][1] = -sin(beta * PI / 180); + T[1][0] = sin(beta * PI / 180); T[1][1] = cos(beta * PI / 180); + MultiplyMatrix(); +} +void CTransform2::Rotate(double beta, CP2 p) +{ + Translate(-p.x, -p.y); + Rotate(beta); + Translate(p.x, p.y); +} +void CTransform2::ReflectOrg(void) +{ + Identity(); + T[0][0] = -1; + T[1][1] = -1; + MultiplyMatrix(); +} +void CTransform2::ReflectX(void) +{ + Identity(); + T[0][0] = 1; + T[1][1] = -1; + MultiplyMatrix(); +} +void CTransform2::ReflectY(void) +{ + Identity(); + T[0][0] = -1; + T[1][1] = 1; + MultiplyMatrix(); +} +void CTransform2::Shear(double b, double c) +{ + Identity(); + T[0][1] = b; + T[1][0] = c; + MultiplyMatrix(); +} +void CTransform2::MultiplyMatrix(void) +{ + CP2* PTemp = new CP2[ptNumber]; + for (int i = 0; i < ptNumber; i++) + PTemp[i] = P[i]; + for (int i = 0; i < ptNumber; i++) + { + P[i].x = T[0][0] * PTemp[i].x + T[0][1] * PTemp[i].y + T[0][2] * PTemp[i].w; + P[i].y = T[1][0] * PTemp[i].x + T[1][1] * PTemp[i].y + T[1][2] * PTemp[i].w; + P[i].w = T[2][0] * PTemp[i].x + T[2][1] * PTemp[i].y + T[2][2] * PTemp[i].w; + } + delete[]PTemp; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CTransform2.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CTransform2.h" new file mode 100644 index 0000000..e81d37e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/CTransform2.h" @@ -0,0 +1,24 @@ +#pragma once +#include "CP2.h" +class CTransform2 +{ +public: + CTransform2(void); + virtual ~CTransform2(void); + void SetMatrix(CP2* P, int ptNumber); + void Identity(void); + void Translate(double tx, double ty); + void Scale(double sx, double sy); + void Scale(double sx, double sy, CP2 p); + void Rotate(double beta); + void Rotate(double beta, CP2 p); + void ReflectOrg(void); + void ReflectX(void); + void ReflectY(void); + void Shear(double b, double c); + void MultiplyMatrix(void); +private: + double T[3][3]; + CP2* P; + int ptNumber; +}; \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/ClassView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/ClassView.cpp" new file mode 100644 index 0000000..52d5cf3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/ClassView.cpp" @@ -0,0 +1,323 @@ + +#include "pch.h" +#include "framework.h" +#include "MainFrm.h" +#include "ClassView.h" +#include "Resource.h" +#include "BezierCircle.h" + +class CClassViewMenuButton : public CMFCToolBarMenuButton +{ + friend class CClassView; + + DECLARE_SERIAL(CClassViewMenuButton) + +public: + CClassViewMenuButton(HMENU hMenu = nullptr) noexcept : CMFCToolBarMenuButton((UINT)-1, hMenu, -1) + { + } + + virtual void OnDraw(CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz = TRUE, + BOOL bCustomizeMode = FALSE, BOOL bHighlight = FALSE, BOOL bDrawBorder = TRUE, BOOL bGrayDisabledButtons = TRUE) + { + pImages = CMFCToolBar::GetImages(); + + CAfxDrawState ds; + pImages->PrepareDrawImage(ds); + + CMFCToolBarMenuButton::OnDraw(pDC, rect, pImages, bHorz, bCustomizeMode, bHighlight, bDrawBorder, bGrayDisabledButtons); + + pImages->EndDrawImage(ds); + } +}; + +IMPLEMENT_SERIAL(CClassViewMenuButton, CMFCToolBarMenuButton, 1) + +////////////////////////////////////////////////////////////////////// +// 构造/析构 +////////////////////////////////////////////////////////////////////// + +CClassView::CClassView() noexcept +{ + m_nCurrSort = ID_SORTING_GROUPBYTYPE; +} + +CClassView::~CClassView() +{ +} + +BEGIN_MESSAGE_MAP(CClassView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_CLASS_ADD_MEMBER_FUNCTION, OnClassAddMemberFunction) + ON_COMMAND(ID_CLASS_ADD_MEMBER_VARIABLE, OnClassAddMemberVariable) + ON_COMMAND(ID_CLASS_DEFINITION, OnClassDefinition) + ON_COMMAND(ID_CLASS_PROPERTIES, OnClassProperties) + ON_COMMAND(ID_NEW_FOLDER, OnNewFolder) + ON_WM_PAINT() + ON_WM_SETFOCUS() + ON_COMMAND_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnSort) + ON_UPDATE_COMMAND_UI_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnUpdateSort) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClassView 消息处理程序 + +int CClassView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndClassView.Create(dwViewStyle, rectDummy, this, 2)) + { + TRACE0("未能创建类视图\n"); + return -1; // 未能创建 + } + + // 加载图像: + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_SORT); + m_wndToolBar.LoadToolBar(IDR_SORT, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + CMenu menuSort; + menuSort.LoadMenu(IDR_POPUP_SORT); + + m_wndToolBar.ReplaceButton(ID_SORT_MENU, CClassViewMenuButton(menuSort.GetSubMenu(0)->GetSafeHmenu())); + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->m_bText = FALSE; + pButton->m_bImage = TRUE; + pButton->SetImage(GetCmdMgr()->GetCmdImage(m_nCurrSort)); + pButton->SetMessageWnd(this); + } + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillClassView(); + + return 0; +} + +void CClassView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CClassView::FillClassView() +{ + HTREEITEM hRoot = m_wndClassView.InsertItem(_T("FakeApp 类"), 0, 0); + m_wndClassView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hClass = m_wndClassView.InsertItem(_T("CFakeAboutDlg"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAboutDlg()"), 3, 3, hClass); + + m_wndClassView.Expand(hRoot, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeApp"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeApp()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("InitInstance()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnAppAbout()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppDoc"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppDoc()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppDoc()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnNewDocument()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppView"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppView()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppView()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("GetDocument()"), 3, 3, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppFrame"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("m_wndMenuBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndToolBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndStatusBar"), 6, 6, hClass); + + hClass = m_wndClassView.InsertItem(_T("Globals"), 2, 2, hRoot); + m_wndClassView.InsertItem(_T("theFakeApp"), 5, 5, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); +} + +void CClassView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndClassView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + CMenu menu; + menu.LoadMenu(IDR_POPUP_SORT); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } +} + +void CClassView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndClassView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +BOOL CClassView::PreTranslateMessage(MSG* pMsg) +{ + return CDockablePane::PreTranslateMessage(pMsg); +} + +void CClassView::OnSort(UINT id) +{ + if (m_nCurrSort == id) + { + return; + } + + m_nCurrSort = id; + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->SetImage(GetCmdMgr()->GetCmdImage(id)); + m_wndToolBar.Invalidate(); + m_wndToolBar.UpdateWindow(); + } +} + +void CClassView::OnUpdateSort(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(pCmdUI->m_nID == m_nCurrSort); +} + +void CClassView::OnClassAddMemberFunction() +{ + AfxMessageBox(_T("添加成员函数...")); +} + +void CClassView::OnClassAddMemberVariable() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassDefinition() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassProperties() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnNewFolder() +{ + AfxMessageBox(_T("新建文件夹...")); +} + +void CClassView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndClassView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CClassView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndClassView.SetFocus(); +} + +void CClassView::OnChangeVisualStyle() +{ + m_ClassViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_CLASS_VIEW_24 : IDB_CLASS_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_ClassViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_ClassViewImages.Add(&bmp, RGB(255, 0, 0)); + + m_wndClassView.SetImageList(&m_ClassViewImages, TVSIL_NORMAL); + + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_SORT_24 : IDR_SORT, 0, 0, TRUE /* 锁定*/); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/ClassView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/ClassView.h" new file mode 100644 index 0000000..786c278 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/ClassView.h" @@ -0,0 +1,54 @@ + +#pragma once + +#include "ViewTree.h" + +class CClassToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CClassView : public CDockablePane +{ +public: + CClassView() noexcept; + virtual ~CClassView(); + + void AdjustLayout(); + void OnChangeVisualStyle(); + +protected: + CClassToolBar m_wndToolBar; + CViewTree m_wndClassView; + CImageList m_ClassViewImages; + UINT m_nCurrSort; + + void FillClassView(); + +// 重写 +public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnClassAddMemberFunction(); + afx_msg void OnClassAddMemberVariable(); + afx_msg void OnClassDefinition(); + afx_msg void OnClassProperties(); + afx_msg void OnNewFolder(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg LRESULT OnChangeActiveTab(WPARAM, LPARAM); + afx_msg void OnSort(UINT id); + afx_msg void OnUpdateSort(CCmdUI* pCmdUI); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/FileView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/FileView.cpp" new file mode 100644 index 0000000..02a1e62 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/FileView.cpp" @@ -0,0 +1,257 @@ + +#include "pch.h" +#include "framework.h" +#include "mainfrm.h" +#include "FileView.h" +#include "Resource.h" +#include "BezierCircle.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CFileView + +CFileView::CFileView() noexcept +{ +} + +CFileView::~CFileView() +{ +} + +BEGIN_MESSAGE_MAP(CFileView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_PROPERTIES, OnProperties) + ON_COMMAND(ID_OPEN, OnFileOpen) + ON_COMMAND(ID_OPEN_WITH, OnFileOpenWith) + ON_COMMAND(ID_DUMMY_COMPILE, OnDummyCompile) + ON_COMMAND(ID_EDIT_CUT, OnEditCut) + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_WM_PAINT() + ON_WM_SETFOCUS() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CWorkspaceBar 消息处理程序 + +int CFileView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; + + if (!m_wndFileView.Create(dwViewStyle, rectDummy, this, 4)) + { + TRACE0("未能创建文件视图\n"); + return -1; // 未能创建 + } + + // 加载视图图像: + m_FileViewImages.Create(IDB_FILE_VIEW, 16, 0, RGB(255, 0, 255)); + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_EXPLORER); + m_wndToolBar.LoadToolBar(IDR_EXPLORER, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillFileView(); + AdjustLayout(); + + return 0; +} + +void CFileView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CFileView::FillFileView() +{ + HTREEITEM hRoot = m_wndFileView.InsertItem(_T("FakeApp 文件"), 0, 0); + m_wndFileView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hSrc = m_wndFileView.InsertItem(_T("FakeApp 源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeApp.rc"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppDoc.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppView.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("MainFrm.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("pch.cpp"), 1, 1, hSrc); + + HTREEITEM hInc = m_wndFileView.InsertItem(_T("FakeApp 头文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppDoc.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppView.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("Resource.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("MainFrm.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("pch.h"), 2, 2, hInc); + + HTREEITEM hRes = m_wndFileView.InsertItem(_T("FakeApp 资源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeApp.rc2"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeAppDoc.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeToolbar.bmp"), 2, 2, hRes); + + m_wndFileView.Expand(hRoot, TVE_EXPAND); + m_wndFileView.Expand(hSrc, TVE_EXPAND); + m_wndFileView.Expand(hInc, TVE_EXPAND); +} + +void CFileView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE); +} + +void CFileView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndFileView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +void CFileView::OnProperties() +{ + AfxMessageBox(_T("属性....")); + +} + +void CFileView::OnFileOpen() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnFileOpenWith() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnDummyCompile() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCut() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCopy() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditClear() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndFileView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CFileView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndFileView.SetFocus(); +} + +void CFileView::OnChangeVisualStyle() +{ + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_EXPLORER_24 : IDR_EXPLORER, 0, 0, TRUE /* 锁定*/); + + m_FileViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_FILE_VIEW_24 : IDB_FILE_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_FileViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_FileViewImages.Add(&bmp, RGB(255, 0, 255)); + + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); +} + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/FileView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/FileView.h" new file mode 100644 index 0000000..e39a7c9 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/FileView.h" @@ -0,0 +1,55 @@ + +#pragma once + +#include "ViewTree.h" + +class CFileViewToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CFileView : public CDockablePane +{ +// 构造 +public: + CFileView() noexcept; + + void AdjustLayout(); + void OnChangeVisualStyle(); + +// 特性 +protected: + + CViewTree m_wndFileView; + CImageList m_FileViewImages; + CFileViewToolBar m_wndToolBar; + +protected: + void FillFileView(); + +// 实现 +public: + virtual ~CFileView(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnProperties(); + afx_msg void OnFileOpen(); + afx_msg void OnFileOpenWith(); + afx_msg void OnDummyCompile(); + afx_msg void OnEditCut(); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/MainFrm.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/MainFrm.cpp" new file mode 100644 index 0000000..62ad8ac --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/MainFrm.cpp" @@ -0,0 +1,408 @@ + +// MainFrm.cpp: CMainFrame 类的实现 +// + +#include "pch.h" +#include "framework.h" +#include "BezierCircle.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) + +const int iMaxUserToolbars = 10; +const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; +const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) + ON_WM_CREATE() + ON_COMMAND(ID_VIEW_CUSTOMIZE, &CMainFrame::OnViewCustomize) + ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, &CMainFrame::OnToolbarCreateNew) + ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook) + ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook) + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // 状态行指示器 + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +// CMainFrame 构造/析构 + +CMainFrame::CMainFrame() noexcept +{ + // TODO: 在此添加成员初始化代码 + theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2008); +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) + return -1; + + BOOL bNameValid; + + if (!m_wndMenuBar.Create(this)) + { + TRACE0("未能创建菜单栏\n"); + return -1; // 未能创建 + } + + m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); + + // 防止菜单栏在激活时获得焦点 + CMFCPopupMenu::SetForceMenuFocus(FALSE); + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) + { + TRACE0("未能创建工具栏\n"); + return -1; // 未能创建 + } + + CString strToolBarName; + bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); + ASSERT(bNameValid); + m_wndToolBar.SetWindowText(strToolBarName); + + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + + // 允许用户定义的工具栏操作: + InitUserToolbars(nullptr, uiFirstUserToolBarId, uiLastUserToolBarId); + + if (!m_wndStatusBar.Create(this)) + { + TRACE0("未能创建状态栏\n"); + return -1; // 未能创建 + } + m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); + + // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行 + m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndMenuBar); + DockPane(&m_wndToolBar); + + + // 启用 Visual Studio 2005 样式停靠窗口行为 + CDockingManager::SetDockingMode(DT_SMART); + // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 + EnableAutoHidePanes(CBRS_ALIGN_ANY); + + // 加载菜单项图像(不在任何标准工具栏上): + CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); + + // 创建停靠窗口 + if (!CreateDockingWindows()) + { + TRACE0("未能创建停靠窗口\n"); + return -1; + } + + m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); + m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndFileView); + CDockablePane* pTabbedBar = nullptr; + m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); + m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndOutput); + m_wndProperties.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndProperties); + + // 基于持久值设置视觉管理器和样式 + OnApplicationLook(theApp.m_nAppLook); + + // 启用工具栏和停靠窗口菜单替换 + EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); + + // 启用快速(按住 Alt 拖动)工具栏自定义 + CMFCToolBar::EnableQuickCustomization(); + + if (CMFCToolBar::GetUserImages() == nullptr) + { + // 加载用户定义的工具栏图像 + if (m_UserImages.Load(_T(".\\UserImages.bmp"))) + { + CMFCToolBar::SetUserImages(&m_UserImages); + } + } + + // 启用菜单个性化(最近使用的命令) + // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 + CList lstBasicCommands; + + lstBasicCommands.AddTail(ID_FILE_NEW); + lstBasicCommands.AddTail(ID_FILE_OPEN); + lstBasicCommands.AddTail(ID_FILE_SAVE); + lstBasicCommands.AddTail(ID_FILE_PRINT); + lstBasicCommands.AddTail(ID_APP_EXIT); + lstBasicCommands.AddTail(ID_EDIT_CUT); + lstBasicCommands.AddTail(ID_EDIT_PASTE); + lstBasicCommands.AddTail(ID_EDIT_UNDO); + lstBasicCommands.AddTail(ID_APP_ABOUT); + lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); + lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7); + lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); + lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); + lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); + lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); + + CMFCToolBar::SetBasicCommands(lstBasicCommands); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWndEx::PreCreateWindow(cs) ) + return FALSE; + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return TRUE; +} + +BOOL CMainFrame::CreateDockingWindows() +{ + BOOL bNameValid; + + // 创建类视图 + CString strClassView; + bNameValid = strClassView.LoadString(IDS_CLASS_VIEW); + ASSERT(bNameValid); + if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“类视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建文件视图 + CString strFileView; + bNameValid = strFileView.LoadString(IDS_FILE_VIEW); + ASSERT(bNameValid); + if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“文件视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建输出窗口 + CString strOutputWnd; + bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND); + ASSERT(bNameValid); + if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建输出窗口\n"); + return FALSE; // 未能创建 + } + + // 创建属性窗口 + CString strPropertiesWnd; + bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND); + ASSERT(bNameValid); + if (!m_wndProperties.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“属性”窗口\n"); + return FALSE; // 未能创建 + } + + SetDockingWindowIcons(theApp.m_bHiColorIcons); + return TRUE; +} + +void CMainFrame::SetDockingWindowIcons(BOOL bHiColorIcons) +{ + HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_FILE_VIEW_HC : IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndFileView.SetIcon(hFileViewIcon, FALSE); + + HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_CLASS_VIEW_HC : IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndClassView.SetIcon(hClassViewIcon, FALSE); + + HICON hOutputBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_OUTPUT_WND_HC : IDI_OUTPUT_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndOutput.SetIcon(hOutputBarIcon, FALSE); + + HICON hPropertiesBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_PROPERTIES_WND_HC : IDI_PROPERTIES_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndProperties.SetIcon(hPropertiesBarIcon, FALSE); + +} + +// CMainFrame 诊断 + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWndEx::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWndEx::Dump(dc); +} +#endif //_DEBUG + + +// CMainFrame 消息处理程序 + +void CMainFrame::OnViewCustomize() +{ + CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* 扫描菜单*/); + pDlgCust->EnableUserDefinedToolbars(); + pDlgCust->Create(); +} + +LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) +{ + LRESULT lres = CFrameWndEx::OnToolbarCreateNew(wp,lp); + if (lres == 0) + { + return 0; + } + + CMFCToolBar* pUserToolbar = (CMFCToolBar*)lres; + ASSERT_VALID(pUserToolbar); + + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + return lres; +} + +void CMainFrame::OnApplicationLook(UINT id) +{ + CWaitCursor wait; + + theApp.m_nAppLook = id; + + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_WIN_2000: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); + break; + + case ID_VIEW_APPLOOK_OFF_XP: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); + break; + + case ID_VIEW_APPLOOK_WIN_XP: + CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + break; + + case ID_VIEW_APPLOOK_OFF_2003: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2005: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2008: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_WINDOWS_7: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + default: + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_OFF_2007_BLUE: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); + break; + + case ID_VIEW_APPLOOK_OFF_2007_BLACK: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); + break; + + case ID_VIEW_APPLOOK_OFF_2007_SILVER: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); + break; + + case ID_VIEW_APPLOOK_OFF_2007_AQUA: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); + break; + } + + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); + CDockingManager::SetDockingMode(DT_SMART); + } + + m_wndOutput.UpdateFonts(); + RedrawWindow(nullptr, nullptr, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); + + theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); +} + +void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI) +{ + pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID); +} + + +BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) +{ + // 基类将执行真正的工作 + + if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) + { + return FALSE; + } + + + // 为所有用户工具栏启用自定义按钮 + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + for (int i = 0; i < iMaxUserToolbars; i ++) + { + CMFCToolBar* pUserToolbar = GetUserToolBarByIndex(i); + if (pUserToolbar != nullptr) + { + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + } + } + + return TRUE; +} + + +void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CFrameWndEx::OnSettingChange(uFlags, lpszSection); + m_wndOutput.UpdateFonts(); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/MainFrm.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/MainFrm.h" new file mode 100644 index 0000000..02feb8e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/MainFrm.h" @@ -0,0 +1,61 @@ + +// MainFrm.h: CMainFrame 类的接口 +// + +#pragma once +#include "FileView.h" +#include "ClassView.h" +#include "OutputWnd.h" +#include "PropertiesWnd.h" + +class CMainFrame : public CFrameWndEx +{ + +protected: // 仅从序列化创建 + CMainFrame() noexcept; + DECLARE_DYNCREATE(CMainFrame) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = nullptr, CCreateContext* pContext = nullptr); + +// 实现 +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // 控件条嵌入成员 + CMFCMenuBar m_wndMenuBar; + CMFCToolBar m_wndToolBar; + CMFCStatusBar m_wndStatusBar; + CMFCToolBarImages m_UserImages; + CFileView m_wndFileView; + CClassView m_wndClassView; + COutputWnd m_wndOutput; + CPropertiesWnd m_wndProperties; + +// 生成的消息映射函数 +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnViewCustomize(); + afx_msg LRESULT OnToolbarCreateNew(WPARAM wp, LPARAM lp); + afx_msg void OnApplicationLook(UINT id); + afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + DECLARE_MESSAGE_MAP() + + BOOL CreateDockingWindows(); + void SetDockingWindowIcons(BOOL bHiColorIcons); +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/OutputWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/OutputWnd.cpp" new file mode 100644 index 0000000..e3f4901 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/OutputWnd.cpp" @@ -0,0 +1,200 @@ + +#include "pch.h" +#include "framework.h" + +#include "OutputWnd.h" +#include "Resource.h" +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// COutputBar + +COutputWnd::COutputWnd() noexcept +{ +} + +COutputWnd::~COutputWnd() +{ +} + +BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() +END_MESSAGE_MAP() + +int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建选项卡窗口: + if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1)) + { + TRACE0("未能创建输出选项卡窗口\n"); + return -1; // 未能创建 + } + + // 创建输出窗格: + const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; + + if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) || + !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) || + !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4)) + { + TRACE0("未能创建输出窗口\n"); + return -1; // 未能创建 + } + + UpdateFonts(); + + CString strTabName; + BOOL bNameValid; + + // 将列表窗口附加到选项卡: + bNameValid = strTabName.LoadString(IDS_BUILD_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0); + bNameValid = strTabName.LoadString(IDS_DEBUG_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1); + bNameValid = strTabName.LoadString(IDS_FIND_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2); + + // 使用一些虚拟文本填写输出选项卡(无需复杂数据) + FillBuildWindow(); + FillDebugWindow(); + FillFindWindow(); + + return 0; +} + +void COutputWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + + // 选项卡控件应覆盖整个工作区: + m_wndTabs.SetWindowPos (nullptr, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); +} + +void COutputWnd::AdjustHorzScroll(CListBox& wndListBox) +{ + CClientDC dc(this); + CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular); + + int cxExtentMax = 0; + + for (int i = 0; i < wndListBox.GetCount(); i ++) + { + CString strItem; + wndListBox.GetText(i, strItem); + + cxExtentMax = max(cxExtentMax, (int)dc.GetTextExtent(strItem).cx); + } + + wndListBox.SetHorizontalExtent(cxExtentMax); + dc.SelectObject(pOldFont); +} + +void COutputWnd::FillBuildWindow() +{ + m_wndOutputBuild.AddString(_T("生成输出正显示在此处。")); + m_wndOutputBuild.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputBuild.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillDebugWindow() +{ + m_wndOutputDebug.AddString(_T("调试输出正显示在此处。")); + m_wndOutputDebug.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputDebug.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillFindWindow() +{ + m_wndOutputFind.AddString(_T("查找输出正显示在此处。")); + m_wndOutputFind.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputFind.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::UpdateFonts() +{ + m_wndOutputBuild.SetFont(&afxGlobalData.fontRegular); + m_wndOutputDebug.SetFont(&afxGlobalData.fontRegular); + m_wndOutputFind.SetFont(&afxGlobalData.fontRegular); +} + +///////////////////////////////////////////////////////////////////////////// +// COutputList1 + +COutputList::COutputList() noexcept +{ +} + +COutputList::~COutputList() +{ +} + +BEGIN_MESSAGE_MAP(COutputList, CListBox) + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput) + ON_WM_WINDOWPOSCHANGING() +END_MESSAGE_MAP() +///////////////////////////////////////////////////////////////////////////// +// COutputList 消息处理程序 + +void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) +{ + CMenu menu; + menu.LoadMenu(IDR_OUTPUT_POPUP); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } + + SetFocus(); +} + +void COutputList::OnEditCopy() +{ + MessageBox(_T("复制输出")); +} + +void COutputList::OnEditClear() +{ + MessageBox(_T("清除输出")); +} + +void COutputList::OnViewOutput() +{ + CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner()); + CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame()); + + if (pMainFrame != nullptr && pParentBar != nullptr) + { + pMainFrame->SetFocus(); + pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE); + pMainFrame->RecalcLayout(); + + } +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/OutputWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/OutputWnd.h" new file mode 100644 index 0000000..4d773c3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/OutputWnd.h" @@ -0,0 +1,59 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// COutputList 窗口 + +class COutputList : public CListBox +{ +// 构造 +public: + COutputList() noexcept; + +// 实现 +public: + virtual ~COutputList(); + +protected: + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnViewOutput(); + + DECLARE_MESSAGE_MAP() +}; + +class COutputWnd : public CDockablePane +{ +// 构造 +public: + COutputWnd() noexcept; + + void UpdateFonts(); + +// 特性 +protected: + CMFCTabCtrl m_wndTabs; + + COutputList m_wndOutputBuild; + COutputList m_wndOutputDebug; + COutputList m_wndOutputFind; + +protected: + void FillBuildWindow(); + void FillDebugWindow(); + void FillFindWindow(); + + void AdjustHorzScroll(CListBox& wndListBox); + +// 实现 +public: + virtual ~COutputWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/PropertiesWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/PropertiesWnd.cpp" new file mode 100644 index 0000000..0a694da --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/PropertiesWnd.cpp" @@ -0,0 +1,273 @@ + +#include "pch.h" +#include "framework.h" + +#include "PropertiesWnd.h" +#include "Resource.h" +#include "MainFrm.h" +#include "BezierCircle.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar + +CPropertiesWnd::CPropertiesWnd() noexcept +{ + m_nComboHeight = 0; +} + +CPropertiesWnd::~CPropertiesWnd() +{ +} + +BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties) + ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties) + ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties) + ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties) + ON_COMMAND(ID_PROPERTIES1, OnProperties1) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1) + ON_COMMAND(ID_PROPERTIES2, OnProperties2) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2) + ON_WM_SETFOCUS() + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar 消息处理程序 + +void CPropertiesWnd::AdjustLayout() +{ + if (GetSafeHwnd () == nullptr || (AfxGetMainWnd() != nullptr && AfxGetMainWnd()->IsIconic())) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndObjectCombo.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndPropList.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight + cyTlb, rectClient.Width(), rectClient.Height() -(m_nComboHeight+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER); +} + +int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建组合: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1)) + { + TRACE0("未能创建属性组合 \n"); + return -1; // 未能创建 + } + + m_wndObjectCombo.AddString(_T("应用程序")); + m_wndObjectCombo.AddString(_T("属性窗口")); + m_wndObjectCombo.SetCurSel(0); + + CRect rectCombo; + m_wndObjectCombo.GetClientRect (&rectCombo); + + m_nComboHeight = rectCombo.Height(); + + if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2)) + { + TRACE0("未能创建属性网格\n"); + return -1; // 未能创建 + } + + InitPropList(); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES); + m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* 已锁定*/); + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* 锁定*/); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + AdjustLayout(); + return 0; +} + +void CPropertiesWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CPropertiesWnd::OnExpandAllProperties() +{ + m_wndPropList.ExpandAll(); +} + +void CPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* /* pCmdUI */) +{ +} + +void CPropertiesWnd::OnSortProperties() +{ + m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnProperties1() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::OnProperties2() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::InitPropList() +{ + SetPropListFont(); + + m_wndPropList.EnableHeaderCtrl(FALSE); + m_wndPropList.EnableDescriptionArea(); + m_wndPropList.SetVSDotNetLook(); + m_wndPropList.MarkModifiedProperties(); + + CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("外观")); + + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("三维外观"), (_variant_t) false, _T("指定窗口的字体不使用粗体,并且控件将使用三维边框"))); + + CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("边框"), _T("对话框外框"), _T("其中之一: “无”、“细”、“可调整大小”或“对话框外框”")); + pProp->AddOption(_T("无")); + pProp->AddOption(_T("细")); + pProp->AddOption(_T("可调整大小")); + pProp->AddOption(_T("对话框外框")); + pProp->AllowEdit(FALSE); + + pGroup1->AddSubItem(pProp); + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("标题"), (_variant_t) _T("关于"), _T("指定窗口标题栏中显示的文本"))); + + m_wndPropList.AddProperty(pGroup1); + + CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("窗口大小"), 0, TRUE); + + pProp = new CMFCPropertyGridProperty(_T("高度"), (_variant_t) 250l, _T("指定窗口的高度")); + pProp->EnableSpinControl(TRUE, 50, 300); + pSize->AddSubItem(pProp); + + pProp = new CMFCPropertyGridProperty( _T("宽度"), (_variant_t) 150l, _T("指定窗口的宽度")); + pProp->EnableSpinControl(TRUE, 50, 200); + pSize->AddSubItem(pProp); + + m_wndPropList.AddProperty(pSize); + + CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("字体")); + + LOGFONT lf; + CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + font->GetLogFont(&lf); + + _tcscpy_s(lf.lfFaceName, _T("宋体, Arial")); + + pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("字体"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("指定窗口的默认字体"))); + pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("使用系统字体"), (_variant_t) true, _T("指定窗口使用“MS Shell Dlg”字体"))); + + m_wndPropList.AddProperty(pGroup2); + + CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("杂项")); + pProp = new CMFCPropertyGridProperty(_T("(名称)"), _T("应用程序")); + pProp->Enable(FALSE); + pGroup3->AddSubItem(pProp); + + CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("窗口颜色"), RGB(210, 192, 254), nullptr, _T("指定默认的窗口颜色")); + pColorProp->EnableOtherButton(_T("其他...")); + pColorProp->EnableAutomaticButton(_T("默认"), ::GetSysColor(COLOR_3DFACE)); + pGroup3->AddSubItem(pColorProp); + + static const TCHAR szFilter[] = _T("图标文件(*.ico)|*.ico|所有文件(*.*)|*.*||"); + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("图标"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("指定窗口图标"))); + + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("文件夹"), _T("c:\\"))); + + m_wndPropList.AddProperty(pGroup3); + + CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("层次结构")); + + CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("第一个子级")); + pGroup4->AddSubItem(pGroup41); + + CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("第二个子级")); + pGroup41->AddSubItem(pGroup411); + + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 1"), (_variant_t) _T("值 1"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 2"), (_variant_t) _T("值 2"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 3"), (_variant_t) _T("值 3"), _T("此为说明"))); + + pGroup4->Expand(FALSE); + m_wndPropList.AddProperty(pGroup4); +} + +void CPropertiesWnd::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + m_wndPropList.SetFocus(); +} + +void CPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CDockablePane::OnSettingChange(uFlags, lpszSection); + SetPropListFont(); +} + +void CPropertiesWnd::SetPropListFont() +{ + ::DeleteObject(m_fntPropList.Detach()); + + LOGFONT lf; + afxGlobalData.fontRegular.GetLogFont(&lf); + + NONCLIENTMETRICS info; + info.cbSize = sizeof(info); + + afxGlobalData.GetNonClientMetrics(info); + + lf.lfHeight = info.lfMenuFont.lfHeight; + lf.lfWeight = info.lfMenuFont.lfWeight; + lf.lfItalic = info.lfMenuFont.lfItalic; + + m_fntPropList.CreateFontIndirect(&lf); + + m_wndPropList.SetFont(&m_fntPropList); + m_wndObjectCombo.SetFont(&m_fntPropList); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/PropertiesWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/PropertiesWnd.h" new file mode 100644 index 0000000..e056430 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/PropertiesWnd.h" @@ -0,0 +1,62 @@ + +#pragma once + +class CPropertiesToolBar : public CMFCToolBar +{ +public: + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CPropertiesWnd : public CDockablePane +{ +// 构造 +public: + CPropertiesWnd() noexcept; + + void AdjustLayout(); + +// 特性 +public: + void SetVSDotNetLook(BOOL bSet) + { + m_wndPropList.SetVSDotNetLook(bSet); + m_wndPropList.SetGroupNameFullWidth(bSet); + } + +protected: + CFont m_fntPropList; + CComboBox m_wndObjectCombo; + CPropertiesToolBar m_wndToolBar; + CMFCPropertyGridCtrl m_wndPropList; + +// 实现 +public: + virtual ~CPropertiesWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnExpandAllProperties(); + afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI); + afx_msg void OnSortProperties(); + afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI); + afx_msg void OnProperties1(); + afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI); + afx_msg void OnProperties2(); + afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + + DECLARE_MESSAGE_MAP() + + void InitPropList(); + void SetPropListFont(); + + int m_nComboHeight; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/Resource.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/Resource.h" new file mode 100644 index 0000000..501d697 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/Resource.h" @@ -0,0 +1,97 @@ +//{{NO_DEPENDENCIES}} +// 生成的 Microsoft Visual C++ 包含文件。 +// 由 BezierCircle.rc 使用 +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_POPUP_EDIT 119 +#define ID_STATUSBAR_PANE1 120 +#define ID_STATUSBAR_PANE2 121 +#define IDS_STATUS_PANE1 122 +#define IDS_STATUS_PANE2 123 +#define IDS_TOOLBAR_STANDARD 124 +#define IDS_TOOLBAR_CUSTOMIZE 125 +#define ID_VIEW_CUSTOMIZE 126 +#define IDR_MAINFRAME 128 +#define IDR_MAINFRAME_256 129 +#define IDR_BezierCircleTYPE 130 +#define ID_WINDOW_MANAGER 131 +#define ID_VIEW_FILEVIEW 133 +#define ID_VIEW_CLASSVIEW 134 +#define ID_PROPERTIES 135 +#define ID_OPEN 136 +#define ID_OPEN_WITH 137 +#define ID_DUMMY_COMPILE 138 +#define ID_CLASS_ADD_MEMBER_FUNCTION 139 +#define ID_CLASS_ADD_MEMBER_VARIABLE 140 +#define ID_CLASS_DEFINITION 141 +#define ID_CLASS_PROPERTIES 142 +#define ID_NEW_FOLDER 143 +#define ID_SORT_MENU 144 +#define ID_SORTING_GROUPBYTYPE 145 +#define ID_SORTING_SORTALPHABETIC 146 +#define ID_SORTING_SORTBYTYPE 147 +#define ID_SORTING_SORTBYACCESS 148 +#define ID_VIEW_OUTPUTWND 149 +#define ID_VIEW_PROPERTIESWND 150 +#define ID_SORTPROPERTIES 151 +#define ID_PROPERTIES1 152 +#define ID_PROPERTIES2 153 +#define ID_EXPAND_ALL 154 +#define IDS_FILE_VIEW 155 +#define IDS_CLASS_VIEW 156 +#define IDS_OUTPUT_WND 157 +#define IDS_PROPERTIES_WND 158 +#define IDI_FILE_VIEW 161 +#define IDI_FILE_VIEW_HC 162 +#define IDI_CLASS_VIEW 163 +#define IDI_CLASS_VIEW_HC 164 +#define IDI_OUTPUT_WND 165 +#define IDI_OUTPUT_WND_HC 166 +#define IDI_PROPERTIES_WND 167 +#define IDI_PROPERTIES_WND_HC 168 +#define IDR_EXPLORER 169 +#define IDB_EXPLORER_24 170 +#define IDR_SORT 171 +#define IDB_SORT_24 172 +#define IDR_POPUP_SORT 173 +#define IDR_POPUP_EXPLORER 174 +#define IDB_FILE_VIEW 175 +#define IDB_FILE_VIEW_24 176 +#define IDB_CLASS_VIEW 177 +#define IDB_CLASS_VIEW_24 178 +#define IDR_MENU_IMAGES 179 +#define IDB_MENU_IMAGES_24 180 +#define ID_TOOLS_MACRO 181 +#define IDR_OUTPUT_POPUP 182 +#define IDR_PROPERTIES 183 +#define IDB_PROPERTIES_HC 184 +#define IDR_THEME_MENU 200 +#define ID_SET_STYLE 201 +#define ID_VIEW_APPLOOK_WIN_2000 205 +#define ID_VIEW_APPLOOK_OFF_XP 206 +#define ID_VIEW_APPLOOK_WIN_XP 207 +#define ID_VIEW_APPLOOK_OFF_2003 208 +#define ID_VIEW_APPLOOK_VS_2005 209 +#define ID_VIEW_APPLOOK_VS_2008 210 +#define ID_VIEW_APPLOOK_OFF_2007_BLUE 215 +#define ID_VIEW_APPLOOK_OFF_2007_BLACK 216 +#define ID_VIEW_APPLOOK_OFF_2007_SILVER 217 +#define ID_VIEW_APPLOOK_OFF_2007_AQUA 218 +#define ID_VIEW_APPLOOK_WINDOWS_7 219 +#define IDS_BUILD_TAB 300 +#define IDS_DEBUG_TAB 301 +#define IDS_FIND_TAB 302 +#define IDS_EXPLORER 305 +#define IDS_EDIT_MENU 306 + +// 新对象的下一组默认值 +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 310 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 310 +#define _APS_NEXT_COMMAND_VALUE 32771 +#endif +#endif diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/ViewTree.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/ViewTree.cpp" new file mode 100644 index 0000000..84996cb --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/ViewTree.cpp" @@ -0,0 +1,43 @@ + +#include "pch.h" +#include "framework.h" +#include "ViewTree.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CViewTree + +CViewTree::CViewTree() noexcept +{ +} + +CViewTree::~CViewTree() +{ +} + +BEGIN_MESSAGE_MAP(CViewTree, CTreeCtrl) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 消息处理程序 + +BOOL CViewTree::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult); + + NMHDR* pNMHDR = (NMHDR*)lParam; + ASSERT(pNMHDR != nullptr); + +#pragma warning(suppress : 26454) + if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips() != nullptr) + { + GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); + } + + return bRes; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/ViewTree.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/ViewTree.h" new file mode 100644 index 0000000..0267d80 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/ViewTree.h" @@ -0,0 +1,23 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 窗口 + +class CViewTree : public CTreeCtrl +{ +// 构造 +public: + CViewTree() noexcept; + +// 重写 +protected: + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + +// 实现 +public: + virtual ~CViewTree(); + +protected: + DECLARE_MESSAGE_MAP() +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/framework.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/pch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/pch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/pch.h" new file mode 100644 index 0000000..9660927 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/pch.h" @@ -0,0 +1,13 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" + +#endif //PCH_H diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/BezierCircle.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/BezierCircle.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/BezierCircle.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/BezierCircle.rc2" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/BezierCircle.rc2" new file mode 100644 index 0000000..1ac38a9 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/BezierCircle.rc2" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/BezierCircleDoc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/BezierCircleDoc.ico" new file mode 100644 index 0000000..96365d4 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/BezierCircleDoc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/Toolbar.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/Toolbar.bmp" new file mode 100644 index 0000000..d501723 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/Toolbar.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/Toolbar256.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/Toolbar256.bmp" new file mode 100644 index 0000000..91a2553 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/Toolbar256.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/class_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/class_view.ico" new file mode 100644 index 0000000..bf6b0dd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/class_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/class_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/class_view_hc.ico" new file mode 100644 index 0000000..3112bf2 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/class_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/classview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/classview.bmp" new file mode 100644 index 0000000..1e02aa1 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/classview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/classview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/classview_hc.bmp" new file mode 100644 index 0000000..6b22e78 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/classview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/explorer.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/explorer.bmp" new file mode 100644 index 0000000..01298ba Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/explorer.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/explorer_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/explorer_hc.bmp" new file mode 100644 index 0000000..697199d Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/explorer_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/file_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/file_view.ico" new file mode 100644 index 0000000..0f93f52 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/file_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/file_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/file_view_hc.ico" new file mode 100644 index 0000000..42ec435 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/file_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/fileview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/fileview.bmp" new file mode 100644 index 0000000..a2d62d0 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/fileview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/fileview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/fileview_hc.bmp" new file mode 100644 index 0000000..b60f483 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/fileview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/menuimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/menuimages.bmp" new file mode 100644 index 0000000..7771841 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/menuimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/menuimages_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/menuimages_hc.bmp" new file mode 100644 index 0000000..577926e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/menuimages_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/output_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/output_wnd.ico" new file mode 100644 index 0000000..d14f991 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/output_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/output_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/output_wnd_hc.ico" new file mode 100644 index 0000000..fdd27e8 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/output_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/properties.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/properties.bmp" new file mode 100644 index 0000000..72e2b29 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/properties.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/properties_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/properties_hc.bmp" new file mode 100644 index 0000000..d18a7ca Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/properties_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/properties_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/properties_wnd.ico" new file mode 100644 index 0000000..3611766 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/properties_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/properties_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/properties_wnd_hc.ico" new file mode 100644 index 0000000..1e06b64 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/properties_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/sort.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/sort.bmp" new file mode 100644 index 0000000..0307301 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/sort.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/sort_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/sort_hc.bmp" new file mode 100644 index 0000000..720e742 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/sort_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/userimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/userimages.bmp" new file mode 100644 index 0000000..affe657 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/res/userimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/targetver.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierCircle/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.aps" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.aps" new file mode 100644 index 0000000..5bbfd4e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.aps" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.cpp" new file mode 100644 index 0000000..751e480 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.cpp" @@ -0,0 +1,219 @@ + +// BezierSurface.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "afxwinappex.h" +#include "afxdialogex.h" +#include "BezierSurface.h" +#include "MainFrm.h" + +#include "BezierSurfaceDoc.h" +#include "BezierSurfaceView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CBezierSurfaceApp + +BEGIN_MESSAGE_MAP(CBezierSurfaceApp, CWinAppEx) + ON_COMMAND(ID_APP_ABOUT, &CBezierSurfaceApp::OnAppAbout) + // 基于文件的标准文档命令 + ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) + // 标准打印设置命令 + ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup) +END_MESSAGE_MAP() + + +// CBezierSurfaceApp 构造 + +CBezierSurfaceApp::CBezierSurfaceApp() noexcept +{ + m_bHiColorIcons = TRUE; + + + m_nAppLook = 0; + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; +#ifdef _MANAGED + // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则: + // 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。 + // 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。 + System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); +#endif + + // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式 + //为 CompanyName.ProductName.SubProduct.VersionInformation + SetAppID(_T("BezierSurface.AppID.NoVersion")); + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + +// 唯一的 CBezierSurfaceApp 对象 + +CBezierSurfaceApp theApp; + + +// CBezierSurfaceApp 初始化 + +BOOL CBezierSurfaceApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinAppEx::InitInstance(); + + + // 初始化 OLE 库 + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + + AfxEnableControlContainer(); + + EnableTaskbarInteraction(FALSE); + + // 使用 RichEdit 控件需要 AfxInitRichEdit2() + // AfxInitRichEdit2(); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) + + + InitContextMenuManager(); + + InitKeyboardManager(); + + InitTooltipManager(); + CMFCToolTipInfo ttParams; + ttParams.m_bVislManagerTheme = TRUE; + theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, + RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); + + // 注册应用程序的文档模板。 文档模板 + // 将用作文档、框架窗口和视图之间的连接 + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(CBezierSurfaceDoc), + RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 + RUNTIME_CLASS(CBezierSurfaceView)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + + + // 分析标准 shell 命令、DDE、打开文件操作的命令行 + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + + + // 调度在命令行中指定的命令。 如果 + // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + + // 唯一的一个窗口已初始化,因此显示它并对其进行更新 + m_pMainWnd->ShowWindow(SW_SHOW); + m_pMainWnd->UpdateWindow(); + return TRUE; +} + +int CBezierSurfaceApp::ExitInstance() +{ + //TODO: 处理可能已添加的附加资源 + AfxOleTerm(FALSE); + + return CWinAppEx::ExitInstance(); +} + +// CBezierSurfaceApp 消息处理程序 + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg() noexcept; + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + +// 用于运行对话框的应用程序命令 +void CBezierSurfaceApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +// CBezierSurfaceApp 自定义加载/保存方法 + +void CBezierSurfaceApp::PreLoadState() +{ + BOOL bNameValid; + CString strName; + bNameValid = strName.LoadString(IDS_EDIT_MENU); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); + bNameValid = strName.LoadString(IDS_EXPLORER); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EXPLORER); +} + +void CBezierSurfaceApp::LoadCustomState() +{ +} + +void CBezierSurfaceApp::SaveCustomState() +{ +} + +// CBezierSurfaceApp 消息处理程序 + + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.h" new file mode 100644 index 0000000..f509065 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.h" @@ -0,0 +1,40 @@ + +// BezierSurface.h: BezierSurface 应用程序的主头文件 +// +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// CBezierSurfaceApp: +// 有关此类的实现,请参阅 BezierSurface.cpp +// + +class CBezierSurfaceApp : public CWinAppEx +{ +public: + CBezierSurfaceApp() noexcept; + + +// 重写 +public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + +// 实现 + UINT m_nAppLook; + BOOL m_bHiColorIcons; + + virtual void PreLoadState(); + virtual void LoadCustomState(); + virtual void SaveCustomState(); + + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern CBezierSurfaceApp theApp; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.rc" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.rc" new file mode 100644 index 0000000..56fc410 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.rc" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.sln" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.sln" new file mode 100644 index 0000000..2049720 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BezierSurface", "BezierSurface.vcxproj", "{0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Debug|x64.ActiveCfg = Debug|x64 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Debug|x64.Build.0 = Debug|x64 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Debug|x86.ActiveCfg = Debug|Win32 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Debug|x86.Build.0 = Debug|Win32 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Release|x64.ActiveCfg = Release|x64 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Release|x64.Build.0 = Release|x64 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Release|x86.ActiveCfg = Release|Win32 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E8A2D4C1-10AA-44DC-8B3A-EFDF8730ECBC} + EndGlobalSection +EndGlobal diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.vcxproj" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.vcxproj" new file mode 100644 index 0000000..d370301 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.vcxproj" @@ -0,0 +1,269 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C} + MFCProj + BezierSurface + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.vcxproj.filters" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.vcxproj.filters" new file mode 100644 index 0000000..808b424 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.vcxproj.filters" @@ -0,0 +1,225 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.vcxproj.user" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.vcxproj.user" new file mode 100644 index 0000000..6d289ab --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurface.vcxproj.user" @@ -0,0 +1,6 @@ + + + + BezierSurface.rc + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurfaceDoc.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurfaceDoc.cpp" new file mode 100644 index 0000000..3581e97 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurfaceDoc.cpp" @@ -0,0 +1,138 @@ + +// BezierSurfaceDoc.cpp: CBezierSurfaceDoc 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "BezierSurface.h" +#endif + +#include "BezierSurfaceDoc.h" + +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CBezierSurfaceDoc + +IMPLEMENT_DYNCREATE(CBezierSurfaceDoc, CDocument) + +BEGIN_MESSAGE_MAP(CBezierSurfaceDoc, CDocument) +END_MESSAGE_MAP() + + +// CBezierSurfaceDoc 构造/析构 + +CBezierSurfaceDoc::CBezierSurfaceDoc() noexcept +{ + // TODO: 在此添加一次性构造代码 + +} + +CBezierSurfaceDoc::~CBezierSurfaceDoc() +{ +} + +BOOL CBezierSurfaceDoc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: 在此添加重新初始化代码 + // (SDI 文档将重用该文档) + + return TRUE; +} + + + + +// CBezierSurfaceDoc 序列化 + +void CBezierSurfaceDoc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: 在此添加存储代码 + } + else + { + // TODO: 在此添加加载代码 + } +} + +#ifdef SHARED_HANDLERS + +// 缩略图的支持 +void CBezierSurfaceDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds) +{ + // 修改此代码以绘制文档数据 + dc.FillSolidRect(lprcBounds, RGB(255, 255, 255)); + + CString strText = _T("TODO: implement thumbnail drawing here"); + LOGFONT lf; + + CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + pDefaultGUIFont->GetLogFont(&lf); + lf.lfHeight = 36; + + CFont fontDraw; + fontDraw.CreateFontIndirect(&lf); + + CFont* pOldFont = dc.SelectObject(&fontDraw); + dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK); + dc.SelectObject(pOldFont); +} + +// 搜索处理程序的支持 +void CBezierSurfaceDoc::InitializeSearchContent() +{ + CString strSearchContent; + // 从文档数据设置搜索内容。 + // 内容部分应由“;”分隔 + + // 例如: strSearchContent = _T("point;rectangle;circle;ole object;"); + SetSearchContent(strSearchContent); +} + +void CBezierSurfaceDoc::SetSearchContent(const CString& value) +{ + if (value.IsEmpty()) + { + RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); + } + else + { + CMFCFilterChunkValueImpl *pChunk = nullptr; + ATLTRY(pChunk = new CMFCFilterChunkValueImpl); + if (pChunk != nullptr) + { + pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT); + SetChunkValue(pChunk); + } + } +} + +#endif // SHARED_HANDLERS + +// CBezierSurfaceDoc 诊断 + +#ifdef _DEBUG +void CBezierSurfaceDoc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CBezierSurfaceDoc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// CBezierSurfaceDoc 命令 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurfaceDoc.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurfaceDoc.h" new file mode 100644 index 0000000..9012779 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurfaceDoc.h" @@ -0,0 +1,48 @@ + +// BezierSurfaceDoc.h: CBezierSurfaceDoc 类的接口 +// + + +#pragma once + + +class CBezierSurfaceDoc : public CDocument +{ +protected: // 仅从序列化创建 + CBezierSurfaceDoc() noexcept; + DECLARE_DYNCREATE(CBezierSurfaceDoc) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); +#ifdef SHARED_HANDLERS + virtual void InitializeSearchContent(); + virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds); +#endif // SHARED_HANDLERS + +// 实现 +public: + virtual ~CBezierSurfaceDoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// 生成的消息映射函数 +protected: + DECLARE_MESSAGE_MAP() + +#ifdef SHARED_HANDLERS + // 用于为搜索处理程序设置搜索内容的 Helper 函数 + void SetSearchContent(const CString& value); +#endif // SHARED_HANDLERS +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurfaceView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurfaceView.cpp" new file mode 100644 index 0000000..588922b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurfaceView.cpp" @@ -0,0 +1,257 @@ + +// BezierSurfaceView.cpp: CBezierSurfaceView 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "BezierSurface.h" +#endif + +#include "BezierSurfaceDoc.h" +#include "BezierSurfaceView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CBezierSurfaceView + +IMPLEMENT_DYNCREATE(CBezierSurfaceView, CView) + +BEGIN_MESSAGE_MAP(CBezierSurfaceView, CView) + // 标准打印命令 + ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CBezierSurfaceView::OnFilePrintPreview) + ON_WM_CONTEXTMENU() + ON_WM_RBUTTONUP() + ON_COMMAND(ID_32771, &CBezierSurfaceView::GraphicAnimation) + ON_WM_KEYDOWN() + ON_WM_KEYUP() + ON_WM_TIMER() + ON_UPDATE_COMMAND_UI(ID_32771, &CBezierSurfaceView::OnUpdateGraphicAnimation) +END_MESSAGE_MAP() + +// CBezierSurfaceView 构造/析构 + +CBezierSurfaceView::CBezierSurfaceView() noexcept +{ + // TODO: 在此处添加构造代码 + bPlay = FALSE; + double R = 200; + double m = 0.5523; + CP2 P2[7];//二维控制点 + P2[0] = CP2(0, -1);//7 个二维点模拟半圆 + P2[1] = CP2(m, -1); + P2[2] = CP2(1, -m); + P2[3] = CP2(1, 0); + P2[4] = CP2(1, m); + P2[5] = CP2(m, 1); + P2[6] = CP2(0, 1); + CP3 DownPoint[4];//下半圆的三维控制点 + DownPoint[0] = CP3(P2[0].x, P2[0].y, 0.0); + DownPoint[1] = CP3(P2[1].x, P2[1].y, 0.0); + DownPoint[2] = CP3(P2[2].x, P2[2].y, 0.0); + DownPoint[3] = CP3(P2[3].x, P2[3].y, 0.0); + revoDown.ReadCubicBezierControlPoint(DownPoint); + tranDown.SetMatrix(revoDown.GetVertexArrayName(), 48); + tranDown.Scale(R, R, R); + CP3 UpPoint[4];//上半圆的三维控制点 + UpPoint[0] = CP3(P2[3].x, P2[3].y, 0.0); + UpPoint[1] = CP3(P2[4].x, P2[4].y, 0.0); + UpPoint[2] = CP3(P2[5].x, P2[5].y, 0.0); + UpPoint[3] = CP3(P2[6].x, P2[6].y, 0.0); + revoUp.ReadCubicBezierControlPoint(UpPoint); + tranUp.SetMatrix(revoUp.GetVertexArrayName(), 48); + tranUp.Scale(R, R, R); +} + +CBezierSurfaceView::~CBezierSurfaceView() +{ +} + +BOOL CBezierSurfaceView::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return CView::PreCreateWindow(cs); +} + +// CBezierSurfaceView 绘图 + +void CBezierSurfaceView::OnDraw(CDC* pDC) +{ + CBezierSurfaceDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + + // TODO: 在此处为本机数据添加绘制代码 + DoubleBuffer(pDC); //双缓冲 +} + +void CBezierSurfaceView::DoubleBuffer(CDC* pDC)//双缓冲 +{ + CRect rect;//定义客户区矩形 + GetClientRect(&rect);//获得客户区的大小 + pDC->SetMapMode(MM_ANISOTROPIC);//pDC自定义坐标系 + pDC->SetWindowExt(rect.Width(), rect.Height());//设置窗口范围 + pDC->SetViewportExt(rect.Width(), -rect.Height());//设置视区范围,x轴水平向右,y轴垂直向上 + pDC->SetViewportOrg(rect.Width() / 2, rect.Height() / 2);//客户区中心为原点 + CDC memDC;//内存DC + memDC.CreateCompatibleDC(pDC);//创建一个与显示pDC兼容的内存memDC + CBitmap NewBitmap, * pOldBitmap;//内存中承载的临时位图 + NewBitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());//创建兼容位图 + pOldBitmap = memDC.SelectObject(&NewBitmap);//将兼容位图选入memDC + memDC.FillSolidRect(rect, pDC->GetBkColor());//按原来背景填充客户区,否则是黑色 + memDC.SetMapMode(MM_ANISOTROPIC);//memDC自定义坐标系 + memDC.SetWindowExt(rect.Width(), rect.Height()); + memDC.SetViewportExt(rect.Width(), -rect.Height()); + memDC.SetViewportOrg(rect.Width() / 2, rect.Height() / 2); + rect.OffsetRect(-rect.Width() / 2, -rect.Height() / 2); + DrawObject(&memDC);//向memDC绘制图形 + pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memDC, -rect.Width() / 2, -rect.Height() / 2, SRCCOPY);//将内存memDC中的位图拷贝到显示pDC中 + memDC.SelectObject(pOldBitmap);//恢复位图 + NewBitmap.DeleteObject();//删除位图 +} + +void CBezierSurfaceView::DrawObject(CDC* pDC)//绘制图形 +{ + revoUp.DrawRevolutionSurface(pDC); + revoDown.DrawRevolutionSurface(pDC); +} + +// CBezierSurfaceView 打印 + + +void CBezierSurfaceView::OnFilePrintPreview() +{ +#ifndef SHARED_HANDLERS + AFXPrintPreview(this); +#endif +} + +BOOL CBezierSurfaceView::OnPreparePrinting(CPrintInfo* pInfo) +{ + // 默认准备 + return DoPreparePrinting(pInfo); +} + +void CBezierSurfaceView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加额外的打印前进行的初始化过程 +} + +void CBezierSurfaceView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加打印后进行的清理过程 +} + +void CBezierSurfaceView::OnRButtonUp(UINT /* nFlags */, CPoint point) +{ + ClientToScreen(&point); + OnContextMenu(this, point); +} + +void CBezierSurfaceView::OnContextMenu(CWnd* /* pWnd */, CPoint point) +{ +#ifndef SHARED_HANDLERS + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE); +#endif +} + + +// CBezierSurfaceView 诊断 + +#ifdef _DEBUG +void CBezierSurfaceView::AssertValid() const +{ + CView::AssertValid(); +} + +void CBezierSurfaceView::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +CBezierSurfaceDoc* CBezierSurfaceView::GetDocument() const // 非调试版本是内联的 +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBezierSurfaceDoc))); + return (CBezierSurfaceDoc*)m_pDocument; +} +#endif //_DEBUG + + +// CBezierSurfaceView 消息处理程序 + + +void CBezierSurfaceView::GraphicAnimation() +{ + // TODO: 在此添加命令处理程序代码 + bPlay = !bPlay; + if (bPlay)//设置定时器 + SetTimer(1, 150, NULL); + else + KillTimer(1); +} + + +void CBezierSurfaceView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + // TODO: 在此添加消息处理程序代码和/或调用默认值 + switch (nChar) + { + case VK_UP: + Alpha = +2; + tranUp.RotateX(Alpha); + tranDown.RotateX(Alpha); + break; + case VK_DOWN: + Alpha = -2; + tranUp.RotateX(Alpha); + tranDown.RotateX(Alpha); + break; + case VK_LEFT: + Beta = -2; + tranUp.RotateY(Beta); + tranDown.RotateY(Beta); + break; + case VK_RIGHT: + Beta = 2; + tranUp.RotateY(Beta); + tranDown.RotateY(Beta); + break; + default: + break; + } + Invalidate(FALSE); + CView::OnKeyDown(nChar, nRepCnt, nFlags); +} + + +void CBezierSurfaceView::OnTimer(UINT_PTR nIDEvent) +{ + // TODO: 在此添加命令更新用户界面处理程序代码 + Alpha = 2; Beta = 2; + tranUp.RotateX(Alpha); + tranDown.RotateX(Alpha); + tranUp.RotateY(Beta); + tranDown.RotateY(Beta); + Invalidate(FALSE); + CView::OnTimer(nIDEvent); +} + + +void CBezierSurfaceView::OnUpdateGraphicAnimation(CCmdUI* pCmdUI) +{ + // TODO: 在此添加命令更新用户界面处理程序代码 + if (bPlay) + pCmdUI->SetCheck(TRUE); + else + pCmdUI->SetCheck(FALSE); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurfaceView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurfaceView.h" new file mode 100644 index 0000000..c0407f5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/BezierSurfaceView.h" @@ -0,0 +1,63 @@ + +// BezierSurfaceView.h: CBezierSurfaceView 类的接口 +// + +#pragma once +#include"CTrans3.h" +#include"CRevolution.h" + +class CBezierSurfaceView : public CView +{ +protected: // 仅从序列化创建 + CBezierSurfaceView() noexcept; + DECLARE_DYNCREATE(CBezierSurfaceView) + +// 特性 +public: + CBezierSurfaceDoc* GetDocument() const; + +// 操作 +public: + +// 重写 +public: + virtual void OnDraw(CDC* pDC); // 重写以绘制该视图 + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// 实现 +public: + virtual ~CBezierSurfaceView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + bool bPlay; + CRevolution revoDown, revoUp; + double Alpha, Beta; + CTrans3 tranUp, tranDown; + void DoubleBuffer(CDC* pDC); + void DrawObject(CDC* pDC); +// 生成的消息映射函数 +protected: + afx_msg void OnFilePrintPreview(); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + DECLARE_MESSAGE_MAP() +public: + afx_msg void GraphicAnimation(); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnTimer(UINT_PTR nIDEvent); + afx_msg void OnUpdateGraphicAnimation(CCmdUI* pCmdUI); +}; + +#ifndef _DEBUG // BezierSurfaceView.cpp 中的调试版本 +inline CBezierSurfaceDoc* CBezierSurfaceView::GetDocument() const + { return reinterpret_cast(m_pDocument); } +#endif + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CBezierPatch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CBezierPatch.cpp" new file mode 100644 index 0000000..21771a0 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CBezierPatch.cpp" @@ -0,0 +1,157 @@ +#include "pch.h" +#include "CBezierPatch.h" +#define ROUND(d) int(d + 0.5) +CBezierPatch::CBezierPatch(void) +{ + ReNumber = 0; +} +CBezierPatch::~CBezierPatch(void) +{ +} +void CBezierPatch::ReadControlPoint(CP3 CtrPt[4][4], int ReNumber) +{ + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + this->CtrPt[i][j] = CtrPt[i][j]; + this->ReNumber = ReNumber; +} +void CBezierPatch::DrawCurvedPatch(CDC* pDC) +{ + CMesh Mesh; + Mesh.BL = CT2(0, 0), Mesh.BR = CT2(1, 0);//ʼuv + Mesh.TR = CT2(1, 1), Mesh.TL = CT2(0, 1); + Recursion(pDC, ReNumber, Mesh);//ݹ麯 +} +void CBezierPatch::Recursion(CDC* pDC, int ReNumber, CMesh Mesh)//ݹ麯 +{ + if (0 == ReNumber) + { + Tessellation(Mesh);//ϸ棬uvתΪxy + DrawFacet(pDC);//Сƽ + return; + } + else + { + CT2 Mid = (Mesh.BL + Mesh.TR) / 2.0; + CMesh SubMesh[4];//һΪĸ + //ӳ + SubMesh[0].BL = Mesh.BL; + SubMesh[0].BR = CT2(Mid.u, Mesh.BL.v); + SubMesh[0].TR = CT2(Mid.u, Mid.v); + SubMesh[0].TL = CT2(Mesh.BL.u, Mid.v); + //ӳ + SubMesh[1].BL = SubMesh[0].BR; + SubMesh[1].BR = Mesh.BR; + SubMesh[1].TR = CT2(Mesh.BR.u, Mid.v); + SubMesh[1].TL = SubMesh[0].TR; + //ӳ + SubMesh[2].BL = SubMesh[1].TL; + SubMesh[2].BR = SubMesh[1].TR; + SubMesh[2].TR = Mesh.TR; + SubMesh[2].TL = CT2(Mid.u, Mesh.TR.v); + //ӳ + SubMesh[3].BL = SubMesh[0].TL; + SubMesh[3].BR = SubMesh[2].BL; + SubMesh[3].TR = SubMesh[2].TL; + SubMesh[3].TL = Mesh.TL; + Recursion(pDC, ReNumber - 1, SubMesh[0]);//ݹ4 + Recursion(pDC, ReNumber - 1, SubMesh[1]); + Recursion(pDC, ReNumber - 1, SubMesh[2]); + Recursion(pDC, ReNumber - 1, SubMesh[3]); + } +} +void CBezierPatch::Tessellation(CMesh Mesh)//ϸ溯 +{ + double M[4][4];//ϵM + M[0][0] = -1, M[0][1] = 3, M[0][2] = -3, M[0][3] = 1; + M[1][0] = 3, M[1][1] = -6, M[1][2] = 3, M[1][3] = 0; + M[2][0] = -3, M[2][1] = 3, M[2][2] = 0, M[2][3] = 0; + M[3][0] = 1, M[3][1] = 0, M[3][2] = 0, M[3][3] = 0; + CP3 P3[4][4];//߼ÿƵ + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + P3[i][j] = CtrPt[i][j]; + LeftMultiplyMatrix(M, P3);//ϵά + TransposeMatrix(M);//תþ + RightMultiplyMatrix(P3, M);//ϵҳά + double u0, u1, u2, u3, v0, v1, v2, v3;//uv + double u[4] = { Mesh.BL.u,Mesh.BR.u ,Mesh.TR.u ,Mesh.TL.u }; + double v[4] = { Mesh.BL.v,Mesh.BR.v ,Mesh.TR.v ,Mesh.TL.v }; + for (int i = 0; i < 4; i++) + { + u3 = pow(u[i], 3.0), u2 = pow(u[i], 2.0), u1 = u[i], u0 = 1; + v3 = pow(v[i], 3.0), v2 = pow(v[i], 2.0), v1 = v[i], v0 = 1; + CP3 Pt = (u3 * P3[0][0] + u2 * P3[1][0] + u1 * P3[2][0] + u0 * P3[3][0]) * v3 + + (u3 * P3[0][1] + u2 * P3[1][1] + u1 * P3[2][1] + u0 * P3[3][1]) * v2 + + (u3 * P3[0][2] + u2 * P3[1][2] + u1 * P3[2][2] + u0 * P3[3][2]) * v1 + + (u3 * P3[0][3] + u2 * P3[1][3] + u1 * P3[2][3] + u0 * P3[3][3]) * v0; + quadrP[i] = Pt; + } +} +void CBezierPatch::DrawFacet(CDC* pDC) +{ + CP2 ScreenPoint[4];//άͶӰ + for (int nPoint = 0; nPoint < 4; nPoint++) + ScreenPoint[nPoint] = quadrP[nPoint];//ͶӰ + pDC->MoveTo(ROUND(ScreenPoint[0].x), ROUND(ScreenPoint[0].y)); + pDC->LineTo(ROUND(ScreenPoint[1].x), ROUND(ScreenPoint[1].y)); + pDC->LineTo(ROUND(ScreenPoint[2].x), ROUND(ScreenPoint[2].y)); + pDC->LineTo(ROUND(ScreenPoint[3].x), ROUND(ScreenPoint[3].y)); + pDC->LineTo(ROUND(ScreenPoint[0].x), ROUND(ScreenPoint[0].y)); +} +void CBezierPatch::LeftMultiplyMatrix(double M[4][4], CP3 P[4][4])//˾M*P +{ + CP3 PTemp[4][4];//ʱ + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + PTemp[i][j] = M[i][0] * P[0][j] + M[i][1] * P[1][j] + M[i][2] * P[2][j] + M[i][3] + * P[3][j]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + P[i][j] = PTemp[i][j]; +} +void CBezierPatch::RightMultiplyMatrix(CP3 P[4][4], double M[4][4])//ҳ˾P*M +{ + CP3 PTemp[4][4];//ʱ + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + PTemp[i][j] = P[i][0] * M[0][j] + P[i][1] * M[1][j] + P[i][2] * M[2][j] + P[i][3] + * M[3][j]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + P[i][j] = PTemp[i][j]; +} +void CBezierPatch::TransposeMatrix(double M[4][4])//תþ +{ + double PTemp[4][4];//ʱ + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + PTemp[j][i] = M[i][j]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + M[i][j] = PTemp[i][j]; +} +void CBezierPatch::DrawControlGrid(CDC* pDC)//ƿ +{ + CP2 P2[4][4];//άƵ + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + P2[i][j] = CtrPt[i][j];//ͶӰ + CPen NewPen, * pOldPen; + NewPen.CreatePen(PS_SOLID, 3, RGB(0, 128, 0)); + pOldPen = pDC->SelectObject(&NewPen); + for (int i = 0; i < 4; i++) + { + pDC->MoveTo(ROUND(P2[i][0].x), ROUND(P2[i][0].y)); + for (int j = 1; j < 4; j++) + pDC->LineTo(ROUND(P2[i][j].x), ROUND(P2[i][j].y)); + } + for (int j = 0; j < 4; j++) + { + pDC->MoveTo(ROUND(P2[0][j].x), ROUND(P2[0][j].y)); + for (int i = 1; i < 4; i++) + pDC->LineTo(ROUND(P2[i][j].x), ROUND(P2[i][j].y)); + } + pDC->SelectObject(pOldPen); + NewPen.DeleteObject(); +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CBezierPatch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CBezierPatch.h" new file mode 100644 index 0000000..70b984f --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CBezierPatch.h" @@ -0,0 +1,23 @@ +#pragma once +#include"CMesh.h" +#include"CP3.h" +class CBezierPatch +{ +public: + CBezierPatch(void); + virtual ~CBezierPatch(void); + void ReadControlPoint(CP3 CtrPt[4][4], int ReNumber);//16 Ƶ͵ݹ + void DrawCurvedPatch(CDC* pDC);// + void DrawControlGrid(CDC* pDC);//ƿ +private: + void Recursion(CDC* pDC, int ReNumber, CMesh Mesh);//ݹ麯 + void Tessellation(CMesh Mesh);//ϸֺ + void DrawFacet(CDC* pDC);//ı + void LeftMultiplyMatrix(double M[4][4], CP3 P[4][4]);//˶ + void RightMultiplyMatrix(CP3 P[4][4], double M[4][4]);//ҳ˶ + void TransposeMatrix(double M[4][4]); +private: + int ReNumber;//ݹ + CP3 quadrP[4];//ı + CP3 CtrPt[4][4];//16 Ƶ +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CMesh.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CMesh.cpp" new file mode 100644 index 0000000..fdaa3e2 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CMesh.cpp" @@ -0,0 +1,2 @@ +#include "pch.h" +#include "CMesh.h" diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CMesh.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CMesh.h" new file mode 100644 index 0000000..3fc719e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CMesh.h" @@ -0,0 +1,10 @@ +#pragma once +#include"CT2.h" +class CMesh +{ +public: + CMesh(void) {} + virtual ~CMesh(void) {} +public: + CT2 BL, BR, TR, TL;//ıε4 ǵ +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CP2.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CP2.cpp" new file mode 100644 index 0000000..a537eb7 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CP2.cpp" @@ -0,0 +1,74 @@ +#include "pch.h" +#include "CP2.h" +CP2::CP2(void) +{ + x = 0.0; + y = 0.0; + w = 1.0; +} +CP2::~CP2(void) +{ +} +CP2::CP2(double x, double y) +{ + this->x = x; + this->y = y; + this->w = 1.0; +} +CP2 operator + (const CP2& p0, const CP2& p1)// +{ + CP2 result; + result.x = p0.x + p1.x; + result.y = p0.y + p1.y; + return result; +} +CP2 operator - (const CP2& p0, const CP2& p1)// +{ + CP2 result; + result.x = p0.x - p1.x; + result.y = p0.y - p1.y; + return result; +} +CP2 operator * (const CP2& p, double scalar)//ͳĻ +{ + return CP2(p.x * scalar, p.y * scalar); +} +CP2 operator * (double scalar, const CP2& p)//ͳĻ +{ + return CP2(p.x * scalar, p.y * scalar); +} +CP2 operator / (const CP2& p, double scalar)// +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + CP2 result; + result.x = p.x / scalar; + result.y = p.y / scalar; + return result; +} +CP2 operator+=(CP2& p0, CP2& p1) +{ + p0.x += p1.x; + p0.y += p1.y; + return p0; +} +CP2 operator-=(CP2& p0, CP2& p1) +{ + p0.x -= p1.x; + p0.y -= p1.y; + return p0; +} +CP2 operator*=(CP2& p, double scalar) +{ + p.x *= scalar; + p.y *= scalar; + return p; +} +CP2 operator/=(CP2& p, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + p.x /= scalar; + p.y /= scalar; + return p; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CP2.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CP2.h" new file mode 100644 index 0000000..fc32cb4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CP2.h" @@ -0,0 +1,23 @@ +#pragma once +class CP2 +{ +public: + CP2(void); + virtual ~CP2(void); + CP2(double x, double y); + friend CP2 operator + (const CP2& p0, const CP2& p1);// + friend CP2 operator - (const CP2& p0, const CP2& p1); + friend CP2 operator * (const CP2& p, double scalar); + friend CP2 operator * (double scalar, const CP2& p); + friend CP2 operator / (const CP2& p, double scalar); + friend CP2 operator += (CP2& p0, CP2& p1); + friend CP2 operator -= (CP2& p0, CP2& p1); + friend CP2 operator *= (CP2& p, double scalar); + friend CP2 operator /= (CP2& p, double scalar); +public: + double x;//ֱ߶ζ˵x + double y;//ֱ߶ζ˵y + double w;// +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CP3.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CP3.cpp" new file mode 100644 index 0000000..d399eaf --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CP3.cpp" @@ -0,0 +1,47 @@ +#include "pch.h" +#include "CP3.h" +CP3::CP3(void) +{ + x = 0, y = 0, z = 0, w = 1; +} +CP3::CP3(double x, double y, double z) :CP2(x, y) +{ + this->z = z; +} +CP3::~CP3(void) +{ +} +CP3 operator + (const CP3& p0, const CP3& p1) +{ + CP3 result; + result.x = p0.x + p1.x; + result.y = p0.y + p1.y; + result.z = p0.z + p1.z; + return result; +} +CP3 operator -(const CP3& p0, const CP3& p1) +{ + CP3 result; + result.x = p0.x - p1.x; + result.y = p0.y - p1.y; + result.z = p0.z - p1.z; + return result; +} +CP3 operator *(const CP3& p, double scalar) +{ + return CP3(p.x * scalar, p.y * scalar, p.z * scalar); +} +CP3 operator *(double scalar, const CP3& p) +{ + return CP3(p.x * scalar, p.y * scalar, p.z * scalar); +} +CP3 operator /(const CP3& p, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + CP3 result; + result.x = p.x / scalar; + result.y = p.y / scalar; + result.z = p.z / scalar; + return result; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CP3.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CP3.h" new file mode 100644 index 0000000..4250bd0 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CP3.h" @@ -0,0 +1,17 @@ +#pragma once +#include "CP2.h" +class CP3 :public CP2 +{ +public: + CP3(void); + virtual ~CP3(void); + CP3(double x, double y, double z); + friend CP3 operator +(const CP3& p0, const CP3& p1); + friend CP3 operator -(const CP3& p0, const CP3& p1); + friend CP3 operator *(const CP3& p, double scalar); + friend CP3 operator *(double scalar, const CP3& p); + friend CP3 operator /(const CP3& p, double scalar); +public: + double z; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CRevolution.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CRevolution.cpp" new file mode 100644 index 0000000..eedda87 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CRevolution.cpp" @@ -0,0 +1,110 @@ +#include "pch.h" +#include "CRevolution.h" +void CRevolution::ReadCubicBezierControlPoint(CP3 P[4])//Bezier 4 Ƶʼ +{ + for (int i = 0; i < 4; i++) + this->P[i] = P[i]; + //תݽṹ + ReadVertex(); + ReadPatch(); +} +CP3* CRevolution::GetVertexArrayName(void)//õ +{ + return V; +} +void CRevolution::ReadVertex(void)//תпƵ +{ + const double m = 0.5523;//ħ + //תһȦҪ4 ,һ16 ,ڶ12 㣬12 㣬ĸ8 㣬 + + //һƬyo + V[0] = P[0]; + V[1] = P[1]; + V[2] = P[2]; + V[3] = P[3]; + V[4].x = V[0].x, V[4].y = V[0].y, V[4].z = -V[0].x * m; + V[5].x = V[1].x, V[5].y = V[1].y, V[5].z = -V[1].x * m; + V[6].x = V[2].x, V[6].y = V[2].y, V[6].z = -V[2].x * m; + V[7].x = V[3].x, V[7].y = V[3].y, V[7].z = -V[3].x * m; + V[8].x = V[0].x * m, V[8].y = V[0].y, V[8].z = -V[0].x; + V[9].x = V[1].x * m, V[9].y = V[1].y, V[9].z = -V[1].x; + V[10].x = V[2].x * m, V[10].y = V[2].y, V[10].z = -V[2].x; + V[11].x = V[3].x * m, V[11].y = V[3].y, V[11].z = -V[3].x; + V[12].x = V[0].z, V[12].y = V[0].y, V[12].z = -V[0].x; + V[13].x = V[1].z, V[13].y = V[1].y, V[13].z = -V[1].x; + V[14].x = V[2].z, V[14].y = V[2].y, V[14].z = -V[2].x; + V[15].x = V[3].z, V[15].y = V[3].y, V[15].z = -V[3].x; + //ڶƬ + V[16].x = -V[0].x * m, V[16].y = V[0].y, V[16].z = -V[0].x; + V[17].x = -V[1].x * m, V[17].y = V[1].y, V[17].z = -V[1].x; + V[18].x = -V[2].x * m, V[18].y = V[2].y, V[18].z = -V[2].x; + V[19].x = -V[3].x * m, V[19].y = V[3].y, V[19].z = -V[3].x; + V[20].x = -V[0].x, V[20].y = V[0].y, V[20].z = -V[0].x * m; + V[21].x = -V[1].x, V[21].y = V[1].y, V[21].z = -V[1].x * m; + V[22].x = -V[2].x, V[22].y = V[2].y, V[22].z = -V[2].x * m; + V[23].x = -V[3].x, V[23].y = V[3].y, V[23].z = -V[3].x * m; + V[24].x = -V[0].x, V[24].y = V[0].y, V[24].z = V[0].z; + V[25].x = -V[1].x, V[25].y = V[1].y, V[25].z = V[1].z; + V[26].x = -V[2].x, V[26].y = V[2].y, V[26].z = V[2].z; + V[27].x = -V[3].x, V[27].y = V[3].y, V[27].z = V[3].z; + //Ƭ + V[28].x = -V[0].x, V[28].y = V[0].y, V[28].z = V[0].x * m; + V[29].x = -V[1].x, V[29].y = V[1].y, V[29].z = V[1].x * m; + V[30].x = -V[2].x, V[30].y = V[2].y, V[30].z = V[2].x * m; + V[31].x = -V[3].x, V[31].y = V[3].y, V[31].z = V[3].x * m; + V[32].x = -V[0].x * m, V[32].y = V[0].y, V[32].z = V[0].x; + V[33].x = -V[1].x * m, V[33].y = V[1].y, V[33].z = V[1].x; + V[34].x = -V[2].x * m, V[34].y = V[2].y, V[34].z = V[2].x; + V[35].x = -V[3].x * m, V[35].y = V[3].y, V[35].z = V[3].x; + V[36].x = V[0].z, V[36].y = V[0].y, V[36].z = V[0].x; + V[37].x = V[1].z, V[37].y = V[1].y, V[37].z = V[1].x; + V[38].x = V[2].z, V[38].y = V[2].y, V[38].z = V[2].x; + V[39].x = V[3].z, V[39].y = V[3].y, V[39].z = V[3].x; + //ĿƬ + V[40].x = V[0].x * m, V[40].y = V[0].y, V[40].z = V[0].x; + V[41].x = V[1].x * m, V[41].y = V[1].y, V[41].z = V[1].x; + V[42].x = V[2].x * m, V[42].y = V[2].y, V[42].z = V[2].x; + V[43].x = V[3].x * m, V[43].y = V[3].y, V[43].z = V[3].x; + V[44].x = V[0].x, V[44].y = V[0].y, V[44].z = V[0].x * m; + V[45].x = V[1].x, V[45].y = V[1].y, V[45].z = V[1].x * m; + V[46].x = V[2].x, V[46].y = V[2].y, V[46].z = V[2].x * m; + V[47].x = V[3].x, V[47].y = V[3].y, V[47].z = V[3].x * m; +} +void CRevolution::ReadPatch(void)//Ƭ +{ + //1Ƭ + S[0].pIndex[0][0] = 0; S[0].pIndex[0][1] = 1; S[0].pIndex[0][2] = 2; S[0].pIndex[0][3] = 3; + S[0].pIndex[1][0] = 4; S[0].pIndex[1][1] = 5; S[0].pIndex[1][2] = 6; S[0].pIndex[1][3] = 7; + S[0].pIndex[2][0] = 8; S[0].pIndex[2][1] = 9; S[0].pIndex[2][2] = 10; S[0].pIndex[2][3] = 11; + S[0].pIndex[3][0] = 12; S[0].pIndex[3][1] = 13; S[0].pIndex[3][2] = 14; S[0].pIndex[3][3] = 15; + //2 Ƭ + S[1].pIndex[0][0] = 12; S[1].pIndex[0][1] = 13; S[1].pIndex[0][2] = 14; S[1].pIndex[0][3] = 15; + S[1].pIndex[1][0] = 16; S[1].pIndex[1][1] = 17; S[1].pIndex[1][2] = 18; S[1].pIndex[1][3] = 19; + S[1].pIndex[2][0] = 20; S[1].pIndex[2][1] = 21; S[1].pIndex[2][2] = 22; S[1].pIndex[2][3] = 23; + S[1].pIndex[3][0] = 24; S[1].pIndex[3][1] = 25; S[1].pIndex[3][2] = 26; S[1].pIndex[3][3] = 27; + //3 Ƭ + S[2].pIndex[0][0] = 24; S[2].pIndex[0][1] = 25; S[2].pIndex[0][2] = 26; S[2].pIndex[0][3] = 27; + S[2].pIndex[1][0] = 28; S[2].pIndex[1][1] = 29; S[2].pIndex[1][2] = 30; S[2].pIndex[1][3] = 31; + S[2].pIndex[2][0] = 32; S[2].pIndex[2][1] = 33; S[2].pIndex[2][2] = 34; S[2].pIndex[2][3] = 35; + S[2].pIndex[3][0] = 36; S[2].pIndex[3][1] = 37; S[2].pIndex[3][2] = 38; S[2].pIndex[3][3] = 39; + //4 Ƭ + S[3].pIndex[0][0] = 36; S[3].pIndex[0][1] = 37; S[3].pIndex[0][2] = 38; S[3].pIndex[0][3] = 39; + S[3].pIndex[1][0] = 40; S[3].pIndex[1][1] = 41; S[3].pIndex[1][2] = 42; S[3].pIndex[1][3] = 43; + S[3].pIndex[2][0] = 44; S[3].pIndex[2][1] = 45; S[3].pIndex[2][2] = 46; S[3].pIndex[2][3] = 47; + S[3].pIndex[3][0] = 0; S[3].pIndex[3][1] = 1; S[3].pIndex[3][2] = 2; S[3].pIndex[3][3] = 3; +} +void CRevolution::DrawRevolutionSurface(CDC* pDC)//ƻת +{ + CP3 Point[4][4];//˫Ƭ16 Ƶ + for (int nPatch = 0; nPatch < 4; nPatch++) + { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + Point[i][j] = V[S[nPatch].pIndex[i][j]]; + int nRecursiveDepth = 3;//ݹ + CBezierPatch patch;//˫ + patch.ReadControlPoint(Point, nRecursiveDepth); + patch.DrawCurvedPatch(pDC); + //patch.DrawControlGrid(pDC); + } +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CRevolution.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CRevolution.h" new file mode 100644 index 0000000..87281c3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CRevolution.h" @@ -0,0 +1,19 @@ +#pragma once +#include "Patch.h" +#include"CBezierPatch.h" +class CRevolution //ת +{ +public: + CRevolution(void) {}; + virtual ~CRevolution(void) {}; + void ReadCubicBezierControlPoint(CP3 P[4]);//߶ʼ + CP3* GetVertexArrayName(void);//õ + void DrawRevolutionSurface(CDC* pDC);//ƻת +private: + void ReadVertex(void);//תƶζ + void ReadPatch(void);//ת˫Ƭ +private: + CP3 P[4];//ߵ4 άƵ + CP3 V[48];//תܶ(4,48) + CPatch S[4];//ת飨һȦ4棩 +}; \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CT2.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CT2.cpp" new file mode 100644 index 0000000..42999ce --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CT2.cpp" @@ -0,0 +1,72 @@ +#include "pch.h" +#include "CT2.h" +CT2::CT2(void) +{ + u = 0.0; + v = 0.0; +} +CT2::CT2(double u, double v) +{ + this->u = u; + this->v = v; +} +CT2::~CT2(void) +{ +} +CT2 operator + (const CT2& t0, const CT2& t1)// +{ + CT2 result; + result.u = t0.u + t1.u; + result.v = t0.v + t1.v; + return result; +} +CT2 operator - (const CT2& t0, const CT2& t1)// +{ + CT2 result; + result.u = t0.u - t1.u; + result.v = t0.v - t1.v; + return result; +} +CT2 operator * (const CT2& t, double scalar)//ͳĻ +{ + return CT2(t.u * scalar, t.v * scalar); +} +CT2 operator * (double scalar, const CT2& t)//͵Ļ +{ + return CT2(t.u * scalar, t.v * scalar); +} +CT2 operator / (const CT2& t, double scalar)// +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + CT2 result; + result.u = t.u / scalar; + result.v = t.v / scalar; + return result; +} +CT2 operator += (CT2& t0, CT2& t1) +{ + t0.u = t0.u + t1.u; + t0.v = t0.v + t1.v; + return t0; +} +CT2 operator -= (CT2& t0, CT2& t1) +{ + t0.u = t0.u - t1.u; + t0.v = t0.v - t1.v; + return t0; +} +CT2 operator *= (CT2& t, double scalar) +{ + t.u = t.u * scalar; + t.v = t.v * scalar; + return t; +} +CT2 operator /= (CT2& t, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + t.u = t.u / scalar; + t.v = t.v / scalar; + return t; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CT2.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CT2.h" new file mode 100644 index 0000000..89a9ab2 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CT2.h" @@ -0,0 +1,20 @@ +#pragma once +class CT2 +{ +public: + CT2(void); + virtual ~CT2(void); + CT2(double u, double v); + friend CT2 operator + (const CT2& t0, const CT2& t1);// + friend CT2 operator - (const CT2& t0, const CT2& t1); + friend CT2 operator * (const CT2& t, double scalar); + friend CT2 operator * (double scalar, const CT2& t); + friend CT2 operator / (const CT2& t, double scalar); + friend CT2 operator += (CT2& t0, CT2& t1); + friend CT2 operator -= (CT2& t0, CT2& t1); + friend CT2 operator *= (CT2& t, double scalar); + friend CT2 operator /= (CT2& t, double scalar); +public: + double u, v; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CTrans3.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CTrans3.cpp" new file mode 100644 index 0000000..746c3fc --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CTrans3.cpp" @@ -0,0 +1,150 @@ +#include "pch.h" +#include "CTrans3.h" +#define PI 3.1415926 +void CTrans3::Identity(void) +{ + M[0][0] = 1.0; M[0][1] = 0.0; M[0][2] = 0.0; M[0][3] = 0.0; + M[1][0] = 0.0; M[1][1] = 1.0; M[1][2] = 0.0; M[1][3] = 0.0; + M[2][0] = 0.0; M[2][1] = 0.0; M[2][2] = 1.0; M[2][3] = 0.0; + M[3][0] = 0.0; M[3][1] = 0.0; M[3][2] = 0.0; M[3][3] = 1.0; +} +void CTrans3::SetMatrix(CP3* P, int ptNumber) +{ + this->P = P; + this->ptNumber = ptNumber; +} +void CTrans3::Translate(double tx, double ty, double tz) +{ + Identity(); + M[0][3] = tx; + M[1][3] = ty; + M[2][3] = tz; + MultiplyMatrix(); +} +void CTrans3::Scale(double sx, double sy, double sz) +{ + Identity(); + M[0][0] = sx; + M[1][1] = sy; + M[2][2] = sz; + MultiplyMatrix(); +} +void CTrans3::Scale(double sx, double sy, double sz, CP3 p) +{ + Translate(-p.x, -p.y, -p.z); + Scale(sx, sy, sz); + Translate(p.x, p.y, p.z); +} +void CTrans3::RotateX(double beta) +{ + Identity(); + double rad = beta * PI / 180; + M[1][1] = cos(rad); M[1][2] = -sin(rad); + M[2][1] = sin(rad); M[2][2] = cos(rad); + MultiplyMatrix(); +} +void CTrans3::RotateY(double beta) +{ + Identity(); + double rad = beta * PI / 180; + M[0][0] = cos(rad); M[0][2] = sin(rad); + M[2][0] = -sin(rad); M[2][2] = cos(rad); + MultiplyMatrix(); +} +void CTrans3::RotateZ(double beta) +{ + Identity(); + double rad = beta * PI / 180; + M[0][0] = cos(rad); M[0][1] = -sin(rad); + M[1][0] = sin(rad); M[1][1] = cos(rad); + MultiplyMatrix(); +} +void CTrans3::RotateX(double beta, CP3 p) +{ + Translate(-p.x, -p.y, -p.z); + RotateX(beta); + Translate(p.x, p.y, p.z); +} +void CTrans3::RotateY(double beta, CP3 p) +{ + Translate(-p.x, -p.y, -p.z); + RotateY(beta); + Translate(p.x, p.y, p.z); +} +void CTrans3::RotateZ(double beta, CP3 p) +{ + Translate(-p.x, -p.y, -p.z); + RotateZ(beta); + Translate(p.x, p.y, p.z); +} +void CTrans3::ReflectX(void) +{ + Identity(); + M[1][1] = -1; + M[2][2] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectY(void) +{ + Identity(); + M[0][0] = -1; + M[2][2] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectZ(void) +{ + Identity(); + M[0][0] = -1; + M[1][1] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectXOY(void) +{ + Identity(); + M[2][2] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectYOZ(void) +{ + Identity(); + M[0][0] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectZOX(void) +{ + Identity(); + M[1][1] = -1; + MultiplyMatrix(); +} +void CTrans3::ShearX(double b, double c) +{ + Identity(); + M[0][1] = b; M[0][2] = c; + MultiplyMatrix(); +} +void CTrans3::ShearY(double d, double f) +{ + Identity(); + M[1][0] = d; M[1][2] = f; + MultiplyMatrix(); +} +void CTrans3::ShearZ(double g, double h) +{ + Identity(); + M[2][0] = g; M[2][1] = h; + MultiplyMatrix(); +} +void CTrans3::MultiplyMatrix(void) +{ + CP3* PTemp = new CP3[ptNumber]; + for (int i = 0; i < ptNumber; i++) + PTemp[i] = P[i]; + for (int i = 0; i < ptNumber; i++) + { + P[i].x = M[0][0] * PTemp[i].x + M[0][1] * PTemp[i].y + M[0][2] * PTemp[i].z + M[0][3] * PTemp[i].w; + P[i].y = M[1][0] * PTemp[i].x + M[1][1] * PTemp[i].y + M[1][2] * PTemp[i].z + M[1][3] * PTemp[i].w; + P[i].z = M[2][0] * PTemp[i].x + M[2][1] * PTemp[i].y + M[2][2] * PTemp[i].z + M[2][3] * PTemp[i].w; + P[i].w = M[3][0] * PTemp[i].x + M[3][1] * PTemp[i].y + M[3][2] * PTemp[i].z + M[3][3] * PTemp[i].w; + } + delete[]PTemp; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CTrans3.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CTrans3.h" new file mode 100644 index 0000000..d6d24a2 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/CTrans3.h" @@ -0,0 +1,34 @@ +#pragma once +#include "CP3.h" +class CTrans3 +{ +public: + CTrans3(void) {}; + virtual ~CTrans3(void) {}; + void Identity(void); + void SetMatrix(CP3* P, int ptNumber); + void Translate(double tx, double ty, double tz); + void Scale(double sx, double sy, double sz); + void Scale(double sx, double sy, double sz, CP3 p); + void RotateX(double beta); + void RotateY(double beta); + void RotateZ(double beta); + void RotateX(double beta, CP3 p); + void RotateY(double beta, CP3 p); + void RotateZ(double beta, CP3 p); + void ReflectX(void); + void ReflectY(void); + void ReflectZ(void); + void ReflectXOY(void); + void ReflectYOZ(void); + void ReflectZOX(void); + void ShearX(double b, double c); + void ShearY(double d, double f); + void ShearZ(double g, double h); + void MultiplyMatrix(void); +private: + double M[4][4]; + CP3* P; + int ptNumber; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/ClassView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/ClassView.cpp" new file mode 100644 index 0000000..898689a --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/ClassView.cpp" @@ -0,0 +1,323 @@ + +#include "pch.h" +#include "framework.h" +#include "MainFrm.h" +#include "ClassView.h" +#include "Resource.h" +#include "BezierSurface.h" + +class CClassViewMenuButton : public CMFCToolBarMenuButton +{ + friend class CClassView; + + DECLARE_SERIAL(CClassViewMenuButton) + +public: + CClassViewMenuButton(HMENU hMenu = nullptr) noexcept : CMFCToolBarMenuButton((UINT)-1, hMenu, -1) + { + } + + virtual void OnDraw(CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz = TRUE, + BOOL bCustomizeMode = FALSE, BOOL bHighlight = FALSE, BOOL bDrawBorder = TRUE, BOOL bGrayDisabledButtons = TRUE) + { + pImages = CMFCToolBar::GetImages(); + + CAfxDrawState ds; + pImages->PrepareDrawImage(ds); + + CMFCToolBarMenuButton::OnDraw(pDC, rect, pImages, bHorz, bCustomizeMode, bHighlight, bDrawBorder, bGrayDisabledButtons); + + pImages->EndDrawImage(ds); + } +}; + +IMPLEMENT_SERIAL(CClassViewMenuButton, CMFCToolBarMenuButton, 1) + +////////////////////////////////////////////////////////////////////// +// 构造/析构 +////////////////////////////////////////////////////////////////////// + +CClassView::CClassView() noexcept +{ + m_nCurrSort = ID_SORTING_GROUPBYTYPE; +} + +CClassView::~CClassView() +{ +} + +BEGIN_MESSAGE_MAP(CClassView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_CLASS_ADD_MEMBER_FUNCTION, OnClassAddMemberFunction) + ON_COMMAND(ID_CLASS_ADD_MEMBER_VARIABLE, OnClassAddMemberVariable) + ON_COMMAND(ID_CLASS_DEFINITION, OnClassDefinition) + ON_COMMAND(ID_CLASS_PROPERTIES, OnClassProperties) + ON_COMMAND(ID_NEW_FOLDER, OnNewFolder) + ON_WM_PAINT() + ON_WM_SETFOCUS() + ON_COMMAND_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnSort) + ON_UPDATE_COMMAND_UI_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnUpdateSort) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClassView 消息处理程序 + +int CClassView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndClassView.Create(dwViewStyle, rectDummy, this, 2)) + { + TRACE0("未能创建类视图\n"); + return -1; // 未能创建 + } + + // 加载图像: + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_SORT); + m_wndToolBar.LoadToolBar(IDR_SORT, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + CMenu menuSort; + menuSort.LoadMenu(IDR_POPUP_SORT); + + m_wndToolBar.ReplaceButton(ID_SORT_MENU, CClassViewMenuButton(menuSort.GetSubMenu(0)->GetSafeHmenu())); + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->m_bText = FALSE; + pButton->m_bImage = TRUE; + pButton->SetImage(GetCmdMgr()->GetCmdImage(m_nCurrSort)); + pButton->SetMessageWnd(this); + } + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillClassView(); + + return 0; +} + +void CClassView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CClassView::FillClassView() +{ + HTREEITEM hRoot = m_wndClassView.InsertItem(_T("FakeApp 类"), 0, 0); + m_wndClassView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hClass = m_wndClassView.InsertItem(_T("CFakeAboutDlg"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAboutDlg()"), 3, 3, hClass); + + m_wndClassView.Expand(hRoot, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeApp"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeApp()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("InitInstance()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnAppAbout()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppDoc"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppDoc()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppDoc()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnNewDocument()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppView"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppView()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppView()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("GetDocument()"), 3, 3, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppFrame"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("m_wndMenuBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndToolBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndStatusBar"), 6, 6, hClass); + + hClass = m_wndClassView.InsertItem(_T("Globals"), 2, 2, hRoot); + m_wndClassView.InsertItem(_T("theFakeApp"), 5, 5, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); +} + +void CClassView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndClassView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + CMenu menu; + menu.LoadMenu(IDR_POPUP_SORT); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } +} + +void CClassView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndClassView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +BOOL CClassView::PreTranslateMessage(MSG* pMsg) +{ + return CDockablePane::PreTranslateMessage(pMsg); +} + +void CClassView::OnSort(UINT id) +{ + if (m_nCurrSort == id) + { + return; + } + + m_nCurrSort = id; + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->SetImage(GetCmdMgr()->GetCmdImage(id)); + m_wndToolBar.Invalidate(); + m_wndToolBar.UpdateWindow(); + } +} + +void CClassView::OnUpdateSort(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(pCmdUI->m_nID == m_nCurrSort); +} + +void CClassView::OnClassAddMemberFunction() +{ + AfxMessageBox(_T("添加成员函数...")); +} + +void CClassView::OnClassAddMemberVariable() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassDefinition() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassProperties() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnNewFolder() +{ + AfxMessageBox(_T("新建文件夹...")); +} + +void CClassView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndClassView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CClassView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndClassView.SetFocus(); +} + +void CClassView::OnChangeVisualStyle() +{ + m_ClassViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_CLASS_VIEW_24 : IDB_CLASS_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_ClassViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_ClassViewImages.Add(&bmp, RGB(255, 0, 0)); + + m_wndClassView.SetImageList(&m_ClassViewImages, TVSIL_NORMAL); + + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_SORT_24 : IDR_SORT, 0, 0, TRUE /* 锁定*/); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/ClassView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/ClassView.h" new file mode 100644 index 0000000..786c278 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/ClassView.h" @@ -0,0 +1,54 @@ + +#pragma once + +#include "ViewTree.h" + +class CClassToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CClassView : public CDockablePane +{ +public: + CClassView() noexcept; + virtual ~CClassView(); + + void AdjustLayout(); + void OnChangeVisualStyle(); + +protected: + CClassToolBar m_wndToolBar; + CViewTree m_wndClassView; + CImageList m_ClassViewImages; + UINT m_nCurrSort; + + void FillClassView(); + +// 重写 +public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnClassAddMemberFunction(); + afx_msg void OnClassAddMemberVariable(); + afx_msg void OnClassDefinition(); + afx_msg void OnClassProperties(); + afx_msg void OnNewFolder(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg LRESULT OnChangeActiveTab(WPARAM, LPARAM); + afx_msg void OnSort(UINT id); + afx_msg void OnUpdateSort(CCmdUI* pCmdUI); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/FileView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/FileView.cpp" new file mode 100644 index 0000000..2eeec43 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/FileView.cpp" @@ -0,0 +1,257 @@ + +#include "pch.h" +#include "framework.h" +#include "mainfrm.h" +#include "FileView.h" +#include "Resource.h" +#include "BezierSurface.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CFileView + +CFileView::CFileView() noexcept +{ +} + +CFileView::~CFileView() +{ +} + +BEGIN_MESSAGE_MAP(CFileView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_PROPERTIES, OnProperties) + ON_COMMAND(ID_OPEN, OnFileOpen) + ON_COMMAND(ID_OPEN_WITH, OnFileOpenWith) + ON_COMMAND(ID_DUMMY_COMPILE, OnDummyCompile) + ON_COMMAND(ID_EDIT_CUT, OnEditCut) + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_WM_PAINT() + ON_WM_SETFOCUS() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CWorkspaceBar 消息处理程序 + +int CFileView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; + + if (!m_wndFileView.Create(dwViewStyle, rectDummy, this, 4)) + { + TRACE0("未能创建文件视图\n"); + return -1; // 未能创建 + } + + // 加载视图图像: + m_FileViewImages.Create(IDB_FILE_VIEW, 16, 0, RGB(255, 0, 255)); + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_EXPLORER); + m_wndToolBar.LoadToolBar(IDR_EXPLORER, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillFileView(); + AdjustLayout(); + + return 0; +} + +void CFileView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CFileView::FillFileView() +{ + HTREEITEM hRoot = m_wndFileView.InsertItem(_T("FakeApp 文件"), 0, 0); + m_wndFileView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hSrc = m_wndFileView.InsertItem(_T("FakeApp 源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeApp.rc"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppDoc.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppView.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("MainFrm.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("pch.cpp"), 1, 1, hSrc); + + HTREEITEM hInc = m_wndFileView.InsertItem(_T("FakeApp 头文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppDoc.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppView.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("Resource.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("MainFrm.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("pch.h"), 2, 2, hInc); + + HTREEITEM hRes = m_wndFileView.InsertItem(_T("FakeApp 资源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeApp.rc2"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeAppDoc.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeToolbar.bmp"), 2, 2, hRes); + + m_wndFileView.Expand(hRoot, TVE_EXPAND); + m_wndFileView.Expand(hSrc, TVE_EXPAND); + m_wndFileView.Expand(hInc, TVE_EXPAND); +} + +void CFileView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE); +} + +void CFileView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndFileView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +void CFileView::OnProperties() +{ + AfxMessageBox(_T("属性....")); + +} + +void CFileView::OnFileOpen() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnFileOpenWith() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnDummyCompile() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCut() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCopy() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditClear() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndFileView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CFileView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndFileView.SetFocus(); +} + +void CFileView::OnChangeVisualStyle() +{ + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_EXPLORER_24 : IDR_EXPLORER, 0, 0, TRUE /* 锁定*/); + + m_FileViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_FILE_VIEW_24 : IDB_FILE_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_FileViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_FileViewImages.Add(&bmp, RGB(255, 0, 255)); + + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); +} + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/FileView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/FileView.h" new file mode 100644 index 0000000..e39a7c9 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/FileView.h" @@ -0,0 +1,55 @@ + +#pragma once + +#include "ViewTree.h" + +class CFileViewToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CFileView : public CDockablePane +{ +// 构造 +public: + CFileView() noexcept; + + void AdjustLayout(); + void OnChangeVisualStyle(); + +// 特性 +protected: + + CViewTree m_wndFileView; + CImageList m_FileViewImages; + CFileViewToolBar m_wndToolBar; + +protected: + void FillFileView(); + +// 实现 +public: + virtual ~CFileView(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnProperties(); + afx_msg void OnFileOpen(); + afx_msg void OnFileOpenWith(); + afx_msg void OnDummyCompile(); + afx_msg void OnEditCut(); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/MainFrm.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/MainFrm.cpp" new file mode 100644 index 0000000..c67d38e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/MainFrm.cpp" @@ -0,0 +1,408 @@ + +// MainFrm.cpp: CMainFrame 类的实现 +// + +#include "pch.h" +#include "framework.h" +#include "BezierSurface.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) + +const int iMaxUserToolbars = 10; +const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; +const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) + ON_WM_CREATE() + ON_COMMAND(ID_VIEW_CUSTOMIZE, &CMainFrame::OnViewCustomize) + ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, &CMainFrame::OnToolbarCreateNew) + ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook) + ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook) + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // 状态行指示器 + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +// CMainFrame 构造/析构 + +CMainFrame::CMainFrame() noexcept +{ + // TODO: 在此添加成员初始化代码 + theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2008); +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) + return -1; + + BOOL bNameValid; + + if (!m_wndMenuBar.Create(this)) + { + TRACE0("未能创建菜单栏\n"); + return -1; // 未能创建 + } + + m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); + + // 防止菜单栏在激活时获得焦点 + CMFCPopupMenu::SetForceMenuFocus(FALSE); + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) + { + TRACE0("未能创建工具栏\n"); + return -1; // 未能创建 + } + + CString strToolBarName; + bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); + ASSERT(bNameValid); + m_wndToolBar.SetWindowText(strToolBarName); + + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + + // 允许用户定义的工具栏操作: + InitUserToolbars(nullptr, uiFirstUserToolBarId, uiLastUserToolBarId); + + if (!m_wndStatusBar.Create(this)) + { + TRACE0("未能创建状态栏\n"); + return -1; // 未能创建 + } + m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); + + // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行 + m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndMenuBar); + DockPane(&m_wndToolBar); + + + // 启用 Visual Studio 2005 样式停靠窗口行为 + CDockingManager::SetDockingMode(DT_SMART); + // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 + EnableAutoHidePanes(CBRS_ALIGN_ANY); + + // 加载菜单项图像(不在任何标准工具栏上): + CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); + + // 创建停靠窗口 + if (!CreateDockingWindows()) + { + TRACE0("未能创建停靠窗口\n"); + return -1; + } + + m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); + m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndFileView); + CDockablePane* pTabbedBar = nullptr; + m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); + m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndOutput); + m_wndProperties.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndProperties); + + // 基于持久值设置视觉管理器和样式 + OnApplicationLook(theApp.m_nAppLook); + + // 启用工具栏和停靠窗口菜单替换 + EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); + + // 启用快速(按住 Alt 拖动)工具栏自定义 + CMFCToolBar::EnableQuickCustomization(); + + if (CMFCToolBar::GetUserImages() == nullptr) + { + // 加载用户定义的工具栏图像 + if (m_UserImages.Load(_T(".\\UserImages.bmp"))) + { + CMFCToolBar::SetUserImages(&m_UserImages); + } + } + + // 启用菜单个性化(最近使用的命令) + // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 + CList lstBasicCommands; + + lstBasicCommands.AddTail(ID_FILE_NEW); + lstBasicCommands.AddTail(ID_FILE_OPEN); + lstBasicCommands.AddTail(ID_FILE_SAVE); + lstBasicCommands.AddTail(ID_FILE_PRINT); + lstBasicCommands.AddTail(ID_APP_EXIT); + lstBasicCommands.AddTail(ID_EDIT_CUT); + lstBasicCommands.AddTail(ID_EDIT_PASTE); + lstBasicCommands.AddTail(ID_EDIT_UNDO); + lstBasicCommands.AddTail(ID_APP_ABOUT); + lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); + lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7); + lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); + lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); + lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); + lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); + + CMFCToolBar::SetBasicCommands(lstBasicCommands); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWndEx::PreCreateWindow(cs) ) + return FALSE; + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return TRUE; +} + +BOOL CMainFrame::CreateDockingWindows() +{ + BOOL bNameValid; + + // 创建类视图 + CString strClassView; + bNameValid = strClassView.LoadString(IDS_CLASS_VIEW); + ASSERT(bNameValid); + if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“类视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建文件视图 + CString strFileView; + bNameValid = strFileView.LoadString(IDS_FILE_VIEW); + ASSERT(bNameValid); + if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“文件视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建输出窗口 + CString strOutputWnd; + bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND); + ASSERT(bNameValid); + if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建输出窗口\n"); + return FALSE; // 未能创建 + } + + // 创建属性窗口 + CString strPropertiesWnd; + bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND); + ASSERT(bNameValid); + if (!m_wndProperties.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“属性”窗口\n"); + return FALSE; // 未能创建 + } + + SetDockingWindowIcons(theApp.m_bHiColorIcons); + return TRUE; +} + +void CMainFrame::SetDockingWindowIcons(BOOL bHiColorIcons) +{ + HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_FILE_VIEW_HC : IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndFileView.SetIcon(hFileViewIcon, FALSE); + + HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_CLASS_VIEW_HC : IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndClassView.SetIcon(hClassViewIcon, FALSE); + + HICON hOutputBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_OUTPUT_WND_HC : IDI_OUTPUT_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndOutput.SetIcon(hOutputBarIcon, FALSE); + + HICON hPropertiesBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_PROPERTIES_WND_HC : IDI_PROPERTIES_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndProperties.SetIcon(hPropertiesBarIcon, FALSE); + +} + +// CMainFrame 诊断 + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWndEx::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWndEx::Dump(dc); +} +#endif //_DEBUG + + +// CMainFrame 消息处理程序 + +void CMainFrame::OnViewCustomize() +{ + CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* 扫描菜单*/); + pDlgCust->EnableUserDefinedToolbars(); + pDlgCust->Create(); +} + +LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) +{ + LRESULT lres = CFrameWndEx::OnToolbarCreateNew(wp,lp); + if (lres == 0) + { + return 0; + } + + CMFCToolBar* pUserToolbar = (CMFCToolBar*)lres; + ASSERT_VALID(pUserToolbar); + + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + return lres; +} + +void CMainFrame::OnApplicationLook(UINT id) +{ + CWaitCursor wait; + + theApp.m_nAppLook = id; + + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_WIN_2000: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); + break; + + case ID_VIEW_APPLOOK_OFF_XP: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); + break; + + case ID_VIEW_APPLOOK_WIN_XP: + CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + break; + + case ID_VIEW_APPLOOK_OFF_2003: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2005: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2008: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_WINDOWS_7: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + default: + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_OFF_2007_BLUE: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); + break; + + case ID_VIEW_APPLOOK_OFF_2007_BLACK: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); + break; + + case ID_VIEW_APPLOOK_OFF_2007_SILVER: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); + break; + + case ID_VIEW_APPLOOK_OFF_2007_AQUA: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); + break; + } + + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); + CDockingManager::SetDockingMode(DT_SMART); + } + + m_wndOutput.UpdateFonts(); + RedrawWindow(nullptr, nullptr, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); + + theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); +} + +void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI) +{ + pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID); +} + + +BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) +{ + // 基类将执行真正的工作 + + if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) + { + return FALSE; + } + + + // 为所有用户工具栏启用自定义按钮 + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + for (int i = 0; i < iMaxUserToolbars; i ++) + { + CMFCToolBar* pUserToolbar = GetUserToolBarByIndex(i); + if (pUserToolbar != nullptr) + { + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + } + } + + return TRUE; +} + + +void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CFrameWndEx::OnSettingChange(uFlags, lpszSection); + m_wndOutput.UpdateFonts(); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/MainFrm.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/MainFrm.h" new file mode 100644 index 0000000..02feb8e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/MainFrm.h" @@ -0,0 +1,61 @@ + +// MainFrm.h: CMainFrame 类的接口 +// + +#pragma once +#include "FileView.h" +#include "ClassView.h" +#include "OutputWnd.h" +#include "PropertiesWnd.h" + +class CMainFrame : public CFrameWndEx +{ + +protected: // 仅从序列化创建 + CMainFrame() noexcept; + DECLARE_DYNCREATE(CMainFrame) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = nullptr, CCreateContext* pContext = nullptr); + +// 实现 +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // 控件条嵌入成员 + CMFCMenuBar m_wndMenuBar; + CMFCToolBar m_wndToolBar; + CMFCStatusBar m_wndStatusBar; + CMFCToolBarImages m_UserImages; + CFileView m_wndFileView; + CClassView m_wndClassView; + COutputWnd m_wndOutput; + CPropertiesWnd m_wndProperties; + +// 生成的消息映射函数 +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnViewCustomize(); + afx_msg LRESULT OnToolbarCreateNew(WPARAM wp, LPARAM lp); + afx_msg void OnApplicationLook(UINT id); + afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + DECLARE_MESSAGE_MAP() + + BOOL CreateDockingWindows(); + void SetDockingWindowIcons(BOOL bHiColorIcons); +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/OutputWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/OutputWnd.cpp" new file mode 100644 index 0000000..e3f4901 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/OutputWnd.cpp" @@ -0,0 +1,200 @@ + +#include "pch.h" +#include "framework.h" + +#include "OutputWnd.h" +#include "Resource.h" +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// COutputBar + +COutputWnd::COutputWnd() noexcept +{ +} + +COutputWnd::~COutputWnd() +{ +} + +BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() +END_MESSAGE_MAP() + +int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建选项卡窗口: + if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1)) + { + TRACE0("未能创建输出选项卡窗口\n"); + return -1; // 未能创建 + } + + // 创建输出窗格: + const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; + + if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) || + !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) || + !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4)) + { + TRACE0("未能创建输出窗口\n"); + return -1; // 未能创建 + } + + UpdateFonts(); + + CString strTabName; + BOOL bNameValid; + + // 将列表窗口附加到选项卡: + bNameValid = strTabName.LoadString(IDS_BUILD_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0); + bNameValid = strTabName.LoadString(IDS_DEBUG_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1); + bNameValid = strTabName.LoadString(IDS_FIND_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2); + + // 使用一些虚拟文本填写输出选项卡(无需复杂数据) + FillBuildWindow(); + FillDebugWindow(); + FillFindWindow(); + + return 0; +} + +void COutputWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + + // 选项卡控件应覆盖整个工作区: + m_wndTabs.SetWindowPos (nullptr, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); +} + +void COutputWnd::AdjustHorzScroll(CListBox& wndListBox) +{ + CClientDC dc(this); + CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular); + + int cxExtentMax = 0; + + for (int i = 0; i < wndListBox.GetCount(); i ++) + { + CString strItem; + wndListBox.GetText(i, strItem); + + cxExtentMax = max(cxExtentMax, (int)dc.GetTextExtent(strItem).cx); + } + + wndListBox.SetHorizontalExtent(cxExtentMax); + dc.SelectObject(pOldFont); +} + +void COutputWnd::FillBuildWindow() +{ + m_wndOutputBuild.AddString(_T("生成输出正显示在此处。")); + m_wndOutputBuild.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputBuild.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillDebugWindow() +{ + m_wndOutputDebug.AddString(_T("调试输出正显示在此处。")); + m_wndOutputDebug.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputDebug.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillFindWindow() +{ + m_wndOutputFind.AddString(_T("查找输出正显示在此处。")); + m_wndOutputFind.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputFind.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::UpdateFonts() +{ + m_wndOutputBuild.SetFont(&afxGlobalData.fontRegular); + m_wndOutputDebug.SetFont(&afxGlobalData.fontRegular); + m_wndOutputFind.SetFont(&afxGlobalData.fontRegular); +} + +///////////////////////////////////////////////////////////////////////////// +// COutputList1 + +COutputList::COutputList() noexcept +{ +} + +COutputList::~COutputList() +{ +} + +BEGIN_MESSAGE_MAP(COutputList, CListBox) + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput) + ON_WM_WINDOWPOSCHANGING() +END_MESSAGE_MAP() +///////////////////////////////////////////////////////////////////////////// +// COutputList 消息处理程序 + +void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) +{ + CMenu menu; + menu.LoadMenu(IDR_OUTPUT_POPUP); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } + + SetFocus(); +} + +void COutputList::OnEditCopy() +{ + MessageBox(_T("复制输出")); +} + +void COutputList::OnEditClear() +{ + MessageBox(_T("清除输出")); +} + +void COutputList::OnViewOutput() +{ + CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner()); + CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame()); + + if (pMainFrame != nullptr && pParentBar != nullptr) + { + pMainFrame->SetFocus(); + pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE); + pMainFrame->RecalcLayout(); + + } +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/OutputWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/OutputWnd.h" new file mode 100644 index 0000000..4d773c3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/OutputWnd.h" @@ -0,0 +1,59 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// COutputList 窗口 + +class COutputList : public CListBox +{ +// 构造 +public: + COutputList() noexcept; + +// 实现 +public: + virtual ~COutputList(); + +protected: + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnViewOutput(); + + DECLARE_MESSAGE_MAP() +}; + +class COutputWnd : public CDockablePane +{ +// 构造 +public: + COutputWnd() noexcept; + + void UpdateFonts(); + +// 特性 +protected: + CMFCTabCtrl m_wndTabs; + + COutputList m_wndOutputBuild; + COutputList m_wndOutputDebug; + COutputList m_wndOutputFind; + +protected: + void FillBuildWindow(); + void FillDebugWindow(); + void FillFindWindow(); + + void AdjustHorzScroll(CListBox& wndListBox); + +// 实现 +public: + virtual ~COutputWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/Patch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/Patch.cpp" new file mode 100644 index 0000000..4ce7690 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/Patch.cpp" @@ -0,0 +1,11 @@ +#include "pch.h" +#include "Patch.h" + +CPatch::CPatch(void) +{ +} + + +CPatch::~CPatch(void) +{ +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/Patch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/Patch.h" new file mode 100644 index 0000000..742d94d --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/Patch.h" @@ -0,0 +1,10 @@ +#pragma once +class CPatch +{ +public: + CPatch(void); + virtual ~CPatch(void); +public: + int pIndex[4][4]; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/PropertiesWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/PropertiesWnd.cpp" new file mode 100644 index 0000000..ec5afe5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/PropertiesWnd.cpp" @@ -0,0 +1,273 @@ + +#include "pch.h" +#include "framework.h" + +#include "PropertiesWnd.h" +#include "Resource.h" +#include "MainFrm.h" +#include "BezierSurface.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar + +CPropertiesWnd::CPropertiesWnd() noexcept +{ + m_nComboHeight = 0; +} + +CPropertiesWnd::~CPropertiesWnd() +{ +} + +BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties) + ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties) + ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties) + ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties) + ON_COMMAND(ID_PROPERTIES1, OnProperties1) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1) + ON_COMMAND(ID_PROPERTIES2, OnProperties2) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2) + ON_WM_SETFOCUS() + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar 消息处理程序 + +void CPropertiesWnd::AdjustLayout() +{ + if (GetSafeHwnd () == nullptr || (AfxGetMainWnd() != nullptr && AfxGetMainWnd()->IsIconic())) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndObjectCombo.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndPropList.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight + cyTlb, rectClient.Width(), rectClient.Height() -(m_nComboHeight+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER); +} + +int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建组合: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1)) + { + TRACE0("未能创建属性组合 \n"); + return -1; // 未能创建 + } + + m_wndObjectCombo.AddString(_T("应用程序")); + m_wndObjectCombo.AddString(_T("属性窗口")); + m_wndObjectCombo.SetCurSel(0); + + CRect rectCombo; + m_wndObjectCombo.GetClientRect (&rectCombo); + + m_nComboHeight = rectCombo.Height(); + + if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2)) + { + TRACE0("未能创建属性网格\n"); + return -1; // 未能创建 + } + + InitPropList(); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES); + m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* 已锁定*/); + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* 锁定*/); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + AdjustLayout(); + return 0; +} + +void CPropertiesWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CPropertiesWnd::OnExpandAllProperties() +{ + m_wndPropList.ExpandAll(); +} + +void CPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* /* pCmdUI */) +{ +} + +void CPropertiesWnd::OnSortProperties() +{ + m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnProperties1() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::OnProperties2() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::InitPropList() +{ + SetPropListFont(); + + m_wndPropList.EnableHeaderCtrl(FALSE); + m_wndPropList.EnableDescriptionArea(); + m_wndPropList.SetVSDotNetLook(); + m_wndPropList.MarkModifiedProperties(); + + CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("外观")); + + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("三维外观"), (_variant_t) false, _T("指定窗口的字体不使用粗体,并且控件将使用三维边框"))); + + CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("边框"), _T("对话框外框"), _T("其中之一: “无”、“细”、“可调整大小”或“对话框外框”")); + pProp->AddOption(_T("无")); + pProp->AddOption(_T("细")); + pProp->AddOption(_T("可调整大小")); + pProp->AddOption(_T("对话框外框")); + pProp->AllowEdit(FALSE); + + pGroup1->AddSubItem(pProp); + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("标题"), (_variant_t) _T("关于"), _T("指定窗口标题栏中显示的文本"))); + + m_wndPropList.AddProperty(pGroup1); + + CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("窗口大小"), 0, TRUE); + + pProp = new CMFCPropertyGridProperty(_T("高度"), (_variant_t) 250l, _T("指定窗口的高度")); + pProp->EnableSpinControl(TRUE, 50, 300); + pSize->AddSubItem(pProp); + + pProp = new CMFCPropertyGridProperty( _T("宽度"), (_variant_t) 150l, _T("指定窗口的宽度")); + pProp->EnableSpinControl(TRUE, 50, 200); + pSize->AddSubItem(pProp); + + m_wndPropList.AddProperty(pSize); + + CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("字体")); + + LOGFONT lf; + CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + font->GetLogFont(&lf); + + _tcscpy_s(lf.lfFaceName, _T("宋体, Arial")); + + pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("字体"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("指定窗口的默认字体"))); + pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("使用系统字体"), (_variant_t) true, _T("指定窗口使用“MS Shell Dlg”字体"))); + + m_wndPropList.AddProperty(pGroup2); + + CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("杂项")); + pProp = new CMFCPropertyGridProperty(_T("(名称)"), _T("应用程序")); + pProp->Enable(FALSE); + pGroup3->AddSubItem(pProp); + + CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("窗口颜色"), RGB(210, 192, 254), nullptr, _T("指定默认的窗口颜色")); + pColorProp->EnableOtherButton(_T("其他...")); + pColorProp->EnableAutomaticButton(_T("默认"), ::GetSysColor(COLOR_3DFACE)); + pGroup3->AddSubItem(pColorProp); + + static const TCHAR szFilter[] = _T("图标文件(*.ico)|*.ico|所有文件(*.*)|*.*||"); + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("图标"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("指定窗口图标"))); + + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("文件夹"), _T("c:\\"))); + + m_wndPropList.AddProperty(pGroup3); + + CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("层次结构")); + + CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("第一个子级")); + pGroup4->AddSubItem(pGroup41); + + CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("第二个子级")); + pGroup41->AddSubItem(pGroup411); + + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 1"), (_variant_t) _T("值 1"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 2"), (_variant_t) _T("值 2"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 3"), (_variant_t) _T("值 3"), _T("此为说明"))); + + pGroup4->Expand(FALSE); + m_wndPropList.AddProperty(pGroup4); +} + +void CPropertiesWnd::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + m_wndPropList.SetFocus(); +} + +void CPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CDockablePane::OnSettingChange(uFlags, lpszSection); + SetPropListFont(); +} + +void CPropertiesWnd::SetPropListFont() +{ + ::DeleteObject(m_fntPropList.Detach()); + + LOGFONT lf; + afxGlobalData.fontRegular.GetLogFont(&lf); + + NONCLIENTMETRICS info; + info.cbSize = sizeof(info); + + afxGlobalData.GetNonClientMetrics(info); + + lf.lfHeight = info.lfMenuFont.lfHeight; + lf.lfWeight = info.lfMenuFont.lfWeight; + lf.lfItalic = info.lfMenuFont.lfItalic; + + m_fntPropList.CreateFontIndirect(&lf); + + m_wndPropList.SetFont(&m_fntPropList); + m_wndObjectCombo.SetFont(&m_fntPropList); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/PropertiesWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/PropertiesWnd.h" new file mode 100644 index 0000000..e056430 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/PropertiesWnd.h" @@ -0,0 +1,62 @@ + +#pragma once + +class CPropertiesToolBar : public CMFCToolBar +{ +public: + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CPropertiesWnd : public CDockablePane +{ +// 构造 +public: + CPropertiesWnd() noexcept; + + void AdjustLayout(); + +// 特性 +public: + void SetVSDotNetLook(BOOL bSet) + { + m_wndPropList.SetVSDotNetLook(bSet); + m_wndPropList.SetGroupNameFullWidth(bSet); + } + +protected: + CFont m_fntPropList; + CComboBox m_wndObjectCombo; + CPropertiesToolBar m_wndToolBar; + CMFCPropertyGridCtrl m_wndPropList; + +// 实现 +public: + virtual ~CPropertiesWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnExpandAllProperties(); + afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI); + afx_msg void OnSortProperties(); + afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI); + afx_msg void OnProperties1(); + afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI); + afx_msg void OnProperties2(); + afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + + DECLARE_MESSAGE_MAP() + + void InitPropList(); + void SetPropListFont(); + + int m_nComboHeight; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/ViewTree.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/ViewTree.cpp" new file mode 100644 index 0000000..84996cb --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/ViewTree.cpp" @@ -0,0 +1,43 @@ + +#include "pch.h" +#include "framework.h" +#include "ViewTree.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CViewTree + +CViewTree::CViewTree() noexcept +{ +} + +CViewTree::~CViewTree() +{ +} + +BEGIN_MESSAGE_MAP(CViewTree, CTreeCtrl) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 消息处理程序 + +BOOL CViewTree::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult); + + NMHDR* pNMHDR = (NMHDR*)lParam; + ASSERT(pNMHDR != nullptr); + +#pragma warning(suppress : 26454) + if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips() != nullptr) + { + GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); + } + + return bRes; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/ViewTree.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/ViewTree.h" new file mode 100644 index 0000000..0267d80 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/ViewTree.h" @@ -0,0 +1,23 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 窗口 + +class CViewTree : public CTreeCtrl +{ +// 构造 +public: + CViewTree() noexcept; + +// 重写 +protected: + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + +// 实现 +public: + virtual ~CViewTree(); + +protected: + DECLARE_MESSAGE_MAP() +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/framework.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/pch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/pch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/pch.h" new file mode 100644 index 0000000..9660927 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/pch.h" @@ -0,0 +1,13 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" + +#endif //PCH_H diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/BezierSurface.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/BezierSurface.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/BezierSurface.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/BezierSurface.rc2" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/BezierSurface.rc2" new file mode 100644 index 0000000..ce9d616 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/BezierSurface.rc2" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/BezierSurfaceDoc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/BezierSurfaceDoc.ico" new file mode 100644 index 0000000..96365d4 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/BezierSurfaceDoc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/Toolbar.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/Toolbar.bmp" new file mode 100644 index 0000000..d501723 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/Toolbar.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/Toolbar256.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/Toolbar256.bmp" new file mode 100644 index 0000000..91a2553 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/Toolbar256.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/class_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/class_view.ico" new file mode 100644 index 0000000..bf6b0dd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/class_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/class_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/class_view_hc.ico" new file mode 100644 index 0000000..3112bf2 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/class_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/classview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/classview.bmp" new file mode 100644 index 0000000..1e02aa1 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/classview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/classview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/classview_hc.bmp" new file mode 100644 index 0000000..6b22e78 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/classview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/explorer.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/explorer.bmp" new file mode 100644 index 0000000..01298ba Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/explorer.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/explorer_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/explorer_hc.bmp" new file mode 100644 index 0000000..697199d Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/explorer_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/file_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/file_view.ico" new file mode 100644 index 0000000..0f93f52 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/file_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/file_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/file_view_hc.ico" new file mode 100644 index 0000000..42ec435 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/file_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/fileview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/fileview.bmp" new file mode 100644 index 0000000..a2d62d0 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/fileview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/fileview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/fileview_hc.bmp" new file mode 100644 index 0000000..b60f483 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/fileview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/menuimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/menuimages.bmp" new file mode 100644 index 0000000..7771841 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/menuimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/menuimages_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/menuimages_hc.bmp" new file mode 100644 index 0000000..577926e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/menuimages_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/output_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/output_wnd.ico" new file mode 100644 index 0000000..d14f991 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/output_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/output_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/output_wnd_hc.ico" new file mode 100644 index 0000000..fdd27e8 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/output_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/properties.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/properties.bmp" new file mode 100644 index 0000000..72e2b29 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/properties.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/properties_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/properties_hc.bmp" new file mode 100644 index 0000000..d18a7ca Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/properties_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/properties_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/properties_wnd.ico" new file mode 100644 index 0000000..3611766 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/properties_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/properties_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/properties_wnd_hc.ico" new file mode 100644 index 0000000..1e06b64 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/properties_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/sort.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/sort.bmp" new file mode 100644 index 0000000..0307301 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/sort.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/sort_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/sort_hc.bmp" new file mode 100644 index 0000000..720e742 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/sort_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/userimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/userimages.bmp" new file mode 100644 index 0000000..affe657 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/res/userimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/resource.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/resource.h" new file mode 100644 index 0000000..54e2a1f --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/resource.h" @@ -0,0 +1,98 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ 生成的包含文件。 +// 供 BezierSurface.rc 使用 +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_POPUP_EDIT 119 +#define ID_STATUSBAR_PANE1 120 +#define ID_STATUSBAR_PANE2 121 +#define IDS_STATUS_PANE1 122 +#define IDS_STATUS_PANE2 123 +#define IDS_TOOLBAR_STANDARD 124 +#define IDS_TOOLBAR_CUSTOMIZE 125 +#define ID_VIEW_CUSTOMIZE 126 +#define IDR_MAINFRAME 128 +#define IDR_MAINFRAME_256 129 +#define IDR_BezierSurfaceTYPE 130 +#define ID_WINDOW_MANAGER 131 +#define ID_VIEW_FILEVIEW 133 +#define ID_VIEW_CLASSVIEW 134 +#define ID_PROPERTIES 135 +#define ID_OPEN 136 +#define ID_OPEN_WITH 137 +#define ID_DUMMY_COMPILE 138 +#define ID_CLASS_ADD_MEMBER_FUNCTION 139 +#define ID_CLASS_ADD_MEMBER_VARIABLE 140 +#define ID_CLASS_DEFINITION 141 +#define ID_CLASS_PROPERTIES 142 +#define ID_NEW_FOLDER 143 +#define ID_SORT_MENU 144 +#define ID_SORTING_GROUPBYTYPE 145 +#define ID_SORTING_SORTALPHABETIC 146 +#define ID_SORTING_SORTBYTYPE 147 +#define ID_SORTING_SORTBYACCESS 148 +#define ID_VIEW_OUTPUTWND 149 +#define ID_VIEW_PROPERTIESWND 150 +#define ID_SORTPROPERTIES 151 +#define ID_PROPERTIES1 152 +#define ID_PROPERTIES2 153 +#define ID_EXPAND_ALL 154 +#define IDS_FILE_VIEW 155 +#define IDS_CLASS_VIEW 156 +#define IDS_OUTPUT_WND 157 +#define IDS_PROPERTIES_WND 158 +#define IDI_FILE_VIEW 161 +#define IDI_FILE_VIEW_HC 162 +#define IDI_CLASS_VIEW 163 +#define IDI_CLASS_VIEW_HC 164 +#define IDI_OUTPUT_WND 165 +#define IDI_OUTPUT_WND_HC 166 +#define IDI_PROPERTIES_WND 167 +#define IDI_PROPERTIES_WND_HC 168 +#define IDR_EXPLORER 169 +#define IDB_EXPLORER_24 170 +#define IDR_SORT 171 +#define IDB_SORT_24 172 +#define IDR_POPUP_SORT 173 +#define IDR_POPUP_EXPLORER 174 +#define IDB_FILE_VIEW 175 +#define IDB_FILE_VIEW_24 176 +#define IDB_CLASS_VIEW 177 +#define IDB_CLASS_VIEW_24 178 +#define IDR_MENU_IMAGES 179 +#define IDB_MENU_IMAGES_24 180 +#define ID_TOOLS_MACRO 181 +#define IDR_OUTPUT_POPUP 182 +#define IDR_PROPERTIES 183 +#define IDB_PROPERTIES_HC 184 +#define IDR_THEME_MENU 200 +#define ID_SET_STYLE 201 +#define ID_VIEW_APPLOOK_WIN_2000 205 +#define ID_VIEW_APPLOOK_OFF_XP 206 +#define ID_VIEW_APPLOOK_WIN_XP 207 +#define ID_VIEW_APPLOOK_OFF_2003 208 +#define ID_VIEW_APPLOOK_VS_2005 209 +#define ID_VIEW_APPLOOK_VS_2008 210 +#define ID_VIEW_APPLOOK_OFF_2007_BLUE 215 +#define ID_VIEW_APPLOOK_OFF_2007_BLACK 216 +#define ID_VIEW_APPLOOK_OFF_2007_SILVER 217 +#define ID_VIEW_APPLOOK_OFF_2007_AQUA 218 +#define ID_VIEW_APPLOOK_WINDOWS_7 219 +#define IDS_BUILD_TAB 300 +#define IDS_DEBUG_TAB 301 +#define IDS_FIND_TAB 302 +#define IDS_EXPLORER 305 +#define IDS_EDIT_MENU 306 +#define ID_32771 32771 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 310 +#define _APS_NEXT_COMMAND_VALUE 32772 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 310 +#endif +#endif diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/targetver.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/BezierSurface/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246-\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\344\270\211.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246-\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\344\270\211.pdf" new file mode 100644 index 0000000..bb00a6d Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex3/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246-\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\344\270\211.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.aps" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.aps" new file mode 100644 index 0000000..90a45be Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.aps" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.cpp" new file mode 100644 index 0000000..751e480 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.cpp" @@ -0,0 +1,219 @@ + +// BezierSurface.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "afxwinappex.h" +#include "afxdialogex.h" +#include "BezierSurface.h" +#include "MainFrm.h" + +#include "BezierSurfaceDoc.h" +#include "BezierSurfaceView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CBezierSurfaceApp + +BEGIN_MESSAGE_MAP(CBezierSurfaceApp, CWinAppEx) + ON_COMMAND(ID_APP_ABOUT, &CBezierSurfaceApp::OnAppAbout) + // 基于文件的标准文档命令 + ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) + // 标准打印设置命令 + ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup) +END_MESSAGE_MAP() + + +// CBezierSurfaceApp 构造 + +CBezierSurfaceApp::CBezierSurfaceApp() noexcept +{ + m_bHiColorIcons = TRUE; + + + m_nAppLook = 0; + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; +#ifdef _MANAGED + // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则: + // 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。 + // 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。 + System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); +#endif + + // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式 + //为 CompanyName.ProductName.SubProduct.VersionInformation + SetAppID(_T("BezierSurface.AppID.NoVersion")); + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + +// 唯一的 CBezierSurfaceApp 对象 + +CBezierSurfaceApp theApp; + + +// CBezierSurfaceApp 初始化 + +BOOL CBezierSurfaceApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinAppEx::InitInstance(); + + + // 初始化 OLE 库 + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + + AfxEnableControlContainer(); + + EnableTaskbarInteraction(FALSE); + + // 使用 RichEdit 控件需要 AfxInitRichEdit2() + // AfxInitRichEdit2(); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) + + + InitContextMenuManager(); + + InitKeyboardManager(); + + InitTooltipManager(); + CMFCToolTipInfo ttParams; + ttParams.m_bVislManagerTheme = TRUE; + theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, + RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); + + // 注册应用程序的文档模板。 文档模板 + // 将用作文档、框架窗口和视图之间的连接 + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(CBezierSurfaceDoc), + RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 + RUNTIME_CLASS(CBezierSurfaceView)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + + + // 分析标准 shell 命令、DDE、打开文件操作的命令行 + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + + + // 调度在命令行中指定的命令。 如果 + // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + + // 唯一的一个窗口已初始化,因此显示它并对其进行更新 + m_pMainWnd->ShowWindow(SW_SHOW); + m_pMainWnd->UpdateWindow(); + return TRUE; +} + +int CBezierSurfaceApp::ExitInstance() +{ + //TODO: 处理可能已添加的附加资源 + AfxOleTerm(FALSE); + + return CWinAppEx::ExitInstance(); +} + +// CBezierSurfaceApp 消息处理程序 + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg() noexcept; + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + +// 用于运行对话框的应用程序命令 +void CBezierSurfaceApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +// CBezierSurfaceApp 自定义加载/保存方法 + +void CBezierSurfaceApp::PreLoadState() +{ + BOOL bNameValid; + CString strName; + bNameValid = strName.LoadString(IDS_EDIT_MENU); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); + bNameValid = strName.LoadString(IDS_EXPLORER); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EXPLORER); +} + +void CBezierSurfaceApp::LoadCustomState() +{ +} + +void CBezierSurfaceApp::SaveCustomState() +{ +} + +// CBezierSurfaceApp 消息处理程序 + + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.h" new file mode 100644 index 0000000..f509065 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.h" @@ -0,0 +1,40 @@ + +// BezierSurface.h: BezierSurface 应用程序的主头文件 +// +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// CBezierSurfaceApp: +// 有关此类的实现,请参阅 BezierSurface.cpp +// + +class CBezierSurfaceApp : public CWinAppEx +{ +public: + CBezierSurfaceApp() noexcept; + + +// 重写 +public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + +// 实现 + UINT m_nAppLook; + BOOL m_bHiColorIcons; + + virtual void PreLoadState(); + virtual void LoadCustomState(); + virtual void SaveCustomState(); + + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern CBezierSurfaceApp theApp; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.rc" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.rc" new file mode 100644 index 0000000..56fc410 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.rc" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.sln" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.sln" new file mode 100644 index 0000000..2049720 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BezierSurface", "BezierSurface.vcxproj", "{0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Debug|x64.ActiveCfg = Debug|x64 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Debug|x64.Build.0 = Debug|x64 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Debug|x86.ActiveCfg = Debug|Win32 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Debug|x86.Build.0 = Debug|Win32 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Release|x64.ActiveCfg = Release|x64 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Release|x64.Build.0 = Release|x64 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Release|x86.ActiveCfg = Release|Win32 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E8A2D4C1-10AA-44DC-8B3A-EFDF8730ECBC} + EndGlobalSection +EndGlobal diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.vcxproj" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.vcxproj" new file mode 100644 index 0000000..90cc981 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.vcxproj" @@ -0,0 +1,273 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {0B8D3D10-BC59-4D7B-93C6-B8442B679E5C} + MFCProj + BezierSurface + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.vcxproj.filters" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.vcxproj.filters" new file mode 100644 index 0000000..7349994 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.vcxproj.filters" @@ -0,0 +1,237 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.vcxproj.user" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.vcxproj.user" new file mode 100644 index 0000000..6d289ab --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurface.vcxproj.user" @@ -0,0 +1,6 @@ + + + + BezierSurface.rc + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurfaceDoc.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurfaceDoc.cpp" new file mode 100644 index 0000000..3581e97 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurfaceDoc.cpp" @@ -0,0 +1,138 @@ + +// BezierSurfaceDoc.cpp: CBezierSurfaceDoc 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "BezierSurface.h" +#endif + +#include "BezierSurfaceDoc.h" + +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CBezierSurfaceDoc + +IMPLEMENT_DYNCREATE(CBezierSurfaceDoc, CDocument) + +BEGIN_MESSAGE_MAP(CBezierSurfaceDoc, CDocument) +END_MESSAGE_MAP() + + +// CBezierSurfaceDoc 构造/析构 + +CBezierSurfaceDoc::CBezierSurfaceDoc() noexcept +{ + // TODO: 在此添加一次性构造代码 + +} + +CBezierSurfaceDoc::~CBezierSurfaceDoc() +{ +} + +BOOL CBezierSurfaceDoc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: 在此添加重新初始化代码 + // (SDI 文档将重用该文档) + + return TRUE; +} + + + + +// CBezierSurfaceDoc 序列化 + +void CBezierSurfaceDoc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: 在此添加存储代码 + } + else + { + // TODO: 在此添加加载代码 + } +} + +#ifdef SHARED_HANDLERS + +// 缩略图的支持 +void CBezierSurfaceDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds) +{ + // 修改此代码以绘制文档数据 + dc.FillSolidRect(lprcBounds, RGB(255, 255, 255)); + + CString strText = _T("TODO: implement thumbnail drawing here"); + LOGFONT lf; + + CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + pDefaultGUIFont->GetLogFont(&lf); + lf.lfHeight = 36; + + CFont fontDraw; + fontDraw.CreateFontIndirect(&lf); + + CFont* pOldFont = dc.SelectObject(&fontDraw); + dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK); + dc.SelectObject(pOldFont); +} + +// 搜索处理程序的支持 +void CBezierSurfaceDoc::InitializeSearchContent() +{ + CString strSearchContent; + // 从文档数据设置搜索内容。 + // 内容部分应由“;”分隔 + + // 例如: strSearchContent = _T("point;rectangle;circle;ole object;"); + SetSearchContent(strSearchContent); +} + +void CBezierSurfaceDoc::SetSearchContent(const CString& value) +{ + if (value.IsEmpty()) + { + RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); + } + else + { + CMFCFilterChunkValueImpl *pChunk = nullptr; + ATLTRY(pChunk = new CMFCFilterChunkValueImpl); + if (pChunk != nullptr) + { + pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT); + SetChunkValue(pChunk); + } + } +} + +#endif // SHARED_HANDLERS + +// CBezierSurfaceDoc 诊断 + +#ifdef _DEBUG +void CBezierSurfaceDoc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CBezierSurfaceDoc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// CBezierSurfaceDoc 命令 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurfaceDoc.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurfaceDoc.h" new file mode 100644 index 0000000..9012779 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurfaceDoc.h" @@ -0,0 +1,48 @@ + +// BezierSurfaceDoc.h: CBezierSurfaceDoc 类的接口 +// + + +#pragma once + + +class CBezierSurfaceDoc : public CDocument +{ +protected: // 仅从序列化创建 + CBezierSurfaceDoc() noexcept; + DECLARE_DYNCREATE(CBezierSurfaceDoc) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); +#ifdef SHARED_HANDLERS + virtual void InitializeSearchContent(); + virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds); +#endif // SHARED_HANDLERS + +// 实现 +public: + virtual ~CBezierSurfaceDoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// 生成的消息映射函数 +protected: + DECLARE_MESSAGE_MAP() + +#ifdef SHARED_HANDLERS + // 用于为搜索处理程序设置搜索内容的 Helper 函数 + void SetSearchContent(const CString& value); +#endif // SHARED_HANDLERS +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurfaceView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurfaceView.cpp" new file mode 100644 index 0000000..bd8e379 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurfaceView.cpp" @@ -0,0 +1,263 @@ + +// BezierSurfaceView.cpp: CBezierSurfaceView 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "BezierSurface.h" +#endif + +#include "BezierSurfaceDoc.h" +#include "BezierSurfaceView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CBezierSurfaceView + +IMPLEMENT_DYNCREATE(CBezierSurfaceView, CView) + +BEGIN_MESSAGE_MAP(CBezierSurfaceView, CView) + // 标准打印命令 + ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CBezierSurfaceView::OnFilePrintPreview) + ON_WM_CONTEXTMENU() + ON_WM_RBUTTONUP() + ON_COMMAND(ID_32771, &CBezierSurfaceView::GraphicAnimation) + ON_WM_KEYDOWN() + ON_WM_KEYUP() + ON_WM_TIMER() + ON_UPDATE_COMMAND_UI(ID_32771, &CBezierSurfaceView::OnUpdateGraphicAnimation) +END_MESSAGE_MAP() + +// CBezierSurfaceView 构造/析构 + +CBezierSurfaceView::CBezierSurfaceView() noexcept +{ + // TODO: 在此处添加构造代码 + bPlay = FALSE; + double R = 200; + double m = 0.5523; + CP2 P2[7]; + P2[0] = CP2(0, -1); + P2[1] = CP2(m, -1); + P2[2] = CP2(1, -m); + P2[3] = CP2(1, 0); + P2[4] = CP2(1, m); + P2[5] = CP2(m, 1); + P2[6] = CP2(0, 1); + CP3 DownPoint[4]; + DownPoint[0] = CP3(P2[0].x, P2[0].y, 0.0); + DownPoint[1] = CP3(P2[1].x, P2[1].y, 0.0); + DownPoint[2] = CP3(P2[2].x, P2[2].y, 0.0); + DownPoint[3] = CP3(P2[3].x, P2[3].y, 0.0); + revoDown.ReadCubicBezierControlPoint(DownPoint); + tranDown.SetMatrix(revoDown.GetVertexArrayName(), 48); + tranDown.Scale(R, R, R); + CP3 UpPoint[4]; + UpPoint[0] = CP3(P2[3].x, P2[3].y, 0.0); + UpPoint[1] = CP3(P2[4].x, P2[4].y, 0.0); + UpPoint[2] = CP3(P2[5].x, P2[5].y, 0.0); + UpPoint[3] = CP3(P2[6].x, P2[6].y, 0.0); + revoUp.ReadCubicBezierControlPoint(UpPoint); + tranUp.SetMatrix(revoUp.GetVertexArrayName(), 48); + tranUp.Scale(R, R, R); + Alpha = 60; + tranUp.RotateX(Alpha); + tranDown.RotateX(Alpha); + Beta = 30; + tranUp.RotateY(Beta); + tranDown.RotateY(Beta); +} + +CBezierSurfaceView::~CBezierSurfaceView() +{ +} + +BOOL CBezierSurfaceView::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return CView::PreCreateWindow(cs); +} + +// CBezierSurfaceView 绘图 + +void CBezierSurfaceView::OnDraw(CDC* pDC) +{ + CBezierSurfaceDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + + // TODO: 在此处为本机数据添加绘制代码 + DoubleBuffer(pDC); +} + +void CBezierSurfaceView::DoubleBuffer(CDC* pDC) +{ + CRect rect; + GetClientRect(&rect); + pDC->SetMapMode(MM_ANISOTROPIC); + pDC->SetWindowExt(rect.Width(), rect.Height()); + pDC->SetViewportExt(rect.Width(), -rect.Height()); + pDC->SetViewportOrg(rect.Width() / 2, rect.Height() / 2); + CDC memDC; + memDC.CreateCompatibleDC(pDC); + CBitmap NewBitmap, * pOldBitmap; + NewBitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()); + pOldBitmap = memDC.SelectObject(&NewBitmap); + memDC.FillSolidRect(rect, pDC->GetBkColor()); + memDC.SetMapMode(MM_ANISOTROPIC); + memDC.SetWindowExt(rect.Width(), rect.Height()); + memDC.SetViewportExt(rect.Width(), -rect.Height()); + memDC.SetViewportOrg(rect.Width() / 2, rect.Height() / 2); + rect.OffsetRect(-rect.Width() / 2, -rect.Height() / 2); + DrawObject(&memDC); + pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memDC, -rect.Width() / 2, -rect.Height() / 2, SRCCOPY);//将内存memDC中的位图拷贝到显示pDC中 + memDC.SelectObject(pOldBitmap); + NewBitmap.DeleteObject(); +} + +void CBezierSurfaceView::DrawObject(CDC* pDC) +{ + revoUp.DrawRevolutionSurface(pDC); + revoDown.DrawRevolutionSurface(pDC); +} + +// CBezierSurfaceView 打印 + + +void CBezierSurfaceView::OnFilePrintPreview() +{ +#ifndef SHARED_HANDLERS + AFXPrintPreview(this); +#endif +} + +BOOL CBezierSurfaceView::OnPreparePrinting(CPrintInfo* pInfo) +{ + // 默认准备 + return DoPreparePrinting(pInfo); +} + +void CBezierSurfaceView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加额外的打印前进行的初始化过程 +} + +void CBezierSurfaceView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加打印后进行的清理过程 +} + +void CBezierSurfaceView::OnRButtonUp(UINT /* nFlags */, CPoint point) +{ + ClientToScreen(&point); + OnContextMenu(this, point); +} + +void CBezierSurfaceView::OnContextMenu(CWnd* /* pWnd */, CPoint point) +{ +#ifndef SHARED_HANDLERS + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE); +#endif +} + + +// CBezierSurfaceView 诊断 + +#ifdef _DEBUG +void CBezierSurfaceView::AssertValid() const +{ + CView::AssertValid(); +} + +void CBezierSurfaceView::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +CBezierSurfaceDoc* CBezierSurfaceView::GetDocument() const // 非调试版本是内联的 +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBezierSurfaceDoc))); + return (CBezierSurfaceDoc*)m_pDocument; +} +#endif //_DEBUG + + +// CBezierSurfaceView 消息处理程序 + + +void CBezierSurfaceView::GraphicAnimation() +{ + // TODO: 在此添加命令处理程序代码 + bPlay = !bPlay; + if (bPlay) + SetTimer(1, 150, NULL); + else + KillTimer(1); +} + + +void CBezierSurfaceView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + // TODO: 在此添加消息处理程序代码和/或调用默认值 + switch (nChar) + { + case VK_UP: + Alpha = +2; + tranUp.RotateX(Alpha); + tranDown.RotateX(Alpha); + break; + case VK_DOWN: + Alpha = -2; + tranUp.RotateX(Alpha); + tranDown.RotateX(Alpha); + break; + case VK_LEFT: + Beta = -2; + tranUp.RotateY(Beta); + tranDown.RotateY(Beta); + break; + case VK_RIGHT: + Beta = 2; + tranUp.RotateY(Beta); + tranDown.RotateY(Beta); + break; + default: + break; + } + Invalidate(FALSE); + CView::OnKeyDown(nChar, nRepCnt, nFlags); +} + + +void CBezierSurfaceView::OnTimer(UINT_PTR nIDEvent) +{ + // TODO: 在此添加命令更新用户界面处理程序代码 + Alpha = 2; Beta = 2; + tranUp.RotateX(Alpha); + tranDown.RotateX(Alpha); + tranUp.RotateY(Beta); + tranDown.RotateY(Beta); + Invalidate(FALSE); + CView::OnTimer(nIDEvent); +} + + +void CBezierSurfaceView::OnUpdateGraphicAnimation(CCmdUI* pCmdUI) +{ + // TODO: 在此添加命令更新用户界面处理程序代码 + if (bPlay) + pCmdUI->SetCheck(TRUE); + else + pCmdUI->SetCheck(FALSE); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurfaceView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurfaceView.h" new file mode 100644 index 0000000..c0407f5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/BezierSurfaceView.h" @@ -0,0 +1,63 @@ + +// BezierSurfaceView.h: CBezierSurfaceView 类的接口 +// + +#pragma once +#include"CTrans3.h" +#include"CRevolution.h" + +class CBezierSurfaceView : public CView +{ +protected: // 仅从序列化创建 + CBezierSurfaceView() noexcept; + DECLARE_DYNCREATE(CBezierSurfaceView) + +// 特性 +public: + CBezierSurfaceDoc* GetDocument() const; + +// 操作 +public: + +// 重写 +public: + virtual void OnDraw(CDC* pDC); // 重写以绘制该视图 + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// 实现 +public: + virtual ~CBezierSurfaceView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + bool bPlay; + CRevolution revoDown, revoUp; + double Alpha, Beta; + CTrans3 tranUp, tranDown; + void DoubleBuffer(CDC* pDC); + void DrawObject(CDC* pDC); +// 生成的消息映射函数 +protected: + afx_msg void OnFilePrintPreview(); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + DECLARE_MESSAGE_MAP() +public: + afx_msg void GraphicAnimation(); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnTimer(UINT_PTR nIDEvent); + afx_msg void OnUpdateGraphicAnimation(CCmdUI* pCmdUI); +}; + +#ifndef _DEBUG // BezierSurfaceView.cpp 中的调试版本 +inline CBezierSurfaceDoc* CBezierSurfaceView::GetDocument() const + { return reinterpret_cast(m_pDocument); } +#endif + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CBezierPatch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CBezierPatch.cpp" new file mode 100644 index 0000000..ad74c3d --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CBezierPatch.cpp" @@ -0,0 +1,176 @@ +#include "pch.h" +#include "CBezierPatch.h" +#include "CVector3.h" +#define ROUND(d) int(d + 0.5) +CBezierPatch::CBezierPatch(void) +{ + ReNumber = 0; +} +CBezierPatch::~CBezierPatch(void) +{ +} +void CBezierPatch::ReadControlPoint(CP3 CtrPt[4][4], int ReNumber) +{ + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + this->CtrPt[i][j] = CtrPt[i][j]; + this->ReNumber = ReNumber; +} +void CBezierPatch::DrawCurvedPatch(CDC* pDC) +{ + CMesh Mesh; + Mesh.BL = CT2(0, 0), Mesh.BR = CT2(1, 0); + Mesh.TR = CT2(1, 1), Mesh.TL = CT2(0, 1); + Recursion(pDC, ReNumber, Mesh); +} +void CBezierPatch::Recursion(CDC* pDC, int ReNumber, CMesh Mesh) +{ + if (0 == ReNumber) + { + Tessellation(Mesh); + DrawFacet(pDC); + return; + } + else + { + CT2 Mid = (Mesh.BL + Mesh.TR) / 2.0; + CMesh SubMesh[4]; + //ӳ + SubMesh[0].BL = Mesh.BL; + SubMesh[0].BR = CT2(Mid.u, Mesh.BL.v); + SubMesh[0].TR = CT2(Mid.u, Mid.v); + SubMesh[0].TL = CT2(Mesh.BL.u, Mid.v); + //ӳ + SubMesh[1].BL = SubMesh[0].BR; + SubMesh[1].BR = Mesh.BR; + SubMesh[1].TR = CT2(Mesh.BR.u, Mid.v); + SubMesh[1].TL = SubMesh[0].TR; + //ӳ + SubMesh[2].BL = SubMesh[1].TL; + SubMesh[2].BR = SubMesh[1].TR; + SubMesh[2].TR = Mesh.TR; + SubMesh[2].TL = CT2(Mid.u, Mesh.TR.v); + //ӳ + SubMesh[3].BL = SubMesh[0].TL; + SubMesh[3].BR = SubMesh[2].BL; + SubMesh[3].TR = SubMesh[2].TL; + SubMesh[3].TL = Mesh.TL; + Recursion(pDC, ReNumber - 1, SubMesh[0]); + Recursion(pDC, ReNumber - 1, SubMesh[1]); + Recursion(pDC, ReNumber - 1, SubMesh[2]); + Recursion(pDC, ReNumber - 1, SubMesh[3]); + } +} +void CBezierPatch::Tessellation(CMesh Mesh) +{ + double M[4][4]; + M[0][0] = -1, M[0][1] = 3, M[0][2] = -3, M[0][3] = 1; + M[1][0] = 3, M[1][1] = -6, M[1][2] = 3, M[1][3] = 0; + M[2][0] = -3, M[2][1] = 3, M[2][2] = 0, M[2][3] = 0; + M[3][0] = 1, M[3][1] = 0, M[3][2] = 0, M[3][3] = 0; + CP3 P3[4][4]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + P3[i][j] = CtrPt[i][j]; + LeftMultiplyMatrix(M, P3); + TransposeMatrix(M); + RightMultiplyMatrix(P3, M); + double u0, u1, u2, u3, v0, v1, v2, v3; + double u[4] = { Mesh.BL.u,Mesh.BR.u ,Mesh.TR.u ,Mesh.TL.u }; + double v[4] = { Mesh.BL.v,Mesh.BR.v ,Mesh.TR.v ,Mesh.TL.v }; + for (int i = 0; i < 4; i++) + { + u3 = pow(u[i], 3.0), u2 = pow(u[i], 2.0), u1 = u[i], u0 = 1; + v3 = pow(v[i], 3.0), v2 = pow(v[i], 2.0), v1 = v[i], v0 = 1; + CP3 Pt = (u3 * P3[0][0] + u2 * P3[1][0] + u1 * P3[2][0] + u0 * P3[3][0]) * v3 + + (u3 * P3[0][1] + u2 * P3[1][1] + u1 * P3[2][1] + u0 * P3[3][1]) * v2 + + (u3 * P3[0][2] + u2 * P3[1][2] + u1 * P3[2][2] + u0 * P3[3][2]) * v1 + + (u3 * P3[0][3] + u2 * P3[1][3] + u1 * P3[2][3] + u0 * P3[3][3]) * v0; + quadrP[i] = Pt; + } +} +void CBezierPatch::DrawFacet(CDC* pDC) +{ + + CP2 ScreenPoint[4]; CP3 ViewPoint = projection.GetEye(); + CVector3 ViewVector(quadrP[0], ViewPoint); + ViewVector = ViewVector.Normalize(); + CVector3 Vector01(quadrP[0], quadrP[1]); + CVector3 Vector02(quadrP[0], quadrP[2]); + CVector3 Vector03(quadrP[0], quadrP[3]); + CVector3 FacetNormalA = CrossProduct(Vector01, Vector02); + CVector3 FacetNormalB = CrossProduct(Vector02, Vector03); + CVector3 FacetNormal = (FacetNormalA + FacetNormalB); + FacetNormal = FacetNormal.Normalize(); + CPen pen(PS_SOLID, 1, RGB(0, 0, 0)); + CPen* pOldPen = pDC->SelectObject(&pen); + if (DotProduct(ViewVector, FacetNormal) >= 0) + { + for (int nPoint = 0; nPoint < 4; nPoint++) + ScreenPoint[nPoint] = projection.PerspectiveProjection(quadrP[nPoint]); + pDC->MoveTo(ROUND(ScreenPoint[0].x), ROUND(ScreenPoint[0].y)); + pDC->LineTo(ROUND(ScreenPoint[1].x), ROUND(ScreenPoint[1].y)); + pDC->LineTo(ROUND(ScreenPoint[2].x), ROUND(ScreenPoint[2].y)); + pDC->LineTo(ROUND(ScreenPoint[3].x), ROUND(ScreenPoint[3].y)); + pDC->LineTo(ROUND(ScreenPoint[0].x), ROUND(ScreenPoint[0].y)); + } + pDC->SelectObject(pOldPen); +} + + +void CBezierPatch::LeftMultiplyMatrix(double M[4][4], CP3 P[4][4]) +{ + CP3 PTemp[4][4]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + PTemp[i][j] = M[i][0] * P[0][j] + M[i][1] * P[1][j] + M[i][2] * P[2][j] + M[i][3] + * P[3][j]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + P[i][j] = PTemp[i][j]; +} +void CBezierPatch::RightMultiplyMatrix(CP3 P[4][4], double M[4][4]) +{ + CP3 PTemp[4][4]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + PTemp[i][j] = P[i][0] * M[0][j] + P[i][1] * M[1][j] + P[i][2] * M[2][j] + P[i][3] + * M[3][j]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + P[i][j] = PTemp[i][j]; +} +void CBezierPatch::TransposeMatrix(double M[4][4]) +{ + double PTemp[4][4]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + PTemp[j][i] = M[i][j]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + M[i][j] = PTemp[i][j]; +} +void CBezierPatch::DrawControlGrid(CDC* pDC) +{ + CP2 P2[4][4]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + P2[i][j] = projection.PerspectiveProjection(CtrPt[i][j]); + CPen NewPen, * pOldPen; + NewPen.CreatePen(PS_SOLID, 3, RGB(0, 128, 0)); + pOldPen = pDC->SelectObject(&NewPen); + for (int i = 0; i < 4; i++) + { + pDC->MoveTo(ROUND(P2[i][0].x), ROUND(P2[i][0].y)); + for (int j = 1; j < 4; j++) + pDC->LineTo(ROUND(P2[i][j].x), ROUND(P2[i][j].y)); + } + for (int j = 0; j < 4; j++) + { + pDC->MoveTo(ROUND(P2[0][j].x), ROUND(P2[0][j].y)); + for (int i = 1; i < 4; i++) + pDC->LineTo(ROUND(P2[i][j].x), ROUND(P2[i][j].y)); + } + pDC->SelectObject(pOldPen); + NewPen.DeleteObject(); +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CBezierPatch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CBezierPatch.h" new file mode 100644 index 0000000..3838777 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CBezierPatch.h" @@ -0,0 +1,25 @@ +#pragma once +#include"CMesh.h" +#include"CP3.h" +#include"CProjection.h" +class CBezierPatch +{ +public: + CBezierPatch(void); + virtual ~CBezierPatch(void); + void ReadControlPoint(CP3 CtrPt[4][4], int ReNumber); + void DrawCurvedPatch(CDC* pDC); + void DrawControlGrid(CDC* pDC); +private: + void Recursion(CDC* pDC, int ReNumber, CMesh Mesh); + void Tessellation(CMesh Mesh); + void DrawFacet(CDC* pDC); + void LeftMultiplyMatrix(double M[4][4], CP3 P[4][4]); + void RightMultiplyMatrix(CP3 P[4][4], double M[4][4]); + void TransposeMatrix(double M[4][4]); +private: + int ReNumber; + CP3 quadrP[4]; + CP3 CtrPt[4][4]; + CProjection projection; +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CMesh.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CMesh.cpp" new file mode 100644 index 0000000..fdaa3e2 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CMesh.cpp" @@ -0,0 +1,2 @@ +#include "pch.h" +#include "CMesh.h" diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CMesh.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CMesh.h" new file mode 100644 index 0000000..d86ae14 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CMesh.h" @@ -0,0 +1,10 @@ +#pragma once +#include"CT2.h" +class CMesh +{ +public: + CMesh(void) {} + virtual ~CMesh(void) {} +public: + CT2 BL, BR, TR, TL; +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CP2.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CP2.cpp" new file mode 100644 index 0000000..a537eb7 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CP2.cpp" @@ -0,0 +1,74 @@ +#include "pch.h" +#include "CP2.h" +CP2::CP2(void) +{ + x = 0.0; + y = 0.0; + w = 1.0; +} +CP2::~CP2(void) +{ +} +CP2::CP2(double x, double y) +{ + this->x = x; + this->y = y; + this->w = 1.0; +} +CP2 operator + (const CP2& p0, const CP2& p1)// +{ + CP2 result; + result.x = p0.x + p1.x; + result.y = p0.y + p1.y; + return result; +} +CP2 operator - (const CP2& p0, const CP2& p1)// +{ + CP2 result; + result.x = p0.x - p1.x; + result.y = p0.y - p1.y; + return result; +} +CP2 operator * (const CP2& p, double scalar)//ͳĻ +{ + return CP2(p.x * scalar, p.y * scalar); +} +CP2 operator * (double scalar, const CP2& p)//ͳĻ +{ + return CP2(p.x * scalar, p.y * scalar); +} +CP2 operator / (const CP2& p, double scalar)// +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + CP2 result; + result.x = p.x / scalar; + result.y = p.y / scalar; + return result; +} +CP2 operator+=(CP2& p0, CP2& p1) +{ + p0.x += p1.x; + p0.y += p1.y; + return p0; +} +CP2 operator-=(CP2& p0, CP2& p1) +{ + p0.x -= p1.x; + p0.y -= p1.y; + return p0; +} +CP2 operator*=(CP2& p, double scalar) +{ + p.x *= scalar; + p.y *= scalar; + return p; +} +CP2 operator/=(CP2& p, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + p.x /= scalar; + p.y /= scalar; + return p; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CP2.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CP2.h" new file mode 100644 index 0000000..fc32cb4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CP2.h" @@ -0,0 +1,23 @@ +#pragma once +class CP2 +{ +public: + CP2(void); + virtual ~CP2(void); + CP2(double x, double y); + friend CP2 operator + (const CP2& p0, const CP2& p1);// + friend CP2 operator - (const CP2& p0, const CP2& p1); + friend CP2 operator * (const CP2& p, double scalar); + friend CP2 operator * (double scalar, const CP2& p); + friend CP2 operator / (const CP2& p, double scalar); + friend CP2 operator += (CP2& p0, CP2& p1); + friend CP2 operator -= (CP2& p0, CP2& p1); + friend CP2 operator *= (CP2& p, double scalar); + friend CP2 operator /= (CP2& p, double scalar); +public: + double x;//ֱ߶ζ˵x + double y;//ֱ߶ζ˵y + double w;// +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CP3.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CP3.cpp" new file mode 100644 index 0000000..d399eaf --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CP3.cpp" @@ -0,0 +1,47 @@ +#include "pch.h" +#include "CP3.h" +CP3::CP3(void) +{ + x = 0, y = 0, z = 0, w = 1; +} +CP3::CP3(double x, double y, double z) :CP2(x, y) +{ + this->z = z; +} +CP3::~CP3(void) +{ +} +CP3 operator + (const CP3& p0, const CP3& p1) +{ + CP3 result; + result.x = p0.x + p1.x; + result.y = p0.y + p1.y; + result.z = p0.z + p1.z; + return result; +} +CP3 operator -(const CP3& p0, const CP3& p1) +{ + CP3 result; + result.x = p0.x - p1.x; + result.y = p0.y - p1.y; + result.z = p0.z - p1.z; + return result; +} +CP3 operator *(const CP3& p, double scalar) +{ + return CP3(p.x * scalar, p.y * scalar, p.z * scalar); +} +CP3 operator *(double scalar, const CP3& p) +{ + return CP3(p.x * scalar, p.y * scalar, p.z * scalar); +} +CP3 operator /(const CP3& p, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + CP3 result; + result.x = p.x / scalar; + result.y = p.y / scalar; + result.z = p.z / scalar; + return result; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CP3.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CP3.h" new file mode 100644 index 0000000..4250bd0 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CP3.h" @@ -0,0 +1,17 @@ +#pragma once +#include "CP2.h" +class CP3 :public CP2 +{ +public: + CP3(void); + virtual ~CP3(void); + CP3(double x, double y, double z); + friend CP3 operator +(const CP3& p0, const CP3& p1); + friend CP3 operator -(const CP3& p0, const CP3& p1); + friend CP3 operator *(const CP3& p, double scalar); + friend CP3 operator *(double scalar, const CP3& p); + friend CP3 operator /(const CP3& p, double scalar); +public: + double z; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CProjection.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CProjection.cpp" new file mode 100644 index 0000000..afd3700 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CProjection.cpp" @@ -0,0 +1,43 @@ +#include "pch.h" +#include "CProjection.h" +CProjection::CProjection(void) +{ + R = 1200, d = 800; + EyePoint.x = 0, EyePoint.y = 0, EyePoint.z = R; +} +CProjection::~CProjection(void) +{ +} +void CProjection::SetEye(double R) +{ + EyePoint.z = R; +} +CP3 CProjection::GetEye(void) +{ + return EyePoint; +} +CP2 CProjection::ObliqueProjection(CP3 WorldPoint) +{ + CP2 ScreenPoint; + ScreenPoint.x = WorldPoint.x - 0.3536 * WorldPoint.z; + ScreenPoint.y = WorldPoint.y - 0.3536 * WorldPoint.z; + return ScreenPoint; +} +CP2 CProjection::OrthogonalProjection(CP3 WorldPoint) +{ + CP2 ScreenPoint; + ScreenPoint.x = WorldPoint.x; + ScreenPoint.y = WorldPoint.y; + return ScreenPoint; +} +CP2 CProjection::PerspectiveProjection(CP3 WorldPoint) +{ + CP3 ViewPoint; + ViewPoint.x = WorldPoint.x; + ViewPoint.y = WorldPoint.y; + ViewPoint.z = EyePoint.z - WorldPoint.z; + CP2 ScreenPoint; + ScreenPoint.x = d * ViewPoint.x / ViewPoint.z; + ScreenPoint.y = d * ViewPoint.y / ViewPoint.z; + return ScreenPoint; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CProjection.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CProjection.h" new file mode 100644 index 0000000..bbfb8b2 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CProjection.h" @@ -0,0 +1,16 @@ +#pragma once +#include "CP3.h" +class CProjection +{ +public: + CProjection(void); + virtual ~CProjection(void); + void SetEye(double R); + CP3 GetEye(void); + CP2 ObliqueProjection(CP3 WorldPoint); + CP2 OrthogonalProjection(CP3 WorldPoint); + CP2 PerspectiveProjection(CP3 WorldPoint); +private: + CP3 EyePoint; + double R, d; +}; \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CRevolution.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CRevolution.cpp" new file mode 100644 index 0000000..4437bc1 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CRevolution.cpp" @@ -0,0 +1,107 @@ +#include "pch.h" +#include "CRevolution.h" +void CRevolution::ReadCubicBezierControlPoint(CP3 P[4]) +{ + for (int i = 0; i < 4; i++) + this->P[i] = P[i]; + ReadVertex(); + ReadPatch(); +} +CP3* CRevolution::GetVertexArrayName(void) +{ + return V; +} +void CRevolution::ReadVertex(void) +{ + const double m = 0.5523; + //һƬ + V[0] = P[0]; + V[1] = P[1]; + V[2] = P[2]; + V[3] = P[3]; + V[4].x = V[0].x, V[4].y = V[0].y, V[4].z = -V[0].x * m; + V[5].x = V[1].x, V[5].y = V[1].y, V[5].z = -V[1].x * m; + V[6].x = V[2].x, V[6].y = V[2].y, V[6].z = -V[2].x * m; + V[7].x = V[3].x, V[7].y = V[3].y, V[7].z = -V[3].x * m; + V[8].x = V[0].x * m, V[8].y = V[0].y, V[8].z = -V[0].x; + V[9].x = V[1].x * m, V[9].y = V[1].y, V[9].z = -V[1].x; + V[10].x = V[2].x * m, V[10].y = V[2].y, V[10].z = -V[2].x; + V[11].x = V[3].x * m, V[11].y = V[3].y, V[11].z = -V[3].x; + V[12].x = V[0].z, V[12].y = V[0].y, V[12].z = -V[0].x; + V[13].x = V[1].z, V[13].y = V[1].y, V[13].z = -V[1].x; + V[14].x = V[2].z, V[14].y = V[2].y, V[14].z = -V[2].x; + V[15].x = V[3].z, V[15].y = V[3].y, V[15].z = -V[3].x; + //ڶƬ + V[16].x = -V[0].x * m, V[16].y = V[0].y, V[16].z = -V[0].x; + V[17].x = -V[1].x * m, V[17].y = V[1].y, V[17].z = -V[1].x; + V[18].x = -V[2].x * m, V[18].y = V[2].y, V[18].z = -V[2].x; + V[19].x = -V[3].x * m, V[19].y = V[3].y, V[19].z = -V[3].x; + V[20].x = -V[0].x, V[20].y = V[0].y, V[20].z = -V[0].x * m; + V[21].x = -V[1].x, V[21].y = V[1].y, V[21].z = -V[1].x * m; + V[22].x = -V[2].x, V[22].y = V[2].y, V[22].z = -V[2].x * m; + V[23].x = -V[3].x, V[23].y = V[3].y, V[23].z = -V[3].x * m; + V[24].x = -V[0].x, V[24].y = V[0].y, V[24].z = V[0].z; + V[25].x = -V[1].x, V[25].y = V[1].y, V[25].z = V[1].z; + V[26].x = -V[2].x, V[26].y = V[2].y, V[26].z = V[2].z; + V[27].x = -V[3].x, V[27].y = V[3].y, V[27].z = V[3].z; + //Ƭ + V[28].x = -V[0].x, V[28].y = V[0].y, V[28].z = V[0].x * m; + V[29].x = -V[1].x, V[29].y = V[1].y, V[29].z = V[1].x * m; + V[30].x = -V[2].x, V[30].y = V[2].y, V[30].z = V[2].x * m; + V[31].x = -V[3].x, V[31].y = V[3].y, V[31].z = V[3].x * m; + V[32].x = -V[0].x * m, V[32].y = V[0].y, V[32].z = V[0].x; + V[33].x = -V[1].x * m, V[33].y = V[1].y, V[33].z = V[1].x; + V[34].x = -V[2].x * m, V[34].y = V[2].y, V[34].z = V[2].x; + V[35].x = -V[3].x * m, V[35].y = V[3].y, V[35].z = V[3].x; + V[36].x = V[0].z, V[36].y = V[0].y, V[36].z = V[0].x; + V[37].x = V[1].z, V[37].y = V[1].y, V[37].z = V[1].x; + V[38].x = V[2].z, V[38].y = V[2].y, V[38].z = V[2].x; + V[39].x = V[3].z, V[39].y = V[3].y, V[39].z = V[3].x; + //ĿƬ + V[40].x = V[0].x * m, V[40].y = V[0].y, V[40].z = V[0].x; + V[41].x = V[1].x * m, V[41].y = V[1].y, V[41].z = V[1].x; + V[42].x = V[2].x * m, V[42].y = V[2].y, V[42].z = V[2].x; + V[43].x = V[3].x * m, V[43].y = V[3].y, V[43].z = V[3].x; + V[44].x = V[0].x, V[44].y = V[0].y, V[44].z = V[0].x * m; + V[45].x = V[1].x, V[45].y = V[1].y, V[45].z = V[1].x * m; + V[46].x = V[2].x, V[46].y = V[2].y, V[46].z = V[2].x * m; + V[47].x = V[3].x, V[47].y = V[3].y, V[47].z = V[3].x * m; +} +void CRevolution::ReadPatch(void)//Ƭ +{ + //1Ƭ + S[0].pIndex[0][0] = 0; S[0].pIndex[0][1] = 1; S[0].pIndex[0][2] = 2; S[0].pIndex[0][3] = 3; + S[0].pIndex[1][0] = 4; S[0].pIndex[1][1] = 5; S[0].pIndex[1][2] = 6; S[0].pIndex[1][3] = 7; + S[0].pIndex[2][0] = 8; S[0].pIndex[2][1] = 9; S[0].pIndex[2][2] = 10; S[0].pIndex[2][3] = 11; + S[0].pIndex[3][0] = 12; S[0].pIndex[3][1] = 13; S[0].pIndex[3][2] = 14; S[0].pIndex[3][3] = 15; + //2Ƭ + S[1].pIndex[0][0] = 12; S[1].pIndex[0][1] = 13; S[1].pIndex[0][2] = 14; S[1].pIndex[0][3] = 15; + S[1].pIndex[1][0] = 16; S[1].pIndex[1][1] = 17; S[1].pIndex[1][2] = 18; S[1].pIndex[1][3] = 19; + S[1].pIndex[2][0] = 20; S[1].pIndex[2][1] = 21; S[1].pIndex[2][2] = 22; S[1].pIndex[2][3] = 23; + S[1].pIndex[3][0] = 24; S[1].pIndex[3][1] = 25; S[1].pIndex[3][2] = 26; S[1].pIndex[3][3] = 27; + //3Ƭ + S[2].pIndex[0][0] = 24; S[2].pIndex[0][1] = 25; S[2].pIndex[0][2] = 26; S[2].pIndex[0][3] = 27; + S[2].pIndex[1][0] = 28; S[2].pIndex[1][1] = 29; S[2].pIndex[1][2] = 30; S[2].pIndex[1][3] = 31; + S[2].pIndex[2][0] = 32; S[2].pIndex[2][1] = 33; S[2].pIndex[2][2] = 34; S[2].pIndex[2][3] = 35; + S[2].pIndex[3][0] = 36; S[2].pIndex[3][1] = 37; S[2].pIndex[3][2] = 38; S[2].pIndex[3][3] = 39; + //4Ƭ + S[3].pIndex[0][0] = 36; S[3].pIndex[0][1] = 37; S[3].pIndex[0][2] = 38; S[3].pIndex[0][3] = 39; + S[3].pIndex[1][0] = 40; S[3].pIndex[1][1] = 41; S[3].pIndex[1][2] = 42; S[3].pIndex[1][3] = 43; + S[3].pIndex[2][0] = 44; S[3].pIndex[2][1] = 45; S[3].pIndex[2][2] = 46; S[3].pIndex[2][3] = 47; + S[3].pIndex[3][0] = 0; S[3].pIndex[3][1] = 1; S[3].pIndex[3][2] = 2; S[3].pIndex[3][3] = 3; +} +void CRevolution::DrawRevolutionSurface(CDC* pDC) +{ + CP3 Point[4][4]; + for (int nPatch = 0; nPatch < 4; nPatch++) + { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + Point[i][j] = V[S[nPatch].pIndex[i][j]]; + int nRecursiveDepth = 3; + CBezierPatch patch; + patch.ReadControlPoint(Point, nRecursiveDepth); + patch.DrawCurvedPatch(pDC); + //patch.DrawControlGrid(pDC); + } +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CRevolution.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CRevolution.h" new file mode 100644 index 0000000..7935ec6 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CRevolution.h" @@ -0,0 +1,19 @@ +#pragma once +#include "Patch.h" +#include"CBezierPatch.h" +class CRevolution +{ +public: + CRevolution(void) {}; + virtual ~CRevolution(void) {}; + void ReadCubicBezierControlPoint(CP3 P[4]); + CP3* GetVertexArrayName(void); + void DrawRevolutionSurface(CDC* pDC); +private: + void ReadVertex(void); + void ReadPatch(void); +private: + CP3 P[4]; + CP3 V[48]; + CPatch S[4]; +}; \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CT2.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CT2.cpp" new file mode 100644 index 0000000..42999ce --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CT2.cpp" @@ -0,0 +1,72 @@ +#include "pch.h" +#include "CT2.h" +CT2::CT2(void) +{ + u = 0.0; + v = 0.0; +} +CT2::CT2(double u, double v) +{ + this->u = u; + this->v = v; +} +CT2::~CT2(void) +{ +} +CT2 operator + (const CT2& t0, const CT2& t1)// +{ + CT2 result; + result.u = t0.u + t1.u; + result.v = t0.v + t1.v; + return result; +} +CT2 operator - (const CT2& t0, const CT2& t1)// +{ + CT2 result; + result.u = t0.u - t1.u; + result.v = t0.v - t1.v; + return result; +} +CT2 operator * (const CT2& t, double scalar)//ͳĻ +{ + return CT2(t.u * scalar, t.v * scalar); +} +CT2 operator * (double scalar, const CT2& t)//͵Ļ +{ + return CT2(t.u * scalar, t.v * scalar); +} +CT2 operator / (const CT2& t, double scalar)// +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + CT2 result; + result.u = t.u / scalar; + result.v = t.v / scalar; + return result; +} +CT2 operator += (CT2& t0, CT2& t1) +{ + t0.u = t0.u + t1.u; + t0.v = t0.v + t1.v; + return t0; +} +CT2 operator -= (CT2& t0, CT2& t1) +{ + t0.u = t0.u - t1.u; + t0.v = t0.v - t1.v; + return t0; +} +CT2 operator *= (CT2& t, double scalar) +{ + t.u = t.u * scalar; + t.v = t.v * scalar; + return t; +} +CT2 operator /= (CT2& t, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + t.u = t.u / scalar; + t.v = t.v / scalar; + return t; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CT2.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CT2.h" new file mode 100644 index 0000000..6e810e5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CT2.h" @@ -0,0 +1,20 @@ +#pragma once +class CT2 +{ +public: + CT2(void); + virtual ~CT2(void); + CT2(double u, double v); + friend CT2 operator + (const CT2& t0, const CT2& t1); + friend CT2 operator - (const CT2& t0, const CT2& t1); + friend CT2 operator * (const CT2& t, double scalar); + friend CT2 operator * (double scalar, const CT2& t); + friend CT2 operator / (const CT2& t, double scalar); + friend CT2 operator += (CT2& t0, CT2& t1); + friend CT2 operator -= (CT2& t0, CT2& t1); + friend CT2 operator *= (CT2& t, double scalar); + friend CT2 operator /= (CT2& t, double scalar); +public: + double u, v; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CTrans3.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CTrans3.cpp" new file mode 100644 index 0000000..746c3fc --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CTrans3.cpp" @@ -0,0 +1,150 @@ +#include "pch.h" +#include "CTrans3.h" +#define PI 3.1415926 +void CTrans3::Identity(void) +{ + M[0][0] = 1.0; M[0][1] = 0.0; M[0][2] = 0.0; M[0][3] = 0.0; + M[1][0] = 0.0; M[1][1] = 1.0; M[1][2] = 0.0; M[1][3] = 0.0; + M[2][0] = 0.0; M[2][1] = 0.0; M[2][2] = 1.0; M[2][3] = 0.0; + M[3][0] = 0.0; M[3][1] = 0.0; M[3][2] = 0.0; M[3][3] = 1.0; +} +void CTrans3::SetMatrix(CP3* P, int ptNumber) +{ + this->P = P; + this->ptNumber = ptNumber; +} +void CTrans3::Translate(double tx, double ty, double tz) +{ + Identity(); + M[0][3] = tx; + M[1][3] = ty; + M[2][3] = tz; + MultiplyMatrix(); +} +void CTrans3::Scale(double sx, double sy, double sz) +{ + Identity(); + M[0][0] = sx; + M[1][1] = sy; + M[2][2] = sz; + MultiplyMatrix(); +} +void CTrans3::Scale(double sx, double sy, double sz, CP3 p) +{ + Translate(-p.x, -p.y, -p.z); + Scale(sx, sy, sz); + Translate(p.x, p.y, p.z); +} +void CTrans3::RotateX(double beta) +{ + Identity(); + double rad = beta * PI / 180; + M[1][1] = cos(rad); M[1][2] = -sin(rad); + M[2][1] = sin(rad); M[2][2] = cos(rad); + MultiplyMatrix(); +} +void CTrans3::RotateY(double beta) +{ + Identity(); + double rad = beta * PI / 180; + M[0][0] = cos(rad); M[0][2] = sin(rad); + M[2][0] = -sin(rad); M[2][2] = cos(rad); + MultiplyMatrix(); +} +void CTrans3::RotateZ(double beta) +{ + Identity(); + double rad = beta * PI / 180; + M[0][0] = cos(rad); M[0][1] = -sin(rad); + M[1][0] = sin(rad); M[1][1] = cos(rad); + MultiplyMatrix(); +} +void CTrans3::RotateX(double beta, CP3 p) +{ + Translate(-p.x, -p.y, -p.z); + RotateX(beta); + Translate(p.x, p.y, p.z); +} +void CTrans3::RotateY(double beta, CP3 p) +{ + Translate(-p.x, -p.y, -p.z); + RotateY(beta); + Translate(p.x, p.y, p.z); +} +void CTrans3::RotateZ(double beta, CP3 p) +{ + Translate(-p.x, -p.y, -p.z); + RotateZ(beta); + Translate(p.x, p.y, p.z); +} +void CTrans3::ReflectX(void) +{ + Identity(); + M[1][1] = -1; + M[2][2] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectY(void) +{ + Identity(); + M[0][0] = -1; + M[2][2] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectZ(void) +{ + Identity(); + M[0][0] = -1; + M[1][1] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectXOY(void) +{ + Identity(); + M[2][2] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectYOZ(void) +{ + Identity(); + M[0][0] = -1; + MultiplyMatrix(); +} +void CTrans3::ReflectZOX(void) +{ + Identity(); + M[1][1] = -1; + MultiplyMatrix(); +} +void CTrans3::ShearX(double b, double c) +{ + Identity(); + M[0][1] = b; M[0][2] = c; + MultiplyMatrix(); +} +void CTrans3::ShearY(double d, double f) +{ + Identity(); + M[1][0] = d; M[1][2] = f; + MultiplyMatrix(); +} +void CTrans3::ShearZ(double g, double h) +{ + Identity(); + M[2][0] = g; M[2][1] = h; + MultiplyMatrix(); +} +void CTrans3::MultiplyMatrix(void) +{ + CP3* PTemp = new CP3[ptNumber]; + for (int i = 0; i < ptNumber; i++) + PTemp[i] = P[i]; + for (int i = 0; i < ptNumber; i++) + { + P[i].x = M[0][0] * PTemp[i].x + M[0][1] * PTemp[i].y + M[0][2] * PTemp[i].z + M[0][3] * PTemp[i].w; + P[i].y = M[1][0] * PTemp[i].x + M[1][1] * PTemp[i].y + M[1][2] * PTemp[i].z + M[1][3] * PTemp[i].w; + P[i].z = M[2][0] * PTemp[i].x + M[2][1] * PTemp[i].y + M[2][2] * PTemp[i].z + M[2][3] * PTemp[i].w; + P[i].w = M[3][0] * PTemp[i].x + M[3][1] * PTemp[i].y + M[3][2] * PTemp[i].z + M[3][3] * PTemp[i].w; + } + delete[]PTemp; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CTrans3.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CTrans3.h" new file mode 100644 index 0000000..d6d24a2 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CTrans3.h" @@ -0,0 +1,34 @@ +#pragma once +#include "CP3.h" +class CTrans3 +{ +public: + CTrans3(void) {}; + virtual ~CTrans3(void) {}; + void Identity(void); + void SetMatrix(CP3* P, int ptNumber); + void Translate(double tx, double ty, double tz); + void Scale(double sx, double sy, double sz); + void Scale(double sx, double sy, double sz, CP3 p); + void RotateX(double beta); + void RotateY(double beta); + void RotateZ(double beta); + void RotateX(double beta, CP3 p); + void RotateY(double beta, CP3 p); + void RotateZ(double beta, CP3 p); + void ReflectX(void); + void ReflectY(void); + void ReflectZ(void); + void ReflectXOY(void); + void ReflectYOZ(void); + void ReflectZOX(void); + void ShearX(double b, double c); + void ShearY(double d, double f); + void ShearZ(double g, double h); + void MultiplyMatrix(void); +private: + double M[4][4]; + CP3* P; + int ptNumber; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CVector3.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CVector3.cpp" new file mode 100644 index 0000000..9bb0b88 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CVector3.cpp" @@ -0,0 +1,95 @@ +#include "pch.h" +#include "CVector3.h" +CVector3::CVector3(void) +{ + x = 0.0, y = 0.0, z = 1.0; +} +CVector3::~CVector3(void) +{ +} +CVector3::CVector3(double x, double y, double z) +{ + this->x = x; + this->y = y; + this->z = z; +} +CVector3::CVector3(const CP3& p) +{ + x = p.x; + y = p.y; + z = p.z; +} +CVector3::CVector3(const CP3& p0, const CP3& p1) +{ + x = p1.x - p0.x; + y = p1.y - p0.y; + z = p1.z - p0.z; +} +double CVector3::Magnitude(void) +{ + return sqrt(x * x + y * y + z * z); +} +CVector3 CVector3::Normalize(void){ + CVector3 vector; + double magnitude = sqrt(x * x + y * y + z * z); + if (fabs(magnitude) < 1e-4) + magnitude = 1.0; + vector.x = x / magnitude; + vector.y = y / magnitude; + vector.z = z / magnitude; + return vector; +} +CVector3 operator + (const CVector3& v0, const CVector3& v1) +{ + CVector3 vector; + vector.x = v0.x + v1.x; + vector.y = v0.y + v1.y; + vector.z = v0.z + v1.z; + return vector; +} +CVector3 operator - (const CVector3& v0, const CVector3& v1) +{ + CVector3 vector; + vector.x = v0.x - v1.x; + vector.y = v0.y - v1.y; + vector.z = v0.z - v1.z; + return vector; +} +CVector3 operator * (const CVector3& v, double scalar) +{ + CVector3 vector; + vector.x = v.x * scalar; + vector.y = v.y * scalar; + vector.z = v.z * scalar; + return vector; +} +CVector3 operator * (double scalar, const CVector3& v) +{ + CVector3 vector; + vector.x = v.x * scalar; + vector.y = v.y * scalar; + vector.z = v.z * scalar; + return vector; +} +CVector3 operator / (const CVector3& v, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + CVector3 vector; + vector.x = v.x / scalar; + vector.y = v.y / scalar; + vector.z = v.z / scalar; + return vector; +} +double DotProduct(const CVector3& v0, const CVector3& v1) +{ + return(v0.x * v1.x + v0.y * v1.y + v0.z * v1.z); +} +CVector3 CrossProduct(const CVector3& v0, const CVector3& v1) +{ + CVector3 vector; + vector.x = v0.y * v1.z - v0.z * v1.y; + vector.y = v0.z * v1.x - v0.x * v1.z; + vector.z = v0.x * v1.y - v0.y * v1.x; + return vector; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CVector3.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CVector3.h" new file mode 100644 index 0000000..6f1cda4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/CVector3.h" @@ -0,0 +1,22 @@ +#pragma once +#include"CP3.h" +class CVector3 +{ +public: + CVector3(void); + virtual ~CVector3(void); + CVector3(double x, double y, double z); + CVector3(const CP3& p); + CVector3(const CP3& p0, const CP3& p1); + double Magnitude(void); CVector3 Normalize(void); + friend CVector3 operator + (const CVector3& v0, const CVector3& v1); + friend CVector3 operator - (const CVector3& v0, const CVector3& v1); + friend CVector3 operator * (const CVector3& v, double scalar); + friend CVector3 operator * (double scalar, const CVector3& v); + friend CVector3 operator / (const CVector3& v, double scalar); + friend double DotProduct(const CVector3& v0, const CVector3& v1); + friend CVector3 CrossProduct(const CVector3& v0, const CVector3& v1); +private: + double x, y, z; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/ClassView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/ClassView.cpp" new file mode 100644 index 0000000..898689a --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/ClassView.cpp" @@ -0,0 +1,323 @@ + +#include "pch.h" +#include "framework.h" +#include "MainFrm.h" +#include "ClassView.h" +#include "Resource.h" +#include "BezierSurface.h" + +class CClassViewMenuButton : public CMFCToolBarMenuButton +{ + friend class CClassView; + + DECLARE_SERIAL(CClassViewMenuButton) + +public: + CClassViewMenuButton(HMENU hMenu = nullptr) noexcept : CMFCToolBarMenuButton((UINT)-1, hMenu, -1) + { + } + + virtual void OnDraw(CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz = TRUE, + BOOL bCustomizeMode = FALSE, BOOL bHighlight = FALSE, BOOL bDrawBorder = TRUE, BOOL bGrayDisabledButtons = TRUE) + { + pImages = CMFCToolBar::GetImages(); + + CAfxDrawState ds; + pImages->PrepareDrawImage(ds); + + CMFCToolBarMenuButton::OnDraw(pDC, rect, pImages, bHorz, bCustomizeMode, bHighlight, bDrawBorder, bGrayDisabledButtons); + + pImages->EndDrawImage(ds); + } +}; + +IMPLEMENT_SERIAL(CClassViewMenuButton, CMFCToolBarMenuButton, 1) + +////////////////////////////////////////////////////////////////////// +// 构造/析构 +////////////////////////////////////////////////////////////////////// + +CClassView::CClassView() noexcept +{ + m_nCurrSort = ID_SORTING_GROUPBYTYPE; +} + +CClassView::~CClassView() +{ +} + +BEGIN_MESSAGE_MAP(CClassView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_CLASS_ADD_MEMBER_FUNCTION, OnClassAddMemberFunction) + ON_COMMAND(ID_CLASS_ADD_MEMBER_VARIABLE, OnClassAddMemberVariable) + ON_COMMAND(ID_CLASS_DEFINITION, OnClassDefinition) + ON_COMMAND(ID_CLASS_PROPERTIES, OnClassProperties) + ON_COMMAND(ID_NEW_FOLDER, OnNewFolder) + ON_WM_PAINT() + ON_WM_SETFOCUS() + ON_COMMAND_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnSort) + ON_UPDATE_COMMAND_UI_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnUpdateSort) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClassView 消息处理程序 + +int CClassView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndClassView.Create(dwViewStyle, rectDummy, this, 2)) + { + TRACE0("未能创建类视图\n"); + return -1; // 未能创建 + } + + // 加载图像: + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_SORT); + m_wndToolBar.LoadToolBar(IDR_SORT, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + CMenu menuSort; + menuSort.LoadMenu(IDR_POPUP_SORT); + + m_wndToolBar.ReplaceButton(ID_SORT_MENU, CClassViewMenuButton(menuSort.GetSubMenu(0)->GetSafeHmenu())); + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->m_bText = FALSE; + pButton->m_bImage = TRUE; + pButton->SetImage(GetCmdMgr()->GetCmdImage(m_nCurrSort)); + pButton->SetMessageWnd(this); + } + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillClassView(); + + return 0; +} + +void CClassView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CClassView::FillClassView() +{ + HTREEITEM hRoot = m_wndClassView.InsertItem(_T("FakeApp 类"), 0, 0); + m_wndClassView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hClass = m_wndClassView.InsertItem(_T("CFakeAboutDlg"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAboutDlg()"), 3, 3, hClass); + + m_wndClassView.Expand(hRoot, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeApp"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeApp()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("InitInstance()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnAppAbout()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppDoc"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppDoc()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppDoc()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnNewDocument()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppView"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppView()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppView()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("GetDocument()"), 3, 3, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppFrame"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("m_wndMenuBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndToolBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndStatusBar"), 6, 6, hClass); + + hClass = m_wndClassView.InsertItem(_T("Globals"), 2, 2, hRoot); + m_wndClassView.InsertItem(_T("theFakeApp"), 5, 5, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); +} + +void CClassView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndClassView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + CMenu menu; + menu.LoadMenu(IDR_POPUP_SORT); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } +} + +void CClassView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndClassView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +BOOL CClassView::PreTranslateMessage(MSG* pMsg) +{ + return CDockablePane::PreTranslateMessage(pMsg); +} + +void CClassView::OnSort(UINT id) +{ + if (m_nCurrSort == id) + { + return; + } + + m_nCurrSort = id; + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->SetImage(GetCmdMgr()->GetCmdImage(id)); + m_wndToolBar.Invalidate(); + m_wndToolBar.UpdateWindow(); + } +} + +void CClassView::OnUpdateSort(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(pCmdUI->m_nID == m_nCurrSort); +} + +void CClassView::OnClassAddMemberFunction() +{ + AfxMessageBox(_T("添加成员函数...")); +} + +void CClassView::OnClassAddMemberVariable() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassDefinition() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassProperties() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnNewFolder() +{ + AfxMessageBox(_T("新建文件夹...")); +} + +void CClassView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndClassView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CClassView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndClassView.SetFocus(); +} + +void CClassView::OnChangeVisualStyle() +{ + m_ClassViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_CLASS_VIEW_24 : IDB_CLASS_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_ClassViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_ClassViewImages.Add(&bmp, RGB(255, 0, 0)); + + m_wndClassView.SetImageList(&m_ClassViewImages, TVSIL_NORMAL); + + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_SORT_24 : IDR_SORT, 0, 0, TRUE /* 锁定*/); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/ClassView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/ClassView.h" new file mode 100644 index 0000000..786c278 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/ClassView.h" @@ -0,0 +1,54 @@ + +#pragma once + +#include "ViewTree.h" + +class CClassToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CClassView : public CDockablePane +{ +public: + CClassView() noexcept; + virtual ~CClassView(); + + void AdjustLayout(); + void OnChangeVisualStyle(); + +protected: + CClassToolBar m_wndToolBar; + CViewTree m_wndClassView; + CImageList m_ClassViewImages; + UINT m_nCurrSort; + + void FillClassView(); + +// 重写 +public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnClassAddMemberFunction(); + afx_msg void OnClassAddMemberVariable(); + afx_msg void OnClassDefinition(); + afx_msg void OnClassProperties(); + afx_msg void OnNewFolder(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg LRESULT OnChangeActiveTab(WPARAM, LPARAM); + afx_msg void OnSort(UINT id); + afx_msg void OnUpdateSort(CCmdUI* pCmdUI); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/FileView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/FileView.cpp" new file mode 100644 index 0000000..2eeec43 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/FileView.cpp" @@ -0,0 +1,257 @@ + +#include "pch.h" +#include "framework.h" +#include "mainfrm.h" +#include "FileView.h" +#include "Resource.h" +#include "BezierSurface.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CFileView + +CFileView::CFileView() noexcept +{ +} + +CFileView::~CFileView() +{ +} + +BEGIN_MESSAGE_MAP(CFileView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_PROPERTIES, OnProperties) + ON_COMMAND(ID_OPEN, OnFileOpen) + ON_COMMAND(ID_OPEN_WITH, OnFileOpenWith) + ON_COMMAND(ID_DUMMY_COMPILE, OnDummyCompile) + ON_COMMAND(ID_EDIT_CUT, OnEditCut) + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_WM_PAINT() + ON_WM_SETFOCUS() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CWorkspaceBar 消息处理程序 + +int CFileView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; + + if (!m_wndFileView.Create(dwViewStyle, rectDummy, this, 4)) + { + TRACE0("未能创建文件视图\n"); + return -1; // 未能创建 + } + + // 加载视图图像: + m_FileViewImages.Create(IDB_FILE_VIEW, 16, 0, RGB(255, 0, 255)); + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_EXPLORER); + m_wndToolBar.LoadToolBar(IDR_EXPLORER, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillFileView(); + AdjustLayout(); + + return 0; +} + +void CFileView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CFileView::FillFileView() +{ + HTREEITEM hRoot = m_wndFileView.InsertItem(_T("FakeApp 文件"), 0, 0); + m_wndFileView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hSrc = m_wndFileView.InsertItem(_T("FakeApp 源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeApp.rc"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppDoc.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppView.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("MainFrm.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("pch.cpp"), 1, 1, hSrc); + + HTREEITEM hInc = m_wndFileView.InsertItem(_T("FakeApp 头文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppDoc.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppView.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("Resource.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("MainFrm.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("pch.h"), 2, 2, hInc); + + HTREEITEM hRes = m_wndFileView.InsertItem(_T("FakeApp 资源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeApp.rc2"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeAppDoc.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeToolbar.bmp"), 2, 2, hRes); + + m_wndFileView.Expand(hRoot, TVE_EXPAND); + m_wndFileView.Expand(hSrc, TVE_EXPAND); + m_wndFileView.Expand(hInc, TVE_EXPAND); +} + +void CFileView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE); +} + +void CFileView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndFileView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +void CFileView::OnProperties() +{ + AfxMessageBox(_T("属性....")); + +} + +void CFileView::OnFileOpen() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnFileOpenWith() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnDummyCompile() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCut() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCopy() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditClear() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndFileView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CFileView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndFileView.SetFocus(); +} + +void CFileView::OnChangeVisualStyle() +{ + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_EXPLORER_24 : IDR_EXPLORER, 0, 0, TRUE /* 锁定*/); + + m_FileViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_FILE_VIEW_24 : IDB_FILE_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_FileViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_FileViewImages.Add(&bmp, RGB(255, 0, 255)); + + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); +} + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/FileView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/FileView.h" new file mode 100644 index 0000000..e39a7c9 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/FileView.h" @@ -0,0 +1,55 @@ + +#pragma once + +#include "ViewTree.h" + +class CFileViewToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CFileView : public CDockablePane +{ +// 构造 +public: + CFileView() noexcept; + + void AdjustLayout(); + void OnChangeVisualStyle(); + +// 特性 +protected: + + CViewTree m_wndFileView; + CImageList m_FileViewImages; + CFileViewToolBar m_wndToolBar; + +protected: + void FillFileView(); + +// 实现 +public: + virtual ~CFileView(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnProperties(); + afx_msg void OnFileOpen(); + afx_msg void OnFileOpenWith(); + afx_msg void OnDummyCompile(); + afx_msg void OnEditCut(); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/MainFrm.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/MainFrm.cpp" new file mode 100644 index 0000000..c67d38e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/MainFrm.cpp" @@ -0,0 +1,408 @@ + +// MainFrm.cpp: CMainFrame 类的实现 +// + +#include "pch.h" +#include "framework.h" +#include "BezierSurface.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) + +const int iMaxUserToolbars = 10; +const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; +const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) + ON_WM_CREATE() + ON_COMMAND(ID_VIEW_CUSTOMIZE, &CMainFrame::OnViewCustomize) + ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, &CMainFrame::OnToolbarCreateNew) + ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook) + ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook) + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // 状态行指示器 + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +// CMainFrame 构造/析构 + +CMainFrame::CMainFrame() noexcept +{ + // TODO: 在此添加成员初始化代码 + theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2008); +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) + return -1; + + BOOL bNameValid; + + if (!m_wndMenuBar.Create(this)) + { + TRACE0("未能创建菜单栏\n"); + return -1; // 未能创建 + } + + m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); + + // 防止菜单栏在激活时获得焦点 + CMFCPopupMenu::SetForceMenuFocus(FALSE); + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) + { + TRACE0("未能创建工具栏\n"); + return -1; // 未能创建 + } + + CString strToolBarName; + bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); + ASSERT(bNameValid); + m_wndToolBar.SetWindowText(strToolBarName); + + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + + // 允许用户定义的工具栏操作: + InitUserToolbars(nullptr, uiFirstUserToolBarId, uiLastUserToolBarId); + + if (!m_wndStatusBar.Create(this)) + { + TRACE0("未能创建状态栏\n"); + return -1; // 未能创建 + } + m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); + + // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行 + m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndMenuBar); + DockPane(&m_wndToolBar); + + + // 启用 Visual Studio 2005 样式停靠窗口行为 + CDockingManager::SetDockingMode(DT_SMART); + // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 + EnableAutoHidePanes(CBRS_ALIGN_ANY); + + // 加载菜单项图像(不在任何标准工具栏上): + CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); + + // 创建停靠窗口 + if (!CreateDockingWindows()) + { + TRACE0("未能创建停靠窗口\n"); + return -1; + } + + m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); + m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndFileView); + CDockablePane* pTabbedBar = nullptr; + m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); + m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndOutput); + m_wndProperties.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndProperties); + + // 基于持久值设置视觉管理器和样式 + OnApplicationLook(theApp.m_nAppLook); + + // 启用工具栏和停靠窗口菜单替换 + EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); + + // 启用快速(按住 Alt 拖动)工具栏自定义 + CMFCToolBar::EnableQuickCustomization(); + + if (CMFCToolBar::GetUserImages() == nullptr) + { + // 加载用户定义的工具栏图像 + if (m_UserImages.Load(_T(".\\UserImages.bmp"))) + { + CMFCToolBar::SetUserImages(&m_UserImages); + } + } + + // 启用菜单个性化(最近使用的命令) + // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 + CList lstBasicCommands; + + lstBasicCommands.AddTail(ID_FILE_NEW); + lstBasicCommands.AddTail(ID_FILE_OPEN); + lstBasicCommands.AddTail(ID_FILE_SAVE); + lstBasicCommands.AddTail(ID_FILE_PRINT); + lstBasicCommands.AddTail(ID_APP_EXIT); + lstBasicCommands.AddTail(ID_EDIT_CUT); + lstBasicCommands.AddTail(ID_EDIT_PASTE); + lstBasicCommands.AddTail(ID_EDIT_UNDO); + lstBasicCommands.AddTail(ID_APP_ABOUT); + lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); + lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7); + lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); + lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); + lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); + lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); + + CMFCToolBar::SetBasicCommands(lstBasicCommands); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWndEx::PreCreateWindow(cs) ) + return FALSE; + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return TRUE; +} + +BOOL CMainFrame::CreateDockingWindows() +{ + BOOL bNameValid; + + // 创建类视图 + CString strClassView; + bNameValid = strClassView.LoadString(IDS_CLASS_VIEW); + ASSERT(bNameValid); + if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“类视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建文件视图 + CString strFileView; + bNameValid = strFileView.LoadString(IDS_FILE_VIEW); + ASSERT(bNameValid); + if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“文件视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建输出窗口 + CString strOutputWnd; + bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND); + ASSERT(bNameValid); + if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建输出窗口\n"); + return FALSE; // 未能创建 + } + + // 创建属性窗口 + CString strPropertiesWnd; + bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND); + ASSERT(bNameValid); + if (!m_wndProperties.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“属性”窗口\n"); + return FALSE; // 未能创建 + } + + SetDockingWindowIcons(theApp.m_bHiColorIcons); + return TRUE; +} + +void CMainFrame::SetDockingWindowIcons(BOOL bHiColorIcons) +{ + HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_FILE_VIEW_HC : IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndFileView.SetIcon(hFileViewIcon, FALSE); + + HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_CLASS_VIEW_HC : IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndClassView.SetIcon(hClassViewIcon, FALSE); + + HICON hOutputBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_OUTPUT_WND_HC : IDI_OUTPUT_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndOutput.SetIcon(hOutputBarIcon, FALSE); + + HICON hPropertiesBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_PROPERTIES_WND_HC : IDI_PROPERTIES_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndProperties.SetIcon(hPropertiesBarIcon, FALSE); + +} + +// CMainFrame 诊断 + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWndEx::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWndEx::Dump(dc); +} +#endif //_DEBUG + + +// CMainFrame 消息处理程序 + +void CMainFrame::OnViewCustomize() +{ + CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* 扫描菜单*/); + pDlgCust->EnableUserDefinedToolbars(); + pDlgCust->Create(); +} + +LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) +{ + LRESULT lres = CFrameWndEx::OnToolbarCreateNew(wp,lp); + if (lres == 0) + { + return 0; + } + + CMFCToolBar* pUserToolbar = (CMFCToolBar*)lres; + ASSERT_VALID(pUserToolbar); + + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + return lres; +} + +void CMainFrame::OnApplicationLook(UINT id) +{ + CWaitCursor wait; + + theApp.m_nAppLook = id; + + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_WIN_2000: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); + break; + + case ID_VIEW_APPLOOK_OFF_XP: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); + break; + + case ID_VIEW_APPLOOK_WIN_XP: + CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + break; + + case ID_VIEW_APPLOOK_OFF_2003: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2005: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2008: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_WINDOWS_7: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + default: + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_OFF_2007_BLUE: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); + break; + + case ID_VIEW_APPLOOK_OFF_2007_BLACK: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); + break; + + case ID_VIEW_APPLOOK_OFF_2007_SILVER: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); + break; + + case ID_VIEW_APPLOOK_OFF_2007_AQUA: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); + break; + } + + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); + CDockingManager::SetDockingMode(DT_SMART); + } + + m_wndOutput.UpdateFonts(); + RedrawWindow(nullptr, nullptr, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); + + theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); +} + +void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI) +{ + pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID); +} + + +BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) +{ + // 基类将执行真正的工作 + + if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) + { + return FALSE; + } + + + // 为所有用户工具栏启用自定义按钮 + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + for (int i = 0; i < iMaxUserToolbars; i ++) + { + CMFCToolBar* pUserToolbar = GetUserToolBarByIndex(i); + if (pUserToolbar != nullptr) + { + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + } + } + + return TRUE; +} + + +void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CFrameWndEx::OnSettingChange(uFlags, lpszSection); + m_wndOutput.UpdateFonts(); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/MainFrm.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/MainFrm.h" new file mode 100644 index 0000000..02feb8e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/MainFrm.h" @@ -0,0 +1,61 @@ + +// MainFrm.h: CMainFrame 类的接口 +// + +#pragma once +#include "FileView.h" +#include "ClassView.h" +#include "OutputWnd.h" +#include "PropertiesWnd.h" + +class CMainFrame : public CFrameWndEx +{ + +protected: // 仅从序列化创建 + CMainFrame() noexcept; + DECLARE_DYNCREATE(CMainFrame) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = nullptr, CCreateContext* pContext = nullptr); + +// 实现 +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // 控件条嵌入成员 + CMFCMenuBar m_wndMenuBar; + CMFCToolBar m_wndToolBar; + CMFCStatusBar m_wndStatusBar; + CMFCToolBarImages m_UserImages; + CFileView m_wndFileView; + CClassView m_wndClassView; + COutputWnd m_wndOutput; + CPropertiesWnd m_wndProperties; + +// 生成的消息映射函数 +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnViewCustomize(); + afx_msg LRESULT OnToolbarCreateNew(WPARAM wp, LPARAM lp); + afx_msg void OnApplicationLook(UINT id); + afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + DECLARE_MESSAGE_MAP() + + BOOL CreateDockingWindows(); + void SetDockingWindowIcons(BOOL bHiColorIcons); +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/OutputWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/OutputWnd.cpp" new file mode 100644 index 0000000..e3f4901 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/OutputWnd.cpp" @@ -0,0 +1,200 @@ + +#include "pch.h" +#include "framework.h" + +#include "OutputWnd.h" +#include "Resource.h" +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// COutputBar + +COutputWnd::COutputWnd() noexcept +{ +} + +COutputWnd::~COutputWnd() +{ +} + +BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() +END_MESSAGE_MAP() + +int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建选项卡窗口: + if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1)) + { + TRACE0("未能创建输出选项卡窗口\n"); + return -1; // 未能创建 + } + + // 创建输出窗格: + const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; + + if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) || + !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) || + !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4)) + { + TRACE0("未能创建输出窗口\n"); + return -1; // 未能创建 + } + + UpdateFonts(); + + CString strTabName; + BOOL bNameValid; + + // 将列表窗口附加到选项卡: + bNameValid = strTabName.LoadString(IDS_BUILD_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0); + bNameValid = strTabName.LoadString(IDS_DEBUG_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1); + bNameValid = strTabName.LoadString(IDS_FIND_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2); + + // 使用一些虚拟文本填写输出选项卡(无需复杂数据) + FillBuildWindow(); + FillDebugWindow(); + FillFindWindow(); + + return 0; +} + +void COutputWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + + // 选项卡控件应覆盖整个工作区: + m_wndTabs.SetWindowPos (nullptr, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); +} + +void COutputWnd::AdjustHorzScroll(CListBox& wndListBox) +{ + CClientDC dc(this); + CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular); + + int cxExtentMax = 0; + + for (int i = 0; i < wndListBox.GetCount(); i ++) + { + CString strItem; + wndListBox.GetText(i, strItem); + + cxExtentMax = max(cxExtentMax, (int)dc.GetTextExtent(strItem).cx); + } + + wndListBox.SetHorizontalExtent(cxExtentMax); + dc.SelectObject(pOldFont); +} + +void COutputWnd::FillBuildWindow() +{ + m_wndOutputBuild.AddString(_T("生成输出正显示在此处。")); + m_wndOutputBuild.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputBuild.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillDebugWindow() +{ + m_wndOutputDebug.AddString(_T("调试输出正显示在此处。")); + m_wndOutputDebug.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputDebug.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillFindWindow() +{ + m_wndOutputFind.AddString(_T("查找输出正显示在此处。")); + m_wndOutputFind.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputFind.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::UpdateFonts() +{ + m_wndOutputBuild.SetFont(&afxGlobalData.fontRegular); + m_wndOutputDebug.SetFont(&afxGlobalData.fontRegular); + m_wndOutputFind.SetFont(&afxGlobalData.fontRegular); +} + +///////////////////////////////////////////////////////////////////////////// +// COutputList1 + +COutputList::COutputList() noexcept +{ +} + +COutputList::~COutputList() +{ +} + +BEGIN_MESSAGE_MAP(COutputList, CListBox) + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput) + ON_WM_WINDOWPOSCHANGING() +END_MESSAGE_MAP() +///////////////////////////////////////////////////////////////////////////// +// COutputList 消息处理程序 + +void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) +{ + CMenu menu; + menu.LoadMenu(IDR_OUTPUT_POPUP); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } + + SetFocus(); +} + +void COutputList::OnEditCopy() +{ + MessageBox(_T("复制输出")); +} + +void COutputList::OnEditClear() +{ + MessageBox(_T("清除输出")); +} + +void COutputList::OnViewOutput() +{ + CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner()); + CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame()); + + if (pMainFrame != nullptr && pParentBar != nullptr) + { + pMainFrame->SetFocus(); + pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE); + pMainFrame->RecalcLayout(); + + } +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/OutputWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/OutputWnd.h" new file mode 100644 index 0000000..4d773c3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/OutputWnd.h" @@ -0,0 +1,59 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// COutputList 窗口 + +class COutputList : public CListBox +{ +// 构造 +public: + COutputList() noexcept; + +// 实现 +public: + virtual ~COutputList(); + +protected: + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnViewOutput(); + + DECLARE_MESSAGE_MAP() +}; + +class COutputWnd : public CDockablePane +{ +// 构造 +public: + COutputWnd() noexcept; + + void UpdateFonts(); + +// 特性 +protected: + CMFCTabCtrl m_wndTabs; + + COutputList m_wndOutputBuild; + COutputList m_wndOutputDebug; + COutputList m_wndOutputFind; + +protected: + void FillBuildWindow(); + void FillDebugWindow(); + void FillFindWindow(); + + void AdjustHorzScroll(CListBox& wndListBox); + +// 实现 +public: + virtual ~COutputWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/Patch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/Patch.cpp" new file mode 100644 index 0000000..4ce7690 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/Patch.cpp" @@ -0,0 +1,11 @@ +#include "pch.h" +#include "Patch.h" + +CPatch::CPatch(void) +{ +} + + +CPatch::~CPatch(void) +{ +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/Patch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/Patch.h" new file mode 100644 index 0000000..742d94d --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/Patch.h" @@ -0,0 +1,10 @@ +#pragma once +class CPatch +{ +public: + CPatch(void); + virtual ~CPatch(void); +public: + int pIndex[4][4]; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/PropertiesWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/PropertiesWnd.cpp" new file mode 100644 index 0000000..ec5afe5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/PropertiesWnd.cpp" @@ -0,0 +1,273 @@ + +#include "pch.h" +#include "framework.h" + +#include "PropertiesWnd.h" +#include "Resource.h" +#include "MainFrm.h" +#include "BezierSurface.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar + +CPropertiesWnd::CPropertiesWnd() noexcept +{ + m_nComboHeight = 0; +} + +CPropertiesWnd::~CPropertiesWnd() +{ +} + +BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties) + ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties) + ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties) + ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties) + ON_COMMAND(ID_PROPERTIES1, OnProperties1) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1) + ON_COMMAND(ID_PROPERTIES2, OnProperties2) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2) + ON_WM_SETFOCUS() + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar 消息处理程序 + +void CPropertiesWnd::AdjustLayout() +{ + if (GetSafeHwnd () == nullptr || (AfxGetMainWnd() != nullptr && AfxGetMainWnd()->IsIconic())) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndObjectCombo.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndPropList.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight + cyTlb, rectClient.Width(), rectClient.Height() -(m_nComboHeight+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER); +} + +int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建组合: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1)) + { + TRACE0("未能创建属性组合 \n"); + return -1; // 未能创建 + } + + m_wndObjectCombo.AddString(_T("应用程序")); + m_wndObjectCombo.AddString(_T("属性窗口")); + m_wndObjectCombo.SetCurSel(0); + + CRect rectCombo; + m_wndObjectCombo.GetClientRect (&rectCombo); + + m_nComboHeight = rectCombo.Height(); + + if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2)) + { + TRACE0("未能创建属性网格\n"); + return -1; // 未能创建 + } + + InitPropList(); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES); + m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* 已锁定*/); + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* 锁定*/); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + AdjustLayout(); + return 0; +} + +void CPropertiesWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CPropertiesWnd::OnExpandAllProperties() +{ + m_wndPropList.ExpandAll(); +} + +void CPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* /* pCmdUI */) +{ +} + +void CPropertiesWnd::OnSortProperties() +{ + m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnProperties1() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::OnProperties2() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::InitPropList() +{ + SetPropListFont(); + + m_wndPropList.EnableHeaderCtrl(FALSE); + m_wndPropList.EnableDescriptionArea(); + m_wndPropList.SetVSDotNetLook(); + m_wndPropList.MarkModifiedProperties(); + + CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("外观")); + + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("三维外观"), (_variant_t) false, _T("指定窗口的字体不使用粗体,并且控件将使用三维边框"))); + + CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("边框"), _T("对话框外框"), _T("其中之一: “无”、“细”、“可调整大小”或“对话框外框”")); + pProp->AddOption(_T("无")); + pProp->AddOption(_T("细")); + pProp->AddOption(_T("可调整大小")); + pProp->AddOption(_T("对话框外框")); + pProp->AllowEdit(FALSE); + + pGroup1->AddSubItem(pProp); + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("标题"), (_variant_t) _T("关于"), _T("指定窗口标题栏中显示的文本"))); + + m_wndPropList.AddProperty(pGroup1); + + CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("窗口大小"), 0, TRUE); + + pProp = new CMFCPropertyGridProperty(_T("高度"), (_variant_t) 250l, _T("指定窗口的高度")); + pProp->EnableSpinControl(TRUE, 50, 300); + pSize->AddSubItem(pProp); + + pProp = new CMFCPropertyGridProperty( _T("宽度"), (_variant_t) 150l, _T("指定窗口的宽度")); + pProp->EnableSpinControl(TRUE, 50, 200); + pSize->AddSubItem(pProp); + + m_wndPropList.AddProperty(pSize); + + CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("字体")); + + LOGFONT lf; + CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + font->GetLogFont(&lf); + + _tcscpy_s(lf.lfFaceName, _T("宋体, Arial")); + + pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("字体"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("指定窗口的默认字体"))); + pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("使用系统字体"), (_variant_t) true, _T("指定窗口使用“MS Shell Dlg”字体"))); + + m_wndPropList.AddProperty(pGroup2); + + CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("杂项")); + pProp = new CMFCPropertyGridProperty(_T("(名称)"), _T("应用程序")); + pProp->Enable(FALSE); + pGroup3->AddSubItem(pProp); + + CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("窗口颜色"), RGB(210, 192, 254), nullptr, _T("指定默认的窗口颜色")); + pColorProp->EnableOtherButton(_T("其他...")); + pColorProp->EnableAutomaticButton(_T("默认"), ::GetSysColor(COLOR_3DFACE)); + pGroup3->AddSubItem(pColorProp); + + static const TCHAR szFilter[] = _T("图标文件(*.ico)|*.ico|所有文件(*.*)|*.*||"); + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("图标"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("指定窗口图标"))); + + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("文件夹"), _T("c:\\"))); + + m_wndPropList.AddProperty(pGroup3); + + CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("层次结构")); + + CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("第一个子级")); + pGroup4->AddSubItem(pGroup41); + + CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("第二个子级")); + pGroup41->AddSubItem(pGroup411); + + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 1"), (_variant_t) _T("值 1"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 2"), (_variant_t) _T("值 2"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 3"), (_variant_t) _T("值 3"), _T("此为说明"))); + + pGroup4->Expand(FALSE); + m_wndPropList.AddProperty(pGroup4); +} + +void CPropertiesWnd::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + m_wndPropList.SetFocus(); +} + +void CPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CDockablePane::OnSettingChange(uFlags, lpszSection); + SetPropListFont(); +} + +void CPropertiesWnd::SetPropListFont() +{ + ::DeleteObject(m_fntPropList.Detach()); + + LOGFONT lf; + afxGlobalData.fontRegular.GetLogFont(&lf); + + NONCLIENTMETRICS info; + info.cbSize = sizeof(info); + + afxGlobalData.GetNonClientMetrics(info); + + lf.lfHeight = info.lfMenuFont.lfHeight; + lf.lfWeight = info.lfMenuFont.lfWeight; + lf.lfItalic = info.lfMenuFont.lfItalic; + + m_fntPropList.CreateFontIndirect(&lf); + + m_wndPropList.SetFont(&m_fntPropList); + m_wndObjectCombo.SetFont(&m_fntPropList); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/PropertiesWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/PropertiesWnd.h" new file mode 100644 index 0000000..e056430 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/PropertiesWnd.h" @@ -0,0 +1,62 @@ + +#pragma once + +class CPropertiesToolBar : public CMFCToolBar +{ +public: + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CPropertiesWnd : public CDockablePane +{ +// 构造 +public: + CPropertiesWnd() noexcept; + + void AdjustLayout(); + +// 特性 +public: + void SetVSDotNetLook(BOOL bSet) + { + m_wndPropList.SetVSDotNetLook(bSet); + m_wndPropList.SetGroupNameFullWidth(bSet); + } + +protected: + CFont m_fntPropList; + CComboBox m_wndObjectCombo; + CPropertiesToolBar m_wndToolBar; + CMFCPropertyGridCtrl m_wndPropList; + +// 实现 +public: + virtual ~CPropertiesWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnExpandAllProperties(); + afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI); + afx_msg void OnSortProperties(); + afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI); + afx_msg void OnProperties1(); + afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI); + afx_msg void OnProperties2(); + afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + + DECLARE_MESSAGE_MAP() + + void InitPropList(); + void SetPropListFont(); + + int m_nComboHeight; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/ViewTree.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/ViewTree.cpp" new file mode 100644 index 0000000..84996cb --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/ViewTree.cpp" @@ -0,0 +1,43 @@ + +#include "pch.h" +#include "framework.h" +#include "ViewTree.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CViewTree + +CViewTree::CViewTree() noexcept +{ +} + +CViewTree::~CViewTree() +{ +} + +BEGIN_MESSAGE_MAP(CViewTree, CTreeCtrl) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 消息处理程序 + +BOOL CViewTree::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult); + + NMHDR* pNMHDR = (NMHDR*)lParam; + ASSERT(pNMHDR != nullptr); + +#pragma warning(suppress : 26454) + if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips() != nullptr) + { + GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); + } + + return bRes; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/ViewTree.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/ViewTree.h" new file mode 100644 index 0000000..0267d80 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/ViewTree.h" @@ -0,0 +1,23 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 窗口 + +class CViewTree : public CTreeCtrl +{ +// 构造 +public: + CViewTree() noexcept; + +// 重写 +protected: + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + +// 实现 +public: + virtual ~CViewTree(); + +protected: + DECLARE_MESSAGE_MAP() +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/framework.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/pch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/pch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/pch.h" new file mode 100644 index 0000000..9660927 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/pch.h" @@ -0,0 +1,13 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" + +#endif //PCH_H diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/BezierSurface.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/BezierSurface.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/BezierSurface.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/BezierSurface.rc2" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/BezierSurface.rc2" new file mode 100644 index 0000000..ce9d616 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/BezierSurface.rc2" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/BezierSurfaceDoc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/BezierSurfaceDoc.ico" new file mode 100644 index 0000000..96365d4 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/BezierSurfaceDoc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/Toolbar.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/Toolbar.bmp" new file mode 100644 index 0000000..d501723 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/Toolbar.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/Toolbar256.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/Toolbar256.bmp" new file mode 100644 index 0000000..91a2553 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/Toolbar256.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/class_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/class_view.ico" new file mode 100644 index 0000000..bf6b0dd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/class_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/class_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/class_view_hc.ico" new file mode 100644 index 0000000..3112bf2 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/class_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/classview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/classview.bmp" new file mode 100644 index 0000000..1e02aa1 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/classview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/classview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/classview_hc.bmp" new file mode 100644 index 0000000..6b22e78 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/classview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/explorer.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/explorer.bmp" new file mode 100644 index 0000000..01298ba Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/explorer.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/explorer_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/explorer_hc.bmp" new file mode 100644 index 0000000..697199d Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/explorer_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/file_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/file_view.ico" new file mode 100644 index 0000000..0f93f52 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/file_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/file_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/file_view_hc.ico" new file mode 100644 index 0000000..42ec435 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/file_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/fileview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/fileview.bmp" new file mode 100644 index 0000000..a2d62d0 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/fileview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/fileview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/fileview_hc.bmp" new file mode 100644 index 0000000..b60f483 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/fileview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/menuimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/menuimages.bmp" new file mode 100644 index 0000000..7771841 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/menuimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/menuimages_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/menuimages_hc.bmp" new file mode 100644 index 0000000..577926e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/menuimages_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/output_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/output_wnd.ico" new file mode 100644 index 0000000..d14f991 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/output_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/output_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/output_wnd_hc.ico" new file mode 100644 index 0000000..fdd27e8 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/output_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/properties.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/properties.bmp" new file mode 100644 index 0000000..72e2b29 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/properties.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/properties_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/properties_hc.bmp" new file mode 100644 index 0000000..d18a7ca Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/properties_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/properties_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/properties_wnd.ico" new file mode 100644 index 0000000..3611766 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/properties_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/properties_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/properties_wnd_hc.ico" new file mode 100644 index 0000000..1e06b64 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/properties_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/sort.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/sort.bmp" new file mode 100644 index 0000000..0307301 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/sort.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/sort_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/sort_hc.bmp" new file mode 100644 index 0000000..720e742 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/sort_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/userimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/userimages.bmp" new file mode 100644 index 0000000..affe657 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/res/userimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/resource.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/resource.h" new file mode 100644 index 0000000..54e2a1f --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/resource.h" @@ -0,0 +1,98 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ 生成的包含文件。 +// 供 BezierSurface.rc 使用 +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_POPUP_EDIT 119 +#define ID_STATUSBAR_PANE1 120 +#define ID_STATUSBAR_PANE2 121 +#define IDS_STATUS_PANE1 122 +#define IDS_STATUS_PANE2 123 +#define IDS_TOOLBAR_STANDARD 124 +#define IDS_TOOLBAR_CUSTOMIZE 125 +#define ID_VIEW_CUSTOMIZE 126 +#define IDR_MAINFRAME 128 +#define IDR_MAINFRAME_256 129 +#define IDR_BezierSurfaceTYPE 130 +#define ID_WINDOW_MANAGER 131 +#define ID_VIEW_FILEVIEW 133 +#define ID_VIEW_CLASSVIEW 134 +#define ID_PROPERTIES 135 +#define ID_OPEN 136 +#define ID_OPEN_WITH 137 +#define ID_DUMMY_COMPILE 138 +#define ID_CLASS_ADD_MEMBER_FUNCTION 139 +#define ID_CLASS_ADD_MEMBER_VARIABLE 140 +#define ID_CLASS_DEFINITION 141 +#define ID_CLASS_PROPERTIES 142 +#define ID_NEW_FOLDER 143 +#define ID_SORT_MENU 144 +#define ID_SORTING_GROUPBYTYPE 145 +#define ID_SORTING_SORTALPHABETIC 146 +#define ID_SORTING_SORTBYTYPE 147 +#define ID_SORTING_SORTBYACCESS 148 +#define ID_VIEW_OUTPUTWND 149 +#define ID_VIEW_PROPERTIESWND 150 +#define ID_SORTPROPERTIES 151 +#define ID_PROPERTIES1 152 +#define ID_PROPERTIES2 153 +#define ID_EXPAND_ALL 154 +#define IDS_FILE_VIEW 155 +#define IDS_CLASS_VIEW 156 +#define IDS_OUTPUT_WND 157 +#define IDS_PROPERTIES_WND 158 +#define IDI_FILE_VIEW 161 +#define IDI_FILE_VIEW_HC 162 +#define IDI_CLASS_VIEW 163 +#define IDI_CLASS_VIEW_HC 164 +#define IDI_OUTPUT_WND 165 +#define IDI_OUTPUT_WND_HC 166 +#define IDI_PROPERTIES_WND 167 +#define IDI_PROPERTIES_WND_HC 168 +#define IDR_EXPLORER 169 +#define IDB_EXPLORER_24 170 +#define IDR_SORT 171 +#define IDB_SORT_24 172 +#define IDR_POPUP_SORT 173 +#define IDR_POPUP_EXPLORER 174 +#define IDB_FILE_VIEW 175 +#define IDB_FILE_VIEW_24 176 +#define IDB_CLASS_VIEW 177 +#define IDB_CLASS_VIEW_24 178 +#define IDR_MENU_IMAGES 179 +#define IDB_MENU_IMAGES_24 180 +#define ID_TOOLS_MACRO 181 +#define IDR_OUTPUT_POPUP 182 +#define IDR_PROPERTIES 183 +#define IDB_PROPERTIES_HC 184 +#define IDR_THEME_MENU 200 +#define ID_SET_STYLE 201 +#define ID_VIEW_APPLOOK_WIN_2000 205 +#define ID_VIEW_APPLOOK_OFF_XP 206 +#define ID_VIEW_APPLOOK_WIN_XP 207 +#define ID_VIEW_APPLOOK_OFF_2003 208 +#define ID_VIEW_APPLOOK_VS_2005 209 +#define ID_VIEW_APPLOOK_VS_2008 210 +#define ID_VIEW_APPLOOK_OFF_2007_BLUE 215 +#define ID_VIEW_APPLOOK_OFF_2007_BLACK 216 +#define ID_VIEW_APPLOOK_OFF_2007_SILVER 217 +#define ID_VIEW_APPLOOK_OFF_2007_AQUA 218 +#define ID_VIEW_APPLOOK_WINDOWS_7 219 +#define IDS_BUILD_TAB 300 +#define IDS_DEBUG_TAB 301 +#define IDS_FIND_TAB 302 +#define IDS_EXPLORER 305 +#define IDS_EDIT_MENU 306 +#define ID_32771 32771 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 310 +#define _APS_NEXT_COMMAND_VALUE 32772 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 310 +#endif +#endif diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/targetver.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/BezierSurface/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246-\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\345\233\233.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246-\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\345\233\233.pdf" new file mode 100644 index 0000000..e88a376 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex4/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246-\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\345\233\233.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/BezierPatch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/BezierPatch.cpp" new file mode 100644 index 0000000..2f8dc6a --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/BezierPatch.cpp" @@ -0,0 +1,199 @@ +#include "pch.h" +#include "BezierPatch.h" +#define ROUND(d) int(d + 0.5) + +CBezierPatch::CBezierPatch(void) +{ + ReNumber = 0; +} + +CBezierPatch::~CBezierPatch(void) +{ +} + +void CBezierPatch::ReadControlPoint(CP3 CtrPt[4][4], int ReNumber) +{ + for (int i = 0; i< 4; i++) + for (int j = 0; j < 4; j++) + this->CtrPt[i][j] = CtrPt[i][j]; + this->ReNumber = ReNumber; +} + +void CBezierPatch::SetScene(CLighting* pLight, CMaterial* pMaterial)//ó +{ + this->pLight = pLight; + this->pMaterial = pMaterial; +} + +void CBezierPatch::DrawCurvedPatch(CDC* pDC, CZBuffer* pZBuffer) +{ + CMesh Mesh; + Mesh.BL = CT2(0, 0), Mesh.BR = CT2(1, 0);//ʼuv + Mesh.TR = CT2(1, 1), Mesh.TL = CT2(0, 1); + Recursion(pDC, pZBuffer, ReNumber, Mesh);//ݹ麯 +} + +void CBezierPatch::Recursion(CDC* pDC, CZBuffer* pZBuffer, int ReNumber, CMesh Mesh)//ݹ麯 +{ + if (0 == ReNumber) + { + Tessellation(Mesh);//ϸ棬uvתΪxy + DrawFacet(pDC, pZBuffer);//Сƽ + return; + } + else + { + CT2 Mid = (Mesh.BL + Mesh.TR) / 2.0; + CMesh SubMesh[4];//һΪĸ + //ӳ + SubMesh[0].BL = Mesh.BL; + SubMesh[0].BR = CT2(Mid.u, Mesh.BL.v); + SubMesh[0].TR = CT2(Mid.u, Mid.v); + SubMesh[0].TL = CT2(Mesh.BL.u, Mid.v); + //ӳ + SubMesh[1].BL = SubMesh[0].BR; + SubMesh[1].BR = Mesh.BR; + SubMesh[1].TR = CT2(Mesh.BR.u, Mid.v); + SubMesh[1].TL = SubMesh[0].TR; + //ӳ + SubMesh[2].BL = SubMesh[1].TL; + SubMesh[2].BR = SubMesh[1].TR; + SubMesh[2].TR = Mesh.TR; + SubMesh[2].TL = CT2(Mid.u, Mesh.TR.v); + //ӳ + SubMesh[3].BL = SubMesh[0].TL; + SubMesh[3].BR = SubMesh[2].BL; + SubMesh[3].TR = SubMesh[2].TL; + SubMesh[3].TL = Mesh.TL; + Recursion(pDC, pZBuffer, ReNumber - 1, SubMesh[0]);//ݹ4 + Recursion(pDC, pZBuffer, ReNumber - 1, SubMesh[1]); + Recursion(pDC, pZBuffer, ReNumber - 1, SubMesh[2]); + Recursion(pDC, pZBuffer, ReNumber - 1, SubMesh[3]); + } +} + +void CBezierPatch::Tessellation(CMesh Mesh)//ϸ溯 +{ + double M[4][4];//ϵM + M[0][0] = -1, M[0][1] = 3, M[0][2] = -3, M[0][3] = 1; + M[1][0] = 3, M[1][1] = -6, M[1][2] = 3, M[1][3] = 0; + M[2][0] = -3, M[2][1] = 3, M[2][2] = 0, M[2][3] = 0; + M[3][0] = 1, M[3][1] = 0, M[3][2] = 0, M[3][3] = 0; + CP3 P3[4][4];//߼ÿƵ + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + P3[i][j] = CtrPt[i][j]; + LeftMultiplyMatrix(M, P3);//ϵά + TransposeMatrix(M);//תþ + RightMultiplyMatrix(P3, M);//ϵҳά + double u0, u1, u2, u3, v0, v1, v2, v3;//uv + double u[4] = { Mesh.BL.u,Mesh.BR.u ,Mesh.TR.u ,Mesh.TL.u }; + double v[4] = { Mesh.BL.v,Mesh.BR.v ,Mesh.TR.v ,Mesh.TL.v }; + for (int i = 0; i < 4; i++) + { + u3 = pow(u[i], 3.0), u2 = pow(u[i], 2.0), u1 = u[i], u0 = 1; + v3 = pow(v[i], 3.0), v2 = pow(v[i], 2.0), v1 = v[i], v0 = 1; + quadrP[i] = (u3 * P3[0][0] + u2 * P3[1][0] + u1 * P3[2][0] + u0 * P3[3][0]) * v3 + + (u3 * P3[0][1] + u2 * P3[1][1] + u1 * P3[2][1] + u0 * P3[3][1]) * v2 + + (u3 * P3[0][2] + u2 * P3[1][2] + u1 * P3[2][2] + u0 * P3[3][2]) * v1 + + (u3 * P3[0][3] + u2 * P3[1][3] + u1 * P3[2][3] + u0 * P3[3][3]) * v0; + //㶥㷨 + CP3 uTagent, vTagent; + double du3, du2, du1, du0;//uƫ + du3 = 3.0 * pow(u[i], 2.0), du2 = 2.0 * u[i], du1 = 1, du0 = 0.0; + v3 = pow(v[i], 3.0), v2 = pow(v[i], 2.0), v1 = v[i], v0 = 1.0; + uTagent = (du3 * P3[0][0] + du2 * P3[1][0] + du1 * P3[2][0] + du0 * P3[3][0]) * v3 + + (du3 * P3[0][1] + du2 * P3[1][1] + du1 * P3[2][1] + du0 * P3[3][1]) * v2 + + (du3 * P3[0][2] + du2 * P3[1][2] + du1 * P3[2][2] + du0 * P3[3][2]) * v1 + + (du3 * P3[0][3] + du2 * P3[1][3] + du1 * P3[2][3] + du0 * P3[3][3]) * v0; + double dv3, dv2, dv1, dv0;//vƫ + u3 = pow(u[i], 3.0), u2 = pow(u[i], 2.0), u1 = u[i], u0 = 1.0; + dv3 = 3.0 * pow(v[i], 2.0), dv2 = 2.0 * v[i], dv1 = 1.0, dv0 = 0.0; + vTagent = (u3 * P3[0][0] + u2 * P3[1][0] + u1 * P3[2][0] + u0 * P3[3][0]) * dv3 + + (u3 * P3[0][1] + u2 * P3[1][1] + u1 * P3[2][1] + u0 * P3[3][1]) * dv2 + + (u3 * P3[0][2] + u2 * P3[1][2] + u1 * P3[2][2] + u0 * P3[3][2]) * dv1 + + (u3 * P3[0][3] + u2 * P3[1][3] + u1 * P3[2][3] + u0 * P3[3][3]) * dv0; + CVector3 Pu = CVector3(uTagent), Pv = CVector3(vTagent); + quadrN[i] = CrossProduct(Pu, Pv).Normalize();//һ㷨 + if(Pv.Magnitude() < 1e-4)//ϱvƫΪ + quadrN[i] = CVector3(quadrP[i]).Normalize(); + + } +} + +void CBezierPatch::DrawFacet(CDC* pDC, CZBuffer* pZBuffer) +{ + CP3 ScreenPoint[4]; + CP3 ViewPoint = projection.GetEye(); + CVector3 NewVector[4], PerturbationVector; + for (int nPoint = 0; nPoint < 4; nPoint++) + { + ScreenPoint[nPoint] = projection.PerspectiveProjection3(quadrP[nPoint]); + double Frequency = 50; + double bump = sin((quadrP[nPoint].x + quadrP[nPoint].y + quadrP[nPoint].z) / Frequency); + PerturbationVector = CVector3(bump, bump, bump); + NewVector[nPoint] = quadrN[nPoint] + PerturbationVector; + } + pZBuffer->SetPoint(ScreenPoint[0], ScreenPoint[2], ScreenPoint[3], NewVector[0], NewVector[2], NewVector[3]); + pZBuffer->PhongShader(pDC, ViewPoint, pLight, pMaterial); + pZBuffer->SetPoint(ScreenPoint[0], ScreenPoint[1], ScreenPoint[2], NewVector[0], NewVector[1], NewVector[2]); + pZBuffer->PhongShader(pDC, ViewPoint, pLight, pMaterial); +} + +void CBezierPatch::LeftMultiplyMatrix(double M[4][4], CP3 P[4][4])//˾M*P +{ + CP3 PTemp[4][4];//ʱ + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + PTemp[i][j] = M[i][0] * P[0][j] + M[i][1] * P[1][j] + M[i][2] * P[2][j] + M[i][3] * P[3][j]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + P[i][j] = PTemp[i][j]; +} + +void CBezierPatch::RightMultiplyMatrix(CP3 P[4][4], double M[4][4])//ҳ˾P*M +{ + CP3 PTemp[4][4];//ʱ + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + PTemp[i][j] = P[i][0] * M[0][j] + P[i][1] * M[1][j] + P[i][2] * M[2][j] + P[i][3] * M[3][j]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + P[i][j] = PTemp[i][j]; +} + +void CBezierPatch::TransposeMatrix(double M[4][4])//תþ +{ + double PTemp[4][4];//ʱ + for(int i = 0; i < 4; i++) + for(int j = 0; j < 4; j++) + PTemp[j][i] = M[i][j]; + for(int i = 0; i < 4; i++) + for(int j = 0; j < 4; j++) + M[i][j] = PTemp[i][j]; +} + +void CBezierPatch::DrawControlGrid(CDC* pDC)//ƿ +{ + CP2 P2[4][4];//άƵ + for(int i = 0; i < 4; i++) + for(int j = 0; j < 4; j++) + P2[i][j] = projection.PerspectiveProjection2(CtrPt[i][j]);//͸ͶӰ + CPen NewPen, *pOldPen; + NewPen.CreatePen(PS_SOLID, 3, RGB(0, 128, 0)); + pOldPen = pDC->SelectObject(&NewPen); + for(int i = 0; i < 4; i++) + { + pDC->MoveTo(ROUND(P2[i][0].x), ROUND(P2[i][0].y)); + for(int j = 1; j < 4; j++) + pDC->LineTo(ROUND(P2[i][j].x),ROUND(P2[i][j].y)); + } + for(int j = 0; j < 4; j++) + { + pDC->MoveTo(ROUND(P2[0][j].x), ROUND(P2[0][j].y)); + for(int i = 1; i < 4; i++) + pDC->LineTo(ROUND(P2[i][j].x), ROUND(P2[i][j].y)); + } + pDC->SelectObject(pOldPen); + NewPen.DeleteObject(); +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/BezierPatch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/BezierPatch.h" new file mode 100644 index 0000000..acfe56c --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/BezierPatch.h" @@ -0,0 +1,31 @@ +#pragma once +#include"Mesh.h" +#include"Projection.h" +#include"ZBuffer.h" + +class CBezierPatch +{ +public: + CBezierPatch(void); + virtual ~CBezierPatch(void); + void ReadControlPoint(CP3 CtrPt[4][4], int ReNumber);//16Ƶ͵ݹ + void SetScene(CLighting* pLight, CMaterial* pMaterial);//ó + void DrawCurvedPatch(CDC* pDC, CZBuffer* pZBuffer);// + void DrawControlGrid(CDC* pDC);//ƿ +private: + void Recursion(CDC* pDC, CZBuffer* pZBuffer, int ReNumber, CMesh Mesh);//ݹ麯 + void Tessellation(CMesh Mesh);//ϸֺ + void DrawFacet(CDC* pDC, CZBuffer* pZBuffer);//ı + void LeftMultiplyMatrix(double M[4][4], CP3 P[4][4]);//˶ + void RightMultiplyMatrix(CP3 P[4][4], double M[4][4]);//ҳ˶ + void TransposeMatrix(double M[4][4]);//תþ +private: + int ReNumber;//ݹ + CP3 CtrPt[4][4];//16Ƶ + CP3 quadrP[4];//ıεĶ + CVector3 quadrN[4];//ıεĶ㷨 + CProjection projection;//ͶӰ + CLighting* pLight;// + CMaterial* pMaterial;// +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CLightSource.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CLightSource.cpp" new file mode 100644 index 0000000..2609e20 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CLightSource.cpp" @@ -0,0 +1,36 @@ +#include "pch.h" +#include "CLightSource.h" +CLightSource::CLightSource(void) +{ + L_Diffuse = CRGB(0.0, 0.0, 0.0); + L_Specular = CRGB(1.0, 1.0, 1.0); + L_Position.x = 0.0, L_Position.y = 0.0, L_Position.z = 1000.0; + L_C0 = 1.0; L_C1 = 0.0; L_C2 = 0.0; L_OnOff = TRUE; +} +CLightSource::~CLightSource(void) +{ +} +void CLightSource::SetDiffuse(CRGB difuse) +{ + L_Diffuse = difuse; +} +void CLightSource::SetSpecular(CRGB specular) +{ + L_Specular = specular; +} +void CLightSource::SetPosition(double x, double y, double z) +{ + L_Position.x = x; + L_Position.y = y; + L_Position.z = z; +} +void CLightSource::SetOnOff(BOOL onoff) +{ + L_OnOff = onoff; +} +void CLightSource::SetAttenuationFactor(double c0, double c1, double c2) +{ + L_C0 = c0; + L_C1 = c1; + L_C2 = c2; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CLightSource.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CLightSource.h" new file mode 100644 index 0000000..3f865f4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CLightSource.h" @@ -0,0 +1,20 @@ +#pragma once +#include"CRGB.h" +#include"P3.h" +class CLightSource +{ +public: + CLightSource(void); + virtual ~CLightSource(void); + void SetDiffuse(CRGB diffuse); + void SetSpecular(CRGB specular); + void SetPosition(double x, double y, double z); + void SetAttenuationFactor(double c0, double c1, double c2); + void SetOnOff(BOOL onoff);public: + CRGB L_Diffuse; CRGB L_Specular; + CP3 L_Position; + double L_C0; + double L_C1; + double L_C2; + BOOL L_OnOff; +}; \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CLighting.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CLighting.cpp" new file mode 100644 index 0000000..faa5e9b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CLighting.cpp" @@ -0,0 +1,64 @@ +#include "pch.h" +#include "CLighting.h" +CLighting::CLighting(void) +{ + nLightNumber = 1; + LightSource = new CLightSource[nLightNumber]; + Ambient = CRGB(0.3, 0.3, 0.3); +} +CLighting::CLighting(int nLightNumber) +{ + this->nLightNumber = nLightNumber; + LightSource = new CLightSource[nLightNumber]; + Ambient = CRGB(0.3, 0.3, 0.3); +} +CLighting::~CLighting(void) +{ + if (LightSource) + { + delete[]LightSource; + LightSource = NULL; + } +} +void CLighting::SetLightNumber(int nLightNumber) +{ + if (LightSource) + delete[]LightSource; + this->nLightNumber = nLightNumber; + LightSource = new CLightSource[nLightNumber]; +} +CRGB CLighting::Illuminate(CP3 ViewPoint, CP3 Point, CVector3 ptNormal, CMaterial* pMaterial) +{ + CRGB ResultI = pMaterial->M_Emission; + for (int loop = 0; loop < nLightNumber; loop++) + { + if (LightSource[loop].L_OnOff) + { + CRGB I = CRGB(0.0, 0.0, 0.0); + CVector3 L(Point, LightSource[loop].L_Position); + double d = L.Magnitude(); + L = L.Normalize(); + CVector3 N = ptNormal; + N = N.Normalize(); + double NdotL = max(DotProduct(N, L), 0); + I += LightSource[loop].L_Diffuse * pMaterial->M_Diffuse * NdotL; + CVector3 V(Point, ViewPoint); + V = V.Normalize(); + CVector3 H = (L + V) / (L + V).Magnitude(); + double NdotH = max(DotProduct(N, H), 0); + double Rs = pow(NdotH, pMaterial->M_n); + I += LightSource[loop].L_Specular * pMaterial->M_Specular * Rs; + double c0 = LightSource[loop].L_C0; + double c1 = LightSource[loop].L_C1; + double c2 = LightSource[loop].L_C2; + double f = (1.0 / (c0 + c1 * d + c2 * d * d)); + f = min(1.0, f); + ResultI += I * f; + } + else + ResultI += Point.c; + } + ResultI += Ambient * pMaterial->M_Ambient; + ResultI.Normalize(); + return ResultI; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CLighting.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CLighting.h" new file mode 100644 index 0000000..4bcde73 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CLighting.h" @@ -0,0 +1,18 @@ +#pragma once +#include"CMaterial.h" +#include"Vector3.h" +#include"CLightSource.h" +class CLighting +{ +public: + CLighting(void); + CLighting(int nLightNumber); + virtual ~CLighting(void); + void SetLightNumber(int nLightNumber); + CRGB Illuminate(CP3 ViewPoint, CP3 Point, CVector3 ptNormal, CMaterial* pMaterial); + +public: + int nLightNumber; + CLightSource* LightSource; + CRGB Ambient; +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CMaterial.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CMaterial.cpp" new file mode 100644 index 0000000..60dc920 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CMaterial.cpp" @@ -0,0 +1,33 @@ +#include "pch.h" +#include "CMaterial.h" +CMaterial::CMaterial(void) +{ + M_Ambient = CRGB(0.2, 0.2, 0.2); + M_Diffuse = CRGB(0.8, 0.8, 0.8); + M_Specular = CRGB(0.0, 0.0, 0.0); + M_Emission = CRGB(0.0, 0.0, 0.0, 1.0); + M_n = 1.0; +} +CMaterial::~CMaterial(void) +{ +} +void CMaterial::SetAmbient(CRGB c) +{ + M_Ambient = c; +} +void CMaterial::SetDiffuse(CRGB c) +{ + M_Diffuse = c; +} +void CMaterial::SetSpecular(CRGB c) +{ + M_Specular = c; +} +void CMaterial::SetEmission(CRGB c) +{ + M_Emission = c; +} +void CMaterial::SetExponent(double n) +{ + M_n = n; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CMaterial.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CMaterial.h" new file mode 100644 index 0000000..01f7849 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CMaterial.h" @@ -0,0 +1,19 @@ +#pragma once +#include "CRGB.h" +class CMaterial +{ +public: + CMaterial(void); + virtual~CMaterial(void); + void SetAmbient(CRGB c); + void SetDiffuse(CRGB c); + void SetSpecular(CRGB c); + void SetEmission(CRGB c); + void SetExponent(double n); +public: + CRGB M_Ambient; + CRGB M_Diffuse; + CRGB M_Specular; + CRGB M_Emission; + double M_n; +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CRGB.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CRGB.cpp" new file mode 100644 index 0000000..d16aab0 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CRGB.cpp" @@ -0,0 +1,101 @@ +#include "pch.h" +#include "CRGB.h" +CRGB::CRGB(void) +{ + red = 1.0; + green = 1.0; + blue = 1.0; + alpha = 0.0; +} +CRGB::CRGB(double red, double green, double blue, double alpha) +{ + this->red = red; + this->green = green; + this->blue = blue; + this->alpha = alpha; +} +CRGB::~CRGB(void) +{ +} +CRGB operator + (const CRGB& c0, const CRGB& c1) +{ + CRGB color; + color.red = c0.red + c1.red; + color.green = c0.green + c1.green; + color.blue = c0.blue + c1.blue; + return color; +} +CRGB operator - (const CRGB& c0, const CRGB& c1) +{ + CRGB color; + color.red = c0.red - c1.red; + color.green = c0.green - c1.green; + color.blue = c0.blue - c1.blue; + return color; +} +CRGB operator * (const CRGB& c0, const CRGB& c1) +{ + CRGB color; + color.red = c0.red * c1.red; + color.green = c0.green * c1.green; + color.blue = c0.blue * c1.blue; + return color; +} +CRGB operator * (const CRGB & c, double scalar) +{ + CRGB color; + color.red = scalar * c.red; + color.green = scalar * c.green; + color.blue = scalar * c.blue; + return color; +} +CRGB operator * (double scalar, const CRGB & c) +{ + CRGB color; + color.red = scalar * c.red; + color.green = scalar * c.green; + color.blue = scalar * c.blue; + return color; +} +CRGB operator / (const CRGB & c, double scalar) +{ + CRGB color; + color.red = c.red / scalar; + color.green = c.green / scalar; + color.blue = c.blue / scalar; + return color; +} +CRGB operator += (CRGB & c1, CRGB & c2) +{ + c1.red += c2.red; + c1.green += c2.green; + c1.blue += c2.blue; + return c1; +} +CRGB operator -= (CRGB& c1, CRGB& c2) +{ + c1.red -= c2.red; + c1.green -= c2.green; + c1.blue -= c2.blue; + return c1; +} +CRGB operator *= (CRGB& c1, CRGB& c2) +{ + c1.red *= c2.red; + c1.green *= c2.green; + c1.blue *= c2.blue; + return c1; +} +CRGB operator /= (CRGB& c1, double scalar) +{ + c1.red /= scalar; + c1.green /= scalar; + c1.blue /= scalar; + return c1; +} +void CRGB::Normalize(void) +{ + red = (red < 0.0) ? 0.0 : ((red > 1.0) ? 1.0 : red); + green = (green < 0.0) ? 0.0 : ((green > 1.0) ? 1.0 : green); + blue = (blue < 0.0) ? 0.0 : ((blue > 1.0) ? 1.0 : blue); +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CRGB.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CRGB.h" new file mode 100644 index 0000000..1c5083b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CRGB.h" @@ -0,0 +1,23 @@ +#pragma once +class CRGB +{ +public: + CRGB(void); + CRGB(double red, double green, double blue, double alpha = 0.0); + virtual ~CRGB(void); + friend CRGB operator + (const CRGB& c0, const CRGB& c1); + friend CRGB operator - (const CRGB& c0, const CRGB& c1); + friend CRGB operator * (const CRGB& c0, const CRGB& c1); + friend CRGB operator * (const CRGB& c, double scalar); + friend CRGB operator * (double scalar, const CRGB& c); + friend CRGB operator / (const CRGB& c, double scalar); + friend CRGB operator += (CRGB& c1, CRGB& c2); + friend CRGB operator -= (CRGB& c1, CRGB& c2); + friend CRGB operator *= (CRGB& c1, CRGB& c2); + friend CRGB operator /= (CRGB& c1, double scalar); + void Normalize(void); +public: + double red; double green; + double blue; + double alpha; +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.aps" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.aps" new file mode 100644 index 0000000..a3f9ee2 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.aps" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.cpp" new file mode 100644 index 0000000..0fc2d02 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.cpp" @@ -0,0 +1,219 @@ + +// CZBuffer.cpp: 定义应用程序的类行为。 +// + +#include "pch.h" +#include "framework.h" +#include "afxwinappex.h" +#include "afxdialogex.h" +#include "CZBuffer.h" +#include "MainFrm.h" + +#include "CZBufferDoc.h" +#include "CZBufferView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CCZBufferApp + +BEGIN_MESSAGE_MAP(CCZBufferApp, CWinAppEx) + ON_COMMAND(ID_APP_ABOUT, &CCZBufferApp::OnAppAbout) + // 基于文件的标准文档命令 + ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) + // 标准打印设置命令 + ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup) +END_MESSAGE_MAP() + + +// CCZBufferApp 构造 + +CCZBufferApp::CCZBufferApp() noexcept +{ + m_bHiColorIcons = TRUE; + + + m_nAppLook = 0; + // 支持重新启动管理器 + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; +#ifdef _MANAGED + // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则: + // 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。 + // 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。 + System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); +#endif + + // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式 + //为 CompanyName.ProductName.SubProduct.VersionInformation + SetAppID(_T("CZBuffer.AppID.NoVersion")); + + // TODO: 在此处添加构造代码, + // 将所有重要的初始化放置在 InitInstance 中 +} + +// 唯一的 CCZBufferApp 对象 + +CCZBufferApp theApp; + + +// CCZBufferApp 初始化 + +BOOL CCZBufferApp::InitInstance() +{ + // 如果一个运行在 Windows XP 上的应用程序清单指定要 + // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, + //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // 将它设置为包括所有要在应用程序中使用的 + // 公共控件类。 + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinAppEx::InitInstance(); + + + // 初始化 OLE 库 + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + + AfxEnableControlContainer(); + + EnableTaskbarInteraction(FALSE); + + // 使用 RichEdit 控件需要 AfxInitRichEdit2() + // AfxInitRichEdit2(); + + // 标准初始化 + // 如果未使用这些功能并希望减小 + // 最终可执行文件的大小,则应移除下列 + // 不需要的特定初始化例程 + // 更改用于存储设置的注册表项 + // TODO: 应适当修改该字符串, + // 例如修改为公司或组织名 + SetRegistryKey(_T("应用程序向导生成的本地应用程序")); + LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) + + + InitContextMenuManager(); + + InitKeyboardManager(); + + InitTooltipManager(); + CMFCToolTipInfo ttParams; + ttParams.m_bVislManagerTheme = TRUE; + theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, + RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); + + // 注册应用程序的文档模板。 文档模板 + // 将用作文档、框架窗口和视图之间的连接 + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(CCZBufferDoc), + RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 + RUNTIME_CLASS(CCZBufferView)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + + + // 分析标准 shell 命令、DDE、打开文件操作的命令行 + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + + + // 调度在命令行中指定的命令。 如果 + // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + + // 唯一的一个窗口已初始化,因此显示它并对其进行更新 + m_pMainWnd->ShowWindow(SW_SHOW); + m_pMainWnd->UpdateWindow(); + return TRUE; +} + +int CCZBufferApp::ExitInstance() +{ + //TODO: 处理可能已添加的附加资源 + AfxOleTerm(FALSE); + + return CWinAppEx::ExitInstance(); +} + +// CCZBufferApp 消息处理程序 + + +// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg() noexcept; + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + +// 实现 +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + +// 用于运行对话框的应用程序命令 +void CCZBufferApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +// CCZBufferApp 自定义加载/保存方法 + +void CCZBufferApp::PreLoadState() +{ + BOOL bNameValid; + CString strName; + bNameValid = strName.LoadString(IDS_EDIT_MENU); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); + bNameValid = strName.LoadString(IDS_EXPLORER); + ASSERT(bNameValid); + GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EXPLORER); +} + +void CCZBufferApp::LoadCustomState() +{ +} + +void CCZBufferApp::SaveCustomState() +{ +} + +// CCZBufferApp 消息处理程序 + + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.h" new file mode 100644 index 0000000..a2fcf94 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.h" @@ -0,0 +1,40 @@ + +// CZBuffer.h: CZBuffer 应用程序的主头文件 +// +#pragma once + +#ifndef __AFXWIN_H__ + #error "在包含此文件之前包含 'pch.h' 以生成 PCH" +#endif + +#include "resource.h" // 主符号 + + +// CCZBufferApp: +// 有关此类的实现,请参阅 CZBuffer.cpp +// + +class CCZBufferApp : public CWinAppEx +{ +public: + CCZBufferApp() noexcept; + + +// 重写 +public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + +// 实现 + UINT m_nAppLook; + BOOL m_bHiColorIcons; + + virtual void PreLoadState(); + virtual void LoadCustomState(); + virtual void SaveCustomState(); + + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern CCZBufferApp theApp; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.rc" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.rc" new file mode 100644 index 0000000..53bd279 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.rc" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.sln" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.sln" new file mode 100644 index 0000000..d981f3a --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.sln" @@ -0,0 +1,33 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CZBuffer", "CZBuffer.vcxproj", "{1B573248-BD52-4138-B146-F3E3E5BA2666}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决方案项", "{98550773-8062-430B-A928-4CADBEDC3A3F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1B573248-BD52-4138-B146-F3E3E5BA2666}.Debug|x64.ActiveCfg = Debug|x64 + {1B573248-BD52-4138-B146-F3E3E5BA2666}.Debug|x64.Build.0 = Debug|x64 + {1B573248-BD52-4138-B146-F3E3E5BA2666}.Debug|x86.ActiveCfg = Debug|Win32 + {1B573248-BD52-4138-B146-F3E3E5BA2666}.Debug|x86.Build.0 = Debug|Win32 + {1B573248-BD52-4138-B146-F3E3E5BA2666}.Release|x64.ActiveCfg = Release|x64 + {1B573248-BD52-4138-B146-F3E3E5BA2666}.Release|x64.Build.0 = Release|x64 + {1B573248-BD52-4138-B146-F3E3E5BA2666}.Release|x86.ActiveCfg = Release|Win32 + {1B573248-BD52-4138-B146-F3E3E5BA2666}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {73CECA98-9BAD-4288-9819-E19FEC2CB20D} + EndGlobalSection +EndGlobal diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.vcxproj" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.vcxproj" new file mode 100644 index 0000000..8a555d3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.vcxproj" @@ -0,0 +1,287 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {1B573248-BD52-4138-B146-F3E3E5BA2666} + MFCProj + CZBuffer + 10.0 + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + true + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + true + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + pch.h + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.vcxproj.filters" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.vcxproj.filters" new file mode 100644 index 0000000..cb578b3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.vcxproj.filters" @@ -0,0 +1,279 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.vcxproj.user" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.vcxproj.user" new file mode 100644 index 0000000..305f86a --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBuffer.vcxproj.user" @@ -0,0 +1,6 @@ + + + + CZBuffer.rc + + \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBufferDoc.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBufferDoc.cpp" new file mode 100644 index 0000000..c2cfd3a --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBufferDoc.cpp" @@ -0,0 +1,138 @@ + +// CZBufferDoc.cpp: CCZBufferDoc 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "CZBuffer.h" +#endif + +#include "CZBufferDoc.h" + +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CCZBufferDoc + +IMPLEMENT_DYNCREATE(CCZBufferDoc, CDocument) + +BEGIN_MESSAGE_MAP(CCZBufferDoc, CDocument) +END_MESSAGE_MAP() + + +// CCZBufferDoc 构造/析构 + +CCZBufferDoc::CCZBufferDoc() noexcept +{ + // TODO: 在此添加一次性构造代码 + +} + +CCZBufferDoc::~CCZBufferDoc() +{ +} + +BOOL CCZBufferDoc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: 在此添加重新初始化代码 + // (SDI 文档将重用该文档) + + return TRUE; +} + + + + +// CCZBufferDoc 序列化 + +void CCZBufferDoc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: 在此添加存储代码 + } + else + { + // TODO: 在此添加加载代码 + } +} + +#ifdef SHARED_HANDLERS + +// 缩略图的支持 +void CCZBufferDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds) +{ + // 修改此代码以绘制文档数据 + dc.FillSolidRect(lprcBounds, RGB(255, 255, 255)); + + CString strText = _T("TODO: implement thumbnail drawing here"); + LOGFONT lf; + + CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + pDefaultGUIFont->GetLogFont(&lf); + lf.lfHeight = 36; + + CFont fontDraw; + fontDraw.CreateFontIndirect(&lf); + + CFont* pOldFont = dc.SelectObject(&fontDraw); + dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK); + dc.SelectObject(pOldFont); +} + +// 搜索处理程序的支持 +void CCZBufferDoc::InitializeSearchContent() +{ + CString strSearchContent; + // 从文档数据设置搜索内容。 + // 内容部分应由“;”分隔 + + // 例如: strSearchContent = _T("point;rectangle;circle;ole object;"); + SetSearchContent(strSearchContent); +} + +void CCZBufferDoc::SetSearchContent(const CString& value) +{ + if (value.IsEmpty()) + { + RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); + } + else + { + CMFCFilterChunkValueImpl *pChunk = nullptr; + ATLTRY(pChunk = new CMFCFilterChunkValueImpl); + if (pChunk != nullptr) + { + pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT); + SetChunkValue(pChunk); + } + } +} + +#endif // SHARED_HANDLERS + +// CCZBufferDoc 诊断 + +#ifdef _DEBUG +void CCZBufferDoc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CCZBufferDoc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// CCZBufferDoc 命令 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBufferDoc.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBufferDoc.h" new file mode 100644 index 0000000..989bcb7 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBufferDoc.h" @@ -0,0 +1,48 @@ + +// CZBufferDoc.h: CCZBufferDoc 类的接口 +// + + +#pragma once + + +class CCZBufferDoc : public CDocument +{ +protected: // 仅从序列化创建 + CCZBufferDoc() noexcept; + DECLARE_DYNCREATE(CCZBufferDoc) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); +#ifdef SHARED_HANDLERS + virtual void InitializeSearchContent(); + virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds); +#endif // SHARED_HANDLERS + +// 实现 +public: + virtual ~CCZBufferDoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + void InitializeLightingScene(void); +// 生成的消息映射函数 +protected: + DECLARE_MESSAGE_MAP() + +#ifdef SHARED_HANDLERS + // 用于为搜索处理程序设置搜索内容的 Helper 函数 + void SetSearchContent(const CString& value); +#endif // SHARED_HANDLERS +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBufferView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBufferView.cpp" new file mode 100644 index 0000000..17e0f10 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBufferView.cpp" @@ -0,0 +1,277 @@ + +// CZBufferView.cpp: CCZBufferView 类的实现 +// + +#include "pch.h" +#include "framework.h" +// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 +// ATL 项目中进行定义,并允许与该项目共享文档代码。 +#ifndef SHARED_HANDLERS +#include "CZBuffer.h" +#endif + +#include "CZBufferDoc.h" +#include "CZBufferView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CCZBufferView + +IMPLEMENT_DYNCREATE(CCZBufferView, CView) + +BEGIN_MESSAGE_MAP(CCZBufferView, CView) + // 标准打印命令 + ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview) + ON_WM_CONTEXTMENU() + ON_WM_RBUTTONUP() + ON_COMMAND(ID_GRAPHIC_ANIMATION, &CCZBufferView::OnGraphicAnimation) + ON_UPDATE_COMMAND_UI(ID_GRAPHIC_ANIMATION, &CCZBufferView::OnUpdateGraphicAnimation) + ON_WM_KEYDOWN() + ON_WM_TIMER() +END_MESSAGE_MAP() + +// CCZBufferView 构造/析构 + +CCZBufferView::CCZBufferView() noexcept +{ + // TODO: 在此处添加构造代码 + bPlay = FALSE; + double R = 400; + double m = 0.5523; + CP2 P2[7];//二维控制点 + P2[0] = CP2(0, -1);//7个二维点模拟半圆 + P2[1] = CP2(m, -1); + P2[2] = CP2(1, -m); + P2[3] = CP2(1, 0); + P2[4] = CP2(1, m); + P2[5] = CP2(m, 1); + P2[6] = CP2(0, 1); + CP3 DownPoint[4];//下半圆的三维控制点 + DownPoint[0] = CP3(P2[0].x, P2[0].y, 0.0); + DownPoint[1] = CP3(P2[1].x, P2[1].y, 0.0); + DownPoint[2] = CP3(P2[2].x, P2[2].y, 0.0); + DownPoint[3] = CP3(P2[3].x, P2[3].y, 0.0); + revoDown.ReadCubicBezierControlPoint(DownPoint); + tranDown.SetMatrix(revoDown.GetVertexArrayName(), 48); + tranDown.Scale(R, R, R); + CP3 UpPoint[4];//上半圆的三维控制点 + UpPoint[0] = CP3(P2[3].x, P2[3].y, 0.0); + UpPoint[1] = CP3(P2[4].x, P2[4].y, 0.0); + UpPoint[2] = CP3(P2[5].x, P2[5].y, 0.0); + UpPoint[3] = CP3(P2[6].x, P2[6].y, 0.0); + revoUp.ReadCubicBezierControlPoint(UpPoint); + tranUp.SetMatrix(revoUp.GetVertexArrayName(), 48); + tranUp.Scale(R, R, R); + InitializeLightingScene(); + revoDown.patch.SetScene(pLight, pMaterial);//设置场景 + revoUp.patch.SetScene(pLight, pMaterial);//设置场景 + +} + +CCZBufferView::~CCZBufferView() +{ + if (pLight != NULL) + { + delete pLight; + pLight = NULL; + } + if (pMaterial != NULL) + { + delete pMaterial; + pMaterial = NULL; + } +} + +BOOL CCZBufferView::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return CView::PreCreateWindow(cs); +} + +// CCZBufferView 绘图 + +void CCZBufferView::OnDraw(CDC* pDC) +{ + CCZBufferDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + + // TODO: 在此处为本机数据添加绘制代码 + DoubleBuffer(pDC); +} + +void CCZBufferView::DoubleBuffer(CDC* pDC)//双缓冲 +{ + CRect rect;//定义客户区矩形 + GetClientRect(&rect);//获得客户区的大小 + pDC->SetMapMode(MM_ANISOTROPIC);//pDC自定义坐标系 + pDC->SetWindowExt(rect.Width(), rect.Height());//设置窗口范围 + pDC->SetViewportExt(rect.Width(), -rect.Height());//设置视区范围,x轴水平向右,y轴垂直向上 + pDC->SetViewportOrg(rect.Width() / 2, rect.Height() / 2);//客户区中心为原点 + CDC memDC;//内存DC + memDC.CreateCompatibleDC(pDC);//创建一个与显示pDC兼容的内存memDC + CBitmap NewBitmap, * pOldBitmap;//内存中承载的临时位图 + NewBitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());//创建兼容位图 + pOldBitmap = memDC.SelectObject(&NewBitmap);//将兼容位图选入memDC + //memDC.FillSolidRect(rect, pDC->GetBkColor());//按原来背景填充客户区,否则是黑色 + memDC.SetMapMode(MM_ANISOTROPIC);//memDC自定义坐标系 + memDC.SetWindowExt(rect.Width(), rect.Height()); + memDC.SetViewportExt(rect.Width(), -rect.Height()); + memDC.SetViewportOrg(rect.Width() / 2, rect.Height() / 2); + rect.OffsetRect(-rect.Width() / 2, -rect.Height() / 2); + DrawObject(&memDC);//向memDC绘制图形 + pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memDC, -rect.Width() / 2, -rect.Height() / 2, SRCCOPY);//将内存memDC中的位图拷贝到显示pDC中 + memDC.SelectObject(pOldBitmap);//恢复位图 + NewBitmap.DeleteObject();//删除位图 +} + +void CCZBufferView::DrawObject(CDC* pDC)//绘制图形 +{ + CZBuffer* pZBuffer = new CZBuffer; + pZBuffer->InitialDepthBuffer(1000, 1000, 2000);//初始化深度缓冲器 + revoUp.DrawRevolutionSurface(pDC, pZBuffer); + revoDown.DrawRevolutionSurface(pDC, pZBuffer); + delete pZBuffer; + +} + +// CCZBufferView 打印 + + +BOOL CCZBufferView::OnPreparePrinting(CPrintInfo* pInfo) +{ + // 默认准备 + return DoPreparePrinting(pInfo); +} + +void CCZBufferView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加额外的打印前进行的初始化过程 +} + +void CCZBufferView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: 添加打印后进行的清理过程 +} + + +// CCZBufferView 诊断 + +#ifdef _DEBUG +void CCZBufferView::AssertValid() const +{ + CView::AssertValid(); +} + +void CCZBufferView::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +CCZBufferDoc* CCZBufferView::GetDocument() const // 非调试版本是内联的 +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCZBufferDoc))); + return (CCZBufferDoc*)m_pDocument; +} + +void CCZBufferView::InitializeLightingScene(void)//初始化光照环境 +{ + //设置光源属性 + nLightSourceNumber = 1;//光源个数 + pLight = new CLighting(nLightSourceNumber);//一维光源动态数组 + pLight->LightSource[0].SetPosition(0, 0, 1000);//设置光源位置坐标 + for (int i = 0; i < nLightSourceNumber; i++) + { + pLight->LightSource[i].L_Diffuse = CRGB(1.0, 1.0, 1.0);//光源的漫反射颜色 + pLight->LightSource[i].L_Specular = CRGB(1.0, 1.0, 1.0);//光源镜面高光颜色 + pLight->LightSource[i].L_C0 = 1.0;//常数衰减因子 + pLight->LightSource[i].L_C1 = 0.0000001;//线性衰减因子 + pLight->LightSource[i].L_C2 = 0.00000001;//二次衰减因子 + pLight->LightSource[i].L_OnOff = TRUE;//光源开启 + } + //设置材质属性 + pMaterial = new CMaterial; + pMaterial->SetAmbient(CRGB(0.847, 0.10, 0.075));//环境反射率 + pMaterial->SetDiffuse(CRGB(0.852, 0.006, 0.026));//漫反射率 + pMaterial->SetSpecular(CRGB(1.0, 1.0, 1.0));//镜面反射率 + pMaterial->SetEmission(CRGB(0.0, 0.0, 0.0));//自身辐射的颜色 + pMaterial->SetExponent(10);//高光指数 +} + +#endif //_DEBUG + + +// CCZBufferView 消息处理程序 + +void CCZBufferView::OnGraphicAnimation() +{ + // TODO: 在此添加命令处理程序代码 + bPlay = !bPlay; + if (bPlay)//设置定时器 + SetTimer(1, 150, NULL); + else + KillTimer(1); +} + +void CCZBufferView::OnUpdateGraphicAnimation(CCmdUI* pCmdUI) +{ + // TODO: 在此添加命令更新用户界面处理程序代码 + if (bPlay) + pCmdUI->SetCheck(TRUE); + else + pCmdUI->SetCheck(FALSE); +} + + +void CCZBufferView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + // TODO: 在此添加消息处理程序代码和/或调用默认值 + switch (nChar) + { + case VK_UP: + Alpha = -5; + tranUp.RotateX(Alpha); + tranDown.RotateX(Alpha); + break; + case VK_DOWN: + Alpha = +5; + tranUp.RotateX(Alpha); + tranDown.RotateX(Alpha); + break; + case VK_LEFT: + Beta = -5; + tranUp.RotateY(Beta); + tranDown.RotateY(Beta); + break; + case VK_RIGHT: + Beta = +5; + tranUp.RotateY(Beta); + tranDown.RotateY(Beta); + break; + default: + break; + } + Invalidate(false); + CView::OnKeyDown(nChar, nRepCnt, nFlags); +} + + +void CCZBufferView::OnTimer(UINT_PTR nIDEvent) +{ + // TODO: 在此添加消息处理程序代码和/或调用默认值 + Alpha = 5, Beta = 5; + tranUp.RotateX(Alpha); + tranDown.RotateX(Alpha); + tranUp.RotateY(Beta); + tranDown.RotateY(Beta); + Invalidate(FALSE); + CView::OnTimer(nIDEvent); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBufferView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBufferView.h" new file mode 100644 index 0000000..4c74ac3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/CZBufferView.h" @@ -0,0 +1,63 @@ + +// CZBufferView.h: CCZBufferView 类的接口 +// + +#pragma once +#include "Transform3.h" +#include "Revolution.h" + +class CCZBufferView : public CView +{ +protected: // 仅从序列化创建 + CCZBufferView() noexcept; + DECLARE_DYNCREATE(CCZBufferView) + +// 特性 +public: + CCZBufferDoc* GetDocument() const; + + // 操作 +public: + void DoubleBuffer(CDC* pDC);//双缓冲 + void DrawObject(CDC* pDC);//绘制图形 + void InitializeLightingScene(void);//初始化光照场景 + // 重写 +public: + virtual void OnDraw(CDC* pDC); // 重写以绘制该视图 + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// 实现 +public: + virtual ~CCZBufferView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + CRevolution revoUp, revoDown; + double Alpha, Beta; + CTransform3 tranUp, tranDown; + BOOL bPlay;//动画按钮 + int nLightSourceNumber;//光源数量 + CLighting* pLight;//光照环境 + CMaterial* pMaterial;//物体材质 +// 生成的消息映射函数 +protected: + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnGraphicAnimation(); + afx_msg void OnUpdateGraphicAnimation(CCmdUI* pCmdUI); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnTimer(UINT_PTR nIDEvent); +}; + +#ifndef _DEBUG // TestView.cpp 中的调试版本 +inline CCZBufferDoc* CCZBufferView::GetDocument() const + { return reinterpret_cast(m_pDocument); } +#endif + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ClassView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ClassView.cpp" new file mode 100644 index 0000000..72850aa --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ClassView.cpp" @@ -0,0 +1,324 @@ + +#include "pch.h" +#include "framework.h" +#include "MainFrm.h" +#include "ClassView.h" +#include "Resource.h" +#include "CZBuffer.h" + +class CClassViewMenuButton : public CMFCToolBarMenuButton +{ + friend class CClassView; + + DECLARE_SERIAL(CClassViewMenuButton) + +public: + CClassViewMenuButton(HMENU hMenu = nullptr) noexcept : CMFCToolBarMenuButton((UINT)-1, hMenu, -1) + { + } + + virtual void OnDraw(CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz = TRUE, + BOOL bCustomizeMode = FALSE, BOOL bHighlight = FALSE, BOOL bDrawBorder = TRUE, BOOL bGrayDisabledButtons = TRUE) + { + pImages = CMFCToolBar::GetImages(); + + CAfxDrawState ds; + pImages->PrepareDrawImage(ds); + + CMFCToolBarMenuButton::OnDraw(pDC, rect, pImages, bHorz, bCustomizeMode, bHighlight, bDrawBorder, bGrayDisabledButtons); + + pImages->EndDrawImage(ds); + } +}; + +IMPLEMENT_SERIAL(CClassViewMenuButton, CMFCToolBarMenuButton, 1) + +////////////////////////////////////////////////////////////////////// +// 构造/析构 +////////////////////////////////////////////////////////////////////// + +CClassView::CClassView() noexcept +{ + m_nCurrSort = ID_SORTING_GROUPBYTYPE; +} + +CClassView::~CClassView() +{ +} + +BEGIN_MESSAGE_MAP(CClassView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_CLASS_ADD_MEMBER_FUNCTION, OnClassAddMemberFunction) + ON_COMMAND(ID_CLASS_ADD_MEMBER_VARIABLE, OnClassAddMemberVariable) + ON_COMMAND(ID_CLASS_DEFINITION, OnClassDefinition) + ON_COMMAND(ID_CLASS_PROPERTIES, OnClassProperties) + ON_COMMAND(ID_NEW_FOLDER, OnNewFolder) + ON_WM_PAINT() + ON_WM_SETFOCUS() + ON_COMMAND_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnSort) + ON_UPDATE_COMMAND_UI_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnUpdateSort) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClassView 消息处理程序 + +int CClassView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndClassView.Create(dwViewStyle, rectDummy, this, 2)) + { + TRACE0("未能创建类视图\n"); + return -1; // 未能创建 + } + + // 加载图像: + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_SORT); + m_wndToolBar.LoadToolBar(IDR_SORT, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + CMenu menuSort; + menuSort.LoadMenu(IDR_POPUP_SORT); + + m_wndToolBar.ReplaceButton(ID_SORT_MENU, CClassViewMenuButton(menuSort.GetSubMenu(0)->GetSafeHmenu())); + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->m_bText = FALSE; + pButton->m_bImage = TRUE; + pButton->SetImage(GetCmdMgr()->GetCmdImage(m_nCurrSort)); + pButton->SetMessageWnd(this); + } + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillClassView(); + + return 0; +} + +void CClassView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CClassView::FillClassView() +{ + HTREEITEM hRoot = m_wndClassView.InsertItem(_T("FakeApp 类"), 0, 0); + m_wndClassView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hClass = m_wndClassView.InsertItem(_T("CFakeAboutDlg"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAboutDlg()"), 3, 3, hClass); + + m_wndClassView.Expand(hRoot, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeApp"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeApp()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("InitInstance()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnAppAbout()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppDoc"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppDoc()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppDoc()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("OnNewDocument()"), 3, 3, hClass); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppView"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppView()"), 4, 4, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppView()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("GetDocument()"), 3, 3, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); + + hClass = m_wndClassView.InsertItem(_T("CFakeAppFrame"), 1, 1, hRoot); + m_wndClassView.InsertItem(_T("CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("~CFakeAppFrame()"), 3, 3, hClass); + m_wndClassView.InsertItem(_T("m_wndMenuBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndToolBar"), 6, 6, hClass); + m_wndClassView.InsertItem(_T("m_wndStatusBar"), 6, 6, hClass); + + hClass = m_wndClassView.InsertItem(_T("Globals"), 2, 2, hRoot); + m_wndClassView.InsertItem(_T("theFakeApp"), 5, 5, hClass); + m_wndClassView.Expand(hClass, TVE_EXPAND); +} + +void CClassView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndClassView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + CMenu menu; + menu.LoadMenu(IDR_POPUP_SORT); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } +} + +void CClassView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndClassView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +BOOL CClassView::PreTranslateMessage(MSG* pMsg) +{ + return CDockablePane::PreTranslateMessage(pMsg); +} + +void CClassView::OnSort(UINT id) +{ + if (m_nCurrSort == id) + { + return; + } + + m_nCurrSort = id; + + CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); + + if (pButton != nullptr) + { + pButton->SetImage(GetCmdMgr()->GetCmdImage(id)); + m_wndToolBar.Invalidate(); + m_wndToolBar.UpdateWindow(); + } +} + +void CClassView::OnUpdateSort(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(pCmdUI->m_nID == m_nCurrSort); +} + +void CClassView::OnClassAddMemberFunction() +{ + AfxMessageBox(_T("添加成员函数...")); +} + +void CClassView::OnClassAddMemberVariable() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassDefinition() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnClassProperties() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CClassView::OnNewFolder() +{ + AfxMessageBox(_T("新建文件夹...")); +} + +void CClassView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndClassView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CClassView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndClassView.SetFocus(); +} + +void CClassView::OnChangeVisualStyle() +{ + m_ClassViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_CLASS_VIEW_24 : IDB_CLASS_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_ClassViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_ClassViewImages.Add(&bmp, RGB(255, 0, 0)); + + m_wndClassView.SetImageList(&m_ClassViewImages, TVSIL_NORMAL); + + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_SORT_24 : IDR_SORT, 0, 0, TRUE /* 锁定*/); +} + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ClassView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ClassView.h" new file mode 100644 index 0000000..8459352 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ClassView.h" @@ -0,0 +1,53 @@ + +#pragma once + +#include "ViewTree.h" + +class CClassToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CClassView : public CDockablePane +{ +public: + CClassView() noexcept; + virtual ~CClassView(); + + void AdjustLayout(); + void OnChangeVisualStyle(); + +protected: + CClassToolBar m_wndToolBar; + CViewTree m_wndClassView; + CImageList m_ClassViewImages; + UINT m_nCurrSort; + + void FillClassView(); + +// 重写 +public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnClassAddMemberFunction(); + afx_msg void OnClassAddMemberVariable(); + afx_msg void OnClassDefinition(); + afx_msg void OnClassProperties(); + afx_msg void OnNewFolder(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnSort(UINT id); + afx_msg void OnUpdateSort(CCmdUI* pCmdUI); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/FileView.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/FileView.cpp" new file mode 100644 index 0000000..0c0bc9f --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/FileView.cpp" @@ -0,0 +1,257 @@ + +#include "pch.h" +#include "framework.h" +#include "mainfrm.h" +#include "FileView.h" +#include "Resource.h" +#include "CZBuffer.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CFileView + +CFileView::CFileView() noexcept +{ +} + +CFileView::~CFileView() +{ +} + +BEGIN_MESSAGE_MAP(CFileView, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_PROPERTIES, OnProperties) + ON_COMMAND(ID_OPEN, OnFileOpen) + ON_COMMAND(ID_OPEN_WITH, OnFileOpenWith) + ON_COMMAND(ID_DUMMY_COMPILE, OnDummyCompile) + ON_COMMAND(ID_EDIT_CUT, OnEditCut) + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_WM_PAINT() + ON_WM_SETFOCUS() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CWorkspaceBar 消息处理程序 + +int CFileView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建视图: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; + + if (!m_wndFileView.Create(dwViewStyle, rectDummy, this, 4)) + { + TRACE0("未能创建文件视图\n"); + return -1; // 未能创建 + } + + // 加载视图图像: + m_FileViewImages.Create(IDB_FILE_VIEW, 16, 0, RGB(255, 0, 255)); + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_EXPLORER); + m_wndToolBar.LoadToolBar(IDR_EXPLORER, 0, 0, TRUE /* 已锁定*/); + + OnChangeVisualStyle(); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + // 填入一些静态树视图数据(此处只需填入虚拟代码,而不是复杂的数据) + FillFileView(); + AdjustLayout(); + + return 0; +} + +void CFileView::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CFileView::FillFileView() +{ + HTREEITEM hRoot = m_wndFileView.InsertItem(_T("FakeApp 文件"), 0, 0); + m_wndFileView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); + + HTREEITEM hSrc = m_wndFileView.InsertItem(_T("FakeApp 源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeApp.rc"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppDoc.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("FakeAppView.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("MainFrm.cpp"), 1, 1, hSrc); + m_wndFileView.InsertItem(_T("pch.cpp"), 1, 1, hSrc); + + HTREEITEM hInc = m_wndFileView.InsertItem(_T("FakeApp 头文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppDoc.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("FakeAppView.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("Resource.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("MainFrm.h"), 2, 2, hInc); + m_wndFileView.InsertItem(_T("pch.h"), 2, 2, hInc); + + HTREEITEM hRes = m_wndFileView.InsertItem(_T("FakeApp 资源文件"), 0, 0, hRoot); + + m_wndFileView.InsertItem(_T("FakeApp.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeApp.rc2"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeAppDoc.ico"), 2, 2, hRes); + m_wndFileView.InsertItem(_T("FakeToolbar.bmp"), 2, 2, hRes); + + m_wndFileView.Expand(hRoot, TVE_EXPAND); + m_wndFileView.Expand(hSrc, TVE_EXPAND); + m_wndFileView.Expand(hInc, TVE_EXPAND); +} + +void CFileView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView; + ASSERT_VALID(pWndTree); + + if (pWnd != pWndTree) + { + CDockablePane::OnContextMenu(pWnd, point); + return; + } + + if (point != CPoint(-1, -1)) + { + // 选择已单击的项: + CPoint ptTree = point; + pWndTree->ScreenToClient(&ptTree); + + UINT flags = 0; + HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); + if (hTreeItem != nullptr) + { + pWndTree->SelectItem(hTreeItem); + } + } + + pWndTree->SetFocus(); + theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE); +} + +void CFileView::AdjustLayout() +{ + if (GetSafeHwnd() == nullptr) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndFileView.SetWindowPos(nullptr, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); +} + +void CFileView::OnProperties() +{ + AfxMessageBox(_T("属性....")); + +} + +void CFileView::OnFileOpen() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnFileOpenWith() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnDummyCompile() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCut() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditCopy() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnEditClear() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CFileView::OnPaint() +{ + CPaintDC dc(this); // 用于绘制的设备上下文 + + CRect rectTree; + m_wndFileView.GetWindowRect(rectTree); + ScreenToClient(rectTree); + + rectTree.InflateRect(1, 1); + dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); +} + +void CFileView::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + + m_wndFileView.SetFocus(); +} + +void CFileView::OnChangeVisualStyle() +{ + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_EXPLORER_24 : IDR_EXPLORER, 0, 0, TRUE /* 锁定*/); + + m_FileViewImages.DeleteImageList(); + + UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_FILE_VIEW_24 : IDB_FILE_VIEW; + + CBitmap bmp; + if (!bmp.LoadBitmap(uiBmpId)) + { + TRACE(_T("无法加载位图: %x\n"), uiBmpId); + ASSERT(FALSE); + return; + } + + BITMAP bmpObj; + bmp.GetBitmap(&bmpObj); + + UINT nFlags = ILC_MASK; + + nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; + + m_FileViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); + m_FileViewImages.Add(&bmp, RGB(255, 0, 255)); + + m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); +} + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/FileView.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/FileView.h" new file mode 100644 index 0000000..e39a7c9 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/FileView.h" @@ -0,0 +1,55 @@ + +#pragma once + +#include "ViewTree.h" + +class CFileViewToolBar : public CMFCToolBar +{ + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CFileView : public CDockablePane +{ +// 构造 +public: + CFileView() noexcept; + + void AdjustLayout(); + void OnChangeVisualStyle(); + +// 特性 +protected: + + CViewTree m_wndFileView; + CImageList m_FileViewImages; + CFileViewToolBar m_wndToolBar; + +protected: + void FillFileView(); + +// 实现 +public: + virtual ~CFileView(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnProperties(); + afx_msg void OnFileOpen(); + afx_msg void OnFileOpenWith(); + afx_msg void OnDummyCompile(); + afx_msg void OnEditCut(); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/MainFrm.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/MainFrm.cpp" new file mode 100644 index 0000000..e1a01cf --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/MainFrm.cpp" @@ -0,0 +1,408 @@ + +// MainFrm.cpp: CMainFrame 类的实现 +// + +#include "pch.h" +#include "framework.h" +#include "CZBuffer.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) + +const int iMaxUserToolbars = 10; +const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; +const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) + ON_WM_CREATE() + ON_COMMAND(ID_VIEW_CUSTOMIZE, &CMainFrame::OnViewCustomize) + ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, &CMainFrame::OnToolbarCreateNew) + ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook) + ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook) + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // 状态行指示器 + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +// CMainFrame 构造/析构 + +CMainFrame::CMainFrame() noexcept +{ + // TODO: 在此添加成员初始化代码 + theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2008); +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) + return -1; + + BOOL bNameValid; + + if (!m_wndMenuBar.Create(this)) + { + TRACE0("未能创建菜单栏\n"); + return -1; // 未能创建 + } + + m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); + + // 防止菜单栏在激活时获得焦点 + CMFCPopupMenu::SetForceMenuFocus(FALSE); + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) + { + TRACE0("未能创建工具栏\n"); + return -1; // 未能创建 + } + + CString strToolBarName; + bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); + ASSERT(bNameValid); + m_wndToolBar.SetWindowText(strToolBarName); + + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + + // 允许用户定义的工具栏操作: + InitUserToolbars(nullptr, uiFirstUserToolBarId, uiLastUserToolBarId); + + if (!m_wndStatusBar.Create(this)) + { + TRACE0("未能创建状态栏\n"); + return -1; // 未能创建 + } + m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); + + // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行 + m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndMenuBar); + DockPane(&m_wndToolBar); + + + // 启用 Visual Studio 2005 样式停靠窗口行为 + CDockingManager::SetDockingMode(DT_SMART); + // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 + EnableAutoHidePanes(CBRS_ALIGN_ANY); + + // 加载菜单项图像(不在任何标准工具栏上): + CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); + + // 创建停靠窗口 + if (!CreateDockingWindows()) + { + TRACE0("未能创建停靠窗口\n"); + return -1; + } + + m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); + m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndFileView); + CDockablePane* pTabbedBar = nullptr; + m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); + m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndOutput); + m_wndProperties.EnableDocking(CBRS_ALIGN_ANY); + DockPane(&m_wndProperties); + + // 基于持久值设置视觉管理器和样式 + OnApplicationLook(theApp.m_nAppLook); + + // 启用工具栏和停靠窗口菜单替换 + EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); + + // 启用快速(按住 Alt 拖动)工具栏自定义 + CMFCToolBar::EnableQuickCustomization(); + + if (CMFCToolBar::GetUserImages() == nullptr) + { + // 加载用户定义的工具栏图像 + if (m_UserImages.Load(_T(".\\UserImages.bmp"))) + { + CMFCToolBar::SetUserImages(&m_UserImages); + } + } + + // 启用菜单个性化(最近使用的命令) + // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 + CList lstBasicCommands; + + lstBasicCommands.AddTail(ID_FILE_NEW); + lstBasicCommands.AddTail(ID_FILE_OPEN); + lstBasicCommands.AddTail(ID_FILE_SAVE); + lstBasicCommands.AddTail(ID_FILE_PRINT); + lstBasicCommands.AddTail(ID_APP_EXIT); + lstBasicCommands.AddTail(ID_EDIT_CUT); + lstBasicCommands.AddTail(ID_EDIT_PASTE); + lstBasicCommands.AddTail(ID_EDIT_UNDO); + lstBasicCommands.AddTail(ID_APP_ABOUT); + lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); + lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); + lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7); + lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); + lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); + lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); + lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); + + CMFCToolBar::SetBasicCommands(lstBasicCommands); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWndEx::PreCreateWindow(cs) ) + return FALSE; + // TODO: 在此处通过修改 + // CREATESTRUCT cs 来修改窗口类或样式 + + return TRUE; +} + +BOOL CMainFrame::CreateDockingWindows() +{ + BOOL bNameValid; + + // 创建类视图 + CString strClassView; + bNameValid = strClassView.LoadString(IDS_CLASS_VIEW); + ASSERT(bNameValid); + if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“类视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建文件视图 + CString strFileView; + bNameValid = strFileView.LoadString(IDS_FILE_VIEW); + ASSERT(bNameValid); + if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“文件视图”窗口\n"); + return FALSE; // 未能创建 + } + + // 创建输出窗口 + CString strOutputWnd; + bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND); + ASSERT(bNameValid); + if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建输出窗口\n"); + return FALSE; // 未能创建 + } + + // 创建属性窗口 + CString strPropertiesWnd; + bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND); + ASSERT(bNameValid); + if (!m_wndProperties.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) + { + TRACE0("未能创建“属性”窗口\n"); + return FALSE; // 未能创建 + } + + SetDockingWindowIcons(theApp.m_bHiColorIcons); + return TRUE; +} + +void CMainFrame::SetDockingWindowIcons(BOOL bHiColorIcons) +{ + HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_FILE_VIEW_HC : IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndFileView.SetIcon(hFileViewIcon, FALSE); + + HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_CLASS_VIEW_HC : IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndClassView.SetIcon(hClassViewIcon, FALSE); + + HICON hOutputBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_OUTPUT_WND_HC : IDI_OUTPUT_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndOutput.SetIcon(hOutputBarIcon, FALSE); + + HICON hPropertiesBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_PROPERTIES_WND_HC : IDI_PROPERTIES_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); + m_wndProperties.SetIcon(hPropertiesBarIcon, FALSE); + +} + +// CMainFrame 诊断 + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWndEx::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWndEx::Dump(dc); +} +#endif //_DEBUG + + +// CMainFrame 消息处理程序 + +void CMainFrame::OnViewCustomize() +{ + CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* 扫描菜单*/); + pDlgCust->EnableUserDefinedToolbars(); + pDlgCust->Create(); +} + +LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) +{ + LRESULT lres = CFrameWndEx::OnToolbarCreateNew(wp,lp); + if (lres == 0) + { + return 0; + } + + CMFCToolBar* pUserToolbar = (CMFCToolBar*)lres; + ASSERT_VALID(pUserToolbar); + + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + return lres; +} + +void CMainFrame::OnApplicationLook(UINT id) +{ + CWaitCursor wait; + + theApp.m_nAppLook = id; + + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_WIN_2000: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); + break; + + case ID_VIEW_APPLOOK_OFF_XP: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); + break; + + case ID_VIEW_APPLOOK_WIN_XP: + CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + break; + + case ID_VIEW_APPLOOK_OFF_2003: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2005: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_VS_2008: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + case ID_VIEW_APPLOOK_WINDOWS_7: + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7)); + CDockingManager::SetDockingMode(DT_SMART); + break; + + default: + switch (theApp.m_nAppLook) + { + case ID_VIEW_APPLOOK_OFF_2007_BLUE: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); + break; + + case ID_VIEW_APPLOOK_OFF_2007_BLACK: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); + break; + + case ID_VIEW_APPLOOK_OFF_2007_SILVER: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); + break; + + case ID_VIEW_APPLOOK_OFF_2007_AQUA: + CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); + break; + } + + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); + CDockingManager::SetDockingMode(DT_SMART); + } + + m_wndOutput.UpdateFonts(); + RedrawWindow(nullptr, nullptr, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); + + theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); +} + +void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI) +{ + pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID); +} + + +BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) +{ + // 基类将执行真正的工作 + + if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) + { + return FALSE; + } + + + // 为所有用户工具栏启用自定义按钮 + BOOL bNameValid; + CString strCustomize; + bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); + ASSERT(bNameValid); + + for (int i = 0; i < iMaxUserToolbars; i ++) + { + CMFCToolBar* pUserToolbar = GetUserToolBarByIndex(i); + if (pUserToolbar != nullptr) + { + pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); + } + } + + return TRUE; +} + + +void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CFrameWndEx::OnSettingChange(uFlags, lpszSection); + m_wndOutput.UpdateFonts(); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/MainFrm.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/MainFrm.h" new file mode 100644 index 0000000..02feb8e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/MainFrm.h" @@ -0,0 +1,61 @@ + +// MainFrm.h: CMainFrame 类的接口 +// + +#pragma once +#include "FileView.h" +#include "ClassView.h" +#include "OutputWnd.h" +#include "PropertiesWnd.h" + +class CMainFrame : public CFrameWndEx +{ + +protected: // 仅从序列化创建 + CMainFrame() noexcept; + DECLARE_DYNCREATE(CMainFrame) + +// 特性 +public: + +// 操作 +public: + +// 重写 +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = nullptr, CCreateContext* pContext = nullptr); + +// 实现 +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // 控件条嵌入成员 + CMFCMenuBar m_wndMenuBar; + CMFCToolBar m_wndToolBar; + CMFCStatusBar m_wndStatusBar; + CMFCToolBarImages m_UserImages; + CFileView m_wndFileView; + CClassView m_wndClassView; + COutputWnd m_wndOutput; + CPropertiesWnd m_wndProperties; + +// 生成的消息映射函数 +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnViewCustomize(); + afx_msg LRESULT OnToolbarCreateNew(WPARAM wp, LPARAM lp); + afx_msg void OnApplicationLook(UINT id); + afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + DECLARE_MESSAGE_MAP() + + BOOL CreateDockingWindows(); + void SetDockingWindowIcons(BOOL bHiColorIcons); +}; + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Mesh.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Mesh.cpp" new file mode 100644 index 0000000..bb75f64 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Mesh.cpp" @@ -0,0 +1,10 @@ +#include "pch.h" +#include "Mesh.h" + +CMesh::CMesh(void) +{ +} + +CMesh:: ~CMesh(void) +{ +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Mesh.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Mesh.h" new file mode 100644 index 0000000..f6b9d30 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Mesh.h" @@ -0,0 +1,10 @@ +#pragma once +#include"T2.h" +class CMesh +{ +public: + CMesh(void); + virtual ~CMesh(void); +public: + CT2 BL, BR, TR, TL;//ıε4ǵ +}; \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/OutputWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/OutputWnd.cpp" new file mode 100644 index 0000000..e3f4901 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/OutputWnd.cpp" @@ -0,0 +1,200 @@ + +#include "pch.h" +#include "framework.h" + +#include "OutputWnd.h" +#include "Resource.h" +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// COutputBar + +COutputWnd::COutputWnd() noexcept +{ +} + +COutputWnd::~COutputWnd() +{ +} + +BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() +END_MESSAGE_MAP() + +int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建选项卡窗口: + if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1)) + { + TRACE0("未能创建输出选项卡窗口\n"); + return -1; // 未能创建 + } + + // 创建输出窗格: + const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; + + if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) || + !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) || + !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4)) + { + TRACE0("未能创建输出窗口\n"); + return -1; // 未能创建 + } + + UpdateFonts(); + + CString strTabName; + BOOL bNameValid; + + // 将列表窗口附加到选项卡: + bNameValid = strTabName.LoadString(IDS_BUILD_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0); + bNameValid = strTabName.LoadString(IDS_DEBUG_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1); + bNameValid = strTabName.LoadString(IDS_FIND_TAB); + ASSERT(bNameValid); + m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2); + + // 使用一些虚拟文本填写输出选项卡(无需复杂数据) + FillBuildWindow(); + FillDebugWindow(); + FillFindWindow(); + + return 0; +} + +void COutputWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + + // 选项卡控件应覆盖整个工作区: + m_wndTabs.SetWindowPos (nullptr, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); +} + +void COutputWnd::AdjustHorzScroll(CListBox& wndListBox) +{ + CClientDC dc(this); + CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular); + + int cxExtentMax = 0; + + for (int i = 0; i < wndListBox.GetCount(); i ++) + { + CString strItem; + wndListBox.GetText(i, strItem); + + cxExtentMax = max(cxExtentMax, (int)dc.GetTextExtent(strItem).cx); + } + + wndListBox.SetHorizontalExtent(cxExtentMax); + dc.SelectObject(pOldFont); +} + +void COutputWnd::FillBuildWindow() +{ + m_wndOutputBuild.AddString(_T("生成输出正显示在此处。")); + m_wndOutputBuild.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputBuild.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillDebugWindow() +{ + m_wndOutputDebug.AddString(_T("调试输出正显示在此处。")); + m_wndOutputDebug.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputDebug.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::FillFindWindow() +{ + m_wndOutputFind.AddString(_T("查找输出正显示在此处。")); + m_wndOutputFind.AddString(_T("输出正显示在列表视图的行中")); + m_wndOutputFind.AddString(_T("但您可以根据需要更改其显示方式...")); +} + +void COutputWnd::UpdateFonts() +{ + m_wndOutputBuild.SetFont(&afxGlobalData.fontRegular); + m_wndOutputDebug.SetFont(&afxGlobalData.fontRegular); + m_wndOutputFind.SetFont(&afxGlobalData.fontRegular); +} + +///////////////////////////////////////////////////////////////////////////// +// COutputList1 + +COutputList::COutputList() noexcept +{ +} + +COutputList::~COutputList() +{ +} + +BEGIN_MESSAGE_MAP(COutputList, CListBox) + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) + ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput) + ON_WM_WINDOWPOSCHANGING() +END_MESSAGE_MAP() +///////////////////////////////////////////////////////////////////////////// +// COutputList 消息处理程序 + +void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) +{ + CMenu menu; + menu.LoadMenu(IDR_OUTPUT_POPUP); + + CMenu* pSumMenu = menu.GetSubMenu(0); + + if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; + + if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) + return; + + ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); + UpdateDialogControls(this, FALSE); + } + + SetFocus(); +} + +void COutputList::OnEditCopy() +{ + MessageBox(_T("复制输出")); +} + +void COutputList::OnEditClear() +{ + MessageBox(_T("清除输出")); +} + +void COutputList::OnViewOutput() +{ + CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner()); + CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame()); + + if (pMainFrame != nullptr && pParentBar != nullptr) + { + pMainFrame->SetFocus(); + pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE); + pMainFrame->RecalcLayout(); + + } +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/OutputWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/OutputWnd.h" new file mode 100644 index 0000000..4d773c3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/OutputWnd.h" @@ -0,0 +1,59 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// COutputList 窗口 + +class COutputList : public CListBox +{ +// 构造 +public: + COutputList() noexcept; + +// 实现 +public: + virtual ~COutputList(); + +protected: + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnEditCopy(); + afx_msg void OnEditClear(); + afx_msg void OnViewOutput(); + + DECLARE_MESSAGE_MAP() +}; + +class COutputWnd : public CDockablePane +{ +// 构造 +public: + COutputWnd() noexcept; + + void UpdateFonts(); + +// 特性 +protected: + CMFCTabCtrl m_wndTabs; + + COutputList m_wndOutputBuild; + COutputList m_wndOutputDebug; + COutputList m_wndOutputFind; + +protected: + void FillBuildWindow(); + void FillDebugWindow(); + void FillFindWindow(); + + void AdjustHorzScroll(CListBox& wndListBox); + +// 实现 +public: + virtual ~COutputWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + + DECLARE_MESSAGE_MAP() +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/P2.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/P2.cpp" new file mode 100644 index 0000000..d12c93e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/P2.cpp" @@ -0,0 +1,95 @@ +#include "pch.h" +#include "P2.h" + +CP2::CP2(void) +{ + x = 0.0, y = 0.0, w = 1.0; + c = CRGB(0.5, 0.4, 0.0); +} + +CP2::CP2(double x, double y, CRGB c) +{ + this->x = x; + this->y = y; + this->w = 1.0; + this->c = c; +} + +CP2::CP2(double x, double y) +{ + this->x = x; + this->y = y; + this->w = 1.0; + this->c = CRGB(1.0, 1.0, 1.0); +} + +CP2::~CP2(void) +{ + +} + +CP2 operator + (const CP2 &p0, const CP2 &p1)// +{ + CP2 result; + result.x = p0.x + p1.x; + result.y = p0.y + p1.y; + return result; +} + +CP2 operator - (const CP2 &p0, const CP2 &p1)// +{ + CP2 result; + result.x = p0.x - p1.x; + result.y = p0.y - p1.y; + return result; +} + +CP2 operator * (const CP2 &p, double scalar)//ͳĻ +{ + return CP2(p.x * scalar, p.y * scalar); +} + +CP2 operator * (double scalar, const CP2 &p)//͵Ļ +{ + return CP2(p.x * scalar, p.y * scalar); +} + +CP2 operator / (const CP2 &p, double scalar)// +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + CP2 result; + result.x = p.x / scalar; + result.y = p.y / scalar; + return result; +} + +CP2 operator += (CP2 &p0, CP2 &p1) +{ + p0.x += p1.x; + p0.y += p1.y; + return p0; +} + +CP2 operator-=(CP2 &p0, CP2 &p1) +{ + p0.x -= p1.x; + p0.y -= p1.y; + return p0; +} + +CP2 operator *= (CP2 &p, double scalar) +{ + p.x *= scalar; + p.y *= scalar; + return p; +} + +CP2 operator /= (CP2 &p, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + p.x /= scalar; + p.y /= scalar; + return p; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/P2.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/P2.h" new file mode 100644 index 0000000..6ddda5c --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/P2.h" @@ -0,0 +1,25 @@ +#pragma once +#include"CRGB.h" + +class CP2 +{ +public: + CP2(void); + virtual ~CP2(void); + CP2(double x, double y); + CP2(double x, double y, CRGB c); + friend CP2 operator + (const CP2 &p0, const CP2 &p1);// + friend CP2 operator - (const CP2 &p0, const CP2 &p1); + friend CP2 operator * (const CP2 &p, double scalar); + friend CP2 operator * (double scalar, const CP2 &p); + friend CP2 operator / (const CP2 &p, double scalar); + friend CP2 operator += (CP2 &p0, CP2 &p1); + friend CP2 operator -= (CP2 &p0, CP2 &p1); + friend CP2 operator *= (CP2 &p, double scalar); + friend CP2 operator /= (CP2 &p, double scalar); +public: + double x; + double y; + double w; + CRGB c; +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/P3.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/P3.cpp" new file mode 100644 index 0000000..cc3845e --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/P3.cpp" @@ -0,0 +1,85 @@ +#include "pch.h" +#include "P3.h" + +CP3::CP3(void) +{ + z = 0.0; +} + +CP3::~CP3(void) +{ + +} +CP3::CP3(double x, double y, double z) :CP2(x, y) +{ + this->z = z; +} + +CP3 operator + (const CP3 &p0, const CP3 &p1)// +{ + CP3 p; + p.x = p0.x + p1.x; + p.y = p0.y + p1.y; + p.z = p0.z + p1.z; + return p; +} + +CP3 operator - (const CP3 &p0, const CP3 &p1)// +{ + CP3 p; + p.x = p0.x - p1.x; + p.y = p0.y - p1.y; + p.z = p0.z - p1.z; + return p; +} + +CP3 operator * (const CP3 &p, double scalar)//ͳĻ +{ + return CP3(p.x * scalar, p.y * scalar, p.z * scalar); +} + +CP3 operator * (double scalar, const CP3 &p)//ͳĻ +{ + return CP3(p.x * scalar, p.y * scalar, p.z * scalar); +} + +CP3 operator / (const CP3 &p, double scalar)// +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + return CP3(p.x / scalar, p.y / scalar, p.z / scalar); +} + +CP3 operator += (CP3 &p0, CP3 &p1) +{ + p0.x = p0.x + p1.x; + p0.y = p0.y + p1.y; + p0.z = p0.z + p1.z; + return p0; +} + +CP3 operator -= (CP3 &p0, CP3 &p1) +{ + p0.x = p0.x - p1.x; + p0.y = p0.y - p1.y; + p0.z = p0.z - p1.z; + return p0; +} + +CP3 operator *= (CP3 &p, double scalar) +{ + p.x = p.x * scalar; + p.y = p.y * scalar; + p.z = p.z * scalar; + return p; +} + +CP3 operator /= (CP3 &p, double scalar) +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + p.x = p.x / scalar; + p.y = p.y / scalar; + p.z = p.z / scalar; + return p; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/P3.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/P3.h" new file mode 100644 index 0000000..69165da --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/P3.h" @@ -0,0 +1,21 @@ +#pragma once +#include "p2.h" + +class CP3 : public CP2 +{ +public: + CP3(void); + virtual ~CP3(void); + CP3(double x, double y, double z); + friend CP3 operator + (const CP3 &p0, const CP3 &p1);// + friend CP3 operator - (const CP3 &p0, const CP3 &p1); + friend CP3 operator * (const CP3 &p, double scalar); + friend CP3 operator * (double scalar, const CP3 &p); + friend CP3 operator / (const CP3 &p, double scalar); + friend CP3 operator += (CP3 &p0, CP3 &p1); + friend CP3 operator -= (CP3 &p0, CP3 &p1); + friend CP3 operator *= (CP3 &p, double scalar); + friend CP3 operator /= (CP3 &p, double scalar); +public: + double z; +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Patch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Patch.cpp" new file mode 100644 index 0000000..1bc5444 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Patch.cpp" @@ -0,0 +1,12 @@ +#include "pch.h" +#include "Patch.h" + + +CPatch::CPatch(void) +{ +} + + +CPatch::~CPatch(void) +{ +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Patch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Patch.h" new file mode 100644 index 0000000..742d94d --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Patch.h" @@ -0,0 +1,10 @@ +#pragma once +class CPatch +{ +public: + CPatch(void); + virtual ~CPatch(void); +public: + int pIndex[4][4]; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Point2.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Point2.cpp" new file mode 100644 index 0000000..0e2344b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Point2.cpp" @@ -0,0 +1,70 @@ +#include "pch.h" +#include "Point2.h" + +CPoint2::CPoint2(void) +{ + x = 0; + y = 0; + c = CRGB(0, 0, 0); +} + +CPoint2::CPoint2(int x, int y) +{ + this->x = x; + this->y = y; + c = CRGB(0, 0, 0); +} + +CPoint2::CPoint2(int x, int y, CRGB c) +{ + this->x = x; + this->y = y; + this->c = c; +} + +CPoint2::CPoint2(int x, int y, CVector3 n) +{ + this->x = x; + this->y = y; + this->n = n; +} + +CPoint2::~CPoint2(void) +{ +} + +CPoint2 operator + (const CPoint2 &pt0, const CPoint2 &pt1)// +{ + CPoint2 point; + point.x = pt0.x + pt1.x; + point.y = pt0.y + pt1.y; + return point; +} + +CPoint2 operator - (const CPoint2 &pt0, const CPoint2 &pt1)// +{ + CPoint2 point; + point.x = pt0.x - pt1.x; + point.y = pt0.y - pt1.y; + return point; +} + +CPoint2 operator * (const CPoint2 &pt, int scalar)//ͳĻ +{ + return CPoint2(pt.x * scalar, pt.y * scalar); +} + +CPoint2 operator * (int scalar, const CPoint2 &pt)//ͳĻ +{ + return CPoint2(pt.x * scalar, pt.y * scalar); +} + +CPoint2 operator / (const CPoint2 &pt, double scalar)// +{ + if (fabs(scalar) < 1e-4) + scalar = 1.0; + CPoint2 point; + point.x = int(pt.x / scalar); + point.y = int(pt.y / scalar); + return point; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Point2.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Point2.h" new file mode 100644 index 0000000..be2e1b2 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Point2.h" @@ -0,0 +1,21 @@ +#pragma once +#include"CRGB.h" +#include"Vector3.h" + +class CPoint2 +{ +public: + CPoint2(void); + CPoint2(int x, int y); + CPoint2(int x, int y, CRGB c); + CPoint2(int x, int y, CVector3 n); + virtual ~CPoint2(void); + friend CPoint2 operator + (const CPoint2 &pt0, const CPoint2 &pt1); + friend CPoint2 operator - (const CPoint2 &pt0, const CPoint2 &pt1); + friend CPoint2 operator * (int scalar, const CPoint2 &pt); +public: + int x, y; + CRGB c; + CVector3 n; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Point3.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Point3.cpp" new file mode 100644 index 0000000..f054f81 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Point3.cpp" @@ -0,0 +1,12 @@ +#include "pch.h" +#include "Point3.h" +CPoint3::CPoint3(void) +{ +} +CPoint3::CPoint3(int x, int y, double z) :CPoint2(x, y) +{ + this->z = z; +} +CPoint3::~CPoint3(void) +{ +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Point3.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Point3.h" new file mode 100644 index 0000000..9ce81a5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Point3.h" @@ -0,0 +1,11 @@ +#pragma once +#include "Point2.h" +class CPoint3 : public CPoint2 +{ +public: + CPoint3(void); + CPoint3(int x, int y, double z); + virtual ~CPoint3(void); +public: + double z; +}; \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Projection.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Projection.cpp" new file mode 100644 index 0000000..f5add1f --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Projection.cpp" @@ -0,0 +1,68 @@ +#include "pch.h" +#include "Projection.h" + +CProjection::CProjection(void) +{ + R = 1200, d = 800; + EyePoint.x = 0, EyePoint.y = 0, EyePoint.z = R;//ӵλĻǰ +} + +CProjection::~CProjection(void) +{ +} + +void CProjection::SetEye(double R)//Ӿ +{ + this->R = R; +} + +CP3 CProjection::GetEye(void)//ȡӵ +{ + return EyePoint; +} + + +CP2 CProjection::ObliqueProjection(CP3 WorldPoint)//бͶӰ +{ + CP2 ScreenPoint;//Ļϵά + ScreenPoint.x = WorldPoint.x - 0.3536 * WorldPoint.z; + ScreenPoint.y = WorldPoint.y - 0.3536 * WorldPoint.z; + return ScreenPoint; +} + +CP2 CProjection::OrthogonalProjection(CP3 WorldPoint)//ͶӰ +{ + CP2 ScreenPoint;//Ļϵά + ScreenPoint.x = WorldPoint.x; + ScreenPoint.y = WorldPoint.y; + return ScreenPoint; +} + +CP2 CProjection::PerspectiveProjection2(CP3 WorldPoint) +{ + CP3 ViewPoint;//۲ϵά + ViewPoint.x = WorldPoint.x; + ViewPoint.y = WorldPoint.y; + ViewPoint.z = EyePoint.z - WorldPoint.z; + ViewPoint.c = WorldPoint.c; + CP2 ScreenPoint;//Ļϵά + ScreenPoint.x = d * ViewPoint.x / ViewPoint.z; + ScreenPoint.y = d * ViewPoint.y / ViewPoint.z; + ScreenPoint.c = ViewPoint.c; + return ScreenPoint; +} + +CP3 CProjection::PerspectiveProjection3(CP3 WorldPoint) +{ + CP3 ViewPoint; + ViewPoint.x = WorldPoint.x; + ViewPoint.y = WorldPoint.y; + ViewPoint.z = EyePoint.z - WorldPoint.z; + ViewPoint.c = WorldPoint.c; + CP3 ScreenPoint; + ScreenPoint.x = d * ViewPoint.x / ViewPoint.z; + ScreenPoint.y = d * ViewPoint.y / ViewPoint.z; + ScreenPoint.z = (ViewPoint.z - d) * d / ViewPoint.z; + ScreenPoint.c = ViewPoint.c; + return ScreenPoint; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Projection.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Projection.h" new file mode 100644 index 0000000..2cc9eec --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Projection.h" @@ -0,0 +1,19 @@ +#pragma once +#include "P3.h" + +class CProjection +{ +public: + CProjection(void); + virtual ~CProjection(void); + void SetEye(double R);//Ӿ + CP3 GetEye(void);//ȡӵ + CP2 ObliqueProjection(CP3 WorldPoint);//бͶӰ + CP2 OrthogonalProjection(CP3 WorldPoint);//ͶӰ + CP2 PerspectiveProjection2(CP3 WorldPoint);//ά͸ͶӰ + CP3 PerspectiveProjection3(CP3 WorldPoint);//ά͸ͶӰ +private: + CP3 EyePoint;//ӵ + double R, d;//ӾӾ +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/PropertiesWnd.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/PropertiesWnd.cpp" new file mode 100644 index 0000000..4084a95 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/PropertiesWnd.cpp" @@ -0,0 +1,273 @@ + +#include "pch.h" +#include "framework.h" + +#include "PropertiesWnd.h" +#include "Resource.h" +#include "MainFrm.h" +#include "CZBuffer.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar + +CPropertiesWnd::CPropertiesWnd() noexcept +{ + m_nComboHeight = 0; +} + +CPropertiesWnd::~CPropertiesWnd() +{ +} + +BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane) + ON_WM_CREATE() + ON_WM_SIZE() + ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties) + ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties) + ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties) + ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties) + ON_COMMAND(ID_PROPERTIES1, OnProperties1) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1) + ON_COMMAND(ID_PROPERTIES2, OnProperties2) + ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2) + ON_WM_SETFOCUS() + ON_WM_SETTINGCHANGE() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CResourceViewBar 消息处理程序 + +void CPropertiesWnd::AdjustLayout() +{ + if (GetSafeHwnd () == nullptr || (AfxGetMainWnd() != nullptr && AfxGetMainWnd()->IsIconic())) + { + return; + } + + CRect rectClient; + GetClientRect(rectClient); + + int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; + + m_wndObjectCombo.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndToolBar.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); + m_wndPropList.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight + cyTlb, rectClient.Width(), rectClient.Height() -(m_nComboHeight+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER); +} + +int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDockablePane::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rectDummy; + rectDummy.SetRectEmpty(); + + // 创建组合: + const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1)) + { + TRACE0("未能创建属性组合 \n"); + return -1; // 未能创建 + } + + m_wndObjectCombo.AddString(_T("应用程序")); + m_wndObjectCombo.AddString(_T("属性窗口")); + m_wndObjectCombo.SetCurSel(0); + + CRect rectCombo; + m_wndObjectCombo.GetClientRect (&rectCombo); + + m_nComboHeight = rectCombo.Height(); + + if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2)) + { + TRACE0("未能创建属性网格\n"); + return -1; // 未能创建 + } + + InitPropList(); + + m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES); + m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* 已锁定*/); + m_wndToolBar.CleanUpLockedImages(); + m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* 锁定*/); + + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); + m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); + m_wndToolBar.SetOwner(this); + + // 所有命令将通过此控件路由,而不是通过主框架路由: + m_wndToolBar.SetRouteCommandsViaFrame(FALSE); + + AdjustLayout(); + return 0; +} + +void CPropertiesWnd::OnSize(UINT nType, int cx, int cy) +{ + CDockablePane::OnSize(nType, cx, cy); + AdjustLayout(); +} + +void CPropertiesWnd::OnExpandAllProperties() +{ + m_wndPropList.ExpandAll(); +} + +void CPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* /* pCmdUI */) +{ +} + +void CPropertiesWnd::OnSortProperties() +{ + m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode()); +} + +void CPropertiesWnd::OnProperties1() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::OnProperties2() +{ + // TODO: 在此处添加命令处理程序代码 +} + +void CPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/) +{ + // TODO: 在此处添加命令更新 UI 处理程序代码 +} + +void CPropertiesWnd::InitPropList() +{ + SetPropListFont(); + + m_wndPropList.EnableHeaderCtrl(FALSE); + m_wndPropList.EnableDescriptionArea(); + m_wndPropList.SetVSDotNetLook(); + m_wndPropList.MarkModifiedProperties(); + + CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("外观")); + + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("三维外观"), (_variant_t) false, _T("指定窗口的字体不使用粗体,并且控件将使用三维边框"))); + + CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("边框"), _T("对话框外框"), _T("其中之一: “无”、“细”、“可调整大小”或“对话框外框”")); + pProp->AddOption(_T("无")); + pProp->AddOption(_T("细")); + pProp->AddOption(_T("可调整大小")); + pProp->AddOption(_T("对话框外框")); + pProp->AllowEdit(FALSE); + + pGroup1->AddSubItem(pProp); + pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("标题"), (_variant_t) _T("关于"), _T("指定窗口标题栏中显示的文本"))); + + m_wndPropList.AddProperty(pGroup1); + + CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("窗口大小"), 0, TRUE); + + pProp = new CMFCPropertyGridProperty(_T("高度"), (_variant_t) 250l, _T("指定窗口的高度")); + pProp->EnableSpinControl(TRUE, 50, 300); + pSize->AddSubItem(pProp); + + pProp = new CMFCPropertyGridProperty( _T("宽度"), (_variant_t) 150l, _T("指定窗口的宽度")); + pProp->EnableSpinControl(TRUE, 50, 200); + pSize->AddSubItem(pProp); + + m_wndPropList.AddProperty(pSize); + + CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("字体")); + + LOGFONT lf; + CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + font->GetLogFont(&lf); + + _tcscpy_s(lf.lfFaceName, _T("宋体, Arial")); + + pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("字体"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("指定窗口的默认字体"))); + pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("使用系统字体"), (_variant_t) true, _T("指定窗口使用“MS Shell Dlg”字体"))); + + m_wndPropList.AddProperty(pGroup2); + + CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("杂项")); + pProp = new CMFCPropertyGridProperty(_T("(名称)"), _T("应用程序")); + pProp->Enable(FALSE); + pGroup3->AddSubItem(pProp); + + CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("窗口颜色"), RGB(210, 192, 254), nullptr, _T("指定默认的窗口颜色")); + pColorProp->EnableOtherButton(_T("其他...")); + pColorProp->EnableAutomaticButton(_T("默认"), ::GetSysColor(COLOR_3DFACE)); + pGroup3->AddSubItem(pColorProp); + + static const TCHAR szFilter[] = _T("图标文件(*.ico)|*.ico|所有文件(*.*)|*.*||"); + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("图标"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("指定窗口图标"))); + + pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("文件夹"), _T("c:\\"))); + + m_wndPropList.AddProperty(pGroup3); + + CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("层次结构")); + + CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("第一个子级")); + pGroup4->AddSubItem(pGroup41); + + CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("第二个子级")); + pGroup41->AddSubItem(pGroup411); + + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 1"), (_variant_t) _T("值 1"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 2"), (_variant_t) _T("值 2"), _T("此为说明"))); + pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 3"), (_variant_t) _T("值 3"), _T("此为说明"))); + + pGroup4->Expand(FALSE); + m_wndPropList.AddProperty(pGroup4); +} + +void CPropertiesWnd::OnSetFocus(CWnd* pOldWnd) +{ + CDockablePane::OnSetFocus(pOldWnd); + m_wndPropList.SetFocus(); +} + +void CPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + CDockablePane::OnSettingChange(uFlags, lpszSection); + SetPropListFont(); +} + +void CPropertiesWnd::SetPropListFont() +{ + ::DeleteObject(m_fntPropList.Detach()); + + LOGFONT lf; + afxGlobalData.fontRegular.GetLogFont(&lf); + + NONCLIENTMETRICS info; + info.cbSize = sizeof(info); + + afxGlobalData.GetNonClientMetrics(info); + + lf.lfHeight = info.lfMenuFont.lfHeight; + lf.lfWeight = info.lfMenuFont.lfWeight; + lf.lfItalic = info.lfMenuFont.lfItalic; + + m_fntPropList.CreateFontIndirect(&lf); + + m_wndPropList.SetFont(&m_fntPropList); + m_wndObjectCombo.SetFont(&m_fntPropList); +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/PropertiesWnd.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/PropertiesWnd.h" new file mode 100644 index 0000000..e056430 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/PropertiesWnd.h" @@ -0,0 +1,62 @@ + +#pragma once + +class CPropertiesToolBar : public CMFCToolBar +{ +public: + virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) + { + CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); + } + + virtual BOOL AllowShowOnList() const { return FALSE; } +}; + +class CPropertiesWnd : public CDockablePane +{ +// 构造 +public: + CPropertiesWnd() noexcept; + + void AdjustLayout(); + +// 特性 +public: + void SetVSDotNetLook(BOOL bSet) + { + m_wndPropList.SetVSDotNetLook(bSet); + m_wndPropList.SetGroupNameFullWidth(bSet); + } + +protected: + CFont m_fntPropList; + CComboBox m_wndObjectCombo; + CPropertiesToolBar m_wndToolBar; + CMFCPropertyGridCtrl m_wndPropList; + +// 实现 +public: + virtual ~CPropertiesWnd(); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnExpandAllProperties(); + afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI); + afx_msg void OnSortProperties(); + afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI); + afx_msg void OnProperties1(); + afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI); + afx_msg void OnProperties2(); + afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + + DECLARE_MESSAGE_MAP() + + void InitPropList(); + void SetPropListFont(); + + int m_nComboHeight; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Revolution.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Revolution.cpp" new file mode 100644 index 0000000..e6df1ec --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Revolution.cpp" @@ -0,0 +1,122 @@ + +#include "pch.h" +#include "Revolution.h" + +CRevolution::CRevolution(void) +{ +} + +CRevolution::~CRevolution(void) +{ +} + +void CRevolution::ReadCubicBezierControlPoint(CP3 P[4])//Bezier4Ƶʼ +{ + for (int i = 0; i < 4; i++) + this->P[i] = P[i]; + //תݽṹ + ReadVertex(); + ReadPatch(); +} + + +CP3* CRevolution::GetVertexArrayName(void)//õ +{ + return V; +} + +void CRevolution::ReadVertex(void)//תпƵ +{ + const double m = 0.5523;//ħ + //תһȦҪ4,һ16,ڶ12㣬12㣬ĸ8㣬48 + //һƬyo + V[0] = P[0]; + V[1] = P[1]; + V[2] = P[2]; + V[3] = P[3]; + V[4].x = V[0].x, V[4].y = V[0].y, V[4].z = -V[0].x * m; + V[5].x = V[1].x, V[5].y = V[1].y, V[5].z = -V[1].x * m; + V[6].x = V[2].x, V[6].y = V[2].y, V[6].z = -V[2].x * m; + V[7].x = V[3].x, V[7].y = V[3].y, V[7].z = -V[3].x * m; + V[8].x = V[0].x * m, V[8].y = V[0].y, V[8].z = -V[0].x; + V[9].x = V[1].x * m, V[9].y = V[1].y, V[9].z = -V[1].x; + V[10].x = V[2].x * m, V[10].y = V[2].y, V[10].z = -V[2].x; + V[11].x = V[3].x * m, V[11].y = V[3].y, V[11].z = -V[3].x; + V[12].x = V[0].z, V[12].y = V[0].y, V[12].z = -V[0].x; + V[13].x = V[1].z, V[13].y = V[1].y, V[13].z = -V[1].x; + V[14].x = V[2].z, V[14].y = V[2].y, V[14].z = -V[2].x; + V[15].x = V[3].z, V[15].y = V[3].y, V[15].z = -V[3].x; + //ڶƬ + V[16].x = -V[0].x * m, V[16].y = V[0].y, V[16].z = -V[0].x; + V[17].x = -V[1].x * m, V[17].y = V[1].y, V[17].z = -V[1].x; + V[18].x = -V[2].x * m, V[18].y = V[2].y, V[18].z = -V[2].x; + V[19].x = -V[3].x * m, V[19].y = V[3].y, V[19].z = -V[3].x; + V[20].x = -V[0].x, V[20].y = V[0].y, V[20].z = -V[0].x * m; + V[21].x = -V[1].x, V[21].y = V[1].y, V[21].z = -V[1].x * m; + V[22].x = -V[2].x, V[22].y = V[2].y, V[22].z = -V[2].x * m; + V[23].x = -V[3].x, V[23].y = V[3].y, V[23].z = -V[3].x * m; + V[24].x = -V[0].x, V[24].y = V[0].y, V[24].z = V[0].z; + V[25].x = -V[1].x, V[25].y = V[1].y, V[25].z = V[1].z; + V[26].x = -V[2].x, V[26].y = V[2].y, V[26].z = V[2].z; + V[27].x = -V[3].x, V[27].y = V[3].y, V[27].z = V[3].z; + //Ƭ + V[28].x = -V[0].x, V[28].y = V[0].y, V[28].z = V[0].x * m; + V[29].x = -V[1].x, V[29].y = V[1].y, V[29].z = V[1].x * m; + V[30].x = -V[2].x, V[30].y = V[2].y, V[30].z = V[2].x * m; + V[31].x = -V[3].x, V[31].y = V[3].y, V[31].z = V[3].x * m; + V[32].x = -V[0].x * m, V[32].y = V[0].y, V[32].z = V[0].x; + V[33].x = -V[1].x * m, V[33].y = V[1].y, V[33].z = V[1].x; + V[34].x = -V[2].x * m, V[34].y = V[2].y, V[34].z = V[2].x; + V[35].x = -V[3].x * m, V[35].y = V[3].y, V[35].z = V[3].x; + V[36].x = V[0].z, V[36].y = V[0].y, V[36].z = V[0].x; + V[37].x = V[1].z, V[37].y = V[1].y, V[37].z = V[1].x; + V[38].x = V[2].z, V[38].y = V[2].y, V[38].z = V[2].x; + V[39].x = V[3].z, V[39].y = V[3].y, V[39].z = V[3].x; + //ĿƬ + V[40].x = V[0].x * m, V[40].y = V[0].y, V[40].z = V[0].x; + V[41].x = V[1].x * m, V[41].y = V[1].y, V[41].z = V[1].x; + V[42].x = V[2].x * m, V[42].y = V[2].y, V[42].z = V[2].x; + V[43].x = V[3].x * m, V[43].y = V[3].y, V[43].z = V[3].x; + V[44].x = V[0].x, V[44].y = V[0].y, V[44].z = V[0].x * m; + V[45].x = V[1].x, V[45].y = V[1].y, V[45].z = V[1].x * m; + V[46].x = V[2].x, V[46].y = V[2].y, V[46].z = V[2].x * m; + V[47].x = V[3].x, V[47].y = V[3].y, V[47].z = V[3].x * m; +} + +void CRevolution::ReadPatch(void)//Ƭ +{ + //1Ƭ + S[0].pIndex[0][0] = 0; S[0].pIndex[0][1] = 1; S[0].pIndex[0][2] = 2; S[0].pIndex[0][3] = 3; + S[0].pIndex[1][0] = 4; S[0].pIndex[1][1] = 5; S[0].pIndex[1][2] = 6; S[0].pIndex[1][3] = 7; + S[0].pIndex[2][0] = 8; S[0].pIndex[2][1] = 9; S[0].pIndex[2][2] = 10; S[0].pIndex[2][3] = 11; + S[0].pIndex[3][0] = 12; S[0].pIndex[3][1] = 13; S[0].pIndex[3][2] = 14; S[0].pIndex[3][3] = 15; + //2Ƭ + S[1].pIndex[0][0] = 12; S[1].pIndex[0][1] = 13; S[1].pIndex[0][2] = 14; S[1].pIndex[0][3] = 15; + S[1].pIndex[1][0] = 16; S[1].pIndex[1][1] = 17; S[1].pIndex[1][2] = 18; S[1].pIndex[1][3] = 19; + S[1].pIndex[2][0] = 20; S[1].pIndex[2][1] = 21; S[1].pIndex[2][2] = 22; S[1].pIndex[2][3] = 23; + S[1].pIndex[3][0] = 24; S[1].pIndex[3][1] = 25; S[1].pIndex[3][2] = 26; S[1].pIndex[3][3] = 27; + //3Ƭ + S[2].pIndex[0][0] = 24; S[2].pIndex[0][1] = 25; S[2].pIndex[0][2] = 26; S[2].pIndex[0][3] = 27; + S[2].pIndex[1][0] = 28; S[2].pIndex[1][1] = 29; S[2].pIndex[1][2] = 30; S[2].pIndex[1][3] = 31; + S[2].pIndex[2][0] = 32; S[2].pIndex[2][1] = 33; S[2].pIndex[2][2] = 34; S[2].pIndex[2][3] = 35; + S[2].pIndex[3][0] = 36; S[2].pIndex[3][1] = 37; S[2].pIndex[3][2] = 38; S[2].pIndex[3][3] = 39; + //4Ƭ + S[3].pIndex[0][0] = 36; S[3].pIndex[0][1] = 37; S[3].pIndex[0][2] = 38; S[3].pIndex[0][3] = 39; + S[3].pIndex[1][0] = 40; S[3].pIndex[1][1] = 41; S[3].pIndex[1][2] = 42; S[3].pIndex[1][3] = 43; + S[3].pIndex[2][0] = 44; S[3].pIndex[2][1] = 45; S[3].pIndex[2][2] = 46; S[3].pIndex[2][3] = 47; + S[3].pIndex[3][0] = 0; S[3].pIndex[3][1] = 1; S[3].pIndex[3][2] = 2; S[3].pIndex[3][3] = 3; +} + +void CRevolution::DrawRevolutionSurface(CDC* pDC, CZBuffer* pZbuffer)//ƻת +{ + CP3 Point[4][4];//˫Ƭ16Ƶ + for(int nPatch = 0;nPatch < 4;nPatch++) + { + for(int i = 0;i < 4;i++) + for (int j = 0;j < 4;j++) + Point[i][j] = V[S[nPatch].pIndex[i][j]]; + int nRecursiveDepth = 5;//ݹ + patch.ReadControlPoint(Point, nRecursiveDepth); + patch.DrawCurvedPatch(pDC, pZbuffer); + } +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Revolution.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Revolution.h" new file mode 100644 index 0000000..ffe58ea --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Revolution.h" @@ -0,0 +1,22 @@ +#pragma once +#include "Patch.h" +#include "BezierPatch.h" + +class CRevolution //ת +{ +public: + CRevolution(void); + virtual ~CRevolution(void); + void ReadCubicBezierControlPoint(CP3 P[4]);//߶ʼ + CP3* GetVertexArrayName(void);//õ + void DrawRevolutionSurface(CDC* pDC, CZBuffer* pZbuffer);//ƻת +private: + void ReadVertex(void);//תƶζ + void ReadPatch(void);//ת˫Ƭ +private: + CP3 P[4];//ߵ4άƵ + CP3 V[48];//תܶ(4,48) + CPatch S[4];//ת飨һȦ4棩 +public: + CBezierPatch patch;//BezierƬ +}; \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/T2.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/T2.cpp" new file mode 100644 index 0000000..fdb53f5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/T2.cpp" @@ -0,0 +1,86 @@ +#include "pch.h" +#include "T2.h" + +CT2::CT2(void) +{ + u = 0.0; + v = 0.0; +} + +CT2::CT2(double u, double v) +{ + this->u = u; + this->v = v; +} + +CT2::~CT2(void) +{ + +} + +CT2 operator + (const CT2 &t0, const CT2 &t1)// +{ + CT2 result; + result.u = t0.u + t1.u; + result.v = t0.v + t1.v; + return result; +} + +CT2 operator - (const CT2 &t0, const CT2 &t1)// +{ + CT2 result; + result.u = t0.u - t1.u; + result.v = t0.v - t1.v; + return result; +} + +CT2 operator * (const CT2 &t, double scalar)//ͳĻ +{ + return CT2(t.u * scalar, t.v * scalar); +} + +CT2 operator * (double scalar, const CT2 &t)//͵Ļ +{ + return CT2(t.u * scalar, t.v * scalar); +} + +CT2 operator / (const CT2 &t,double scalar)// +{ + if(fabs(scalar) < 1e-4) + scalar = 1.0; + CT2 result; + result.u = t.u/scalar; + result.v = t.v/scalar; + return result; +} + +CT2 operator += (CT2 &t0, CT2 &t1) +{ + t0.u = t0.u + t1.u; + t0.v = t0.v + t1.v; + return t0; +} + +CT2 operator -= (CT2 &t0, CT2 &t1) +{ + t0.u = t0.u - t1.u; + t0.v = t0.v - t1.v; + return t0; +} + +CT2 operator *= (CT2 &t, double scalar) +{ + t.u = t.u * scalar; + t.v = t.v * scalar; + return t; +} + +CT2 operator /= (CT2 &t, double scalar) +{ + if(fabs(scalar) < 1e-4) + scalar = 1.0; + t.u = t.u/scalar; + t.v = t.v/scalar; + return t; +} + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/T2.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/T2.h" new file mode 100644 index 0000000..61762a9 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/T2.h" @@ -0,0 +1,23 @@ +#pragma once +#include"CRGB.h" + +class CT2 +{ +public: + CT2(void); + virtual ~CT2(void); + CT2(double u, double v); + friend CT2 operator + (const CT2 &t0, const CT2 &t1);// + friend CT2 operator - (const CT2 &t0, const CT2 &t1); + friend CT2 operator * (const CT2 &t, double scalar); + friend CT2 operator * (double scalar, const CT2 &t); + friend CT2 operator / (const CT2 &t,double scalar); + friend CT2 operator += (CT2 &t0, CT2 &t1); + friend CT2 operator -= (CT2 &t0, CT2 &t1); + friend CT2 operator *= (CT2 &t, double scalar); + friend CT2 operator /= (CT2 &t, double scalar); +public: + double u, v; + CRGB c; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Transform3.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Transform3.cpp" new file mode 100644 index 0000000..ad91729 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Transform3.cpp" @@ -0,0 +1,186 @@ +#include "pch.h" +#include "Transform3.h" +#define PI 3.1415926 + +CTransform3::CTransform3(void) +{ +} + +CTransform3::~CTransform3(void) +{ +} + +void CTransform3::Identity(void)//λʼ +{ + T[0][0] = 1.0, T[0][1] = 0.0, T[0][2] = 0.0, T[0][3] = 0.0; + T[1][0] = 0.0, T[1][1] = 1.0, T[1][2] = 0.0, T[1][3] = 0.0; + T[2][0] = 0.0, T[2][1] = 0.0, T[2][2] = 1.0, T[2][3] = 0.0; + T[3][0] = 0.0, T[3][1] = 0.0, T[3][2] = 0.0, T[3][3] = 1.0; +} + +void CTransform3::SetMatrix(CP3* P, int ptNumber)//ʼ +{ + this->P = P; + this->ptNumber = ptNumber; +} + +void CTransform3::Translate(double tx,double ty,double tz)//ƽƱ任 +{ + Identity(); + T[0][3] = tx, T[1][3] = ty, T[2][3] = tz; + MultiplyMatrix(); +} + +void CTransform3::Scale(double sx, double sy, double sz)//ű任 +{ + Identity(); + T[0][0] = sx, T[1][1] = sy, T[2][2] = sz; + MultiplyMatrix(); +} + +void CTransform3::Scale(double sx, double sy, double sz, CP3 p)//ű任 +{ + Translate(-p.x, -p.y, -p.z); + Scale(sx, sy, sz); + Translate(p.x, p.y, p.z); +} + +void CTransform3::Scale(double s)//ű任 +{ + Identity(); + T[0][0] = s, T[1][1] = s, T[2][2] = s; + MultiplyMatrix(); +} + +void CTransform3::Scale(double s, CP3 p)//ű任 +{ + Translate(-p.x, -p.y, -p.z); + Scale(s); + Translate(p.x, p.y, p.z); +} + +void CTransform3::RotateX(double beta)//Xת任 +{ + Identity(); + beta = beta * PI / 180; + T[1][1] = cos(beta), T[1][2] = -sin(beta); + T[2][1] = sin(beta), T[2][2] = cos(beta); + MultiplyMatrix(); +} + +void CTransform3::RotateY(double beta)//Yת任 +{ + Identity(); + beta = beta * PI/180; + T[0][0] = cos(beta), T[0][2] = sin(beta); + T[2][0] =-sin(beta), T[2][2] = cos(beta); + MultiplyMatrix(); +} + +void CTransform3::RotateZ(double beta)//Zת任 +{ + Identity(); + beta = beta * PI/180; + T[0][0] = cos(beta), T[0][1] = -sin(beta); + T[1][0] = sin(beta), T[1][1] = cos(beta); + MultiplyMatrix(); +} + +void CTransform3::RotateX(double beta, CP3 p)//Xת任 +{ + Translate(-p.x, -p.y, -p.z); + RotateX(beta); + Translate(p.x, p.y, p.z); +} + +void CTransform3::RotateY(double beta, CP3 p)//Yת任 +{ + Translate(-p.x, -p.y, -p.z); + RotateY(beta); + Translate(p.x, p.y, p.z); +} + +void CTransform3::RotateZ(double beta, CP3 p)//Zת任 +{ + Translate(-p.x, -p.y, -p.z); + RotateZ(beta); + Translate(p.x, p.y, p.z); +} + +void CTransform3::ReflectX(void)//Xᷴ任 +{ + Identity(); + T[1][1] = -1, T[2][2] = -1; + MultiplyMatrix(); +} + +void CTransform3::ReflectY(void)//Yᷴ任 +{ + Identity(); + T[0][0] = -1, T[2][2] = -1; + MultiplyMatrix(); +} + +void CTransform3::ReflectZ(void)//Zᷴ任 +{ + Identity(); + T[0][0] = -1, T[1][1] = -1; + MultiplyMatrix(); +} + +void CTransform3::ReflectXOY(void)//XOY淴任 +{ + Identity(); + T[2][2] = -1; + MultiplyMatrix(); +} + +void CTransform3::ReflectYOZ(void)//YOZ淴任 +{ + Identity(); + T[0][0] = -1; + MultiplyMatrix(); +} + +void CTransform3::ReflectZOX(void)//XOZ淴任 +{ + Identity(); + T[1][1] = -1; + MultiplyMatrix(); +} + +void CTransform3::ShearX(double b, double c)//Xб任 +{ + Identity(); + T[0][1] = b, T[0][2] = c; + MultiplyMatrix(); +} + +void CTransform3::ShearY(double d, double f)//Yб任 +{ + Identity(); + T[1][0] = d, T[1][2] = f; + MultiplyMatrix(); +} + +void CTransform3::ShearZ(double g, double h)//Zб任 +{ + Identity(); + T[2][0] = g;T[2][1] = h; + MultiplyMatrix(); +} + +void CTransform3::MultiplyMatrix(void)// +{ + CP3* PTemp = new CP3[ptNumber]; + for(int i = 0;i < ptNumber;i++) + PTemp[i] = P[i]; + for(int i = 0;i < ptNumber;i++) + { + P[i].x = T[0][0] * PTemp[i].x + T[0][1] * PTemp[i].y + T[0][2] * PTemp[i].z + T[0][3] * PTemp[i].w; + P[i].y = T[1][0] * PTemp[i].x + T[1][1] * PTemp[i].y + T[1][2] * PTemp[i].z + T[1][3] * PTemp[i].w; + P[i].z = T[2][0] * PTemp[i].x + T[2][1] * PTemp[i].y + T[2][2] * PTemp[i].z + T[2][3] * PTemp[i].w; + P[i].w = T[3][0] * PTemp[i].x + T[3][1] * PTemp[i].y + T[3][2] * PTemp[i].z + T[3][3] * PTemp[i].w; + } + delete []PTemp; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Transform3.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Transform3.h" new file mode 100644 index 0000000..2ede144 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Transform3.h" @@ -0,0 +1,39 @@ +#pragma once +#include"P3.h" + +class CTransform3 +{ +public: + CTransform3(void); + virtual ~CTransform3(void); + void Identity(void);//λʼ + void SetMatrix(CP3* P, int ptNumber);//άʼ + void Translate(double tx, double ty, double tz);//ƽƱ任 + void Scale(double sx,double sy, double sz);//ű任 + void Scale(double sx,double sy, double sz,CP3 p);//ű任 + void Scale(double s);//ű任 + void Scale(double s, CP3 p);//ű任 + void RotateX(double beta);//Xת任 + void RotateY(double beta);//Yת任 + void RotateZ(double beta);//Zת任 + void RotateX(double beta, CP3 p);//Xת任 + void RotateY(double beta, CP3 p);//Yת任 + void RotateZ(double beta, CP3 p);//Zת任 + void ReflectX(void);//Xᷴ任 + void ReflectY(void);//Yᷴ任 + void ReflectZ(void);//Zᷴ任 + void ReflectXOY(void);//XOY淴任 + void ReflectYOZ(void);//YOZ淴任 + void ReflectZOX(void);//ZOX淴任 + void ShearX(double b, double c);//Xб任 + void ShearY(double d, double f);//Yб任 + void ShearZ(double g, double h);//Zб任 + void MultiplyMatrix(void);// +private: + double T[4][4];//ά任 + CP3* P;//ά + int ptNumber;//ά +}; + + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Vector3.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Vector3.cpp" new file mode 100644 index 0000000..3ba5f4a --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Vector3.cpp" @@ -0,0 +1,111 @@ +#include "pch.h" +#include "Vector3.h" + +CVector3::CVector3(void) +{ + x = 0.0,y = 0.0, z = 1.0;//ָz +} + + +CVector3::~CVector3(void) +{ +} + +CVector3::CVector3(double x, double y, double z)// +{ + this->x = x; + this->y = y; + this->z = z; +} + +CVector3::CVector3(const CP3 &p) +{ + x = p.x; + y = p.y; + z = p.z; +} + +CVector3::CVector3(const CP3 &p0, const CP3 &p1)// +{ + x = p1.x - p0.x; + y = p1.y - p0.y; + z = p1.z - p0.z; +} + +double CVector3::Magnitude(void)//ģ +{ + return sqrt(x * x + y * y + z * z); +} + +CVector3 CVector3::Normalize(void)//һΪλ +{ + CVector3 vector; + double magnitude = sqrt(x * x + y * y + z * z); + if(fabs(magnitude) < 1e-4) + magnitude = 1.0; + vector.x = x / magnitude; + vector.y = y / magnitude; + vector.z = z / magnitude; + return vector; +} + +CVector3 operator + (const CVector3 &v0, const CVector3 &v1)//ĺ +{ + CVector3 vector; + vector.x = v0.x + v1.x; + vector.y = v0.y + v1.y; + vector.z = v0.z + v1.z; + return vector; +} + +CVector3 operator - (const CVector3 &v0, const CVector3 &v1)//IJ +{ + CVector3 vector; + vector.x = v0.x - v1.x; + vector.y = v0.y - v1.y; + vector.z = v0.z - v1.z; + return vector; +} + +CVector3 operator * (const CVector3 &v, double scalar)//볣Ļ +{ + CVector3 vector; + vector.x = v.x * scalar; + vector.y = v.y * scalar; + vector.z = v.z * scalar; + return vector; +} + +CVector3 operator * (double scalar, const CVector3 &v)//Ļ +{ + CVector3 vector; + vector.x = v.x * scalar; + vector.y = v.y * scalar; + vector.z = v.z * scalar; + return vector; +} + +CVector3 operator / (const CVector3 &v, double scalar)// +{ + if(fabs(scalar) < 1e-4) + scalar = 1.0; + CVector3 vector; + vector.x = v.x / scalar; + vector.y = v.y / scalar; + vector.z = v.z / scalar; + return vector; +} + +double DotProduct(const CVector3 &v0, const CVector3 &v1)//ĵ +{ + return(v0.x * v1.x + v0.y * v1.y + v0.z * v1.z); +} + +CVector3 CrossProduct(const CVector3 &v0, const CVector3 &v1)//IJ +{ + CVector3 vector; + vector.x = v0.y * v1.z - v0.z * v1.y; + vector.y = v0.z * v1.x - v0.x * v1.z; + vector.z = v0.x * v1.y - v0.y * v1.x; + return vector; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Vector3.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Vector3.h" new file mode 100644 index 0000000..8d4ad83 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/Vector3.h" @@ -0,0 +1,24 @@ +#pragma once +#include "P3.h" + +class CVector3 +{ +public: + CVector3(void); + virtual ~CVector3(void); + CVector3(double x, double y, double z);// + CVector3(const CP3 &p); + CVector3(const CP3 &p0, const CP3 &p1);// + double Magnitude(void);//ģ + CVector3 Normalize(void);//һ + friend CVector3 operator + (const CVector3 &v0, const CVector3 &v1);// + friend CVector3 operator - (const CVector3 &v0, const CVector3 &v1); + friend CVector3 operator * (const CVector3 &v, double scalar); + friend CVector3 operator * (double scalar, const CVector3 &v); + friend CVector3 operator / (const CVector3 &v, double scalar); + friend double DotProduct(const CVector3 &v0, const CVector3 &v1);//ĵ + friend CVector3 CrossProduct(const CVector3 &v0, const CVector3 &v1);//IJ +public: + double x,y,z; +}; + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ViewTree.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ViewTree.cpp" new file mode 100644 index 0000000..84996cb --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ViewTree.cpp" @@ -0,0 +1,43 @@ + +#include "pch.h" +#include "framework.h" +#include "ViewTree.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CViewTree + +CViewTree::CViewTree() noexcept +{ +} + +CViewTree::~CViewTree() +{ +} + +BEGIN_MESSAGE_MAP(CViewTree, CTreeCtrl) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 消息处理程序 + +BOOL CViewTree::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult); + + NMHDR* pNMHDR = (NMHDR*)lParam; + ASSERT(pNMHDR != nullptr); + +#pragma warning(suppress : 26454) + if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips() != nullptr) + { + GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); + } + + return bRes; +} diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ViewTree.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ViewTree.h" new file mode 100644 index 0000000..0267d80 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ViewTree.h" @@ -0,0 +1,23 @@ + +#pragma once + +///////////////////////////////////////////////////////////////////////////// +// CViewTree 窗口 + +class CViewTree : public CTreeCtrl +{ +// 构造 +public: + CViewTree() noexcept; + +// 重写 +protected: + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + +// 实现 +public: + virtual ~CViewTree(); + +protected: + DECLARE_MESSAGE_MAP() +}; diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ZBuffer.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ZBuffer.cpp" new file mode 100644 index 0000000..1c1f148 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ZBuffer.cpp" @@ -0,0 +1,150 @@ +#include "pch.h" +#include "ZBuffer.h" +#define ROUND(d) int(d + 0.5) +CZBuffer::CZBuffer(void) +{ + zBuffer = NULL; +} +CZBuffer::~CZBuffer(void) +{ + for (int i = 0; i < nWidth; i++) + { + delete[] zBuffer[i]; + zBuffer[i] = NULL; + } + if (zBuffer != NULL) + { + delete zBuffer; + zBuffer = NULL; + } +} +void CZBuffer::SetPoint(CP3 P0, CP3 P1, CP3 P2, CVector3 N0, CVector3 N1, CVector3 N2) +{ + this->P0 = P0, this->P1 = P1, this->P2 = P2; + point0.x = ROUND(P0.x); + point0.y = ROUND(P0.y); + point0.z = P0.z; + point0.c = P0.c; + point0.n = N0; + point1.x = ROUND(P1.x); + point1.y = ROUND(P1.y); + point1.z = P1.z; + point1.c = P1.c; + point1.n = N1; + point2.x = ROUND(P2.x); + point2.y = ROUND(P2.y); + point2.z = P2.z; + point2.c = P2.c; + point2.n = N2; +} +void CZBuffer::PhongShader(CDC* pDC, CP3 ViewPoint, CLighting* pLight, CMaterial* + pMaterial) +{ + double CurrentDepth = 0.0; + CVector3 Vector01(P0, P1), Vector02(P0, P2); + CVector3 fNormal = CrossProduct(Vector01, Vector02); + double A = fNormal.x, B = fNormal.y, C = fNormal.z; + double D = -A * P0.x - B * P0.y - C * P0.z; + if (fabs(C) < 1e-4) + C = 1.0; + double DepthStep = -A / C; + SortVertex(); + int nTotalLine = point1.y - point0.y + 1; + SpanLeft = new CPoint2[nTotalLine]; + SpanRight = new CPoint2[nTotalLine]; + int nDeltz = (point1.x - point0.x) * (point2.y - point0.y) - (point1.y - point0.y) * (point2.x - point0.x); + if (nDeltz > 0) + { + nIndex = 0; + EdgeFlag(point0, point2, TRUE); + EdgeFlag(point2, point1, TRUE); + nIndex = 0; + EdgeFlag(point0, point1, FALSE); + } + else + { + nIndex = 0; + EdgeFlag(point0, point1, TRUE); + nIndex = 0; + EdgeFlag(point0, point2, FALSE); + EdgeFlag(point2, point1, FALSE); + } + for (int y = point0.y; y < point1.y; y++) + { + int n = y - point0.y; + for (int x = SpanLeft[n].x; x < SpanRight[n].x; x++) + { + CurrentDepth = -(A * x + B * y + D) / C; + CVector3 ptNormal = LinearInterp(x, SpanLeft[n].x, SpanRight[n].x, SpanLeft[n].n, SpanRight[n].n); + ptNormal = ptNormal.Normalize(); + CRGB Intensity = pLight->Illuminate(ViewPoint, CP3(x, y, CurrentDepth), ptNormal, pMaterial); + if (CurrentDepth <= zBuffer[x + nWidth / 2][y + nHeight / 2]) + { + zBuffer[x + nWidth / 2][y + nHeight / 2] = CurrentDepth; + pDC->SetPixelV(x, y, RGB(Intensity.red * 255, Intensity.green * 255, Intensity.blue * 255)); + } + CurrentDepth += DepthStep; + } + } + if (SpanLeft) + { + delete[]SpanLeft; + SpanLeft = NULL; + } + if (SpanRight) + { + delete[]SpanRight; + SpanRight = NULL; + } +} +void CZBuffer::EdgeFlag(CPoint2 PStart, CPoint2 PEnd, BOOL bFeature) +{ + int dx = PEnd.x - PStart.x; + int dy = PEnd.y - PStart.y; + double m = double(dx) / dy; + double x = PStart.x; + for (int y = PStart.y; y < PEnd.y; y++) + { + CVector3 ptNormal = LinearInterp(y, PStart.y, PEnd.y, PStart.n, PEnd.n); + if (bFeature) + SpanLeft[nIndex++] = CPoint2(ROUND(x), y, ptNormal); + else + SpanRight[nIndex++] = CPoint2(ROUND(x), y, ptNormal); + x += m; + } +} +void CZBuffer::SortVertex(void) +{ + CPoint3 pt[3]; + pt[0] = point0; + pt[1] = point1; + pt[2] = point2; + for (int i = 0; i < 2; i++) + { + int min = i; + for (int j = i + 1; j < 3; j++) + if (pt[j].y < pt[min].y) + min = j; + CPoint3 pTemp = pt[i]; + pt[i] = pt[min]; + pt[min] = pTemp; + } + point0 = pt[0]; + point1 = pt[2]; + point2 = pt[1]; +} +CVector3 CZBuffer::LinearInterp(double t, double tStart, double tEnd, CVector3 vStart, CVector3 vEnd) +{ + CVector3 vector; + vector = (tEnd - t) / (tEnd - tStart) * vStart + (t - tStart) / (tEnd - tStart) * vEnd; + return vector; +} +void CZBuffer::InitialDepthBuffer(int nWidth, int nHeight, double zDepth){ + this->nWidth = nWidth, this->nHeight = nHeight; + zBuffer = new double* [nWidth]; + for (int i = 0; i < nWidth; i++) + zBuffer[i] = new double[nHeight]; + for (int i = 0; i < nWidth; i++) + for (int j = 0; j < nHeight; j++) + zBuffer[i][j] = zDepth; +} \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ZBuffer.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ZBuffer.h" new file mode 100644 index 0000000..328c18f --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/ZBuffer.h" @@ -0,0 +1,24 @@ +#pragma once +#include "Point3.h" +#include "CLighting.h" +class CZBuffer +{ +public: + CZBuffer(void); + virtual ~CZBuffer(void); + void InitialDepthBuffer(int nWidth, int nHeight, double zDepth); + void SetPoint(CP3 P0, CP3 P1, CP3 P2, CVector3 N0, CVector3 N1, CVector3 N2); + void PhongShader(CDC* pDC, CP3 ViewPoint, CLighting* pLight, CMaterial* pMaterial); +private: + void SortVertex(void); + void EdgeFlag(CPoint2 PStart, CPoint2 PEnd, BOOL bFeature); + CVector3 LinearInterp(double t, double coorStart, double coorEnd, CVector3 normalStart, CVector3 normalEnd); +protected: + CP3 P0, P1, P2; + CPoint3 point0, point1, point2; + CPoint2* SpanLeft; + CPoint2* SpanRight; + int nIndex; + double** zBuffer; + int nWidth, nHeight; +}; \ No newline at end of file diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/framework.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/framework.h" new file mode 100644 index 0000000..5672fb5 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/framework.h" @@ -0,0 +1,49 @@ +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 + +// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 +#define _AFX_ALL_WARNINGS + +#include // MFC 核心组件和标准组件 +#include // MFC 扩展 + + +#include // MFC 自动化类 + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC 对 Internet Explorer 4 公共控件的支持 +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC 对 Windows 公共控件的支持 +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC 支持功能区和控制条 + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/pch.cpp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/pch.cpp" new file mode 100644 index 0000000..b6fb8f4 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/pch.cpp" @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/pch.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/pch.h" new file mode 100644 index 0000000..9660927 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/pch.h" @@ -0,0 +1,13 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include "framework.h" + +#endif //PCH_H diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/CZBuffer.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/CZBuffer.ico" new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/CZBuffer.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/CZBuffer.rc2" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/CZBuffer.rc2" new file mode 100644 index 0000000..cbc8a74 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/CZBuffer.rc2" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/CZBufferDoc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/CZBufferDoc.ico" new file mode 100644 index 0000000..96365d4 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/CZBufferDoc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/Toolbar.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/Toolbar.bmp" new file mode 100644 index 0000000..d501723 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/Toolbar.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/Toolbar256.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/Toolbar256.bmp" new file mode 100644 index 0000000..91a2553 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/Toolbar256.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/class_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/class_view.ico" new file mode 100644 index 0000000..bf6b0dd Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/class_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/class_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/class_view_hc.ico" new file mode 100644 index 0000000..3112bf2 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/class_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/classview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/classview.bmp" new file mode 100644 index 0000000..1e02aa1 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/classview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/classview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/classview_hc.bmp" new file mode 100644 index 0000000..6b22e78 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/classview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/explorer.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/explorer.bmp" new file mode 100644 index 0000000..01298ba Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/explorer.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/explorer_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/explorer_hc.bmp" new file mode 100644 index 0000000..697199d Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/explorer_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/file_view.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/file_view.ico" new file mode 100644 index 0000000..0f93f52 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/file_view.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/file_view_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/file_view_hc.ico" new file mode 100644 index 0000000..42ec435 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/file_view_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/fileview.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/fileview.bmp" new file mode 100644 index 0000000..a2d62d0 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/fileview.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/fileview_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/fileview_hc.bmp" new file mode 100644 index 0000000..b60f483 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/fileview_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/menuimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/menuimages.bmp" new file mode 100644 index 0000000..7771841 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/menuimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/menuimages_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/menuimages_hc.bmp" new file mode 100644 index 0000000..577926e Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/menuimages_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/output_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/output_wnd.ico" new file mode 100644 index 0000000..d14f991 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/output_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/output_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/output_wnd_hc.ico" new file mode 100644 index 0000000..fdd27e8 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/output_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/properties.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/properties.bmp" new file mode 100644 index 0000000..72e2b29 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/properties.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/properties_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/properties_hc.bmp" new file mode 100644 index 0000000..d18a7ca Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/properties_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/properties_wnd.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/properties_wnd.ico" new file mode 100644 index 0000000..3611766 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/properties_wnd.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/properties_wnd_hc.ico" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/properties_wnd_hc.ico" new file mode 100644 index 0000000..1e06b64 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/properties_wnd_hc.ico" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/sort.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/sort.bmp" new file mode 100644 index 0000000..0307301 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/sort.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/sort_hc.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/sort_hc.bmp" new file mode 100644 index 0000000..720e742 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/sort_hc.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/userimages.bmp" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/userimages.bmp" new file mode 100644 index 0000000..affe657 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/res/userimages.bmp" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/resource.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/resource.h" new file mode 100644 index 0000000..5ba799b --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/resource.h" @@ -0,0 +1,98 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ 生成的包含文件。 +// 供 CZBuffer.rc 使用 +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_POPUP_EDIT 119 +#define ID_STATUSBAR_PANE1 120 +#define ID_STATUSBAR_PANE2 121 +#define IDS_STATUS_PANE1 122 +#define IDS_STATUS_PANE2 123 +#define IDS_TOOLBAR_STANDARD 124 +#define IDS_TOOLBAR_CUSTOMIZE 125 +#define ID_VIEW_CUSTOMIZE 126 +#define IDR_MAINFRAME 128 +#define IDR_MAINFRAME_256 129 +#define IDR_CZBufferTYPE 130 +#define ID_WINDOW_MANAGER 131 +#define ID_VIEW_FILEVIEW 133 +#define ID_VIEW_CLASSVIEW 134 +#define ID_PROPERTIES 135 +#define ID_OPEN 136 +#define ID_OPEN_WITH 137 +#define ID_DUMMY_COMPILE 138 +#define ID_CLASS_ADD_MEMBER_FUNCTION 139 +#define ID_CLASS_ADD_MEMBER_VARIABLE 140 +#define ID_CLASS_DEFINITION 141 +#define ID_CLASS_PROPERTIES 142 +#define ID_NEW_FOLDER 143 +#define ID_SORT_MENU 144 +#define ID_SORTING_GROUPBYTYPE 145 +#define ID_SORTING_SORTALPHABETIC 146 +#define ID_SORTING_SORTBYTYPE 147 +#define ID_SORTING_SORTBYACCESS 148 +#define ID_VIEW_OUTPUTWND 149 +#define ID_VIEW_PROPERTIESWND 150 +#define ID_SORTPROPERTIES 151 +#define ID_PROPERTIES1 152 +#define ID_PROPERTIES2 153 +#define ID_EXPAND_ALL 154 +#define IDS_FILE_VIEW 155 +#define IDS_CLASS_VIEW 156 +#define IDS_OUTPUT_WND 157 +#define IDS_PROPERTIES_WND 158 +#define IDI_FILE_VIEW 161 +#define IDI_FILE_VIEW_HC 162 +#define IDI_CLASS_VIEW 163 +#define IDI_CLASS_VIEW_HC 164 +#define IDI_OUTPUT_WND 165 +#define IDI_OUTPUT_WND_HC 166 +#define IDI_PROPERTIES_WND 167 +#define IDI_PROPERTIES_WND_HC 168 +#define IDR_EXPLORER 169 +#define IDB_EXPLORER_24 170 +#define IDR_SORT 171 +#define IDB_SORT_24 172 +#define IDR_POPUP_SORT 173 +#define IDR_POPUP_EXPLORER 174 +#define IDB_FILE_VIEW 175 +#define IDB_FILE_VIEW_24 176 +#define IDB_CLASS_VIEW 177 +#define IDB_CLASS_VIEW_24 178 +#define IDR_MENU_IMAGES 179 +#define IDB_MENU_IMAGES_24 180 +#define ID_TOOLS_MACRO 181 +#define IDR_OUTPUT_POPUP 182 +#define IDR_PROPERTIES 183 +#define IDB_PROPERTIES_HC 184 +#define IDR_THEME_MENU 200 +#define ID_SET_STYLE 201 +#define ID_VIEW_APPLOOK_WIN_2000 205 +#define ID_VIEW_APPLOOK_OFF_XP 206 +#define ID_VIEW_APPLOOK_WIN_XP 207 +#define ID_VIEW_APPLOOK_OFF_2003 208 +#define ID_VIEW_APPLOOK_VS_2005 209 +#define ID_VIEW_APPLOOK_VS_2008 210 +#define ID_VIEW_APPLOOK_OFF_2007_BLUE 215 +#define ID_VIEW_APPLOOK_OFF_2007_BLACK 216 +#define ID_VIEW_APPLOOK_OFF_2007_SILVER 217 +#define ID_VIEW_APPLOOK_OFF_2007_AQUA 218 +#define ID_VIEW_APPLOOK_WINDOWS_7 219 +#define IDS_BUILD_TAB 300 +#define IDS_DEBUG_TAB 301 +#define IDS_FIND_TAB 302 +#define IDS_EXPLORER 305 +#define IDS_EDIT_MENU 306 +#define ID_GRAPHIC_ANIMATION 32771 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 310 +#define _APS_NEXT_COMMAND_VALUE 32772 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 310 +#endif +#endif diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/targetver.h" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/targetver.h" new file mode 100644 index 0000000..79934a3 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/CZBuffer/targetver.h" @@ -0,0 +1,8 @@ +#pragma once + +// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 + +//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 +// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 + +#include diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246-\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\344\272\224.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246-\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\344\272\224.pdf" new file mode 100644 index 0000000..daa77ce Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/ex5/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246-\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246-\345\256\236\351\252\214\344\272\224.pdf" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/\345\244\215\344\271\240\345\244\247\347\272\262.jpg" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/\345\244\215\344\271\240\345\244\247\347\272\262.jpg" new file mode 100644 index 0000000..2a22070 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/\345\244\215\344\271\240\345\244\247\347\272\262.jpg" differ diff --git "a/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246\345\244\247\347\272\262.pdf" "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246\345\244\247\347\272\262.pdf" new file mode 100644 index 0000000..5c64241 Binary files /dev/null and "b/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246/\350\256\241\347\256\227\346\234\272\345\233\276\345\275\242\345\255\246\345\244\247\347\272\262.pdf" differ diff --git "a/\350\256\241\347\273\204+\345\256\236\351\252\214/HQFC-B1\345\255\246\347\224\237\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246.pdf" "b/\350\256\241\347\273\204+\345\256\236\351\252\214/HQFC-B1\345\255\246\347\224\237\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246.pdf" new file mode 100644 index 0000000..46b79f2 Binary files /dev/null and "b/\350\256\241\347\273\204+\345\256\236\351\252\214/HQFC-B1\345\255\246\347\224\237\345\256\236\351\252\214\346\214\207\345\257\274\344\271\246.pdf" differ diff --git "a/\350\256\241\347\273\204+\345\256\236\351\252\214/HQFC-B1\350\257\276\347\250\213\350\256\276\350\256\241-\344\277\256.ppt" "b/\350\256\241\347\273\204+\345\256\236\351\252\214/HQFC-B1\350\257\276\347\250\213\350\256\276\350\256\241-\344\277\256.ppt" new file mode 100644 index 0000000..74fbaff Binary files /dev/null and "b/\350\256\241\347\273\204+\345\256\236\351\252\214/HQFC-B1\350\257\276\347\250\213\350\256\276\350\256\241-\344\277\256.ppt" differ diff --git "a/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/adder.v" "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/adder.v" new file mode 100644 index 0000000..32f02d3 --- /dev/null +++ "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/adder.v" @@ -0,0 +1,6 @@ +module adder (A, B, Cin, Sum, Cout); +input A, B, Cin; +output Sum, Cout; +assign Sum = A ^ B ^ Cin; +assign Cout = (A & B) | (B & Cin) | (Cin & A); +endmodule diff --git "a/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/adder.vwf" "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/adder.vwf" new file mode 100644 index 0000000..0c71c74 --- /dev/null +++ "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/adder.vwf" @@ -0,0 +1,208 @@ +/* +WARNING: Do NOT edit the input and output ports in this file in a text +editor if you plan to continue editing the block that represents it in +the Block Editor! File corruption is VERY likely to occur. +*/ + +/* +Copyright (C) 1991-2013 Altera Corporation +Your use of Altera Corporation's design tools, logic functions +and other software and tools, and its AMPP partner logic +functions, and any output files from any of the foregoing +(including device programming or simulation files), and any +associated documentation or information are expressly subject +to the terms and conditions of the Altera Program License +Subscription Agreement, Altera MegaCore Function License +Agreement, or other applicable license agreement, including, +without limitation, that your use is for the sole purpose of +programming logic devices manufactured by Altera and sold by +Altera or its authorized distributors. Please refer to the +applicable agreement for further details. +*/ + +HEADER +{ + VERSION = 1; + TIME_UNIT = ns; + DATA_OFFSET = 0.0; + DATA_DURATION = 1000.0; + SIMULATION_TIME = 0.0; + GRID_PHASE = 0.0; + GRID_PERIOD = 10.0; + GRID_DUTY_CYCLE = 50; +} + +SIGNAL("A") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = INPUT; + PARENT = ""; +} + +SIGNAL("B") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = INPUT; + PARENT = ""; +} + +SIGNAL("Cin") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = INPUT; + PARENT = ""; +} + +SIGNAL("Cout") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = OUTPUT; + PARENT = ""; +} + +SIGNAL("Sum") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = OUTPUT; + PARENT = ""; +} + +TRANSITION_LIST("A") +{ + NODE + { + REPEAT = 1; + LEVEL 0 FOR 40.0; + LEVEL 1 FOR 40.0; + LEVEL 0 FOR 70.0; + LEVEL 1 FOR 10.0; + LEVEL 0 FOR 20.0; + LEVEL 1 FOR 20.0; + LEVEL 0 FOR 800.0; + } +} + +TRANSITION_LIST("B") +{ + NODE + { + REPEAT = 1; + LEVEL 0 FOR 20.0; + LEVEL 1 FOR 20.0; + LEVEL 0 FOR 20.0; + LEVEL 1 FOR 20.0; + LEVEL 0 FOR 50.0; + LEVEL 1 FOR 10.0; + LEVEL 0 FOR 40.0; + LEVEL 1 FOR 20.0; + LEVEL 0 FOR 800.0; + } +} + +TRANSITION_LIST("Cin") +{ + NODE + { + REPEAT = 1; + LEVEL 0 FOR 10.0; + LEVEL 1 FOR 10.0; + LEVEL 0 FOR 10.0; + LEVEL 1 FOR 10.0; + LEVEL 0 FOR 10.0; + LEVEL 1 FOR 10.0; + LEVEL 0 FOR 10.0; + LEVEL 1 FOR 10.0; + LEVEL 0 FOR 50.0; + LEVEL 1 FOR 10.0; + LEVEL 0 FOR 10.0; + LEVEL 1 FOR 10.0; + LEVEL 0 FOR 20.0; + LEVEL 1 FOR 20.0; + LEVEL 0 FOR 800.0; + } +} + +TRANSITION_LIST("Cout") +{ + NODE + { + REPEAT = 1; + LEVEL X FOR 1000.0; + } +} + +TRANSITION_LIST("Sum") +{ + NODE + { + REPEAT = 1; + LEVEL X FOR 1000.0; + } +} + +DISPLAY_LINE +{ + CHANNEL = "A"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 0; + TREE_LEVEL = 0; +} + +DISPLAY_LINE +{ + CHANNEL = "B"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 1; + TREE_LEVEL = 0; +} + +DISPLAY_LINE +{ + CHANNEL = "Cin"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 2; + TREE_LEVEL = 0; +} + +DISPLAY_LINE +{ + CHANNEL = "Cout"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 3; + TREE_LEVEL = 0; +} + +DISPLAY_LINE +{ + CHANNEL = "Sum"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 4; + TREE_LEVEL = 0; +} + +TIME_BAR +{ + TIME = 0; + MASTER = TRUE; +} +; diff --git "a/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/counter.v" "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/counter.v" new file mode 100644 index 0000000..6ceb043 --- /dev/null +++ "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/counter.v" @@ -0,0 +1,23 @@ +module ex5 +( +clk, +rst, q, +overflow +); + +input clk; +input rst; +output reg [3:0]q; +output overflow; +always@(posedge clk or negedge rst) +begin + if(~rst)q<=4'h0; + else + begin + if(4'h9==q)q<=4'h0; + else q<=q+4'h1; + end + end +assign overflow = 4'h9 == q; +endmodule + diff --git "a/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/counter.vwf" "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/counter.vwf" new file mode 100644 index 0000000..fa9496a --- /dev/null +++ "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/counter.vwf" @@ -0,0 +1,269 @@ +/* +WARNING: Do NOT edit the input and output ports in this file in a text +editor if you plan to continue editing the block that represents it in +the Block Editor! File corruption is VERY likely to occur. +*/ + +/* +Copyright (C) 1991-2013 Altera Corporation +Your use of Altera Corporation's design tools, logic functions +and other software and tools, and its AMPP partner logic +functions, and any output files from any of the foregoing +(including device programming or simulation files), and any +associated documentation or information are expressly subject +to the terms and conditions of the Altera Program License +Subscription Agreement, Altera MegaCore Function License +Agreement, or other applicable license agreement, including, +without limitation, that your use is for the sole purpose of +programming logic devices manufactured by Altera and sold by +Altera or its authorized distributors. Please refer to the +applicable agreement for further details. +*/ + +HEADER +{ + VERSION = 1; + TIME_UNIT = ns; + DATA_OFFSET = 0.0; + DATA_DURATION = 1000.0; + SIMULATION_TIME = 0.0; + GRID_PHASE = 0.0; + GRID_PERIOD = 10.0; + GRID_DUTY_CYCLE = 50; +} + +SIGNAL("overflow") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = OUTPUT; + PARENT = ""; +} + +SIGNAL("q") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = BUS; + WIDTH = 4; + LSB_INDEX = 0; + DIRECTION = OUTPUT; + PARENT = ""; +} + +SIGNAL("q[3]") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = OUTPUT; + PARENT = "q"; +} + +SIGNAL("q[2]") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = OUTPUT; + PARENT = "q"; +} + +SIGNAL("q[1]") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = OUTPUT; + PARENT = "q"; +} + +SIGNAL("q[0]") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = OUTPUT; + PARENT = "q"; +} + +SIGNAL("clk") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = INPUT; + PARENT = ""; +} + +SIGNAL("rst") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = INPUT; + PARENT = ""; +} + +TRANSITION_LIST("overflow") +{ + NODE + { + REPEAT = 1; + LEVEL X FOR 1000.0; + } +} + +TRANSITION_LIST("q[3]") +{ + NODE + { + REPEAT = 1; + LEVEL X FOR 1000.0; + } +} + +TRANSITION_LIST("q[2]") +{ + NODE + { + REPEAT = 1; + LEVEL X FOR 1000.0; + } +} + +TRANSITION_LIST("q[1]") +{ + NODE + { + REPEAT = 1; + LEVEL X FOR 1000.0; + } +} + +TRANSITION_LIST("q[0]") +{ + NODE + { + REPEAT = 1; + LEVEL X FOR 1000.0; + } +} + +TRANSITION_LIST("clk") +{ + NODE + { + REPEAT = 1; + NODE + { + REPEAT = 100; + LEVEL 0 FOR 5.0; + LEVEL 1 FOR 5.0; + } + } +} + +TRANSITION_LIST("rst") +{ + NODE + { + REPEAT = 1; + LEVEL 0 FOR 20.0; + LEVEL 1 FOR 300.0; + LEVEL 0 FOR 20.0; + LEVEL 1 FOR 660.0; + } +} + +DISPLAY_LINE +{ + CHANNEL = "clk"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 0; + TREE_LEVEL = 0; +} + +DISPLAY_LINE +{ + CHANNEL = "rst"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 1; + TREE_LEVEL = 0; + GRAY_CODE = ON; +} + +DISPLAY_LINE +{ + CHANNEL = "q"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 2; + TREE_LEVEL = 0; + CHILDREN = 3, 4, 5, 6; +} + +DISPLAY_LINE +{ + CHANNEL = "q[3]"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 3; + TREE_LEVEL = 1; + PARENT = 2; +} + +DISPLAY_LINE +{ + CHANNEL = "q[2]"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 4; + TREE_LEVEL = 1; + PARENT = 2; +} + +DISPLAY_LINE +{ + CHANNEL = "q[1]"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 5; + TREE_LEVEL = 1; + PARENT = 2; +} + +DISPLAY_LINE +{ + CHANNEL = "q[0]"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 6; + TREE_LEVEL = 1; + PARENT = 2; +} + +DISPLAY_LINE +{ + CHANNEL = "overflow"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 7; + TREE_LEVEL = 0; +} + +TIME_BAR +{ + TIME = 10000; + MASTER = TRUE; +} +; diff --git "a/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/decode.v" "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/decode.v" new file mode 100644 index 0000000..e0e816b --- /dev/null +++ "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/decode.v" @@ -0,0 +1,23 @@ +module decode +( +input wire[1:0] a, +input wire en, +output reg[3:0] y +); + +integer i; +always @(*)begin +if(en==1) + for(i=0;i<4;i=i+1)begin + if(a==i) + y[i]=1; + else + y[i]=0; + end +else + for(i=0;i<4;i=i+1)begin + y[i]=0; + end + +end +endmodule diff --git "a/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/decode.vwf" "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/decode.vwf" new file mode 100644 index 0000000..f9692f1 --- /dev/null +++ "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2145\344\273\243\347\240\201/decode.vwf" @@ -0,0 +1,293 @@ +/* +WARNING: Do NOT edit the input and output ports in this file in a text +editor if you plan to continue editing the block that represents it in +the Block Editor! File corruption is VERY likely to occur. +*/ + +/* +Copyright (C) 1991-2013 Altera Corporation +Your use of Altera Corporation's design tools, logic functions +and other software and tools, and its AMPP partner logic +functions, and any output files from any of the foregoing +(including device programming or simulation files), and any +associated documentation or information are expressly subject +to the terms and conditions of the Altera Program License +Subscription Agreement, Altera MegaCore Function License +Agreement, or other applicable license agreement, including, +without limitation, that your use is for the sole purpose of +programming logic devices manufactured by Altera and sold by +Altera or its authorized distributors. Please refer to the +applicable agreement for further details. +*/ + +HEADER +{ + VERSION = 1; + TIME_UNIT = ns; + DATA_OFFSET = 0.0; + DATA_DURATION = 1000.0; + SIMULATION_TIME = 0.0; + GRID_PHASE = 0.0; + GRID_PERIOD = 10.0; + GRID_DUTY_CYCLE = 50; +} + +SIGNAL("a") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = BUS; + WIDTH = 2; + LSB_INDEX = 0; + DIRECTION = INPUT; + PARENT = ""; +} + +SIGNAL("a[1]") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = INPUT; + PARENT = "a"; +} + +SIGNAL("a[0]") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = INPUT; + PARENT = "a"; +} + +SIGNAL("y") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = BUS; + WIDTH = 4; + LSB_INDEX = 0; + DIRECTION = OUTPUT; + PARENT = ""; +} + +SIGNAL("y[3]") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = OUTPUT; + PARENT = "y"; +} + +SIGNAL("y[2]") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = OUTPUT; + PARENT = "y"; +} + +SIGNAL("y[1]") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = OUTPUT; + PARENT = "y"; +} + +SIGNAL("y[0]") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = OUTPUT; + PARENT = "y"; +} + +SIGNAL("en") +{ + VALUE_TYPE = NINE_LEVEL_BIT; + SIGNAL_TYPE = SINGLE_BIT; + WIDTH = 1; + LSB_INDEX = -1; + DIRECTION = INPUT; + PARENT = ""; +} + +TRANSITION_LIST("a[1]") +{ + NODE + { + REPEAT = 1; + LEVEL 0 FOR 20.0; + LEVEL 1 FOR 20.0; + LEVEL 0 FOR 20.0; + LEVEL 1 FOR 20.0; + LEVEL 0 FOR 20.0; + LEVEL 1 FOR 20.0; + LEVEL 0 FOR 880.0; + } +} + +TRANSITION_LIST("a[0]") +{ + NODE + { + REPEAT = 1; + LEVEL 0 FOR 40.0; + LEVEL 1 FOR 40.0; + LEVEL 0 FOR 20.0; + LEVEL 1 FOR 20.0; + LEVEL 0 FOR 880.0; + } +} + +TRANSITION_LIST("y[3]") +{ + NODE + { + REPEAT = 1; + LEVEL X FOR 1000.0; + } +} + +TRANSITION_LIST("y[2]") +{ + NODE + { + REPEAT = 1; + LEVEL X FOR 1000.0; + } +} + +TRANSITION_LIST("y[1]") +{ + NODE + { + REPEAT = 1; + LEVEL X FOR 1000.0; + } +} + +TRANSITION_LIST("y[0]") +{ + NODE + { + REPEAT = 1; + LEVEL X FOR 1000.0; + } +} + +TRANSITION_LIST("en") +{ + NODE + { + REPEAT = 1; + LEVEL 1 FOR 80.0; + LEVEL 0 FOR 920.0; + } +} + +DISPLAY_LINE +{ + CHANNEL = "a"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 0; + TREE_LEVEL = 0; + CHILDREN = 1, 2; +} + +DISPLAY_LINE +{ + CHANNEL = "a[1]"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 1; + TREE_LEVEL = 1; + PARENT = 0; +} + +DISPLAY_LINE +{ + CHANNEL = "a[0]"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 2; + TREE_LEVEL = 1; + PARENT = 0; +} + +DISPLAY_LINE +{ + CHANNEL = "en"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 3; + TREE_LEVEL = 0; +} + +DISPLAY_LINE +{ + CHANNEL = "y"; + EXPAND_STATUS = EXPANDED; + RADIX = Binary; + TREE_INDEX = 4; + TREE_LEVEL = 0; + CHILDREN = 5, 6, 7, 8; +} + +DISPLAY_LINE +{ + CHANNEL = "y[3]"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 5; + TREE_LEVEL = 1; + PARENT = 4; +} + +DISPLAY_LINE +{ + CHANNEL = "y[2]"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 6; + TREE_LEVEL = 1; + PARENT = 4; +} + +DISPLAY_LINE +{ + CHANNEL = "y[1]"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 7; + TREE_LEVEL = 1; + PARENT = 4; +} + +DISPLAY_LINE +{ + CHANNEL = "y[0]"; + EXPAND_STATUS = COLLAPSED; + RADIX = Binary; + TREE_INDEX = 8; + TREE_LEVEL = 1; + PARENT = 4; +} + +TIME_BAR +{ + TIME = 0; + MASTER = TRUE; +} +; diff --git "a/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2148\347\240\201\347\202\271\350\241\250.B1" "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2148\347\240\201\347\202\271\350\241\250.B1" new file mode 100644 index 0000000..34125d0 --- /dev/null +++ "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\345\256\236\351\252\2148\347\240\201\347\202\271\350\241\250.B1" @@ -0,0 +1,131 @@ +HQFC-B1΢ƴ +JMӹ +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 07 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 10 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 05 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 30 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 3A +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3F +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3B +0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 3F +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 05 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + diff --git "a/\350\256\241\347\273\204+\345\256\236\351\252\214/\347\241\254\344\273\266\347\273\274\345\220\210\345\256\236\351\252\214\346\212\245\345\221\212.pdf" "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\347\241\254\344\273\266\347\273\274\345\220\210\345\256\236\351\252\214\346\212\245\345\221\212.pdf" new file mode 100644 index 0000000..7104667 Binary files /dev/null and "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\347\241\254\344\273\266\347\273\274\345\220\210\345\256\236\351\252\214\346\212\245\345\221\212.pdf" differ diff --git "a/\350\256\241\347\273\204+\345\256\236\351\252\214/\350\256\241\347\273\204\345\244\215\344\271\240\351\242\230.pdf" "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\350\256\241\347\273\204\345\244\215\344\271\240\351\242\230.pdf" new file mode 100644 index 0000000..c0dde8a Binary files /dev/null and "b/\350\256\241\347\273\204+\345\256\236\351\252\214/\350\256\241\347\273\204\345\244\215\344\271\240\351\242\230.pdf" differ diff --git "a/\350\275\257\344\273\266\345\267\245\347\250\213/2022 A\345\215\267.pdf" "b/\350\275\257\344\273\266\345\267\245\347\250\213/2022 A\345\215\267.pdf" new file mode 100644 index 0000000..e54b901 Binary files /dev/null and "b/\350\275\257\344\273\266\345\267\245\347\250\213/2022 A\345\215\267.pdf" differ diff --git "a/\350\275\257\344\273\266\345\267\245\347\250\213/\350\275\257\344\273\266\345\267\245\347\250\213\345\244\215\344\271\240(2022\345\271\264).pdf" "b/\350\275\257\344\273\266\345\267\245\347\250\213/\350\275\257\344\273\266\345\267\245\347\250\213\345\244\215\344\271\240(2022\345\271\264).pdf" new file mode 100644 index 0000000..bfb5bcf Binary files /dev/null and "b/\350\275\257\344\273\266\345\267\245\347\250\213/\350\275\257\344\273\266\345\267\245\347\250\213\345\244\215\344\271\240(2022\345\271\264).pdf" differ diff --git "a/\350\275\257\344\273\266\345\267\245\347\250\213/\350\275\257\344\273\266\345\267\245\347\250\213\345\244\215\344\271\240(2023\345\271\264).pdf" "b/\350\275\257\344\273\266\345\267\245\347\250\213/\350\275\257\344\273\266\345\267\245\347\250\213\345\244\215\344\271\240(2023\345\271\264).pdf" new file mode 100644 index 0000000..67dc2b8 Binary files /dev/null and "b/\350\275\257\344\273\266\345\267\245\347\250\213/\350\275\257\344\273\266\345\267\245\347\250\213\345\244\215\344\271\240(2023\345\271\264).pdf" differ diff --git "a/\350\275\257\344\273\266\345\267\245\347\250\213/\350\275\257\345\267\245\344\275\234\344\270\232\347\255\224\346\241\210.pdf" "b/\350\275\257\344\273\266\345\267\245\347\250\213/\350\275\257\345\267\245\344\275\234\344\270\232\347\255\224\346\241\210.pdf" new file mode 100644 index 0000000..e2dca17 Binary files /dev/null and "b/\350\275\257\344\273\266\345\267\245\347\250\213/\350\275\257\345\267\245\344\275\234\344\270\232\347\255\224\346\241\210.pdf" differ diff --git "a/\351\253\230\347\255\211\346\225\260\345\255\246/\345\244\232\345\205\203\345\276\256\347\247\257\345\210\206A\345\220\214\346\255\245\347\273\203\344\271\240\350\247\243\347\255\224.pdf" "b/\351\253\230\347\255\211\346\225\260\345\255\246/\345\244\232\345\205\203\345\276\256\347\247\257\345\210\206A\345\220\214\346\255\245\347\273\203\344\271\240\350\247\243\347\255\224.pdf" new file mode 100644 index 0000000..5bdede4 Binary files /dev/null and "b/\351\253\230\347\255\211\346\225\260\345\255\246/\345\244\232\345\205\203\345\276\256\347\247\257\345\210\206A\345\220\214\346\255\245\347\273\203\344\271\240\350\247\243\347\255\224.pdf" differ