fix edit page loading
This commit is contained in:
parent
5e1344d9d5
commit
05a0eab829
|
@ -35,7 +35,7 @@
|
||||||
ManipulationMode="TranslateX,TranslateY" ManipulationDelta="MainScroll_ManipulationDelta"
|
ManipulationMode="TranslateX,TranslateY" ManipulationDelta="MainScroll_ManipulationDelta"
|
||||||
Loading="MainScroll_Loading">
|
Loading="MainScroll_Loading">
|
||||||
<Viewbox Width="{Binding Width, Source={StaticResource previewStyle}, Mode=OneWay}" Height="{Binding Height, Source={StaticResource previewStyle}, Mode=OneWay}">
|
<Viewbox Width="{Binding Width, Source={StaticResource previewStyle}, Mode=OneWay}" Height="{Binding Height, Source={StaticResource previewStyle}, Mode=OneWay}">
|
||||||
<Image x:Name="MainPreview" Source="{x:Bind PreviewModel.Source, Mode=OneWay}" ImageOpened="Image_Loaded">
|
<Image x:Name="MainPreview" Source="{x:Bind PreviewModel.Source, Mode=OneWay}">
|
||||||
<Image.ContextFlyout>
|
<Image.ContextFlyout>
|
||||||
<MenuFlyout>
|
<MenuFlyout>
|
||||||
<MenuFlyoutItem x:Name="MainPreviewRefresh" Text="Refresh" Click="MainPreviewRefresh_Click" />
|
<MenuFlyoutItem x:Name="MainPreviewRefresh" Text="Refresh" Click="MainPreviewRefresh_Click" />
|
||||||
|
@ -76,7 +76,6 @@
|
||||||
Source="{x:Bind Source, Mode=OneWay}"
|
Source="{x:Bind Source, Mode=OneWay}"
|
||||||
Opacity="{x:Bind Deleted, Mode=OneWay, Converter={StaticResource opacityConverter}}"
|
Opacity="{x:Bind Deleted, Mode=OneWay, Converter={StaticResource opacityConverter}}"
|
||||||
Tapped="Image_Tapped"
|
Tapped="Image_Tapped"
|
||||||
ImageOpened="Image_Loaded"
|
|
||||||
Tag="{x:Bind Id}">
|
Tag="{x:Bind Id}">
|
||||||
<Image.ContextFlyout>
|
<Image.ContextFlyout>
|
||||||
<MenuFlyout>
|
<MenuFlyout>
|
||||||
|
|
|
@ -12,6 +12,7 @@ using PCUT.ViewModels;
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Input;
|
using Windows.UI.Xaml.Input;
|
||||||
|
using Windows.UI.Xaml.Media.Imaging;
|
||||||
using Windows.UI.Xaml.Navigation;
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
|
||||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
||||||
|
@ -86,9 +87,9 @@ namespace PCUT.Pages
|
||||||
if (_svgData.Data != null)
|
if (_svgData.Data != null)
|
||||||
{
|
{
|
||||||
LoadingModel.SetCount(_svgData.ComponentCount + dataUnloaded);
|
LoadingModel.SetCount(_svgData.ComponentCount + dataUnloaded);
|
||||||
PreviewModel.SetSource(_svgData.Data);
|
PreviewModel.SetSource(_svgData.Data, Image_Loaded);
|
||||||
foreach (var (id, deleted, component) in _svgData.ComponentData)
|
foreach (var (id, deleted, component) in _svgData.ComponentData)
|
||||||
ComponentModel.AddSource(id, deleted, component);
|
ComponentModel.AddSource(id, deleted, component, Image_Loaded);
|
||||||
}
|
}
|
||||||
if (!UserContext.Instance.IsPermittedEdit)
|
if (!UserContext.Instance.IsPermittedEdit)
|
||||||
_designCenterModel.SelectedHeightIndex = 0;
|
_designCenterModel.SelectedHeightIndex = 0;
|
||||||
|
@ -157,9 +158,10 @@ namespace PCUT.Pages
|
||||||
((ComponentStyle)Resources["componentStyle"]).SetSize(ComponentColumnDefinition, rate: 3);
|
((ComponentStyle)Resources["componentStyle"]).SetSize(ComponentColumnDefinition, rate: 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Image_Loaded(object sender, RoutedEventArgs e)
|
private void Image_Loaded(SvgImageSource sender, SvgImageSourceOpenedEventArgs e)
|
||||||
{
|
{
|
||||||
LoadingModel.DecreaseCount();
|
LoadingModel.DecreaseCount();
|
||||||
|
sender.Opened -= Image_Loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AllImageLoaded(object sender, PropertyChangedEventArgs e)
|
private void AllImageLoaded(object sender, PropertyChangedEventArgs e)
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using PCUT.Extensions;
|
using PCUT.Extensions;
|
||||||
|
using Windows.Foundation;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Media;
|
using Windows.UI.Xaml.Media;
|
||||||
using Windows.UI.Xaml.Media.Imaging;
|
using Windows.UI.Xaml.Media.Imaging;
|
||||||
|
@ -13,9 +14,13 @@ namespace PCUT.ViewModels
|
||||||
{
|
{
|
||||||
public ObservableCollection<ComponentImageSource> ComponentList { get; } = new ObservableCollection<ComponentImageSource>();
|
public ObservableCollection<ComponentImageSource> ComponentList { get; } = new ObservableCollection<ComponentImageSource>();
|
||||||
|
|
||||||
public void AddSource(string id, bool deleted, XDocument doc)
|
public void AddSource(string id, bool deleted, XDocument doc, TypedEventHandler<SvgImageSource, SvgImageSourceOpenedEventArgs> eventHandler = null)
|
||||||
{
|
{
|
||||||
var source = new SvgImageSource();
|
var source = new SvgImageSource();
|
||||||
|
if (eventHandler != null)
|
||||||
|
{
|
||||||
|
source.Opened += eventHandler;
|
||||||
|
}
|
||||||
ComponentList.Add(new ComponentImageSource { Id = id, Deleted = deleted, Source = source });
|
ComponentList.Add(new ComponentImageSource { Id = id, Deleted = deleted, Source = source });
|
||||||
_ = source.LoadSvgAsync(doc);
|
_ = source.LoadSvgAsync(doc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using PCUT.Extensions;
|
using PCUT.Extensions;
|
||||||
|
using Windows.Foundation;
|
||||||
using Windows.UI.Xaml.Media;
|
using Windows.UI.Xaml.Media;
|
||||||
using Windows.UI.Xaml.Media.Imaging;
|
using Windows.UI.Xaml.Media.Imaging;
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ namespace PCUT.ViewModels
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
private ImageSource _source;
|
private ImageSource _source;
|
||||||
private ImageSource _defaultSource = new SvgImageSource();
|
private SvgImageSource _defaultSource = new SvgImageSource();
|
||||||
|
|
||||||
public ImageSource Source
|
public ImageSource Source
|
||||||
{
|
{
|
||||||
|
@ -31,9 +32,13 @@ namespace PCUT.ViewModels
|
||||||
Source = source;
|
Source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSource(XDocument doc)
|
public void SetSource(XDocument doc, TypedEventHandler<SvgImageSource, SvgImageSourceOpenedEventArgs> eventHandler = null)
|
||||||
{
|
{
|
||||||
Source = _defaultSource;
|
Source = _defaultSource;
|
||||||
|
if (eventHandler != null)
|
||||||
|
{
|
||||||
|
_defaultSource.Opened += eventHandler;
|
||||||
|
}
|
||||||
if (doc != null)
|
if (doc != null)
|
||||||
_ = _source.LoadSvgAsync(doc);
|
_ = _source.LoadSvgAsync(doc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace PCUT.ViewModels
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
private int _count;
|
private int _count;
|
||||||
public int Count { get; }
|
public int Count { get => _count; }
|
||||||
|
|
||||||
public void SetCount(int count)
|
public void SetCount(int count)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue