Exemplo n.º 1
0
        private void buttonAddRes_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ColorDefinition colorDefinition = new ColorDefinition();
                byte[]          colorBytes      = new byte[3];
                colorBytes[0]         = (byte)random.Next(256);
                colorBytes[1]         = (byte)random.Next(256);
                colorBytes[2]         = (byte)random.Next(256);
                colorDefinition.Color = colorBytes;

                System.Windows.Media.Color windowColor = System.Windows.Media.Color.FromRgb(colorDefinition.Color[0], colorDefinition.Color[1], colorDefinition.Color[2]);
                colorDefinition.BackgroundColor = new SolidColorBrush(windowColor);

                var names = from name in responsibleDefinitions select name.ParameterValue;

                StatusItemWindow itemWindow = new StatusItemWindow(colorDefinition, ColorSource.Responsibility, NewOrEdit.New);
                if (names.Count() > 0)
                {
                    itemWindow.DefinitionNames = names.ToList();
                }

                if (itemWindow.ShowDialog() == true)
                {
                    ColorDefinition newDefinition = itemWindow.SelColorDefinition;
                    itemWindow.Close();

                    dataGridResponsibility.ItemsSource = null;
                    responsibleDefinitions.Add(newDefinition);
                    responsibleDefinitions             = responsibleDefinitions.OrderBy(o => o.ParameterValue).ToList();
                    dataGridResponsibility.ItemsSource = responsibleDefinitions;

                    bool updated = BCFParser.UpdateColorSheet(responsibleScheme, null, newDefinition, ModifyItem.Add, colorSheetId);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to add Responsibility item.\n" + ex.Message, "Add Responsibility Item", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Exemplo n.º 2
0
        private void buttonEditRes_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (null != dataGridResponsibility.SelectedItem)
                {
                    ColorDefinition colorDefinition = (ColorDefinition)dataGridResponsibility.SelectedItem;
                    ColorDefinition oldDefinition   = new ColorDefinition(colorDefinition);
                    string          oldName         = colorDefinition.ParameterValue;

                    var names = from name in responsibleDefinitions select name.ParameterValue;

                    StatusItemWindow itemWindow = new StatusItemWindow(colorDefinition, ColorSource.Responsibility, NewOrEdit.Edit);
                    if (names.Count() > 0)
                    {
                        itemWindow.DefinitionNames = names.ToList();
                    }

                    if (itemWindow.ShowDialog() == true)
                    {
                        ColorDefinition newDefinition = itemWindow.SelColorDefinition;
                        itemWindow.Close();

                        dataGridResponsibility.ItemsSource = null;
                        responsibleDefinitions             = responsibleDefinitions.OrderBy(o => o.ParameterValue).ToList();
                        dataGridResponsibility.ItemsSource = responsibleDefinitions;

                        bool updated = BCFParser.UpdateColorSheet(responsibleScheme, oldDefinition, newDefinition, ModifyItem.Edit, colorSheetId);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to edit Responsibility item.\n" + ex.Message, "Edit Responsibility Item", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }