因为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. 201521123077 《Java程序设计》第4周学习总结

    1. 本周学习总结 几种简单说明注释的使用 抽象类与抽象方法 super调用父类的方法 2. 书面作业 Q1.注释的应用使用类的注释与方法的注释为前面编写的类与方法进行注释,并在Eclipse中查看. ...

  2. 201521123075 《Java程序设计》第4周学习总结

    1. 本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. 1.2 使用常规方法总结其他上课内容. - 了解了多态就是以单一的接口操作多种类型的对象,但是对多态和继承的关系还是有点混乱. - ...

  3. 201521123113 《Java程序设计》第4周学习总结

    1.本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. 1.2 使用常规方法总结其他上课内容. 设计类的技巧:类名和方法名要能够体现他们的职责,类名首字母要大写 如何识别一个类 方法.属性的 ...

  4. 201521123035《Java程序设计》第四周学习总结

    本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. 1.2 使用常规方法总结其他上课内容. 本周还讲了注释与类设计.老师用例子向我们展示实际生活中一个类里面包含了哪些属性,并由此联想到如果自 ...

  5. java课程设计(团队)-五子棋

    单机五子棋小游戏 一:团队介绍 组长:网络1511,毛卓 组员:网络1511,朱潞潞 组员:网络1511,范阳斌 二:项目git提交记录截图 三:项目使用主要技术 netBeans,GUI 四:项目特 ...

  6. [02] Servlet获取请求和页面跳转

    1.Tomcat和Servlet的关系 之前提到过,Servlet是运行在Web容器里的,Tomcat作为容器的一种,在这里自然也要大概说说两者之间的大致关系. 首先,如上所述,Tomcat是Web应 ...

  7. 小甲鱼:Python学习笔记003_函数

    >>> # 函数>>> def myFirstFunction(params1,params2...): print("这是我的第一个函数!") ...

  8. Elipse中发布一个Maven项目到Tomcat

    对于maven初学者的我,经常遇到一个问题就是,maven项目创建成功后,本来已经添加了jar的依赖,但是发布到Tomcat中就是没有jar包存在, 启动Tomcat总是报没有找到jar包,可项目结构 ...

  9. Linux Ubuntu从零开始部署web环境及项目-----搭建ssh环境(一)

    linux搭建ssh环境 1,用户登录 成功输入用户名和密码后 进入Ubuntu界面  2,配置网络 参考:http://blog.csdn.net/liu782726344/article/deta ...

  10. day09<面向对象+>

    面向对象(多态的概述及其代码体现) 面向对象(多态中的成员访问特点之成员变量) 面向对象(多态中的成员访问特点之成员方法) 面向对象(多态中的成员访问特点之静态成员方法) 面向对象(超人的故事) 面向 ...