// SPDX-License-Identifier: AGPL-3.0-only
/**
* Digital Voice Modem - Desktop Dispatch Console
* AGPLv3 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Desktop Dispatch Console
* @license AGPLv3 License (https://opensource.org/licenses/AGPL-3.0)
*
* Copyright (C) 2025 Caleb, K4PHP
*
*/
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Media;
namespace dvmconsole
{
///
///
///
public class CallHistoryViewModel
{
/*
** Properties
*/
///
///
///
public ObservableCollection CallHistory { get; set; }
/*
** Methods
*/
///
/// Initializes a new instance of the class.
///
public CallHistoryViewModel()
{
CallHistory = new ObservableCollection();
}
} // public class CallHistoryViewModel
///
///
///
public class CallEntry : DependencyObject
{
public static readonly DependencyProperty BackgroundColorProperty =
DependencyProperty.Register(nameof(BackgroundColor), typeof(Brush), typeof(CallEntry), new PropertyMetadata(Brushes.Transparent));
/*
** Properties
*/
///
///
///
public string Channel { get; set; }
///
///
///
public int SrcId { get; set; }
///
///
///
public int DstId { get; set; }
///
///
///
public Brush BackgroundColor
{
get { return (Brush)GetValue(BackgroundColorProperty); }
set { SetValue(BackgroundColorProperty, value); }
}
} // public class CallEntry : DependencyObject
///
/// Interaction logic for CallHistoryWindow.xaml.
///
public partial class CallHistoryWindow : Window
{
/*
** Properties
*/
///
///
///
public CallHistoryViewModel ViewModel { get; set; }
/*
** Methods
*/
///
/// Initializes a new instance of the class.
///
public CallHistoryWindow()
{
InitializeComponent();
ViewModel = new CallHistoryViewModel();
DataContext = ViewModel;
}
///
///
///
///
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
this.Hide();
}
///
///
///
///
///
///
public void AddCall(string channel, int srcId, int dstId)
{
Dispatcher.Invoke(() =>
{
ViewModel.CallHistory.Insert(0, new CallEntry
{
Channel = channel,
SrcId = srcId,
DstId = dstId,
BackgroundColor = Brushes.Transparent
});
});
}
///
///
///
///
///
///
public void ChannelKeyed(string channel, int srcId, bool encrypted)
{
Dispatcher.Invoke(() =>
{
foreach (var entry in ViewModel.CallHistory.Where(c => c.Channel == channel && c.SrcId == srcId))
{
if (!encrypted)
entry.BackgroundColor = Brushes.LightGreen;
else
entry.BackgroundColor = Brushes.Orange;
}
});
}
///
///
///
///
///
public void ChannelUnkeyed(string channel, int srcId)
{
Dispatcher.Invoke(() =>
{
foreach (var entry in ViewModel.CallHistory.Where(c => c.Channel == channel && c.SrcId == srcId))
{
entry.BackgroundColor = Brushes.Transparent;
}
});
}
} // public partial class CallHistoryWindow : Window
} // namespace dvmconsole