Esempio n. 1
0
 public void Flags()
 {
     var Test = new NotebookDialog<FlagsTest>("Which is good?");
     FlagsTest Result = new FlagsTest();
     
     Assert.IsTrue(Test.Run(Result));
     Assert.AreEqual(Fruit.Apple | Fruit.Banana, Result.Choose);
     Assert.AreEqual(Fruit.Apple | Fruit.Banana, Result.Choose2);
 }
Esempio n. 2
0
 public void Simplest()
 {
     var Present = new NotebookDialog<Test>("Doe, Female, Yes");
     var SaveTo = new Test();
     Assert.IsTrue(Present.Run(SaveTo));
     Assert.AreEqual("Doe", SaveTo.Surname);
     Assert.AreEqual(Sex.Female, SaveTo.Gender);
     Assert.IsTrue(SaveTo.Newsletter);
 }
Esempio n. 3
0
        public void Echo()
        {
            NotebookDialog<RepeatTest> Echo = new NotebookDialog<RepeatTest>("I'm a parrot");

            var Test = new RepeatTest();

            Assert.IsTrue(Echo.Run(Test));
            Assert.IsTrue(Echo.Run(Test));
        }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();

            NotebookDialog<Test> T = new NotebookDialog<Test>("Title here");
            Test Store = new Test();
            T.Run(Store);

            Console.WriteLine(Store.Toggle);
            Console.WriteLine(Store.Entry);
            Console.WriteLine(Store.Color);
        }
Esempio n. 5
0
        public void Repeating()
        {
            NotebookDialog<RepeatTest> Repeater = new NotebookDialog<RepeatTest>("First empty");

            var Test1 = new RepeatTest();
            var Test2 = new RepeatTest();

            Repeater.Run(Test1);
            Repeater.Run(Test2);

            Assert.IsFalse(Test1.Hey);
            Assert.IsEmpty(Test1.Hoi);

            Assert.IsTrue(Test2.Hey);
            Assert.IsNotEmpty(Test2.Hoi);
        }
Esempio n. 6
0
        /// <summary>
        /// Show edit notebook dialog
        /// </summary>
        public void EditNotebook(object sender)
        {
            var notebook = (Models.Notebook.Notebook)sender;

            var dialog = new NotebookDialog();

            dialog.Closing += (s, e) =>
            {
                if (dialog.DataContext is AddNotebookViewModel vm && vm.Notebook != null)
                {
                    SelectedNotebookItem.Notebook = vm.Notebook;
                }
            };

            dialog.ShowDialogWindow(new AddNotebookViewModel(dialog, notebook));
        }
Esempio n. 7
0
        public void Filling()
        {
            NotebookDialog<MultiTest> Filler = new NotebookDialog<MultiTest>("All filled?");

            MultiTest Filled =  new MultiTest();
            Filled.Answer = 42;
            Filled.Back = Direction.Back;
            Filled.Black = new ushort [] { 0, 0, 0 };
            Filled.Check = true;
            Filled.Fr = Fruit.Apple | Fruit.Orange;
            Filled.Hosts = "/etc/hosts";
            Filled.Newyear = new DateTime(System.DateTime.Now.Year, 1, 1);
            Filled.Wuppertahl = "wuppertahl";

            Assert.IsTrue(Filler.Run(Filled));
        }
Esempio n. 8
0
        public void Saving()
        {
            NotebookDialog<MultiTest> Saver = new NotebookDialog<MultiTest>("Do comply");

            var Test = new MultiTest();

            Assert.IsTrue(Saver.Run(Test));

            Assert.AreEqual("wuppertahl", Test.Wuppertahl.ToLower());
            Assert.AreEqual(42, Test.Answer);
            Assert.AreEqual(1, Test.Newyear.DayOfYear);
            Assert.IsTrue(Test.Check);

            Assert.AreEqual("/etc/hosts", Test.Hosts);
            Assert.AreEqual(Direction.Back, Test.Back);
            Assert.AreEqual(new ushort[] { 0, 0, 0 }, Test.Black);
            Assert.AreEqual(Fruit.Apple | Fruit.Orange, Test.Fr);
        }
Esempio n. 9
0
        public void Grouping()
        {
            GroupingTest Save = new GroupingTest();

            IModalPresenter Present = new NotebookDialog<GroupingTest>(Title);
            Assert.IsTrue(Present.Run(Save));

            Present = new ListStoreDialog<GroupingTest>(Title);
            Assert.IsTrue(Present.Run(Save));

            Present = new TreeStoreDialog<GroupingTest>(Title);
            Assert.IsTrue(Present.Run(Save));

            var NonModal = new WizardDialog<GroupingTest>(Title);
            NonModal.Run(Save);
            NonModal.Block();
            Assert.IsTrue(NonModal.Success);
        }
Esempio n. 10
0
        /// <summary>
        /// Add new notebook dialog
        /// </summary>
        public void AddNotebook()
        {
            var dialog = new NotebookDialog();

            dialog.Closing += (s, e) =>
            {
                if (dialog.DataContext is AddNotebookViewModel vm && vm.Notebook != null)
                {
                    if (!NotebookItems.Any(x => x.Notebook == vm.Notebook))
                    {
                        NotebookItems.Insert(0, new NotebookItem
                        {
                            Notebook = vm.Notebook,

                            EditNotebookCommand   = new RelayParameterizedCommand(EditNotebook),
                            DeleteNotebookCommand = new RelayParameterizedCommand(DeleteNotebook)
                        });
                    }
                }
            };

            dialog.ShowDialogWindow(new AddNotebookViewModel(dialog));
        }
Esempio n. 11
0
 public void Sizing()
 {
     var Test = new NotebookDialog<SizingTest>("Different size");
     var Result = new SizingTest();
     Assert.IsTrue(Test.Run(Result));
 }
Esempio n. 12
0
        public void DateTime()
        {
#if QYOTO
            const string Title = "Formatted date";
#endif
#if GTK
            const string Title = "Changed calendar";
#endif
            var Dialog = new NotebookDialog<DateTimeTest>(Title);
            Assert.IsTrue(Dialog.Run(new DateTimeTest()));
        }
Esempio n. 13
0
 public void Numbers()
 {
     NotebookDialog<NumberTest> Test = new NotebookDialog<NumberTest>("Correct entries?");
     var Store = new NumberTest();
     Assert.IsTrue(Test.Run(Store));
 }
Esempio n. 14
0
 public void Changing()
 {
     Dialog = new NotebookDialog<Change>("Selene");
     Dialog.SubscribeAllChange<Change>(HandleChange);
     
     Assert.IsTrue(Dialog.Run(new Change()));
     Assert.AreEqual(10, TimesChanged);
 }
Esempio n. 15
0
        public void ListView()
        {
            var Disp = new NotebookDialog<Container>("Add one person");
            var Test = new Container();
            Assert.IsTrue(Disp.Run(Test));
            Assert.AreEqual(2, Test.People.Length);

            var Disp2 = new NotebookDialog<EditListGrey>("Add/Remove grey");
            var Test2 = new EditListGrey();
            Assert.IsTrue(Disp2.Run(Test2));

            var Disp3 = new NotebookDialog<EditListInv>("Invisible add/remove");
            var Test3 = new EditListInv();
            Assert.IsTrue(Disp3.Run(Test3));
            
            var Disp4 = new NotebookDialog<NonEditList>("Disabled inline edit");
            var Test4 = new NonEditList();
            Assert.IsTrue(Disp4.Run(Test4));
        }
Esempio n. 16
0
 public void Labeling()
 {
     var Present = new NotebookDialog<LabelingTest>("OK if values match and dialog title given");
     LabelingTest Save = new LabelingTest();
     Assert.IsTrue(Present.Run(Save));
 }
Esempio n. 17
0
 public void Serializing()
 {
     var Disp = new NotebookDialog<Person>("Selene demo application");
     var Test = Person.Load(Filename);
     Assert.IsTrue(Disp.Run(Test));
     Test.Save(Filename);
 }
Esempio n. 18
0
        public void Manifest()
        {
            if(Stub()) return;

            var Disp = new NotebookDialog<ManifestTest>("OK if loaded correctly");
            var Feed = new ManifestTest();
            Assert.IsTrue(Disp.Run(Feed));
        }
Esempio n. 19
0
 public void Toggle()
 {
     var Present = new NotebookDialog<ToggleTest>("Should toggle");
     var Save = new ToggleTest();
     Assert.IsTrue(Present.Run(Save));
 }
Esempio n. 20
0
        public void Embedding()
        {
            var Embed = new NotebookDialog<EmbeddingTest>("Selene");
            var Test = new EmbeddingTest();

            const string WindowTitle = "Selene";
            const string LabelText = "This label is not part of the notebook";
            const string ButtonText = "Neither is this button";

#if GTK
            Window Container = new Window(WindowTitle);
            Label Extra = new Label(LabelText);
            Button Click = new Button(ButtonText);
            VBox Box = new VBox();

            Click.Clicked += delegate {
                Embed.Save();
                Console.WriteLine(Test.Alpha);
            };
            Box.Add(Embed.Content(Test));
            Box.Add(Extra);
            Box.Add(Click);
            Container.BorderWidth = 5;
            Box.Spacing = 5;
            Container.Add(Box);
            Container.ShowAll();
#endif
#if QYOTO
            QDialog Dialog = new QDialog();
            QVBoxLayout MainLay = new QVBoxLayout();
            QHBoxLayout Lay = (QHBoxLayout) Embed.Content(Test);
            MainLay.AddLayout(Lay);
            Dialog.SetLayout(MainLay);
            Dialog.SetWindowTitle(WindowTitle);

            QLabel Label = new QLabel(LabelText);
            QPushButton Button = new QPushButton(ButtonText);
            MainLay.AddWidget(Label);
            MainLay.AddWidget(Button);

            QWidget.Connect(Button, Qt.SIGNAL("clicked()"), delegate {
                Embed.Save();
                Console.WriteLine(Test.Alpha);
            });

            Dialog.Exec();
#endif
#if WINDOWS
            Form MainForm = new Form();
            ControlVBox MainBox = new ControlVBox(5,5);
            MainForm.Text = WindowTitle;

            var Content = Embed.Content(Test);
            Content.AutoSize = true;
            MainBox.Controls.Add(Content);

            Label L = new Label();
            L.Text = LabelText;
            L.AutoSize = true;
            MainBox.Controls.Add(L);

            Button B = new Button();
            B.Text = ButtonText;
            B.Click += delegate {
                Embed.Save();
                Console.WriteLine(Test.Alpha);
            };
            MainBox.Controls.Add(B);

            MainForm.Controls.Add(MainBox);

            MainForm.AutoSize = true;
            MainForm.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            MainForm.Show();
#endif
        }