Beispiel #1
0
        /// <summary>
        /// Finds an identical, already saved krystal
        /// </summary>
        /// <param name="nameIntro">one of "ck", "lk", "mk", "xk", "sk"</param>
        /// <returns></returns>
        protected string GetNameOfEquivalentSavedKrystal(string nameIntro)
        {
            Debug.Assert(_name == "" || _name == K.UntitledKrystalName);
            string        newName      = "";
            DirectoryInfo dir          = new DirectoryInfo(K.KrystalsFolder);
            Krystal       otherKrystal = null;

            foreach (FileInfo fileInfo in dir.GetFiles("*.krys"))
            {
                if (fileInfo.Name[0] == nameIntro[0])
                {
                    switch (fileInfo.Name[0])
                    {
                    case 'c':
                        otherKrystal = new ConstantKrystal(K.KrystalsFolder + @"\" + fileInfo.Name);
                        break;

                    case 'l':
                        otherKrystal = new LineKrystal(K.KrystalsFolder + @"\" + fileInfo.Name);
                        break;

                    case 'm':
                        otherKrystal = new ModulationKrystal(K.KrystalsFolder + @"\" + fileInfo.Name);
                        break;

                    case 'p':
                        otherKrystal = new PermutationKrystal(K.KrystalsFolder + @"\" + fileInfo.Name);
                        break;

                    case 's':
                        otherKrystal = new ShapedExpansionKrystal(K.KrystalsFolder + @"\" + fileInfo.Name);
                        break;

                    case 'x':
                        otherKrystal = new ExpansionKrystal(K.KrystalsFolder + @"\" + fileInfo.Name);
                        break;
                    }
                    if (this.CompareTo(otherKrystal) == 0)
                    {
                        newName = otherKrystal.Name;
                        break;
                    }
                }
            }
            return(newName);
        }
Beispiel #2
0
        public static Krystal LoadKrystal(string pathname)
        {
            Krystal krystal  = null;
            string  filename = Path.GetFileName(pathname);

            if (IsConstantKrystalFilename(filename))
            {
                krystal = new ConstantKrystal(pathname);
            }
            else if (IsLineKrystalFilename(filename))
            {
                krystal = new LineKrystal(pathname);
            }
            else if (IsExpansionKrystalFilename(filename))
            {
                krystal = new ExpansionKrystal(pathname);
            }
            else if (IsShapedExpansionKrystalFilename(filename))
            {
                krystal = new ShapedExpansionKrystal(pathname);
            }
            else if (IsModulationKrystalFilename(filename))
            {
                krystal = new ModulationKrystal(pathname);
            }
            else if (IsPermutationKrystalFilename(filename))
            {
                krystal = new PermutationKrystal(pathname);
            }

            else
            {
                string msg = pathname + "\r\n\r\n is not a known type of krystal.";
                MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return(krystal);
        }