Beispiel #1
0
        public override bool Remove(BaseEntity entity)
        {
            bool result = false;

            if (entity == null)
            {
                ShowFeedback("No valid group selected. Canceling.", FeedbackType.Error);
                return(false);
            }
            try
            {
                ClearFeedback();
                string msg = "";
                int    sId = entity.Id;
                result = SelectedGroup.RemoveStudent((Student)entity, UnitOfWork, ref msg);
                if (result)
                {
                    UpdateMyGroupsList(RowLimit);
                    ShowFeedback($"Removed Student {sId} from Group {SelectedGroup.Id}.", FeedbackType.Success);
                    return(true);
                }
                else
                {
                    ShowFeedback(msg, FeedbackType.Error);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ShowFeedback(ex.Message, FeedbackType.Error);
                return(false);
            }
        }
Beispiel #2
0
        public override bool Save()
        {
            ClearFeedback();
            bool result = false;

            try
            {
                if (FormContext == FormContext.Create)
                {
                    //Create New
                    result = User.AddNewGroup(SelectedGroup, UnitOfWork);
                    UpdateMyGroupsList(RowLimit);
                    FormContext = FormContext.Update;//since selected group now has ID set
                    ShowFeedback($"Successfully created: {SelectedGroup.Id}.", FeedbackType.Success);
                }
                else
                {
                    //Update
                    result = SelectedGroup.ValidateGroup(UnitOfWork);
                    if (result)
                    {
                        UnitOfWork.Complete();
                        ShowFeedback($"Successfully updated: {SelectedGroup.Id}.", FeedbackType.Success);
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                ShowFeedback(ex.GetBaseException().Message, FeedbackType.Error);
                return(false);
            }
        }
        private void DeleteCurrent(object sender, RoutedEventArgs e)
        {
            if (SelectedItem.GetType().Name == SelectedFaculty.GetType().Name)
            {
                SelectedFaculty = (FacultyViewModel)SelectedItem;
                Collection.Remove(SelectedFaculty.Key, true);
                CollectionView.Remove(SelectedFaculty);
            }

            if (SelectedItem.GetType().Name == SelectedGroup.GetType().Name)
            {
                SelectedGroup = (GroupViewModel)SelectedItem;
                Faculty <int, Group <int, Student> > faculty;
                Collection.TryGetValue(SelectedGroup.Parent.Key, out faculty, true);
                faculty.Remove(SelectedGroup.Key, true);
                SelectedGroup.Parent.Groups.Remove(SelectedGroup);
            }

            if (SelectedItem.GetType().Name == SelectedStudent.GetType().Name)
            {
                SelectedStudent = (StudentViewModel)SelectedItem;
                Faculty <int, Group <int, Student> > faculty;
                Collection.TryGetValue(SelectedStudent.Parent.Parent.Key, out faculty, true);
                Group <int, Student> group;
                faculty.TryGetValue(SelectedStudent.Parent.Key, out group, true);
                group.Remove(SelectedStudent.Key, true);
                SelectedStudent.Parent.Students.Remove(SelectedStudent);
            }

            TreeViewAll.ItemsSource = null;
            TreeViewAll.ItemsSource = CollectionView;
        }
 public void EnableGroups()
 {
     IsGroupSet = !SelectedGroup.Equals(string.Empty);
     EnableVideoInputs();
     GroupNumber = "0";
     ChangeColors();
 }
 protected void UpdateTemplateList()
 {
     templates.Clear();
     if (SelectedGroup != null)
     {
         templates.AddRange(SelectedGroup.GetTemplatesRecursively());
     }
 }
Beispiel #6
0
 public void SetClipboard()
 {
     if (SelectedGroup != null)
     {
         // Keep a reference to the data object because we will get a clipboard update when it is sent to the keyboard.
         setData = new DataObject(DataFormats.Text, SelectedGroup.ToString(), true);
         Clipboard.SetDataObject(setData);
     }
 }
Beispiel #7
0
    void Update()
    {
        if (Input.GetMouseButtonDown(1))                                                                //Right click
        {
            RaycastHit hit;
            Ray        ray = screenCamera.ScreenPointToRay(Input.mousePosition);

            int layerMask = 1 << 9;
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))                               //only hit the ground layer
            {
                if (waypointScript != null)
                {
                    if (waypointScript.waypoint != null && waypointScript.waypoint.layer != 11)
                    {
                        Destroy(waypointScript.waypoint);                                               //if theres already a waypoint, destroy it
                    }
                    destination = Instantiate(prefab, hit.point, Quaternion.identity);                  //set a new waypoint
                    currentGroup.destinationWaypoint = destination;
                    currentGroup.Selected();
                }
            }
        }
        if (Input.GetMouseButtonDown(0))                                                                //Left click
        {
            RaycastHit hit;
            Ray        ray       = screenCamera.ScreenPointToRay(Input.mousePosition);
            int        layerMask = 1 << 10;                                                                 //only hit characters
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask, QueryTriggerInteraction.Ignore))
            {
                if (first)                                                                                          //if the first group sleceted in the game
                {
                    first        = false;
                    currentGroup = hit.transform.parent.gameObject.GetComponent <SelectedGroup>();
                    currentGroup.Selected();
                }
                else
                {
                    if (waypointScript.waypoint != null)                                                            //if not, deselect the previous group
                    {
                        waypointScript.waypoint.GetComponent <Renderer>().material = waypointUnselected;
                    }
                    if (currentGroup != null)
                    {
                        currentGroup.UnSelected();
                    }

                    currentGroup = hit.transform.parent.gameObject.GetComponent <SelectedGroup>();
                    currentGroup.Selected();
                }
                waypointScript = hit.transform.parent.gameObject.GetComponent <MoveToWaypoint>();
                if (waypointScript.waypoint != null)
                {
                    waypointScript.waypoint.GetComponent <Renderer>().material = waypointSelected;
                }
            }
        }
    }
Beispiel #8
0
        /// <summary>
        /// process a frame by calling the Draw method of selected group
        /// </summary>
        /// <param name="main"></param>
        public static void Process(MainWindow main)
        {
            if (mainw == null)
            {
                mainw = main;
            }

            SelectedGroup.Draw(main.userCanvas);
        }
Beispiel #9
0
 private void CtxProjPatternAdd_Click(object sender, EventArgs e)
 {
     using (var frm = new frmPatternImport())
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             frm.Pattern.Group = SelectedGroup;
             SelectedGroup.Add(frm.Pattern);
         }
     }
 }
Beispiel #10
0
        private int GetTotal()
        {
            if (!SelectedGroup.HasValue())
            {
                return(ExceptionStores.TotalExceptionCount);
            }
            var group = Groups.Find(g => g.Name == SelectedGroup);

            if (group != null && SelectedLog.HasValue())
            {
                return(group.Applications.Find(a => a.Name == SelectedLog)?.ExceptionCount ?? 0);
            }
            return(group?.Total ?? 0);
        }
Beispiel #11
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (txtDelGroupID.ToString() != "")
            {
                if (MessageBox.Show("Are you sure you want to delete this booking?", "Delete Booking Details",
                                    MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    int SelectedGroup;
                    SelectedGroup = int.Parse(txtDelSearch.Text);
                    drBooking     = dsBookings.Tables["Practice Room Booking"].Rows.Find(SelectedGroup);
                    drBooking.Delete();
                    daBookings.Update(dsBookings, "Practice Room Booking");
                    MessageBox.Show("Details have been deleted for: " + SelectedGroup.ToString());

                    clear();
                }
            }
        }
Beispiel #12
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (textBox2.ToString() != "")
     {
         if (MessageBox.Show("Are you sure you want to delete this Group?", "Delete Group Details",
                             MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
         {
             int SelectedGroup;
             SelectedGroup = int.Parse(textBox2.Text);
             drGroups      = dsGroups.Tables["Groups"].Rows.Find(SelectedGroup);
             drGroups.Delete();
             daGroups.Update(dsGroups, "Groups");
             MessageBox.Show("Details have been deleted for: " + SelectedGroup.ToString());
             textBox1.Clear();
             textBox2.Clear();
             tabGroups.SelectedIndex = 0;
         }
     }
 }
        private void ShowScoolarships(object sender, RoutedEventArgs e)
        {
            if (SelectedItem.GetType().Name == SelectedGroup.GetType().Name)
            {
                ScoolarshipList sl = new ScoolarshipList((GroupViewModel)SelectedItem);
                sl.Owner = this;
                sl.Resources["BorderColor"]    = Resources["BorderColor"];
                sl.Resources["ButtonColor"]    = Resources["ButtonColor"];
                sl.Resources["BGColor"]        = Resources["BGColor"];
                sl.Resources["TextColor"]      = Resources["TextColor"];
                sl.Resources["FontStyle"]      = Resources["FontStyle"];
                sl.Resources["FontFamily"]     = Resources["FontFamily"];
                sl.Resources["FontSizeSmall"]  = Resources["FontSizeSmall"];
                sl.Resources["FontSizeMedium"] = Resources["FontSizeMedium"];
                sl.Resources["FontSizeLarge"]  = Resources["FontSizeLarge"];

                sl.Show();
            }
        }
        private void PoolingUpdate(object obj)
        {
            App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE
            {
                try
                {
                    //Temp group holds the selected Group's properties so they don't get cleared with pooling
                    Group tempGroup = new Group();
                    tempGroup.ShallowCopy(SelectedGroup);

                    UpdateMyGroupsList(RowLimit);
                    RefreshAvailableStudents(SelectedGroup);
                    SelectedGroup.ShallowCopy(tempGroup);

                    foreach (Group g in Groups)
                    {//safe way to get record value updates from database
                        if (g.Id != SelectedGroup.Id)
                        {
                            UnitOfWork.Reload(g);
                        }
                        if (g.Id == SelectedGroup.Id)//reload the groups Students list
                        {
                            ////SelectedGroup.Students = new ObservableCollection<Student>(UnitOfWork.StudentRepo.GetStudentsFromGroup(SelectedGroup));
                            //foreach (Student s in SelectedGroup.Students)
                            //{
                            //    UnitOfWork.Detach(s);
                            //    SelectedGroup.Students.Remove(s);
                            //}
                            //UnitOfWork.LoadStudents(SelectedGroup);
                        }
                    }
                    OnPropertyChanged(nameof(SelectedGroup));
                }
                catch (Exception ex)
                {
                    ShowFeedback($"Error refreshing content. \n{ex.Message}", FeedbackType.Error);
                }
            });
        }
Beispiel #15
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            checkbox.Current.BindValueChanged(selected =>
            {
                if (selected.NewValue)
                {
                    if (SelectedGroup.Value == null)
                    {
                        checkbox.Current.Value = false;
                        return;
                    }

                    if (ControlPoint.Value == null)
                    {
                        SelectedGroup.Value.Add(ControlPoint.Value = CreatePoint());
                    }
                }
                else
                {
                    if (ControlPoint.Value != null)
                    {
                        SelectedGroup.Value.Remove(ControlPoint.Value);
                        ControlPoint.Value = null;
                    }
                }

                content.BypassAutoSizeAxes = selected.NewValue ? Axes.None : Axes.Y;
            }, true);

            SelectedGroup.BindValueChanged(points =>
            {
                ControlPoint.Value     = points.NewValue?.ControlPoints.OfType <T>().FirstOrDefault();
                checkbox.Current.Value = ControlPoint.Value != null;
            }, true);

            ControlPoint.BindValueChanged(OnControlPointChanged, true);
        }
        private void TreeViewSelected(object sender, RoutedEventArgs e)
        {
            TreeViewItem tvi = e.OriginalSource as TreeViewItem;

            if (tvi != null)
            {
                if (tvi.DataContext.GetType().Name == SelectedFaculty.GetType().Name)
                {
                    Add_Info_Button.Content = "_Add group...";
                    Delete_Button.Content   = "_Delete faculty";
                    Modify_Button.Content   = "_Modify faculty...";
                    Delete_Button.IsEnabled = true;
                    Delete_Button.Opacity   = 1;
                    Modify_Button.Opacity   = 1;
                    Modify_Button.IsEnabled = true;

                    SelectedItem    = (FacultyViewModel)tvi.DataContext;
                    SelectedFaculty = (FacultyViewModel)tvi.DataContext;
                    bool hasstuds = false;
                    foreach (var group in SelectedFaculty.Groups)
                    {
                        if (group.Students.Count != 0)
                        {
                            hasstuds = true;
                        }
                    }
                    AM_TB.Content = (hasstuds) ? "Faculty average mark: " + SelectedFaculty.AM
                        : "";
                }
                if (tvi.DataContext.GetType().Name == SelectedGroup.GetType().Name)
                {
                    Add_Info_Button.Content = "_Add student...";
                    Delete_Button.Content   = "_Delete group";
                    Modify_Button.Content   = "_Modify group...";
                    Delete_Button.IsEnabled = true;
                    Delete_Button.Opacity   = 1;
                    Modify_Button.Opacity   = 1;
                    Modify_Button.IsEnabled = true;
                    SSListButton.IsEnabled  = true;
                    SSListButton.Opacity    = 1;

                    SelectedItem  = (GroupViewModel)tvi.DataContext;
                    SelectedGroup = (GroupViewModel)tvi.DataContext;
                    AM_TB.Content = (SelectedGroup.Students.Count != 0) ? "Group average mark: " + SelectedGroup.AM : "";
                }
                if (tvi.DataContext.GetType().Name == SelectedStudent.GetType().Name)
                {
                    Add_Info_Button.Content = "_More info...";
                    Delete_Button.Content   = "_Delete student";
                    Modify_Button.Content   = "_Modify student...";
                    Delete_Button.IsEnabled = true;
                    Delete_Button.Opacity   = 1;
                    Modify_Button.Opacity   = 1;
                    Modify_Button.IsEnabled = true;


                    SelectedItem    = (StudentViewModel)tvi.DataContext;
                    SelectedStudent = (StudentViewModel)tvi.DataContext;
                    AM_TB.Content   = "Student average mark: " + SelectedStudent.AM;
                }
            }
        }
Beispiel #17
0
        public ConnectionInfoManagementViewModel()
        {
            AddNewItemCommand = IsItemEditing.Inverse().ToReactiveCommand();
            AddNewItemCommand.Subscribe(() =>
            {
                SelectedItem.Value = null;
                EditingItem.Value  = new T();
                if (IsGroupSelected?.Value == true)
                {
                    EditingItem.Value.GroupName = SelectedGroup.Value?.Name;
                }
                IsItemEditing.Value = true;
            }).AddTo(Disposable);

            ConnectCommand.Subscribe(async item => await ConfirmConnect(item)).AddTo(Disposable);

            IsItemSelected = SelectedItem.Select(x => x != null).ToReadOnlyReactiveProperty();

            IsNotItemEditing = IsItemEditing.Inverse().ToReadOnlyReactiveProperty();

            SelectedItem.Subscribe(x =>
            {
                EditingItem.Value   = SelectedItem.Value;
                IsItemEditing.Value = false;
            }).AddTo(Disposable);

            StartEditCommand = IsItemSelected
                               .CombineLatest(IsItemEditing.Inverse(), (a, b) => a && b)
                               .ToReactiveCommand();
            StartEditCommand.Subscribe(() =>
            {
                EditingItem.Value   = SelectedItem.Value.CloneDeep();
                IsItemEditing.Value = true;
            }).AddTo(Disposable);

            ReplicateCommand = IsItemSelected
                               .CombineLatest(IsItemEditing.Inverse(), (a, b) => a && b)
                               .ToReactiveCommand();
            ReplicateCommand.Subscribe(() =>
            {
                var replicated      = SelectedItem.Value.CloneDeep();
                replicated.Id       = -1;
                SelectedItem.Value  = null;
                EditingItem.Value   = replicated;
                IsItemEditing.Value = true;
            }).AddTo(Disposable);

            RemoveCommand = IsItemSelected
                            .CombineLatest(IsItemEditing.Inverse(), (a, b) => a && b)
                            .ToAsyncReactiveCommand();
            RemoveCommand.Subscribe(async() =>
            {
                if (await Remove(SelectedItem.Value))
                {
                    Items.Remove(SelectedItem.Value);
                    // Renew Windows JumpList
                    JumpListHelper.RenewJumpList(await MainWindow.DbContext.EnumerateAllConnectionInfos());
                }
            }).AddTo(Disposable);

            DiscardChangesCommand = IsItemEditing.ToReactiveCommand();
            DiscardChangesCommand.Subscribe(() =>
            {
                EditingItem.Value   = SelectedItem.Value ?? new T();
                IsItemEditing.Value = false;
            }).AddTo(Disposable);

            SaveChangesCommand = IsItemEditing.ToReactiveCommand();
            SaveChangesCommand.Subscribe(async() =>
            {
                var selectedItem = SelectedItem.Value;
                var item         = EditingItem.Value;
                try
                {
                    var(result, resultItem) = await Save(item);
                    if (resultItem == null)
                    {
                        return;        // FAILED
                    }
                    item = resultItem; // Replace with the saved item
                    if (result)        // ADDED
                    {
                        Items.Add(item);
                    }
                    else // UPDATED
                    {
                        var oldItem = Items.FirstOrDefault(x => x.Id == item.Id);
                        if (oldItem != null)
                        {
                            var index = Items.IndexOf(oldItem);
                            if (index >= 0)
                            {
                                Items.RemoveAt(index);
                                Items.Insert(index, item);
                            }
                        }
                    }
                    // Renew Windows JumpList
                    JumpListHelper.RenewJumpList(await MainWindow.DbContext.EnumerateAllConnectionInfos());
                }
                catch (OperationCanceledException) // User manually canceled
                {
                    return;
                }
                SelectedItem.Value  = item;
                IsItemEditing.Value = false;
            }).AddTo(Disposable);

            // Connection info filterings
            FilterText
            .Throttle(TimeSpan.FromMilliseconds(500))
            .ObserveOnDispatcher()
            .Subscribe(_ => RefreshCollectionView())
            .AddTo(Disposable);
            SelectedGroup
            .ObserveOnDispatcher()
            .Subscribe(_ => RefreshCollectionView())
            .AddTo(Disposable);

            // If any group is selected or not (except for "All")
            IsGroupSelected = SelectedGroup
                              .Select(x => x?.Name != AllGroupName)
                              .ToReadOnlyReactivePropertySlim()
                              .AddTo(Disposable);

            // Group list extraction on connection info events
            Observable.CombineLatest(
                // When Add, Remove or Update
                Items.CollectionChangedAsObservable()
                .Select(_ => Unit.Default)
                .StartWith(Unit.Default),
                // When GroupName property in each element changed
                Items.ObserveElementPropertyChanged()
                .Where(x => x.EventArgs.PropertyName == nameof(ConnectionInfoBase.GroupName))
                .Select(_ => Unit.Default)
                .StartWith(Unit.Default)
                )
            .Throttle(TimeSpan.FromMilliseconds(500))     // Once 500 ms
            .ObserveOnDispatcher()
            .Subscribe(_ =>
            {
                var selectedGroup = SelectedGroup.Value;
                // Reload group list
                Groups.Clear();
                EnumerateGroups().ToList().ForEach(Groups.Add);
                // Reset selected group
                SelectedGroup.Value = (selectedGroup is null) ? Groups.FirstOrDefault() : selectedGroup;
            })
            .AddTo(Disposable);
        }
        //private bool canUpdate;
        //private bool isStudentSelected()
        //{
        //    return SelectedStudent != null;
        //}

        private bool isSelectedStudentAsPrevious()
        {
            if (City != null)
            {
                if (!City.Equals(SelectedStudent.City))
                {
                    return(false);
                }
            }
            else if (SelectedStudent.City != null)
            {
                if (!SelectedStudent.City.Equals(City))
                {
                    return(false);
                }
            }



            if (DateOfBirth != null)
            {
                if (!DateOfBirth.Equals(SelectedStudent.DateOfBirth))
                {
                    return(false);
                }
            }
            else if (SelectedStudent.DateOfBirth != null)
            {
                if (!SelectedStudent.DateOfBirth.Equals(DateOfBirth))
                {
                    return(false);
                }
            }



            if (FirstName != null)
            {
                if (!FirstName.Equals(SelectedStudent.FirstName))
                {
                    return(false);
                }
            }
            else if (SelectedStudent.FirstName != null)
            {
                if (!SelectedStudent.FirstName.Equals(FirstName))
                {
                    return(false);
                }
            }



            if (LastName != null)
            {
                if (!LastName.Equals(SelectedStudent.LastName))
                {
                    return(false);
                }
            }
            else if (SelectedStudent.LastName != null)
            {
                if (!SelectedStudent.LastName.Equals(LastName))
                {
                    return(false);
                }
            }


            if (SelectedGroup != null)
            {
                if (!SelectedGroup.Equals(SelectedStudent.Group))
                {
                    return(false);
                }
            }
            else if (SelectedStudent.Group != null)
            {
                if (!SelectedStudent.Group.Equals(SelectedGroup))
                {
                    return(false);
                }
            }



            if (IndexID != null)
            {
                if (!IndexID.Equals(SelectedStudent.IndexID))
                {
                    return(false);
                }
            }
            else if (SelectedStudent.IndexID != null)
            {
                if (!SelectedStudent.IndexID.Equals(IndexID))
                {
                    return(false);
                }
            }

            return(true);
        }
        private void load()
        {
            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;

            Padding = new MarginPadding(10);

            InternalChildren = new Drawable[]
            {
                new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Spacing          = new Vector2(10),
                    Direction        = FillDirection.Vertical,
                    Children         = new Drawable[]
                    {
                        textBox = new LabelledTextBox
                        {
                            Label = "Time"
                        },
                        button = new TriangleButton
                        {
                            Text             = "Use current time",
                            RelativeSizeAxes = Axes.X,
                            Action           = () => changeSelectedGroupTime(clock.CurrentTime)
                        }
                    }
                },
            };

            textBox.OnCommit += (sender, isNew) =>
            {
                if (!isNew)
                {
                    return;
                }

                if (double.TryParse(sender.Text, out var newTime))
                {
                    changeSelectedGroupTime(newTime);
                }
                else
                {
                    SelectedGroup.TriggerChange();
                }
            };

            SelectedGroup.BindValueChanged(group =>
            {
                if (group.NewValue == null)
                {
                    textBox.Text = string.Empty;

                    textBox.Current.Disabled = true;
                    button.Enabled.Value     = false;
                    return;
                }

                textBox.Current.Disabled = false;
                button.Enabled.Value     = true;

                textBox.Text = $"{group.NewValue.Time:n0}";
            }, true);
        }
        private void ModifyCurrent(object sender, RoutedEventArgs e)
        {
            if (SelectedItem.GetType().Name == SelectedFaculty.GetType().Name)
            {
                InputPage ip = new InputPage((FacultyViewModel)SelectedItem, "Modify");
                ip.Owner = this;
                ip.Resources["BorderColor"]    = Resources["BorderColor"];
                ip.Resources["ButtonColor"]    = Resources["ButtonColor"];
                ip.Resources["BGColor"]        = Resources["BGColor"];
                ip.Resources["TextColor"]      = Resources["TextColor"];
                ip.Resources["FontStyle"]      = Resources["FontStyle"];
                ip.Resources["FontFamily"]     = Resources["FontFamily"];
                ip.Resources["FontSizeSmall"]  = Resources["FontSizeSmall"];
                ip.Resources["FontSizeMedium"] = Resources["FontSizeMedium"];
                ip.Resources["FontSizeLarge"]  = Resources["FontSizeLarge"];

                ip.Show();

                TreeViewAll.ItemsSource = null;
                TreeViewAll.ItemsSource = CollectionView;
            }

            if (SelectedItem.GetType().Name == SelectedGroup.GetType().Name)
            {
                InputPage ip = new InputPage((GroupViewModel)SelectedItem, "Modify");
                ip.Owner = this;
                ip.Resources["BorderColor"]    = Resources["BorderColor"];
                ip.Resources["ButtonColor"]    = Resources["ButtonColor"];
                ip.Resources["BGColor"]        = Resources["BGColor"];
                ip.Resources["TextColor"]      = Resources["TextColor"];
                ip.Resources["FontStyle"]      = Resources["FontStyle"];
                ip.Resources["FontFamily"]     = Resources["FontFamily"];
                ip.Resources["FontSizeSmall"]  = Resources["FontSizeSmall"];
                ip.Resources["FontSizeMedium"] = Resources["FontSizeMedium"];
                ip.Resources["FontSizeLarge"]  = Resources["FontSizeLarge"];

                ip.Show();

                TreeViewAll.ItemsSource = null;
                TreeViewAll.ItemsSource = CollectionView;
            }

            if (SelectedItem.GetType().Name == SelectedStudent.GetType().Name)
            {
                SelectedStudent = (StudentViewModel)SelectedItem;
                StudentInput si = new StudentInput((StudentViewModel)SelectedItem);
                si.Owner = this;
                si.Resources["BorderColor"]    = Resources["BorderColor"];
                si.Resources["ButtonColor"]    = Resources["ButtonColor"];
                si.Resources["BGColor"]        = Resources["BGColor"];
                si.Resources["TextColor"]      = Resources["TextColor"];
                si.Resources["FontStyle"]      = Resources["FontStyle"];
                si.Resources["FontFamily"]     = Resources["FontFamily"];
                si.Resources["FontSizeSmall"]  = Resources["FontSizeSmall"];
                si.Resources["FontSizeMedium"] = Resources["FontSizeMedium"];
                si.Resources["FontSizeLarge"]  = Resources["FontSizeLarge"];

                si.Show();

                TreeViewAll.ItemsSource = null;
                TreeViewAll.ItemsSource = CollectionView;
            }
        }
Beispiel #21
0
        private void load()
        {
            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;

            Padding = new MarginPadding(10)
            {
                Bottom = 0
            };

            InternalChildren = new Drawable[]
            {
                new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Spacing          = new Vector2(10),
                    Direction        = FillDirection.Vertical,
                    Children         = new Drawable[]
                    {
                        textBox = new LabelledTextBox
                        {
                            Label = "Time"
                        },
                        button = new RoundedButton
                        {
                            Text             = "Use current time",
                            RelativeSizeAxes = Axes.X,
                            Action           = () => changeSelectedGroupTime(clock.CurrentTime)
                        }
                    }
                },
            };

            textBox.OnCommit += (sender, isNew) =>
            {
                if (!isNew)
                {
                    return;
                }

                if (double.TryParse(sender.Text, out double newTime))
                {
                    changeSelectedGroupTime(newTime);
                }
                else
                {
                    SelectedGroup.TriggerChange();
                }
            };

            SelectedGroup.BindValueChanged(group =>
            {
                if (group.NewValue == null)
                {
                    textBox.Text = string.Empty;

                    // cannot use textBox.Current.Disabled due to https://github.com/ppy/osu-framework/issues/3919
                    textBox.ReadOnly     = true;
                    button.Enabled.Value = false;
                    return;
                }

                textBox.ReadOnly     = false;
                button.Enabled.Value = true;

                textBox.Text = $"{group.NewValue.Time:n0}";
            }, true);
        }
        private void Add(object sender, RoutedEventArgs e)
        {
            if (SelectedItem == null)
            {
                InputPage ip = new InputPage(new FacultyViewModel(), "Add");
                ip.Owner = this;

                ip.Resources["BorderColor"]    = Resources["BorderColor"];
                ip.Resources["ButtonColor"]    = Resources["ButtonColor"];
                ip.Resources["BGColor"]        = Resources["BGColor"];
                ip.Resources["TextColor"]      = Resources["TextColor"];
                ip.Resources["FontStyle"]      = Resources["FontStyle"];
                ip.Resources["FontFamily"]     = Resources["FontFamily"];
                ip.Resources["FontSizeSmall"]  = Resources["FontSizeSmall"];
                ip.Resources["FontSizeMedium"] = Resources["FontSizeMedium"];
                ip.Resources["FontSizeLarge"]  = Resources["FontSizeLarge"];

                ip.Show();

                TreeViewAll.ItemsSource     = null;
                TreeViewAll.ItemsSource     = CollectionView;
                Delete_All_Button.IsEnabled = true;
                Delete_All_Button.Opacity   = 1;
                return;
            }

            if (SelectedItem.GetType().Name == SelectedFaculty.GetType().Name)
            {
                SelectedFaculty = (FacultyViewModel)SelectedItem;
                InputPage ip = new InputPage(new GroupViewModel()
                {
                    Parent = SelectedFaculty
                }, "Add");
                ip.Owner = this;

                ip.Resources["BorderColor"]    = Resources["BorderColor"];
                ip.Resources["ButtonColor"]    = Resources["ButtonColor"];
                ip.Resources["BGColor"]        = Resources["BGColor"];
                ip.Resources["TextColor"]      = Resources["TextColor"];
                ip.Resources["FontStyle"]      = Resources["FontStyle"];
                ip.Resources["FontFamily"]     = Resources["FontFamily"];
                ip.Resources["FontSizeSmall"]  = Resources["FontSizeSmall"];
                ip.Resources["FontSizeMedium"] = Resources["FontSizeMedium"];
                ip.Resources["FontSizeLarge"]  = Resources["FontSizeLarge"];

                ip.Show();
                TreeViewAll.ItemsSource = null;
                TreeViewAll.ItemsSource = CollectionView;
                return;
            }

            if (SelectedItem.GetType().Name == SelectedGroup.GetType().Name)
            {
                SelectedGroup = (GroupViewModel)SelectedItem;
                StudentInput si = new StudentInput("Add new student to group \"" + SelectedGroup.Name + "\"");
                si.Owner = this;

                si.Resources["BorderColor"]    = Resources["BorderColor"];
                si.Resources["ButtonColor"]    = Resources["ButtonColor"];
                si.Resources["BGColor"]        = Resources["BGColor"];
                si.Resources["TextColor"]      = Resources["TextColor"];
                si.Resources["FontStyle"]      = Resources["FontStyle"];
                si.Resources["FontFamily"]     = Resources["FontFamily"];
                si.Resources["FontSizeSmall"]  = Resources["FontSizeSmall"];
                si.Resources["FontSizeMedium"] = Resources["FontSizeMedium"];
                si.Resources["FontSizeLarge"]  = Resources["FontSizeLarge"];

                si.Show();
                TreeViewAll.ItemsSource = null;
                TreeViewAll.ItemsSource = CollectionView;
                return;
            }

            if (SelectedItem.GetType().Name == SelectedStudent.GetType().Name)
            {
                SelectedStudent = (StudentViewModel)SelectedItem;
                Info si = new Info(SelectedStudent);
                si.Resources["BorderColor"]    = Resources["BorderColor"];
                si.Resources["ButtonColor"]    = Resources["ButtonColor"];
                si.Resources["BGColor"]        = Resources["BGColor"];
                si.Resources["TextColor"]      = Resources["TextColor"];
                si.Resources["FontStyle"]      = Resources["FontStyle"];
                si.Resources["FontFamily"]     = Resources["FontFamily"];
                si.Resources["FontSizeSmall"]  = Resources["FontSizeSmall"];
                si.Resources["FontSizeMedium"] = Resources["FontSizeMedium"];
                si.Resources["FontSizeLarge"]  = Resources["FontSizeLarge"];

                si.Show();
                return;
            }
        }