WPF Prism IModule,IEventAggregaor GetEvent Publish Subscribe

news/2025/10/2 16:56:00/文章来源:https://www.cnblogs.com/Fred1987/p/19123748
Install-Package Prism.DryIOC;
Install-Package Prism.Wpf;

 

 

//BookModule
using BookModule.Services;
using BookModule.ViewModels;
using BookModule.Views;
using System;
using System.Collections.Generic;
using System.Text;namespace BookModule
{public class BookModule : IModule{private IRegionManager regionManager;public BookModule(IRegionManager regionManagerValue){regionManager = regionManagerValue;}public void OnInitialized(IContainerProvider containerProvider){regionManager.RegisterViewWithRegion("BooksRegion", typeof(BookView));}public void RegisterTypes(IContainerRegistry containerRegistry){containerRegistry.Register<IIDService, IDService>();containerRegistry.Register<INameService, NameService>();containerRegistry.Register<IISBNService, ISBNService>();containerRegistry.RegisterForNavigation<BookView, BookViewViewModel>("BookView");}}
}//UserModule
using System;
using System.Collections.Generic;
using System.Text;
using UserModule.ViewModels;
using UserModule.Views;namespace UserModule
{public class UserModule : IModule{IRegionManager regionManager;public UserModule(IRegionManager regionManagerValue){regionManager = regionManagerValue;}public void OnInitialized(IContainerProvider containerProvider){//regionManager.RegisterViewWithRegion("UserRegion",typeof(UserView));
        }public void RegisterTypes(IContainerRegistry containerRegistry){containerRegistry.RegisterForNavigation<UserView, UserViewModel>("UserView");}}
}//App.xaml.cs
using BookModule;
using BookModule.Services;
using BookModule.ViewModels;
using BookModule.Views;
using Prism.Commands;
using Prism.Ioc;
using Prism.Modularity;
using System.Configuration;
using System.Data;
using System.Windows;
using UserModule;
using UserModule.ViewModels;
using UserModule.Views;namespace WpfApp22
{/// <summary>/// Interaction logic for App.xaml/// </summary>public partial class App : PrismApplication{protected override Window CreateShell(){return Container.Resolve<ShellView>();}protected override void OnInitialized(){base.OnInitialized();var regionManager = Container.Resolve<IRegionManager>();regionManager.RequestNavigate("BookRegion", "BookView");regionManager.RequestNavigate("UserRegion", "UserView");}protected override void RegisterTypes(IContainerRegistry containerRegistry){         containerRegistry.RegisterForNavigation<ShellView, ShellViewModel>();}protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog){base.ConfigureModuleCatalog(moduleCatalog);moduleCatalog.AddModule<BookModule.BookModule>();moduleCatalog.AddModule<UserModule.UserModule>();}}}

 

 

 

using System;
using System.Collections.Generic;
using System.Text;namespace BookModule.Models
{public class StatusUpdatedEvent : PubSubEvent<string>{}
}public class BookViewViewModel : BindableBase
{IIDService idService;IISBNService isbnService;INameService nameService;IEventAggregator eventAggregator;public BookViewViewModel(IIDService idServiceValue, IISBNService isbnServiceValue,INameService nameServiceValue, IEventAggregator eventAggregatorValue){idService = idServiceValue;isbnService = isbnServiceValue;nameService = nameServiceValue;eventAggregator = eventAggregatorValue;}public void UpdateMainStatus(string mainStatusValue){eventAggregator.GetEvent<StatusUpdatedEvent>().Publish(mainStatusValue);}
}public class ShellViewModel : BindableBase
{private IEventAggregator eventAggregator;public ShellViewModel(IEventAggregator eventAggregatorValue){eventAggregator = eventAggregatorValue;eventAggregator.GetEvent<StatusUpdatedEvent>().Subscribe(OnStatusUpdated);MainStatus = "Loading...";MainStr = $"In Main view,now is {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}";System.Timers.Timer tmr = new System.Timers.Timer();tmr.Interval = 1000;tmr.Elapsed += Tmr_Elapsed;tmr.Start();}private void OnStatusUpdated(string statusValue){MainStatus = statusValue;}public void OnUnload(){eventAggregator.GetEvent<StatusUpdatedEvent>().Unsubscribe(OnStatusUpdated);}
}

 

 

 

 

 

image

 

 

image

 

 

 

 

 

//Main
//App.xaml
<prism:PrismApplication x:Class="WpfApp22.App"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:WpfApp22"xmlns:prism="http://prismlibrary.com/">
</prism:PrismApplication>//App.xaml.cs
using BookModule;
using BookModule.Services;
using BookModule.ViewModels;
using BookModule.Views;
using Prism.Commands;
using Prism.Ioc;
using Prism.Modularity;
using System.Configuration;
using System.Data;
using System.Windows;
using UserModule;
using UserModule.ViewModels;
using UserModule.Views;namespace WpfApp22
{/// <summary>/// Interaction logic for App.xaml/// </summary>public partial class App : PrismApplication{protected override Window CreateShell(){return Container.Resolve<ShellView>();}protected override void OnInitialized(){base.OnInitialized();var regionManager = Container.Resolve<IRegionManager>();regionManager.RequestNavigate("BookRegion", "BookView");regionManager.RequestNavigate("UserRegion", "UserView");}protected override void RegisterTypes(IContainerRegistry containerRegistry){         containerRegistry.RegisterForNavigation<ShellView, ShellViewModel>();}protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog){base.ConfigureModuleCatalog(moduleCatalog);moduleCatalog.AddModule<BookModule.BookModule>();moduleCatalog.AddModule<UserModule.UserModule>();}}}//MainWindow.xaml
<Window x:Class="WpfApp22.ShellView"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:prism="http://prismlibrary.com/"prism:ViewModelLocator.AutoWireViewModel="True"WindowState="Maximized"HorizontalAlignment="Stretch"VerticalAlignment="Stretch"xmlns:local="clr-namespace:WpfApp22"mc:Ignorable="d"Title="ShellView" Height="450" Width="800"><Grid><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*"/><RowDefinition Height="Auto"/></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions><TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"Text="{Binding MainStr}"  FontSize="50" /><ContentControl prism:RegionManager.RegionName="BookRegion"Grid.Row="1"Grid.Column="0"VerticalAlignment="Stretch"HorizontalAlignment="Stretch"/><ContentControl prism:RegionManager.RegionName="UserRegion"Grid.Row="1"Grid.Column="1"VerticalAlignment="Stretch"HorizontalAlignment="Stretch"/><TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"Text="{Binding MainStatus}"  FontSize="50" /></Grid>
</Window>//MainViewModel.cs
using BookModule.Models;
using BookModule.ViewModels;
using System;
using System.Collections.Generic;
using System.Text;namespace WpfApp22
{public class ShellViewModel : BindableBase{private IEventAggregator eventAggregator;public ShellViewModel(IEventAggregator eventAggregatorValue){eventAggregator = eventAggregatorValue;eventAggregator.GetEvent<StatusUpdatedEvent>().Subscribe(OnStatusUpdated);MainStatus = "Loading...";MainStr = $"In Main view,now is {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}";System.Timers.Timer tmr = new System.Timers.Timer();tmr.Interval = 1000;tmr.Elapsed += Tmr_Elapsed;tmr.Start();}private void OnStatusUpdated(string statusValue){MainStatus = statusValue;}public void OnUnload(){eventAggregator.GetEvent<StatusUpdatedEvent>().Unsubscribe(OnStatusUpdated);}private void Tmr_Elapsed(object? sender, System.Timers.ElapsedEventArgs e){MainStr = $"In Main view,now is {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}";}private string mainStr;public string MainStr{get{return mainStr;}set{SetProperty(ref mainStr, value);}}private string mainStatus;public string MainStatus{get{return mainStatus;}set{SetProperty(ref mainStatus, value);}}public Action<string> UpdateMainStatusAction => UpdateMainStatus;private void UpdateMainStatus(string statusValue){MainStatus = statusValue;}}
}//ModuleA
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Media;namespace BookModule.Models
{public class Book{public int Id { get; set; }public string Name { get; set; }public string Author { get; set; }public string Title {  get; set; }public string Topic {  get; set; }public string ISBN {  get; set; }public ImageSource ImgSource { get; set; }}
}using System;
using System.Collections.Generic;
using System.Text;namespace BookModule.Models
{public class StatusUpdatedEvent : PubSubEvent<string>{}
}using System;
using System.Collections.Generic;
using System.Text;namespace BookModule.Services
{public interface IIDService{int GetID();}public class IDService:IIDService{int id = 0;public int GetID(){return Interlocked.Increment(ref id);}}
}using System;
using System.Collections.Generic;
using System.Text;namespace BookModule.Services
{public interface IISBNService{string GetISBN();}public class ISBNService : IISBNService{int idx = 0;public string GetISBN(){return $"ISBN_{Interlocked.Increment(ref idx)}_{Guid.NewGuid():N}";}}
}
using System;
using System.Collections.Generic;
using System.Text;namespace BookModule.Services
{public interface INameService{string GetName();}public class NameService:INameService{int idx = 0;public string GetName(){return $"Name_{++idx}";}}
}
using BookModule.Models;
using BookModule.Services;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Text;
using System.Windows.Media;
using System.Windows.Media.Imaging;namespace BookModule.ViewModels
{public class BookViewViewModel : BindableBase{IIDService idService;IISBNService isbnService;INameService nameService;IEventAggregator eventAggregator;public BookViewViewModel(IIDService idServiceValue, IISBNService isbnServiceValue,INameService nameServiceValue, IEventAggregator eventAggregatorValue){idService = idServiceValue;isbnService = isbnServiceValue;nameService = nameServiceValue;eventAggregator = eventAggregatorValue;}public void UpdateMainStatus(string mainStatusValue){eventAggregator.GetEvent<StatusUpdatedEvent>().Publish(mainStatusValue);}public async Task InitBooksCollection(){var imgDir = @"D:\C\WpfApp22\BookModule\Images\";if (!Directory.Exists(imgDir)){return;}var imgs = Directory.GetFiles(imgDir);if (imgs == null || !imgs.Any()){return;}int imgsCount = imgs.Count();BooksCollection = new ObservableCollection<Book>();List<Book> booksList = new List<Book>();await Task.Run(async () =>{for (int i = 1; i < 1000001; i++){booksList.Add(new Book(){Id = idService.GetID(),Name = nameService.GetName(),ISBN = isbnService.GetISBN(),Title = $"Title_{i}",Topic = $"Topic_{i}",Author = $"Author_{i}",ImgSource = GetImgSourceViaUrl(imgs[i % imgsCount])});if (i % 1000 == 0){await PopulateBooksCollectionAsync(booksList);}}if (booksList.Any()){await PopulateBooksCollectionAsync(booksList);}});}private async Task PopulateBooksCollectionAsync(List<Book> booksList){var tempList = booksList.ToList();booksList.Clear();await System.Windows.Application.Current.Dispatcher.InvokeAsync(() =>{foreach (var bk in tempList){BooksCollection.Add(bk);}UpdateMainStatus($"Loaded {BooksCollection.Count} items!");}, System.Windows.Threading.DispatcherPriority.Background);}private ImageSource GetImgSourceViaUrl(string imgUrl){BitmapImage bmi = new BitmapImage();bmi.BeginInit();bmi.UriSource = new Uri(imgUrl, UriKind.RelativeOrAbsolute);bmi.EndInit();bmi.Freeze();return bmi;}private ObservableCollection<Book> booksCollection;public ObservableCollection<Book> BooksCollection{get{return booksCollection;}set{SetProperty(ref booksCollection, value);}}private double gridWidth;public double GridWidth{get{return gridWidth;}set{SetProperty(ref gridWidth, value);}}private double gridHeight;public double GridHeight{get{return gridHeight;}set{SetProperty(ref gridHeight, value);}}}
}
<UserControl x:Class="BookModule.Views.BookView"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"             xmlns:local="clr-namespace:BookModule.Views"xmlns:prism="http://prismlibrary.com/"VerticalAlignment="Stretch"HorizontalAlignment="Stretch"prism:ViewModelLocator.AutoWireViewModel="True"><Grid><ListBox ItemsSource="{Binding BooksCollection,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"VirtualizingPanel.IsVirtualizing="True"VirtualizingPanel.VirtualizationMode="Recycling"VirtualizingPanel.CacheLength="2,2"VirtualizingPanel.CacheLengthUnit="Item"ScrollViewer.IsDeferredScrollingEnabled="True"ScrollViewer.CanContentScroll="True"><ListBox.ItemTemplate><DataTemplate><Grid Width="{Binding DataContext.GridWidth,RelativeSource={RelativeSource AncestorType=UserControl}}"Height="{Binding DataContext.GridHeight,RelativeSource={RelativeSource AncestorType=UserControl}}"><Grid.Background><ImageBrush ImageSource="{Binding ImgSource}"Stretch="UniformToFill"/></Grid.Background><Grid.Resources><Style TargetType="{x:Type TextBlock}"><Setter Property="HorizontalAlignment" Value="Center"/><Setter Property="VerticalAlignment" Value="Center"/><Setter Property="FontSize" Value="20"/><Style.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter Property="FontSize" Value="30"/><Setter Property="Foreground" Value="Red"/></Trigger></Style.Triggers></Style></Grid.Resources><Grid.RowDefinitions><RowDefinition/><RowDefinition/></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/><ColumnDefinition/><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions><TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding Id}"/><TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Name}"/><TextBlock Grid.Row="0" Grid.Column="2" Text="{Binding Author}"/><TextBlock Grid.Row="0" Grid.Column="3" Text="{Binding Title}"/><TextBlock Grid.Row="0" Grid.Column="4" Text="{Binding Topic}"/><TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="5" Text="{Binding ISBN}"/></Grid></DataTemplate></ListBox.ItemTemplate></ListBox></Grid>
</UserControl>using BookModule.ViewModels;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace BookModule.Views
{/// <summary>/// Interaction logic for BookView.xaml/// </summary>public partial class BookView : UserControl{public BookView(){InitializeComponent();this.SizeChanged += (s, e) =>{if (this.DataContext is BookViewViewModel bkVM){bkVM.GridWidth = this.ActualWidth;bkVM.GridHeight = this.ActualHeight;}};this.Loaded += async (s, e) =>{if (this.DataContext is BookViewViewModel bkVM){await bkVM.InitBooksCollection();}};}private async Task BookView_Loaded(object sender, RoutedEventArgs e){}}
}
using BookModule.Services;
using BookModule.ViewModels;
using BookModule.Views;
using System;
using System.Collections.Generic;
using System.Text;namespace BookModule
{public class BookModule : IModule{private IRegionManager regionManager;public BookModule(IRegionManager regionManagerValue){regionManager = regionManagerValue;}public void OnInitialized(IContainerProvider containerProvider){regionManager.RegisterViewWithRegion("BooksRegion", typeof(BookView));}public void RegisterTypes(IContainerRegistry containerRegistry){containerRegistry.Register<IIDService, IDService>();containerRegistry.Register<INameService, NameService>();containerRegistry.Register<IISBNService, ISBNService>();containerRegistry.RegisterForNavigation<BookView, BookViewViewModel>("BookView");}}
}//Module B
using System;
using System.Collections.Generic;
using System.Text;namespace UserModule.Models
{public class User{public int Id { get; set; }        public string Name { get; set; }public string Email { get; set; }}
}using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics.Eventing.Reader;
using System.IO;
using System.Text;
using System.Windows.Controls;
using UserModule.Models;namespace UserModule.ViewModels
{public class UserViewModel : BindableBase{public UserViewModel(){InitUsersCollection();SaveInExcelCommand = new DelegateCommand<object>(SaveInExcelCommandExecuted);}private void SaveInExcelCommandExecuted(object obj){var dg = obj as DataGrid;if (dg != null){var items = dg.ItemsSource?.Cast<User>()?.ToList();}}private void InitUsersCollection(){UsersCollection = new ObservableCollection<User>();for (int i = 1; i < 1001; i++){UsersCollection.Add(new User(){Id = i * i,Name = $"Name_{i}",Email = $"User_{i}@gmail.com"});}}private ObservableCollection<User> usersCollection;public ObservableCollection<User> UsersCollection{get{return usersCollection;}set{SetProperty(ref usersCollection, value);}}public DelegateCommand<object> SaveInExcelCommand { get; set; }public void ExportListTAsExcel<T>(List<T> dataList, string filePath = "", string sheetName = "Sheet1"){if (dataList == null || !dataList.Any()){return;}//// Set EPPlus license context for free use//ExcelPackage.LicenseContext = LicenseContext.NonCommercial;//using (var package = new ExcelPackage())//{//    var worksheet = package.Workbook.Worksheets.Add(sheetName);//    // Load data starting from cell A1//    worksheet.Cells["A1"].LoadFromCollection(dataList, true);//    // Auto-fit columns for better readability//    worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();//    // Save the file//    package.SaveAs(new FileInfo(filePath));//}
        }}}<UserControl x:Class="UserModule.Views.UserView"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:UserModule.Views"xmlns:prism="http://prismlibrary.com/"prism:ViewModelLocator.AutoWireViewModel="True"VerticalAlignment="Stretch"HorizontalAlignment="Stretch"><Grid><DataGrid ItemsSource="{Binding UsersCollection,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"VirtualizingPanel.IsVirtualizing="True"VirtualizingPanel.VirtualizationMode="Recycling"VirtualizingPanel.CacheLength="2,2"VirtualizingPanel.CacheLengthUnit="Item"ScrollViewer.IsDeferredScrollingEnabled="True"ScrollViewer.CanContentScroll="True"FontSize="50"><DataGrid.ContextMenu><ContextMenu><MenuItem Header="Save In Excel"Command="{Binding SaveInExcelCommand}"CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu},Path=PlacementTarget}"/></ContextMenu></DataGrid.ContextMenu></DataGrid></Grid>
</UserControl>using System;
using System.Collections.Generic;
using System.Text;
using UserModule.ViewModels;
using UserModule.Views;namespace UserModule
{public class UserModule : IModule{IRegionManager regionManager;public UserModule(IRegionManager regionManagerValue){regionManager = regionManagerValue;}public void OnInitialized(IContainerProvider containerProvider){//regionManager.RegisterViewWithRegion("UserRegion",typeof(UserView));
        }public void RegisterTypes(IContainerRegistry containerRegistry){containerRegistry.RegisterForNavigation<UserView, UserViewModel>("UserView");}}
}

 

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Spring Boot 集成 Redis 全方位详解 - 指南

Spring Boot 集成 Redis 全方位详解 - 指南pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "…

济南网站建设群用wordpress建站一个人可以吗

一、使用方法编写求圆面积和周长的程序&#xff0c;运行时提示输入圆半径&#xff0c;然后输出计算结果。运行效果如下图所示&#xff1a; import java.util.Scanner;public class Test {public static void main(String[] args) {Scanner input new Scanner(System.in);Syste…

ubuntu安装pbc库

本文主要介绍使用ubuntu安装pbc库,并在安装过程中遇到的问题的解决方法ubuntu安装pbc库 pbc中的gmp库和pbc库下载链接如下: pbc下载 密码:gh40 1.安装gcc库 首先查看一下是否安装gcc库,若没有安装则无法运行c语言代…

基础微网站开发代理商移动端网站咋做

金蝶财务软件想要使用的好是有技巧的&#xff01;快捷键简易汇总&#xff1a;快捷键详细说明1、凭证处理①、摘要栏两种快速复制摘要的功能&#xff0c;在下一行中按“..”可复制上一条摘要&#xff0c;按“//”可复制第一条摘要。同时&#xff0c;系统还设计了摘要库&#xff…

《电路基础》第六章学习笔记

《电路基础》第六章学习笔记本章我们将学习电容和电感电路。电容器构成: 电容器由被绝缘体(电介质)隔开的两个导电金属极板组成高中知识: \[q=Cv \]\[C= \frac{\varepsilon A}{d} \]其中A为各个极板的表面积,d为两…

wordpress开发视频网站模板国外电商网站如何建立

前言 做了一段时间的bat脚本开发&#xff0c;bat脚本中有各种各样的命令跟传统的编程逻辑完全不同&#xff0c;本专栏会讲解下各种各式的命令使用方法。 本篇文章讲解的是获取windows系统的复制命令&#xff08;copy和xcopy&#xff09;&#xff0c;copy和xcopy是Windows命令行…

datadome 隐私模式 ck设置

开启隐私模式, ck 无法成功设置window["document"]["cookie"] = "dd_testcookie=1; path=/; SameSite=None; Secure"

有后台管理系统网站管理二手房信息发布平台

根据 UNIX_TIMESTAMP 去掉分钟后的的位数 思路如下select UNIX_TIMESTAMP(now()) 当前时间 秒,now() 当前时间,FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(CURRENT_TIMESTAMP) / (3 * 60)) * (3 * 60)) 3分钟为分隔去掉多余位数当前时间 秒 当前时间 3分钟为分隔去掉多余…

利用IOT-Tree消息流【标签读写】功能详细说明

利用IOT-Tree消息流【标签读写】功能详细说明pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", &qu…

2025.10.2 2024CCPC重庆

施工中…… vp 5/13(B E I J K) 补题: A D H M

二分图判定,染色法

#include <iostream> #include <cstring> #include <algorithm> using namespace std;const int N=100010,M=2*N; int n,m; struct edge{int v,ne;}e[M]; int h[N],idx; int color[N];void add(int …

命令行实用技巧

键盘上下键调出历史命令 Ctrl + c:废弃当前命令行中的命令,取消当前执行的命令,例如ping Ctrl + l,clear:清屏 tab键自动补齐:可补齐命令、参数、文件路径、软件名 esc + . :将上一条命令参数变成当前命令的执行…

网站代码多彩外卖小程序怎么制作

文章目录 参考文章PGO是什么使用PGO的好处PGO做了什么热函数内联什么是内联内联的好处Go默认的内联策略查看内联预算PGO的热函数内联 去虚拟化调用指令高速缓存 PGO有什么缺点可执行程序变大构建时间变长 PGO怎么使用典型的工作流程收集CPU配置文件生产环境启动PGO代码改动重新…

廊坊企业做网站做企业官网的公司

wav文件格式分析详解 作者&#xff1a;曹京日期&#xff1a;2006年7月17日 一、综述 WAVE文件作为多媒体中使用的声波文件格式之一&#xff0c;它是以RIFF格式为标准的。RIFF是英文Resource Interchange File Format的缩写&#xff0c;每个WAVE文件的头四个字节便是“RIFF…

农家乐网站 建设绍兴以往网站招工做

​一、前言 上一篇给牛奶做直播之二 主要讲用RTMP搭建点播服务器&#xff0c;整了半天直播还没上场&#xff0c;今天不讲太多理论的玩意&#xff0c;奶牛今天放假了也不出场&#xff0c;就由本人亲自上场来个直播首秀&#xff0c;见下图&#xff0c;如果有兴趣的话&#xff0…

菏泽哪里有做网站的因酷网站建设

转载自公众号&#xff1a;工匠小猪猪的技术世界 摘要: 本文非原创&#xff0c;是笔者搜集了一些HikariCP相关的资料整理给大家的介绍&#xff0c;主要讲解了为什么sb2选择了HikariCP以及HikariCP为什么这么快。 Springboot2默认数据库连接池选择了HikariCP为何选择HikariCP理由…

设备沉睡的“心跳”难题:BLE休眠后无法被手机唤醒的分析与优化 - 详解

设备沉睡的“心跳”难题:BLE休眠后无法被手机唤醒的分析与优化 - 详解pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: &…

CPU温度查看(Core Temp)

前言 原因很简单,用到Core Temp这个软件是因为想查看CPU的温度,现在从任务管理器中已经看不到CPU温度了,所以需要其他方式来查看为什么需要看CPU的温度呢,因为在某天,我发现刚开机,基本没跑什么任务,风扇就开始…

实用指南:Python虚拟环境管理工具virtualenv详解

实用指南:Python虚拟环境管理工具virtualenv详解pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas",…

博罗网站设计公司网站服务搭建

sys模块 与操作系统交互的一个接口 文件夹相关 os.makedirs(dirname1/dirname2) 可生成多层递归目录os.removedirs(dirname1) 若目录为空&#xff0c;则删除&#xff0c;并递归到上一级目录&#xff0c;如若也为空&#xff0c;则删除&#xff0c;依此类推os.mkdir(dirnam…