主頁 > .NET開發 > WPF工控組態軟體之冷卻塔和空氣壓碩訓開發

WPF工控組態軟體之冷卻塔和空氣壓碩訓開發

2022-10-20 06:06:38 .NET開發

WPF以其豐富靈活的控制元件樣式設計,相較于WinForm而言,一直是工控組態軟體的寵兒,經過上一篇文章的學習,已經對WPF開發工控組態軟體有了一個基本的了解, 今天繼續學習冷卻塔和空氣壓碩訓的開發,僅供學習分享使用,如有不足之處,還請指正,

設計知識點

關于本示例中,涉及的知識點,如下所示:

  • 自定義用戶控制元件,用戶可以根據業務需要自定義控制元件,將普通的控制元件進行組合,封裝,以滿足特定的功能,并達到復用的目的,
  • WPF形狀,影片,可以通過選擇,移動,變形等相關功能,改變控制元件的呈現形狀,
  • 依賴屬性,WPF可以通過依賴屬性進行資料的系結,實作UI與業務邏輯的解耦,

冷卻塔CoolingTower

冷卻塔組成拆解

關于冷卻塔的組成部分,經過拆解如下所示:

  1. 頂部一個經過旋轉和縮放的風扇(Path)
  2. 一個橢圓形(Ellipse)和一個路徑形狀(Path),使得橢圓看起來像立體一樣
  3. 一個不規則形狀多邊形(Ploygon)
  4. 一個四邊形(Border),兩個圓形指示燈(Border),兩個四邊形底座(Border),表示前景和側面,

經過以上分析,不難發現,復雜的圖形均是由簡單的圖形組合起來的,

冷卻塔示例截圖

冷卻塔正常運轉時,綠燈亮且風扇轉動,例外時紅燈亮,且風扇停止,截圖如下所示:

冷卻塔原始碼

冷卻塔原始碼分為三個組成部分,如下所示:

1. 控制元件布局

控制元件布局主要是排版布局形狀等內容,如下所示:

  1 <Viewbox HorizontalAlignment="Center" VerticalAlignment="Center">
  2     <Canvas Width="205" Height="245" Margin="5">
  3         <Polygon Points="0,65 40,10 205,10 180,65 " Fill="#EEE"></Polygon>
  4         <Path Data="M0 0 A60 15 0 0 0 120 0 L120 25 A60 15 0 0 1 0 25" Canvas.Left="45" Canvas.Top="15">
  5             <Path.Fill>
  6                 <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
  7                     <GradientStop Color="#FFD6D6D6" Offset="0"></GradientStop>
  8                     <GradientStop Color="White" Offset="0.52"></GradientStop>
  9                     <GradientStop Color="#FFD6D6D6" Offset="1"></GradientStop>
 10                 </LinearGradientBrush>
 11             </Path.Fill>
 12         </Path>
 13         <Ellipse Width="120" Height="30" Fill="#CCC" Canvas.Left="45"></Ellipse>
 14         <Border Canvas.Left="52" Canvas.Top="-38">
 15             <Viewbox Width="105" Height="105" RenderTransformOrigin="0.5,0.5">
 16                 <Viewbox.RenderTransform>
 17                     <TransformGroup>
 18                         <RotateTransform Angle="20" x:Name="rt"></RotateTransform>
 19                         <ScaleTransform ScaleY="0.25"></ScaleTransform>
 20                     </TransformGroup>
 21                 </Viewbox.RenderTransform>
 22                 <Path Stretch="Fill" Data="M261.851429 528.822857c-43.885714-24.868571-84.845714-23.405714-121.417143 5.851429-35.108571 26.331429-49.737143 62.902857-43.885715 106.788571 5.851429 38.034286 19.017143 74.605714 40.96 108.251429 21.942857 35.108571 46.811429 59.977143 76.068572 74.605714 78.994286 40.96 147.748571 29.257143 207.725714-35.108571 19.017143-20.48 33.645714-43.885714 46.811429-73.142858 14.628571-32.182857 23.405714-61.44 24.868571-90.697142 0-14.628571 7.314286-21.942857 19.017143-21.942858s19.017143 5.851429 24.868571 16.091429c17.554286 51.2 14.628571 99.474286-10.24 143.36-24.868571 43.885714-21.942857 84.845714 4.388572 119.954286 26.331429 35.108571 62.902857 49.737143 106.788571 42.422857 38.034286-5.851429 74.605714-19.017143 108.251429-40.96 35.108571-21.942857 59.977143-46.811429 74.605714-76.068572 40.96-78.994286 29.257143-147.748571-36.571428-206.262857-20.48-19.017143-43.885714-35.108571-73.142858-48.274285-32.182857-14.628571-61.44-23.405714-90.697142-24.868572-14.628571 0-21.942857-7.314286-21.942858-19.017143s5.851429-20.48 17.554286-23.405714c20.48-7.314286 40.96-11.702857 62.902857-11.702857 27.794286 0 54.125714 7.314286 78.994286 20.48 43.885714 24.868571 84.845714 23.405714 121.417143-4.388572 35.108571-26.331429 49.737143-62.902857 43.885714-106.788571-5.851429-38.034286-19.017143-74.605714-40.96-108.251429-21.942857-35.108571-46.811429-59.977143-76.068571-74.605714-78.994286-40.96-147.748571-29.257143-207.725715 35.108572-19.017143 20.48-33.645714 45.348571-46.811428 73.142857-14.628571 32.182857-23.405714 62.902857-24.868572 90.697143 0 13.165714-7.314286 20.48-19.017142 21.942857s-20.48-5.851429-24.868572-16.091429c-7.314286-20.48-10.24-40.96-10.24-64.365714 0-27.794286 7.314286-54.125714 20.48-78.994286 24.868571-43.885714 21.942857-84.845714-4.388571-119.954286-26.331429-35.108571-61.44-49.737143-105.325715-43.885714-38.034286 5.851429-74.605714 19.017143-108.251428 40.96-35.108571 21.942857-59.977143 46.811429-76.068572 76.068572-40.96 78.994286-29.257143 147.748571 36.571429 207.725714 20.48 19.017143 45.348571 35.108571 73.142857 48.274286 32.182857 14.628571 61.44 21.942857 90.697143 23.405714 14.628571 0 21.942857 7.314286 21.942857 19.017143s-5.851429 20.48-17.554286 24.868571c-49.737143 17.554286-98.011429 14.628571-141.897142-10.24m279.405714-46.811428c8.777143 8.777143 11.702857 17.554286 11.702857 29.257142s-4.388571 21.942857-11.702857 30.72c-8.777143 7.314286-17.554286 11.702857-29.257143 11.702858s-21.942857-4.388571-30.72-11.702858c-8.777143-8.777143-11.702857-19.017143-11.702857-30.72s4.388571-21.942857 11.702857-29.257142c8.777143-8.777143 19.017143-13.165714 30.72-13.165715 11.702857 1.462857 20.48 4.388571 29.257143 13.165715z" Fill="#EEE">
 23                 </Path>
 24             </Viewbox>
 25         </Border>
 26         <Grid Width="180" Height="180" Canvas.Top="65" Background="#E0E0E0">
 27             <Border VerticalAlignment="Top" Height="140" BorderThickness="10">
 28                 <Border.Background>
 29                     <DrawingBrush TileMode="Tile" ViewportUnits="Absolute" Viewport="1,0,25,1">
 30                         <DrawingBrush.Drawing>
 31                             <GeometryDrawing>
 32                                 <GeometryDrawing.Pen>
 33                                     <Pen Brush="#EEE"></Pen>
 34                                 </GeometryDrawing.Pen>
 35                                 <GeometryDrawing.Geometry>
 36                                     <PathGeometry>
 37                                         <PathFigure>
 38                                             <LineSegment Point="10,0"></LineSegment>
 39                                             <LineSegment Point="10,10"></LineSegment>
 40                                         </PathFigure>
 41                                     </PathGeometry>
 42                                 </GeometryDrawing.Geometry>
 43                             </GeometryDrawing>
 44                         </DrawingBrush.Drawing>
 45                     </DrawingBrush>
 46                 </Border.Background>
 47             </Border>
 48             <Grid Height="50" VerticalAlignment="Bottom">
 49                 <Grid.ColumnDefinitions>
 50                     <ColumnDefinition></ColumnDefinition>
 51                     <ColumnDefinition></ColumnDefinition>
 52                 </Grid.ColumnDefinitions>
 53                 <Border Background="DarkGray" Grid.Column="0" Margin="5,0"></Border>
 54                 <Border Background="DarkGray" Grid.Column="1" Margin="5,0"></Border>
 55             </Grid>
 56          </Grid>
 57 
 58         <Grid Width="180" Height="180" Canvas.Top="65" Canvas.Left="180" Background="#E0E0E0">
 59             <Grid.RenderTransform>
 60                 <TransformGroup>
 61                     <ScaleTransform ScaleX="0.139"></ScaleTransform>
 62                     <SkewTransform AngleY="-65.5"></SkewTransform>
 63                 </TransformGroup>
 64             </Grid.RenderTransform>
 65             <Border VerticalAlignment="Top" Height="140" BorderThickness="10">
 66                 <Border.Background>
 67                     <DrawingBrush TileMode="Tile" ViewportUnits="Absolute" Viewport="1,0,25,1">
 68                         <DrawingBrush.Drawing>
 69                             <GeometryDrawing>
 70                                 <GeometryDrawing.Pen>
 71                                     <Pen Brush="#EEE"></Pen>
 72                                 </GeometryDrawing.Pen>
 73                                 <GeometryDrawing.Geometry>
 74                                     <PathGeometry>
 75                                         <PathFigure>
 76                                             <LineSegment Point="10,0"></LineSegment>
 77                                             <LineSegment Point="10,10"></LineSegment>
 78                                         </PathFigure>
 79                                     </PathGeometry>
 80                                 </GeometryDrawing.Geometry>
 81                             </GeometryDrawing>
 82                         </DrawingBrush.Drawing>
 83                     </DrawingBrush>
 84                 </Border.Background>
 85             </Border>
 86             <Grid Height="50" VerticalAlignment="Bottom">
 87                 <Grid.ColumnDefinitions>
 88                     <ColumnDefinition></ColumnDefinition>
 89                     <ColumnDefinition></ColumnDefinition>
 90                 </Grid.ColumnDefinitions>
 91                 <Border Background="DarkGray" Grid.Column="0" Margin="5,0"></Border>
 92                 <Border Background="DarkGray" Grid.Column="1" Margin="5,0"></Border>
 93             </Grid>
 94         </Grid>
 95 
 96         <Border Width="18" Height="18" CornerRadius="10" Canvas.Left="150" Canvas.Top="80">
 97             <Border.Background>
 98                 <RadialGradientBrush>
 99                     <GradientStop Color="Gray" Offset="0.6" x:Name="gsGreen"></GradientStop>
100                     <GradientStop Color="White"></GradientStop>
101                 </RadialGradientBrush>
102             </Border.Background>
103         </Border>
104         <Border Width="18" Height="18" CornerRadius="10" Canvas.Left="150" Canvas.Top="105">
105             <Border.Background>
106                 <RadialGradientBrush>
107                     <GradientStop Color="Gray" Offset="0.6" x:Name="gsRed"></GradientStop>
108                     <GradientStop Color="White"></GradientStop>
109                 </RadialGradientBrush>
110             </Border.Background>
111         </Border>
112     </Canvas>
113 </Viewbox>

2. 狀態管理

冷卻塔有兩個狀態,正常運行狀態和例外狀態,分別對應不同的呈現,如下所示:

 1 <VisualStateManager.VisualStateGroups>
 2     <VisualStateGroup>
 3         <VisualState x:Name="normalState">
 4             <Storyboard>
 5                 <DoubleAnimation Duration="0:0:0.5" From="0" To="-360" RepeatBehavior="Forever" Storyboard.TargetName="rt" Storyboard.TargetProperty="Angle"></DoubleAnimation>
 6                 <ColorAnimationUsingKeyFrames Storyboard.TargetName="gsGreen" Storyboard.TargetProperty="Color">
 7                     <DiscreteColorKeyFrame Value="Green" KeyTime="0"></DiscreteColorKeyFrame>
 8                 </ColorAnimationUsingKeyFrames>
 9             </Storyboard>
10         </VisualState>
11         <VisualState x:Name="errorState">
12             <Storyboard>
13                 <ColorAnimationUsingKeyFrames Storyboard.TargetName="gsRed" RepeatBehavior="Forever" Storyboard.TargetProperty="Color" Duration="0:0:1">
14                     <DiscreteColorKeyFrame Value="Red" KeyTime="0:0:0.5"></DiscreteColorKeyFrame>
15                     <DiscreteColorKeyFrame Value="Gray" KeyTime="0:0:1"></DiscreteColorKeyFrame>
16                 </ColorAnimationUsingKeyFrames>
17             </Storyboard>
18         </VisualState>
19     </VisualStateGroup>
20 </VisualStateManager.VisualStateGroups>

3. 依賴屬性

在本示例中,依賴屬性主要用于控制狀態,如下所示:

 1 namespace WpfControl.UserControls
 2 {
 3     /// <summary>
 4     /// CoolingTower.xaml 的互動邏輯
 5     /// </summary>
 6     public partial class CoolingTower : UserControl
 7     {
 8         public RunningState RunningState
 9         {
10             get { return (RunningState)GetValue(RunningStateProperty); }
11             set { SetValue(RunningStateProperty, value); }
12         }
13 
14         // Using a DependencyProperty as the backing store for RunningState.  This enables animation, styling, binding, etc...
15         public static readonly DependencyProperty RunningStateProperty =
16             DependencyProperty.Register("RunningState", typeof(RunningState), typeof(CoolingTower), new PropertyMetadata(default(RunningState), RunningStateChangedCallback));
17 
18         private static void RunningStateChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
19         {
20             RunningState value =https://www.cnblogs.com/hsiang/archive/2022/10/19/ (RunningState)e.NewValue;
21             VisualStateManager.GoToState(d as CoolingTower, value =https://www.cnblogs.com/hsiang/archive/2022/10/19/= RunningState.Normal ? "normalState" : "errorState", false);
22         }
23         public CoolingTower()
24         {
25             InitializeComponent();
26         }
27     }
28 }

4. 呼叫示例

組件寫好后,呼叫非常簡單,如下所示:

 1 <Window x:Class="WpfControl.TestWindow2"
 2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 4         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 5         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 6         xmlns:local="clr-namespace:WpfControl"
 7         xmlns:uctrl="clr-namespace:WpfControl.UserControls"
 8         mc:Ignorable="d"
 9         Title="冷卻塔" Height="450" Width="800">
10     <Grid>
11         <Grid.ColumnDefinitions>
12             <ColumnDefinition></ColumnDefinition>
13             <ColumnDefinition></ColumnDefinition>
14         </Grid.ColumnDefinitions>
15         <uctrl:CoolingTower Grid.Column="0" RunningState="Error" Width="100" Height="100"></uctrl:CoolingTower>
16         <uctrl:CoolingTower Grid.Column="1" RunningState="Normal" Width="100" Height="100"></uctrl:CoolingTower>
17     </Grid>
18 </Window>

 

空氣壓碩訓AirCompresser

空氣壓碩訓功能拆解

關于空氣壓縮式機的組成部分,經過拆解如下所示:

  1. 左側一個四邊形(Path)
  2. 頂部一個四邊形(Path)
  3. 前景一個四邊形(Path),兩條線(Line)
  4. 兩個小圓點(Ellipse)
  5. 底部一個四邊形(Border)
  6. 右上角指示燈(Ellipse)

經過以上分析,不難發現,空氣壓碩訓均是由簡單的圖形組合起來的,

空氣壓碩訓示例截圖

空氣壓縮式機同樣包括兩種狀態,正常狀態,綠燈亮和例外狀態,紅燈閃爍,示例截圖如下所示:

空氣壓碩訓原始碼

空氣壓碩訓原始碼分為三個組成部分,如下所示:

1. 頁面布局

頁面布局主要進行控制元件的排版,如下所示:

 1  <Viewbox Stretch="Fill">
 2     <Grid>
 3         <Path x:Name="left" Data="M0,0,0,200,80,300,80,70" Fill="Gray"></Path>
 4         <Path x:Name="top" Data="M0,0,80,70,400,60,320 -10" Fill="Gray"></Path>
 5         <Path x:Name="front" Data="M80,300,80,70,400,60,400,280" Fill="LightGray"></Path>
 6         <Line x:Name="l1" X1="180" X2="180" Y1="66" Y2="280" StrokeThickness="1" Stroke="Gray"></Line>
 7         <Line x:Name="l2" X1="280" X2="280" Y1="66" Y2="280" StrokeThickness="1" Stroke="Gray"></Line>
 8         <Ellipse x:Name="c1" Width="10" Height="10" Fill="DarkGray"></Ellipse>
 9         <Ellipse x:Name="c2" Width="10" Height="10" Fill="DarkGray" Margin="0,3,80,0"></Ellipse>
10         <Border x:Name="bottom"  Height="22" Background="DarkGray" Margin="80,0,0,0" VerticalAlignment="Bottom">
11             <Border.RenderTransform>
12                 <SkewTransform AngleY="-4"></SkewTransform>
13             </Border.RenderTransform>
14         </Border>
15         <Ellipse x:Name="alarm"  Width="18" Height="18" Margin="0,80,10,0" HorizontalAlignment="Right" VerticalAlignment="Top">
16             <Ellipse.Fill>
17                 <SolidColorBrush Color="LightGray"></SolidColorBrush>
18             </Ellipse.Fill>
19         </Ellipse>
20     </Grid>
21 </Viewbox>

2. 狀態管理

空氣壓碩訓主要有兩種狀態,分別表示不同的運行情況,如下所示:

 1 <VisualStateManager.VisualStateGroups>
 2     <VisualStateGroup>
 3         <VisualState x:Name="errorState">
 4             <Storyboard RepeatBehavior="Forever">
 5                 <ColorAnimation Duration="0:0:0.5" From="White" To="Red" BeginTime="0:0:0"   Storyboard.TargetName="alarm" Storyboard.TargetProperty="Fill.Color"></ColorAnimation>
 6             </Storyboard>
 7         </VisualState>
 8         <VisualState x:Name="normalSate">
 9             <Storyboard RepeatBehavior="Forever">
10                 <ColorAnimation Duration="0:0:0.1" From="LightGreen" To="LightGreen" BeginTime="0:0:0" Storyboard.TargetName="alarm" Storyboard.TargetProperty="Fill.Color"></ColorAnimation>
11             </Storyboard>
12         </VisualState>
13     </VisualStateGroup>
14 </VisualStateManager.VisualStateGroups>

3. 依賴屬性

空氣壓碩訓的依賴屬性和冷卻塔相似,如下所示:

 1 namespace WpfControl.UserControls
 2 {
 3     /// <summary>
 4     /// AirCompresser.xaml 的互動邏輯
 5     /// </summary>
 6     public partial class AirCompresser : UserControl
 7     {
 8 
 9 
10 
11 
12         public RunningState RunningState
13         {
14             get { return (RunningState)GetValue(RunningStateProperty); }
15             set { SetValue(RunningStateProperty, value); }
16         }
17 
18         // Using a DependencyProperty as the backing store for RunningState.  This enables animation, styling, binding, etc...
19         public static readonly DependencyProperty RunningStateProperty =
20             DependencyProperty.Register("RunningState", typeof(RunningState), typeof(AirCompresser), new PropertyMetadata(default(RunningState),RunningStateChangedCallback));
21 
22         private static void RunningStateChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
23         {
24             RunningState value =https://www.cnblogs.com/hsiang/archive/2022/10/19/ (RunningState)e.NewValue;
25             VisualStateManager.GoToState(d as AirCompresser, value =https://www.cnblogs.com/hsiang/archive/2022/10/19/= RunningState.Error ? "errorState" : "normalSate", false);
26         }
27 
28         public AirCompresser()
29         {
30             InitializeComponent();
31         }
32     }
33 }

4. 呼叫示例

呼叫空氣壓碩訓示例,如下所示:

 1 <Window x:Class="WpfControl.TestWindow"
 2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 4         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 5         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 6         xmlns:local="clr-namespace:WpfControl"
 7         xmlns:uctrl="clr-namespace:WpfControl.UserControls"
 8         mc:Ignorable="d"
 9         Title="空氣壓碩訓示例" Height="450" Width="800">
10     <Grid>
11         <uctrl:AirCompresser Width="150" Height="100" RunningState="Error" Margin="10,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"></uctrl:AirCompresser>
12         <uctrl:AirCompresser Width="150" Height="100" RunningState="Normal" Margin="50,200,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"></uctrl:AirCompresser>
13         <uctrl:AirCompresser Width="150" Height="100" RunningState="Normal" Margin="0,0,10,10" HorizontalAlignment="Right" VerticalAlignment="Bottom"></uctrl:AirCompresser>
14         <uctrl:AirCompresser Width="150" Height="100" RunningState="Error" Margin="0,0,50,200" HorizontalAlignment="Right" VerticalAlignment="Bottom"></uctrl:AirCompresser>
15     </Grid>
16 </Window>

備注

以上就是本篇文章的全部內容,旨在拋磚引玉,共同學習,一起進步,學習編程,從關注【老碼識途】開始!!!


作者:小六公子
出處:http://www.cnblogs.com/hsiang/
本文著作權歸作者和博客園共有,寫文不易,支持原創,歡迎轉載【點贊】,轉載請保留此段宣告,且在文章頁面明顯位置給出原文連接,謝謝,
關注個人公眾號,定時同步更新技術及職場文章

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/518445.html

標籤:.NET技术

上一篇:System.IO.FileSystemWatcher的坑

下一篇:在WooCommerce中發送電子郵件通知之前,使用哪個掛鉤來保存訂單元資料

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • WebAPI簡介

    Web體系結構: 有三個核心:資源(resource),URL(統一資源識別符號)和表示 他們的關系是這樣的:一個資源由一個URL進行標識,HTTP客戶端使用URL定位資源,表示是從資源回傳資料,媒體型別是資源回傳的資料格式。 接下來我們說下HTTP. HTTP協議的系統是一種無狀態的方式,使用請求/ ......

    uj5u.com 2020-09-09 22:07:47 more
  • asp.net core 3.1 入口:Program.cs中的Main函式

    本文分析Program.cs 中Main()函式中代碼的運行順序分析asp.net core程式的啟動,重點不是剖析原始碼,而是理清程式開始時執行的順序。到呼叫了哪些實體,哪些法方。asp.net core 3.1 的程式入口在專案Program.cs檔案里,如下。ususing System; us ......

    uj5u.com 2020-09-09 22:07:49 more
  • asp.net網站作為websocket服務端的應用該如何寫

    最近被websocket的一個問題困擾了很久,有一個需求是在web網站中搭建websocket服務。客戶端通過網頁與服務器建立連接,然后服務器根據ip給客戶端網頁發送資訊。 其實,這個需求并不難,只是剛開始對websocket的內容不太了解。上網搜索了一下,有通過asp.net core 實作的、有 ......

    uj5u.com 2020-09-09 22:08:02 more
  • ASP.NET 開源匯入匯出庫Magicodes.IE Docker中使用

    Magicodes.IE在Docker中使用 更新歷史 2019.02.13 【Nuget】版本更新到2.0.2 【匯入】修復單列匯入的Bug,單元測驗“OneColumnImporter_Test”。問題見(https://github.com/dotnetcore/Magicodes.IE/is ......

    uj5u.com 2020-09-09 22:08:05 more
  • 在webform中使用ajax

    如果你用過Asp.net webform, 說明你也算是.NET 開發的老兵了。WEBform應該是2011 2013左右,當時還用visual studio 2005、 visual studio 2008。后來基本都用的是MVC。 如果是新開發的專案,估計沒人會用webform技術。但是有些舊版 ......

    uj5u.com 2020-09-09 22:08:50 more
  • iis添加asp.net網站,訪問提示:由于擴展配置問題而無法提供您請求的

    今天在iis服務器配置asp.net網站,遇到一個問題,記錄一下: 問題:由于擴展配置問題而無法提供您請求的頁面。如果該頁面是腳本,請添加處理程式。如果應下載檔案,請添加 MIME 映射。 WindowServer2012服務器,添加角色安裝完.netframework和iis之后,運行aspx頁面 ......

    uj5u.com 2020-09-09 22:10:00 more
  • WebAPI-處理架構

    帶著問題去思考,大家好! 問題1:HTTP請求和回傳相應的HTTP回應資訊之間發生了什么? 1:首先是最底層,托管層,位于WebAPI和底層HTTP堆疊之間 2:其次是 訊息處理程式管道層,這里比如日志和快取。OWIN的參考是將訊息處理程式管道的一些功能下移到堆疊下端的OWIN中間件了。 3:控制器處理 ......

    uj5u.com 2020-09-09 22:11:13 more
  • 微信門戶開發框架-使用指導說明書

    微信門戶應用管理系統,采用基于 MVC + Bootstrap + Ajax + Enterprise Library的技術路線,界面層采用Boostrap + Metronic組合的前端框架,資料訪問層支持Oracle、SQLServer、MySQL、PostgreSQL等資料庫。框架以MVC5,... ......

    uj5u.com 2020-09-09 22:15:18 more
  • WebAPI-HTTP編程模型

    帶著問題去思考,大家好!它是什么?它包含什么?它能干什么? 訊息 HTTP編程模型的核心就是訊息抽象,表示為:HttPRequestMessage,HttpResponseMessage.用于客戶端和服務端之間交換請求和回應訊息。 HttpMethod類包含了一組靜態屬性: private stat ......

    uj5u.com 2020-09-09 22:15:23 more
  • 部署WebApi隨筆

    一、跨域 NuGet參考Microsoft.AspNet.WebApi.Cors WebApiConfig.cs中配置: // Web API 配置和服務 config.EnableCors(new EnableCorsAttribute("*", "*", "*")); 二、清除默認回傳XML格式 ......

    uj5u.com 2020-09-09 22:15:48 more
最新发布
  • C#多執行緒學習(二) 如何操縱一個執行緒

    <a href="https://www.cnblogs.com/x-zhi/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2943582/20220801082530.png" alt="" /></...

    uj5u.com 2023-04-19 09:17:20 more
  • C#多執行緒學習(二) 如何操縱一個執行緒

    C#多執行緒學習(二) 如何操縱一個執行緒 執行緒學習第一篇:C#多執行緒學習(一) 多執行緒的相關概念 下面我們就動手來創建一個執行緒,使用Thread類創建執行緒時,只需提供執行緒入口即可。(執行緒入口使程式知道該讓這個執行緒干什么事) 在C#中,執行緒入口是通過ThreadStart代理(delegate)來提供的 ......

    uj5u.com 2023-04-19 09:16:49 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    <a href="https://www.cnblogs.com/huangxincheng/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/214741/20200614104537.png" alt="" /&g...

    uj5u.com 2023-04-18 08:39:04 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    一:背景 1. 講故事 前段時間協助訓練營里的一位朋友分析了一個程式卡死的問題,回過頭來看這個案例比較經典,這篇稍微整理一下供后來者少踩坑吧。 二:WinDbg 分析 1. 為什么會卡死 因為是表單程式,理所當然就是看主執行緒此時正在做什么? 可以用 ~0s ; k 看一下便知。 0:000> k # ......

    uj5u.com 2023-04-18 08:33:10 more
  • SignalR, No Connection with that ID,IIS

    <a href="https://www.cnblogs.com/smartstar/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/u36196.jpg" alt="" /></a>...

    uj5u.com 2023-03-30 17:21:52 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:15:33 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:13:31 more
  • C#遍歷指定檔案夾中所有檔案的3種方法

    <a href="https://www.cnblogs.com/xbhp/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/957602/20230310105611.png" alt="" /></a&...

    uj5u.com 2023-03-27 14:46:55 more
  • C#/VB.NET:如何將PDF轉為PDF/A

    <a href="https://www.cnblogs.com/Carina-baby/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2859233/20220427162558.png" alt="" />...

    uj5u.com 2023-03-27 14:46:35 more
  • 武裝你的WEBAPI-OData聚合查詢

    <a href="https://www.cnblogs.com/podolski/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/616093/20140323000327.png" alt="" /><...

    uj5u.com 2023-03-27 14:46:16 more