Esempio n. 1
0
 private cType getSettings()
 {
     if (radioButtonDDS.Checked)
     {
         int bits = radioButton8Bit.Checked ? 8 : radioButton16Bit.Checked ? 16 : radioButton32Bit.Checked ? 32: 0;
         DDS outp = new DDS(bits, inp.Width, inp.Height, inp.Depth, 0, 0, 0);
         outp.Compressed = radioButtonCompressed.Checked;
         if (comboBoxFormat.SelectedItem != null)
         {
             outp.FormatName = (ParsedBitmap.BitmapFormat)Enum.Parse(typeof(ParsedBitmap.BitmapType), "BITM_FORMAT_" + comboBoxFormat.SelectedItem.ToString());
         }
         return(outp);
     }
     else if (radioButtonJpeg.Checked)
     {
         JPG outp = new JPG();
         return(outp);
     }
     else if (radioButtonBitmap.Checked)
     {
         BMP outp = new BMP();
         return(outp);
     }
     return(null);
 }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            #region Observer Pattern
            Book b = new Book("The lord of the rings");
            var  l = new Librarian();
            var  g = new Grocer();
            var  r = new Restorer();
            b.addObserver(l);
            b.addObserver(g);
            b.addObserver(r);
            b.Notify();
            Console.WriteLine("---------------------------------------------------------");
            #endregion

            #region Factory Method Pattern
            MyApplication app = new MyApplication();
            var           doc = app.createDocument();
            doc.Open();
            Console.WriteLine("---------------------------------------------------------");
            #endregion

            #region Bridge Pattern
            AbstractPicture img = new JPG(new OSXImp());
            img.Caller();
            img = new BMP(new WinImp());
            img.Caller();
            img = new GIF(new LinuxImp());
            img.Caller();
            Console.WriteLine("---------------------------------------------------------");
            #endregion

            #region Abstract Factory Pattern
            // THIS IS THE CLIENT CLASS CONTENT MENTIONED ON PATTERN PRINCIPLES.
            IFactory   factory   = new PMFactory();
            IScrollbar scrollbar = factory.BuildScrollbar();
            IWindow    window    = factory.BuildWindow();

            scrollbar.Draw();
            window.Draw();

            Console.WriteLine("\n");

            factory   = new MOTIFFactory();
            scrollbar = factory.BuildScrollbar();
            window    = factory.BuildWindow();

            scrollbar.Draw();
            window.Draw();
            Console.WriteLine("---------------------------------------------------------");
            #endregion

            #region Adapter Pattern
            var oldcar  = new OldCar("Chevrolet", "Impala", new DateTime(1967, 1, 1));
            var adapter = new OldNewAdapter(oldcar);
            Console.WriteLine(adapter.getBrand());
            Console.WriteLine(adapter.getYears());
            Console.WriteLine("---------------------------------------------------------");
            #endregion
        }
Esempio n. 3
0
        public cType convert(cType inputType)
        {
            Bitmap bm = null;

            // Decoding section
            if (inputType is DDS)
            {
                //bm = DDSRead(inputType as DDS);
                DDSConvert(inp, outp);
            }
            else if (inputType is JPG)
            {
                bm = new Bitmap(inputType.stream);
            }
            else if (inputType is BMP)
            {
                bm = new Bitmap(inputType.stream);
            }

            // Encoding section
            bm.Save(outp.stream, System.Drawing.Imaging.ImageFormat.Bmp);
            if (outp is DDS)
            {
                DDS inp = inputType as DDS;
                //switch (formats) { }

                return(outp);
            }
            else if (outp is JPG)
            {
                cType outputType = new JPG();
                bm.Save(outp.stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                return(outputType);
            }
            else if (outp is BMP)
            {
                cType outputType = new BMP();
                bm.Save(outp.stream, System.Drawing.Imaging.ImageFormat.Bmp);
                return(outputType);
            }

            return(null);
        }
Esempio n. 4
0
        public cType convert(cType inputType)
        {
            Bitmap bm = null;

            // Decoding section
            if (inputType is DDS)
            {
                //bm = DDSRead(inputType as DDS);
                DDSConvert(inp, outp);
            }
            else if (inputType is JPG)
                bm = new Bitmap(inputType.stream);
            else if (inputType is BMP)
                bm = new Bitmap(inputType.stream);

            // Encoding section
            bm.Save(outp.stream, System.Drawing.Imaging.ImageFormat.Bmp);
            if (outp is DDS)
            {
                DDS inp = inputType as DDS;
                //switch (formats) { }

                return outp;
            }
            else if (outp is JPG)
            {
                cType outputType = new JPG();
                bm.Save(outp.stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                return outputType;
            }
            else if (outp is BMP)
            {
                cType outputType = new BMP();
                bm.Save(outp.stream, System.Drawing.Imaging.ImageFormat.Bmp);
                return outputType;
            }

            return null;
        }
Esempio n. 5
0
 private cType getSettings()
 {
     if (radioButtonDDS.Checked)
     {
         int bits = radioButton8Bit.Checked ? 8 : radioButton16Bit.Checked ? 16 : radioButton32Bit.Checked ? 32: 0;
         DDS outp = new DDS(bits, inp.Width, inp.Height, inp.Depth, 0, 0, 0);
         outp.Compressed = radioButtonCompressed.Checked;
         if (comboBoxFormat.SelectedItem != null)
             outp.FormatName = (ParsedBitmap.BitmapFormat) Enum.Parse(typeof(ParsedBitmap.BitmapType), "BITM_FORMAT_" + comboBoxFormat.SelectedItem.ToString());
         return outp;
     }
     else if (radioButtonJpeg.Checked)
     {
         JPG outp = new JPG();
         return outp;
     }
     else if (radioButtonBitmap.Checked)
     {
         BMP outp = new BMP();
         return outp;
     }
     return null;
 }
Esempio n. 6
0
        public void setDetails(cType input, bool orig)
        {
            if (orig)
            {
                dataOrigType.Text   = input.classType.ToString();
                dataOrigBPP.Text    = input.BitsPerPixel.ToString();
                dataOrigWidth.Text  = input.Width.ToString();
                dataOrigHeight.Text = input.Height.ToString();
            }

            switch (input.classType)
            {
            case classTypes.DDS:
                DDS DDSInput = input as DDS;
                radioButtonDDS.Checked = true;
                // Compressed/Uncompressed
                if (DDSInput.Compressed)
                {
                    radioButtonCompressed.Checked = true;
                    radioButton32Bit.Checked      = true;
                    radioButton16Bit.Enabled      = false;
                    radioButton8Bit.Enabled       = false;
                }
                else
                {
                    radioButtonUncompressed.Checked = true;
                    radioButton16Bit.Enabled        = true;
                    radioButton8Bit.Enabled         = true;
                    switch (DDSInput.BitsPerPixel)
                    {
                    case 8:
                        radioButton8Bit.Checked = true;
                        break;

                    case 16:
                        radioButton16Bit.Checked = true;
                        break;

                    case 32:
                        radioButton32Bit.Checked = true;
                        break;
                    }
                }

                if (orig)
                {
                    dataOrigFormat.Text = DDSInput.FormatName.ToString();
                    for (int i = 1; i < DDSInput.MipMapCount; i++)
                    {
                        comboBoxMipmaps.Items.Add(i);
                    }
                    if (comboBoxMipmaps.Items.Count > 0)
                    {
                        checkBoxMipMaps.Enabled       = true;
                        checkBoxMipMaps.Checked       = true;
                        comboBoxMipmaps.SelectedIndex = comboBoxMipmaps.Items.Count - 1;
                    }
                    else
                    {
                        checkBoxMipMaps.Checked = false;
                        checkBoxMipMaps.Enabled = false;
                    }
                }

                setFormats(DDSInput);
                break;

            case classTypes.Jpeg:
                JPG JPGInput = input as JPG;
                radioButtonJpeg.Checked = true;
                break;

            case classTypes.Bitmap:
                BMP BMPInput = input as BMP;
                radioButtonBitmap.Checked = true;
                break;
            }
        }