Wei-Meng Lee - C# 2008 Programmer's Reference

Здесь есть возможность читать онлайн «Wei-Meng Lee - C# 2008 Programmer's Reference» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: Indianapolis, Год выпуска: 2009, ISBN: 2009, Издательство: Wiley Publishing, Inc., Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

C# 2008 Programmer's Reference: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «C# 2008 Programmer's Reference»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

C# 2008 Programmers Reference provides a concise and thorough reference on all aspects of the language. Each chapter contains detailed code samples that provide a quick and easy way to understand the key concepts covered.

C# 2008 Programmer's Reference — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «C# 2008 Programmer's Reference», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

//---fired when a node in the TreeView is selected

// and the Enter key pressed---

private void TreeView1_KeyDown(object sender, KeyEventArgs e) {

TreeNode node = TreeView1.SelectedNode;

//---if the Enter key was pressed---

if (e.KeyCode == System.Windows.Forms.Keys.Enter) {

//---if this is a post node---

if (node.ImageIndex == ICO_POST) {

//---set the title of Form2 to title of post---

frm2.Text = node.Text;

//---modifier for webBrowser1 in Form2 must be set to

// Internal---

//---set the webbrowser control to display the post content---

frm2.webBrowser1.DocumentText = node.Tag.ToString();

//---show Form2---

frm2.Show();

}

}

}

Figure 1816 To unsubscribe a feed you remove the feeds URL from the text - фото 334

Figure 18-16

To unsubscribe a feed, you remove the feed's URL from the text file and then remove the feed node from the TreeViewcontrol. This is handled by the Unsubscribe MenuItemcontrol:

//---Unsubscribe a feed---

private void mnuUnsubscribe_Click(object sender, EventArgs e) {

//---get the node to unsubscribe---

TreeNode CurrentSelectedNode = TreeView1.SelectedNode;

//---confirm the deletion with the user---

DialogResult result =

MessageBox.Show("Remove " + CurrentSelectedNode.Text + "?",

"Unsubscribe", MessageBoxButtons.YesNo,

MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

try {

if (result == DialogResult.Yes) {

//---URL To unsubscribe---

string urlToUnsubscribe = CurrentSelectedNode.Tag.ToString();

//---load all the feeds from feeds list---

TextReader textreader = File.OpenText(feedsList);

string[] feeds = textreader.ReadToEnd().Split('|');

textreader.Close();

//---rewrite the feeds list omitting the one to be

// unsubscribed---

TextWriter textwriter = File.CreateText(feedsList);

for (int i = 0; i <= feeds.Length - 2; i++) {

if (feeds[i] != urlToUnsubscribe) {

textwriter.Write(feeds[i] + "|");

}

}

textwriter.Close();

//---remove the node from the TreeView control---

CurrentSelectedNode.Remove();

MessageBox.Show("Feed unsubscribed!");

}

} catch (Exception ex) {

MessageBox.Show(ex.Message);

}

}

When the user needs to refresh a feed, first make a backup copy of the feed XML document and proceed to subscribe to the same feed again. If the subscription is successful, remove the node containing the old feed. If the subscription is not successful (for example, when a device is disconnected from the Internet), restore the backup feed XML document. This is handled by the Refresh Feed MenuItemcontrol:

//---refresh the current feed---

private void mnuRefreshFeed_Click(object sender, EventArgs e) {

//---if no Internet connectivity---

if (!IsConnected()) {

MessageBox.Show("You are not connected to the Internet."); return;

}

//---get the node to be refreshed---

TreeNode CurrentSelectedNode = TreeView1.SelectedNode;

string url = CurrentSelectedNode.Tag.ToString();

//---get the filename of the feed---

string FileName =

appPath + @"\" + RemoveSpecialChars(url) + ".xml";

try {

//---make a backup copy of the current feed---

File.Copy(FileName, FileName + "_Copy", true);

//---delete feed from local storage---

File.Delete(FileName);

//---load the same feed again---

if (SubscribeFeed(url)) {

//---remove the node to be refreshed---

CurrentSelectedNode.Remove();

} else //---the subscription(refresh) failed---

{

//---restore the deleted feed file---

File.Copy(FileName + "_Copy", FileName, true);

MessageBox.Show("Refresh not successful. Please try again.");

}

//---delete the backup file---

File.Delete(FileName + "_Copy");

} catch (Exception ex) {

MessageBox.Show("Refresh failed (" + ex.Message + ")");

}

}

In the Clickevent handler for the Collapse All Feeds MenuItemcontrol, use the CollapseAll()method from the TreeViewcontrol to collapse all the nodes:

private void mnuCollapseAllFeeds_Click(object sender, EventArgs e) {

TreeView1.CollapseAll();

}

Finally, code the Clickevent handler in the Back MenuItemcontrol in Form2as follows:

private void mnuBack_Click(object sender, EventArgs e) {

this.Hide();

}

That's it! You are now ready to test the application.

Testing Using Emulators

The SDKs for the various platforms include various emulators for you to test your Windows Mobile applications without needing to use a real device. For example, if your project is targeting the Windows Mobile 6 platform, you would see a list of emulators available for your testing (see Figure 18-17).

Figure 1817 Once you have selected an emulator to use click the Connect to - фото 335

Figure 18-17

Once you have selected an emulator to use, click the Connect to Device button to launch it. To test your application, cradle the emulator to ActiveSync first so that you have Internet connectivity on the emulator. To cradle the emulator to ActiveSync, select Tools→Device Emulator Manager in Visual Studio 2008; right-click the emulator that has been launched (the one with the green arrow next to it); and select Cradle (see Figure 18-18).

Figure 1818 Now press F5 in Visual Studio 2008 to deploy the application onto - фото 336

Figure 18-18

Now press F5 in Visual Studio 2008 to deploy the application onto the emulator for testing.

Testing Using Real Devices

While most of the testing can be performed on the emulators, it is always helpful to use a real device to fully test your application. For example, you will find out the true usability of your application when users have to type using the small keypad on the phone (versus typing using a keyboard when testing on an emulator). For this purpose, you can test your application on some of the devices running the Windows Mobile 6 Standard platform, such as the Samsung Black II (see Figure 18-19).

Figure 1819 Testing your Windows Mobile application on real devices could not - фото 337

Figure 18-19

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «C# 2008 Programmer's Reference»

Представляем Вашему вниманию похожие книги на «C# 2008 Programmer's Reference» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «C# 2008 Programmer's Reference»

Обсуждение, отзывы о книге «C# 2008 Programmer's Reference» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x