Commit f233d67d authored by 姜春辉's avatar 姜春辉

修改宿舍信息数据结构,呈现方式

parent 13cc06cf
...@@ -5,7 +5,15 @@ using System.Text; ...@@ -5,7 +5,15 @@ using System.Text;
namespace DashBoard.ServiceModel namespace DashBoard.ServiceModel
{ {
//宿舍状态测试地址:http://192.168.1.2:8019/Visualization/SuSheState.ashx?Bui=a
public class School_SuSheBuild
{
public int BuiId { get; set; }
public string BuiName { get; set; }
public List<School_SuSheState> Floors { get; set; }
}
//传参说明:?Bui=a a男生宿舍楼b女生宿舍楼y游泳馆 //传参说明:?Bui=a a男生宿舍楼b女生宿舍楼y游泳馆
public class School_SuSheState public class School_SuSheState
{ {
......
...@@ -24,21 +24,24 @@ ...@@ -24,21 +24,24 @@
<ImageBrush ImageSource="/SchoolSituation;component/images/dormbg.png"></ImageBrush> <ImageBrush ImageSource="/SchoolSituation;component/images/dormbg.png"></ImageBrush>
</Border.Background> </Border.Background>
<Border Margin="50" BorderThickness="0" BorderBrush="#FF0080A9"> <Border Margin="50" BorderThickness="0" BorderBrush="#FF0080A9">
<TabControl x:Name="tabControl" Margin="0" SelectedIndex="{Binding page}" Background="Transparent" BorderThickness="0"> <TabControl x:Name="tabControl" Margin="0"
SelectedIndex="0"
ItemsSource="{Binding DormList}"
Background="Transparent" BorderThickness="0">
<TabControl.ItemContainerStyle> <TabControl.ItemContainerStyle>
<Style TargetType="TabItem"> <Style TargetType="TabItem">
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="TabItem"> <ControlTemplate TargetType="TabItem">
<TabPanel> <TabPanel>
<Border x:Name="bor" Background="Transparent" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" BorderThickness="0,2,0,0" BorderBrush="Transparent"> <Border x:Name="bor" Background="Transparent" Height="60" Width="194" BorderThickness="0,2,0,0" BorderBrush="Transparent">
<StackPanel Orientation="Horizontal" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"> <StackPanel Orientation="Horizontal" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
<Border x:Name="img" Height="24" Width="24" VerticalAlignment="Center" Margin="32,0,0,0"> <Border x:Name="img" Height="24" Width="24" VerticalAlignment="Center" Margin="32,0,0,0">
<Border.Background> <Border.Background>
<ImageBrush ImageSource="/SchoolSituation;component/images/louchengblack.png"></ImageBrush> <ImageBrush ImageSource="/SchoolSituation;component/images/louchengblack.png"></ImageBrush>
</Border.Background> </Border.Background>
</Border> </Border>
<TextBlock x:Name="text" Text="{TemplateBinding Name}" FontFamily="微软雅黑" FontSize="24" Foreground="#FF0080A9" VerticalAlignment="Center" Margin="10,0,0,0"></TextBlock> <TextBlock x:Name="text" Text="{Binding Name}" FontFamily="微软雅黑" FontSize="24" Foreground="#FF0080A9" VerticalAlignment="Center" Margin="10,0,0,0"></TextBlock>
</StackPanel> </StackPanel>
</Border> </Border>
</TabPanel> </TabPanel>
...@@ -59,7 +62,140 @@ ...@@ -59,7 +62,140 @@
</Setter> </Setter>
</Style> </Style>
</TabControl.ItemContainerStyle> </TabControl.ItemContainerStyle>
<TabItem Height="60" Width="194" x:Name="女生楼"> <TabControl.ContentTemplate>
<ItemContainerTemplate>
<Grid>
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/SchoolSituation;component/images/listbg.png" />
</Grid.Background>
</Grid>
<Border Background="#B2FFFFFF" BorderThickness="0,1,0,0" BorderBrush="#FF0080A9">
<ListView Margin="23,10,27,27" Padding="0"
ItemsSource="{Binding Floors}" BorderThickness="0"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Background="Transparent">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.Template>
<ControlTemplate>
<ScrollViewer Style="{DynamicResource scrollviewerStyle}"
HorizontalScrollBarVisibility="Disabled"
IsManipulationEnabled="False">
<ItemsPresenter>
</ItemsPresenter>
</ScrollViewer>
</ControlTemplate>
</ListView.Template>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Grid Width="1726" Margin="0,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="97"/>
<ColumnDefinition Width="1629"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="10"></RowDefinition>
</Grid.RowDefinitions>
<Grid x:Name="grid" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center">
<TextBlock FontFamily="黑体" FontSize="34" Foreground="#FF1BA7B5" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="18,0,0,0" Text="{Binding FloorNumber,StringFormat={}{0}F}"></TextBlock>
<TextBlock FontFamily="黑体" FontSize="34" Foreground="#FF1BA7B5" VerticalAlignment="Center" Text=">" HorizontalAlignment="Left" Margin="57,0,0,0"></TextBlock>
</Grid>
<Line Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" X1="0" X2="1710" Stroke="#FF57CFD9" StrokeDashArray="2,2" StrokeThickness="2" VerticalAlignment="Bottom"></Line>
<ListView ItemsSource="{Binding list}" Grid.Column="1"
Grid.Row="0" Margin="0" Padding="0"
BorderThickness="0" VerticalAlignment="Top"
Background="Transparent" BorderBrush="Transparent"
>
<ListView.Template>
<ControlTemplate TargetType="ListView">
<ItemsPresenter/>
</ControlTemplate>
</ListView.Template>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="1629" Orientation="Horizontal">
</WrapPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Button Command="{Binding DataContext.ShowDetailCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Page}}}"
CommandParameter="{Binding }">
<Button.Template>
<ControlTemplate>
<Border x:Name="border" BorderThickness="0,4,0,0" Margin="8,8,0,0" CornerRadius="5" Height="42" Width="116" Background="#FF57CFD9" BorderBrush="#FF1BA7B5">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="dormNo" Text="{Binding RoomName}" Foreground="#FF385982" FontFamily="黑体" FontSize="23.92" VerticalAlignment="Center" Margin="10,0,0,0"></TextBlock>
<TextBlock x:Name="cur" Text="{Binding In}" FontFamily="黑体" Foreground="#FF385982" FontSize="17.68" VerticalAlignment="Center" Margin="10,0,0,0"></TextBlock>
<TextBlock x:Name="all" Foreground="#FF385982" FontFamily="黑体" FontSize="17.68" VerticalAlignment="Center">
<Run Text="/"></Run>
<Run Text="{Binding Sum}"></Run>
</TextBlock>
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding DormScore}" Value="4">
<Setter Property="BorderBrush" Value="#FFEB9205" TargetName="border"></Setter>
<Setter Property="Background" Value="#FFECC27F" TargetName="border"/>
<Setter Property="Foreground" Value="white" TargetName="dormNo"></Setter>
<Setter Property="Foreground" Value="white" TargetName="cur"/>
<Setter Property="Foreground" Value="white" TargetName="all"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding DormScore}" Value="3">
<Setter Property="BorderBrush" Value="#FFAF0A46" TargetName="border"></Setter>
<Setter Property="Background" Value="#FFE28C8A" TargetName="border"/>
<Setter Property="Foreground" Value="white" TargetName="dormNo"></Setter>
<Setter Property="Foreground" Value="white" TargetName="cur"/>
<Setter Property="Foreground" Value="white" TargetName="all"></Setter>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding FloorNumber}" Value="7">
<Setter Property="Margin" Value="0,10,0,0" TargetName="grid"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</Border>
</Grid>
</ItemContainerTemplate>
</TabControl.ContentTemplate>
<!--<TabItem Height="60" Width="194" x:Name="女生楼">
<Grid> <Grid>
<Grid> <Grid>
<Grid.Background> <Grid.Background>
...@@ -415,7 +551,7 @@ ...@@ -415,7 +551,7 @@
</ListView> </ListView>
</Border> </Border>
</Grid> </Grid>
</TabItem> </TabItem>-->
</TabControl> </TabControl>
</Border> </Border>
......
...@@ -7,30 +7,21 @@ using System.Collections.ObjectModel; ...@@ -7,30 +7,21 @@ using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Controls;
namespace SchoolSituation namespace SchoolSituation
{ {
public partial class DormInfoViewModel : PageViewModel public partial class DormInfoViewModel : PageViewModel
{ {
private ObservableCollection<ViewSuSheState> _Dorma; private ObservableCollection<ViewSuSheBuild> _DormList;
public ObservableCollection<ViewSuSheState> Dorma
{ public ObservableCollection<ViewSuSheBuild> DormList
get { return _Dorma; }
set { _Dorma = value; RaisePropertyChanged("Dorma"); }
}
private ObservableCollection<ViewSuSheState> _Dormb;
public ObservableCollection<ViewSuSheState> Dormb
{
get { return _Dormb; }
set { _Dormb = value; RaisePropertyChanged("Dormb"); }
}
private ObservableCollection<ViewSuSheState> _Dormy;
public ObservableCollection<ViewSuSheState> Dormy
{ {
get { return _Dormy; } get { return _DormList ?? (_DormList = new ObservableCollection<ViewSuSheBuild>()); }
set { _Dormy = value; RaisePropertyChanged("Dormy"); } set { _DormList = value; RaisePropertyChanged("DormList"); }
} }
public override void Enter() public override void Enter()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
...@@ -48,49 +39,23 @@ namespace SchoolSituation ...@@ -48,49 +39,23 @@ namespace SchoolSituation
if (isfirst) if (isfirst)
{ {
isfirst = false; isfirst = false;
var localresulta = Tools.ReadCache($"SuShetStatea.json"); var localresult = Tools.ReadCache($"SuSheBuild.json");
var locala = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheState>>(localresulta); var local = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheBuild>>(localresult);
var localresultb = Tools.ReadCache($"SuShetStateb.json"); if (local != null)
var localb = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheState>>(localresultb);
var localresulty = Tools.ReadCache($"SuShetStatey.json");
var localy = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheState>>(localresulty);
if (locala != null || locala != null || locala != null)
{ {
Dorma = new ObservableCollection<ViewSuSheState>(locala.Select(r => (ViewSuSheState)r).ToList()); DormList = new ObservableCollection<ViewSuSheBuild>(local.Select(r => (ViewSuSheBuild)r).ToList());
Dormb = new ObservableCollection<ViewSuSheState>(localb.Select(r => (ViewSuSheState)r).ToList());
Dormy = new ObservableCollection<ViewSuSheState>(localy.Select(r => (ViewSuSheState)r).ToList());
} }
} }
//读取本地数据加载界面 //读取本地数据加载界面
if (string.IsNullOrEmpty(Source)) return false; if (string.IsNullOrEmpty(Source)) return false;
var updateResult = false; var updateResult = false;
var getUrla = new Uri(Source + "?Bui=a"); var resulta = Tools.Get(new Uri(Source), out string backDataa);
var getUrlb = new Uri(Source + "?Bui=b");
var getUrly = new Uri(Source + "?Bui=y");
var resulta = Tools.Get(getUrla, out string backDataa);
if (resulta) if (resulta)
{ {
var writeCacheResulta = Tools.WriteCache($"SuShetStatea.json", backDataa); var writeCacheResulta = Tools.WriteCache($"SuSheBuild.json", backDataa);
var entiya = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheState>>(backDataa); var entiya = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheBuild>>(backDataa);
Dorma = new ObservableCollection<ViewSuSheState>(entiya.Select(r => (ViewSuSheState)r).ToList()); DormList = new ObservableCollection<ViewSuSheBuild>(entiya.Select(r => (ViewSuSheBuild)r).ToList());
updateResult = true;
}
var resultb = Tools.Get(getUrlb, out string backDatab);
if (resultb)
{
var writeCacheResultb = Tools.WriteCache($"SuShetStateb.json", backDatab);
var entiyb = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheState>>(backDatab);
Dormb = new ObservableCollection<ViewSuSheState>(entiyb.Select(r => (ViewSuSheState)r).ToList());
updateResult = true;
}
var resulty = Tools.Get(getUrly, out string backDatay);
if (resulty)
{
var writeCacheResulty = Tools.WriteCache($"SuShetStatey.json", backDatay);
var entiyy = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheState>>(backDatay);
Dormy = new ObservableCollection<ViewSuSheState>(entiyy.Select(r => (ViewSuSheState)r).ToList());
updateResult = true; updateResult = true;
} }
return updateResult; return updateResult;
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -7,6 +8,43 @@ using GalaSoft.MvvmLight; ...@@ -7,6 +8,43 @@ using GalaSoft.MvvmLight;
namespace SchoolSituation namespace SchoolSituation
{ {
public class ViewSuSheBuild : ObservableObject
{
private int _Id;
public int Id
{
get { return _Id; }
set { _Id = value; RaisePropertyChanged("Id"); }
}
private string _Name;
public string Name
{
get { return _Name; }
set { _Name = value; RaisePropertyChanged("Name"); }
}
private ObservableCollection<ViewSuSheState> _Floors;
public ObservableCollection<ViewSuSheState> Floors
{
get { return _Floors; }
set { _Floors = value; RaisePropertyChanged("Floors"); }
}
public static explicit operator ViewSuSheBuild(DashBoard.ServiceModel.School_SuSheBuild data)
{
var entity = new ViewSuSheBuild();
entity.Id = data.BuiId;
entity.Name = data.BuiName;
entity.Floors = new ObservableCollection<ViewSuSheState>(data.Floors.Select(r => (ViewSuSheState)r).ToList());
return entity;
}
}
public class ViewSuSheState : ObservableObject public class ViewSuSheState : ObservableObject
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment