コード例 #1
0
        private void ButtonLoad_onClick(object sender, EventArgs e)//load button
        {
            //Todo: Add ability to load image file formats also
            //OpenFileDialogue.Filter = "SVG Files (*.svg)|*.svg|Image files (*.png, *.tiff, *.tif)|*.png;.tiff;.tif|All files (*.*)|*.*";
            //This may be a significant undertaking
            //Most of these routines are built with an SVG being assumed.

            OpenFileDialogue.Filter = "SVG Files (*.svg)|*.svg|All files (*.*)|*.*";
            if (OpenFileDialogue.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            lastSourceFilename = OpenFileDialogue.FileName;


            //to minimize disk IO this is only opened once here and when it needs to be rerendered for actual field generation.
            SvgDocument d = SvgDocument.Open(OpenFileDialogue.FileName);

            lastWidthHeight             = new Tuple <float, float>(d.Width.Value, d.Height.Value);
            DecalLoaded                 = true;
            this.GenerateButton.Enabled = true;
            SourceAspect                = lastWidthHeight.Item1 / lastWidthHeight.Item2;
            int sourceHeight = 4096;
            int sourceWidth  = (int)(4096 * (1.0f / SourceAspect));

            //rendered once to memory. That file in memory is downsampled for the preview image as the window is resized.
            SourceBitmap       = SignedDistanceFieldRenderer.RenderSvgToBitmapWithMaximumSize(lastSourceFilename, sourceWidth, sourceHeight);
            decalPreview.Image = BitmapHelper.ResizeBitmapToFit(SourceBitmap, decalPreview.Width, decalPreview.Height, SourceAspect);
        }
コード例 #2
0
 public void SetFilePath()
 {
     _openFileDialogue = new OpenFileDialogue();
     _openFileDialogue.SetFilePath(_imagePath);
     _image = Image.FromFile(_imagePath);
 }
コード例 #3
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialogue.FileName         = "Product.txt";
            OpenFileDialogue.InitialDirectory = Directory.GetCurrentDirectory();
            OpenFileDialogue.Filter           = "Text Files(*.txt)|*.txt| All Files (*.*)|*.*";
            var result = OpenFileDialogue.ShowDialog();

            if (result != DialogResult.Cancel)
            {
                try
                {
                    using (StreamReader inputStream = new StreamReader(
                               File.Open(OpenFileDialogue.FileName, FileMode.Open)))
                    {
                        //read the file
                        Program.productDetails.ProductionId = int.Parse(inputStream.ReadLine());
                        Program.productDetails.Cost         = double.Parse(inputStream.ReadLine());
                        Program.productDetails.Manufacturer = inputStream.ReadLine();
                        Program.productDetails.Model        = inputStream.ReadLine();
                        Program.productDetails.RamType      = inputStream.ReadLine();
                        Program.productDetails.RamSize      = inputStream.ReadLine();
                        Program.productDetails.DisplayType  = inputStream.ReadLine();
                        Program.productDetails.LCDSize      = inputStream.ReadLine();
                        Program.productDetails.CPUClass     = inputStream.ReadLine();
                        Program.productDetails.CPUBrand     = inputStream.ReadLine();
                        Program.productDetails.CPUType      = inputStream.ReadLine();
                        Program.productDetails.CPUSpeed     = inputStream.ReadLine();
                        Program.productDetails.CPUNumber    = inputStream.ReadLine();
                        Program.productDetails.Condition    = inputStream.ReadLine();
                        Program.productDetails.OS           = inputStream.ReadLine();
                        Program.productDetails.Platform     = inputStream.ReadLine();
                        Program.productDetails.HDDSize      = inputStream.ReadLine();
                        Program.productDetails.HDDSpeed     = inputStream.ReadLine();
                        Program.productDetails.GPUType      = inputStream.ReadLine();
                        Program.productDetails.OpticalDrive = inputStream.ReadLine();
                        Program.productDetails.AudioType    = inputStream.ReadLine();
                        Program.productDetails.LAN          = inputStream.ReadLine();
                        Program.productDetails.WIFI         = inputStream.ReadLine();
                        Program.productDetails.Width        = inputStream.ReadLine();
                        Program.productDetails.Height       = inputStream.ReadLine();
                        Program.productDetails.Depth        = inputStream.ReadLine();
                        Program.productDetails.Weight       = inputStream.ReadLine();
                        Program.productDetails.MouseType    = inputStream.ReadLine();
                        Program.productDetails.Power        = inputStream.ReadLine();
                        Program.productDetails.WebCam       = inputStream.ReadLine();

                        inputStream.Close();
                        inputStream.Dispose();
                    }
                    this.Hide();
                    Program.orderForm.Show();
                }
                catch (IOException exception)
                {
                    MessageBox.Show("ERROR" + exception.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (FormatException exception)
                {
                    MessageBox.Show("ERROR " + exception.Message + "\n\nPlease select the appropriate file type", "ERROR",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }