Skip to content

Commit

Permalink
🔥 Introduce SatelliteHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
SydneyOwl committed May 15, 2024
1 parent 3c629cd commit aedd0c9
Show file tree
Hide file tree
Showing 9 changed files with 507 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Views/Common/HintWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
WindowStartupLocation="CenterScreen">
<Canvas>
<ScrollViewer VerticalScrollBarVisibility="Auto" Width="250" Height="250">
<SelectableTextBlock Name="tbContent" TextWrapping="Wrap" />
<SelectableTextBlock Name="tbContent" TextWrapping="Wrap" Width="220"/>
</ScrollViewer>
<Button Canvas.Bottom="20" Canvas.Left="100" Content="关闭" Name="button" Click="Button_OnClick" />
</Canvas>
Expand Down
10 changes: 5 additions & 5 deletions Views/Gt12/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@
<PathIcon Data="{StaticResource channel_regular}" />
</MenuItem.Icon>
</MenuItem>
<!-- <MenuItem Header="打星助手"> -->
<!-- <MenuItem.Icon> -->
<!-- <PathIcon Data="{StaticResource channel_regular}"/> -->
<!-- </MenuItem.Icon> -->
<!-- </MenuItem> -->
<MenuItem Header="打星助手" Click="SatMenuItem_OnClick">
<MenuItem.Icon>
<PathIcon Data="{StaticResource channel_regular}"/>
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Header="其他">
<MenuItem Header="主题色">
Expand Down
44 changes: 44 additions & 0 deletions Views/Gt12/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,4 +597,48 @@ private void BootImageMenuItem_OnClick(object? sender, RoutedEventArgs e)
{
new BootImageImportWindow(SHX_DEVICE.GT12).ShowDialog(this);
}

private void SatMenuItem_OnClick(object? sender, RoutedEventArgs e)
{
new SatelliteHelperWindow(InsertNewChannel).ShowDialog(this);
}
private void InsertNewChannel(string rx, string dec, string tx, string enc, string name)
{
var lastEmptyIndex = -1;
for (var i = ListItems.Count - 1; i >= 0; i--)
{
if (!ListItems[i].IsVisable)
{
lastEmptyIndex = i;
}
else
{
break;
}
}

if (lastEmptyIndex == -1)
{
throw new IndexOutOfRangeException("信道空间已满,无法插入!");
}

var data = new Channel
{
Id = lastEmptyIndex,
RxFreq = rx,
StrRxCtsDcs = dec,
TxFreq = tx,
StrTxCtsDcs = enc,
TxPower = 0,
Bandwide = 0,
ScanAdd = 0,
SignalGroup = 0,
SqMode = 0,
Pttid = 0,
SignalSystem = 0,
IsVisable = true,
Name = name
};
ListItems[lastEmptyIndex] = data;
}
}
2 changes: 1 addition & 1 deletion Views/Plugin/BootImageImportWindow.axaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="390"
Width="400" Height="{Binding windowHeight}"
x:Class="SenhaixFreqWriter.Views.Plugin.BootImageImportWindow"
xmlns:vm="using:SenhaixFreqWriter.Views.Plugin"
x:DataType="vm:BootImageImportWindow"
Expand Down
8 changes: 5 additions & 3 deletions Views/Plugin/BootImageImportWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
using MsBox.Avalonia;
Expand All @@ -25,6 +23,8 @@ public partial class BootImageImportWindow : Window
public int bootImgWidth { get; set; }
public int bootImgHeight { get; set; }

public int windowHeight { get; set; }

public string hint { get; set; }

public BootImageImportWindow(SHX_DEVICE dev)
Expand All @@ -36,11 +36,13 @@ public BootImageImportWindow(SHX_DEVICE dev)
bootImgWidth = Constants.Shx8x00.OTHERS.BOOT_IMG_WIDTH;
bootImgHeight = Constants.Shx8x00.OTHERS.BOOT_IMG_HEIGHT;
hint = $"尺寸限制:{bootImgWidth}x{bootImgHeight},建议bmp格式";
windowHeight = 200;
break;
case SHX_DEVICE.GT12:
bootImgWidth = Constants.Gt12.OTHERS.BOOT_IMG_WIDTH;
bootImgHeight = Constants.Gt12.OTHERS.BOOT_IMG_HEIGHT;
hint = $"尺寸限制:{bootImgWidth}x{bootImgHeight},建议bmp格式";
windowHeight = 390;
break;
}
InitializeComponent();
Expand Down
55 changes: 55 additions & 0 deletions Views/Plugin/SatelliteHelperWindow.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="500" Height="550"
x:Class="SenhaixFreqWriter.Views.Plugin.SatelliteHelperWindow"
xmlns:vm="using:SenhaixFreqWriter.Views.Plugin"
x:DataType="vm:SatelliteHelperWindow"
Title="打星助手">
<Canvas>
<Label Content="搜索:" Margin="20"></Label>
<TextBox Canvas.Top="15" Canvas.Left="70" Width="100" TextChanged="SearchTextBox_OnTextChanged"></TextBox>

<Label Content="选择一个卫星:" Canvas.Left="20" Canvas.Top="60"></Label>
<ListBox Name="satListBox" ItemsSource="{Binding namelist}" Height="330"
Width="150" Canvas.Top="100" Canvas.Left="20"
SelectionChanged="SatListBox_OnSelectionChanged"/>

<Label Content="卫星详情:" Canvas.Left="220" Canvas.Top="60"></Label>
<TextBox Width="250" Height="130" IsReadOnly="True"
Canvas.Top="100" Canvas.Left="220" Name="selectedSatelliteInfo"></TextBox>

<Label Content="选择模式:" Canvas.Left="220" Canvas.Top="240"></Label>
<ListBox Name="modeListBox" ItemsSource="" Height="160"
Width="250" Canvas.Top="270" Canvas.Left="220"
SelectionChanged="ModeListBox_OnSelectionChanged"/>

<Border Width="260" Height="95" BorderBrush="Black" BorderThickness="1"
Canvas.Top="440" Canvas.Left="10"></Border>
<CheckBox Canvas.Top="470" Canvas.Left="20" IsChecked="True" Name="doppler"></CheckBox>
<Label Content="多普勒" Canvas.Top="475" Canvas.Left="40"></Label>

<Label Content="U段±" Canvas.Top="450" Canvas.Left="100"></Label>
<TextBox Canvas.Top="445" Canvas.Left="145" Name="uoffset" Text="10"></TextBox>
<Label Content="kHz" Canvas.Top="450" Canvas.Left="220"></Label>

<Label Content="V段±" Canvas.Top="500" Canvas.Left="100"></Label>
<TextBox Canvas.Top="495" Canvas.Left="145" Name="voffset" Text="5"></TextBox>
<Label Content="kHz" Canvas.Top="500" Canvas.Left="220"></Label>

<Button HorizontalAlignment="Left" Canvas.Top="440" Canvas.Left="350" Name="FetchSat" Click="FetchSatDataButton_OnClick">
<StackPanel Orientation="Horizontal">
<PathIcon Data="{StaticResource arrow_sync_regular}" Margin="0,0,10,0" />
<TextBlock Text="更新星历" VerticalAlignment="Center" Name="FetchSatText"/>
</StackPanel>
</Button>

<Button HorizontalAlignment="Left" Canvas.Top="500" Canvas.Left="350" Click="InsertChannelButton_OnClick" Name="insertChannel" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<PathIcon Data="{StaticResource channel_regular}" Margin="0,0,10,0" />
<TextBlock Text="插入信道" VerticalAlignment="Center" />
</StackPanel>
</Button>
</Canvas>
</Window>
Loading

0 comments on commit aedd0c9

Please sign in to comment.