Exemplo 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));
 }
Exemplo n.º 2
0
 protected override XCom.XCImageCollection LoadFileOverride(
     string directory,
     string file,
     int imgWid,
     int imgHei,
     Palette pal)
 {
     return(codec.LoadFile(
                directory,
                file,
                imgWid,
                imgHei,
                pal));
 }
Exemplo n.º 3
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();
                }
            }
        }