Beispiel #1
0
        private void OpenCommandHandler_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            try
            {
                if (Check_Changes())
                {
                    Serialize();
                }

                OpenFileDialog dlg = new OpenFileDialog
                {
                    Filter      = "Serialization data|*.dat|All|*.*",
                    FilterIndex = 2
                };

                if (dlg.ShowDialog() == true)
                {
                    Collection = new V3MainCollection();
                    Collection.Load(dlg.FileName);
                    InitDataContext();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{this.GetType()}.MenuItem_Open_Click() raised exception:\n{ex.Message}");
            }
        }
        public static V3MainCollection Load(string filename)
        {
            FileStream       fileStream = null;
            V3MainCollection res        = null;

            try
            {
                fileStream = File.OpenRead(filename);
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                res = binaryFormatter.Deserialize(fileStream) as V3MainCollection;
                res.CollectionChanged += res.collectionChangedHandler;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }
            return(res);
        }
        public void collectionChangedHandler(object sender, NotifyCollectionChangedEventArgs args)
        {
            V3MainCollection mainsender = (V3MainCollection)sender;

            PropertyChanged?.Invoke(sender, new PropertyChangedEventArgs("max_distance"));
            mainsender.changed_not_saved = true;
        }
Beispiel #4
0
        private void MenuItem_New_Click(object sender, RoutedEventArgs e)
        {
            if (Check_Changes())
            {
                Serialize();
            }

            Collection = new V3MainCollection();
            InitDataContext();
        }
Beispiel #5
0
 static void MainCollectionNearest(V3MainCollection mainCollection, Vector2 point, string number)
 {
     Console.WriteLine($"{number} point: {point}");
     foreach (V3Data item in mainCollection)
     {
         foreach (Vector2 coord in item.Nearest(point))
         {
             Console.Write(coord + " ");
         }
         Console.WriteLine();
     }
     Console.WriteLine();
 }
Beispiel #6
0
        static void Main()
        {
            V3MainCollection mainCollection = new V3MainCollection();

            mainCollection.DataChanged += DataChangesCollector;
            mainCollection.AddDefaults();
            V3DataCollection collection1 = new V3DataCollection("test1.txt");

            mainCollection.Add(collection1);

            //Console.WriteLine(mainCollection.ToString("F3"));

            mainCollection[2].Info = "--- CHANGED INFO ---";
            mainCollection[4].Time = DateTime.Now;
            mainCollection[1]      = new V3DataCollection("test2.txt");

            V3Data temp = mainCollection[3];

            mainCollection.Remove(3);
            temp.Info = "REMOVED OBJECT";                            // Это изменение не вызывает событие

            //Console.WriteLine(mainCollection.ToString("F3"));
        }