123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- using Avalonia.Collections;
- using CommunityToolkit.Mvvm.Input;
- using Shaker.Models;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Input;
- namespace ShakerApp.ViewModels
- {
- internal class SignalPreviewViewModel:DisplayViewModelBase<IModel>, IDataPreview
- {
-
- public AvaloniaList<AnalogSignalPreviewViewModel> SignalPreviews { get; } = new AvaloniaList<AnalogSignalPreviewViewModel>();
- private bool upSignalData;
- private int rowCount = 2;
- private int columnCount = 2;
- private bool showLayout = false;
- private SignalPreviewViewModel()
- {
- this.ButtonVisibily = false;
- Content = typeof(Views.SignalPreviewView);
- SignalPreviews.Add(new AnalogSignalPreviewViewModel(AnalogType.Displacement));
- SignalPreviews.Add(new AnalogSignalPreviewViewModel(AnalogType.Acceleration));
- SignalPreviews.Add(new AnalogSignalPreviewViewModel(AnalogType.OutSignal));
- SignalPreviews.Add(new AnalogSignalPreviewViewModel(AnalogType.Driver));
- timer.AutoReset = false;
- timer.Elapsed += (_, _) =>
- {
- ShowLayout = true;
- };
- timer.Enabled = false;
- timer.Stop();
- }
- static SignalPreviewViewModel()
- {
- }
- public ICommand OneCommnad => new RelayCommand(One);
- private void One()
- {
- RowCount = 1;
- ColumnCount = 1;
- ShowLayout = false;
- }
- public ICommand OneTwoCommand=>new RelayCommand(OneTwo);
- private void OneTwo()
- {
- RowCount = 1;
- ColumnCount = 2;
- ShowLayout = false;
- }
- public ICommand TwoOneCommand=>new RelayCommand(TwoOne);
- private void TwoOne()
- {
- RowCount = 2;
- ColumnCount = 1;
- ShowLayout = false;
- }
- public ICommand TwoTwoCommand=>new RelayCommand(TwoTwo);
- private void TwoTwo()
- {
- RowCount = 2;
- ColumnCount = 2;
- ShowLayout = false;
- }
- public bool ShowLayout { get => showLayout; set =>SetProperty(ref showLayout , value); }
- private System.Timers.Timer timer = new System.Timers.Timer(1000);
- private bool buttonPointerOver;
- private bool panelPointerOver;
- public ICommand PointerExitedCommand=>new RelayCommand(PointerExited);
- private void PointerExited()
- {
- ButtonPointerOver = false;
- timer.Stop();
- }
- public bool ButtonPointerOver
- {
- get => buttonPointerOver;
- set
- {
- SetProperty(ref buttonPointerOver, value);
- ShowLayout = ShowLayout ? PanelPointerOver : (ButtonPointerOver || PanelPointerOver);
- }
- }
- public bool PanelPointerOver
- {
- get => panelPointerOver;
- set
- {
- SetProperty(ref panelPointerOver, value);
- ShowLayout = ShowLayout ? PanelPointerOver : (ButtonPointerOver || PanelPointerOver);
- }
- }
- public ICommand ControlPointerEnteredCommand=>new RelayCommand(ControlPointerEntered);
- private void ControlPointerEntered()
- {
- PanelPointerOver = true;
- }
- public ICommand ControlPointerExitedCommand => new RelayCommand(ControlPointerExited);
- private void ControlPointerExited()
- {
- PanelPointerOver = false;
- }
- public ICommand PointerEnteredCommand=>new RelayCommand(PointerEntered);
- private void PointerEntered()
- {
- ButtonPointerOver = true;
- ShowLayout = false;
- timer.Start();
- }
- public int RowCount { get => rowCount; set =>SetProperty(ref rowCount , value); }
- public int ColumnCount { get => columnCount; set =>SetProperty(ref columnCount , value); }
- public static SignalPreviewViewModel Instance { get; } = new SignalPreviewViewModel();
- public bool UpSignalData
- {
- get => upSignalData;
- set
- {
- upSignalData = value;
- foreach (var item in SignalPreviews)
- {
- item.UpSignalData = value;
- }
- }
- }
- }
- }
|