• Thế Giới Giải Mã

    Bí ẩn nhân loại Leonardo Da Vinci

  • Thế Giới Giải Mã

    Anh hùng thầm lặng Nikola Tesla

  • Thế Giới Giải Mã

    Thần đèn Thomas Edison

  • Thế Giới Giải Mã

    Người thôi miên Adolf Hitler

Showing posts with label Windows Store. Show all posts
Showing posts with label Windows Store. Show all posts

21 June 2017

Chia sẻ file, dữ liệu giữa các máy tính trong mạng LAN, Công ty, văn phòng, trường học, gia đình

HƯỚNG DẪN CHIA SẺ TÀI LIỆU GIỮA CÁC MÁY TÍNH TRONG MẠNG LAN
Bước 1: Vào Netword and Sharing Center bằng cách vào Control panel tìm và chọn Netword and Sharing Center
Bước 2: Vào Change advanced sharing settings.
Bước 3: Tiếp theo, bạn nhấn vào Private
Bước 4: Tích vào các tùy chọn như dưới và nhấn Save changes để lưu thiết lập
Bước 5: Vào thư mục, file bạn muốn chia sẻ phải chuột và chọn properties
Bước 6: Chuyển qua tab Sharing và chọn Share...
Bước 7: Nhấn chọn Everyone sau đó nhấn Add, tiếp theo nhấn Share để chia sẻ Files, thư mục
Bước 8: Từ máy muốn copy dữ liệu bạn gõ vào địa chỉ tên máy hoặc địa chỉ IP của máy đã chia sẻ dữ liệu bằng cách nhấn tổ hợp Windows +R sau đó gõ vào theo cú pháp:
\\Computer_Name
Hoặc \\ip_address
Trong đó Computer_Name là máy chia sẻ dữ liệu, ip_address là địa chỉ IP của máy chia sẻ dữ liệu
Ví dụ: Máy Taimienphi1 muốn truy cập vào máy Taimienphi2 để copy dữ liệu bạn có thể gõ \\Taimienphi2
http://thuthuat.taimienphi.vn/chia-se-tai-lieu-giua-cac-may-tinh-trong-mang-lan-2066n.aspx 
Trên đây chúng tôi vừa hướng dẫn bạn cách chia sẻ dữ liệu giữa các máy tính trong mạng Lan. Với thủ thuật này, bạn có thể nhanh chóng và dễ dàng copy, chuyển đổi dữ liệu giữa máy tính trong mạng Lan mà không cần phải có các thiết bị khác.
Nguồn thuthuat.taimienphi.vn

21 April 2017

Assignment

  1. Create Login form on MainPage.xaml as following:                                             [1]
Fig 0. MainPage.xaml GUI
(Note: Grid Background=”Brown”)
Control
x:Name
Text/PlaceHolderText
Event
Handler
TextBox
xnUsername
Input Username
KeyDown
OnKeyDown()
TextBox
xnPassword
Input Password
KeyDown
OnKeyDown()
Button
xnLogin
Login
Click
Login_Click
Button
xnRegister
Register
Click
Register_Click()


  1. Functions: On MainPage.xaml.cs                                                                              [8]
Return Type
Methods
Description
void
MainPage()
Use Navigation Cache so when users come back to this page, they can quickly Log In back to PlacePage without having to re-type their log in information.
Also use Navigation Cache on PlacePage so when user go back to the page, all previous information which user is working on will be there. [2]
void
Login_Click(object sender, RoutedEventArgs e)
Get all PasswordCredential in PasswordVault by Resource “Aptech”. If any PasswordCredential match with inputted Username and Password then navigate to BookingPage. Else, show a notification that “Login failed!” [3]
void
Register_Click(object sender, RoutedEventArgs e)
Add the inputted Username and Password as PasswordCredential with Resource “Aptech” into PasswordVault. [3]

3.      Create BookingPage with textboxes to accept Name, City,
a.       Mobile number and Email id of the customer along with a command button.
b.      When customer clicks on Submit button, display a page with a link “Previous”.

c.       Using cache management write code so when user visits previous page, all entered data should be saved in the textbox.

15 April 2017

TEST WASD2 Windows store Trắc Nghiệm

Total: Full 80%

Windows Store và JSON: Tạo file Json vs Browser Images và Search Name từ Json hiển thị - Windows Store Apps

Test WADS2
--Tạo JSON--
//Contact c = new Contact();
//c.name="Antonio"
string json = Newtonsoft.Json.JsonConvert.SerializeObject(c);

StorageFolder localFolder = ApplicationData.Current.LocalFolder;

StorageFile textFile = await localFolder.CreateFileAsync("contact3.json",CreationCollisionOption.ReplaceExisting);
using (IRandomAccessStream textStream = await textFile.OpenAsync(FileAccessMode.ReadWrite))
{
          using (DataWriter textWriter = new DataWriter(textStream))
          {
                textWriter.WriteString(json);
                await textWriter.StoreAsync();
          }
}
--Đọc JSON--
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
StorageFile textFile = await localFolder.GetFileAsync("contact3.json");
using (IRandomAccessStream textStream = await textFile.OpenReadAsync())
{
      DataReader textReader = new DataReader(textStream);
      uint textLength = (uint)textStream.Size;
      await textReader.LoadAsync(textLength);
      string jsonContent = textReader.ReadString(textLength);

      JsonValue jsonValue = JsonValue.Parse(jsonContent);

      string name = jsonValue.GetObject().GetNamedString("name");
      tbName.Text = name; //VD: đưa value name vào textBox
}
--Hiển thị Value trên ComboBox--
protected override void OnNavigatedTo(NavigationEventArgs e)
{
        List<string> item = new List<string>();
        item.Add("family");
        item.Add("family_2");
        item.Add("family_3");
        comboBox.DataContext = item;
}
<ComboBox x:Name="comboBox" ItemsSource="{Binding}" />
--Display ảnh từ Pictures Library--
var file = await
Windows.Storage.KnownFolders.PicturesLibrary.GetFileAsync("human.png");
var stream = await file.OpenReadAsync();
var bitmapImage = new BitmapImage();
bitmapImage.SetSource(stream);

this.image.Source = bitmapImage;

//Chú ý vào file manifest cấp quyền
Tạo Page Create Contact
MainPage.xaml
Windows Store 2017
<Page
    x:Class="TestWSAD2.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:TestWSAD2"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <TextBlock x:Name="textBlock" FontSize="30" HorizontalAlignment="Left" Height="58" Margin="335,69,0,0" TextWrapping="Wrap" Text="Create new Contact" VerticalAlignment="Top" Width="615"/>
        <TextBlock x:Name="textBlock1" FontSize="25" HorizontalAlignment="Left" Height="40" Margin="225,185,0,0" TextWrapping="Wrap" Text="Contact Name" VerticalAlignment="Top" Width="185"/>
        <TextBlock x:Name="textBlock1_Copy" FontSize="25" HorizontalAlignment="Left" Height="40" Margin="225,280,0,0" TextWrapping="Wrap" Text="Contact Number" VerticalAlignment="Top" Width="185"/>
        <TextBlock x:Name="textBlock1_Copy1" FontSize="25" HorizontalAlignment="Left" Height="40" Margin="225,384,0,0" TextWrapping="Wrap" Text="Contact Group" VerticalAlignment="Top" Width="185"/>
        <TextBlock x:Name="textBlock1_Copy2" FontSize="25" HorizontalAlignment="Left" Height="40" Margin="225,502,0,0" TextWrapping="Wrap" Text="Contact Image" VerticalAlignment="Top" Width="185"/>
        <TextBox x:Name="tbName" HorizontalAlignment="Left" FontSize="18" Height="40" Margin="505,185,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="329"/>
        <TextBox x:Name="tbNumber" HorizontalAlignment="Left" FontSize="18" Height="40" Margin="505,280,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="329"/>
        <TextBox x:Name="tbImage" HorizontalAlignment="Left" FontSize="18" Height="40" Margin="505,502,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="329"/>
        <ComboBox x:Name="comboBox" ItemsSource="{Binding}" HorizontalAlignment="Left" Height="40" Margin="505,384,0,0" VerticalAlignment="Top" Width="329" FontSize="18" />
        <Button x:Name="btnBrowser" Content="Browser..." HorizontalAlignment="Left" Height="43" Margin="877,502,0,0" VerticalAlignment="Top" Width="182" Click="btnBrowser_Click"/>
        <Button x:Name="btnSave" Content="Save Contact" HorizontalAlignment="Left" Height="43" Margin="542,610,0,0" VerticalAlignment="Top" Width="181" Click="btnSave_Click"/>

    </Grid>
</Page>
MainPage.xaml.cs
Windows Store 2017
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.Storage.Streams;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace TestWSAD2
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //Display comboBox
            List<string> item = new List<string>();
            item.Add("family");
            item.Add("family_2");
            item.Add("family_3");
            comboBox.DataContext = item;
        }


        private async void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Contact c = new Contact();
            c.name = tbName.Text;
            c.number = tbNumber.Text;
            c.group = comboBox.SelectedItem.ToString();
            c.image = tbImage.Text;

            string json = Newtonsoft.Json.JsonConvert.SerializeObject(c);

            StorageFolder localFolder = ApplicationData.Current.LocalFolder;

            StorageFile textFile = await localFolder.CreateFileAsync("contact3.json",CreationCollisionOption.ReplaceExisting);
            using (IRandomAccessStream textStream = await textFile.OpenAsync(FileAccessMode.ReadWrite))
            {
                using (DataWriter textWriter = new DataWriter(textStream))
                {
                    textWriter.WriteString(json);
                    await textWriter.StoreAsync();
                }
            }
            Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog("Them du lieu thanh cong");
            await dialog.ShowAsync();

            Frame.Navigate(typeof(SearchContact));
        }

        private async void btnBrowser_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker picker = new FileOpenPicker();
            picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".png");
            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".gif");
            picker.FileTypeFilter.Add(".jpeg");

            StorageFile file = await picker.PickSingleFileAsync();
            if (file != null)
                tbImage.Text = file.Name;
            else
                tbImage.Text = "Chua chon file";
        }
    }

}
class Contact
{
    public string name { set; get; }
    public string number { set; get; }
    public string group { set; get; }
    public string image { set; get; }
}
Add thư viện hỗ trợ JSON

Cấu trúc Project
Tạo page SearchContact
SearchContact.xaml
Windows Store 2017
<Page
    x:Class="TestWSAD2.SearchContact"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:TestWSAD2"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <TextBlock x:Name="textBlock" FontSize="30" HorizontalAlignment="Left" Height="58" Margin="165,85,0,0" TextWrapping="Wrap" Text="Search Contact" VerticalAlignment="Top" Width="615"/>
        <TextBlock x:Name="textBlock1" FontSize="25" HorizontalAlignment="Left" Height="40" Margin="55,201,0,0" TextWrapping="Wrap" Text="Contact Name" VerticalAlignment="Top" Width="185"/>
        <TextBlock x:Name="textBlock2" FontSize="25" HorizontalAlignment="Left" Height="40" Margin="55,296,0,0" TextWrapping="Wrap" Text="Contact Number" VerticalAlignment="Top" Width="185"/>
        <TextBlock x:Name="textBlock3" FontSize="25" HorizontalAlignment="Left" Height="40" Margin="55,400,0,0" TextWrapping="Wrap" Text="Contact Group" VerticalAlignment="Top" Width="185"/>
        <TextBlock x:Name="textBlock4" FontSize="25" HorizontalAlignment="Left" Height="40" Margin="55,518,0,0" TextWrapping="Wrap" Text="Contact Image" VerticalAlignment="Top" Width="185"/>
        <TextBox x:Name="tbName" HorizontalAlignment="Left" FontSize="18" Height="40" Margin="335,201,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="416"/>
        <TextBox x:Name="tbNumber" HorizontalAlignment="Left" FontSize="18" Height="40" Margin="335,296,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="416"/>
        <TextBox x:Name="tbImage" HorizontalAlignment="Left" FontSize="18" Height="40" Margin="335,518,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="416"/>
        <ComboBox x:Name="comboBox" ItemsSource="{Binding}" HorizontalAlignment="Left" Height="40" Margin="335,400,0,0" VerticalAlignment="Top" Width="416" FontSize="18" />
        <Button x:Name="btnSearchContact" Content="Search Contact" HorizontalAlignment="Left" Height="46" Margin="843,198,0,0" VerticalAlignment="Top" Width="214" Click="btnSearchContact_Click"/>
        <Button x:Name="btnBack" Content="Back" HorizontalAlignment="Left" Height="37" Margin="447,622,0,0" VerticalAlignment="Top" Width="148" Click="btnBack_Click" d:LayoutOverrides="HorizontalAlignment"/>
        <Image x:Name="image" HorizontalAlignment="Right" Margin="0,345,312,210" Width="208" d:LayoutOverrides="VerticalAlignment"/>
    </Grid>
</Page>
SearchContact.xaml.cs
Windows Store 2017
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Data.Json;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;

namespace TestWSAD2
{
    public sealed partial class SearchContact : Page
    {
        public SearchContact()
        {
            this.InitializeComponent();
        }
       
        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            Frame.Navigate(typeof(MainPage));
        }

        private async void btnSearchContact_Click(object sender, RoutedEventArgs e)
        {
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            StorageFile textFile = await localFolder.GetFileAsync("contact3.json");
            using (IRandomAccessStream textStream = await textFile.OpenReadAsync())
            {
                DataReader textReader = new DataReader(textStream);
                uint textLength = (uint)textStream.Size;
                await textReader.LoadAsync(textLength);
                string jsonContent = textReader.ReadString(textLength);

                JsonValue jsonValue = JsonValue.Parse(jsonContent);

                string name = jsonValue.GetObject().GetNamedString("name");

                if (tbName.Text.Equals(name))
                {
                    //TexBox name 
                    tbName.Text = name;

                    //TextBox number
                    string number = jsonValue.GetObject().GetNamedString("number");
                    tbNumber.Text = number;

                    //Combobox group
                    string group = jsonValue.GetObject().GetNamedString("group");
                    List<String> list = new List<String>();
                    list.Add(group);
                    comboBox.DataContext = list;
                    //TextBox image
                    string image = jsonValue.GetObject().GetNamedString("image");
                    tbImage.Text = image;

                    //Show image
                    var file = await
                    Windows.Storage.KnownFolders.PicturesLibrary.GetFileAsync(image);
                    var stream = await file.OpenReadAsync();
                    var bitmapImage = new BitmapImage();
                    bitmapImage.SetSource(stream);

                    this.image.Source = bitmapImage;

                }
            }

        }
    }
}
Run Test App
 Create success!
 Go to Search page
 Display kết quả Search và hiển thị hình ảnh

10 April 2017

Windows Store và File: Tạo Folder và Bindding hiển thị Folder lên ComboBox trên App Windows Store C#

MainPage.xaml
Windows Store 2017
<Page
    x:Class="CaptureDemo.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:CaptureDemo"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <TextBox x:Name="tb_folder_name" HorizontalAlignment="Left" Margin="305,250,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="32" Width="190" FontSize="20"/>
        <TextBlock x:Name="textBlock" HorizontalAlignment="Left" Height="40" Margin="105,250,0,0" TextWrapping="Wrap" Text="Folder name:" VerticalAlignment="Top" Width="155" FontSize="24"/>
        <Button x:Name="btn_create" Content="Create new Folder" HorizontalAlignment="Left" Margin="567,247,0,0" VerticalAlignment="Top" Click="btn_create_Click"/>
        <ComboBox x:Name="comboBox" ItemsSource="{Binding}" HorizontalAlignment="Left" Margin="305,357,0,0" VerticalAlignment="Top" Width="190" Height="32"/>
        <Button x:Name="btn_show" Content="Get folder name" HorizontalAlignment="Left" Margin="567,357,0,0" VerticalAlignment="Top" Click="btn_show_Click"/>
        <TextBlock x:Name="textBlock1" HorizontalAlignment="Left" Margin="105,360,0,0" TextWrapping="Wrap" Text="Folder name:" VerticalAlignment="Top" FontSize="24"/>
    </Grid>

</Page>
Cấp quyền vào thư mục Pricture Libarary
MainPage.xaml.cs
Windows Store 2017
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Media.Capture;
using Windows.Media.MediaProperties;
using Windows.Storage;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace CaptureDemo
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

        private async void btn_create_Click(object sender, RoutedEventArgs e)
        {
            //Tao folder o PicturesLibrary
            StorageFolder appFolder = await KnownFolders.PicturesLibrary.CreateFolderAsync(tb_folder_name.Text, CreationCollisionOption.OpenIfExists);
            var dialog = new MessageDialog("Tao Folder: " + tb_folder_name.Text + " thanh cong");
            await dialog.ShowAsync();
        }

        private async void btn_show_Click(object sender, RoutedEventArgs e)
        {
            //Tao List add name folder
            List<String> list = new List<String>();
            StorageFolder folder = KnownFolders.PicturesLibrary;
            IReadOnlyList<IStorageItem> items = await folder.GetItemsAsync();
            foreach (var item in items)
            {
                if (item is StorageFolder)
                {
                    list.Add(item.Name);
                }

            }
            //Bindding name folder vao ComboBox
            comboBox.DataContext = list;
        }
    }
}

Windows Store và Graphics: Camera Capture trên App Windows Store C#

MainPage.xaml
Windows Store 2017
<Page
    x:Class="CaptureDemo.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:CaptureDemo"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <CaptureElement x:Name="capture" HorizontalAlignment="Left" Height="336" Margin="135,155,0,0" VerticalAlignment="Top" Width="680"/>
        <Button x:Name="btn_start" Content="Start Camera" HorizontalAlignment="Left" Margin="242,577,0,0" VerticalAlignment="Top" Click="btn_start_Click"/>
        <Button x:Name="btn_capture" Content="Capture and Save" HorizontalAlignment="Left" Margin="592,577,0,0" VerticalAlignment="Top" Click="btn_capture_Click"/>

    </Grid>
</Page>
Cấp quyền Camera
MainPage.xaml.cs
Windows Store 2017
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Media.Capture;
using Windows.Media.MediaProperties;
using Windows.Storage;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace CaptureDemo
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

        private async void btn_start_Click(object sender, RoutedEventArgs e)
        {
            //Start Camera
            MediaCapture captureManager = new MediaCapture();
            await captureManager.InitializeAsync();
            capture.Source = captureManager;
            await captureManager.StartPreviewAsync();
        }

        private async void btn_capture_Click(object sender, RoutedEventArgs e)
        {
            //Capture image
            Windows.Media.Capture.MediaCapture takePhotoManager = new Windows.Media.Capture.MediaCapture();
            await takePhotoManager.InitializeAsync();
            //Save file pic-001.jpg
            ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();
            StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("pic-001.jpg", CreationCollisionOption.ReplaceExisting);
            await takePhotoManager.CapturePhotoToStorageFileAsync(imgFormat, file);
        }
    }
}

 

BACK TO TOP

Xuống cuối trang