Exemplo n.º 1
0
        public Graphic(user a, picture p)
        {
            InitializeComponent();
            ic.MouseLeftButtonUp += Strokes_StrokesChanged;
            Saves.Add(ic.Strokes.Clone());
            logged = a;
            try
            {
                var fs = new FileStream(p.path,
                                        FileMode.Open, FileAccess.Read);
                StrokeCollection strokes = new StrokeCollection(fs);
                ic.Strokes = strokes;

                BitmapImage bmpbg = new BitmapImage();
                bmpbg.BeginInit();
                bmpbg.StreamSource = new MemoryStream(p.bg);
                bmpbg.EndInit();
                background.Source     = bmpbg;
                background.Visibility = Visibility.Visible;
            }
            catch { }
            Saves.Add(ic.Strokes.Clone());
            Sliderink.Visibility = Visibility.Visible;

            ic.DefaultDrawingAttributes.Width  = 4;
            ic.DefaultDrawingAttributes.Height = 4;
            ic.EditingMode = InkCanvasEditingMode.None;
            ic.EditingMode = InkCanvasEditingMode.Ink;
        }
Exemplo n.º 2
0
        public gallerytemplate(picture p, user u)
        {
            InitializeComponent();

            iddd.Text        = p.painting_id.ToString();
            owner.Text       = p.username;
            description.Text = p.descript;
            descrip.Text     = p.descript;
            datet.Text       = p.date_created.ToString();
            logged           = u;
            P = p;
            if (logged.username == p.username)
            {
                description.IsEnabled = true;
                continue_.IsEnabled   = true;
                del.IsEnabled         = true;
                edit.IsEnabled        = true;
            }
            if (logged.role == "admin")
            {
                owner.IsEnabled       = true;
                description.IsEnabled = true;
                continue_.IsEnabled   = true;
                del.IsEnabled         = true;
                edit.IsEnabled        = true;
            }
            else
            {
                owner.IsEnabled = false;
            }
        }
Exemplo n.º 3
0
        void show(picture p, bool color)
        {
            gallerytemplate a = new gallerytemplate(p, logged);

            if (color == true)
            {
                a.usersitem.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#992A1C64"));
            }
            BitmapImage bi = new BitmapImage();

            bi.BeginInit();
            bi.StreamSource = new MemoryStream(p.painting);
            bi.EndInit();
            a.img.Source = bi;
            if (counter % 3 == 0)
            {
                this.stack_to_add.Children.Add(a);
            }
            else if (counter % 2 == 0)
            {
                this.stack_to_add1.Children.Add(a);
            }
            else if (counter % 1 == 0)
            {
                this.stack_to_add2.Children.Add(a);
            }
            counter -= 1;
            if (counter == 0)
            {
                counter = 3;
            }
        }
Exemplo n.º 4
0
        private void SaveintoGallery(object sender, RoutedEventArgs e)
        {
            Infopicker inf = new Infopicker("Название или описание вашего эскиза:");

            if (inf.ShowDialog() == true)
            {
                try
                {
                    Save(temppic);
                    StrokeCollection t = new StrokeCollection(ic.Strokes);
                    ic.Strokes.Clear();
                    Save(tempbackg);
                    ic.Strokes = t;

                    var fs1 = new FileStream(tempstrokes, FileMode.Create, FileAccess.ReadWrite);
                    ic.Strokes.Save(fs1);
                    fs1.Close();

                    string str = "null";

                    using (painDB_Entities db = new painDB_Entities())
                    {
                        str = inf.write.Text;
                        string path = Environment.CurrentDirectory.ToString() + $@"\Resources\Data\stroke_copies\{str}.bmp";

                        byte[] buffer       = File.ReadAllBytes(temppic);
                        string base64String = Convert.ToBase64String(buffer, 0, buffer.Length);
                        byte[] bufferdata   = Convert.FromBase64String(base64String);

                        byte[] bufferbg       = File.ReadAllBytes(tempbackg);
                        string base64Stringbg = Convert.ToBase64String(bufferbg, 0, bufferbg.Length);
                        byte[] bufferdatabg   = Convert.FromBase64String(base64Stringbg);

                        picture p1 = new picture {
                            username = logged.username, painting = bufferdata, date_created = DateTime.Now,
                            descript = str, path = path, bg = bufferdatabg
                        };

                        db.pictures.Add(p1);
                        db.SaveChanges();
                        //сохраняю штрихи в хранилище
                        var fs = new FileStream(path, FileMode.Create);
                        ic.Strokes.Save(fs);
                    }
                }
                catch (Exception ex) { Message exept = new Message(ex.Message); exept.ShowDialog(); }
            }
        }