You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
172 lines
4.0 KiB
172 lines
4.0 KiB
@page "/control" |
|
@using Pages |
|
@using System.Numerics |
|
@using EGFramework |
|
@implements IEGFramework |
|
@rendermode InteractiveServer |
|
|
|
<PageTitle>靶机控制</PageTitle> |
|
|
|
<h1>靶机控制</h1> |
|
|
|
<div class="control-panel"> |
|
|
|
<div class="control-section"> |
|
<button class="btn @(isTargetActive ? "btn-danger" : "btn-success")" |
|
@onclick="ToggleTarget" |
|
disabled="@isTargetOperationInProgress"> |
|
@if (isTargetOperationInProgress) |
|
{ |
|
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> |
|
<span>@(isTargetActive ? "停止中..." : "启动中...")</span> |
|
} |
|
else |
|
{ |
|
<span>@(isTargetActive ? "停止靶机" : "启动靶机")</span> |
|
} |
|
</button> |
|
</div> |
|
|
|
@if (isMoving) |
|
{ |
|
<div class="moving-overlay"> |
|
<div class="spinner-border text-primary" role="status"> |
|
<span class="visually-hidden">移动中...</span> |
|
</div> |
|
<p>空轨移动中,请等待...</p> |
|
</div> |
|
} |
|
</div> |
|
|
|
@code { |
|
private DataActionStatus dataActionStatus = new DataActionStatus { Position = 0, Rotate = 0 }; |
|
private bool isMoving = false; |
|
private bool isTargetActive = false; |
|
private bool isTargetOperationInProgress = false; |
|
public ModelTrackControl ModelTrackControl { set; get; } |
|
protected override void OnInitialized() |
|
{ |
|
ModelTrackControl = this.GetModule<ModelTrackControl>(); |
|
} |
|
|
|
private async Task ToggleTarget() |
|
{ |
|
if (isTargetOperationInProgress) return; |
|
|
|
isTargetOperationInProgress = true; |
|
StateHasChanged(); |
|
|
|
|
|
|
|
isTargetActive = !isTargetActive; |
|
if(isTargetActive){ |
|
this.ModelTrackControl.StartTarget(); |
|
}else{ |
|
this.ModelTrackControl.RevertTarget(); |
|
} |
|
// 模拟靶机操作延迟 |
|
await Task.Delay(2000); |
|
|
|
dataActionStatus.Rotate = isTargetActive ? 90 : 0; |
|
|
|
isTargetOperationInProgress = false; |
|
StateHasChanged(); |
|
} |
|
|
|
} |
|
|
|
<style> |
|
.control-panel { |
|
position: relative; |
|
max-width: 800px; |
|
margin: 0 auto; |
|
padding: 20px; |
|
border: 1px solid #dee2e6; |
|
border-radius: 8px; |
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1); |
|
} |
|
|
|
.control-section { |
|
margin-bottom: 25px; |
|
} |
|
|
|
.slider-container { |
|
display: flex; |
|
flex-direction: column; |
|
gap: 10px; |
|
position: relative; |
|
margin-bottom: 15px; |
|
} |
|
|
|
.position-markers { |
|
position: relative; |
|
height: 20px; |
|
width: 100%; |
|
} |
|
|
|
.position-marker { |
|
position: absolute; |
|
width: 12px; |
|
height: 12px; |
|
border-radius: 50%; |
|
transform: translateX(-50%); |
|
top: 4px; |
|
border: 2px solid white; |
|
box-shadow: 0 0 2px rgba(0,0,0,0.5); |
|
} |
|
|
|
.location-slider { |
|
width: 100%; |
|
} |
|
|
|
.slider-value { |
|
text-align: center; |
|
font-weight: bold; |
|
margin-top: 5px; |
|
} |
|
|
|
.location-buttons { |
|
display: flex; |
|
flex-wrap: wrap; |
|
gap: 10px; |
|
justify-content: center; |
|
} |
|
|
|
.location-btn { |
|
flex: 1; |
|
min-width: 120px; |
|
border: none; |
|
} |
|
|
|
.color-display { |
|
height: 80px; |
|
display: flex; |
|
align-items: center; |
|
justify-content: center; |
|
border-radius: 5px; |
|
color: white; |
|
text-shadow: 1px 1px 2px rgba(0,0,0,0.7); |
|
font-weight: bold; |
|
} |
|
|
|
.status-display { |
|
background-color: #f8f9fa; |
|
padding: 15px; |
|
border-radius: 5px; |
|
margin-bottom: 20px; |
|
} |
|
|
|
.moving-overlay { |
|
position: absolute; |
|
top: 0; |
|
left: 0; |
|
right: 0; |
|
bottom: 0; |
|
background-color: rgba(255, 255, 255, 0.8); |
|
display: flex; |
|
flex-direction: column; |
|
justify-content: center; |
|
align-items: center; |
|
z-index: 100; |
|
} |
|
</style> |