示例#1
0
        public static void Open_Object(ObservableCollection<Model_Object> Objects, int index, int Subject_Security_Level, bool On_Creating)
        {
            if (index < 0)
            {
                MessageBox.Show("Выберите заметку");
                return;
            }
            Model_Object Object = Objects[index];
            string directory = $"{Directory.GetCurrentDirectory()}\\{Object.Model_Name}\\{Object.Name}.txt";
            if (!File.Exists(directory))
            {
                MessageBox.Show("Заметка не существует!"); Objects.RemoveAt(index);
                return;
            }
            if (Object.Security_Level < Subject_Security_Level && !On_Creating)
            {
                MessageBox.Show("Недостаточно прав!");
                return;
            }
            Object_Editor_Window object_editor = new Object_Editor_Window(directory, Object.Security_Level <= Subject_Security_Level);

            if (object_editor.ShowDialog() == true)
            {
                Objects.RemoveAt(index);
            }
        }
示例#2
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (MessageBox.Show("Сохранить изменения?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                Model_Object[] objects = new Model_Object[All_Objects.Count];
                All_Objects.CopyTo(objects, 0);
                foreach (Model_Object o in objects)
                {
                    if (o.Security_Level >= Current_User.Security_Level &&
                        !Objects.Contains(o) ||
                        (Objects.Any(obj => obj.Name == o.Name && obj.Security_Level != o.Security_Level)))
                    {
                        All_Objects.Remove(o);
                    }
                }
                foreach (Model_Object o in Objects)
                {
                    if (!objects.Contains(o))
                    {
                        All_Objects.Add(o);
                    }
                }

                Model.Save_Model(Model_Name, All_Objects);
            }
        }