Exemplo n.º 1
0
        static void Main()
        {
            RecipeBooks.SetCurrent();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                using (var content = new Tabs())
                using (var form = new Form { Text = "Recipe Book", AutoSize = true })
                {
                    form.Controls.Add(content);
                    Application.ThreadException += (o, e) =>
                    {
                        Utils.Alert("I'm sorry, an unhandled error has occurred in the application", "Oh no!");
                        Utils.LogAnyErrors(e.Exception);
                        Application.ExitThread();
                    };
                    Application.Run(form);
                }
            }
            finally
            {
                Utils.TryInvoke(RecipeBooks.Current.Save);
            }
        }
Exemplo n.º 2
0
        public Form1()
        {
            InitializeComponent();

            this.itemEditor1.SetItem(new RecipeBook.Domain.Item() { Name = "bob", Category = Domain.Category.Frozen, AssumeIsInStock = true, UnitType = Domain.UnitType.VolumeStandard, DefaultBuyUnit = Domain.Unit.Cup, DefaultRecipeUnit = Domain.Unit.FluidOunce });
            Domain.Item item;
            IList<string> msgs;
            this.itemEditor1.TryGetItem(out item, out msgs);

            var test = new Button { Text = "test" };
            test.Click += (o, e) =>
            {
                this.itemEditor1.SetReadOnly(!this.itemEditor1.ReadOnly);

                if (new Random().Next() % 2 == 0)
                {
                    this.recipeEditor1.SetReadOnly(!this.recipeEditor1.ReadOnly);
                    Recipe r; IList<string> errs;
                    this.recipeEditor1.TryGetRecipe(out r, out errs);
                    if (r != null)
                        Utils.Alert("Got recipe with " + r.Ingredients.Count + " ings ");
                }
                else
                {
                    this.recipeEditor1.CheckBoxMode = !this.recipeEditor1.CheckBoxMode;
                    Utils.Alert(this.recipeEditor1.GetIngredients().Count.ToString());
                }
            };
            this.Controls.Add(test);

            var tabs = new Tabs { Dock = DockStyle.Fill };
            this.Controls.Add(tabs);
            tabs.BringToFront();
            this.Width += 200;
            this.Height += 200;
        }