Beispiel #1
0
        static void TestDirectory(DirectoryInfo dir, FolderTreeEnumerator enumerator)
        {
            List <FileInfo> files = new List <FileInfo>(dir.GetFiles());

            files.Sort(CompareFileInfo);
            foreach (FileInfo file in files)
            {
                if (0 == (file.Attributes & (FileAttributes.Hidden | FileAttributes.System)) && (file.Extension.Equals(".jpg", StringComparison.OrdinalIgnoreCase) || file.Extension.Equals(".doc", StringComparison.OrdinalIgnoreCase)))
                {
                    Trace.WriteLine(enumerator.Current);
                    if (file.FullName != enumerator.Current)
                    {
                        Trace.Fail(string.Format("{0} != {1}", file.FullName, enumerator.Current));
                    }
                    enumerator.MoveNext();
                    enumerator.MovePrev();
                    if (file.FullName != enumerator.Current)
                    {
                        Trace.Fail(string.Format("{0} != {1} (fwd/bck)", file.FullName, enumerator.Current));
                    }
                    enumerator.MoveNext();
                }
            }

            foreach (DirectoryInfo subdir in dir.GetDirectories())
            {
                if (0 == (subdir.Attributes & (FileAttributes.Hidden | FileAttributes.System)))
                {
                    TestDirectory(subdir, enumerator);
                }
            }
        }
Beispiel #2
0
        public static void Test()
        {
            FolderTreeEnumerator enumerator = new FolderTreeEnumerator();

            enumerator.IncludeExtensions = new string[] { ".jpg", ".doc" };
            enumerator.RootDirectories   = new string[]
            {
                "C:\\Documents and Settings"
                //@"C:\Documents and Settings\brandt.redd\My Documents\Geocaches\Archive\TB Winnie's Wagon_files"
            };

            Trace.Assert(enumerator.MoveNext());
            TestDirectory(new DirectoryInfo(enumerator.RootDirectories[0]), enumerator);
            Trace.Assert(!enumerator.MoveNext());

            enumerator.Reset();
            Trace.Assert(enumerator.MoveNext());
            TestDirectorySkip(new DirectoryInfo(enumerator.RootDirectories[0]), enumerator);
            Trace.Assert(!enumerator.MoveNext());
        }
Beispiel #3
0
        public App()
        {
            bool firstInstance;

            fAppMutex = new Mutex(true, cMutexName, out firstInstance);
            if (!firstInstance)
            {
                Debug.WriteLine("Instance already running.");
                Shutdown();
                return;
            }

            //InitializeComponent();

#if DEBUG && false
            FolderTreeEnumerator.Test();
#endif
            bool   noShow      = false;
            bool   syntaxError = false;
            string rootPath    = null;
            {
                string[] commandLineArgs = Environment.GetCommandLineArgs();

                fIsScreenSaver = System.IO.Path.GetExtension(commandLineArgs[0]).Equals(".scr", StringComparison.OrdinalIgnoreCase);

                IEnumerator p = commandLineArgs.GetEnumerator();
                p.MoveNext();                 // Skip exe name
                while (p.MoveNext())
                {
                    string arg = p.Current as string;
                    if (arg[0] == '-' || arg[0] == '/')
                    {
                        int colon = arg.IndexOf(':');

                        string option;
                        string value;
                        if (colon >= 0)
                        {
                            option = arg.Substring(1, colon - 1).ToLower();
                            value  = arg.Substring(colon + 1);
                        }
                        else
                        {
                            option = arg.Substring(1).ToLower();
                            value  = null;
                        }

                        switch (option)
                        {
                        case "c":                                 // Screen saver configuration
                            MessageBox.Show("Right-click on the screen saver while it's running to change configuration.");
                            noShow = true;
                            break;

                        case "s":                                 // Screen saver show
                            break;                                // do nothing

                        default:
                            syntaxError = true;
                            noShow      = true;
                            break;
                        }
                    }
                    else if (rootPath == null)
                    {
                        rootPath = arg;
                    }
                    else
                    {
                        syntaxError = true;
                        noShow      = true;
                    }
                }
            }

            if (syntaxError)
            {
                MessageBox.Show(cSyntax);
            }
            if (noShow)
            {
                return;
            }

            SlideShowWindow mainWindow = new SlideShowWindow();
            mainWindow.Height = 800;                    // QQQ Maximize the window here
            mainWindow.Width  = 800;
            mainWindow.LoadState();
            if (rootPath != null)
            {
                if (!string.Equals(mainWindow.RootPath, rootPath, StringComparison.OrdinalIgnoreCase))
                {
                    mainWindow.SelectedDirectories = new string[] { rootPath };
                }
                mainWindow.RootPath = rootPath;
            }
            mainWindow.Show();
            mainWindow.Start();

            //Window otherWindow = new Window1();
            //otherWindow.Show();
        }