1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using CommunityToolkit.Mvvm.ComponentModel;
- using CommunityToolkit.Mvvm.Input;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Input;
- namespace AutoDeploy
- {
- public class MainWindowViewModel: ObservableObject
- {
- private MainWindowViewModel()
- {
- float f = 20;
- ushort[] v = new ushort[2] {0x42a0,0x0000 };
- byte[] b = new byte[4];
- //Unsafe.CopyBlock(ref Unsafe.As<ushort,byte>(ref v[0]), ref Unsafe.As<float, byte>(ref f), 4);
- v = v.Reverse().ToArray();
- float f1 = Unsafe.As<ushort, float>(ref v[0]);
- }
- static MainWindowViewModel()
- {
- }
- public ICommand StartCommand => new RelayCommand(Start);
- private async void Start()
- {
- Renci.SshNet.SshClient client = new Renci.SshNet.SshClient(IP, UserName, Password);
- client.Connect();
- var input = new System.IO.StreamWriter(new System.IO.MemoryStream());
- input.AutoFlush = true;
- var output = new System.IO.StreamReader(new System.IO.MemoryStream());
- var ext = new System.IO.StreamReader(new System.IO.MemoryStream());
- client.CreateShell(input.BaseStream, output.BaseStream,ext.BaseStream);
- input.WriteLine("opkg update");
-
- Debug.WriteLine(output.ReadLine());
- client.Disconnect();
- client.Dispose();
- }
- public string IP { get; set; } = "192.168.1.34";
- public string UserName { get; set; } = "admin";
- public string Password { get; set; } = "123456";
- public static MainWindowViewModel Instance { get; } = new MainWindowViewModel();
- }
- }
|