Beispiel #1
0
        public MainForm()
        {
            this.InitializeComponent();

            SettingsPage.Text = ServiceLocator.LanguageCatalog.GetString("Settings");

            var f = new Panel();

            f.BorderStyle = BorderStyle.FixedSingle;
            f.Visible     = true;

            var undoBtn = new RadButtonElement();

            undoBtn.Image      = Resources.Undo_icon;
            undoBtn.Name       = "undoBtn";
            undoBtn.ShowBorder = false;
            undoBtn.Enabled    = false;
            undoBtn.Click     += (s, e) => UndoRedoManager.Undo();

            var redoBtn = new RadButtonElement();

            redoBtn.Image      = Resources.Redo_icon;
            redoBtn.Name       = "redoBtn";
            redoBtn.ShowBorder = false;
            redoBtn.Enabled    = false;
            redoBtn.Click     += (s, e) => UndoRedoManager.Redo();

            UndoRedoManager.CommandDone += (s, e) =>
            {
                undoBtn.Enabled = UndoRedoManager.CanUndo;
                redoBtn.Enabled = UndoRedoManager.CanRedo;
            };

            this.FormElement.TitleBar.SystemButtons.Children.Insert(0, undoBtn);
            this.FormElement.TitleBar.SystemButtons.Children.Insert(1, redoBtn);

            this.host = DesignerHost.CreateHost(f, null, (sender, e) => { this.propertyGrid.SelectedObject = sender; }, false);

            this.host.AddControl(new Button());

            this.radPanel1.Controls.Add(this.host);

            this.ProductsView.Groups.Clear();

            Price.PriceChanged += (s, e) =>
            {
                this.priceLbl.DigitText = Price.Value;
                this.historyView1.Invalidate();
            };

            this.productsView1.DataSource = DbContext.ProductCollection;
            this.productsView1.BestFitColumns();

            foreach (var pc in DbContext.ProductCategoryCollection.FindAll())
            {
                var tmp = new TileGroupElement()
                {
                    Name = pc.Name, Visibility = Telerik.WinControls.ElementVisibility.Visible, Text = pc.Name, Tag = pc.id
                };

                foreach (var p in DbContext.ProductCollection.FindAll())
                {
                    var tmpItem = new RadTileElement()
                    {
                        Text = p.ID, Image = Image.FromStream(new MemoryStream(p.Image)), Name = p.ID, Tag = p.TotalPrice, Visibility = Telerik.WinControls.ElementVisibility.Visible
                    };

                    tmpItem.Click += (s, e) =>
                    {
                        Price.Add(p);
                        ServiceLocator.ProductHistory.Add(p);
                    };

                    tmp.Items.Add(tmpItem);
                }

                this.ProductsView.Groups.Add(tmp);
            }

            #if DEBUG
            Cursor.Show();
            #else
            Cursor.Hide();
            #endif

            PluginLoader.AddObject("ui", new UiClass(this));
            PluginLoader.AddObject("import", new Action <string>(c => {
                var ass = Assembly.LoadFile(c);
                foreach (var t in ass.GetTypes())
                {
                    PluginLoader.AddType(t.Name, t);
                }
            }));
        }