Переписать код работы с NotifyIcon (WPF, C#) на VB.NET - Visual Basic .NET
Формулировка задачи:
Привет!!!
помогите перевести программу на С# в VB.NET:
Вот что я сам смог на переводить:
<<Заранее благодарен.>>
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using System.Drawing;
- using System.Windows.Forms;
- namespace WpfApplication1
- {
- /// <summary>
- /// Логика взаимодействия для MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- protected NotifyIcon notifyicon;
- private void button1_Click(object sender, RoutedEventArgs e)
- {
- notifyicon = new System.Windows.Forms.NotifyIcon();
- notifyicon.Icon = new System.Drawing.Icon("Bulb.ico");
- notifyicon.Visible = true;
- notifyicon.MouseClick += new System.Windows.Forms.MouseEventHandler(notifyicon_Click);
- notifyicon.ShowBalloonTip(500, "Ich bin im Trey", "Ich bin eine Notifyicon", System.Windows.Forms.ToolTipIcon.Info);
- System.Windows.Forms.ContextMenu notinfyiconContextMenu = new System.Windows.Forms.ContextMenu();
- notinfyiconContextMenu.MenuItems.Add("Offnen", new EventHandler(Open));
- notinfyiconContextMenu.MenuItems.Add("Beenden", new EventHandler(Close));
- notifyicon.ContextMenu = notinfyiconContextMenu;
- }
- private void Open(object sender, EventArgs e)
- {
- System.Windows.Forms.MessageBox.Show("Offnen");
- }
- private void Close(object sender, EventArgs e)
- {
- System.Windows.Forms.MessageBox.Show("Beenden");
- }
- private void notifyicon_Click(object sender, System.Windows.Forms.MouseEventArgs e)
- {
- if (e.Button == System.Windows.Forms.MouseButtons.Left)
- {
- System.Windows.Forms.MessageBox.Show("Linke Maustaste gerduckt");
- }
- }
- }
- }
Листинг программы
- Imports System.Windows.Forms
- Imports System.Drawing
- Class MainWindow
- Private notifyicon As NotifyIcon = New NotifyIcon()
- Private notifyiconContextMenu As ContextMenu = New ContextMenu()
- Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
- notifyicon.Icon = New System.Drawing.Icon("Bulb.ico")
- notifyicon.Visible = True
- notifyicon.MouseClick += New System.Windows.Forms.MouseEventHandler(notifyicon_Click)' во тета строка ошибки выдает.
- notifyicon.ShowBalloonTip(500, "Ich bin im Trey", "Ich bin eine Notifyicon", System.Windows.Forms.ToolTipIcon.Info)
- notifyiconContextMenu.MenuItems.Add("Offnen", New EventHandler(AddressOf Open))
- notifyiconContextMenu.MenuItems.Add("Beenden", New EventHandler(AddressOf Close))
- notifyicon.ContextMenu = notifyiconContextMenu
- End Sub
- Private Sub Open(ByVal sender As Object, ByVal e As EventArgs)
- MessageBox.Show("Offnen")
- End Sub
- Overloads Sub Close(ByVal sender As Object, ByVal e As EventArgs)
- MessageBox.Show("Beenden")
- End Sub
- Private Sub notifyicon_Click(ByVal sender As Object, ByVal e As MouseEventArgs)
- If (e.Button = System.Windows.Forms.MouseButtons.Left) Then
- MessageBox.Show("Linke Maustaste gerduckt")
- End If
- End Sub
- End Class
Решение задачи: «Переписать код работы с NotifyIcon (WPF, C#) на VB.NET»
textual
Листинг программы
- Imports System.Collections.Generic
- Imports System.Linq
- Imports System.Text
- Imports System.Windows
- Imports System.Windows.Controls
- Imports System.Windows.Data
- Imports System.Windows.Documents
- Imports System.Windows.Input
- Imports System.Windows.Media
- Imports System.Windows.Media.Imaging
- Imports System.Windows.Navigation
- Imports System.Windows.Shapes
- Imports System.Drawing
- Imports System.Windows.Forms
- Namespace WpfApplication1
- ''' <summary>
- ''' Логика взаимодействия для MainWindow.xaml
- ''' </summary>
- Public Partial Class MainWindow
- Inherits Window
- Public Sub New()
- InitializeComponent()
- End Sub
- Protected notifyicon As NotifyIcon
- Private Sub button1_Click(sender As Object, e As RoutedEventArgs)
- notifyicon = New System.Windows.Forms.NotifyIcon()
- notifyicon.Icon = New System.Drawing.Icon("Bulb.ico")
- notifyicon.Visible = True
- AddHandler notifyicon.MouseClick, New System.Windows.Forms.MouseEventHandler(AddressOf notifyicon_Click)
- notifyicon.ShowBalloonTip(500, "Ich bin im Trey", "Ich bin eine Notifyicon", System.Windows.Forms.ToolTipIcon.Info)
- Dim notinfyiconContextMenu As New System.Windows.Forms.ContextMenu()
- notinfyiconContextMenu.MenuItems.Add("Offnen", New EventHandler(AddressOf Open))
- notinfyiconContextMenu.MenuItems.Add("Beenden", New EventHandler(AddressOf Close))
- notifyicon.ContextMenu = notinfyiconContextMenu
- End Sub
- Private Sub Open(sender As Object, e As EventArgs)
- System.Windows.Forms.MessageBox.Show("Offnen")
- End Sub
- Private Sub Close(sender As Object, e As EventArgs)
- System.Windows.Forms.MessageBox.Show("Beenden")
- End Sub
- Private Sub notifyicon_Click(sender As Object, e As System.Windows.Forms.MouseEventArgs)
- If e.Button = System.Windows.Forms.MouseButtons.Left Then
- System.Windows.Forms.MessageBox.Show("Linke Maustaste gerduckt")
- End If
- End Sub
- End Class
- End Namespace
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д