Skip to content

Commit

Permalink
Added support for checking screens info
Browse files Browse the repository at this point in the history
  • Loading branch information
chkam05 committed Jan 31, 2024
1 parent 5eefd9d commit 0c1c3f8
Show file tree
Hide file tree
Showing 11 changed files with 1,010 additions and 12 deletions.
22 changes: 16 additions & 6 deletions SystemController/Screens/Data/ScreenInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,14 @@ public bool IsInVirtualRange(int x, int y)
/// <summary> Map virtual area to oryignal area. </summary>
/// <param name="virtualRect"> Virtual area react. </param>
/// <returns> Area mapped to oryginal area. </returns>
public Rectangle MapToOryginalSize(Rectangle virtualRect)
public Rectangle MapToOryginalSize(Rectangle virtualRect, bool onlySize = false)
{
return MapToOryginalSize(virtualRect.X, virtualRect.Y, virtualRect.Width, virtualRect.Height);
return MapToOryginalSize(
virtualRect.X,
virtualRect.Y,
virtualRect.Width,
virtualRect.Height,
onlySize);
}

// --------------------------------------------------------------------------------
Expand All @@ -127,13 +132,14 @@ public Rectangle MapToOryginalSize(Rectangle virtualRect)
/// <param name="width"> Width. </param>
/// <param name="height"> Height. </param>
/// <returns> Area mapped to oryginal area. </returns>
public Rectangle MapToOryginalSize(double x, double y, double width, double height)
public Rectangle MapToOryginalSize(double x, double y, double width, double height, bool onlySize = false)
{
return MapToOryginalSize(
Convert.ToInt32(x),
Convert.ToInt32(y),
Convert.ToInt32(width),
Convert.ToInt32(height));
Convert.ToInt32(height),
onlySize);
}

// --------------------------------------------------------------------------------
Expand All @@ -143,9 +149,13 @@ public Rectangle MapToOryginalSize(double x, double y, double width, double heig
/// <param name="width"> Width. </param>
/// <param name="height"> Height. </param>
/// <returns> Area mapped to oryginal area. </returns>
public Rectangle MapToOryginalSize(int x, int y, int width, int height)
public Rectangle MapToOryginalSize(int x, int y, int width, int height, bool onlySize = false)
{
return new Rectangle(ScaleX(x), ScaleY(y), ScaleX(width), ScaleY(height));
return new Rectangle(
onlySize ? x :ScaleX(x),
onlySize ? y : ScaleY(y),
ScaleX(width),
ScaleY(height));
}

// --------------------------------------------------------------------------------
Expand Down
63 changes: 63 additions & 0 deletions SystemManager/Controls/KeyValueViewControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<UserControl
x:Class="SystemManager.Controls.KeyValueViewControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:cex="clr-namespace:chkam05.Tools.ControlsEx;assembly=chkam05.Tools.ControlsEx"
xmlns:cfg="clr-namespace:SystemManager.Data.Configuration"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SystemManager.Controls"
mc:Ignorable="d"

Background="{x:Null}"
BorderBrush="{x:Null}"
BorderThickness="0"
Foreground="{Binding ThemeForegroundBrush, Source={StaticResource AppearanceConfig}, Mode=OneWay}">

<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Themes/Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>

<!-- STATIC -->

<x:Static x:Key="AppearanceConfig" Member="cfg:AppearanceConfig.Instance"/>
<x:Static x:Key="ConfigManager" Member="cfg:ConfigManager.Instance"/>

</ResourceDictionary>
</UserControl.Resources>

<Border
Background="{Binding ThemeShadeBackgroundBrush, Source={StaticResource AppearanceConfig}, Mode=OneWay}"
BorderBrush="{Binding ThemeShadeBackgroundBrush, Source={StaticResource AppearanceConfig}, Mode=OneWay}"
BorderThickness="1"
CornerRadius="8"
Padding="8">

<Grid
VerticalAlignment="Center">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="160"/>
<ColumnDefinition Width="160"/>
</Grid.ColumnDefinitions>

<TextBlock
Grid.Column="0"
HorizontalAlignment="Left"
Text="{Binding Header, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=UserControl}}"
VerticalAlignment="Center"/>

<cex:TextBoxEx
Grid.Column="1"
HorizontalAlignment="Stretch"
IsReadOnly="True"
Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=UserControl}}"
VerticalAlignment="Center"/>

</Grid>

</Border>

</UserControl>
66 changes: 66 additions & 0 deletions SystemManager/Controls/KeyValueViewControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;

namespace SystemManager.Controls
{
public partial class KeyValueViewControl : UserControl
{

// DEPENDENCY PROPERTIES

public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(
nameof(Header),
typeof(string),
typeof(KeyValueViewControl),
new PropertyMetadata(""));

public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
nameof(Value),
typeof(string),
typeof(KeyValueViewControl),
new PropertyMetadata(""));


// GETTERS & SETTERS

public string Header
{
get { return (string)GetValue(HeaderProperty); }
set { SetValue(HeaderProperty, value); }
}

public string Value
{
get { return (string)GetValue(HeaderProperty); }
set { SetValue(HeaderProperty, value); }
}


// METHODS

#region CLASS METHODS

// --------------------------------------------------------------------------------
/// <summary> KeyValueViewControl class constructor. </summary>
public KeyValueViewControl()
{
// Initialize user interface.
InitializeComponent();
}

#endregion CLASS METHODS

}
}
93 changes: 93 additions & 0 deletions SystemManager/Data/Screens/ScreensDataContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SystemController.Screens;
using SystemController.Screens.Data;
using SystemManager.ViewModels.Base;
using SystemManager.ViewModels.Screens;

namespace SystemManager.Data.Screens
{
public class ScreensDataContext : BaseViewModel
{

// VARIABLES

private ObservableCollection<ScreenInfoViewModel> _screensCollection = new ObservableCollection<ScreenInfoViewModel>();
private ScreenInfoViewModel _selectedScreen;


// GETTERS & SETTERS

public ObservableCollection<ScreenInfoViewModel> ScreensCollection
{
get => _screensCollection;
set
{
UpdateProperty(ref _screensCollection, value);
_screensCollection.CollectionChanged += ScreensCollectionChanged;
}
}

public ScreenInfoViewModel SelectedScreen
{
get => _selectedScreen;
set => UpdateProperty(ref _selectedScreen, value);
}


// METHODS

#region CLASS METHODS

// --------------------------------------------------------------------------------
/// <summary> ScreensDataContext class constructor. </summary>
public ScreensDataContext()
{
ReloadScreens();
}

#endregion CLASS METHODS

#region PROPERITES CHANGED METHODS

// --------------------------------------------------------------------------------
/// <summary> Method invoked after Screens collection changed. </summary>
/// <param name="sender"> Object that invoked the method. </param>
/// <param name="e"> Notify Collection Changed Event Arguments. </param>
private void ScreensCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
OnPropertyChanged(nameof(ScreensCollection));
}

#endregion PROPERITES CHANGED METHODS

#region SCREENS MANAGEMENT METHODS

// --------------------------------------------------------------------------------
/// <summary> Reload screens. </summary>
public void ReloadScreens()
{
ScreensCollection = new ObservableCollection<ScreenInfoViewModel>(
ScreenManager.GetAllScreens().Select(s => new ScreenInfoViewModel(s)));
}

// --------------------------------------------------------------------------------
/// <summary> Select screen. </summary>
/// <param name="deviceName"> Screen device name. </param>
public void SelectScreen(string deviceName)
{
var screen = ScreensCollection.FirstOrDefault(s => s.DeviceName == deviceName);

if (screen != null)
SelectedScreen = screen;
}

#endregion SCREENS MANAGEMENT METHODS

}
}
10 changes: 6 additions & 4 deletions SystemManager/InternalMessages/ScreenSelectInternalMessage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Background="{Binding ThemeBackgroundBrush, Source={StaticResource AppearanceConfig}, Mode=OneWay}"
BorderBrush="{Binding AccentColorBrush, Source={StaticResource AppearanceConfig}, Mode=OneWay}"
BottomBackground="{Binding ThemeShadeBackgroundBrush, Source={StaticResource AppearanceConfig}, Mode=OneWay}"
BottomBorderBrush="{Binding AccentColorBrush, Source={StaticResource AppearanceConfig}, Mode=OneWay}"
BottomBorderBrush="{Binding ThemeShadeBackgroundBrush, Source={StaticResource AppearanceConfig}, Mode=OneWay}"
BottomPadding="8"
ButtonBackground="{Binding AccentColorBrush, Source={StaticResource AppearanceConfig}, Mode=OneWay}"
ButtonBorderBrush="{Binding AccentColorBrush, Source={StaticResource AppearanceConfig}, Mode=OneWay}"
Expand Down Expand Up @@ -55,14 +55,16 @@
<cex:ScrollViewerEx
x:Name="_scorllViewer"
HorizontalAlignment="Stretch"
HorizontalScrollBarVisibility="Visible"
HorizontalScrollBarVisibility="Auto"
MinHeight="256"
MinWidth="512"
VerticalAlignment="Stretch"
VerticalScrollBarVisibility="Visible">
VerticalScrollBarVisibility="Auto">

<Canvas
x:Name="_canvas"/>
x:Name="_canvas"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>

</cex:ScrollViewerEx>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class ScreenSelectInternalMessage : StandardInternalMessageEx

// CONST

private const double SCALING = 0.25d;
private const double SCALING = 0.10d;


// VARIABLES
Expand Down
Loading

0 comments on commit 0c1c3f8

Please sign in to comment.