示例#1
0
        private static void SaveData(Content content)
        {
            if (content == null)
            {
                throw new Exception("You passed the container's content before the content was assigned to the value");
            }


            try
            {
                if (content.imgData == null)
                {
                    return;
                }

                string dataFile = $"{content.cont.ID}.dat";
                string dataPath = Path.Combine(SavePath, dataFile);

                if (content.cont.CensorActive || content.cont.ScramblerActive)
                {
                    if (File.Exists(dataPath))
                    {
                        File.Delete(dataPath);
                    }
                }
                else
                {
                    content.imgData.Save(dataPath);
                }
            }
            catch (Exception ex) { Bugs.Exist(ex); } //bugs don't exist
        }
示例#2
0
 internal static void Restart()
 {
     try
     {
         Application.Restart();
     }
     catch (Exception ex) { Bugs.Exist(ex); } //bugs don't exist
 }
示例#3
0
        public ImageContent(Container _cont, byte[] data)
        {
            cont         = _cont;
            cont.content = this;

            cont.Hide();

            try
            {
                MemoryStream stream = new MemoryStream(data);
                imgData = Image.FromStream(stream);
                displayImage();
            }
            catch (Exception ex) { Bugs.Exist(ex); } //bugs don't exist
        }
示例#4
0
        public void Save(string metaFile)
        {
            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = null;

            try
            {
                stream = new FileStream(metaFile, FileMode.Create, FileAccess.Write, FileShare.None);
                formatter.Serialize(stream, this);
            }
            catch (Exception ex) { Bugs.Exist(ex); } //bugs don't exist
            finally
            {
                stream?.Close();
            }
        }
示例#5
0
        public ImageContent(Container _cont, string path)
        {
            cont         = _cont;
            cont.content = this;

            cont.Hide();

            try
            {
                Image img = Image.FromFile(path);

                imgData = img;
                displayImage();
            }
            catch (Exception ex) { Bugs.Exist(ex); } //bugs don't exist
        }
示例#6
0
        public static SaveMeta Load(string metaFile)
        {
            SaveMeta sm = null;

            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = null;

            try
            {
                stream = new FileStream(metaFile, FileMode.Open);
                sm     = (SaveMeta)formatter.Deserialize(stream);
            }
            catch (Exception ex) { Bugs.Exist(ex); } //bugs don't exist
            finally
            {
                stream?.Close();
            }

            return(sm);
        }
示例#7
0
        public void CloseAllScramblers()
        {
            List <Container> unregister = new List <Container>();

            foreach (var scrm in containers.Where(it => it.content != null && (it.content is ScramblerContent || it.content is ScramblerTargetContent)))
            {
                unregister.Add(scrm);
            }

            foreach (var scrm in unregister)
            {
                try
                {
                    (scrm.content as ScramblerContent)?.ScramblerTimer.Stop();
                    scrm.Close();
                    containers.Remove(scrm);
                    scrm.Dispose();
                }
                catch (Exception ex) { Bugs.Exist(ex); } //bugs don't exist
            }
        }
示例#8
0
        private static void LoadData(string dataPath, Container cont)
        {
            try
            {
                //var img = Image.FromFile(dataPath);

                Image img;
                using (var bmpTemp = new Bitmap(dataPath))
                {
                    img = new Bitmap(bmpTemp);
                }

                if (img == null)
                {
                    return;
                }

                cont.LoadImage(img, true);
            }
            catch (Exception ex) { Bugs.Exist(ex); } //bugs don't exist
        }
示例#9
0
        public static void Reset()
        {
            foreach (var cont in Main.containers)
            {
                string metaFile = $"{cont.ID}.meta";
                string metaPath = Path.Combine(SavePath, metaFile);

                string dataFile = $"{cont.ID}.dat";
                string dataPath = Path.Combine(SavePath, dataFile);

                cont.Close();

                if (cont != null && !cont.IsDisposed)
                {
                    cont.Dispose();
                }

                if (File.Exists(metaPath))
                {
                    File.Delete(metaPath);
                }

                if (File.Exists(dataPath))
                {
                    File.Delete(dataPath);
                }
            }

            foreach (var file in SaveDi.GetFiles())
            {
                try
                {
                    file.Delete();
                }
                catch (Exception ex) { Bugs.Exist(ex); } //bugs don't exist
            }
            Main.Restart();
        }