Exemplo n.º 1
0
        private void Ok_OnClick(object sender, RoutedEventArgs e)
        {
            if (!overWriteExisting && markers.Select(x => x.Name).Contains(Name.Text))
            {
                MessageBox.Show("Маркер с таким именем уже существует.");
                return;
            }
            marker.Name = Name.Text;

            var tmpCode = marker.Code;

            marker.Code = Code.Text;

            var errors = Marker.CheckCodeErrors();

            if (errors != null && errors.HasErrors)
            {
                MessageBox.Show(String.Join("\t\n", errors.Cast <CompilerError>().Select(x => x.ErrorText)));
                marker.Code = tmpCode;
                return;
            }

            marker.Colour      = (MarkerColour)((IsAffiliated.IsChecked.Value ? 3 : 0) + Colour.SelectedIndex);
            marker.Score       = Importance.SelectedIndex + 1;
            marker.Description = Description.Text;


            //TODO make marker change after update
            marker.Save();
            //serializer.Serialize(File.Open("./markers",FileMode.OpenOrCreate),markersList.ToArray());
//            using (var file = File.Open("./markers", FileMode.OpenOrCreate))
//            {
//                var tmp = (Marker[])serializer.Deserialize(file);
//                file.Position = 0;
//                serializer.Serialize(file,tmp.Concat(new[]{marker}).ToArray());
//            }

            Close();
        }