Пример #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (Lewy.ListBoxSciezki.SelectedIndex != -1)
            {
                string plikL = Path.Combine(Lewy.AktualnaSciezka, Lewy.ZawartoscSciezki[Lewy.ListBoxSciezki.SelectedIndex]);
                string plikR = Path.Combine(Prawy.AktualnaSciezka, Lewy.ZawartoscSciezki[Lewy.ListBoxSciezki.SelectedIndex]);

                try
                {
                    if (Prawy.ZawartoscSciezki.Contains(Lewy.ZawartoscSciezki[Lewy.ListBoxSciezki.SelectedIndex]))
                    {
                        MessageBoxResult overwrite = MessageBox.Show($"Czy chcesz nadpisać plik ?", "OVERWRITE", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
                        if (overwrite == MessageBoxResult.Yes)
                        {
                            File.Copy(plikL, plikR, true);
                            Prawy.ListBoxSciezki.ItemsSource = Prawy.GetContents();
                        }
                    }
                    else
                    {
                        File.Copy(plikL, plikR, true);
                        Prawy.ListBoxSciezki.ItemsSource = Prawy.GetContents();
                    }
                }
                catch (Exception b)
                {
                    MessageBox.Show(b.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                    Lewy.ListBoxSciezki.ItemsSource  = Lewy.GetContents();
                    Prawy.ListBoxSciezki.ItemsSource = Prawy.GetContents();
                }
            }
        }
Пример #2
0
 public void WypiszWezel()
 {
     if (Lewy != null)
     {
         Lewy.WypiszWezel();
     }
     Dane.WypiszOsobe();
     Console.WriteLine();
     if (Prawy != null)
     {
         Prawy.WypiszWezel();
     }
 }
Пример #3
0
 public void KlonujRekurencyjnie(Wezel wezel)
 {
     wezel.Dane = Dane;  // osoby nie s¹ kopiowane
     if (Lewy != null)
     {
         wezel.Lewy = new Wezel();
         Lewy.KlonujRekurencyjnieGleboko(wezel.Lewy);
     }
     if (Prawy != null)
     {
         wezel.Prawy = new Wezel();
         Prawy.KlonujRekurencyjnieGleboko(wezel.Prawy);
     }
 }
Пример #4
0
 //ogolnie to nie wiem czy dobrze to jest. Robi³em na oko i sprawdze potem :D
 public void KlonujRekurencyjnieGleboko(Wezel wezel)
 {
     wezel.Dane = new Osoba.Osoba(Dane);  // osoby s¹ kopiowane i s¹ niezale¿ne
     if (Lewy != null)
     {
         wezel.Lewy = new Wezel();
         Lewy.KlonujRekurencyjnieGleboko(wezel.Lewy);
     }
     if (Prawy != null)
     {
         wezel.Prawy = new Wezel();
         Prawy.KlonujRekurencyjnieGleboko(wezel.Prawy);
     }
 }
Пример #5
0
            public bool Add(T Element)
            {
                ItemsInNode++;

                if (this.Element == null)
                {
                    this.Element = Element;

                    return(true);
                }
                else
                {
                    T comparing = Element;

                    if (this.Element.CompareTo(comparing) > 0)
                    {
                        comparing    = this.Element;
                        this.Element = Element;
                    }

                    if (Lewy == null)
                    {
                        Lewy = new KopiecElement(comparing);
                        return(true);
                    }

                    if (Lewy.Element.CompareTo(comparing) > 0)
                    {
                        T temp = Lewy.Element;
                        Lewy.Element = comparing;
                        comparing    = temp;
                    }

                    if (Prawy == null)
                    {
                        Prawy = new KopiecElement(comparing);
                        return(true);
                    }

                    if (Prawy.ItemsInNode < Lewy.ItemsInNode)
                    {
                        return(Prawy.Add(comparing));
                    }
                    else
                    {
                        return(Lewy.Add(comparing));
                    }
                }
            }