예제 #1
0
 private void FileMenu_New_Clicked(object sender, RoutedEventArgs e)
 {
     Save_ToFile();
     team = new  TeamObservable("Test Team");
     Update_Content();
     DataContext = team;
 }
예제 #2
0
        private void OpenButton_Click(object sender, RoutedEventArgs e)
        {
            if (TeamOb.Change)
            {
                MessageBoxResult result = MessageBox.Show("Сохранить изменения?", "Сообщение", MessageBoxButton.YesNo, MessageBoxImage.Information);

                if (result == MessageBoxResult.Yes)
                {
                    Save(TeamOb);
                }
            }

            OpenFileDialog open_dialog = new OpenFileDialog();

            if (open_dialog.ShowDialog() == true)
            {
                TeamObservable.Load(open_dialog.FileName, ref TeamOb);

                TeamOb.CollectionChanged += CollectionChangedEventHandler;
                this.DataContext          = TeamOb;

                LeftListBox.ItemsSource = TeamOb;

                ListCollectionView CollectionView = new ListCollectionView(TeamOb);
                CollectionView.Filter    = TeamOb.FilterByResearcher;
                RightListBox.ItemsSource = CollectionView;
            }
        }
예제 #3
0
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            team           = this.FindResource("key_team") as TeamObservable;
            researcherStub = this.FindResource("key_researcherStub") as Researcher;

            this.dontUseDataTemplateRadioButton.IsChecked = true;
        }
예제 #4
0
 private void OnClickNew(object sender, RoutedEventArgs e)
 {
     if (ProceedWithCollectionReplacement())
     {
         team        = new TeamObservable();
         DataContext = this.team;
     }
 }
예제 #5
0
 private void FileMenu_Save_Clicked(object sender, RoutedEventArgs e)
 {
     Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
     if (sfd.ShowDialog() == true)
     {
         TeamObservable.Save(sfd.FileName, team);
     }
 }
예제 #6
0
        //private void WindowBind()
        //{
        //    Binding bd = new Binding();
        //    bd.Source = researcher;
        //    bd.Path = new PropertyPath("Name[0]");
        //    bd.Mode = BindingMode.OneWayToSource;
        //    ResWindow.TextBoxName.SetBinding(TextBox.TextProperty, bd);

        //    Binding bd1 = new Binding();
        //    bd1.Source = researcher;
        //    bd1.Path = new PropertyPath("Name[1]");
        //    bd1.Mode = BindingMode.OneWayToSource;
        //    ResWindow.TextBoxLastName.SetBinding(TextBox.TextProperty, bd1);

        //    Binding bd2 = new Binding();
        //    bd2.Source = researcher;
        //    bd2.Path = new PropertyPath("Date");
        //    bd2.Mode = BindingMode.OneWayToSource;
        //    ResWindow.DatePick.SetBinding(DatePicker.TextProperty, bd2);

        //    Binding bd3 = new Binding();
        //    bd3.Source = researcher;
        //    bd3.Path = new PropertyPath("Topic");
        //    bd3.Mode = BindingMode.OneWayToSource;
        //    ResWindow.CBox.SetBinding(ComboBox.SelectedValueProperty, bd3);

        //    Binding bd4 = new Binding();
        //    bd4.Source = researcher;
        //    bd4.Path = new PropertyPath("num");
        //    bd4.Mode = BindingMode.OneWayToSource;
        //    ResWindow.Num.SetBinding(TextBox.TextProperty, bd4);

        //    ResWindow.AddButton.Click += AddButton_Click;
        //}

        //private void Refresh(TeamObservable t)
        //{
        //    LeftListBox.ItemsSource = t;
        //    RightListBox.ItemsSource = from item in t where item is Researcher select item;
        //    //RightListBox.ItemTemplate =
        //}

        private void Save(TeamObservable t)
        {
            SaveFileDialog save_dialog = new SaveFileDialog();

            if (save_dialog.ShowDialog() == true)
            {
                t.Change = false;
                TeamObservable.Save(save_dialog.FileName, t);
            }
        }
예제 #7
0
 private void FileMenu_Open_Clicked(object sender, RoutedEventArgs e)
 {
     Save_ToFile();
     Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
     if (ofd.ShowDialog() == true)
     {
         TeamObservable.Load(ofd.FileName, ref team);
         Update_Content();
         DataContext = team;
     }
 }
예제 #8
0
        public MainWindow()
        {
            InitializeComponent();

            team = new TeamObservable("Test Team");

            team.CollectionChanged += Data_Changed_Handler;

            temp_researcher = new Researcher();

            DataContext = team;

            inp_grid.DataContext = temp_researcher;

            research.ItemsSource   = team.RT;
            research.SelectedIndex = 0;
        }
예제 #9
0
        //------------------
        // Command handlers
        //------------------
        private void OpenCommandHandler(object sender, ExecutedRoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            dlg.Filter          = "TeamObservable serialized object (*teamobservable)|*.teamobservable|All(*.*)|*.*";
            dlg.FilterIndex     = 0;
            dlg.CheckFileExists = true;

            if (dlg.ShowDialog() == true)
            {
                if (ProceedWithCollectionReplacement())
                {
                    TeamObservable.Load(dlg.FileName, ref team);
                    // Here is no potential exception, but the file could be not opened properly.
                    // Need a messagebox here.
                    DataContext = team;
                }
            }
        }
예제 #10
0
        private bool SaveCollection()
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();

            dlg.Filter          = "TeamObservable serialized object(*teamobservable)|*.teamobservable|All(*.*)|*.*";
            dlg.FilterIndex     = 0;
            dlg.OverwritePrompt = true;

            if (dlg.ShowDialog() == true)
            {
                team.ChangesNotSaved = false;
                TeamObservable.Save(dlg.FileName, this.team);
                // Here is no potential exception, but the file can be not saved properly.
                // Need a messagebox here.
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #11
0
 private void Save_ToFile()
 {
     if (team.IfChanged)
     {
         Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
         var result = MessageBox.Show("Save changes? Data may be lost.", "Message", MessageBoxButton.YesNo);
         if (result == MessageBoxResult.Yes)
         {
             if (sfd.ShowDialog() == true)
             {
                 TeamObservable.Save(sfd.FileName, team);
                 team.IfChanged = false;
                 //TextBlock_IfChanged.Text = team.IfChanged.ToString();
             }
         }
         else
         {
             MessageBox.Show("Changes canceled.", "Message");
         }
     }
 }