Example #1
0
 private void AddItem()
 {
     if (SelectedItem is Model.Page)
     {
         var page    = SelectedItem as Model.Page;
         var element = new Element()
         {
             Name = "Новое поле " + (page.Elements.Count + 1), Value = "Новое поле " + (page.Elements.Count + 1)
         };
         page.Elements.Add(element);
         SelectedItem = element;
     }
     else if (SelectedItem is Element)
     {
         var page    = CurrentForm.Pages.Single(p => p.Elements.Contains(SelectedItem as Element));
         var element = new Element()
         {
             Name = "Новое поле " + (page.Elements.Count + 1), Value = "Новое поле " + (page.Elements.Count + 1)
         };
         page.Elements.Add(element);
         SelectedItem = element;
     }
     else if (CurrentForm != null)
     {
         var page = new formPrinter.Model.Page()
         {
             Name = "Новая страница " + (CurrentForm.Pages.Count + 1)
         };
         CurrentForm.Pages.Add(page);
         SelectedItem = page;
     }
 }
Example #2
0
        private void New()
        {
            var form = new Form()
            {
                Name = "Новый бланк"
            };
            var page = new Model.Page()
            {
                Name = "Страница 1", Height = 29.7, Width = 21
            };

            page.Elements.Add(new Element()
            {
                Name = "Новое поле", Value = "Новое поле"
            });
            form.Pages.Add(page);
            Forms.Add(form);
            CurrentForm            = form;
            CurrentForm.HasChanges = false;
        }
Example #3
0
        private void LoadTest()
        {
            using (Stream file = Application.GetResourceStream(new Uri("pack://application:,,,/new.frmx")).Stream)
            {
                file.Position = 0;
                System.Xml.Serialization.XmlSerializer reader =
                    new System.Xml.Serialization.XmlSerializer(typeof(Form));

                var form = (Form)reader.Deserialize(file);
                Forms.Add(form);
                form.HasChanges = false;
                CurrentForm     = form;
            }


            return;



            var Form = new Form();

            Form.Name = "Мой бланк 1";
            Forms.Add(Form);

            CurrentForm = Form;

            var page = new formPrinter.Model.Page();

            page.Width  = 21;
            page.Height = 15;
            page.Name   = "Страница 1";


            Stream picStream = Application.GetResourceStream(new Uri("pack://application:,,,/новый файл.jpg")).Stream;

            picStream.Position = 0;
            byte[] bytes = new byte[picStream.Length];
            picStream.Read(bytes, 0, (int)picStream.Length);
            page.Image = formPrinter.Model.Page.ImageFromBytes(bytes);

            Form.Pages.Add(page);

            var element = new Element();

            element.Name   = "Number";
            element.X      = 3;
            element.Y      = 5;
            element.Height = 1;
            element.Width  = 6;
            element.Value  = "Some text";
            page.Elements.Add(element);

            element             = new Element();
            element.Name        = "Date";
            element.ElementType = ElementType.Calendar;
            element.X           = 7;
            element.Y           = 4;
            element.Height      = 1;
            element.Width       = 6;
            element.Value       = "01.05.2012";
            page.Elements.Add(element);


            element             = new Element();
            element.Name        = "Date";
            element.ElementType = ElementType.List;
            element.ListChoisesSeparetedText = "apple;mint;berry";

            element.X      = 3;
            element.Y      = 8;
            element.Height = 1;
            element.Width  = 6;
            element.Value  = "apple";
            page.Elements.Add(element);

            element             = new Element();
            element.Name        = "Date";
            element.ElementType = ElementType.Text;
            element.X           = 13;
            element.Y           = 5;
            element.Height      = 1;
            element.Width       = 6;
            element.Value       = "True";
            page.Elements.Add(element);

            page = new formPrinter.Model.Page();



            page.Image = formPrinter.Model.Page.ImageFromBytes(bytes);

            page.Width  = 21;
            page.Height = 29.7;
            page.Name   = "Page 2";

            Form.Pages.Add(page);

            element        = new Element();
            element.Name   = "Number";
            element.X      = 3;
            element.Y      = 5;
            element.Height = 1;
            element.Width  = 6;
            element.Value  = "Some text";
            page.Elements.Add(element);
        }