예제 #1
0
        public void Open(string path)
        {
            using (Stream stream = new FileStream(path, FileMode.Open))
            {
                BinaryReader reader = new BinaryReader(stream);

                int    version = reader.ReadInt32();
                string guid    = reader.ReadString();

                RegisteredTemplates.Template template = RegisteredTemplates.Instance.FindTemplate(guid);

                if (template == null)
                {
                    MessageBox.Info(string.Format("Template {0} is not registered.", guid));
                    return;
                }

                if (template.Path.IsNullOrEmpty())
                {
                    using (Stream templateStream = ContentLoader.Current.Open("Templates/SampleTemplate.zip"))
                    {
                        CurrentTemplate.Instance.Load(templateStream);
                    }
                }
                else
                {
                    using (Stream templateStream = new FileStream(template.Path, FileMode.Open))
                    {
                        CurrentTemplate.Instance.Load(templateStream);
                    }
                }

                New();
                Layers.Clear();

                ReadVersion1(reader);

                _layerIndex = Layers.Count + 1;
                Layers[Layers.Count - 1].Selected.Value = true;
            }

            FilePath = path;
            FileName = Path.GetFileNameWithoutExtension(path);
        }
예제 #2
0
 public void NewFromTemplate(RegisteredTemplates.Template template)
 {
     FileMenuController.Current.OnNew(template.Path);
     Close();
 }