WPF实现类似网易云音乐的菜单切换

这里是借助三方UI框架实现了,感兴趣的小伙伴可以看一下。

深色模式:​

浅色模式:

​这里主要使用了以下三个包:

MahApps.Metro:UI库,提供菜单导航和其它控件​​​​​​​

实现步骤:1、使用BlurWindow放置一个窗口

 1 <tianxia:BlurWindow x:Class="GameOptimizerTool.MainWindow"
 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"
 9         xmlns:tianxia="clr-namespace:TianXiaTech"
10         mc:Ignorable="d"
11         Title="工具箱" Height="650" Width="1100" TitleForeground="{DynamicResource MahApps.Brushes.Text}" Icon="logo.png" Background="{DynamicResource MahApps.Brushes.ThemeBackground}">
12     <Grid>
13     </Grid>
14 </tianxia:BlurWindow>

这里的一些颜色使用了动态资源 ,以便实现深色和浅色模式的切换。

2、引入 XAML命名空间前缀

1   xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
2   xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
3   xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"

3、放置HamburgerMenu控件

通过设置HamburgerMenu.ItemsSource属性,可以设置菜单项

通过设置HamburgerMenu.OptionsItemsSource属性,可以增加设置项,设置项会显示在左下角

注意:这里我们需要设置控件的控件模板,否则 会显示异常

 1  <mah:HamburgerMenu x:Name="HamburgerMenuControl"
 2                    CompactPaneLength="48"
 3                    OpenPaneLength="70"
 4                    HamburgerWidth="48"
 5                    IsPaneOpen="True"
 6                    ItemInvoked="HamburgerMenuControl_OnItemInvoked"
 7                    ItemTemplate="{StaticResource MenuItemTemplate}"
 8                    OptionsItemTemplate="{StaticResource MenuItemTemplate}"
 9                    SelectedIndex="0"
10                    Style="{StaticResource MahApps.Styles.HamburgerMenu.Ripple}"
11                    VerticalScrollBarOnLeftSide="False">
12      <!--Items-->  
13      <mah:HamburgerMenu.ItemsSource>
14          <mah:HamburgerMenuItemCollection>
15              <mah:HamburgerMenuIconItem Icon="{iconPacks:Material Kind=Home}" Label="首页">
16                  <mah:HamburgerMenuIconItem.Tag>
17                      <local:HomeView />
18                  </mah:HamburgerMenuIconItem.Tag>
19          </mah:HamburgerMenuItemCollection>
20      </mah:HamburgerMenu.ItemsSource>
21 
22      <!--设置-->  
23      <mah:HamburgerMenu.OptionsItemsSource>
24          <mah:HamburgerMenuItemCollection>
25              <mah:HamburgerMenuIconItem Icon="{iconPacks:Material Kind=Cog}" Label="设置">
26                  <mah:HamburgerMenuIconItem.Tag>
27                      <local:OptimizerView />
28                  </mah:HamburgerMenuIconItem.Tag>
29              </mah:HamburgerMenuIconItem>
30          </mah:HamburgerMenuItemCollection>
31      </mah:HamburgerMenu.OptionsItemsSource>
32 
33      <mah:HamburgerMenu.ContentTemplate>
34          <DataTemplate DataType="{x:Type mah:HamburgerMenuIconItem}">
35              <Grid Margin="20 0 10 0">
36                  <Grid.RowDefinitions>
37                      <RowDefinition Height="Auto" />
38                      <RowDefinition Height="*" />
39                  </Grid.RowDefinitions>
40                  <!--标题文本,如果需要大标题显示,取消注释这段代码-->
41                  <TextBlock Grid.Row="0"
42                            Margin="0 15 0 5"
43                            Padding="0"
44                            FontFamily="{DynamicResource MahApps.Fonts.Family.Header}"
45                            FontSize="{DynamicResource MahApps.Font.Size.Header}"
46                            Foreground="{DynamicResource MahApps.Brushes.Text}"
47                            Text="{Binding Label}" />
48                  <ScrollViewer Grid.Row="1"
49                               Focusable="False"
50                               HorizontalScrollBarVisibility="Disabled"
51                               VerticalScrollBarVisibility="Auto">
52                      <ContentControl Content="{Binding Tag}" Focusable="False" />
53                  </ScrollViewer>
54              </Grid>
55          </DataTemplate>
56      </mah:HamburgerMenu.ContentTemplate>
57 
58  </mah:HamburgerMenu>

4、设置HamburgerMenu控件菜单项的样式

我们直接放到窗口资源 里

  1  <tianxia:BlurWindow.Resources>
  2      <ResourceDictionary>
  3          <!--左侧菜单的样式-->
  4          <DataTemplate x:Key="MenuItemTemplate" DataType="{x:Type mah:HamburgerMenuIconItem}">
  5              <Grid Height="40">
  6                  <Grid.ColumnDefinitions>
  7                      <ColumnDefinition Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type mah:HamburgerMenu}}, Path=CompactPaneLength}" />
  8                      <ColumnDefinition />
  9                  </Grid.ColumnDefinitions>
 10                  <ContentControl Grid.Column="0"
 11                               HorizontalAlignment="Center"
 12                               VerticalAlignment="Center"
 13                               Content="{Binding Icon}"
 14                               Focusable="False"
 15                               IsTabStop="False" />
 16                  <TextBlock Grid.Column="1"
 17                          VerticalAlignment="Center"
 18                          FontSize="13"
 19                          Text="{Binding Label}" />
 20              </Grid>
 21          </DataTemplate>
 22 
 23          <ObjectDataProvider x:Key="DisplayModeEnumValues"
 24                           MethodName="GetValues"
 25                           ObjectType="{x:Type mah:SplitViewDisplayMode}">
 26              <ObjectDataProvider.MethodParameters>
 27                  <x:Type TypeName="mah:SplitViewDisplayMode" />
 28              </ObjectDataProvider.MethodParameters>
 29          </ObjectDataProvider>
 30 
 31          <ObjectDataProvider x:Key="VisibilityEnumValues"
 32                           MethodName="GetValues"
 33                           ObjectType="{x:Type Visibility}">
 34              <ObjectDataProvider.MethodParameters>
 35                  <x:Type TypeName="Visibility" />
 36              </ObjectDataProvider.MethodParameters>
 37          </ObjectDataProvider>
 38 
 39          <Style x:Key="MahApps.Styles.ListBoxItem.HamburgerMenuItem.Ripple"
 40              BasedOn="{StaticResource MahApps.Styles.ListBoxItem.HamburgerMenuItem}"
 41              TargetType="{x:Type ListBoxItem}">
 42              <Setter Property="Template">
 43                  <Setter.Value>
 44                      <ControlTemplate TargetType="{x:Type ListBoxItem}">
 45                          <Grid x:Name="RootGrid"
 46                             Background="Transparent"
 47                             RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}">
 48                              <Border x:Name="Border"
 49                                   Background="{TemplateBinding Background}"
 50                                   BorderBrush="{TemplateBinding BorderBrush}"
 51                                   BorderThickness="{TemplateBinding BorderThickness}"
 52                                   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
 53                              <Grid Margin="{TemplateBinding BorderThickness}">
 54                                  <Grid HorizontalAlignment="Left"
 55                                     VerticalAlignment="Center"
 56                                     Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:HamburgerMenu}}, Path=ShowSelectionIndicator, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
 57                                      <Rectangle x:Name="SelectionIndicator"
 58                                              Width="{DynamicResource HamburgerMenuSelectionIndicatorThemeWidth}"
 59                                              Height="{DynamicResource HamburgerMenuSelectionIndicatorThemeHeight}"
 60                                              Fill="{TemplateBinding Foreground}"
 61                                              Focusable="False"
 62                                              Opacity="0.0" />
 63                                  </Grid>
 64                                  <materialDesign:Ripple x:Name="ContentPresenter"
 65                                                      Padding="{TemplateBinding Padding}"
 66                                                      HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
 67                                                      VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
 68                                                      Content="{TemplateBinding Content}"
 69                                                      ContentTemplate="{TemplateBinding ContentTemplate}"
 70                                                      ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
 71                                                      Feedback="{DynamicResource MahApps.Brushes.Gray.MouseOver}"
 72                                                      Focusable="False"
 73                                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
 74                              </Grid>
 75                          </Grid>
 76                          <ControlTemplate.Triggers>
 77                              <Trigger Property="IsSelected" Value="True">
 78                                  <Setter TargetName="Border" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.SelectedBackgroundBrush), Mode=OneWay}" />
 79                                  <Setter TargetName="ContentPresenter" Property="Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.SelectedForegroundBrush), Mode=OneWay}" />
 80                                  <Setter TargetName="SelectionIndicator" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.SelectedForegroundBrush), Mode=OneWay}" />
 81                                  <Setter TargetName="SelectionIndicator" Property="Opacity" Value="1.0" />
 82                              </Trigger>
 83                              <MultiTrigger>
 84                                  <MultiTrigger.Conditions>
 85                                      <Condition Property="IsSelected" Value="True" />
 86                                      <Condition Property="Selector.IsSelectionActive" Value="True" />
 87                                  </MultiTrigger.Conditions>
 88                                  <Setter TargetName="Border" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.ActiveSelectionBackgroundBrush), Mode=OneWay}" />
 89                                  <Setter TargetName="ContentPresenter" Property="Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.ActiveSelectionForegroundBrush), Mode=OneWay}" />
 90                                  <Setter TargetName="SelectionIndicator" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.ActiveSelectionForegroundBrush), Mode=OneWay}" />
 91                              </MultiTrigger>
 92 
 93                              <MultiTrigger>
 94                                  <MultiTrigger.Conditions>
 95                                      <Condition Property="IsMouseOver" Value="True" />
 96                                      <Condition Property="IsSelected" Value="True" />
 97                                  </MultiTrigger.Conditions>
 98                                  <Setter TargetName="Border" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.HoverSelectedBackgroundBrush), Mode=OneWay}" />
 99                                  <Setter TargetName="ContentPresenter" Property="Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.HoverSelectedForegroundBrush), Mode=OneWay}" />
100                                  <Setter TargetName="SelectionIndicator" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.HoverSelectedForegroundBrush), Mode=OneWay}" />
101                              </MultiTrigger>
102                              <MultiTrigger>
103                                  <MultiTrigger.Conditions>
104                                      <Condition Property="IsMouseOver" Value="True" />
105                                      <Condition Property="IsSelected" Value="False" />
106                                  </MultiTrigger.Conditions>
107                                  <Setter TargetName="Border" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.HoverBackgroundBrush), Mode=OneWay}" />
108                                  <Setter TargetName="ContentPresenter" Property="Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.HoverForegroundBrush), Mode=OneWay}" />
109                                  <Setter TargetName="SelectionIndicator" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.HoverForegroundBrush), Mode=OneWay}" />
110                              </MultiTrigger>
111 
112                              <Trigger Property="mah:ItemHelper.IsMouseLeftButtonPressed" Value="True">
113                                  <Setter TargetName="Border" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.MouseLeftButtonPressedBackgroundBrush), Mode=OneWay}" />
114                                  <Setter TargetName="ContentPresenter" Property="Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.MouseLeftButtonPressedForegroundBrush), Mode=OneWay}" />
115                                  <Setter TargetName="SelectionIndicator" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.MouseLeftButtonPressedForegroundBrush), Mode=OneWay}" />
116                              </Trigger>
117                              <Trigger Property="mah:ItemHelper.IsMouseRightButtonPressed" Value="True">
118                                  <Setter TargetName="Border" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.MouseRightButtonPressedBackgroundBrush), Mode=OneWay}" />
119                                  <Setter TargetName="ContentPresenter" Property="Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.MouseRightButtonPressedForegroundBrush), Mode=OneWay}" />
120                                  <Setter TargetName="SelectionIndicator" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.MouseRightButtonPressedForegroundBrush), Mode=OneWay}" />
121                              </Trigger>
122 
123                              <Trigger Property="IsEnabled" Value="False">
124                                  <Setter TargetName="Border" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.DisabledBackgroundBrush), Mode=OneWay}" />
125                                  <Setter TargetName="ContentPresenter" Property="Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.DisabledForegroundBrush), Mode=OneWay}" />
126                                  <Setter TargetName="RootGrid" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background, Mode=OneWay}" />
127                                  <Setter TargetName="SelectionIndicator" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.DisabledForegroundBrush), Mode=OneWay}" />
128                              </Trigger>
129                              <MultiTrigger>
130                                  <MultiTrigger.Conditions>
131                                      <Condition Property="IsEnabled" Value="False" />
132                                      <Condition Property="IsSelected" Value="True" />
133                                  </MultiTrigger.Conditions>
134                                  <Setter TargetName="Border" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.DisabledSelectedBackgroundBrush), Mode=OneWay}" />
135                                  <Setter TargetName="ContentPresenter" Property="Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.DisabledSelectedForegroundBrush), Mode=OneWay}" />
136                                  <Setter TargetName="SelectionIndicator" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.DisabledSelectedForegroundBrush), Mode=OneWay}" />
137                              </MultiTrigger>
138                          </ControlTemplate.Triggers>
139                      </ControlTemplate>
140                  </Setter.Value>
141              </Setter>
142              <Setter Property="mah:ItemHelper.ActiveSelectionBackgroundBrush" Value="Transparent" />
143              <Setter Property="mah:ItemHelper.ActiveSelectionForegroundBrush" Value="{DynamicResource MahApps.Brushes.AccentBase}" />
144              <Setter Property="mah:ItemHelper.DisabledForegroundBrush" Value="{DynamicResource MahApps.Brushes.Gray}" />
145              <Setter Property="mah:ItemHelper.DisabledSelectedBackgroundBrush" Value="Transparent" />
146              <Setter Property="mah:ItemHelper.DisabledSelectedForegroundBrush" Value="{DynamicResource MahApps.Brushes.Gray}" />
147              <Setter Property="mah:ItemHelper.HoverBackgroundBrush" Value="{DynamicResource MahApps.Brushes.Gray.SemiTransparent}" />
148              <Setter Property="mah:ItemHelper.HoverSelectedBackgroundBrush" Value="{DynamicResource MahApps.Brushes.Gray.SemiTransparent}" />
149              <Setter Property="mah:ItemHelper.HoverSelectedForegroundBrush" Value="{DynamicResource MahApps.Brushes.AccentBase}" />
150              <Setter Property="mah:ItemHelper.SelectedBackgroundBrush" Value="Transparent" />
151              <Setter Property="mah:ItemHelper.SelectedForegroundBrush" Value="{DynamicResource MahApps.Brushes.AccentBase}" />
152          </Style>
153 
154          <Style x:Key="MahApps.Styles.HamburgerMenu.Ripple"
155              BasedOn="{StaticResource MahApps.Styles.HamburgerMenu}"
156              TargetType="{x:Type mah:HamburgerMenu}">
157              <Setter Property="ItemContainerStyle" Value="{StaticResource MahApps.Styles.ListBoxItem.HamburgerMenuItem.Ripple}" />
158              <Setter Property="OptionsItemContainerStyle" Value="{StaticResource MahApps.Styles.ListBoxItem.HamburgerMenuItem.Ripple}" />
159              <Setter Property="PaneBackground" Value="{DynamicResource MahApps.Brushes.ThemeBackground}" />
160              <Setter Property="PaneForeground" Value="{DynamicResource MahApps.Brushes.Text}" />
161              <Setter Property="ShowSelectionIndicator" Value="True" />
162          </Style>
163 
164      </ResourceDictionary>
165  </tianxia:BlurWindow.Resources>

5、增加菜单项切换时的事件处理程序

在放置HamburgerMenu控件时,设置了ItemInvoked事件

1 ItemInvoked="HamburgerMenuControl_OnItemInvoked"

事件处理程序如下:

1   private void HamburgerMenuControl_OnItemInvoked(object sender, MahApps.Metro.Controls.HamburgerMenuItemInvokedEventArgs args)
2   {
3       HamburgerMenuControl.Content = args.InvokedItem;
4   }

6、切换深色模式

MahApps.Metro提供了模式切换的功能,直接调用以下代码即可

1 private void Window_Loaded(object sender, RoutedEventArgs e)
2 {
3     ThemeManager.Current.ChangeThemeBaseColor(Application.Current, "Dark");
4 }

HamburgerMenu控件是如何实现的

这里内部其实是使用的ListBox,ListBox自身已经具备了切换事件和选中事件,所以在ListBox的基础上,加以封装,就能实现HamburgerMenu。

这里不做详细介绍,可以参考MahApps.Metro源码里的Themes\HamburgerMenuTemplate.xamlControls\HamburgerMenu里的文件。

项目地址:GitHub - MahApps/MahApps.Metro: A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.

最终效果

示例代码

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/895479.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【含文档】基于Springboot+Vue的二手书籍交易系统(含源码+数据库+lw)

1.开发环境 开发系统:Windows10/11 架构模式:MVC/前后端分离 JDK版本: Java JDK1.8 开发工具:IDEA 数据库版本: mysql5.7或8.0 数据库可视化工具: navicat 服务器: SpringBoot自带 apache tomcat 主要技术: Java,Springboot,mybatis,mysql,vue 2.视频演示地址 3.功能 系统定…

博流bl616开发笔记

本文大体框架如图 目录 一、博流BL616、BL618基本框架、信息二、博流烧录环境搭建1. Windows环境1.1 SDK1.2 编译工具链1.3 开发工具1.4 程序编译下载1.4.1 eclipse使用步骤1.4.2 vscode使用步骤 2. Linux环境 三、基本外设使用前言1.GPIO1.1 硬件原理图1.2 API1.2.1句柄1.2.2…

3d NMDS多样性分析图 R语言

# 安装并加载必要的包 if (!require("vegan")) install.packages("vegan") if (!require("ggplot2")) install.packages("ggplot2") if (!require("plotly")) install.packages("plotly") if (!require("ret…

code CERT_HAS_EXPIRED npm ERR! errno CERT_HAS_EXPIRED 证书过期

解决方案&#xff1a; 1、以管理员权限打开cmd 2、 若项目在D盘,先换成D: 3、cd进入项目路径 4、清空缓存 npm cache clean --force 5、查看当前的npm镜像设置 npm config get registry 6、切换新源 npm config set registry https://registry.npmmirror.com 7、查看新源…

六大知名Web安全漏洞靶场

如果想搞懂一个漏洞&#xff0c;最好的方法是先编写出这个漏洞&#xff0c;然后利用它&#xff0c;最后修复它。漏洞靶场模拟真实环境&#xff0c;它为网络安全人员提供了一个安全可控的平台&#xff0c;用于发现、评估和测试应用程序、系统或网络设备的安全漏洞。WEB漏洞靶场可…

【Linux】如何通过系统宏定义,获取进程的退出码或退出信号

我们可以通过系统写好的宏来获取获取进程的退出码或退出信号&#xff1a;底层是通过对 waitpid 函数参数 status 进行位运算&#xff0c;取对应部分的数值 一、相关宏定义的介绍 waitpid(pid, &status, 0);&#xff1a; 这行代码等待指定 PID (pid) 的子进程结束&#x…

linux环境下C程序的编译过程以及makefile的简单使用

在windows下&#xff0c;很多用来进行编程软件对于写好的文件&#xff0c;点击编译即可生成想要文件。如.exe可执行文件&#xff0c;.hex文件或者.bin文件等等。软件为我们省略了很多事。但是对于linux初学者来说&#xff0c;初次接触linux系统&#xff0c;面对命令行黑框框有点…

Java后端面试题:MySQL篇

目录 MySQL基础部分 1. SELECT语句完整的执行顺序是什么&#xff1f; 2. 说一说内连接和外连接。 3. 请说说数据库三大范式。 4. 请你说说视图的作用&#xff0c;视图可以更改么&#xff1f; 架构 5. 请你说一说MySQL架构。 6. 请你说说一条SQL语句的执行过程&#xff…

MIT 6.5840(6.824) Lab 5:Sharded Key/Value Service 设计实现

文章目录 1 实验要求1.1 介绍1.2 lab5A&#xff1a;控制器和静态分片1.3 lab5B&#xff1a;碎片移动1.4 挑战任务 2 实验设计2.1 整体架构2.2 shardctrler2.3 shardkv server2.3.1 结构2.3.2 日志类型2.3.3 读写服务2.3.4 配置更新检测2.3.5 分片迁移2.3.6 垃圾回收2.3.7 空日志…

一个简单的Qt Console Application计算练习程序

初步体验Qt Creator 用途&#xff1a;练习20以内2位数乘法速算的程序 功能1&#xff1a;支持用户设定题目数量 std::cout << "请输入本次练习题目数量&#xff1a;";int numProblems 0;std::string num;std::cin >> num;try {numProblems std::stoi(…

【云从】六、云存储

文章目录 1、应用架构2、存储设备3、存储方案3.1 直连式存储DAS3.2 网络连接存储NAS3.3 存储区域网络SAN3.4 分布式存储ServerSAN3.5 软件定义存储SDS 4、云存储4.1 云硬盘CBS4.2 文件存储CFS4.3 对象存储COS 1、应用架构 2、存储设备 硬盘性能对比&#xff1a; 硬盘接口对比&…

ubuntu docker安装elasticsearch:7.12.1

#es和kibana容器互联网络 docker network create es-netdocker pull elasticsearch:7.12.1 docker pull kibana:7.12.1 mkdir -p /root/datas/docker/es/data mkdir -p /root/datas/docker/es/logs mkdir -p /root/datas/docker/es/pluginssudo chmod -R 777 /root/datas/docke…

高级算法设计与分析 学习笔记13 线性规划

注意是线性规划不是动态规划哦 好家伙&#xff0c;这不是凸优化吗&#xff1f; 凸优化标准形式&#xff1a; 先改成统一最大化&#xff08;凸优化那边怎么是统一最小化&#xff1f;&#xff09; 原来的x2正负无所谓&#xff0c;但我希望每个x都是有限制的&#xff0c;所以把它改…

鸿蒙网络编程系列24-Web组件与应用互操作示例

1. APP内嵌网页与应用互操作概述 在通常的APP开发中&#xff0c;经常会采用内嵌网页的形式&#xff0c;通过网页来展现丰富的动态内容&#xff0c;虽少了很多原生开发的功能&#xff0c;但是这么做无可厚非&#xff0c;毕竟APP需要适配的系统平台很多&#xff0c;比如安卓、苹…

递归神经网络(RNN)简介

递归神经网络简介 在本文中,我们将介绍神经网络的一种新的变体,即递归神经网络,也称为 (RNN),当数据是连续的时,如时间序列数据和文本数据,它比简单的神经网络效果更好。 什么是递归神经网络 (RNN)? 循环神经网络 (RNN) 是一种神经网络,其中上一步的输出作为当前…

王道考研视频——操作系统笔记

操作系统 1.1 操作系统的概念、特征、功能、目标 操作系统&#xff08; Operating System&#xff0c;OS&#xff09;是指控制和管理整个计算机系统的硬件和软件资源&#xff0c;并合理地组织调度计算机的工作和资源的分配&#xff0c;以提供给用户和其他软件方便的接口和环境…

[数据结构]栈的实现与应用

文章目录 一、引言二、栈的基本概念1、栈是什么2、栈的实现方式对比3、函数栈帧 三、栈的实现1、结构体定义2、初始化3、销毁4、显示5、数据操作 四、分析栈1、优点2、缺点 五、总结1、练习题2、源代码 一、引言 栈&#xff0c;作为一种基础且重要的数据结构&#xff0c;在计算…

【数据结构】滑动窗口算法详解:高效解决子串问题

滑动窗口&#xff08;Sliding Window&#xff09;是一种常用于处理数组或字符串中子序列问题的算法技巧。它通过维护一个窗口来限制待处理的数据范围&#xff0c;从而高效地解决问题&#xff0c;避免重复计算。它的时间复杂度通常为 O(N)&#xff0c;相较于暴力破解&#xff08…

Go 项目如何集成类似mybatisPlus插件呢?GORM走起!!

导读&#xff1a; 在 Go 项目中&#xff0c;虽然没有像 MyBatis Plus 这样特定的 ORM 插件&#xff0c;但可以使用功能相似的 Go ORM 框架&#xff0c;比如 GORM&#xff0c;它支持链式查询、自动迁移、预加载等功能&#xff0c;与 MyBatis Plus 有相似之处。通过一些插件或扩…

常用API

Object类&#xff1a; instanceof&#xff1a;java中的关键字&#xff0c;判断左边的对象是否是右面类的实例。 它的作用是判断其左边对象是否为其右边类的实例&#xff0c;返回boolean类型的数据。 getClass()&#xff1a;得到调用者的数据类型&#xff1b; 进行对象内容比较…