Пример #1
0
		public Window1(){
			InitializeComponent();			
			ikonaUAC.ImageSource = Ikony.Ikona("user32.dll",-106,true);
			ikonaUloz.ImageSource = Ikony.Ikona("shell32.dll",258,true);
			ikonaNapoveda.ImageSource = Ikony.Ikona("shell32.dll",277,true);
			ikonaNastaveni.ImageSource = Ikony.Ikona("imageres.dll",109,true);	
			tbCesta.Text = vychozi_cesta;
			Directory.SetCurrentDirectory(vychozi_cesta);
            Funkce.CD(vychozi_cesta);
			richTextBox1.Document.Blocks.Add(
				new Paragraph(new Run(Environment.OSVersion.ToString() + "\r\n"
			)));
			
			if(Funkce.Admin()) 
				Title+= " - Admin práva";
			
			DispatcherTimer dt = new DispatcherTimer();
			dt.Tick += new EventHandler(Hodiny);
			dt.Interval = TimeSpan.FromSeconds(10);
			dt.Start();
            Predvolby.NactiNastaveni();
            Predvolby.NactiProgramy();
            Predvolby.NactiHistorii();
            Funkce.ZapisDatum();
            Funkce.CbZapsat(cbPrikaz);
        }		
Пример #2
0
        public static void CD(string cesta)
        {
            if (Regex.Match(mw.tbCesta.Text, "^[a-zA-Z]:\\\\$").Success&& cesta == "..")
            {
                mw.disk = true;
                mw.lvSlozky.Items.Clear();

                foreach (var d in DriveInfo.GetDrives())
                {
                    string      druh = d.DriveType.ToString();
                    ImageSource ik   = null;
                    if (druh == "CDRom")
                    {
                        ik = Ikony.Ikona("shell32.dll", 11, true);
                    }
                    else if (druh == "Fixed")
                    {
                        ik = Ikony.Ikona("shell32.dll", 8, true);
                    }
                    else
                    {
                        ik = Ikony.Ikona("shell32.dll", 8, true);
                    }

                    mw.lvSlozky.Items.Add(new Polozky {
                        lvikona = ik, lvnazev = d.Name.ToString()
                    });
                }

                mw.lvSlozky.Items.Add(new Polozky {
                    lvikona = Ikony.Ikona("shell32.dll", 158, true), lvnazev = "Profil"
                });
                mw.lvSlozky.Items.Add(new Polozky {
                    lvikona = Ikony.Ikona("imageres.dll", 105, true), lvnazev = "Plocha"
                });
                mw.lvSlozky.Items.Add(new Polozky {
                    lvikona = Ikony.Ikona("shell32.dll", 3, true), lvnazev = "Windows"
                });
                return;
            }

            if (mw.disk)
            {
                if (cesta == "Windows")
                {
                    cesta = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
                }
                if (cesta == "Profil")
                {
                    cesta = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
                }
                if (cesta == "Plocha")
                {
                    cesta = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                }
                mw.disk = false;
            }

            string cesta2 = "";

            if (Regex.Match(cesta, "[a-zA-Z]:").Success)
            {
                cesta2 = cesta;
            }
            else
            {
                cesta2 = Directory.GetCurrentDirectory() + "\\" + cesta;
            }

            try { Directory.SetCurrentDirectory(cesta2); } catch { }
            mw.tbCesta.Text = Directory.GetCurrentDirectory();
            mw.Soubory(cesta2);
        }
Пример #3
0
        public void Soubory(string cesta) {
            string filtr = tbFiltr.Text;

            Thread u = new Thread(() => {
                try {
                    seznam_souboru.Clear();
                    seznam_slozek.Clear();
                    ImageSource ikSlozka = null;

                    Dispatcher.BeginInvoke(DispatcherPriority.Background,(ThreadStart)delegate () {
                        lvSoubory.Items.Clear();
                        lvSlozky.Items.Clear();
                        ikSlozka = Ikony.Ikona("shell32.dll",3,true);
                    });

                    foreach (string s in Directory.GetFiles(cesta)) {
                        if (filtr == "") seznam_souboru.Add(s);
                        else {
                            foreach (string p in filtr.Split(' ')) {
                                if (Path.GetExtension(s).ToLower() == "." + p)
                                    seznam_souboru.Add(s);
                            }
                        }
                    }

                    foreach (string p in Directory.GetDirectories(cesta)) {
                        seznam_slozek.Add(p);
                    }

                    foreach (string p in Directory.GetDirectories(cesta)) {
                        seznam_slozek.Add(p);
                    }

                    Dispatcher.BeginInvoke(DispatcherPriority.Background,(ThreadStart)delegate () {
                        lvSlozky.Items.Add(new Polozky { lvnazev = ".." });
                    });

                    foreach (string p in seznam_slozek.ToList()) {
                        Dispatcher.BeginInvoke(DispatcherPriority.Background,(ThreadStart)delegate () {
                            lvSlozky.Items.Add(new Polozky { lvikona = ikSlozka,lvnazev = Path.GetFileName(p) });
                        });
                    }

                    seznam = 1;
                    if (nacitat_soubory) {

                        foreach (string p in seznam_souboru.ToList()) {
                            Dispatcher.BeginInvoke(DispatcherPriority.Background,(ThreadStart)delegate () {
                                lvSoubory.Items.Add(
                                    new Polozky {
                                        lvzaskrknuto = true,
                                        lvikona = Ikony.Ikona2(Path.GetFullPath(p)),
                                        lvnazev = Path.GetFileNameWithoutExtension(p),
                                        lvpripona = Path.GetExtension(p).Replace(".","")
                                    });
                            });
                        }
                        seznam = 2;
                    }
                }
                catch (Exception e) {
                    if (e is DirectoryNotFoundException) cesta = "1";
                    else MessageBox.Show(e.Message.ToString(),"Upozornění",0,MessageBoxImage.Warning);

                    Dispatcher.BeginInvoke(DispatcherPriority.Background,(ThreadStart)delegate () {
                        Funkce.CD("..");
                    });
                }
            });
            u.IsBackground = true;
            u.Start();
        }