当前位置: 首页 > news >正文

做淘客网站用备案吗家具网页设计素材

做淘客网站用备案吗,家具网页设计素材,做网站预算表,wordpress在线储存WPF里面虽然很多形式上跟Winform一样#xff0c;但是控件的使用上面还是会有很多诧异。RichTextBox就是一个例子#xff0c;是的#xff0c;在WPF里面对这个控件可以做很多Winform很难做的效果出来。比如在对RichTextBox插入图片#xff0c;winform时代除了用复制粘贴这种借…WPF里面虽然很多形式上跟Winform一样但是控件的使用上面还是会有很多诧异。RichTextBox就是一个例子是的在WPF里面对这个控件可以做很多Winform很难做的效果出来。比如在对RichTextBox插入图片winform时代除了用复制粘贴这种借助剪贴板的差劲方法之外就是要重写和自定义RichTextBox控件了。这就需要高超的编程能力了。但在WPF里面只需要加几个代码就能搞定了。在XAML里面添加图片到RichTextBox可以如下所示        RichTextBox HorizontalAlignmentLeft Margin90,12,0,0 NamerichTextBox1            RichTextBox.Document                FlowDocument FocusableTrue LineHeight5                    Paragraph x:Namegara                                              文字区域                        Image SourceD:\1342892_10.jpg FocusableTrue Height50 StretchUniform /                                               文字区域                                               Run Text文字区域文字区域/Run                        Run Text文字区域/Run                    /Paragraph                    Paragraph x:Namegara1                                              Run Text文字区域/Run                        Run Text文字区域/Run                    /Paragraph                                   /FlowDocument            /RichTextBox.Document        /RichTextBox 这样就往控件里面添加了图片了。备注FlowDocument里面的LineHeight 属性是文字段落的间距。默认间距很大所以这里调整一下 当然这样未必能够完全满足要求因为有时候我们需要在程序运行的时候点击按钮选取图片进行添加。代码如下private void AddJPG_Click(object sender, RoutedEventArgs e)        {            string filepath ;            string filename ;            OpenFileDialog openfilejpg new OpenFileDialog();            openfilejpg.Filter jpg图片(*.jpg)|*.jpg|gif图片(*.gif)|*.gif;            openfilejpg.FilterIndex 0;            openfilejpg.RestoreDirectory true;            openfilejpg.Multiselect false;            if (openfilejpg.ShowDialog() true)            {                filepath openfilejpg.FileName;                Image img new Image();                BitmapImage bImg new BitmapImage();                               img.IsEnabled true;                               bImg.BeginInit();                bImg.UriSource new Uri(filepath, UriKind.Relative);                bImg.EndInit();                img.Source bImg;                 //MessageBox.Show(bImg.Width.ToString() , bImg.Height.ToString());                /* 调整图片大小                if (bImg.Height 100 || bImg.Width 100)                {                    img.Height bImg.Height * 0.2;                    img.Width bImg.Width * 0.2;                }*/                img.Stretch Stretch.Uniform;  //图片缩放模式                new InlineUIContainer(img, richTextBox1.Selection.Start); //插入图片到选定位置            }        }这样就插入了一张图片到RichTextBox里了是不是很简单呢 原文在此http://blogs.msdn.com/jfoscoding/archive/2006/01/14/512825.aspx 这里仅整理出其中的知识点1. 取得已被选中的内容(1)使用 RichTextBox.Document.Selection属性(2)访问RichTextBox.Document.Blocks属性的“blocks”中的Text2. 在XAML中增加内容给RichTextBox:RichTextBox IsSpellCheckEnabledTrue   FlowDocument        Paragraph!-- 这里加上你的内容 --          This is a richTextBox. I can BoldBold/Bold, ItalicItalicize/Italic, HyperlinkHyperlink stuff/Hyperlink right in my document.        /Paragraph   /FlowDocument/RichTextBox3. 缩短段间距,类似BR,而不是P方法是使用Style定义段间距:    RichTextBox        RichTextBox.Resources          Style TargetType{x:Type Paragraph}            Setter PropertyMargin Value0/          /Style        /RichTextBox.Resources        FlowDocument          Paragraph            This is my first paragraph... see how there is...          /Paragraph          Paragraph            a no space anymore between it and the second paragraph?          /Paragraph        /FlowDocument      /RichTextBox4. 从文件中读出纯文本文件后放进RichTextBox或直接将文本放进RichTextBox中:private void LoadTextFile(RichTextBox richTextBox, string filename){    richTextBox.Document.Blocks.Clear();    using (StreamReader streamReader File.OpenText(filename)) {           Paragraph paragraph new Paragraph();           paragraph.Text streamReader.ReadToEnd();           richTextBox.Document.Blocks.Add(paragraph);    }}private void LoadText(RichTextBox richTextBox, string txtContent){    richTextBox.Document.Blocks.Clear();    Paragraph paragraph new Paragraph();    paragraph.Text  txtContent;    richTextBox.Document.Blocks.Add(paragraph);}5. 取得指定RichTextBox的内容private string GetText(RichTextBox richTextBox) {        TextRange textRange new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);        return textRange.Text;}6. 将RTF (rich text format)放到RichTextBox中private static void LoadRTF(string rtf, RichTextBox richTextBox)        {            if (string.IsNullOrEmpty(rtf)) {                throw new ArgumentNullException();            }            TextRange textRange new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);            using (MemoryStream rtfMemoryStream new MemoryStream()) {                using (StreamWriter rtfStreamWriter new StreamWriter(rtfMemoryStream)) {                    rtfStreamWriter.Write(rtf);                    rtfStreamWriter.Flush();                    rtfMemoryStream.Seek(0, SeekOrigin.Begin);//Load the MemoryStream into TextRange ranging from start to end of RichTextBox.                    textRange.Load(rtfMemoryStream, DataFormats.Rtf);                }            }        }7. 将文件中的内容加载为RichTextBox的内容        private static void LoadFile(string filename, RichTextBox richTextBox)        {            if (string.IsNullOrEmpty(filename)) {                throw new ArgumentNullException();            }            if (!File.Exists(filename)) {                throw new FileNotFoundException();            }            using (FileStream stream File.OpenRead(filename)) {                TextRange documentTextRange new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);                string dataFormat DataFormats.Text;                string ext System.IO.Path.GetExtension(filename);                if (String.Compare(ext, .xaml,true) 0) {                    dataFormat DataFormats.Xaml;                }                else if (String.Compare(ext, .rtf, true) 0) {                    dataFormat DataFormats.Rtf;                }                documentTextRange.Load(stream, dataFormat);            }                }8. 将RichTextBox的内容保存为文件        private static void SaveFile(string filename, RichTextBox richTextBox)        {            if (string.IsNullOrEmpty(filename)) {                throw new ArgumentNullException();            }            using (FileStream stream File.OpenWrite(filename)) {                TextRange documentTextRange new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);                string dataFormat DataFormats.Text;                string ext System.IO.Path.GetExtension(filename);                if (String.Compare(ext, .xaml, true) 0) {                    dataFormat DataFormats.Xaml;                }                else if (String.Compare(ext, .rtf, true) 0) {                    dataFormat DataFormats.Rtf;                }                documentTextRange.Save(stream, dataFormat);            }        }9. 做个简单的编辑器  !-- Window1.xaml --  DockPanel    Menu DockPanel.DockTop      MenuItem Header_File        MenuItem Header_Open File ClickOnOpenFile/        MenuItem Header_Save ClickOnSaveFile/        Separator/        MenuItem HeaderE_xit ClickOnExit/      /MenuItem          /Menu    RichTextBox NamerichTextBox1/RichTextBox       /DockPanel        // Window1.xaml.cs        private void OnExit(object sender, EventArgs e) {            this.Close();        }        private void OnOpenFile(object sender, EventArgs e) {            Microsoft.Win32.OpenFileDialog ofd new Microsoft.Win32.OpenFileDialog();            ofd.Filter Text Files (*.txt; *.xaml; *.rtf)|*.txt;*.xaml;*.rtf;            ofd.Multiselect false;            if (ofd.ShowDialog() true) {                LoadFile(ofd.SafeFileName, richTextBox1);            }        }        private void OnSaveFile(object sender, EventArgs e) {            Microsoft.Win32.SaveFileDialog sfd new Microsoft.Win32.SaveFileDialog();            sfd.Filter Text Files (*.txt; *.xaml; *.rtf)|*.txt;*.xaml;*.rtf;            if (sfd.ShowDialog() true) {                SaveFile(sfd.SafeFileName, richTextBox1);            }        }心中时常装有一盘人生的大棋,天作棋盘,星作棋子,在斗转星移中,只有不断地搏击人生,人生才有意义,生命才能彰显光辉,才能收获一分永恒。
http://www.pierceye.com/news/614098/

相关文章:

  • 设计深圳网站制作网站建设及维护招聘
  • 网站开发实训新的体会wordpress防止机器人注册
  • 购买的网站如何换背景自建网站如何被百度收录
  • 国外外贸网站手机销售网站制作
  • 海外永久网站众车网是哪家公司网站
  • 上海 网站开发 兼职布吉建设网站
  • 做网站资金来源是什么wordpress模版sns
  • 聊城wap网站建设如何分析网站竞争对手
  • 卓业网站建设flash 网站 收费
  • 两学一做 答题 网站自己做网站买东西
  • 深圳哪家公司做网站好购物网站开发问题域分析
  • 简单个人网站wordpress插件查询
  • 上海做网站搜索一下马来西亚的网站建设的竞争对手的分析
  • 建站优化易下拉系统163邮箱登录注册
  • c 做网站电子商务平台中搜索词拆解包括
  • 腾讯云10g数字盘做网站够么四川省建设人才网
  • 批量 网站标题中海园林建设有限公司网站
  • 鲜花网站数据库建设免费律师咨询
  • 团队网站建设哪家便宜制作公司网站流程
  • 青龙桥网站建设企业网页是什么
  • 上海网站建设备案号怎么恢复法律咨询网站开发
  • 烟台做网站价格动力网站建设
  • 北戴河网站建设墨刀制作网页教程
  • 成都网站设计开发做得好微信商城怎么开发
  • 江西省城乡建设培训网-官方网站上海建设集团有限公司
  • 凡科网站设计模板grimhelm wordpress
  • 自己做的网站不备案行吗建筑工程集团有限公司
  • 网站初期 权重怎么做彩票类网站开发
  • 南通网站定制公司服务器网站建设维护合同
  • 亳州做商标网站的公司免费的网站模板