Ejemplo n.º 1
0
        private void MenuOpen_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog OpenDlg = new OpenFileDialog())
            {
                OpenDlg.Filter = "Bayonetta IDD|*.idd";

                if (OpenDlg.ShowDialog() == DialogResult.OK && File.Exists(OpenDlg.FileName))
                {
                    CurrentFilePath = OpenDlg.FileName;
                    CurrentFile     = IDD.Load(new FileStream(CurrentFilePath, FileMode.Open));

                    TextureImg.Image = null;
                    LstTextures.Items.Clear();
                    LstItems.Items.Clear();
                    NUDX.Value = 0;
                    NUDY.Value = 0;
                    NUDW.Value = 0;
                    NUDH.Value = 0;

                    for (int Index = 0; Index < CurrentFile.Textures.Count; Index++)
                    {
                        LstTextures.Items.Add(string.Format("Texture {0:D5}", Index));
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void MenuSave_Click(object sender, EventArgs e)
 {
     if (CurrentFile != null)
     {
         IDD.Save(new FileStream(CurrentFilePath, FileMode.Open), CurrentFile);
         MessageBox.Show(
             "Changes saved successfully!",
             "Information",
             MessageBoxButtons.OK,
             MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 3
0
        private void btnPreview_Click(object sender, EventArgs e)
        {
            // Only display a print preview if it's a paged document. Otherwise, display an image from the page segment if we can
            switch (DocType)
            {
            case eFileType.Document:
                // Verify they want to view if there are missing resources
                if (afpFile.Resources.All(r => r.IsLoaded || r.IsNETCodePage) || MessageBox.Show("There are referenced resources that have not been located. Preview anyway?"
                                                                                                 , "Missing Resources", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    // Set up a print preview dialog and wire it to our print parser's build event
                    PrintPreviewDialog ppd = new PrintPreviewDialog()
                    {
                        Document = new PrintDocument()
                        {
                            DocumentName = opts.LastOpenedFile
                        }
                    };
                    ppd.Controls.OfType <ToolStrip>().First().Items["printToolStripButton"].Visible = false;    // Temp disable until we actually might want to print something
                    ((Form)ppd).WindowState = FormWindowState.Maximized;
                    ppd.Document.PrintPage += printParser.BuildPrintPage;

                    // Set page size by checking the first PGD. Width and height are in 1/100 inch
                    PGD pgd    = afpFile.Fields.OfType <PGD>().First();
                    int xWidth = (int)(Converters.GetInches((int)pgd.XSize, pgd.UnitsPerXBase, pgd.BaseUnit) * 100);
                    int yWidth = (int)(Converters.GetInches((int)pgd.YSize, pgd.UnitsPerYBase, pgd.BaseUnit) * 100);
                    ppd.Document.DefaultPageSettings.PaperSize = new PaperSize("Custom", xWidth, yWidth);

                    ppd.ShowDialog();
                }

                break;

            case eFileType.IOCAImage:
            case eFileType.IMImage:
                int fileCounter = 1;

                if (afpFile.ParsedImages.Any() || afpFile.ParsedIMImages.Any())
                {
                    Cursor = Cursors.WaitCursor;

                    // Clear out the directory of existing pngs
                    foreach (string file in Directory.GetFiles(Environment.CurrentDirectory))
                    {
                        if (new FileInfo(file).Extension.ToUpper() == ".PNG")
                        {
                            File.Delete(file);
                        }
                    }

                    // Generate a .png from the image data and save it to the exe directory
                    if (DocType == eFileType.IOCAImage)
                    {
                        foreach (KeyValuePair <Container, IReadOnlyList <ImageInfo> > kvp in afpFile.ParsedImages)
                        {
                            foreach (ImageInfo image in kvp.Value)
                            {
                                Bitmap png = new Bitmap(new MemoryStream(image.Data));

                                // Get resolution from descriptor
                                IDD   descriptor = kvp.Key.GetStructure <IDD>();
                                float xScale     = (float)Converters.GetInches(png.Width, descriptor.HResolution, descriptor.BaseUnit);
                                float yScale     = (float)Converters.GetInches(png.Height, descriptor.VResolution, descriptor.BaseUnit);
                                png.SetResolution(png.Width / xScale, png.Height / yScale);

                                // Generate image
                                png.Save($"{Environment.CurrentDirectory}\\Image {fileCounter++}.png", System.Drawing.Imaging.ImageFormat.Png);
                            }
                        }
                    }
                    else
                    {
                        foreach (KeyValuePair <Container, IReadOnlyList <IMImageCell> > kvp in afpFile.ParsedIMImages)
                        {
                            IMImageCell.GenerateBitmap(kvp.Key.GetStructure <IID>(), kvp.Value.ToList())
                            .Save($"{Environment.CurrentDirectory}\\Image {fileCounter++}.png", System.Drawing.Imaging.ImageFormat.Png);
                        }
                    }

                    btnPreview.Enabled = false;
                    Cursor             = Cursors.Default;
                    if (MessageBox.Show($"{fileCounter} image(s) created in executing directory. Open directory?",
                                        "Images Created", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        System.Diagnostics.Process.Start(Environment.CurrentDirectory);
                    }
                }
                else
                {
                    MessageBox.Show("No image containers found, though this does appear to be an image file.");
                }
                break;
            }
        }
Ejemplo n.º 4
0
        private void button7_Click(object sender, EventArgs e)
        {
            string logfile = @"LogFile.txt";
            string logbody = null;

            TextBox[] textBoxes = new TextBox[] { textBox1, textBox2, textBox3, textBox4, textBox5, textBox6, textBox7, textBox8, textBox9, textBox10,
                                                  textBox11, textBox12, textBox13, textBox14, textBox15, textBox16, textBox17, textBox18, textBox19, textBox20,
                                                  textBox21, textBox22, textBox23, textBox24, textBox25, textBox26, textBox27, textBox28, textBox29, textBox30,
                                                  textBox31, textBox32, textBox33, textBox34, textBox35, textBox36, textBox37, textBox38, textBox39, textBox40,
                                                  textBox41, textBox42, textBox43, textBox44, textBox45, textBox46, textBox47, textBox48, textBox49, textBox50,
                                                  textBox51, textBox52, textBox53, textBox54, textBox55, textBox56, textBox57, textBox58, textBox59, textBox60 };

            if (!File.Exists(logfile))
            {
                File.Create(logfile);
            }

            try
            {
                this.Invoke((MethodInvoker) delegate
                {
                    for (int x = 0; x < numericUpDown4.Value; x++)
                    {
                        for (int i = 0; i < 20; i++)
                        {
                            if (m_innovativeConnected)
                            {
                                m_innovative_hal.Address(i + 1);                                //set gpio mux
                                address.Value = i + 1;
                                address.Refresh();

                                /*
                                 * FuryServerConnection_DropDown(this, new EventArgs()); //click the dropdown to populate list
                                 * for (int j = 0; j < FuryServerConnection.Items.Count; j++)
                                 * {
                                 *      string selected = InnovativeICEConnection.Text;
                                 *      string resultString = Regex.Match(selected, @"\d+").Value;
                                 *      if (FuryServerConnection.Items[j].ToString().Contains(resultString))
                                 *              FuryServerConnection.SelectedIndex = j;
                                 * }//select the right server based on the innovative box
                                 * furyConnectBox.Checked = true;
                                 * furyConnectBox_Click(this, new EventArgs()); //connect fury
                                 */
                                m_x80_hal.FirmwareEn = true;

                                string fw        = System.Text.Encoding.ASCII.GetString(m_x80_hal.FirmwareID);
                                firmewareID.Text = fw;
                                firmewareID.Refresh();
                                mcuTemp.Text = m_x80_hal.MCU_TEMP.ToString();
                                mcuTemp.Refresh();
                                IDD.Text = m_x80_hal.DUT_CURRENT.ToString();
                                IDD.Refresh();
                                thermTemp.Text = m_x80_hal.DUT_TEMP.ToString();
                                thermTemp.Refresh();
                                dutPresent.Checked = Convert.ToBoolean(m_x80_hal.DUTPRESENT);
                                dutPresent.Refresh();
                                firmwareEN.Checked = m_x80_hal.FirmwareEn;
                                firmwareEN.Refresh();
                                furyConnectBox_Click(this, new EventArgs());                                 //disconnect fury


                                textBoxes[(3 * i)].Text     = m_x80_hal.MCU_TEMP.ToString();
                                textBoxes[(3 * i) + 1].Text = m_x80_hal.DUT_CURRENT.ToString();
                                textBoxes[(3 * i) + 2].Text = m_x80_hal.DUT_TEMP.ToString();
                                if (Convert.ToBoolean(m_x80_hal.DUTPRESENT))
                                {
                                    textBoxes[(3 * i)].BackColor     = Color.Gold;
                                    textBoxes[(3 * i) + 1].BackColor = Color.Gold;
                                    textBoxes[(3 * i) + 2].BackColor = Color.Gold;
                                }
                                else
                                {
                                    textBoxes[(3 * i)].BackColor     = Color.LightGray;
                                    textBoxes[(3 * i) + 1].BackColor = Color.LightGray;
                                    textBoxes[(3 * i) + 2].BackColor = Color.LightGray;
                                }

                                logbody += m_x80_hal.MCU_TEMP.ToString() + "," + m_x80_hal.DUT_CURRENT.ToString() + "," + m_x80_hal.DUT_TEMP.ToString() + ",";
                            }
                            else
                            {
                                MessageBox.Show("Innovative server not connected");
                            }
                        }
                        if (logbody != null)
                        {
                            using (System.IO.StreamWriter filewriter = new System.IO.StreamWriter(logfile, true))
                            {
                                filewriter.WriteLine(DateTime.Now.ToString("MMMM dd yyyy hh:mm tt,") + logbody);
                            }
                            logbody = null;
                        }
                        if (x != numericUpDown4.Value - 1)
                        {
                            Thread.Sleep(Decimal.ToInt32(numericUpDown3.Value) * 1000);
                        }
                    }
                });
            }
            catch { }
        }