因为git提交需要写这次做的,所以我想弄个东西来帮我写

WPF可以使用快捷键,快捷键主要使用InputBindings,WPF读写文件很简单

我每次都要写

第一句标题

之后就是我写的修改

然后加上我名字

加上时间

有一次我修改了函数f

删除一个函数

标题是我做了工具

我需要写:

#我做了工具

修改函数f

删除函数

林德熙 2016年3月16日 16:43:40

这样每次写都需要加# 我的名字,于是我就做了个软件

点击确定

我可以在工具.txt

我可以复制里面内容,这样可以在一个不想使用git的,直接看到每天我在做

每次按确定,我觉得还是做快捷键,做了alt+enter就是放在工具.txt

快捷键

App.xaml

<Application.Resources>

<RoutedUICommand x:Key="quedin" Text="确定"></RoutedUICommand>

</Application.Resources>

捷MainPage.xaml

使用快捷键

<Window.InputBindings>

<KeyBinding Modifiers="Alt" Key="Enter"  Command="{StaticResource quedin}"></KeyBinding>

</Window.InputBindings>

我们把这个命令需要按下的键Modifiers="Alt" 如果需要按ctrl+alt可以Modifiers="Control+Alt"如

后台写快捷键使用保存

private void key(object sender, RoutedEventArgs e)

{

view.text = text.Text;

view.Storage();

}

TextBox binding是失去焦点更新,我不想去改

<Window.CommandBindings>

<CommandBinding Command="{StaticResource quedin}" Executed="key"></CommandBinding>

</Window.CommandBindings>

把文件保存

using (FileStream temp = new FileStream(file, FileMode.Append))

{

byte[] buffer = Encoding.Default.GetBytes(text);

int n = buffer.Length;

temp.Write(buffer, 0, n);

text = "";

}

我使用Depend绑定文本,因为最后的text需要在后台修改,而view绑定是viewModel,前台和后台数据变化直接,可以前台使用

#region

using System.Windows;

using System.Windows.Data;

#endregion

namespace 跨境工具箱

{

public class viewModel : DependencyObject

{

public viewModel()

{

_model = new model();

Binding bind = new Binding("text")

{

Source = _model,

Mode = BindingMode.TwoWay

};

BindingOperations.SetBinding(this, text_property, bind);

bind = new Binding("name")

{

Source = _model,

Mode = BindingMode.TwoWay

};

BindingOperations.SetBinding(this, name_property, bind);

bind = new Binding("time")

{

Source = _model,

Mode = BindingMode.TwoWay

};

BindingOperations.SetBinding(this, time_property, bind);

bind = new Binding("reminder")

{

Source = _model,

Mode = BindingMode.TwoWay

};

BindingOperations.SetBinding(this, reminder_property, bind);

bind = new Binding("file")

{

Source = _model,

Mode = BindingMode.TwoWay

};

BindingOperations.SetBinding(this, file_property, bind);

}

public static readonly DependencyProperty file_property = DependencyProperty.Register(

"file", typeof (string), typeof (viewModel), new PropertyMetadata(default(string)));

public static readonly DependencyProperty reminder_property = DependencyProperty.Register(

"reminder", typeof (string), typeof (viewModel), new PropertyMetadata(default(string)));

public static readonly DependencyProperty time_property = DependencyProperty.Register(

"time", typeof (bool), typeof (viewModel), new PropertyMetadata(default(bool)));

public static readonly DependencyProperty name_property = DependencyProperty.Register(

"name", typeof (string), typeof (viewModel), new PropertyMetadata(default(string)));

public static readonly DependencyProperty text_property = DependencyProperty.Register(

"text", typeof (string), typeof (viewModel), new PropertyMetadata(default(string)));

public string file

{

set

{

SetValue(file_property, value);

}

get

{

return (string) GetValue(file_property);

}

}

public string reminder

{

set

{

SetValue(reminder_property, value);

}

get

{

return (string) GetValue(reminder_property);

}

}

public bool time

{

set

{

SetValue(time_property, value);

}

get

{

return (bool) GetValue(time_property);

}

}

public string name

{

set

{

SetValue(name_property, value);

}

get

{

return (string) GetValue(name_property);

}

}

public string text

{

set

{

SetValue(text_property, value);

}

get

{

return (string) GetValue(text_property);

}

}

private model _model;

}

}

想要这个软件给别人用,他们可以用他们名字,可以选要不要时间

<Grid.ColumnDefinitions>

<ColumnDefinition></ColumnDefinition>

<ColumnDefinition></ColumnDefinition>

<ColumnDefinition></ColumnDefinition>

</Grid.ColumnDefinitions>

<TextBox Text="{Binding Path=name,Mode=TwoWay}" Grid.Column="0" Margin="10,10,10,10"></TextBox>

<CheckBox Content="时间" Grid.Column="1" Margin="10,10,10,10" IsChecked="{Binding Path=time,Mode=TwoWay}"></CheckBox>

<Button Grid.Column="2" Content="确定" Margin="10,10,10,10" Click="key"></Button>

保存设置

public void storage()

{

try

{

string str = "工具箱.txt";

using (FileStream temp = new FileStream(str, FileMode.Create))

{

str = file + "\n" + name + "\n" + time;

byte[] buffer = Encoding.Default.GetBytes(str);

temp.Write(buffer, 0, buffer.Length);

}

}

catch (Exception e)

{

reminder = e.Message;

}

}

这个软件我使用在宝资通

这个月准备CVTE面试,没有时间去写博客,之前在写网络编程,现在还好多问题我在找微软写的,但是他们做的好像好多没有,我看了超神的QiniuUWP,他用的我看到是HttpWebRequest  Socket现在王大神就做了局域网通信,我还在看,他写的我看不明白,不是他用的高级,是没有把心放在去看他的

WPF 快捷键读写txt的更多相关文章

  1. WPF 读写TxT文件

    原文:WPF 读写TxT文件 文/嶽永鹏 WPF 中读取和写入TxT 是经常性的操作,本篇将从详细演示WPF如何读取和写入TxT文件. 首先,TxT文件希望逐行读取,并将每行读取到的数据作为一个数组的 ...

  2. [转载]C#读写txt文件的两种方法介绍

    C#读写txt文件的两种方法介绍 by 大龙哥 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char ...

  3. C#读写txt文件的两种方法介绍

    C#读写txt文件的两种方法介绍 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char数组,然后输出 ...

  4. java指定编码的按行读写txt文件(几种读写方式的比较)

    转: java指定编码的按行读写txt文件(几种读写方式的比较) 2018年10月16日 20:40:02 Handoking 阅读数:976  版权声明:本文为博主原创文章,未经博主允许不得转载. ...

  5. python操作txt文件中数据教程[1]-使用python读写txt文件

    python操作txt文件中数据教程[1]-使用python读写txt文件 觉得有用的话,欢迎一起讨论相互学习~Follow Me 原始txt文件 程序实现后结果 程序实现 filename = '. ...

  6. C#读写txt文件的两种方法介绍[转]

    C#读写txt文件的两种方法介绍 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char数组,然后输出 ...

  7. C#读写txt文件的两种方法介绍 v

    C#读写txt文件的两种方法介绍 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char数组,然后输出 ...

  8. unity3d读写txt

    http://www.cnblogs.com/sunet/p/3851353.html?utm_source=tuicool 记录一下昨天用到的技术点:基于android平台unity3d读写txt. ...

  9. UNICODE环境下读写txt文件操作

    内容转载自http://blog.sina.com.cn/s/blog_5d2bad130100t0x9.html UNICODE环境下读写txt文件操作 (2011-07-26 17:40:05) ...

随机推荐

  1. 201521123091 《Java程序设计》第1周学习总结

    Java 第一周总结 第一周的作业. 1.本章学习总结 [x] 初识Java语言:Java的历史,三大平台,了解JVM/JRE/JDK [x] Java开发环境的配置 [x] 用记事本编写Java程序 ...

  2. 团队作业4——第一次项目冲刺(ALpha版本)第三天

    一.Daily Scrum Meeting照片 二.燃尽图 三.项目进展 1.界面 完成了前端的HTML页面设计 2.功能 完成了后端数据处理的全部基本功能: 数据结构设计及数据交互操作 博客页面数据 ...

  3. 201521123067 《Java程序设计》第6周学习总结

    1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图,对面向对象思想进行一个总结. 2. 书面作业 Q1:clone方法 1.1 Object ...

  4. 201521123004 《Java程序设计》第10周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常与多线程相关内容. 答: 异常的概念上周的思维导图大致体现,这周就归纳一下错误调试 由于多线程的内容比较散,我就直接用文字总结 ...

  5. Java课程设计——GUI密码生成器团队博客

    1.团队名称.团队成员介绍(需要有照片) 1.1团队名称 小黄人 1.2团队成员介绍 吴玲:组长,现任院就业会策划部副部长 郭琪容:组员,现任院硬件协会会长 2. 项目git地址 吴 玲 郭琪容 3. ...

  6. select应用于read函数 超时非阻塞方式

    /* * "Timed" read - timout specifies the # of seconds to wait before * giving up (5th argu ...

  7. jmeter测试HTTP请求

    HTTP超文本传输协议(HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议.所有的WWW文件都必须遵守这个标准.(详情参考看一下百科) HTTP发送请求有GE ...

  8. 传统编程和IoC的对比

    ref:http://www.importnew.com/13619.html 传统编程:决定使用哪个具体的实现类的控制权在调用类本身,在编译阶段就确定了. IoC模式:调用类只依赖接口,而不依赖具体 ...

  9. maven web 项目中启动报错 Java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

    主要原因是maven项目里面的jar包吗,没有导入到项目中 maven web 项目中启动报错 Java.lang.ClassNotFoundException: org.springframewor ...

  10. BootStrap基礎知識

    BootStrap基礎知識 1. .lead //突出 .text-left //文字居左 .text-right //文字居右 .text-center //文字居中 .text-justify / ...