◆Wpf◆-画面线程委托方法
Dispatcher.Invoke(new Action(ServiceProvider.Configure));
◆Wpf◆-模型数据绑定方法1
ViewModelBase.cs
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace View
{
// View model base class
public abstract class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
ViewModel.cs
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Imaging;
namespace View
{
public class CaptureViewModel : ViewModelBase
{
private BitmapSource m_LiveViewImage; //实时画像显示绑定对象
private string[] m_ShutterSpeedList; //快门速度清单
private AsyncObservableCollection<FileItem> m_PictureFiles;
private int m_BatteryLevel;
public CaptureViewModel()
{
m_LiveViewImage = null;
m_ShutterSpeedList = null;
m_SelectedIndex = 0;
m_IsDeviceLoad = false;
m_IsCapture = false;
m_IsLiveViewMode = false;
m_PictureFiles = new AsyncObservableCollection<FileItem>();
}
public AsyncObservableCollection<FileItem> PictureFiles
{
get { return m_PictureFiles; }
set
{
m_PictureFiles = value;
OnPropertyChanged("PictureFiles");
}
}
}
}
MainWindow.xaml
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="View.MainWindow"
xmlns:local="clr-namespace:View"
WindowStartupLocation="CenterScreen"
Title="1" Closed="Window_Closed" WindowStyle="SingleBorderWindow" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="700" SizeToContent="WidthAndHeight" ResizeMode="CanMinimize" MinHeight="700" MinWidth="900" Icon="/SystemExeName;component/Images/Pic.ico" MaxHeight="700" MaxWidth="900" d:DesignWidth="900">
<Window.Resources>
<local:ViewModel x:Key="ViewModel"/>
</Window.Resources>
<Grid DataContext="{StaticResource ViewModel}" Name="CaptureWindow" Initialized="MainWindow_Initialized" Unloaded="MainWindow_Unloaded" MinHeight="650" MinWidth="870">
<ListBox Grid.Row="1" VirtualizingStackPanel.IsVirtualizing="True" Name="ImageListBox" ItemsSource="{Binding PictureFiles, IsAsync=True}" BorderThickness="0" IsSynchronizedWithCurrentItem="True" Focusable="False">
◆文件◆-Zip文件
◆XML◆-XML分析工具
string destfile = Path.Combine(Path.GetTempPath(), "error_report.zip");
if (File.Exists(destfile))
File.Delete(destfile);
using (var zip = new ZipFile(destfile))
{
zip.AddFile(ServiceProvider.LogFile, "");
zip.Save(destfile);
}
◆文件◆-文件确认
if (File.Exists(destfile))
File.Delete(destfile);
XmlSerializer mySerializer = new XmlSerializer(typeof (Branding));
FileStream myFileStream = new FileStream(filename, FileMode.Open,FileAccess.Read,FileShare.Read);
branding = (Branding) mySerializer.Deserialize(myFileStream);
myFileStream.Close();
◆系统◆-Windows地址字符串连接
Path.Combine(“C:”,"Soft", "Set.xml");
◆系统◆-应用程序进程取得
Process.GetCurrentProcess().ProcessName;
◆系统◆-关闭当前应用
Application.Current.Shutdown();
◆线程◆-Task.Factory线程调用方法
Task.Factory.StartNew(Application);
◆WEBService◆-开发测试发布问题解决
问题:当通过浏览器访问接口时提示的错误。
HTTP 错误 404.3 - Not Found
由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射。
解决方法:
在控制面板->程序和功能->启用和关闭Windows功能如下选项启用后,解决问题。