private void GetNameActivityAndTitleApplication() { foundList = new Dictionary <string, string>(); stopwatch = new Stopwatch(); titleApplication = ActiveApplication_db.GetNameApplicationDictionary(); namesActivity = NameActivity_db.GetNameActivityDictionary(); }
private void applyFilterButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Regex regex = new Regex(contentsOfFilter.Text, RegexOptions.IgnoreCase); Dictionary <string, string> namesApplication = ActiveApplication_db.GetNameApplicationDictionaryWithoutGroup(); List <int> idApplicationFiltered = new List <int>(); int count = 0; foreach (KeyValuePair <string, string> name in namesApplication) { if (regex.Matches(name.Value).Count > 0) { idApplicationFiltered.Add(Convert.ToInt32(name.Key)); count++; } } if (idApplicationFiltered.Count > 0) { if (ActiveApplication_db.AddGroupToApplications(idApplicationFiltered, selectGroupId.ToString())) { resultsApplyFilter.SetContent("Znaleziono " + count + " element" + ((count == 1) ? "" : "ów.")); } else { resultsApplyFilter.SetContent("Wystąpił błąd z filtrem."); } } else { resultsApplyFilter.SetContent("Znaleziono " + count + " element" + ((count == 1) ? "" : "ów.")); } resultsApplyFilter.Visibility = System.Windows.Visibility.Visible; }
private void DeleteAllApplicationFromActivity() { if (ActiveApplication_db.DeleteAllApplicationsWithActivity(viewActivityID)) { Update(); } }
private void DeleteOneApplicationFromActivity() { if (ActiveApplication_db.DeleteOneApplicationWithGroup(deleteApplicationID)) { checkRemovedActivity.Fill = new SolidColorBrush(Color.FromArgb(70, 200, 0, 0)); } }
private void LoadNonAssignedApplication() { List <ActiveApplication> titlesAllNotAssignedApplication = ActiveApplication_db.GetNonJoinedApplication(); for (int i = 0; i < titlesAllNotAssignedApplication.Count; i++) { Thread.Sleep(10); Application.Current.Dispatcher.Invoke(() => { applicationWithoutGroup = new Canvas(); applicationWithoutGroup = CanvasCreator.CreateCanvas(applicationsWithoutGroup, 560, 60, Color.FromArgb(0, 110, 0, 0), 0, 59 * i); }); string titleApplication = string.Empty; titleApplication = (titlesAllNotAssignedApplication[i].Title.Length > 40) ? titlesAllNotAssignedApplication[i].Title.Remove(40, titlesAllNotAssignedApplication[i].Title.Length - 40) : titlesAllNotAssignedApplication[i].Title; Application.Current.Dispatcher.Invoke(() => { new MyCircle(applicationWithoutGroup, 46, 2, Color.FromArgb(255, 150, 150, 150), 8, 8, 1, true); MyLabel l = new MyLabel(applicationWithoutGroup, "\t" + titleApplication, 560, 60, 14, 0, 0, Color.FromArgb(255, 120, 120, 120), Color.FromArgb(30, 100, 100, 100), 1, HorizontalAlignment.Left, fontWeight: FontWeights.Bold); l.ToolTip(titlesAllNotAssignedApplication[i].Title); new MyLabel(applicationWithoutGroup, ActionOnString.GetFirstLetterFromString(titleApplication), 50, 50, 20, 6, 11, Color.FromArgb(255, 240, 240, 240), Color.FromArgb(0, 100, 100, 100), 0, HorizontalAlignment.Center, fontWeight: FontWeights.ExtraBold); new MyLabel(applicationWithoutGroup, titlesAllNotAssignedApplication[i].NameActivity, 300, 30, 12, 60, 30, Color.FromArgb(255, 120, 120, 120), Color.FromArgb(30, 100, 100, 100), horizontalAlignment: HorizontalAlignment.Left); new MyLabel(applicationWithoutGroup, ActionOnTime.GetNumberDayAgo(titlesAllNotAssignedApplication[i].Date), 100, 30, 13, 466, 0, Color.FromArgb(255, 120, 120, 120), Color.FromArgb(30, 100, 100, 100), horizontalAlignment: HorizontalAlignment.Left); new MyLabel(applicationWithoutGroup, "(" + (titlesAllNotAssignedApplication.Count - i) + ")", 100, 30, 9, 420, 0, Color.FromArgb(255, 120, 120, 120), Color.FromArgb(30, 100, 100, 100), horizontalAlignment: HorizontalAlignment.Left); new MyCircle(applicationWithoutGroup, 25, 1, (Color.FromArgb(255, 0, 123, 255)), 525, 28, setFill: true); Label buttonAddActivity = ButtonCreator.CreateButton(applicationWithoutGroup, "+", 25, 34, 20, 525, 28, Color.FromArgb(255, 255, 255, 255), Color.FromArgb(200, 255, 0, 0), 0, fontWeight: FontWeights.ExtraBold); buttonAddActivity.Margin = new Thickness(0, -8, 0, 0); applicationWithoutGroup.Name = "ID_" + titlesAllNotAssignedApplication[i].ID; buttonAddActivity.MouseLeftButtonDown += buttonAddActivity_MouseLeftButtonDown; applicationsWithoutGroup.Height += 59; }); } Application.Current.Dispatcher.Invoke(() => { applicationsWithoutGroup.Height = ((applicationsWithoutGroup.Height - 300) < 300) ? 300 : applicationsWithoutGroup.Height - 299; }); loadingWindow.notClose = false; Thread.Sleep(200); backgroundWorkerLoadingWindow.DoWork -= loadingWindow.Load; backgroundWorkerLoadingWindow.DoWork += loadingWindow.Close; backgroundWorkerLoadingWindow.RunWorkerAsync(); }
public void Update(string title) { if (!string.IsNullOrEmpty(title) && !string.Equals(title, "-")) { int idTitle = Convert.ToInt32(ActiveApplication_db.GetIdActivityByName(SqlValidator.Validate(title))); nameGroup.SetContent(ActiveApplication_db.GetNameGroupByIdTitle(idTitle)); nameActivity.SetContent(ActiveApplication_db.GetNameActivityByIdTitle(idTitle)); } }
private void DeleteGroup() { if (ActiveApplication_db.DeleteAllApplicationsWithGroup(activeGroupId)) { if (Membership_db.DeleteGroup(activeGroupId)) { contentCanvas.Children.Clear(); LoadGroups(); } } }
public WindowAddTo(Canvas parent, bool revert, AddTo addTo) { IsClosed = false; bool ifAdd = false; parentCanvas = parent; windowAddTo = addTo; if (parent.Tag is int) { idMembership = Convert.ToInt32(parent.Tag); } if (idMembership == 0) { idApplication = parent.Name.Replace("ID_", ""); } timerAnimation = new DispatcherTimer(); timerAnimation.Interval = new TimeSpan(0, 0, 0, 0, 10); repeatIntervals = 0; if (windowAddTo == AddTo.Activity && idMembership == 0) { if (ActiveApplication_db.AddActivityToApplication(idApplication, "1")) { ifAdd = true; } } if (addTo == AddTo.Group) { if (ActiveApplication_db.AddGroupToApplication(idApplication, "NULL")) { ifAdd = true; } } if (windowAddTo == AddTo.Activity && idMembership > 0) { if (ActiveApplication_db.AddActivityToApplicationGroup(idMembership, "1")) { ifAdd = true; } } if (ifAdd) { ((Label)(parentCanvas.Children[7])).Content = "+"; Canvas.SetTop((Label)(parentCanvas.Children[7]), 28); timerAnimation.Tick += new EventHandler(AnimationButtonRestart); timerAnimation.Start(); } }
private void GetAllNotJoinedApplication() { string allNotJoinedApplicationString = ActiveApplication_db.GetAllNotJoinedApplication(); int allNotJoinedApplicationInt; if (int.TryParse(allNotJoinedApplicationString, out allNotJoinedApplicationInt)) { notJoinedApplications.SetContent(allNotJoinedApplicationInt.ToString()); SetColorLabel(allNotJoinedApplicationInt, notJoinedApplications); } else { notJoinedApplications.SetContent("-1"); } }
private void deleteApplicationWithFilterButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (selectGroupId != 0) { string count = ActiveApplication_db.GetAllAutoGroupingApplication(selectGroupId); if (ActiveApplication_db.DeleteAllApplicationsWithGroup(selectGroupId, true, true)) { resultsDeleteApplication.SetContent("Usunięto " + count + " element" + ((string.Equals(count, "1")) ? "" : "ów.")); } else { resultsDeleteApplication.SetContent("Wystąpił błąd podczas usuwania."); } resultsDeleteApplication.Visibility = System.Windows.Visibility.Visible; } }
private void findApplication_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if ((sender as Label).Name.Contains("M")) { idAddExceptionApplication = Convert.ToInt32((sender as Label).Name.Replace("ID_", string.Empty).Replace("M", string.Empty)); idAddExceptionApplicationList = ActiveApplication_db.GetNameApplicationDictionaryWithGroup(idAddExceptionApplication).Select(x => x.Key).ToList(); idAddExceptionApplication = -1; } else { idAddExceptionApplication = Convert.ToInt32((sender as Label).Name.Replace("ID_", string.Empty)); } searchApplicationCanvas.Children.Clear(); searchApplicationCanvas.Visibility = Visibility.Hidden; nameApplicationToException.Text = (sender as Label).Content.ToString(); }
private bool FindApplication() { if (nameApplicationToException.Text.Length > 2) { Regex regex = new Regex(nameApplicationToException.Text.Trim(), RegexOptions.IgnoreCase); Dictionary <string, string> titleApplication = ActiveApplication_db.GetNameApplicationDictionaryWithoutGroup(); Dictionary <string, string> titleMembership = Membership_db.GetNameGroupsDictionaryWithConfiguration(); Dictionary <string, string> titleFindApplication = new Dictionary <string, string>(); foreach (KeyValuePair <string, string> title in titleApplication) { if (regex.Matches(title.Value).Count > 0) { titleFindApplication[title.Key] = title.Value; } } foreach (KeyValuePair <string, string> title in titleMembership) { if (regex.Matches(title.Value).Count > 0) { titleFindApplication[title.Key + "M"] = title.Value; } } searchApplicationCanvas.Children.Clear(); searchApplicationCanvas.Height = 252; int nextIndex = 0; foreach (KeyValuePair <string, string> name in titleFindApplication) { Label application = ButtonCreator.CreateButton(searchApplicationCanvas, name.Value, 250, 29, 12, 20, 0 + (nextIndex * 32), Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 155, 155, 155), horizontalAlignment: HorizontalAlignment.Left); application.Background = new SolidColorBrush(Color.FromArgb(155, 0, 125, 255)); application.Name = "ID_" + name.Key; application.MouseEnter += buttonContent_MouseEnter; application.MouseLeave += buttonContent_MouseLeave; application.MouseLeftButtonDown += findApplication_MouseLeftButtonDown; searchApplicationCanvas.Height += 32; nextIndex++; } searchApplicationCanvas.Height = ((searchApplicationCanvas.Height - 252) < 252) ? 252 : searchApplicationCanvas.Height - 251; idAddExceptionApplication = 0; return(nextIndex > 0); } return(false); }
private void DeleteActivity() { if (ActiveApplication_db.DeleteAllApplicationsWithActivity(viewActivityID)) { if (NameActivity_db.DeleteActivity(namesActivity[index])) { namesActivity = NameActivity_db.GetNameActivityDictionary().Values.ToArray(); contentCanvas.Children.Remove(footerActivity[index]); footerActivity.RemoveAt(index); for (int i = index; i < footerActivity.Count; i++) { Canvas.SetLeft(footerActivity[i], Canvas.GetLeft(footerActivity[i]) - 120); } index = index - 1; Update(); } } }
private bool ActionOnBase(string idActivity) { if (windowAddTo == AddTo.Activity && idMembership == 0) { return(ActiveApplication_db.AddActivityToApplication(idApplication, idActivity)); } else if (windowAddTo == AddTo.Group) { return(ActiveApplication_db.AddGroupToApplication(idApplication, idActivity)); } if (windowAddTo == AddTo.Activity && idMembership > 0) { return(ActiveApplication_db.AddActivityToApplicationGroup(idMembership, idActivity)); } else { return(false); } }
public static void ChangeNameNonActiveWindow(string idNonActiveWindow, string newName) { if (!ActiveApplication_db.CheckIfExistTitle(SqlValidator.Validate(newName))) { string contentCommand = "INSERT INTO activeapplications (Title, IdNameActivity) VALUES ( " + SqlValidator.Validate(newName) + " , 1 )"; DataBase.ExecuteNonQuery(contentCommand); string newIDApplication = ActiveApplication_db.GetIdActivityByName(SqlValidator.Validate(newName)); new AllData_db().UpdateIDApplication(newIDApplication, idNonActiveWindow); DeleteNonActiveWindow(idNonActiveWindow); } else { string newIDApplication = ActiveApplication_db.GetIdActivityByName(SqlValidator.Validate(newName)); new AllData_db().UpdateIDApplication(newIDApplication, idNonActiveWindow); DeleteNonActiveWindow(idNonActiveWindow); } }
private void deleteExceptionButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if ((sender as Label).Name.Contains("M")) { idAddExceptionApplication = Convert.ToInt32((sender as Label).Name.Replace("ID_", string.Empty).Replace("M", string.Empty)); idAddExceptionApplicationList = ActiveApplication_db.GetNameApplicationDictionaryWithGroup(idAddExceptionApplication).Select(x => x.Key).ToList(); foreach (string element in idAddExceptionApplicationList) { ExceptionApplication_db.DeleteExceptionApplication(element); } } else { idAddExceptionApplication = Convert.ToInt32((sender as Label).Name.Replace("ID_", string.Empty)); ExceptionApplication_db.DeleteExceptionApplication(idAddExceptionApplication.ToString()); } idAddExceptionApplication = 0; idAddExceptionApplicationList.Clear(); LoadExceptionApplication(); }
private void UpdateListOfAddedApps() { CommandParameters parameters = new CommandParameters(); parameters.Name.Add(namesActivity[index]); List <ActiveApplication> activeApplication = ActiveApplication_db.GetActiveApplication(parameters); if (activeApplication.Count > 100) { activeApplication.RemoveRange(0, activeApplication.Count - 100); } applicationInActivity.Children.Clear(); string titleApplication = string.Empty; applicationInActivity.Height = 0; for (int i = 0; i < activeApplication.Count; i++) { titleApplication = (activeApplication[i].Title.Length > 16) ? activeApplication[i].Title.Remove(16, activeApplication[i].Title.Length - 16) : activeApplication[i].Title; MyLabel l = new MyLabel(applicationInActivity, titleApplication, 140, 30, 12, 0, 29 * i, Color.FromArgb(255, 155, 155, 155), Color.FromArgb(200, 255, 255, 255), 0, HorizontalAlignment.Left); l.ToolTip(activeApplication[i].Title); new MyRectangle(applicationInActivity, 140, 1, Color.FromArgb(30, 150, 150, 150), 0, 30 + (29 * i)); MyCircle circle = new MyCircle(applicationInActivity, 15, 1, (Color.FromArgb(155, 255, 93, 93)), 115, 8 + (29 * i), 1, true); Label buttonDeleteApplication = ButtonCreator.CreateButton(applicationInActivity, "x", 25, 25, 8, 110, 3 + (29 * i), Color.FromArgb(255, 255, 255, 255), Color.FromArgb(200, 255, 0, 0), 0, fontWeight: FontWeights.ExtraBold); buttonDeleteApplication.Background = new SolidColorBrush(Color.FromArgb(155, 236, 236, 236)); buttonDeleteApplication.MouseEnter += buttonDeleteApplication_MouseEnter; buttonDeleteApplication.MouseLeave += buttonDeleteApplication_MouseLeave; buttonDeleteApplication.MouseLeftButtonDown += buttonDeleteApplication_MouseLeftButtonDown; buttonDeleteApplication.Name = "ID_" + activeApplication[i].ID; ButtonCreator.SetToolTip(buttonDeleteApplication, "Usuń aplikacje z aktywności"); applicationInActivity.Height += 29; } applicationInActivity.Height = ((applicationInActivity.Height - 146) < 146) ? 146 : applicationInActivity.Height - 145; }
private void buttonChangeTreatAsOne_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (selectGroupId > 0) { if (treatAsOne.Visibility == System.Windows.Visibility.Hidden) { if (Membership_db.SetAsOneApplication(selectGroupId, true)) { ActiveApplication_db.DeleteNameActivityForIdMembership(selectGroupId); treatAsOne.Visibility = System.Windows.Visibility.Visible; (sender as Label).Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 155, 0)); } } else { if (Membership_db.SetAsOneApplication(selectGroupId, false)) { treatAsOne.Visibility = System.Windows.Visibility.Hidden; (sender as Label).Foreground = new SolidColorBrush(Color.FromArgb(255, 155, 155, 155)); } } } }
private void AddNameTitleToTableDailyUse() { string contentCommand = string.Empty; if (!ActiveApplication_db.CheckIfExistTitle(nameTitle)) { contentCommand = "INSERT INTO activeapplications (Title, IdNameActivity) VALUES ( " + nameTitle + " , " + 1 + " )"; DataBase.ExecuteNonQuery(contentCommand); } contentCommand = "INSERT INTO dailyuseofapplication (IdTitle, ActivityTime) " + "SELECT activeapplications.ID, 1 " + "FROM activeapplications WHERE activeapplications.Title = " + nameTitle; DataBase.ExecuteNonQuery(contentCommand); Dictionary <string, string> filters = Membership_db.GetFilterDictionaryIfIsFullConfiguration(); if (filters.Any()) { Regex regex; int idNameTitle = 0; foreach (KeyValuePair <string, string> filter in filters) { regex = new Regex(filter.Value, RegexOptions.IgnoreCase); if (regex.Matches(nameTitle).Count > 0) { idNameTitle = (Convert.ToInt32(ActiveApplication_db.GetIdActivityByName(nameTitle))); ActiveApplication_db.AddGroupToApplications(new List <int> { idNameTitle }, (filter.Key).ToString()); ActiveApplication_db.AddActivityToApplicationWithGroup((filter.Key).ToString(), idNameTitle.ToString()); ExceptionApplication_db.AddExceptionApplication(idNameTitle); } } } }
private void LoadContent(object sender, DoWorkEventArgs e) { CommandParameters parameters = new CommandParameters(); parameters.IdMembership = activeGroupId; List <ActiveApplication> activeApplication = ActiveApplication_db.GetActiveApplication(parameters); activeApplication = activeApplication.OrderBy(x => x.ID).Reverse().ToList(); for (int i = 0; i < activeApplication.Count; i++) { contentCanvasShowApplication.Dispatcher.Invoke(() => { MyLabel l = new MyLabel(contentCanvasShowApplication, (i + 1) + ". " + activeApplication[i].Title, 250, 30, 12, 14, 5 + (i * 39), Color.FromArgb(200, 220, 220, 220), Color.FromArgb(0, 0, 0, 0), horizontalAlignment: HorizontalAlignment.Left); l.ToolTip(activeApplication[i].Title); new MyLabel(contentCanvasShowApplication, (activeApplication[i].IfAutoGrouping) ? "Auto" : "Manual", 50, 39, 10, 310, 7 + (i * 39), Color.FromArgb(200, 220, 220, 220), Color.FromArgb(0, 0, 0, 0)); MyCircle circle = new MyCircle(contentCanvasShowApplication, 15, 1, (Color.FromArgb(220, 255, 93, 93)), 385, 12 + (39 * i), 1, true); Label buttonDeleteApplication = ButtonCreator.CreateButton(contentCanvasShowApplication, "x", 25, 25, 8, 380, 7 + (39 * i), Color.FromArgb(255, 255, 255, 255), Color.FromArgb(200, 255, 0, 0), 0, fontWeight: FontWeights.ExtraBold); buttonDeleteApplication.Background = new SolidColorBrush(Color.FromArgb(155, 30, 39, 93)); buttonDeleteApplication.MouseEnter += buttonDeleteApplication_MouseEnter; buttonDeleteApplication.MouseLeave += buttonDeleteApplication_MouseLeave; buttonDeleteApplication.MouseLeftButtonDown += buttonDeleteApplication_MouseLeftButtonDown; buttonDeleteApplication.Name = "ID_" + activeApplication[i].ID.ToString(); ButtonCreator.SetToolTip(buttonDeleteApplication, "Usuń aplikacje z grupy"); new MyRectangle(contentCanvasShowApplication, 400, 1, Color.FromArgb(35, 250, 250, 250), 10, 39 + (i * 39)); contentCanvasShowApplication.Height += 39; }); Thread.Sleep(10); } contentCanvasShowApplication.Dispatcher.Invoke(() => { contentCanvasShowApplication.Height = ((contentCanvasShowApplication.Height - 310) < 310) ? 310 : contentCanvasShowApplication.Height - 309; }); }
private void LoadNonAssignedApplication() { List <ActiveApplication> titlesAllNotAssignedApplication = ActiveApplication_db.GetNonAssignedApplication(); titlesAllNotAssignedApplication.AddRange(ActiveApplication_db.GetNonAssignedApplicationWithGroup()); titlesAllNotAssignedApplication = titlesAllNotAssignedApplication.OrderByDescending(x => x.Date).ToList(); Dictionary <string, string> titleMembership = Membership_db.GetNameGroupsDictionaryIfIsActive(false); titleMembership["0"] = "Brak przynależności"; for (int i = 0; i < titlesAllNotAssignedApplication.Count; i++) { Thread.Sleep(10); Application.Current.Dispatcher.Invoke(() => { nonAssignedAppCanvas = new Canvas(); nonAssignedAppCanvas = CanvasCreator.CreateCanvas(nonAssignedApplications, 560, 60, Color.FromArgb(0, 110, 0, 0), 0, 59 * i); }); string titleApplication = string.Empty; titleApplication = (titlesAllNotAssignedApplication[i].Title.Length > 40) ? titlesAllNotAssignedApplication[i].Title.Remove(40, titlesAllNotAssignedApplication[i].Title.Length - 40) : titlesAllNotAssignedApplication[i].Title; Application.Current.Dispatcher.Invoke(() => { new MyCircle(nonAssignedAppCanvas, 46, 2, Color.FromArgb(255, 150, 150, 150), 8, 8, 1, true); MyLabel l = new MyLabel(nonAssignedAppCanvas, "\t" + titleApplication, 560, 60, 14, 0, 0, Color.FromArgb(255, 120, 120, 120), Color.FromArgb(30, 100, 100, 100), 1, HorizontalAlignment.Left, fontWeight: FontWeights.Bold); l.ToolTip(titlesAllNotAssignedApplication[i].Title); new MyLabel(nonAssignedAppCanvas, ActionOnString.GetFirstLetterFromString(titleApplication), 50, 50, 20, 6, 11, Color.FromArgb(255, 240, 240, 240), Color.FromArgb(0, 100, 100, 100), 0, HorizontalAlignment.Center, fontWeight: FontWeights.ExtraBold); new MyLabel(nonAssignedAppCanvas, titleMembership[titlesAllNotAssignedApplication[i].IdMembership.ToString()], 300, 30, 12, 60, 30, Color.FromArgb(255, 120, 120, 120), Color.FromArgb(30, 100, 100, 100), horizontalAlignment: HorizontalAlignment.Left); new MyLabel(nonAssignedAppCanvas, ActionOnTime.GetNumberDayAgo(titlesAllNotAssignedApplication[i].Date), 100, 30, 13, 466, 0, Color.FromArgb(255, 120, 120, 120), Color.FromArgb(30, 100, 100, 100), horizontalAlignment: HorizontalAlignment.Left); new MyLabel(nonAssignedAppCanvas, "(" + (titlesAllNotAssignedApplication.Count - i) + ")", 100, 30, 9, 420, 0, Color.FromArgb(255, 120, 120, 120), Color.FromArgb(30, 100, 100, 100), horizontalAlignment: HorizontalAlignment.Left); new MyCircle(nonAssignedAppCanvas, 25, 1, (Color.FromArgb(255, 0, 123, 255)), 525, 28, setFill: true); Label buttonAddActivity = ButtonCreator.CreateButton(nonAssignedAppCanvas, "+", 25, 34, 20, 525, 28, Color.FromArgb(255, 255, 255, 255), Color.FromArgb(200, 255, 0, 0), 0, fontWeight: FontWeights.ExtraBold); buttonAddActivity.Margin = new Thickness(0, -8, 0, 0); nonAssignedAppCanvas.Name = "ID_" + titlesAllNotAssignedApplication[i].ID; nonAssignedAppCanvas.Tag = titlesAllNotAssignedApplication[i].IdMembership; buttonAddActivity.MouseLeftButtonDown += buttonAddActivity_MouseLeftButtonDown; nonAssignedApplications.Height += 59; }); } Application.Current.Dispatcher.Invoke(() => { nonAssignedApplications.Height = ((nonAssignedApplications.Height - 300) < 300) ? 300 : nonAssignedApplications.Height - 299; }); loadingWindow.notClose = false; Thread.Sleep(200); backgroundWorkerLoadingWindow.DoWork -= loadingWindow.Load; backgroundWorkerLoadingWindow.DoWork += loadingWindow.Close; backgroundWorkerLoadingWindow.RunWorkerAsync(); }