Ejemplo n.º 1
0
        public static void SaveFilterset(string Path, Filterset fst)
        {
            try
            {
                FileStream   str    = new FileStream(Path, FileMode.Create);
                BinaryWriter writer = new BinaryWriter(str);

                writer.Write(fst.Name);
                writer.Write(fst.HasReferenceImage);
                if (fst.HasReferenceImage)
                {
                    writer.Write(fst.ReferenceImage);
                }
                writer.Write(fst.FilterImages.Count);
                for (int i = 0; i < fst.FilterImages.Count; i++)
                {
                    writer.Write(fst.FilterImages[i]);
                    writer.Write(fst.WBJumps[i]);
                    writer.Write(fst.TintJumps[i]);
                    writer.Write(fst.EVJumps[i]);
                }

                writer.Close();
                str.Close();
            }
            catch (Exception ex) { ErrorReport.ReportError("Save Filterset", ex); }
        }
Ejemplo n.º 2
0
        public static Filterset OpenFilterset(string Path)
        {
            try
            {
                if (File.Exists(Path))
                {
                    Filterset fst = new Filterset(Path);

                    FileStream stream = new FileStream(Path, FileMode.Open);
                    BinaryReader reader = new BinaryReader(stream);

                    fst.Path = Path;

                    fst.Name = reader.ReadString();
                    if (reader.ReadBoolean()) { fst.AddReferenceImage(reader.ReadString()); }
                    int count = reader.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        fst.SetWBJump(i, reader.ReadInt32());
                        fst.SetTintJump(i, reader.ReadDouble());
                        fst.SetEVJump(i, reader.ReadDouble());
                    }

                    reader.Close();
                    stream.Close();

                    return new Filterset(Path);
                }
                else { return null; }
            }
            catch (Exception ex) { ErrorReport.ReportError("Open Filterset", ex); return null; }
        }
        protected void OnSaveButtonClicked(object sender, EventArgs e)
        {
            try
            {
                FileChooserDialog fc = new FileChooserDialog("Save Filterset", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);

                FileFilter filter = new FileFilter();
                filter.Name = "DeSERt Filterset";
                filter.AddMimeType("Filterset/fis");
                filter.AddPattern("*.fis");
                fc.AddFilter(filter);
                fc.DoOverwriteConfirmation = true;
                fc.CurrentName             = FiltersetnameEntry.Text.Replace(" ", "-");
                if (Directory.Exists(MySettings.LastFilterDir))
                {
                    fc.SetCurrentFolder(MySettings.LastFilterDir);
                }

                ResponseType res = (ResponseType)fc.Run();
                if (res == ResponseType.Ok || res == ResponseType.Close)
                {
                    string path;
                    if (!System.IO.Path.HasExtension(fc.Filename))
                    {
                        path = fc.Filename + ".fis";
                    }
                    else
                    {
                        path = fc.Filename;
                    }
                    MySettings.LastFilterDir = System.IO.Path.GetDirectoryName(fc.Filename);
                    MySettings.Save();
                    fst.Name = FiltersetnameEntry.Text;
                    Filterset.SaveFilterset(path, fst);
                    saved = true;
                }
                fc.Destroy();
                if (res == ResponseType.Close)
                {
                    this.Destroy();
                }
            }
            catch (Exception ex) { ErrorReport.ReportError("Save Button (Create Filterset)", ex); }
        }
Ejemplo n.º 4
0
        public static Filterset OpenFilterset(string Path)
        {
            try
            {
                if (File.Exists(Path))
                {
                    Filterset fst = new Filterset(Path);

                    FileStream   stream = new FileStream(Path, FileMode.Open);
                    BinaryReader reader = new BinaryReader(stream);

                    fst.Path = Path;

                    fst.Name = reader.ReadString();
                    if (reader.ReadBoolean())
                    {
                        fst.AddReferenceImage(reader.ReadString());
                    }
                    int count = reader.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        fst.SetWBJump(i, reader.ReadInt32());
                        fst.SetTintJump(i, reader.ReadDouble());
                        fst.SetEVJump(i, reader.ReadDouble());
                    }

                    reader.Close();
                    stream.Close();

                    return(new Filterset(Path));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex) { ErrorReport.ReportError("Open Filterset", ex); return(null); }
        }
Ejemplo n.º 5
0
        public static void SaveFilterset(string Path, Filterset fst)
        {
            try
            {
                FileStream str = new FileStream(Path, FileMode.Create);
                BinaryWriter writer = new BinaryWriter(str);

                writer.Write(fst.Name);
                writer.Write(fst.HasReferenceImage);
                if (fst.HasReferenceImage) { writer.Write(fst.ReferenceImage); }
                writer.Write(fst.FilterImages.Count);
                for (int i = 0; i < fst.FilterImages.Count; i++)
                {
                    writer.Write(fst.FilterImages[i]);
                    writer.Write(fst.WBJumps[i]);
                    writer.Write(fst.TintJumps[i]);
                    writer.Write(fst.EVJumps[i]);
                }

                writer.Close();
                str.Close();
            }
            catch (Exception ex) { ErrorReport.ReportError("Save Filterset", ex); }
        }