Exemplo n.º 1
0
        private void ButtonAddProg_Click(object sender, RoutedEventArgs e)
        {
            if (File.Exists(textBoxInputPath.Text))
            {
                if (textBoxInputName.Text != "")
                {
                    Progs p = new Progs(textBoxInputPath.Text, textBoxInputName.Text);
                    p.Width      = 89;
                    p.Height     = 33;
                    p.Background = Brushes.Transparent;
                    p.Content    = textBoxInputName.Text;
                    string path = Directory.GetCurrentDirectory() + "\\Data\\FavorProg\\" + textBoxInputName.Text + ".DOSSTONED";// +p.ClickedTimes.ToString();

                    listView1.Items.Add(p);

                    if (!File.Exists(path))
                    {
                        using (StreamWriter sw = File.CreateText(path))
                        {
                            sw.WriteLine(textBoxInputPath.Text);
                        }
                    }

                    textBoxInputPath.Text = "";
                    textBoxInputName.Text = "";
                }
                else
                {
                    MessageBox.Show("缺少名称!");
                }
            }
            else
            {
                if (textBoxInputName.Text != "" && textBoxInputPath.Text != "")
                {
                    MessageBox.Show(new FileNotFoundException().Message);
                }
            }
            th.Background         = Brushes.Transparent;
            stackPanel.Visibility = Visibility.Collapsed;
            th.Visibility         = Visibility.Collapsed;
        }
Exemplo n.º 2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            const int BorderPixel = 0;

            this.Left = SystemParameters.WorkArea.Width - Width - BorderPixel;
            this.Top  = SystemParameters.WorkArea.Height - Height - BorderPixel;
            string[] Programs = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Data\\FavorProg", "*.DOSSTONED.*");
            foreach (string program in Programs)
            {
                string sname = "";
                //uint sclick = 0;
                using (StreamReader sr = File.OpenText(program))
                {
                    sname = sr.ReadLine();
                    //sclick = Convert.ToUInt32(Path.GetExtension(program));
                }
                Progs p = new Progs(sname, Path.GetFileNameWithoutExtension(program));
                p.Width      = 89;
                p.Height     = 33;
                p.Background = Brushes.Transparent;
                //p.ClickedTimes = sclick;
                listView1.Items.Add(p);
            }
        }