private bool CreateLoadAnimation(Grid gridName) { loadedControl = new LoadingAnimation(); loadedControl.LoadAnimationElement.Height = 70; loadedControl.LoadAnimationElement.Width = 70; loadedControl.LoadAnimationElement.RingsThickness = 3; gridName.Children.Add(loadedControl); Grid.SetColumnSpan(loadedControl, 3); Grid.SetRowSpan(loadedControl, 2); return(loadedControl.StartAnimation()); }
public SettingsPage(MainWindow mainWindow) { InitializeComponent(); _mWindow = mainWindow; loadedControl = new LoadingAnimation(); MainSheldueGrid.Children.Add(loadedControl); loadedControl.StartAnimation(); _mWindow.KindThrowMessage.Foreground = FindResource("WarningForegroundColorUIElements") as SolidColorBrush; _mWindow.KindThrowMessage.Kind = MaterialDesignThemes.Wpf.PackIconKind.WarningOutline; _mWindow.TextBlockMessageThrow.Text = "Изменение к расписанию загружается! Не закрывайте программу!"; Storyboard sb = _mWindow.FindResource("ShowMessageThrowGrid") as Storyboard; sb.Begin(); Task.Run(() => this.Dispatcher.BeginInvoke((ThreadStart) delegate() { LoadSheldueAsyncMethod(); })); }
public HomePage(MainWindow mWindow) { InitializeComponent(); _mWindow = mWindow; ReferenseDALClass refClassDAL = new ReferenseDALClass(); loadedControl = new LoadingAnimation(); MainSheldueGrid.Children.Add(loadedControl); loadedControl.StartAnimation(); allSheldueList = _mWindow.GetSheldue; if (allSheldueList == null) { userNotes = new List <UserNotes>(refClassDAL.SetConnectionDBSelectAll(_mWindow._userInfo.ID)); _mWindow.KindThrowMessage.Foreground = FindResource("WarningForegroundColorUIElements") as SolidColorBrush; _mWindow.KindThrowMessage.Kind = MaterialDesignThemes.Wpf.PackIconKind.WarningOutline; _mWindow.TextBlockMessageThrow.Text = "Расписание загружается! Не закрывайте программу!"; Storyboard sb = _mWindow.FindResource("ShowMessageThrowGrid") as Storyboard; sb.Begin(); _mWindow.IsEnabled = false; switch (_mWindow._userInfo.Status) { case teacher: Task.Run(() => this.Dispatcher.BeginInvoke((ThreadStart) delegate() { LoadSheldueAsyncMethod(false); })); break; case student: Task.Run(() => this.Dispatcher.BeginInvoke((ThreadStart) delegate() { LoadSheldueAsyncMethod(true); })); break; } } else { ListViewSheldueDay.ItemsSource = allSheldueList; StopAnimation.Tick += new EventHandler(StopMethodAnimation); StopAnimation.Interval = new TimeSpan(0, 0, 1); StopAnimation.Start(); } DateTime firstDate = GetFirstDateOfWeek(DayOfWeek.Monday); var lastDate = GetLastDateOfWeek(DayOfWeek.Saturday); GetListDateOfWeek(firstDate, lastDate); refClassDAL.SetConnectionDBDeleteNote(listDate[0]); }
public void ExcecuteBuild(string[] args) { string path = args[0]; List <Task <string[]> > tasks = new List <Task <string[]> >() { Task.Run(() => Directory.GetFiles(path, "*.png", SearchOption.AllDirectories)), Task.Run(() => Directory.GetFiles(path, "*.wav", SearchOption.AllDirectories)), Task.Run(() => Directory.GetFiles(path, "*.scene", SearchOption.AllDirectories)), Task.Run(() => Directory.GetFiles(path, "*.prefab", SearchOption.AllDirectories)), Task.Run(() => Directory.GetFiles(path, "*.anim", SearchOption.AllDirectories)), Task.Run(() => Directory.GetFiles(path, "*.glsl", SearchOption.AllDirectories)) }; if (args.Length > 2) { foreach (var fileExtention in args[2].Split(":")) { tasks.Add(Task.Run(() => Directory.GetFiles(path, "*." + fileExtention.Replace(".", ""), SearchOption.AllDirectories))); } } var loadingTask = Task.WhenAll(tasks); Console.WriteLine($"Getting Files in: {path}"); Console.WriteLine($"{tasks.Count} loading tasks initilized..."); LoadingAnimation.StartAnimation($"Finding Files"); while (!loadingTask.IsCompleted) { if (loadingTask.IsFaulted) { throw loadingTask.Exception; } Thread.Sleep(10); LoadingAnimation.WriteAnimation(); } LoadingAnimation.EndAnimation(); var result = loadingTask.Result; if (result is null) { throw new NullReferenceException("Result was null."); } ResourceData data = new ResourceData(); foreach (string[] type in result) { Console.WriteLine("Task Entries: " + type.Length); foreach (string asset in type) { var name = Path.GetFileNameWithoutExtension(asset); switch (Path.GetExtension(asset).ToLower()) { case ".png": byte[] rawData; using (MemoryStream ms = new MemoryStream()) { new Bitmap(asset).Save(ms, ImageFormat.Png); rawData = ms.ToArray(); } data.Textures.TryAdd(name, rawData); break; case ".wav": byte[] buff = null; using (FileStream fs = new FileStream(asset, FileMode.Open, FileAccess.Read)) { BinaryReader br = new BinaryReader(fs); long numBytes = new FileInfo(asset).Length; buff = br.ReadBytes((int)numBytes); data.AudioFiles.Add(name, buff); } break; default: var fileText = string.Empty; using (var sr = new StreamReader(asset, Encoding.UTF8)) { fileText = sr.ReadToEnd(); } data.Assets.TryAdd(name, fileText); break; } Console.WriteLine($"\tLoaded {name}."); } } Console.WriteLine($"\nLoaded {data.Count} files."); BinaryFormatter binaryFormatter = new BinaryFormatter(); var newFile = Path.Combine(args.Length > 1 ? args[1] : path, "resources.dat"); Console.WriteLine($"\nCreating {newFile}"); if (File.Exists(newFile)) { File.Delete(newFile); } FileStream fileStream = new FileStream(newFile, FileMode.OpenOrCreate); BinaryFormatter formatter = new BinaryFormatter(); try { using (GZipStream zipStream = new GZipStream(fileStream, CompressionMode.Compress, false)) { formatter.Serialize(zipStream, data); } } catch (SerializationException e) { Console.WriteLine("Failed to serialize. Reason: " + e.Message); throw; } finally { fileStream.Close(); Console.WriteLine($"Packaging Successful!"); } Console.WriteLine("Serlized data."); var color = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\tBuild Complete!"); Console.ForegroundColor = color; }