Ejemplo n.º 1
0
        private void ExportBytes(CVariable editvar)
        {
            var dlg = new SaveFileDialog();

            byte[] bytes = null;

            if (editvar is IByteSource)
            {
                bytes = ((IByteSource)editvar).Bytes;
            }

            dlg.Filter           = string.Join("|", ImportExportUtility.GetPossibleExtensions(bytes));
            dlg.InitialDirectory = Get().Configuration.InitialExportDirectory;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Get().Configuration.InitialExportDirectory = Path.GetDirectoryName(dlg.FileName);

                using (var fs = new FileStream(dlg.FileName, FileMode.Create, FileAccess.Write))
                {
                    using (var writer = new BinaryWriter(fs))
                    {
                        bytes = ImportExportUtility.GetExportBytes(bytes, Path.GetExtension(dlg.FileName));
                        writer.Write(bytes);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void ImportBytes(CVariable editvar)
        {
            var dlg = new OpenFileDialog()
            {
                InitialDirectory = MainController.Get().Configuration.InitialExportDirectory
            };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                MainController.Get().Configuration.InitialExportDirectory = Path.GetDirectoryName(dlg.FileName);

                using (var fs = new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read))
                {
                    using (var reader = new BinaryReader(fs))
                    {
                        var bytes = ImportExportUtility.GetImportBytes(reader);
                        editvar.SetValue(bytes);

                        MainController.LogString(
                            $"{((CVariable) editvar).GetFullDependencyStringName()} succesfully imported from {dlg.FileName}",
                            Logtype.Success);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void ImportBytes(CVariable editvar)
        {
            var dlg = new OpenFileDialog()
            {
                InitialDirectory = Get().Configuration.InitialExportDirectory
            };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Get().Configuration.InitialExportDirectory = Path.GetDirectoryName(dlg.FileName);

                using (var fs = new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read))
                {
                    using (var reader = new BinaryReader(fs))
                    {
                        var bytes = ImportExportUtility.GetImportBytes(reader);
                        editvar.SetValue(bytes);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void ExportBytes(IByteSource editvar)
        {
            var dlg   = new SaveFileDialog();
            var bytes = editvar.GetBytes();

            dlg.Filter           = string.Join("|", ImportExportUtility.GetPossibleExtensions(bytes, (CVariable)editvar));
            dlg.InitialDirectory = MainController.Get().Configuration.InitialExportDirectory;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                MainController.Get().Configuration.InitialExportDirectory = Path.GetDirectoryName(dlg.FileName);

                using (var fs = new FileStream(dlg.FileName, FileMode.Create, FileAccess.Write))
                    using (var writer = new BinaryWriter(fs))
                    {
                        bytes = ImportExportUtility.GetExportBytes(bytes, Path.GetExtension(dlg.FileName), (CVariable)editvar);
                        writer.Write(bytes);

                        MainController.LogString(
                            $"{((CVariable) editvar).GetFullDependencyStringName()} succesfully exported to {dlg.FileName}",
                            Logtype.Success);
                    }
            }
        }