因为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. 学习目标或者作业的制定(SMART原则)

    以下文字摘自邹欣老师的博客 很高兴看到学生们都写了自己的目标: http://www.cnblogs.com/deng201421123059/p/6435346.html 不得不说,有些同学的目标太 ...

  2. 201521123033《Java程序设计》第12周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 2. 书面作业 将Student对象(属性:int id, String name,int age,doubl ...

  3. 201521123051《Java程序设计》第十二周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 一 JAVA语言中主要通过流来完成IO操作. 流:计算机的输入输出之间流动的数据序列,也是类的对象.java中 ...

  4. 201521123029《Java程序设计》第十三周学习总结

    1. 本周学习总结 以你喜欢的方式(思维导图.OneNote或其他)归纳总结多网络相关内容. 2. 书面作业 1.网络基础 1.1 比较ping www.baidu.com与ping cec.jmu. ...

  5. 让SAE下的wordpress支持文件上传

    非PHP程序员照着源码打的小布丁… SAE是不允许本地磁盘读写的,所以使用wordpress撰写文章的时候, 上传控件默认是用不了的,幸好SAE提供了storage服务来存储文件,那就可以修改word ...

  6. 用Beautifulsoup 来爬取贴吧图片

    import urllib.request import bs4 import re import os url="https://tieba.baidu.com/p/1988291937? ...

  7. 读Zepto源码之Touch模块

    大家都知道,因为历史原因,移动端上的点击事件会有 300ms 左右的延迟,Zepto 的 touch 模块解决的就是移动端点击延迟的问题,同时也提供了滑动的 swipe 事件. 读 Zepto 源码系 ...

  8. Struts2第九篇【OGNL、valueStack详解】

    什么是OGNL表达式? OGNL是Object Graphic Navigation Language 是操作对象属性的开源表达式. Struts2框架使用OGNL作为默认的表达式语言. 为什么我们学 ...

  9. 跨Storyboard调用

    在开发中我们会有这种需求从一个故事板跳到另一个故事板 modal UIStoryboard *secondStoryboard = [UIStoryboard storyboardWithName:@ ...

  10. 软件工程个人第二小项目——wc

    github源码和工程文件地址:https://github.com/HuChengLing/wc 基本要求:要实现wc的基本功能即文件中字符数.单词数.行数的统计. 主要功能:文件中字符数.单词数. ...