mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 10:10:45 +08:00
feat.完成界面重构
This commit is contained in:
@@ -167,7 +167,7 @@ bool asst::Assistance::append_fight(int mecidine, int stone, int times, bool onl
|
||||
|
||||
bool asst::Assistance::append_award(bool only_append)
|
||||
{
|
||||
return append_process_task("AwardBegin", "ReceiveAward");
|
||||
return append_process_task("AwardBegin", "Award");
|
||||
}
|
||||
|
||||
bool asst::Assistance::append_visit(bool only_append)
|
||||
|
||||
@@ -50,10 +50,21 @@ bool asst::InfrastProductionTask::shift_facility_list()
|
||||
MultiMatchImageAnalyzer locked_analyzer;
|
||||
locked_analyzer.set_task_info(*locked_task_ptr);
|
||||
|
||||
int index = 0;
|
||||
for (const Rect& tab : m_facility_list_tabs) {
|
||||
if (need_exit()) {
|
||||
return false;
|
||||
}
|
||||
if (index != 0) {
|
||||
json::value enter_json = json::object{
|
||||
{ "facility", m_facility },
|
||||
{ "index", index }
|
||||
};
|
||||
m_callback(AsstMsg::EnterFacility, enter_json, m_callback_arg);
|
||||
}
|
||||
|
||||
++index;
|
||||
|
||||
ctrler.click(tab);
|
||||
sleep(tab_task_ptr->rear_delay);
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace MeoAsstGui
|
||||
break;
|
||||
|
||||
case AsstMsg.EnterFacility:
|
||||
tvm.AddLog("当前正在换班:" + detail["facility"]);
|
||||
tvm.AddLog("当前设施:" + detail["facility"] + " " + (int)detail["index"]);
|
||||
break;
|
||||
|
||||
case AsstMsg.FacilityInfo:
|
||||
|
||||
125
src/MeoAsstGui/Helper/ScrollViewerBinding.cs
Normal file
125
src/MeoAsstGui/Helper/ScrollViewerBinding.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
// MeoAssistanceGui - A part of the MeoAssistance-Arknight project
|
||||
// Copyright (C) 2021 MistEO and Contributors
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
|
||||
namespace MeoAsstGui
|
||||
{
|
||||
public static class ScrollViewerBinding
|
||||
{
|
||||
#region VerticalOffset attached property
|
||||
|
||||
/// <summary>
|
||||
/// VerticalOffset attached property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty VerticalOffsetProperty =
|
||||
DependencyProperty.RegisterAttached("VerticalOffset", typeof(double),
|
||||
typeof(ScrollViewerBinding), new FrameworkPropertyMetadata(double.NaN,
|
||||
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
||||
OnVerticalOffsetPropertyChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Just a flag that the binding has been applied.
|
||||
/// </summary>
|
||||
private static readonly DependencyProperty VerticalScrollBindingProperty =
|
||||
DependencyProperty.RegisterAttached("VerticalScrollBinding", typeof(bool?), typeof(ScrollViewerBinding));
|
||||
|
||||
public static double GetVerticalOffset(DependencyObject depObj)
|
||||
{
|
||||
ScrollViewer scrollViewer = depObj as ScrollViewer;
|
||||
if (scrollViewer == null)
|
||||
return 0;
|
||||
double maxHeight = scrollViewer.ScrollableHeight;
|
||||
return (double)depObj.GetValue(VerticalOffsetProperty) / maxHeight;
|
||||
}
|
||||
|
||||
public static void SetVerticalOffset(DependencyObject depObj, double value)
|
||||
{
|
||||
if (value <= 1)
|
||||
{
|
||||
// by set
|
||||
ScrollViewer scrollViewer = depObj as ScrollViewer;
|
||||
if (scrollViewer == null)
|
||||
return;
|
||||
double maxHeight = scrollViewer.ScrollableHeight;
|
||||
|
||||
depObj.SetValue(VerticalOffsetProperty, value * maxHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
// by scroll
|
||||
depObj.SetValue(VerticalOffsetProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnVerticalOffsetPropertyChanged(DependencyObject d,
|
||||
DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
ScrollViewer scrollViewer = d as ScrollViewer;
|
||||
if (scrollViewer == null)
|
||||
return;
|
||||
|
||||
BindVerticalOffset(scrollViewer);
|
||||
scrollViewer.ScrollToVerticalOffset((double)e.NewValue);
|
||||
}
|
||||
|
||||
public static void BindVerticalOffset(ScrollViewer scrollViewer)
|
||||
{
|
||||
if (scrollViewer.GetValue(VerticalScrollBindingProperty) != null)
|
||||
return;
|
||||
|
||||
scrollViewer.SetValue(VerticalScrollBindingProperty, true);
|
||||
scrollViewer.ScrollChanged += (s, se) =>
|
||||
{
|
||||
if (se.VerticalChange == 0)
|
||||
return;
|
||||
SetVerticalOffset(scrollViewer, se.VerticalOffset);
|
||||
};
|
||||
}
|
||||
|
||||
#endregion VerticalOffset attached property
|
||||
|
||||
#region ScrollableHeight attached property
|
||||
|
||||
//public static readonly DependencyProperty ScrollableHeightProperty =
|
||||
// DependencyProperty.RegisterAttached("ScrollableHeight", typeof(double),
|
||||
// typeof(ScrollViewerBinding), new FrameworkPropertyMetadata(double.NaN, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnScrollableHeightPropertyChanged));
|
||||
|
||||
//public static double GetScrollableHeight(DependencyObject depObj)
|
||||
//{
|
||||
// ScrollViewer scrollViewer = depObj as ScrollViewer;
|
||||
// if (scrollViewer == null)
|
||||
// return 0;
|
||||
// return scrollViewer.ScrollableHeight;
|
||||
//}
|
||||
|
||||
//public static void SetScrollableHeight(DependencyObject depObj, double value)
|
||||
//{
|
||||
// // pass
|
||||
//}
|
||||
|
||||
//private static readonly DependencyProperty ScrollableHeightBindingProperty =
|
||||
// DependencyProperty.RegisterAttached("ScrollableHeightBinding", typeof(bool?), typeof(ScrollViewerBinding));
|
||||
|
||||
//private static void OnScrollableHeightPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
//{
|
||||
//}
|
||||
|
||||
#endregion ScrollableHeight attached property
|
||||
}
|
||||
}
|
||||
@@ -113,6 +113,7 @@
|
||||
<Compile Include="Helper\AsstProxy.cs" />
|
||||
<Compile Include="Helper\AutoScroll.cs" />
|
||||
<Compile Include="Helper\LogItemViewModel.cs" />
|
||||
<Compile Include="Helper\ScrollViewerBinding.cs" />
|
||||
<Compile Include="Helper\ViewStatusStorage.cs" />
|
||||
<Compile Include="Helper\FlowDocumentPagePadding.cs" />
|
||||
<Compile Include="UserControl\AutoRecruitSettingsUserControl.xaml.cs">
|
||||
|
||||
@@ -32,8 +32,8 @@ namespace MeoAsstGui
|
||||
_listTitle.Add("自动公招");
|
||||
_listTitle.Add("信用商店");
|
||||
_listTitle.Add("企鹅数据");
|
||||
_listTitle.Add("连接");
|
||||
_listTitle.Add("其他");
|
||||
//_listTitle.Add("连接");
|
||||
//_listTitle.Add("其他");
|
||||
|
||||
InfrastInit();
|
||||
}
|
||||
@@ -211,6 +211,60 @@ namespace MeoAsstGui
|
||||
}
|
||||
}
|
||||
|
||||
// 消息源,0:无;1:SelectedIndex;2:ScrollOffset
|
||||
private int _notifySource = 0;
|
||||
|
||||
private int _selectedIndex = 0;
|
||||
|
||||
public int SelectedIndex
|
||||
{
|
||||
get { return _selectedIndex; }
|
||||
set
|
||||
{
|
||||
if (_notifySource != 1)
|
||||
{
|
||||
if (_notifySource == 0)
|
||||
{
|
||||
_notifySource = 1;
|
||||
}
|
||||
ScrollOffset = (double)value / (ListTitle.Count - 1);
|
||||
SetAndNotify(ref _selectedIndex, value);
|
||||
}
|
||||
_notifySource = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private double _scrollOffset = 0;
|
||||
|
||||
public double ScrollOffset
|
||||
{
|
||||
get { return _scrollOffset; }
|
||||
set
|
||||
{
|
||||
if (_notifySource != 2)
|
||||
{
|
||||
if (_notifySource == 0)
|
||||
{
|
||||
_notifySource = 2;
|
||||
}
|
||||
SelectedIndex = (int)(value / ScrollHeight * (ListTitle.Count - 1));
|
||||
SetAndNotify(ref _scrollOffset, value);
|
||||
}
|
||||
_notifySource = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private double _scrollHeight = 258; // ScrollViewer.ScrollableHeight, 不知道该咋获取,默认值是258
|
||||
|
||||
public double ScrollHeight
|
||||
{
|
||||
get { return _scrollHeight; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _scrollHeight, value);
|
||||
}
|
||||
}
|
||||
|
||||
/* 信用商店设置 */
|
||||
|
||||
private bool _creditShopping = System.Convert.ToBoolean(ViewStatusStorage.Get("Mall.CreditShopping", bool.FalseString));
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace MeoAsstGui
|
||||
TaskItemViewModels.Add(new DragItemViewModel("领取日常奖励", stroageKey));
|
||||
}
|
||||
|
||||
public void AddLog(string content, string color = "Black", string weight = "Regular")
|
||||
public void AddLog(string content, string color = "Gray", string weight = "Regular")
|
||||
{
|
||||
LogItemViewModels.Add(new LogItemViewModel(content, color, weight));
|
||||
//LogItemViewModels.Insert(0, new LogItemViewModel(time + content, color, weight));
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding"
|
||||
xmlns:local="clr-namespace:MeoAsstGui"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="495" d:DesignWidth="800">
|
||||
@@ -12,17 +13,24 @@
|
||||
<ColumnDefinition Width="175" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListBox ItemsSource="{Binding ListTitle}" Grid.Column="0" Margin="10"
|
||||
IsSynchronizedWithCurrentItem="true" />
|
||||
<ScrollViewer HorizontalAlignment="Stretch" Grid.Column="1" Margin="20, 10">
|
||||
<ListBox x:Name="MasterListBox" ItemsSource="{Binding ListTitle}" Grid.Column="0" Margin="10"
|
||||
IsSynchronizedWithCurrentItem="true" SelectedIndex="{Binding SelectedIndex}" />
|
||||
|
||||
<ScrollViewer local:ScrollViewerBinding.VerticalOffset="{Binding ScrollOffset}"
|
||||
HorizontalAlignment="Stretch" Grid.Column="1" Margin="20, 10">
|
||||
<!--local:ScrollViewerBinding.ScrollableHeight="{Binding ScrollHeight, Mode=OneWayToSource}"-->
|
||||
<StackPanel IsEnabled="{Binding Idle}">
|
||||
<Rectangle HorizontalAlignment="Stretch" Fill="LightGray" Height="1" />
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="{Binding ListTitle[0]}" Foreground="Gray" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" />
|
||||
<local:InfrastSettingsUserControl Margin="20" />
|
||||
<Rectangle HorizontalAlignment="Stretch" Fill="LightGray" Height="1" />
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="{Binding ListTitle[1]}" Foreground="Gray" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" />
|
||||
<local:AutoRecruitSettingsUserControl Margin="20" />
|
||||
<Rectangle HorizontalAlignment="Stretch" Fill="LightGray" Height="1" />
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="{Binding ListTitle[2]}" Foreground="Gray" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" />
|
||||
<local:MallSettingsUserControl Margin="20" />
|
||||
<Rectangle HorizontalAlignment="Stretch" Fill="LightGray" Height="1" />
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="{Binding ListTitle[3]}" Foreground="Gray" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" />
|
||||
<local:PenguinReportSettingsUserControl Margin="20" />
|
||||
<!--<Rectangle HorizontalAlignment="Stretch" Fill="LightGray" Height="1" />-->
|
||||
</StackPanel>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Time}"
|
||||
<TextBlock Text="{Binding Time}" Foreground="Gray"
|
||||
Style="{StaticResource TextBlockDefault}" TextWrapping="Wrap" Margin="5, 5" />
|
||||
<TextBlock Text="{Binding Content}" Foreground="{Binding Color}" FontWeight="{Binding Weight}"
|
||||
Style="{StaticResource TextBlockDefault}" TextWrapping="Wrap" Margin="5, 5" />
|
||||
|
||||
Reference in New Issue
Block a user