コード例 #1
0
 private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     try
     {
         var dlg = new CrashDialog();
         dlg.Exception = e.Exception;
         dlg.SaveLog();
         dlg.ShowDialog();
     }
     catch
     {
         foreach (var project in Data.ApplicationSettings.Instance.Projects)
         {
             project.ProjectPath = project.ProjectPath + ".autosave";
             project.Save();
         }
     }
 }
コード例 #2
0
        private async void CrashDialog_Loaded(object sender, RoutedEventArgs e)
        {
            CrashInfo.Text = crash.Message + '\n' + "Error Code:" + crash.HResult.ToHexString();
            CrashDialog.PrimaryButtonClick += async(m, v) =>
            {
                try
                {
                    var crashLOG = await FileIOHelper.AppendLogtoCacheAsync(crash, Guid.NewGuid().ToString());

                    if (!ReportBox.Text.IsNullorEmpty())
                    {
                        await FileIO.AppendTextAsync(crashLOG, "User Voice = " + ReportBox.Text + Environment.NewLine);
                    }
                    if (!EmailBox.Text.IsNullorEmpty())
                    {
                        if (new EmailAddressAttribute().IsValid(EmailBox.Text))
                        {
                            await FileIO.AppendTextAsync(crashLOG, "Email = " + EmailBox.Text + Environment.NewLine);
                        }
                    }
                    var fileBytes = await FileIOHelper.GetBytesAsync(crashLOG);

                    WebHelper.UploadFilesToServer(new Uri(Utils.UPLOAD_CRASH), null, crashLOG.Name, "application/octet-stream", fileBytes);
                }
                catch (Exception)
                {
                    CrashDialog.PrimaryButtonText = "Failed";
                    await CrashDialog.ShowAsync();
                }
            };
            CrashDialog.SecondaryButtonClick += (a, q) =>
            {
                Application.Current.Exit();
            };
            await CrashDialog.ShowAsync();
        }
コード例 #3
0
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="path"></param>
        /// <param name="backup"></param>
        public static void Save(string path, bool backup)
        {
            if (m_Shader == null || !m_Changed)
            {
                return; //not even loaded...
            }
            if (!backup)
            {
                m_Changed = false;
            }
            bool changed = false;

            #region patchmaps

            Loading.Update("Saving " + Path.GetFileName(path) + " - Patchmaps");
            foreach (PatchMapInfo pi in m_PatchInfos)
            {
                if (!pi.Changed)
                {
                    continue;
                }
                pi.Exists = true;
                changed   = true;

                if (!backup)
                {
                    pi.Changed = false;
                }

                for (int i = 0; i < COUNT; i++)
                {
                    if (pi.Patch[i] != null)
                    {
                        Texture p  = pi.Patch[i];
                        string  pp = path + string.Format("patch{0:D2}{1:D2}-{2:D2}.dds", pi.X, pi.Y, i);
                        TextureLoader.Save(pp, ImageFileFormat.Dds, p);

                        //Mips
                        try {
                            using (
                                Texture mip = TextureLoader.FromFile(p.Device, pp, 0, 0, 0, Usage.Dynamic, Format.A8R8G8B8, Pool.Default,
                                                                     Filter.Linear, Filter.Linear, 0)) {
                                //mip.GenerateMipSubLevels();
                                TextureLoader.Save(pp, ImageFileFormat.Dds, mip);
                                mip.Dispose();
                            }
                        }
                        catch (Exception ex) {
                            CrashDialog.Show(ex);
                        }
                    }
                }
            }

            #endregion

            #region textures.csv

            if (changed)
            {
                Loading.Update("Saving " + Path.GetFileName(path) + "... - textures.csv");

                var w = new StreamWriter(string.Format("{0}textures.csv", path), false);
                w.WriteLine(
                    "patch x,patch y,base texture filename,rotate,u translate,v translate,u scale,v scale,visible,num tiles,tileable,normal map filename,specular tint color,specular power,mask type,mask window size");
                w.WriteLine();

                for (int y = 0; y < m_PatchInfos.GetLength(1); y++)
                {
                    for (int x = 0; x < m_PatchInfos.GetLength(0); x++)
                    {
                        PatchMapInfo i = m_PatchInfos[x, y];

                        const string format = "{0},{1},{2},0.00,0.00,0.00,1.00,1.00,1,{3},{4},,0,32.0,0,16";

                        for (int j = 0; j < COUNT; j++)
                        {
                            if (i.Patch[j] != null)
                            {
                                w.WriteLine(string.Format(format,
                                                          x, y, Path.GetFileNameWithoutExtension(TerrainTex.Get(i.R[j])),
                                                          i.RTiles[j], i.RTiles[j] > 1 ? "1" : "0"));
                                w.WriteLine(string.Format(format,
                                                          x, y, Path.GetFileNameWithoutExtension(TerrainTex.Get(i.G[j])),
                                                          i.GTiles[j], i.GTiles[j] > 1 ? "1" : "0"));
                                w.WriteLine(string.Format(format,
                                                          x, y, Path.GetFileNameWithoutExtension(TerrainTex.Get(i.B[j])),
                                                          i.BTiles[j], i.BTiles[j] > 1 ? "1" : "0"));
                                w.WriteLine();
                            }
                        }
                    }
                }

                w.Flush();
                w.Close();
            }

            #endregion
        }