예제 #1
0
        public void doSaveAnimGif(string filename, object sender, DoWorkEventArgs args)
        {
            FileStream fs = new FileStream(filename + ".gif", FileMode.OpenOrCreate);

            using (var stream = new MemoryStream())
            {
                using (var encoder = new GifEncoder(stream, null, null, 12))
                {
                    for (int i = 0; i < SharedSettings.Layers.Length; i++)
                    {
                        var image = (Image)(SharedSettings.Layers[i] as Bitmap).Clone();
                        encoder.AddFrame(image, 0, 0, TimeSpan.FromSeconds(0));
                    }

                    stream.Position = 0;
                    stream.WriteTo(fs);
                }
            }
            fs.Close();

            try
            {
                GoogleDriveUpload.DriveUpload(filename + ".gif");
                string message = SharedSettings.getGlobalString("projectsave_saved");
                MessageBox.Show(new Form()
                {
                    WindowState = FormWindowState.Maximized, TopMost = true
                }, message);
            }
            catch (Exception e)
            {
                MessageBox.Show(new Form()
                {
                    WindowState = FormWindowState.Maximized, TopMost = true
                }, SharedSettings.getGlobalString("gdrivesavedialog_error") + e.Message);
            }
            try
            {
                System.IO.File.Delete(filename + ".gif");
            }
            catch (Exception e)
            {
                Console.WriteLine("Problem deleting temp gif file: " + e.Message);
            }
        }
예제 #2
0
        public void doSave(Bitmap bm, string filename, string filetype, object sender, DoWorkEventArgs args)
        {
            try
            {
                Canvas.handleWatermark(Graphics.FromImage(bm));

                string      ext = ".png";
                ImageFormat fmt = ImageFormat.Png;
                switch (filetype)
                {
                case ("Jpeg | *.jpg"):
                    ext = ".jpg";
                    fmt = ImageFormat.Jpeg;
                    break;

                case ("PNG | *.png"):
                    // don't need to change anything
                    break;

                case ("GIF | *.gif"):
                    ext = ".gif";
                    fmt = ImageFormat.Gif;
                    break;

                case ("ICON | *.ico"):
                    ext = ".ico";
                    fmt = ImageFormat.Icon;
                    break;

                case ("TIFF | *.tiff"):
                    ext = ".tiff";
                    fmt = ImageFormat.Tiff;
                    break;

                case ("Bitmap | *.bmp"):
                    ext = ".bmp";
                    fmt = ImageFormat.Bmp;
                    break;

                default:
                    // on error, default to png
                    break;
                }

                bm.Save(filename + ext, fmt);

                GoogleDriveUpload.DriveUpload(filename + ext);

                string message = SharedSettings.getGlobalString("projectsave_saved");
                MessageBox.Show(new Form()
                {
                    WindowState = FormWindowState.Maximized, TopMost = true
                }, message);

                System.IO.File.Delete(filename + ext);
            }
            catch (Exception e)
            {
                MessageBox.Show(new Form()
                {
                    WindowState = FormWindowState.Maximized, TopMost = true
                }, SharedSettings.getGlobalString("gdrivesavedialog_error") + e.Message);
            }
        }
예제 #3
0
        public void doSaveProject(SharedSettings ss, string filename, object sender, DoWorkEventArgs args)
        {
            try
            {
                System.IO.Directory.CreateDirectory("save");

                Bitmap[] bitArr     = ss.getLayerBitmaps();
                string   baseDir    = System.IO.Directory.GetCurrentDirectory();
                string[] LayerNames = ss.getLayerNames();

                for (int n = 0; n < bitArr.Length; n++)
                {
                    bitArr[n].Save(baseDir + "\\save\\" + LayerNames[n] + ".png", ImageFormat.Png);
                }

                System.IO.File.WriteAllLines(baseDir + @"\save\names.txt", LayerNames);

                if (SharedSettings.bitmapWatermark != null)
                {
                    System.IO.Directory.CreateDirectory("save\\watermark");
                    SharedSettings.bitmapWatermark.Save("save\\watermark\\watermark.png", ImageFormat.Png);
                    string[] watermarkInfo = { SharedSettings.bRenderWatermark.ToString(), SharedSettings.watermarkStyle };
                    System.IO.File.WriteAllLines(baseDir + @"\\save\\watermark\\watermarkdata.txt", watermarkInfo);
                }

                if (System.IO.File.Exists(filename + ".lep"))
                {
                    System.IO.File.Delete(filename + ".lep");
                }

                ZipFile.CreateFromDirectory(baseDir + @"\save", filename + ".lep");

                System.IO.Directory.Delete(baseDir + @"\save", true);
            }
            catch (Exception e)
            {
                string message = SharedSettings.getGlobalString("projectsave_error") + "\n\n" + e.ToString();
                MessageBox.Show(new Form()
                {
                    WindowState = FormWindowState.Maximized, TopMost = true
                }, message);
            }

            try
            {
                GoogleDriveUpload.DriveUpload(filename + ".lep");
                string message = SharedSettings.getGlobalString("projectsave_saved");
                MessageBox.Show(new Form()
                {
                    WindowState = FormWindowState.Maximized, TopMost = true
                }, message);
            }
            catch (Exception e)
            {
                MessageBox.Show(new Form()
                {
                    WindowState = FormWindowState.Maximized, TopMost = true
                }, SharedSettings.getGlobalString("gdrivesavedialog_error") + e.Message);
            }
            try
            {
                System.IO.File.Delete(filename + ".lep");
            }
            catch (Exception e)
            {
                Console.WriteLine("Problem deleting temp lep file: " + e.Message);
            }
        }