Переписать код работы с NotifyIcon (WPF, C#) на VB.NET - Visual Basic .NET

Узнай цену своей работы

Формулировка задачи:

Привет!!! помогите перевести программу на С# в VB.NET:
Листинг программы
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using System.Drawing;
  15. using System.Windows.Forms;
  16. namespace WpfApplication1
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для MainWindow.xaml
  20. /// </summary>
  21. public partial class MainWindow : Window
  22. {
  23. public MainWindow()
  24. {
  25. InitializeComponent();
  26. }
  27. protected NotifyIcon notifyicon;
  28. private void button1_Click(object sender, RoutedEventArgs e)
  29. {
  30. notifyicon = new System.Windows.Forms.NotifyIcon();
  31. notifyicon.Icon = new System.Drawing.Icon("Bulb.ico");
  32. notifyicon.Visible = true;
  33. notifyicon.MouseClick += new System.Windows.Forms.MouseEventHandler(notifyicon_Click);
  34. notifyicon.ShowBalloonTip(500, "Ich bin im Trey", "Ich bin eine Notifyicon", System.Windows.Forms.ToolTipIcon.Info);
  35. System.Windows.Forms.ContextMenu notinfyiconContextMenu = new System.Windows.Forms.ContextMenu();
  36. notinfyiconContextMenu.MenuItems.Add("Offnen", new EventHandler(Open));
  37. notinfyiconContextMenu.MenuItems.Add("Beenden", new EventHandler(Close));
  38. notifyicon.ContextMenu = notinfyiconContextMenu;
  39. }
  40. private void Open(object sender, EventArgs e)
  41. {
  42. System.Windows.Forms.MessageBox.Show("Offnen");
  43. }
  44. private void Close(object sender, EventArgs e)
  45. {
  46. System.Windows.Forms.MessageBox.Show("Beenden");
  47. }
  48. private void notifyicon_Click(object sender, System.Windows.Forms.MouseEventArgs e)
  49. {
  50. if (e.Button == System.Windows.Forms.MouseButtons.Left)
  51. {
  52. System.Windows.Forms.MessageBox.Show("Linke Maustaste gerduckt");
  53. }
  54. }
  55. }
  56. }
Вот что я сам смог на переводить:
Листинг программы
  1. Imports System.Windows.Forms
  2. Imports System.Drawing
  3. Class MainWindow
  4. Private notifyicon As NotifyIcon = New NotifyIcon()
  5. Private notifyiconContextMenu As ContextMenu = New ContextMenu()
  6. Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
  7. notifyicon.Icon = New System.Drawing.Icon("Bulb.ico")
  8. notifyicon.Visible = True
  9. notifyicon.MouseClick += New System.Windows.Forms.MouseEventHandler(notifyicon_Click)' во тета строка ошибки выдает.
  10. notifyicon.ShowBalloonTip(500, "Ich bin im Trey", "Ich bin eine Notifyicon", System.Windows.Forms.ToolTipIcon.Info)
  11. notifyiconContextMenu.MenuItems.Add("Offnen", New EventHandler(AddressOf Open))
  12. notifyiconContextMenu.MenuItems.Add("Beenden", New EventHandler(AddressOf Close))
  13. notifyicon.ContextMenu = notifyiconContextMenu
  14. End Sub
  15. Private Sub Open(ByVal sender As Object, ByVal e As EventArgs)
  16. MessageBox.Show("Offnen")
  17. End Sub
  18. Overloads Sub Close(ByVal sender As Object, ByVal e As EventArgs)
  19. MessageBox.Show("Beenden")
  20. End Sub
  21. Private Sub notifyicon_Click(ByVal sender As Object, ByVal e As MouseEventArgs)
  22. If (e.Button = System.Windows.Forms.MouseButtons.Left) Then
  23. MessageBox.Show("Linke Maustaste gerduckt")
  24. End If
  25. End Sub
  26. End Class
<<Заранее благодарен.>>

Решение задачи: «Переписать код работы с NotifyIcon (WPF, C#) на VB.NET»

textual
Листинг программы
  1. Imports System.Collections.Generic
  2. Imports System.Linq
  3. Imports System.Text
  4. Imports System.Windows
  5. Imports System.Windows.Controls
  6. Imports System.Windows.Data
  7. Imports System.Windows.Documents
  8. Imports System.Windows.Input
  9. Imports System.Windows.Media
  10. Imports System.Windows.Media.Imaging
  11. Imports System.Windows.Navigation
  12. Imports System.Windows.Shapes
  13. Imports System.Drawing
  14. Imports System.Windows.Forms
  15. Namespace WpfApplication1
  16.     ''' <summary>
  17.     ''' Логика взаимодействия для MainWindow.xaml
  18.     ''' </summary>
  19.     Public Partial Class MainWindow
  20.         Inherits Window
  21.         Public Sub New()
  22.             InitializeComponent()
  23.         End Sub
  24.         Protected notifyicon As NotifyIcon
  25.         Private Sub button1_Click(sender As Object, e As RoutedEventArgs)
  26.             notifyicon = New System.Windows.Forms.NotifyIcon()
  27.             notifyicon.Icon = New System.Drawing.Icon("Bulb.ico")
  28.             notifyicon.Visible = True
  29.             AddHandler notifyicon.MouseClick, New System.Windows.Forms.MouseEventHandler(AddressOf notifyicon_Click)
  30.             notifyicon.ShowBalloonTip(500, "Ich bin im Trey", "Ich bin eine Notifyicon", System.Windows.Forms.ToolTipIcon.Info)
  31.  
  32.             Dim notinfyiconContextMenu As New System.Windows.Forms.ContextMenu()
  33.             notinfyiconContextMenu.MenuItems.Add("Offnen", New EventHandler(AddressOf Open))
  34.             notinfyiconContextMenu.MenuItems.Add("Beenden", New EventHandler(AddressOf Close))
  35.  
  36.             notifyicon.ContextMenu = notinfyiconContextMenu
  37.         End Sub
  38.         Private Sub Open(sender As Object, e As EventArgs)
  39.             System.Windows.Forms.MessageBox.Show("Offnen")
  40.         End Sub
  41.         Private Sub Close(sender As Object, e As EventArgs)
  42.             System.Windows.Forms.MessageBox.Show("Beenden")
  43.         End Sub
  44.         Private Sub notifyicon_Click(sender As Object, e As System.Windows.Forms.MouseEventArgs)
  45.             If e.Button = System.Windows.Forms.MouseButtons.Left Then
  46.                 System.Windows.Forms.MessageBox.Show("Linke Maustaste gerduckt")
  47.             End If
  48.         End Sub
  49.     End Class
  50. End Namespace

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

13   голосов , оценка 4.077 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы