private void BeginSelectByDown(object sender, MouseButtonEventArgs e) { if (!IsEditListMode) { return; } if (sender is ListBoxItem) { (sender as ListBoxItem).IsSelected = true; } currentImage = e.OriginalSource as Image; if (currentImage != null && currentImage.Name != "buttonImage") { if (droppedData == null) { FrameworkElement fd = e.OriginalSource as FrameworkElement; if (fd != null) { SolutionInfo item = fd.DataContext as SolutionInfo; if (item != null && solutions.Contains(item)) { droppedData = item; } } } if (droppedData != null) { try { currentImage.Opacity = 1; DragDrop.DoDragDrop(currentImage, droppedData, DragDropEffects.Move); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } }
private void AddCurrentSolution() { if (databaseNameComboBox.SelectedItem == null) { return; } ComboBoxItem currentItem = databaseNameComboBox.SelectedItem as ComboBoxItem; SolutionInfo resultSolution = currentItem.Tag as SolutionInfo; newSolution = resultSolution; if (DatabaseHelper.ReadSolutionInfo(resultSolution.SqlServerName, resultSolution.SqlBaseName, out resultSolution)) { isSolutionRecognized = true; Close(); } else { ShowError("Не удалось получить описание системы для этой базы данных."); // "Не удалось получить описание системы для этой базы данных.".ShowError(); } }
private void ItemDrop(object sender, DragEventArgs e) { if (droppedData == null) { return; } SolutionInfo target = (( FrameworkElement )(sender)).DataContext as SolutionInfo; SolutionInfo dataConnected = e.Data.GetData(typeof(SolutionInfo)) as SolutionInfo; if (dataConnected == null) { return; } if (currentImage != null) { currentImage.Opacity = 0; } int removedIdx = solutions.IndexOf(droppedData); int targetIdx = solutions.IndexOf(target); if (removedIdx < targetIdx) { solutions.Insert(targetIdx + 1, droppedData); solutions.RemoveAt(removedIdx); } else { int remIdx = removedIdx + 1; if (solutions.Count + 1 > remIdx) { solutions.Insert(targetIdx, droppedData); solutions.RemoveAt(remIdx); } } droppedData = null; }
/// <summary> /// to debug set as run parameter: "7028;4dee93e9-f991-47f8-9493-931aa945897a;AramisPlatform;localhost" /// </summary> /// <param name="args"></param> private void Start(string[] args) { if (ProcessHelper.GetOtherSameProcessesList(true).Count > 0) { if (MessageBox.Show(string.Format("Для продолжения запуска требуется закрыть другие запущенные копии системы.\r\n\r\nНажмите Да и система продолжит запуск\r\n\r\nНажмите Нет для отмены{0}", App.StartParameters.TerminatingProcessId > 0 ? "\r\nПроцесс: " + App.StartParameters.TerminatingProcessId.ToString() : ""), "Aramis system", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No) == MessageBoxResult.Yes) { ProcessHelper.GetOtherSameProcessesList(true).ForEach(process => process.SafetyKill()); } else { return; } } Log.Testing = (new List <string>() { "---utk-server1", "-atosit", "donotenter" }).Contains(System.Environment.MachineName.ToLower().Trim()); if (Thread.CurrentThread.Name == null) { Thread.CurrentThread.Name = "Main starter thread"; } ReadSolutions(); // ( new WpfApplication1.SolutionSelectingWindowXXX() ).ShowDialog(); // Нужно что это окно было создано первым, т.к. оно будет главным LoginWindow mainWindow = LoginWindow.Window; bool emptySolutionListAtStart = solutions.Count == 0; if (emptySolutionListAtStart) { TryToAddDefaultSolution(); if (solutions.Count == 0) { SolutionInfo newSolutionInfo = AddNewSystemWindow.AddNewSolution(); if (newSolutionInfo != null) { solutions.Add(newSolutionInfo); SaveSolutionsList(solutions); } } } ReadSolutions(); SelectedSolution = null; if (solutions.Count == 0) { return; } else if (solutions.Count == 1 && !emptySolutionListAtStart && !Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift)) { SelectedSolution = solutions[0]; } else if (App.StartParameters.ExecuteType == ExecuteTypes.Restart) { foreach (var solution in solutions) { if (solution.SqlBaseName.Equals(App.StartParameters.DatabaseName, StringComparison.OrdinalIgnoreCase) && solution.SqlServerName.Equals(App.StartParameters.ServerName, StringComparison.OrdinalIgnoreCase)) { SelectedSolution = solution; break; } } } if (SelectedSolution == null) { SolutionSelectingWindow seleectingWindow = new SolutionSelectingWindow(solutions); seleectingWindow.ShowDialog(); SelectedSolution = seleectingWindow.SelectedSolution; } if (SelectedSolution != null) { InitWithSelectedSolution(); //if (Log.Testing || Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftAlt)) // { // (new Log()).Show(); // } Run(mainWindow); } }