コード例 #1
0
 void Start()
 {
     if (Grid == null)
     {
         Grid = FindObjectOfType <ElementGrid>();
     }
 }
コード例 #2
0
        public void Test_ElementGrid()
        {
            ElementGrid grid = new ElementGrid(0, 0, 2, 2);
            Label       a    = new Label(0, 0, "A1");
            Label       b    = new Label(0, 0, "B");
            Label       c    = new Label(0, 0, "C");
            Rectangle   d    = new Rectangle(0, 0, 1, 2);

            grid.AddElement(a);
            grid.AddElements(b, c);
            grid.AddElements(d);

            grid.Reorder();

            Assert.AreEqual(4, grid.Width);
            Assert.AreEqual(4, grid.Height);

            Assert.AreEqual(0, a.X);
            Assert.AreEqual(2, b.X);
            Assert.AreEqual(0, c.X);
            Assert.AreEqual(2, d.X);

            Assert.AreEqual(0, a.Y);
            Assert.AreEqual(0, b.Y);
            Assert.AreEqual(2, c.Y);
            Assert.AreEqual(2, d.Y);
        }
コード例 #3
0
        private void znajdzPrzepisSkladnikaAkcja()
        {
            ElementGrid e  = listaPrzepisowSkladnikaSelection;
            int         id = e.ID;

            tabControlIndex = 0;
            wypiszPrzepisy(id);
        }
コード例 #4
0
        private void dodajSkladnikAkcja()
        {
            ElementGrid pTest = null;

            if (ParentVM.listaSkladnikow.Count > 0)
            {
                try
                {
                    pTest = ParentVM.listaSkladnikow.First(x => x.NAZWA == nazwa);
                }
                catch (Exception)
                {
                    pTest = null;
                }
            }
            if (pTest == null)
            {
                EntityMethods en = new EntityMethods();
                Skladniki     s  = new Skladniki();
                s.NAZWA        = nazwa;
                s.OPIS         = opis;
                s.UWAGI        = uwagi;
                s.ID_KATEGORII = en.idKategoriiSkladnika(kategorieSelection);
                if (isEdit)
                {
                    s.ID_SKLADNIKA = (int)idEdytowanegoSkladnika;
                    if (zdjecie.GetType() == typeof(BitmapImage))
                    {
                        string path  = ((BitmapImage)zdjecie).UriSource.OriginalString;
                        byte[] image = File.ReadAllBytes(path);
                        s.ZDJECIE = image;
                    }
                    else
                    {
                        s.ZDJECIE = null;
                    }
                    en.edytujSkladnik(s);
                }
                else
                {
                    string path  = ((BitmapImage)zdjecie).UriSource.OriginalString;
                    byte[] image = File.ReadAllBytes(path);
                    s.ZDJECIE = image;
                    idEdytowanegoSkladnika = en.dodajSkladnik(s);
                }
                CloseAction();
                ParentVM.wypiszSkladniki(idEdytowanegoSkladnika);
            }
            else
            {
                MessageBoxShow mb = new MessageBoxShow();
                mb.pokazMessageBox("Informacja", "Został już dodany taki składnik.", MessageBoxTyp.Normalny, MessageBoxIkona.Informacyjna);
            }
        }
コード例 #5
0
ファイル: ElementGridTests.cs プロジェクト: tombogle/saymore
 public void Setup()
 {
     _grid      = new ElementGrid();
     _tmpFolder = new TemporaryFolder("ElementGridTests");
 }
コード例 #6
0
        private void dodajPrzepisAkcja()
        {
            EntityMethods en = new EntityMethods();

            ElementGrid pTest = null;

            if (ParentVM.listaPrzepisow.Count > 0)
            {
                try
                {
                    pTest = ParentVM.listaPrzepisow.First(x => x.NAZWA == nazwa);
                }
                catch (Exception)
                {
                    pTest = null;
                }
            }
            if (pTest == null)
            {
                Przepisy p = new Przepisy();
                p.NAZWA        = nazwa;
                p.NOTATKI      = notatki;
                p.OPIS         = opis;
                p.ILOSC_PORCJI = Double.Parse(iloscPorcji);
                p.ID_KATEGORII = en.idKategoriiPrzepisu(kategorieSelection);
                int czas = 0;
                if (czasH != null)
                {
                    czas = Int32.Parse(czasH) * 60 + Int32.Parse(czasM);
                }
                else
                {
                    czas = Int32.Parse(czasM);
                }
                p.CZAS_PRZYRZADZENIA = czas;
                if (isEdit == false)
                {
                    string path  = ((BitmapImage)zdjecie).UriSource.OriginalString;
                    byte[] image = File.ReadAllBytes(path);
                    p.ZDJECIE = image;

                    idEdytowanegoPrzepisu = en.dodajPrzepis(p);
                }
                else
                {
                    if (zdjecie.GetType() == typeof(BitmapImage))
                    {
                        string path  = ((BitmapImage)zdjecie).UriSource.OriginalString;
                        byte[] image = File.ReadAllBytes(path);
                        p.ZDJECIE = image;
                    }
                    else
                    {
                        p.ZDJECIE = null;
                    }

                    p.ID_PRZEPISU = (int)idEdytowanegoPrzepisu;

                    en.edytujPrzepis(p);

                    en.czyscPrzepisySkladniki((int)idEdytowanegoPrzepisu);
                }

                List <Przepisy_Skladniki> lista = new List <Przepisy_Skladniki>();
                foreach (SkladnikPrzepisu sp in listaSkladnikow)
                {
                    Przepisy_Skladniki ps = new Przepisy_Skladniki();
                    ps.L_ID_PRZEPISU = (int)idEdytowanegoPrzepisu;
                    if (sp.ILOSC != null)
                    {
                        ps.ILOSC = sp.ILOSC;
                    }
                    if (!String.IsNullOrWhiteSpace(sp.JEDNOSTKA))
                    {
                        ps.ID_JEDNOSTKI = en.pobierzIdJednostki(sp.JEDNOSTKA);
                    }
                    ps.L_ID_SKLADNIKA = en.idSkladnika(sp.NAZWA);
                    en.dodajPrzepisySkladniki(ps);
                }

                ParentVM.wypiszPrzepisy((int)idEdytowanegoPrzepisu);
                CloseAction();
            }
            else
            {
                MessageBoxShow mb = new MessageBoxShow();
                mb.pokazMessageBox("Informacja", "Został już dodany taki przepis.", MessageBoxTyp.Normalny, MessageBoxIkona.Informacyjna);
            }
        }
コード例 #7
0
        static void Main()
        {
            using UiHub uiHub = UiHub.Register(80, 25, true);

            uiHub.Title = "Demo";

            View mainView = uiHub.AddView("Main");

            ElementList elementList = new ElementList(30, 10, false);

            Label a = new Label(0, 0, "Hellooo");
            Label b = new Label(0, 0, "World");
            Label c = new Label(0, 0, "!!");

            Label d = new Label(20, 0, 50, 1);

            ElementGrid elementGrid = new ElementGrid(60, 2, 2, 2);

            Rectangle r1 = new Rectangle(0, 0, 3, 2)
            {
                Filler = '#'
            };
            Rectangle r2 = new Rectangle(0, 0, 1, 3)
            {
                Filler = '-'
            };
            Rectangle r3 = new Rectangle(0, 0, 1, 1);
            Rectangle r4 = new Rectangle(0, 0, 1, 1)
            {
                Filler = '0'
            };

            elementGrid.AddElements(r1, r2, r3, r4);
            elementGrid.Reorder();


            elementList.AddElements(a, b, c);

            elementList.Reorder();

            mainView.AddElements(a, b, c, d);
            mainView.AddElements(r1, r2, r3, r4);


            Label label = mainView.AddElement(new Label(0, 0, 10, 1));

            mainView.AddElement(new Button(10, 5, 20, 4, "Button 1")).Pressed += () =>
            {
                label.Text             = "Pressed B1";
                elementList.Horizontal = !elementList.Horizontal;
            };
            mainView.AddElement(new Button(10, 10, 20, 4, "Button 2")).Pressed += () =>
            {
                label.Text    = "Pressed B2";
                elementList.X = 30 + ((elementList.X + 1) % 10);
            };

            RotoList <int> rotoList = new RotoList <int>(0, 15, 20, 1);

            rotoList.ChangedElement += e =>
            {
                label.Text          = "Switch " + e.Value.ToString();
                elementList.Padding = e.Value;
            };

            rotoList.SetElements(new[]
            {
                new RotoList <int> .Element <int>("One", 1),
                new RotoList <int> .Element <int>("Two", 2),
                new RotoList <int> .Element <int>("Three", 3),
                new RotoList <int> .Element <int>("Pi", 4),
            });

            mainView.AddElement(rotoList);

            uiHub.UnhandledKeyPress += (s, e) => d.Text = $"I: {e.KeyInfo.Modifiers}+{e.KeyInfo.Key}";

            uiHub.Run();
        }
コード例 #8
0
 public virtual void Enter()
 {
     ElementGrid.instance.SetType(floor.location, ElementGrid.ElementTotype(stateMachine.currentStateEnum));
 }