Tải bản đầy đủ (.docx) (31 trang)

Quản lý trung tâm tin học

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (573.74 KB, 31 trang )

HO CHI MINH UNIVERSITY OF INDUSTRY
Faculty of Information Technology
LAB REPORT
Software Development Topics
Student:Vũ Văn Thức
ID:09017172
Class:CDTH11K
I.Part 1: Custom Component 3
1) Exercise 1: 3
2) Exercise 2: 4
3) Exercise 3: 5
4) Exercise 4: 6
5) Exercise 5: 7
6) Exercise 6: 7
7) Exercise 7: 8
8) Exercise 8: 9
9) Exercise 9: 9
10) Exercise 10: 10
11) Exercise 11: 10
12) Exercise 12: 11
13) Exercise 13: 11
14) Exercise 14: 12
15) Exercise 15: 12
16) Exercise 16 13
17) Exercise 17: 13
18) Exercise 18: 14
II.Part 2: LinQ 14
1) Exercise 1: 14
2) Exercise 2: 15
3) Exercise 3: 15
4) Exercise 4: 16


5) Exercise 5: 16
III.Part 3: WPF 17
1) Exercise 1: 17
2) Exercise 2: 19
3) Exercise 3: 19
4) Exercise 4: 20
5) Exercise 5: 20
IV.Part 4: Net Remoting 23
1) Exercise 1: 23
Part 1: Custom Component
1) Exercise1: Creating Metro Forms
Cách làm:
-Tạo project như bình thường.
- Project/ Add Window Form.
-Chọn Metro Form hoặc Metro App Form.
Kết Quả :
2) Exercise2: Office 2007 Ribbon Control
Cách làm:
-Tạo project như bình thường.
- Click chuột phải vào Form chính chọn View Code.
-Đổi phần thừa kế của Form thành Office2007RibbonControl
-Trong thanh Toolbox kéo thả RibbonControl vào Form
Kết Quả:
3) Exercise3: Ribbon MDI Merging
Cách Làm:
-Tạo project như bình thường.
-Kéo thả Ribbon Control vào form chính.
-Trong form chính chọn thuộc tính isMdiContainer=true.
-Tạo button để mở form con ta được:
-Tạo Form con và kéo thả RibbonBarMergerContainer vào form và tạo vài

control vào ta được:
Kết Quả:
4) Exercise4: Ribbon Contextual Tab Groups
Cách Làm
-Tạo Office2007RibbonControl
-Chọn RibbonTab sửa thuôc tính Group
-Muốn cho cùng nhóm thì cho cùng tên Groub.
Kết Quả
5) Exercise5: Office 2007 Style Drop-Down Galleries
Cách Làm
-Tạo Office2007RibbonControl
-Click chuột phải vào RibbonBar chọn Add Galleries Container
-Thêm một vài control vào để kiểm tra.
Kết Quả
6) Exercise6: Grouping Popup Gallery Items
Cách Làm:
-Sử dụng bài 5, chọn các control và cho vào các Group
Kết Quả:
7) Exercise7: Using Expandable Panel control to create Office 2010 Access like
Navigation Pane
Cách Làm:
-Kéo thả Expandable Panel vào from chính và gán thuộc tính Dock là left.
-Kéo thả tiếp Expandable Panel vào Expandable Panel đầu tiên đã tạo.
-Chỉnh các Expandable Panel thuộc tính ExpanOnTitleClick = true.
Kết Quả:
8) Exercise8: Creating Menus and Toolbars with DotNetBar
Cách Làm:
-Trong form kéo thả DotNetBarMannager vào.
-Click phải chọn Add Menu Bar.
-Click phải chọn Add ToolBar và Add các Button menu vào

Kết Quả:
9) Exercise9: Creating Dockable Window
Cách Làm:
-Trong form kéo thả DotNetBarMannager vào.
-Click phải vào DotNetBarMannager chọn Crete Dock Bar left
,right,button,top.
-Hiệu chỉnh theo ý muốn.
Kết Quả:
10) Exercise10:Creating Context Menus
Cách Làm:
-Trong Toolbox kéo thả ContextMenuBar vào form.
-Chỉnh menu theo ý muốn.
-Control nào muốn sử dụng thì chọn thuộc tính ContextMenu On : là tên của
ContextMenuBar vừa tạo .
Kết Quả:
11) Exercise11: Office 2010 Status bar
Cách Làm:
-Trong Toolbox kéo thả bar vào from rồi gán thuộc tính Dock là botton.
-Thêm các button vào Bar để hiển thị thông tin.
Kết Quả:
12)Exercise12: Working with PanelEx Control
Cách Làm:
-Trong Toolbox kéo thả PannelEx vào from và hiệu chỉnh màu và các thuộc
tính khác theo ý muốn.
Kết Quả:
13) Exercise13: dding DotNetBarManager to the form
Cách Làm:
-Trong thanh Toolbox click chuột phải chọn Add tab rồi nhập tên tab.
-Chọn tab vừa tạo click phải chọn Choose items.
-Chọn tab .Net Famework Component rồi tick vào các control muốn hiển thị.

14) Exercise14:Working with NavigationPane Control
Cách Làm:
-Trong thanh Toolbox kéo thả NavigationPane vào from.
-Click phải vào NavigationPane tạo vài panel.
-Kéo thả một vài textbox … vào.
Kết Quả:
15) Exercise15: Working with New Tab Control
Cách Làm:
-Trong thanh Toolbox kéo thả Tab Control vào from.
-Click phải vào panel vừa tạo chọn Create new tab để tạo thêm tab.
-Điền thông tin và chỉnh một số chức năng của tab theo yêu cầu.
Kết Quả:
16) Exercise16: Working with New BubbleBar Control
Cách Làm:
-Trong thanh Toolbox kéo thả BubbleBar vào from.
-Thêm một vài tab và item cho BubbleBar.
Kết Quả
17) Exercise17: Working with New ExpandableSplitter Control
-Cách Làm:
-Kéo thả một panel vào form chỉnh dock là left
-Kéo thả ExpandableSplitter vào from.
-Hiệu chỉnh thuộc tính của ExpandControl ExpandableSplitter chọn panel
vừa tạo.
-Tương tự với panel nằm bên phải.
Kết Quả:
18) Exercise18: Document Docking
-Cách Làm:
-Kéo DotNetBarManager vào from
-Chuột phải vào DotNetBarManager vừa tạo chọn Enable Document
Docking.

-Chuột phải vào Document Docking để tạo thêm vài tab.
-Dùng chuột kéo thả các Document Docking vào vị trí thích hợp.
Kết Quả:
II.Part 2: LINQ
1) Exercise 1:Example 1
Mô tả: Sử dụng câu query của LinQ:
-Code:
int[] nums=new int[]{1,2,3,4,5,6,7,8,9}; Tạo mảng số nguyên
var resurt = from num in nums
where num % 2 ==1 Lấy các số lẻ
orderby num
select num;
foreach(int n in resurt)
{
label1.Text += n+" "; Hiển thị lên lable
}
Kết Quả:

2) Exercise 2:Chuyển mảng số từ chuỗi sang mảng số.
Mô tả: S =“20;10;2;0;1;0” => array of int {20,10,2,0,1,0}.
Code:
string s = "20;10;2;0;1;0";
string[] arr = s.Split(';');Tạo mảng chỉ gồm số
List<int> numbersList = arr.Select(m =>m.ToNumber()).ToList(); Chuyển
qua list
int[] arrInt = numbersList.ToArray();Chuyển từ list qua array
Kết Quả:
3) Exercise 3:Ví dụ về lazy loading
Mô tả:
Code:

var source = new List<string>() {"A","B","C"};
var sources = from c in source
select c;
source.Add("D");
=> Kết quả sẽ là A,B,C,D.
Kết Quả:
4) Exercise 4:LinQ Query Syntax
Mô tả:Phân biệt Query Syntax và Method syntax
Code:
//Query syntax
IEnumerable<int> query1 = from num in numbers
where num % 2 == 0 orderby num
select num;
//Method syntax
var query2 = numbers.Where(n => n % 2 == 0).OrderBy(n => n);
Kết Quả:
5) Exercise 5:LinQ và SQL
Mô tả: Thêm xóa sửa cơ bản bằng LinQ đến SQL
Code:
-Add LinQ to SQL class
PetshopDataContext db = new PetshopDataContext();//Tạo xxxDatacontex để truy
cập csdl.
var product = from m in db.Products select m; Lấy dữ liệu bảng Product
-Thêm một dũ liệu qua LinQ:
Product product = new Product();Tạo một product
Nhập dữ liệu cho product
product.ProductId = txtProID.Text;
product.CategoryId = txtCategoryID.Text;
product.Descn = txtDescn.Text;
product.Name = txtName.Text;

product.Image = txtImage.Text;
PetshopDataContext db = new PetshopDataContext();
db.Products.InsertOnSubmit(product);Thực hiện insert
db.SubmitChanges(); Lưu vào csdl
-Xóa:
PetshopDataContext db = new PetshopDataContext();
string proID = txtProID.Text;
Product b = db.Products.Single(c => c.ProductId == proID);
db.Products.DeleteOnSubmit(b); Thực hiện xóa
db.SubmitChanges();
-Sửa:
string id = txtProID.Text;
PetshopDataContext db = new PetshopDataContext();
Product prod = db.Products.Single(a => a.ProductId == id);
prod.CategoryId = txtCategoryID.Text;
prod.Name = txtName.Text;
prod.Descn = txtDescn.Text;
prod.Image = txtImage.Text;
db.SubmitChanges(); // Lưu thay đổi
III.Part 3: WPF (Windows Presentation Foundation)
1) Exercise 1:Đổi màu chữ tìm thấy
Mô tả :Cho một đoạn văn bản có sẵn. Viết chương trình m kiếm một từ nhập
vào và tô màu từ đó nếu có trong đoạn văn bản đó
Code:
-Tạo một Brush chứa màu theo yêu cầu.
Run run = new Run(); run.Background = brush; Tạo Run để thay đổi màu chữ
string[] chuoi = textBlock1.Text.Split(' '); Tạo một mảng các từ
textBlock1.Text = ""; Gán xóa chữ của texBlock
foreach (string str in chuoi)
{

if (str.ToLower().Equals(textBox1.Text.ToLower())) Nếu tìm thấy
{
textBlock1.Inlines.Add(new Run(str) { Background = bru,FontSize=18 });//Tô màu
textBlock1.Inlines.Add(new Run(" "));Khoảng trắng
}
else textBlock1.Inlines.Add(new Run(str+" "));
}
Tương tự khi di chuyển chuột lên thay đổi
textBlock1.Inlines.Add(new Run(str) { Background = bru, FontSize = 18,
FontStyle=FontStyles.Italic });
Kết Quả:
2) Exercise 2:Basic control
Mô tả: Tạo một vài control cơ bản trong wpf
Kết Quả:
3) Exercise 3:Brush
Mô tả: Sử dụng các Brush của WPF
Code:
SolidColorBrush
<Button Content="SolidColorBrush1">
<Button.Background>
<SolidColorBrush>
<SolidColorBrush.Color>
<Color>
<Color.A>123</Color.A>
<Color.B>200</Color.B>
<Color.G>255</Color.G>
</Color>
</SolidColorBrush.Color>
</SolidColorBrush>
</Button.Background>

</Button>
LinearGradientBrush
<Button Content="LinearGradientBrush">
<Button.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="Red" Offset="0.0"></GradientStop>
<GradientStop Color="White" Offset="1.0"></GradientStop>
</LinearGradientBrush>
</Button.Background>
</Button>
Thêm thuộc tính Offset và GradientOrigin để thay đổi hiệu ứng

Kết Quả:
4) Exercise 4:Tạo Control động
Mô tả: Tạo Control động
Code:
StackPanel pn = new StackPanel(); Tạo panel
TextBox txt = new TextBox();Tạo textbox
txt.Text = "Hello teo";
Button bt = new Button();Tạo button
bt.Content = "Click me";
Add textbox và button vào panel
pn.Children.Add(txt);
pn.Children.Add(bt);
this.Content = pn; Add panel vào form chính
5) Exercise 5: Di chuyển Button
Mô tả:Di chuyển button quanh form
Code:
Vector Position; //Vi tri
Vector Velocity;// Van toc

Vector size; // size cua button
Position = new Vector(button1.Margin.Left, button1.Margin.Top); Vị trí của button
size = new Vector(button1.Width, button1.Height);Lấy kích thước của button

×