示例#1
0
        /// <summary>
        /// метод выполянется, когда открывается окно
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Window_Activated(object sender, EventArgs e)
        {
            try
            {
                if (flag)
                {
                    Label label = new Label();

                    label.VerticalAlignment   = VerticalAlignment.Top;
                    label.HorizontalAlignment = HorizontalAlignment.Center;
                    label.FontSize            = 17;
                    label.Margin  = new Thickness(0, 25, 0, 0);
                    label.Content = $"Project: { _project.Name}";
                    grid.Children.Add(label);

                    BackButton.Background = new ImageBrush(new BitmapImage(new Uri(path)));

                    DatabaseActions databaseActions = new DatabaseActions();

                    listSelected = await databaseActions.ShowRisks(_project);

                    if (listSelected == null)
                    {
                        listSelected = new List <Risk>();
                    }

                    RiskActions riskActions = new RiskActions();

                    listRisks = await riskActions.ShowRisks();

                    SeletionCombobox.Items.Add("Общие риски");
                    SeletionCombobox.Text = "Common Risks";
                    SeletionCombobox.Items.Add(_project.Type);
                    listSource = await riskActions.ShowSources();

                    AddToSelected();

                    for (int i = 0; i < listSource.Count; i++)
                    {
                        SeletionCombobox.Items.Add(listSource[i]);
                    }

                    Drawing();
                    SearchForDangerousRisks();

                    await SetUsers();

                    flag = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.TargetSite);
            }
        }
        /// <summary>
        /// метод запускается при открытии окна
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Window_Activated(object sender, EventArgs e)
        {
            if (flag)
            {
                Label label = new Label();
                label.VerticalAlignment   = VerticalAlignment.Top;
                label.HorizontalAlignment = HorizontalAlignment.Center;
                label.FontSize            = 15;
                label.Margin  = new Thickness(0, 25, 0, 0);
                label.Content = $"Project:  { _project.Name}";

                grid.Children.Add(label);
                BackButton.Background = new ImageBrush(new BitmapImage(new Uri(path)));

                DatabaseActions databaseActions = new DatabaseActions();

                listRisksSelected = await databaseActions.ShowRisks(_project);

                if (listRisksSelected == null)
                {
                    listRisksSelected = new List <Risk>();
                }

                RiskActions riskActions = new RiskActions();

                listAllRisks = await riskActions.ShowRisks();

                ComboBoxTypes.Items.Add("Общие риски");
                ComboBoxTypes.Text = "Common Risks";
                ComboBoxTypes.Items.Add(_project.Type);
                listSource = await riskActions.ShowSources();

                AddInSelected();

                for (int i = 0; i < listSource.Count; i++)
                {
                    ComboBoxTypes.Items.Add(listSource[i]);
                }

                DrawHyperbola();
                FindDangerousRisks();
                await SetOwners();

                flag = false;
            }
        }