wpf 生成自己格式的窗口并且按钮横向排序

来源:互联网 发布:java socket 数据传输 编辑:程序博客网 时间:2024/06/05 20:35
<Window x:Class="MysherOCRReader.ChangeDistingWordOfSelected"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="ChangeDistingWordOfSelected"  Height="80" Width="140" MaxHeight="80" MaxWidth="140"         WindowStyle="None" AllowsTransparency="True" Loaded="Window_Loaded" ShowInTaskbar="False">    <Grid>        <StackPanel Name="sp1" Background="LightSlateGray">            <Border Name="cn_drage" Background="LightGray" Height="20">            <TextBlock x:Name="tishi" Text="请输入你要替换的字" HorizontalAlignment="Center" VerticalAlignment="Stretch" ></TextBlock>            </Border>            <TextBox Name="ChangedWord" Height="27"   Margin="3" Width="100"></TextBox>            <StackPanel x:Name="sp_select" HorizontalAlignment="Center" Orientation="Horizontal">            <Button x:Name="btn_ok" Content="确定" Width="55" Margin="5"></Button>            <Button x:Name="btn_cancle" Content="取消" Width="55" Margin="5"></Button>            </StackPanel>        </StackPanel>    </Grid></Window>

后台

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;namespace MysherOCRReader{    /// <summary>    /// ChangeDistingWordOfSelected.xaml 的交互逻辑    /// </summary>    public partial class ChangeDistingWordOfSelected : Window    {        private System.Threading.Mutex myMutex = null;        public string strChange = string.Empty;        public ChangeDistingWordOfSelected()        {            InitializeComponent();            GlobalHelper._ChangeDistingWord = this;            this.btn_ok.Click += new RoutedEventHandler(btn_ok_Click);            this.cn_drage.MouseLeftButtonDown += new MouseButtonEventHandler(cn_drage_MouseLeftButtonDown);            this.btn_cancle.Click += new RoutedEventHandler(btn_cancle_Click);        }        //取消        void btn_cancle_Click(object sender, RoutedEventArgs e)        {            this.Close();        }        //移动border        void cn_drage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)        {            this.DragMove();        }        //确定,没有在这里用        void btn_ok_Click(object sender, RoutedEventArgs e)        {            strChange = this.ChangedWord.Text;        }        /// <summary>        /// 加载的时候判断是不是已经存在如果存在就不再生成了。        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void Window_Loaded(object sender, RoutedEventArgs e)        {            string configs = string.Empty;             //禁止同时打开2个              bool mutexIsNew = false;              try              {                  myMutex = new System.Threading.Mutex(true, configs, out mutexIsNew);              }              catch { }              if (!mutexIsNew)              {                  MessageBox.Show("22222");                this.Close();              }        }    }}
0 0
原创粉丝点击