Ejemplo n.º 1
0
        private void CommandBrowseRight_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            BrowseFolderWindow browseFolderWindow = new BrowseFolderWindow()
            {
                DataContext = ViewModel, Owner = this, SelectedPath = ViewModel.RightPath
            };

            browseFolderWindow.ShowDialog();

            if (browseFolderWindow.DialogResult == true)
            {
                ViewModel.RightPath = browseFolderWindow.SelectedPath;
            }
        }
Ejemplo n.º 2
0
        private void Compare()
        {
            rightSelection              = "";
            leftSelection               = "";
            ViewModel.LeftPath          = ViewModel.LeftPath.Trim();
            ViewModel.RightPath         = ViewModel.RightPath.Trim();
            TextBoxLeftPath.Background  = new SolidColorBrush(Colors.White);
            TextBoxRightPath.Background = new SolidColorBrush(Colors.White);

            BrowseFolderWindow browseLeft = new BrowseFolderWindow()
            {
                DataContext = ViewModel, Owner = this, Title = "Select Left Path"
            };

            if (ViewModel.LeftPath == "")
            {
                browseLeft.ShowDialog();

                if (browseLeft.DialogResult == true)
                {
                    ViewModel.LeftPath = browseLeft.SelectedPath;
                }
            }

            if (ViewModel.RightPath == "" && browseLeft.DialogResult != false)
            {
                BrowseFolderWindow browseRight = new BrowseFolderWindow()
                {
                    DataContext = ViewModel, Owner = this, Title = "Select Right Path"
                };
                browseRight.ShowDialog();

                if (browseRight.DialogResult == true)
                {
                    ViewModel.RightPath = browseRight.SelectedPath;
                }
            }

            if (File.Exists(ViewModel.LeftPath))
            {
                if (File.Exists(ViewModel.RightPath))
                {
                    ViewModel.Mode = CompareMode.File;

                    CompareFiles();
                }
                else
                {
                    TextBoxRightPath.Background = new SolidColorBrush(Colors.Pink);
                }
            }
            else if (Directory.Exists(ViewModel.LeftPath))
            {
                if (Directory.Exists(ViewModel.RightPath))
                {
                    ViewModel.Mode = CompareMode.Folder;

                    CompareDirectories();
                }
                else
                {
                    TextBoxRightPath.Background = new SolidColorBrush(Colors.Pink);
                }
            }
            else
            {
                TextBoxLeftPath.Background = new SolidColorBrush(Colors.Pink);
                if (!(File.Exists(ViewModel.RightPath) || Directory.Exists(ViewModel.RightPath)))
                {
                    TextBoxRightPath.Background = new SolidColorBrush(Colors.Pink);
                }
            }
        }