Ejemplo n.º 1
0
 private static XCImageCollection LoadImageCollection(
     IXCImageFile filterIdx,
     string path,
     string fName)
 {
     return(filterIdx.LoadFile(             // load file based on its filterIndex
                path,
                fName,
                filterIdx.ImageSize.Width,
                filterIdx.ImageSize.Height));
 }
Ejemplo n.º 2
0
        public xcProfile(ImgProfile profile)
            :
            base(0, 0)
        {
            imageSize = new System.Drawing.Size(profile.ImgWid, profile.ImgHei);
            codec     = profile.ImgType;
            expDesc   = profile.Description;
            ext       = profile.Extension;
            author    = "Profile";
            desc      = profile.Description;

            if (profile.OpenSingle != "")
            {
                singleFile = profile.OpenSingle;
            }

//			fileOptions.BmpDialog = true;
//			fileOptions.OpenDialog = true;

            // since it is loading off of an already generic implementation
            // it should let that implementation determine how this format be saved
//			fileOptions.SaveDialog = false;
//			fileOptions.CustomDialog = false;

            fileOptions.Init(false, true, true, false);

            xConsole.AddLine("Profile created: " + desc);

            try
            {
                defPal = XCom.SharedSpace.Instance.GetPaletteTable()[profile.Palette];
            }
            catch
            {
                defPal = XCom.Palette.UFOBattle;
//				defPal = XCom.Palette.TFTDBattle;
            }
        }
Ejemplo n.º 3
0
        public void LoadPckFile(string filePath, int bpp)
        {
            _currentFilePath = filePath;
            _currentFileBpp  = bpp;

            SaveMenuItem.Visible = true;
            IXCImageFile filterIdx = openDictionary[7];

            var fileName = Path.GetFileName(filePath);
            var path     = Path.GetDirectoryName(filePath);

            if (fileName != null)
            {
                var images = LoadImageCollection(filterIdx, path, fileName.ToLower());
                SetImages(images);
                UpdateText();

                MapViewIntegrationMenuItem.Visible = true;
                if (Settings.Default.MapViewIntegrationHelpShown < 2)
                {
                    MapViewIntegrationHelpPanel.Visible = true;
                }
            }
        }
Ejemplo n.º 4
0
        private void openItem_Click(object sender, System.EventArgs e)
        {
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                OnResize(null);

                string fName = openFile.FileName.Substring(openFile.FileName.LastIndexOf("/") + 1).ToLower();

                string ext  = fName.Substring(fName.LastIndexOf("."));
                string file = fName.Substring(0, fName.LastIndexOf("."));
                string path = openFile.FileName.Substring(0, openFile.FileName.LastIndexOf("/") + 1);

                XCom.XCImageCollection toLoad = null;
                bool recover = false;

                // remove saving - there are too many formats and stuff,
                // I will implement only one type of direct saving.
                _currentFilePath     = null;
                SaveMenuItem.Visible = false;

                //Console.WriteLine(openFile.FilterIndex+" -> " + filterIndex[openFile.FilterIndex].GetType());
#if !DEBUG
                try
                {
#endif
                IXCImageFile filterIdx = openDictionary[openFile.FilterIndex];            //filterIndex[openFile.FilterIndex];
                if (filterIdx.GetType() == typeof(xcForceCustom))                         // special case
                {
                    toLoad  = filterIdx.LoadFile(path, fName);
                    recover = true;
                }
                else if (filterIdx.GetType() == typeof(xcCustom))                          // for *.* files, try singles and then extensions
                {
                    // try singles
                    foreach (XCom.Interfaces.IXCImageFile ixf in loadedTypes.AllLoaded)
                    {
                        if (ixf.SingleFileName != null && ixf.SingleFileName.ToLower() == fName.ToLower())
                        {
                            try
                            {
                                toLoad = ixf.LoadFile(path, fName);
                                break;
                            }
                            catch
                            {}
                        }
                    }

                    if (toLoad == null)                             // singles not loaded, try non singles
                    {
                        foreach (XCom.Interfaces.IXCImageFile ixf in loadedTypes.AllLoaded)
                        {
                            if (ixf.SingleFileName == null && ixf.FileExtension.ToLower() == ext.ToLower())
                            {
                                try
                                {
                                    toLoad = ixf.LoadFile(path, fName);
                                    break;
                                }
                                catch
                                {}
                            }
                        }

                        if (toLoad == null)                                 // nothing loaded, force the custom dialog
                        {
                            toLoad = xcCustom.LoadFile(path, fName, 0, 0);
                        }
                    }
                }
                else
                {
                    toLoad = LoadImageCollection(filterIdx, path, fName);
                }
#if !DEBUG
            }
            catch (Exception ex)
            {
                if (MessageBox.Show(
                        this,
                        "Error loading file: " + fName + "\nPath: " + openFile.FileName
                        + "\nError loading file, do you wish to try and recover?\n\nError Message: "
                        + ex + ":" + ex.Message,
                        "Error loading file",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Error) == DialogResult.Yes)
                {
                    toLoad  = xcCustom.LoadFile(path, fName, 0, 0);
                    recover = true;
                }
            }
#endif
                if (!recover && toLoad != null)
                {
                    SetImages(toLoad);
                    UpdateText();
                }
            }
        }