在 IIS 上啟用 Websocket 在 Windows Server 2012 或更高版本上啟用對 WebSocket 協議的支持: 備註 使用 IIS Express 時無需執行這些步驟 通過“管理”菜單或“伺服器管理器”中的鏈接使用“添加角色和功能”嚮導。 選擇“基於角色或基於功能的安裝”。 ...
從網上找到一個WPF日曆控制項,這個日曆是按天展現的,有0點至23點時間刻度,目前只實現了日曆的增加計劃。
未實現的功能滑鼠單擊選擇(可以選擇多個),選擇後可以進行修改,選擇後可以進行刪除,刷新日曆後重新載入日曆計劃。
日曆控制項包含6個自定義控制項,分別是CalendarTimeslotItem,CalendarLedgerItem,CalendarLedger,CalendarDay,Calendar,CalendarAppointmentItem
CalendarTimeslotItem前臺代碼
1 <Style TargetType="{x:Type local:CalendarTimeslotItem}"> 2 <Setter Property="Template"> 3 <Setter.Value> 4 <ControlTemplate TargetType="{x:Type local:CalendarTimeslotItem}"> 5 <Border Background="{TemplateBinding Background}" 6 BorderBrush="#A5BFE1" 7 BorderThickness="0,0.5,0,0.5" 8 x:Name="bd" 9 Height="22"> 10 <Border CornerRadius="4,4,4,4" BorderThickness="1,1,1,1" BorderBrush="#5D8CC9" x:Name="hover" Opacity="0" Background="#10000000"> 11 <!--<TextBlock Text="Click to add appointment" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#A39DD8" />--> 12 </Border> 13 </Border> 14 <ControlTemplate.Triggers> 15 <Trigger Property="IsMouseOver" Value="True"> 16 <Setter Property="Opacity" Value="1" TargetName="hover" /> 17 </Trigger> 18 </ControlTemplate.Triggers> 19 </ControlTemplate> 20 </Setter.Value> 21 </Setter> 22 </Style>View Code
CalendarLedgerItem前臺代碼
1 <Style TargetType="{x:Type local:CalendarLedgerItem}"> 2 <Setter Property="Template"> 3 <Setter.Value> 4 <ControlTemplate TargetType="{x:Type local:CalendarLedgerItem}"> 5 <Border Background="#E3EFFF" 6 BorderBrush="#6593CF" 7 BorderThickness="0,0,1,1" 8 Height="44" Width="50"> 9 <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center"> 10 <TextBlock Text="{TemplateBinding TimeslotA}" Foreground="#9493CF" FontSize="16" Margin="0,3,0,0"/> 11 <TextBlock Text="{TemplateBinding TimeslotB}" Foreground="#9493CF" Margin="1.5,0,0,0"/> 12 </StackPanel> 13 </Border> 14 </ControlTemplate> 15 </Setter.Value> 16 </Setter> 17 </Style>View Code
CalendarLedger前臺代碼
1 <Style TargetType="{x:Type local:CalendarLedger}"> 2 <Setter Property="Template"> 3 <Setter.Value> 4 <ControlTemplate TargetType="{x:Type local:CalendarLedger}"> 5 <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> 6 <StackPanel> 7 <local:CalendarLedgerItem TimeslotA="0" TimeslotB="00" /> 8 <local:CalendarLedgerItem TimeslotA="1" TimeslotB="00" /> 9 <local:CalendarLedgerItem TimeslotA="2" TimeslotB="00" /> 10 <local:CalendarLedgerItem TimeslotA="3" TimeslotB="00" /> 11 <local:CalendarLedgerItem TimeslotA="4" TimeslotB="00" /> 12 <local:CalendarLedgerItem TimeslotA="5" TimeslotB="00" /> 13 <local:CalendarLedgerItem TimeslotA="6" TimeslotB="00" /> 14 <local:CalendarLedgerItem TimeslotA="7" TimeslotB="00" /> 15 <local:CalendarLedgerItem TimeslotA="8" TimeslotB="00" /> 16 <local:CalendarLedgerItem TimeslotA="9" TimeslotB="00" /> 17 <local:CalendarLedgerItem TimeslotA="10" TimeslotB="00" /> 18 <local:CalendarLedgerItem TimeslotA="11" TimeslotB="00" /> 19 <local:CalendarLedgerItem TimeslotA="12" TimeslotB="00" /> 20 <local:CalendarLedgerItem TimeslotA="13" TimeslotB="00" /> 21 <local:CalendarLedgerItem TimeslotA="14" TimeslotB="00" /> 22 <local:CalendarLedgerItem TimeslotA="15" TimeslotB="00" /> 23 <local:CalendarLedgerItem TimeslotA="16" TimeslotB="00" /> 24 <local:CalendarLedgerItem TimeslotA="17" TimeslotB="00" /> 25 <local:CalendarLedgerItem TimeslotA="18" TimeslotB="00" /> 26 <local:CalendarLedgerItem TimeslotA="19" TimeslotB="00" /> 27 <local:CalendarLedgerItem TimeslotA="20" TimeslotB="00" /> 28 <local:CalendarLedgerItem TimeslotA="21" TimeslotB="00" /> 29 <local:CalendarLedgerItem TimeslotA="22" TimeslotB="00" /> 30 <local:CalendarLedgerItem TimeslotA="23" TimeslotB="00" /> 31 </StackPanel> 32 </Border> 33 </ControlTemplate> 34 </Setter.Value> 35 </Setter> 36 </Style>View Code
CalendarDay前臺代碼
1 <Style TargetType="{x:Type local:CalendarDay}"> 2 <Setter Property="ItemsPanel"> 3 <Setter.Value> 4 <ItemsPanelTemplate> 5 <local:TimeslotPanel /> 6 </ItemsPanelTemplate> 7 </Setter.Value> 8 </Setter> 9 <Setter Property="Template"> 10 <Setter.Value> 11 <ControlTemplate TargetType="{x:Type local:CalendarDay}"> 12 <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> 13 <Grid> 14 <StackPanel> 15 <local:CalendarTimeslotItem Background="#E6EDF7" /> 16 <local:CalendarTimeslotItem Background="#E6EDF7" /> 17 <local:CalendarTimeslotItem Background="#E6EDF7" /> 18 <local:CalendarTimeslotItem Background="#E6EDF7" /> 19 <local:CalendarTimeslotItem Background="#E6EDF7" /> 20 <local:CalendarTimeslotItem Background="#E6EDF7" /> 21 <local:CalendarTimeslotItem Background="#E6EDF7" /> 22 <local:CalendarTimeslotItem Background="#E6EDF7" /> 23 <local:CalendarTimeslotItem Background="#E6EDF7" /> 24 <local:CalendarTimeslotItem Background="#E6EDF7" /> 25 <local:CalendarTimeslotItem Background="#E6EDF7" /> 26 <local:CalendarTimeslotItem Background="#E6EDF7" /> 27 <local:CalendarTimeslotItem Background="#E6EDF7" /> 28 <local:CalendarTimeslotItem Background="#E6EDF7" /> 29 <local:CalendarTimeslotItem Background="#E6EDF7" /> 30 <local:CalendarTimeslotItem Background="#E6EDF7" /> 31 <local:CalendarTimeslotItem Background="White" /> 32 <local:CalendarTimeslotItem Background="White" /> 33 <local:CalendarTimeslotItem Background="White" /> 34 <local:CalendarTimeslotItem Background="White" /> 35 <local:CalendarTimeslotItem Background="White" /> 36 <local:CalendarTimeslotItem Background="White" /> 37 <local:CalendarTimeslotItem Background="White" /> 38 <local:CalendarTimeslotItem Background="White" /> 39 <local:CalendarTimeslotItem Background="White" /> 40 <local:CalendarTimeslotItem Background="White" /> 41 <local:CalendarTimeslotItem Background="White" /> 42 <local:CalendarTimeslotItem Background="White" /> 43 <local:CalendarTimeslotItem Background="White" /> 44 <local:CalendarTimeslotItem Background="White" /> 45 <local:CalendarTimeslotItem Background="White" /> 46 <local:CalendarTimeslotItem Background="White" /> 47 <local:CalendarTimeslotItem Background="White" /> 48 <local:CalendarTimeslotItem Background="White" /> 49 <local:CalendarTimeslotItem Background="White" /> 50 <local:CalendarTimeslotItem Background="White" /> 51 <local:CalendarTimeslotItem Background="White" /> 52 <local:CalendarTimeslotItem Background="White" /> 53 <local:CalendarTimeslotItem Background="#E6EDF7" /> 54 <local:CalendarTimeslotItem Background="#E6EDF7" /> 55 <local:CalendarTimeslotItem Background="#E6EDF7" /> 56 <local:CalendarTimeslotItem Background="#E6EDF7" /> 57 <local:CalendarTimeslotItem Background="#E6EDF7" /> 58 <local:CalendarTimeslotItem Background="#E6EDF7" /> 59 <local:CalendarTimeslotItem Background="#E6EDF7" /> 60 <local:CalendarTimeslotItem Background="#E6EDF7" /> 61 <local:CalendarTimeslotItem Background="#E6EDF7" /> 62 <local:CalendarTimeslotItem Background="#E6EDF7" /> 63 </StackPanel> 64 <ItemsPresenter /> 65 </Grid> 66 </Border> 67 </ControlTemplate> 68 </Setter.Value> 69 </Setter> 70 </Style>View Code
Calendar前臺代碼
1 <Style TargetType="{x:Type local:Calendar}"> 2 <Setter Property="Template"> 3 <Setter.Value> 4 <ControlTemplate TargetType="{x:Type local:Calendar}"> 5 <Border Background="#E3EFFF" BorderBrush="#6593CF" BorderThickness="2,2,2,2"> 6 <Grid> 7 <Grid.ColumnDefinitions> 8 <ColumnDefinition Width="50" /> 9 <ColumnDefinition Width="*" /> 10 </Grid.ColumnDefinitions> 11 <Grid.RowDefinitions> 12 <RowDefinition Height="38" /> 13 <RowDefinition Height="22" /> 14 <RowDefinition Height="*" /> 15 </Grid.RowDefinitions> 16 17 <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="5,0,0,0"> 18 <Button Height="25" Command="{x:Static local:Calendar.PreviousDay}" Background="{x:Null}" BorderBrush="{x:Null}"> 19 <Image Source="/Images/Previous.png" /> 20 </Button> 21 <Button Height="25" Command="{x:Static local:Calendar.NextDay}" Background="{x:Null}" BorderBrush="{x:Null}"> 22 <Image Source="/Images/Next.png" /> 23 </Button> 24 </StackPanel> 25 <Border BorderBrush="#6593CF" BorderThickness="0,0,1,1" Grid.Column="0" Grid.Row="1" /> 26 <Border BorderBrush="#6593CF" BorderThickness="0,1,0,1" Background="#30000000" Grid.Column="1" Grid.Row="1"> 27 <TextBlock Text="{TemplateBinding CurrentDate}" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="dayHeader" /> 28 </Border> 29 <ScrollViewer Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"> 30 <Grid> 31 <Grid.ColumnDefinitions> 32 <ColumnDefinition Width="50" /> 33 <ColumnDefinition Width="*" /> 34 </Grid.ColumnDefinitions> 35 36 <local:CalendarLedger Grid.Column="0" /> 37 <local:CalendarDay Grid.Column="1" x:Name="day" /> 38 </Grid> 39 </ScrollViewer> 40 </Grid> 41 </Border> 42 </ControlTemplate> 43 </Setter.Value> 44 </Setter> 45 </Style>View Code
CalendarAppointmentItem前臺代碼
1 <Style TargetType="{x:Type local:CalendarAppointmentItem}"> 2 <Setter Property="AppointmentItem" Value="{Binding AppointmentItem}"/> 3 <Setter Property="StartTime" Value="{Binding StartTime}"/> 4 <Setter Property="EndTime" Value="{Binding EndTime}"/> 5 <Setter Property="Template"> 6 <Setter.Value> 7 <ControlTemplate TargetType="{x:Type local:CalendarAppointmentItem}"> 8 <Border CornerRadius="1,1,1,1" BorderThickness="1,1,1,1" BorderBrush="#5D8CC9" Background="#F1F5E3" Margin="1,1,1,1" Padding="3,1,0,1"> 9 <ContentPresenter ToolTip="{Binding}" /> 10 </Border> 11 </ControlTemplate> 12 </Setter.Value> 13 </Setter> 14 </Style>View Code
日曆控制項是用WPF自定義控制項做的,裡面有些複雜,實在不知道如何實現上述功能,有人願意研究可以看一下,提供源碼。
鏈接:https://pan.baidu.com/s/15G9scu-l_uelMbTUyagilg
提取碼:6666
--------------------------------------------------
只有對寫程式充滿熱情,才能寫出好的程式!