Commit ae58418e by liulongfei

框架调整

parent c06569ec
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="GridSplitter_None" TargetType="GridSplitter">
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Background="Transparent"></Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
......@@ -90,6 +90,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style\GridSplitter\GridSplitter_None.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Style\ListBox\ListBox_None.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
......@@ -28,6 +28,11 @@ namespace VIZ.Framework.Common
public string FullName { get; set; }
/// <summary>
/// 地址
/// </summary>
public string Address { get; set; }
/// <summary>
/// NDI流信息
/// </summary>
public NDIlib.source_t Source { get; set; }
......
......@@ -70,12 +70,14 @@ namespace VIZ.Framework.Common
// NDI流名称
string ndiName = UTF.Utf8ToString(src.p_ndi_name);
string address = UTF.Utf8ToString(src.p_url_address);
// 添加NDI流信息
NDIStreamInfo info = new NDIStreamInfo();
info.FullName = ndiName;
info.Machine = ndiName.Split(new char[] { ' ' }, 2)[0];
info.Name = ndiName.Substring(ndiName.IndexOf(' ') + 1);
info.Address = address;
info.Source = src;
lock (this.Stream.StreamInfos)
......
......@@ -41,28 +41,14 @@ namespace VIZ.Framework.Common
#endregion
#region ViewModelType -- 视图模型类型
private Type viewModelType;
/// <summary>
/// 视图模型类型
/// </summary>
public Type ViewModelType
{
get { return viewModelType; }
set { viewModelType = value; this.RaisePropertyChanged(nameof(ViewModelType)); }
}
#endregion
/// <summary>
/// 视图
/// </summary>
public WeakReference<object> View { get; set; }
/// <summary>
/// 视图模型
/// 视图创建后触发 参数: 导航配置, 视图
/// </summary>
public WeakReference<object> ViewModel { get; set; }
public Action<NavigationConfig, object> ViewCreated { get; set; }
}
}
......@@ -22,7 +22,6 @@
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Visibility" Value="{Binding Path=IsSelected,RelativeSource={RelativeSource Mode=Self},Converter={StaticResource Bool2VisibilityConverter}}"></Setter>
<Setter Property="ViewType" Value="{Binding Path=ViewType,Mode=OneWay}"></Setter>
<Setter Property="ViewModelType" Value="{Binding Path=ViewModelType,Mode=OneWay}"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:NavigationItemControl">
......
......@@ -69,25 +69,6 @@ namespace VIZ.Framework.Common
#endregion
#region ViewModelType -- 视图模型类型
/// <summary>
/// 视图模型类型
/// </summary>
public Type ViewModelType
{
get { return (Type)GetValue(ViewModelTypeProperty); }
set { SetValue(ViewModelTypeProperty, value); }
}
/// <summary>
/// Using a DependencyProperty as the backing store for ViewModelType. This enables animation, styling, binding, etc...
/// </summary>
public static readonly DependencyProperty ViewModelTypeProperty =
DependencyProperty.Register("ViewModelType", typeof(Type), typeof(NavigationItemControl), new PropertyMetadata(null));
#endregion
/// <summary>
/// 可见性改变时触发
/// </summary>
......@@ -104,28 +85,12 @@ namespace VIZ.Framework.Common
if (this.ViewType != null)
{
this.Content = this.ViewType.Assembly.CreateInstance(this.ViewType.FullName);
config.View = new WeakReference<object>(this.Content);
}
if (this.ViewModelType != null)
if (config != null)
{
FrameworkElement view = this.Content as FrameworkElement;
if (view != null)
{
object obj = this.ViewModelType.Assembly.CreateInstance(this.ViewModelType.FullName);
config.ViewModel = new WeakReference<object>(obj);
ViewModelBase vm = obj as ViewModelBase;
if (vm == null)
{
view.DataContext = obj;
}
else
{
WPFHelper.BindingViewModel(view, vm);
}
}
config.View = new WeakReference<object>(this.Content);
config.ViewCreated?.Invoke(config, this.Content);
}
}
}
......
......@@ -6,6 +6,7 @@ using System.Linq;
using System.Management;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
......@@ -118,5 +119,25 @@ namespace VIZ.Framework.Core
return 0;
}
/// <summary>
/// 获取本机第一个IPv4地址
/// </summary>
/// <returns>第一个IPv4地址</returns>
public static string GetLocalFirstIPv4Address()
{
if (!NetworkInterface.GetIsNetworkAvailable())
{
return string.Empty;
}
IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
var ippaddress = host
.AddressList
.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork);
return ippaddress.ToString();
}
}
}
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