refactor: mvp
This commit is contained in:
parent
9a84ad998e
commit
1f6db8e8a9
7
Tech/Model/Repository/IMainRepository.cs
Normal file
7
Tech/Model/Repository/IMainRepository.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Tech_Demo.Model.Repository
|
||||
{
|
||||
public interface IMainRepository
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
46
Tech/MultiPlayerView.Designer.cs
generated
46
Tech/MultiPlayerView.Designer.cs
generated
@ -1,46 +0,0 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Tech_Demo
|
||||
{
|
||||
partial class MultiPlayerView
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// MultiPlayerView
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.Name = "MultiPlayerView";
|
||||
this.Size = new System.Drawing.Size(921, 550);
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Tech_Demo
|
||||
{
|
||||
public partial class MultiPlayerView : UserControl
|
||||
{
|
||||
public MultiPlayerView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,2 +0,0 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeEditing/Localization/MoveToResource/LastResourceFile/@EntryValue">ACFE594E-F51C-4B73-9661-0144FF9E33A3/f:Form1.resx</s:String></wpf:ResourceDictionary>
|
||||
17
Tech/Presenter/MainPresenter.cs
Normal file
17
Tech/Presenter/MainPresenter.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using Tech_Demo.Model.Repository;
|
||||
using Tech_Demo.View;
|
||||
|
||||
namespace Tech_Demo.Presenter
|
||||
{
|
||||
public class MainPresenter
|
||||
{
|
||||
private readonly IMainView _view;
|
||||
private readonly IMainRepository _repository;
|
||||
|
||||
public MainPresenter(IMainView view, IMainRepository repository)
|
||||
{
|
||||
_view = view;
|
||||
_repository = repository;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Tech/Presenter/PlayerPresenter.cs
Normal file
21
Tech/Presenter/PlayerPresenter.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Tech_Demo.Model;
|
||||
using Tech_Demo.View;
|
||||
|
||||
namespace Tech_Demo.Presenter
|
||||
{
|
||||
public class PlayerPresenter
|
||||
{
|
||||
private readonly IPlayerView _view;
|
||||
|
||||
public PlayerPresenter(IPlayerView view)
|
||||
{
|
||||
_view = view;
|
||||
view.Presenter = this;
|
||||
}
|
||||
|
||||
public Equipment GetEquipment()
|
||||
{
|
||||
return new Equipment {Id = 1, Name = "设备1", Ip = "192.168.1.110", Url = @"rtsp://10.211.55.2:8554/rains", Type = 1};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,28 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Tech_Demo.Presenter;
|
||||
using Tech_Demo.View.Impl;
|
||||
|
||||
namespace Tech_Demo
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern bool AttachConsole(int dwProcessId);
|
||||
|
||||
private const int ATTACH_PARENT_PROCESS = -1;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern bool AttachConsole(int dwProcessId);
|
||||
private const int ATTACH_PARENT_PROCESS = -1;
|
||||
|
||||
static void Main()
|
||||
{
|
||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
var mainView = new MainView();
|
||||
mainView.Presenter = new MainPresenter(mainView, null);
|
||||
Application.Run(mainView);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -85,8 +85,11 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Model\Equipment.cs" />
|
||||
<Compile Include="Model\Repository\IMainRepository.cs" />
|
||||
<Compile Include="Model\Repository\Impl\package-info.cs" />
|
||||
<Compile Include="Presenter\MainPresenter.cs" />
|
||||
<Compile Include="Presenter\package-info.cs" />
|
||||
<Compile Include="Presenter\PlayerPresenter.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UCOverview.cs">
|
||||
@ -98,11 +101,12 @@
|
||||
<Compile Include="Util\ArpUtil.cs" />
|
||||
<Compile Include="Util\GetIPNetTable.cs" />
|
||||
<Compile Include="Util\Thumbnail.cs" />
|
||||
<Compile Include="View\Impl\MainForm.cs">
|
||||
<Compile Include="View\IMainView.cs" />
|
||||
<Compile Include="View\Impl\MainView.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\Impl\MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
<Compile Include="View\Impl\MainView.Designer.cs">
|
||||
<DependentUpon>MainView.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\Impl\PlayerView.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
@ -110,6 +114,7 @@
|
||||
<Compile Include="View\Impl\PlayerView.Designer.cs">
|
||||
<DependentUpon>PlayerView.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\IPlayerView.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
@ -123,8 +128,8 @@
|
||||
<EmbeddedResource Include="UCOverview.resx">
|
||||
<DependentUpon>UCOverview.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\Impl\MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
<EmbeddedResource Include="View\Impl\MainView.resx">
|
||||
<DependentUpon>MainView.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\Impl\PlayerView.resx">
|
||||
<DependentUpon>PlayerView.cs</DependentUpon>
|
||||
|
||||
9
Tech/View/IMainView.cs
Normal file
9
Tech/View/IMainView.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using Tech_Demo.Presenter;
|
||||
|
||||
namespace Tech_Demo.View
|
||||
{
|
||||
public interface IMainView
|
||||
{
|
||||
MainPresenter Presenter { set; }
|
||||
}
|
||||
}
|
||||
9
Tech/View/IPlayerView.cs
Normal file
9
Tech/View/IPlayerView.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using Tech_Demo.Presenter;
|
||||
|
||||
namespace Tech_Demo.View
|
||||
{
|
||||
public interface IPlayerView
|
||||
{
|
||||
PlayerPresenter Presenter { set; }
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Tech_Demo
|
||||
namespace Tech_Demo.View.Impl
|
||||
{
|
||||
partial class Form1
|
||||
partial class MainView
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -28,7 +28,7 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainView));
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.button4 = new System.Windows.Forms.Button();
|
||||
this.button3 = new System.Windows.Forms.Button();
|
||||
@ -1,18 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Tech_Demo.Presenter;
|
||||
using Tech_Demo.View;
|
||||
|
||||
namespace Tech_Demo
|
||||
namespace Tech_Demo.View.Impl
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
public partial class MainView : Form, IMainView
|
||||
{
|
||||
public MainPresenter Presenter { private get; set; }
|
||||
|
||||
[DllImport("user32")]
|
||||
private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
|
||||
@ -27,14 +24,16 @@ namespace Tech_Demo
|
||||
public const Int32 AW_SLIDE = 0x00040000; //使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略。
|
||||
public const Int32 AW_BLEND = 0x00080000; //使用淡出效果。只有当hWnd为顶层窗口的时候才可以使用此标志。
|
||||
|
||||
public Form1()
|
||||
public MainView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
panelContainer.Controls.Clear();
|
||||
var playerView = new PlayerView();
|
||||
playerView.Presenter = new PlayerPresenter(playerView);
|
||||
playerView.Dock = DockStyle.Fill;
|
||||
panelContainer.Controls.Add(playerView);
|
||||
// AnimateWindow(playerView.Handle, 1000, AW_HOR_POSITIVE | AW_SLIDE);
|
||||
@ -4,12 +4,14 @@ using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using LibVLCSharp.Shared;
|
||||
using Tech_Demo.Presenter;
|
||||
using Tech_Demo.Properties;
|
||||
using Tech_Demo.View;
|
||||
using Vlc.DotNet.Forms;
|
||||
|
||||
namespace Tech_Demo
|
||||
{
|
||||
public partial class PlayerView : UserControl
|
||||
public partial class PlayerView : UserControl, IPlayerView
|
||||
{
|
||||
/**
|
||||
* 单画面模式
|
||||
@ -43,6 +45,8 @@ namespace Tech_Demo
|
||||
// }
|
||||
}
|
||||
|
||||
public PlayerPresenter Presenter { private get; set; }
|
||||
|
||||
private void vlcControl_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
@ -153,7 +157,8 @@ namespace Tech_Demo
|
||||
":network-caching=100", ":rtsp-tcp"
|
||||
}; // { ":network-caching=100", ":rtsp -tcp", ":no-audio" }; // --avcodec-hw={any,d3d11va,dxva2,none}
|
||||
// var videoUri = new Uri(@"rtsp://admin:abc123456@192.168.1.233:554/h264/ch33/main/av_stream");
|
||||
var videoUri = new Uri(@"rtsp://10.211.55.2:8554/rains");
|
||||
var equipment = Presenter.GetEquipment();
|
||||
var videoUri = new Uri(equipment.Url);
|
||||
if (videoView.MediaPlayer == null)
|
||||
{
|
||||
var libVlc = new LibVLC(enableDebugLogs: true);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user