Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();
            Package = new AMTPackage();
            bool result = AMTUtil.OpenPackage(Package, AMTUtil.GetAbsPath(Directory.GetCurrentDirectory(), "AMT.apkg"));

            if (result)
            {
                //Set current action
                Default        = new AMTActionPlayer(Package.Animation, AMTUtil.GetDefaultAction(Package.Animation));
                CurrentAction  = Default;
                Timer          = new DispatcherTimer();
                Timer.Interval = TimeSpan.FromMilliseconds(10);
                Timer.Tick    += Timer_Tick;
                Timer.Start();
                this.MouseDoubleClick += MainWindow_MouseDoubleClick;
                MEAudio.Play();
            }
            else
            {
                this.Close();
                System.Environment.Exit(0);
            }
            this.MouseDown += Window_MouseDown;
        }
Beispiel #2
0
        private string ArcPreProcessor(string FilePath)
        {
            SevenZipExtractor.SetLibraryPath(@"C:\Program Files (x86)\7-Zip\7z.dll");
            var tmp = new SevenZipExtractor(FilePath);

            tmp.ExtractArchive(WorkingDir);
            return(AMTUtil.GetAbsPath(WorkingDir, Path.GetFileNameWithoutExtension(FilePath) + AMTConfig.ResourceExtension));
        }
Beispiel #3
0
        private void ArcPostProcessor(string FilePath)
        {
            SevenZipExtractor.SetLibraryPath(@"C:\Program Files (x86)\7-Zip\7z.dll");
            var    tmp      = new SevenZipCompressor();
            string PostFile = AMTUtil.GetAbsPath(WorkingDir, CurrentResource.Name + AMTConfig.ResourcePostExtension);

            tmp.CompressFiles(PostFile, FilePath);
            File.Delete(FilePath);
        }
Beispiel #4
0
 private bool SaveCurrentResource()
 {
     try
     {
         File.WriteAllText(AMTUtil.GetAbsPath(WorkingDir, CurrentResource.Name + AMTConfig.ResourceExtension), JsonConvert.SerializeObject(CurrentResource));
         ArcPostProcessor(AMTUtil.GetAbsPath(WorkingDir, CurrentResource.Name + AMTConfig.ResourceExtension));
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Beispiel #5
0
        public bool SavePackage()
        {
            AMTResource resourceBk = this.CurrentResource;

            try
            {
                this.CurrentResource = null;
                File.WriteAllText(AMTUtil.GetAbsPath(WorkingDir, "AMT.apkg"), JsonConvert.SerializeObject(this));
            }
            catch
            {
                return(false);
            }
            this.CurrentResource = resourceBk;
            return(true);
        }
Beispiel #6
0
 public bool SwitchResource(string ResourceName)
 {
     if (CurrentResource != null)
     {
         if (ResourceName == CurrentResource.Name)
         {
             return(true);
         }
     }
     ResourceName = AMTUtil.GetAbsPath(WorkingDir, ResourceName + AMTConfig.ResourceExtension);
     try
     {
         CurrentResource = (AMTResource)JsonConvert.DeserializeObject <AMTResource>(File.ReadAllText(ResourceName));
     }
     catch
     {
         return(false);
     }
     return(true);
 }