コード例 #1
0
 public void SendImageToClient(MyImage image)
 {
     if (ReceiveImageEvent != null)
     {
         ReceiveImageEvent(image);
     }
 }
コード例 #2
0
        public SelectRectangleViewModel()
        {
            MouseLeftDownPoint       = new ReactivePropertySlim <RoixBorderPoint>(mode: ReactivePropertyMode.None);
            MouseLeftUpPoint         = new ReactivePropertySlim <RoixBorderPoint>(mode: ReactivePropertyMode.None);
            MouseMovePoint           = new ReactivePropertySlim <RoixBorderPoint>();
            ViewBorderSize           = new ReactivePropertySlim <RoixSize>(mode: ReactivePropertyMode.DistinctUntilChanged);
            SelectedRectangleToModel = new ReactivePropertySlim <RoixIntRect>();

            var imageSourceSize = MyImage.ToRoixIntSize();

            // 画像座標系の選択枠(これを基準に管理する) マウス操作中に枠を更新 + 操作完了時に枠位置を通知する
            var selectedRectangleOnImage = MouseMovePoint
                                           .Select(latestPoint => (startPoint: MouseLeftDownPoint.Value, latestPoint))
                                           .Where(x => x.startPoint != x.latestPoint)
                                           .SkipUntil(MouseLeftDownPoint.ToUnit())
                                           .TakeUntil(MouseLeftUpPoint.ToUnit())
                                           .Finally(() =>
            {
                var(startPoint, latestPoint) = (MouseLeftDownPoint.Value, MouseLeftUpPoint.Value);
                if (startPoint == default || latestPoint == default || startPoint == latestPoint)
                {
                    return;
                }

                SelectedRectangleToModel.Value = RoixBorderIntRect.Create(startPoint, latestPoint, imageSourceSize).Roi;
            })
                                           .Repeat()
                                           .Select(x => RoixBorderIntRect.Create(x.startPoint, x.latestPoint, imageSourceSize))
                                           .ToReadOnlyReactivePropertySlim();

            // View座標系の選択枠
            SelectedRectangle = selectedRectangleOnImage
                                .CombineLatest(ViewBorderSize, (rect, border) => rect.ConvertToNewBorder(border).Roi)
                                .ToReadOnlyReactivePropertySlim();
        }
コード例 #3
0
        public T Convert(T source, params object[] prms)
        {
            if (prms.Length != 1)
            {
                throw new Exception("Неверное количсетво параметров");
            }
            if (!(prms[0] is int))
            {
                throw new Exception("Параметр должен быть int");
            }
            int bound = (int)prms[0];

            if (bound < 0 || bound > 255)
            {
                throw new BoundException <int>(bound, "Параметр должен быть в диапазоне от 0 до 255");
            }
            var    converter = new GrayscaleConverter <T>();
            var    dst       = new MyImage(source.Width, source.Height);
            object img       = dst;

            img = converter.Convert(source);
            dst = (MyImage)img;
            Parallel.For(0, source.Width, i =>
            {
                Parallel.For(0, source.Height, j =>
                {
                    int rescolor = dst[i, j].R > bound ? 255 : 0;
                    dst[i, j]    = Color.FromArgb(rescolor, rescolor, rescolor);
                });
            });
            img = dst;
            return((T)img);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: alexZajac/image-processing
        /// <summary>
        /// Montre l'innovation HDR en fonction de la suite d'images choisie
        /// </summary>
        /// <param name="tableauImages"></param>
        static void ShowHDR(string[] tableauImages)
        {
            MyImage test    = new MyImage(tableauImages[0]);
            MyImage test1   = new MyImage(tableauImages[1]);
            MyImage test2   = new MyImage(tableauImages[2]);
            MyImage test3   = new MyImage(tableauImages[3]);
            MyImage Weight  = test.GetOverallWeightMap(0.9);
            MyImage Weight1 = test1.GetOverallWeightMap(1);
            MyImage Weight2 = test2.GetOverallWeightMap(1);
            MyImage Weight3 = test3.GetOverallWeightMap(0.9); // On crée les images caractéristiques

            MyImage[] tab = { Weight, Weight1, Weight2, Weight3 };
            Weight.NormalizeWeight(tab);
            Weight1.NormalizeWeight(tab);
            Weight2.NormalizeWeight(tab);
            Weight3.NormalizeWeight(tab);
            MyImage[] Images = { test, test1, test2, test3 }; // On les normalise

            MyImage Naive = test1.NaiveBlending(tab, Images);

            Naive.PostProcessing();
            Naive.From_Image_To_File("HDR.bmp");
            test.From_Image_To_File("image1.bmp");
            test1.From_Image_To_File("image2.bmp");
            test2.From_Image_To_File("image3.bmp");
            test3.From_Image_To_File("image4.bmp");
            Process.Start("image1.bmp");
            Process.Start("image2.bmp");
            Process.Start("image3.bmp");
            Process.Start("image4.bmp");
            Process.Start("HDR.bmp");
        }
コード例 #5
0
        public T Convert(T source, params object[] prms)
        {
            if (prms.Length != 1)
            {
                throw new Exception("Неверное количсетво параметров");
            }
            if (!(prms[0] is double))
            {
                throw new Exception("Параметр должен быть double");
            }
            double c = (double)prms[0];

            if (Math.Abs(c) < 10e-9)
            {
                throw new BoundException <double>(c, "Параметер не может быть равен нулю");
            }
            var dst = new MyImage(source.Width, source.Height);;

            for (int i = 0; i < dst.Width; i++)
            {
                for (int j = 0; j < dst.Height; j++)
                {
                    double dR = c * Math.Log(1 + source[i, j].R);
                    double dG = c * Math.Log(1 + source[i, j].G);
                    double dB = c * Math.Log(1 + source[i, j].B);
                    dst[i, j] = Color.FromArgb(Norm(dR), Norm(dG), Norm(dB));
                }
            }

            object img = dst;

            return((T)img);
        }
コード例 #6
0
 private void MyImage_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
 {
     //クリック位置取得
     MyPoint = e.GetPosition(this);
     //マウスがScrollViewer外になってもドラッグ移動を有効にしたいときだけ必要
     MyImage.CaptureMouse();
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: alexZajac/image-processing
        /// <summary>
        /// Montre l'innovation "Double exposition"
        /// </summary>
        /// <param name="item"></param>
        /// <param name="mask"></param>
        static void ShowDoubleExposure(string item, string mask)
        {
            MyImage Item      = new MyImage(item);
            MyImage landscape = new MyImage(mask);
            MyImage Mask      = Item.GetMask();

            int[] Infos = Mask.Infos();
            Mask.Fill(Item, landscape, Infos, "RightToLeft", false); // On montre le remplissage pour les 4 directions
            Mask.PostProcessing();
            Mask.From_Image_To_File("Mask1.bmp");
            Process.Start(item);
            Process.Start(mask);
            Process.Start("Mask1.bmp");
            Mask.Fill(Item, landscape, Infos, "LeftToRight", false);
            Mask.PostProcessing();
            Mask.From_Image_To_File("Mask2.bmp");
            Process.Start("Mask2.bmp");
            Mask.Fill(Item, landscape, Infos, "TopToBottom", true);
            Mask.PostProcessing();
            Mask.From_Image_To_File("Mask3.bmp");
            Process.Start("Mask3.bmp");
            Mask.Fill(Item, landscape, Infos, "BottomToTop", true);
            Mask.PostProcessing();
            Mask.From_Image_To_File("Mask4.bmp");
            Process.Start("Mask4.bmp");
        }
コード例 #8
0
        /// <summary>
        /// 客户端接收文件消息
        /// </summary>
        /// <param name="fromKey">发送者</param>
        /// <param name="ToKey">接收者</param>
        /// <param name="image"></param>
        void server_ReceiveImageEvent(string fromKey, string ToKey, MyImage image)
        {
            MyUser fromUser = LstUser.FirstOrDefault(x => x.Key == fromKey);

            if (MessageBox.Show(string.Format("{0}给你发送了一张图片:\r\n{1}\r\n是否接收?", fromUser.UserName, System.IO.Path.GetFileName(image.ImageName)), "提示", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
            {
                return;
            }
            System.Windows.Forms.SaveFileDialog sd = new System.Windows.Forms.SaveFileDialog();
            sd.Title = "请设置保存路劲";
            string extension = System.IO.Path.GetExtension(image.ImageName);

            sd.Filter   = string.Format("所发的文件(*{0})|*{0}", extension);
            sd.FileName = System.IO.Path.GetFileName(image.ImageName);
            this.Dispatcher.Invoke(new Action(() =>
            {
                if (sd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                FileHelper.SaveFileFromBytes(image.Data, sd.FileName);
                string msg = string.Format("{0} 接收来自{1}的图片完毕,保存在{2}", DateTime.Now, fromUser.UserName, sd.FileName);
                UpdateText(msg, Colors.Green, true);
            }));
        }
コード例 #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog d = new OpenFileDialog();
                if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    pictureBox1.Image = LoadBitmap(d.FileName);
                }

                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            }
            catch (Exception ex)
            {
                List <Label> Labels = new List <Label>();
                Labels.Add(MyLabel.SetOKLabel("General Error"));
                Labels.Add(MyLabel.SetOKLabel(ex.Message));

                List <Button> Buttons = new List <Button>();
                Buttons.Add(MyButton.SetOKThemeButton());
                MyMessageBox.Show(
                    Labels,
                    "",
                    Buttons,
                    MyImage.SetFailed());
            }
        }
コード例 #10
0
        public ActionResult FileUpload(HttpPostedFileBase file, int id)
        {
            MyImage myim = new MyImage();

            if (file != null)
            {
                var    cba  = db.Products.Find(id).CategoryId;
                var    abc  = db.Categories.Where(cat => cat.Id == cba).First().Name;
                string pic  = System.IO.Path.GetFileName(file.FileName);
                string path = System.IO.Path.Combine(
                    Server.MapPath("~/Content/images/" + abc), pic);
                // file is uploaded
                myim.ImagePath = "/Content/images/" + abc + "/" + file.FileName;
                myim.ProductId = id;
                file.SaveAs(path);

                // save the image path path to the database or you can send image
                // directly to database
                // in-case if you want to store byte[] ie. for DB
                using (MemoryStream ms = new MemoryStream())
                {
                    file.InputStream.CopyTo(ms);
                    byte[] array = ms.GetBuffer();
                }
                db.Images.Add(myim);
                db.SaveChanges();
            }
            // after successfully uploading redirect the user
            return(RedirectToAction("Product/" + id));
        }
コード例 #11
0
        /// <summary>
        /// 接收文件:若是发给服务端则接收,发给其他客户端则转发
        /// </summary>
        /// <param name="fromKey"></param>
        /// <param name="toKey"></param>
        /// <param name="image"></param>
        public void ReceiveImageFromClient(string fromKey, string toKey, MyImage image)
        {
            var    fromUser = ChatToServer.LstUser.Where(x => x.Key == fromKey).FirstOrDefault();
            var    toUser   = ChatToServer.LstUser.Where(x => x.Key == toKey).FirstOrDefault();
            string userName = fromUser.UserName;

            if (toKey == "-1")//发给服务器
            {
                if (MessageBox.Show(string.Format("{0}给你发送了一张图片:\r\n{1}\r\n是否接收?", userName, image.ImageName), "提示", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
                {
                    return;
                }
                System.Windows.Forms.SaveFileDialog sd = new System.Windows.Forms.SaveFileDialog();
                sd.Title = "请设置保存路劲";
                string extension = System.IO.Path.GetExtension(image.ImageName);
                sd.Filter   = string.Format("所发的文件(*{0})|*{0}", extension);
                sd.FileName = System.IO.Path.GetFileName(image.ImageName);
                this.Dispatcher.Invoke(new Action(() =>
                {
                    if (sd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    {
                        return;
                    }
                    FileHelper.SaveFileFromBytes(image.Data, sd.FileName);
                    string msg = string.Format("{0} 接收来自{1}的图片完毕,保存在{2}", DateTime.Now, fromUser.UserName, sd.FileName);
                    UpdateText(msg, Colors.Green, true);
                }));
            }
            else//发给其他客户端
            {
                toUser.Client.SendImageToClient(fromKey, toKey, image);
            }
        }
コード例 #12
0
ファイル: ImageController.cs プロジェクト: rogurotus/Server
        public async Task <SimpleResponse> Post(IFormFile file, string name)
        {
            MyImage image_bd = await _db.images.Where(i => i.name == name).FirstOrDefaultAsync();

            if (image_bd != null)
            {
                return(new SimpleResponse {
                    error = "Такая картинка уже есть"
                });
            }
            MyImage image = new MyImage();

            image.name = name;
            using (var binaryReader = new BinaryReader(file.OpenReadStream()))
            {
                image.file = binaryReader.ReadBytes((int)file.Length);
            }
            await _db.images.AddAsync(image);

            await _db.SaveChangesAsync();

            return(new SimpleResponse {
                message = name
            });
        }
コード例 #13
0
        private void button27_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(Settings.Default.NorthwindConnectionString))
                {
                    using (SqlCommand command = new SqlCommand())
                    {
                        command.CommandText = "select * from MyImageTable ";

                        command.Connection = conn;

                        conn.Open();
                        using (SqlDataReader dataReader = command.ExecuteReader())
                        {
                            this.listBox5.Items.Clear();
                            while (dataReader.Read())
                            {
                                MyImage x = new MyImage();
                                x.ImageID = (int)dataReader["ImageID"];
                                x.Desc    = dataReader["Description"].ToString();

                                this.listBox5.Items.Add(x);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.pictureBox2.Image = this.pictureBox2.ErrorImage;
            }
        }
コード例 #14
0
ファイル: Methods.cs プロジェクト: bracikaa/gms
        public void ReduceEnrollment(int id)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                {
                    using (SqlCommand command = new SqlCommand("UPDATE Exercise SET " +
                                                               "Enrolled=Enrolled - 1 WHERE id=@id", connection))
                    {
                        command.Parameters.AddWithValue("@id", id);
                        command.Connection.Open();
                        command.ExecuteNonQuery();
                        command.Connection.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                List <Label> Labels = new List <Label>();
                Labels.Add(MyLabel.SetOKLabel("General Error"));
                Labels.Add(MyLabel.SetOKLabel(ex.Message));

                List <Button> Buttons = new List <Button>();
                Buttons.Add(MyButton.SetOKThemeButton());
                MyMessageBox.Show(
                    Labels,
                    "",
                    Buttons,
                    MyImage.SetFailed());
            }
        }
コード例 #15
0
ファイル: ImgurApi.cs プロジェクト: Ervin-Halgand/epicture
        async Task <IEnumerable <MyImage> > IApi.GetAccountImages()
        {
            var imgIds = await accountEndpoint.GetImageIdsAsync();

            ObservableCollection <MyImage> Images = new ObservableCollection <MyImage>();

            foreach (var imgId in imgIds)
            {
                var img   = new MyImage();
                var image = await this.GetImageFromId(imgId);

                img.Source = image.Link;
                img.Id     = imgId;
                if (image.Favorite == true)
                {
                    img.Favorite = "\uEB52;";
                }
                else
                {
                    img.Favorite = "\uEB51;";
                }
                Images.Add(img);
            }
            return(Images);
        }
コード例 #16
0
        public async Task <MyImage> GetPhotoAsync(GetPhotoType photoType)
        {
            MediaFile file = await GetPhotoMediaFileAsync(photoType);

            if (file == null)
            {
                return(null);
            }

            var image = new MyImage
            {
                Margin            = new Thickness(5, 0, 5, 5),
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.Start
            };

            //Ten stream może być tworzyny w zły sposób. Nie wiem czy jest potrzeba pobierać go aż 2 razy.
            var stream = file.GetStream();

            image.Source = ImageSource.FromStream(() =>
            {
                return(stream);
            });

            var streamTwo = file.GetStream();

            file.Dispose();
            var bytes = new byte[streamTwo.Length];
            await streamTwo.ReadAsync(bytes, 0, (int)streamTwo.Length);

            image.Base64Representation = Convert.ToBase64String(bytes);

            return(image);
        }
コード例 #17
0
 public void SendImageToClient(string fromKey, string toKey, MyImage image)
 {
     if (ReceiveImageEvent != null)
     {
         ReceiveImageEvent(fromKey, toKey, image);
     }
 }
コード例 #18
0
        public void Should_read_image_data_when_creating_a_new_image_from_file_data()
        {
            var image = new MyImage(TestImages.BlackAndWhiteSquare);

            Check.That(image.Pixels).HasSize(image.Width * image.Height);
            Check.That(image.Pixels).Contains(new Pixel(255, 255, 255));
        }
コード例 #19
0
        public T Convert(T source, params object[] prms)
        {
            if (prms.Length != 2)
            {
                throw new NumberOfArgsException(NumberOfParams, "Необходимо ровно два параметра");
            }
            foreach (var item in prms)
            {
                if (!(item is double))
                {
                    throw new Exception("Параметры должны быть double");
                }
            }
            var dst = new MyImage(source.Width, source.Height);;

            Parallel.For(0, dst.Width, i =>
            {
                Parallel.For(0, dst.Height, j =>
                {
                    double dR = (double)prms[0] * Math.Pow(source[i, j].R, (double)prms[1]);
                    double dG = (double)prms[0] * Math.Pow(source[i, j].G, (double)prms[1]);
                    double dB = (double)prms[0] * Math.Pow(source[i, j].B, (double)prms[1]);
                    dst[i, j] = Color.FromArgb(Norm(dR), Norm(dG), Norm(dB));
                }
                             );
            }
                         );

            object img = dst;

            return((T)img);
        }
コード例 #20
0
        public T Convert(T source, params object[] prms)
        {
            if (prms.Length > 0)
            {
                throw new Exception("Не должно быть параметров");
            }
            var dist = new MyImage(source.Width, source.Height);

            Parallel.For(0, source.Width, i =>
            {
                Parallel.For(0, source.Height, j =>
                {
                    Color color    = source[i, j];
                    Color newcolor =
                        Color.FromArgb(
                            Norm((color.R - source.Min.R) * (255 / (source.Max.R - source.Min.R))),
                            Norm((color.G - source.Min.G) * (255 / (source.Max.G - source.Min.G))),
                            Norm((color.B - source.Min.B) * (255 / (source.Max.B - source.Min.B))));
                    dist[i, j] = newcolor;
                });
            });
            object img = dist;

            return((T)img);
        }
コード例 #21
0
ファイル: Splash.xaml.cs プロジェクト: windwp/THReader
        public Splash(Windows.ApplicationModel.Activation.SplashScreen splashScreen, Services.IManifestService manifestService)
        {
            _manifestService = manifestService;
            this.InitializeComponent();

            // setup size
            Action resize = () =>
            {
                MyImage.Height = splashScreen.ImageLocation.Height;
                MyImage.Width  = splashScreen.ImageLocation.Width;
                MyImage.SetValue(Canvas.TopProperty, splashScreen.ImageLocation.Top);
                MyImage.SetValue(Canvas.LeftProperty, splashScreen.ImageLocation.Left);
            };

            MyImage.ImageOpened        += (s, e) => Window.Current.Activate();
            Window.Current.SizeChanged += (s, e) => resize();
            resize();

            // background color
            var splashColor = _manifestService.SplashBackgroundColor;
            var splashBrush = new SolidColorBrush(splashColor);

            MyGrid.Background = splashBrush;

            // splash image
            var splashPath = _manifestService.SplashImage;
            var splashUrl  = System.IO.Path.Combine("ms-appx:///", splashPath);
            var splashUri  = new Uri(splashUrl);
            var splashImg  = new BitmapImage(splashUri);

            MyImage.Source = splashImg;
        }
コード例 #22
0
        private void createMarkerList(List <Bitmap> images)
        {
            unsafe
            {
                MyImageListElement *list;
                create_image_list_N(&list);
                Dictionary <Bitmap, BitmapData> bmdlist = new Dictionary <Bitmap, BitmapData>();
                foreach (Bitmap im in images)
                {
                    BitmapData bmd = im.LockBits(new Rectangle(0, 0, im.Width, im.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
                    bmdlist.Add(im, bmd);
                    MyImage mimg = new MyImage((uint *)bmd.Scan0.ToPointer(), im.Width, im.Height);
                    add_image_list_item_N(&list, mimg);
                }

                generate_marker_shapes_N(list);


                foreach (KeyValuePair <Bitmap, BitmapData> pair in bmdlist)
                {
                    pair.Key.UnlockBits(pair.Value);
                }

                delete_image_list_D(list);
            }
        }
コード例 #23
0
        private void ChoicePicture_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog dialog = new OpenFileDialog
                {
                    CheckFileExists = true,
                    Multiselect     = false,
                    Filter          = "Images (*.jpg,*.png)|*.jpg;*.png|All Files(*.*)|*.*"
                };

                dialog.ShowDialog();
                {
                    StrName   = dialog.SafeFileName;
                    ImageName = dialog.FileName;
                    ImageSourceConverter isc = new ImageSourceConverter();
                    if (ImageName != "")
                    {
                        MyImage.SetValue(System.Windows.Controls.Image.SourceProperty, isc.ConvertFromString(ImageName));
                        //    ImagePath.Text = ImageName.ToString();
                    }
                }
            }
            catch
            {
                ErrorPage Er = new ErrorPage();
                Er.Show();
                Er.Error_Lable.Content = "مشکلی در سیستم به وجود آمده است";
            }
        }
コード例 #24
0
ファイル: ShopForm.cs プロジェクト: bracikaa/gms
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                sport.Close();

                ShopItemForm formDialog = new ShopItemForm(label8.Text);
                formDialog.ShowDialog();
                sport.Open();
                getItems();
            }
            catch (Exception ex)
            {
                List <Label> Labels = new List <Label>();
                Labels.Add(MyLabel.SetOKLabel("General Error"));
                Labels.Add(MyLabel.SetOKLabel(ex.Message));

                List <Button> Buttons = new List <Button>();
                Buttons.Add(MyButton.SetOKThemeButton());
                MyMessageBox.Show(
                    Labels,
                    "",
                    Buttons,
                    MyImage.SetFailed());
            }
        }
コード例 #25
0
        public static void UpdateChildLayoutData(ContentControl item)
        {
            switch (item.Tag as string)
            {
            case "Text":
                MyText myText = item as MyText;
                myText.updateLayoutDate();
                break;

            case "Image":
                MyImage myImage = item as MyImage;
                myImage.updateLayoutDate();
                break;

            case "Media":
                MyMedia myMedia = item as MyMedia;
                myMedia.updateLayoutDate();
                break;

            case "Office":
                MyOffice myOffice = item as MyOffice;
                myOffice.updateLayoutDate();
                break;
            }
        }
コード例 #26
0
        public static void setControlSource(MyBaseControl currentControl, String content)
        {
            string tag = currentControl.Tag as string;

            switch (tag)
            {
            case "Text":
                MyText myText = currentControl as MyText;
                myText.setContentSource(content);
                break;

            case "Image":
                MyImage myImage = currentControl as MyImage;
                myImage.setContentSource(content);
                break;

            case "Media":
                MyMedia myMedia = currentControl as MyMedia;
                myMedia.setContentSource(content);
                break;

            case "Office":
                MyOffice myOffice = currentControl as MyOffice;
                myOffice.setContentSource(content);
                break;
            }
        }
コード例 #27
0
        } // Update()

        public void Draw()
        {
            Point pontoCentral = new Point((int)(radious / 2.0), ((int)(radious / 2.0)));
            Point pontoDestino = new Point(0, 0);
            Point pontoAtual   = new Point((int)this.ponteiroAtual.X, (int)this.ponteiroAtual.Y);

            if (ponteiroDestino != null)
            {
                pontoDestino = new Point((int)this.ponteiroDestino.X, (int)this.ponteiroDestino.Y);
            }



            Bitmap   AreaInc = new Bitmap((int)radious, (int)radious);
            Graphics g       = Graphics.FromImage(AreaInc);

            g.FillEllipse(new SolidBrush(Color.Blue), 0, 0, AreaInc.Width, AreaInc.Height); // desenha a circunferência da área ativa do joystick vetorial.

            if (ponteiroDestino != null)
            {
                g.DrawLine(new Pen(Color.Yellow, 6.0f), pontoCentral, pontoDestino); // desenha o ponteiro de destino do vetor de direção do joystick.
            }
            g.DrawLine(new Pen(Color.Red, 4.0F), pontoCentral, pontoAtual);          // desenha o ponteiro atual do vetor de direção do joystick.

            this.AreaPadDirect2D = new MyImage(AreaInc, this, AreaInc.Size);
            this.AreaPadDirect2D.Begin();//inicia o desenho dos vetores direção.
            this.AreaPadDirect2D.Clear(this.BackColor);
            this.AreaPadDirect2D.Draw(new vetor2(0, 0));
            this.AreaPadDirect2D.End(); //finaliza o desenho dos vetores direção.

            // libera os recursos utilizados no desenho do componente.
            this.AreaPadDirect2D.Dispose();
            AreaInc.Dispose();
            g.Dispose();
        } // Draw()
コード例 #28
0
        //插入图片
        private void insertImage_Click(object sender, RoutedEventArgs e)
        {
            _inkFrame.InkCollector.InkCanvas.EditingMode = InkCanvasEditingMode.None;
            //打开图片选择框
            OpenFileDialog openfile = new OpenFileDialog()
            {
                Filter      = "Jpeg Files (*.jpg)|*.jpg|Bitmap files (*.bmp)|*.bmp|All Files(*.*)|*.*",
                Multiselect = true
            };

            if (openfile.ShowDialog() == DialogResult.OK)
            {
                string  FileName     = openfile.FileName;
                string  SafeFileName = openfile.SafeFileName;
                MyImage newimage     = new MyImage(FileName);
                newimage.SafeFileName = SafeFileName;
                InkConstants.AddBound(newimage);
                AddImageCommand cmd = new AddImageCommand(_inkFrame.InkCollector, newimage);
                cmd.execute();
                _inkFrame.InkCollector.CommandStack.Push(cmd);
                _inkFrame.pointView.pointView.AddNode(_inkFrame.pointView.pointView.nodeList, _inkFrame.pointView.pointView.links);
            }
            this.Height       = GlobalValues.ControlPanel_OtherModeHeight;
            InkCollector.Mode = InkMode.AutoMove;
        }
コード例 #29
0
        public Splash(SplashScreen splashScreen)
        {
            this.InitializeComponent();

            Action resize = () =>
            {
                if (splashScreen.ImageLocation.Top == 0)
                {
                    MyImage.Visibility = Visibility.Collapsed;
                    return;
                }
                else
                {
                    MyCanvas.Background = null;
                    MyImage.Visibility  = Visibility.Visible;
                }
                MyImage.Height = splashScreen.ImageLocation.Height;
                MyImage.Width  = splashScreen.ImageLocation.Width;
                MyImage.SetValue(Canvas.TopProperty, splashScreen.ImageLocation.Top);
                MyImage.SetValue(Canvas.LeftProperty, splashScreen.ImageLocation.Left);
                ProgressTransform.TranslateY = MyImage.Height / 2;
            };

            Window.Current.SizeChanged += (s, e) => resize();
            resize();
        }
コード例 #30
0
        private void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            dlg.DefaultExt = ".txt";
            dlg.Filter     = "Json (.txt)|*.txt";

            bool?result = dlg.ShowDialog();


            if (result == true)
            {
                string  filename = dlg.FileName;
                MyImage newImg   = new MyImage(this.MainViewPort);
                newImg.Name = filename.Split('\\').Last();
                newImg.Load(filename);
                Images.Add(newImg);

                this.myImage = newImg;
            }

            myImage.RedrawAll();
            RefreshImagesListBox();
            RefreshFiguresView();
        }
コード例 #31
0
        private void goNext()
        {
            string next = globalDatasingleton.getInstance().getNext();
            if (next == null) return;
            if (next == "") return;

            MyImage img = new MyImage();
            img.OriginalPath = next;
            img.Source = new BitmapImage(new Uri(next));
            Viewbox vb = new Viewbox { Width = 200, Child = img };

            LoadVBox(ref vb);
            //LoadVBox(ref next);
        }
コード例 #32
0
ファイル: ImageManager.cs プロジェクト: gaeeyo/Unene
 public static void GetImage(string url, Action<ImageSource> setter)
 {
     MyImage myImage;
     if (!images.TryGetValue(url, out myImage))
     {
         Debug.WriteLine("画像キャッシュ無し: {0}", url);
         myImage = new MyImage(url);
         images.Add(url, myImage);
     }
     else
     {
         Debug.WriteLine("画像キャッシュ有り: {0}", url);
     }
     myImage.AddSetter(setter);
 }
コード例 #33
0
        public onePhotoPage(string filename)
        {
            InitializeComponent();
            //globalDatasingleton.getInstance().InitCursor(

            SurfaceWindow1.changeMessagePage(" ");

            MyImage img = new MyImage();
            if (filename != "")
            {
                img.Source = BitmapUtil.GetImageSource(filename);
                img.OriginalPath = filename;
            }
            LoadImg(img);
            Utility.gradientManager gm = new gradientManager();
            gm.setgradient(gridPhoto);

            UpdateGUI();
        }
コード例 #34
0
ファイル: DrawBoard.cs プロジェクト: hunsteve/RobotNavigation
 private static extern unsafe void real_contour_N(MyImage im, MyShapeListElement** shapeList);
コード例 #35
0
ファイル: DrawBoard.cs プロジェクト: hunsteve/RobotNavigation
 private static extern unsafe void writeImage(char[] filename, MyImage im);
コード例 #36
0
ファイル: DrawBoard.cs プロジェクト: hunsteve/RobotNavigation
 private static extern unsafe void closing(MyImage im);
コード例 #37
0
    void Start()
    {
        if (!serverIsRunned)
        {
            Server();
            serverIsRunned = true;
        }

        mainCanvas = new MyCanvas(new Vector2(Screen.width, Screen.height));
        MakeState();
        windowTests = MakeTests();
        windowTests.SetActive(stateMenu.IsOpenTestsWindow);
        var buttonWindowTests = new MyButton(() => windowTests.SetActive(!windowTests.isOpen), ButtonSprite, new Rect(0, 0, 64, 48), "Tests");
        var rectB = buttonWindowTests.Element.GetComponent<RectTransform>();
        var inputField = new MyInputField("Input", ButtonSprite, new Rect(0, 0, 160, 25));
        buttonWindowTests.SetAnchor(new Vector2(0, 1), new Vector2(0, 1));

        var buttonLog = new MyButton(
            () => Dispatcher.AddRunner(new LogRunner(inputField.Element.GetComponent<InputField>().text)),
            ButtonSprite,
            new Rect(0, 0, 64, 48),
            "Log play");

        var rectLog = buttonLog.Element.GetComponent<RectTransform>();
        buttonLog.SetAnchor(0, 0, 0, 0);
        rectLog.anchoredPosition = new Vector2(300, 40);

        rectB.offsetMin = new Vector2(100, -200);
        UIElement.SetSize(rectB, new Vector2(120, 30));
        var buttonTutorial = new MyButton(
            () => Dispatcher.AddRunner(new TutorialRunner(new LoadingData { AssemblyName = "RoboMovies", Level = "Test" })),
            ButtonSprite,
            new Rect(0, 00, 120, 48),
            "Tutorial");
        buttonTutorial.SetAnchor(new Vector2(0, 1), new Vector2(0, 1));

        rectB = buttonTutorial.Element.GetComponent<RectTransform>();
        rectB.offsetMin = new Vector2(100, -300);
        UIElement.SetSize(rectB, new Vector2(120, 30));

        dropDownListAssembly = Instantiate(DropDownList);
        dropDownListAssembly.name = "BambaLeilo";
        dropDownListAssembly.transform.localPosition = new Vector3(0, 0);
        var dropDown = dropDownListAssembly.GetComponent<Dropdown>();
        dropDown.GetComponent<RectTransform>().position = new Vector3(0, 0, 0);
        dropDown.options = new List<Dropdown.OptionData>();
        foreach (var e in Dispatcher.Loader.Levels.Keys)
            dropDown.options.Add(new Dropdown.OptionData(e));

        for (var i = 0; i < dropDown.options.Count; i++)
            if (dropDown.options[i].text == stateMenu.CurrentAssembly)
                dropDown.value = i;

        dropDownListLevel = Instantiate(DropDownList);
        dropDownListLevel.name = "BambaLeiloLevel";
        dropDownListLevel.transform.localPosition = new Vector3(0, 0);
        var dropDownList = dropDownListLevel.GetComponent<Dropdown>();
        dropDownList.GetComponent<RectTransform>().position = new Vector3(0, 0, 0);
        dropDownList.options = new List<Dropdown.OptionData>();
        foreach (var e in Dispatcher.Loader.Levels[stateMenu.CurrentAssembly].Keys)
            dropDownList.options.Add(new Dropdown.OptionData(e));

        for (var i = 0; i < dropDownList.options.Count; i++)
            if (dropDownList.options[i].text == stateMenu.CurrentLevel)
            {
                dropDownList.value = i;
                dropDownList.options[i] = new Dropdown.OptionData(stateMenu.CurrentLevel);
            }

        var backGround = new MyImage(menuBackground, new Rect(0, 0, menuBackground.textureRect.width, menuBackground.textureRect.height));

        mainCanvas.AddElement(backGround);
        mainCanvas.AddElement(inputField);
        mainCanvas.AddElement(windowTests.Head);
        mainCanvas.AddElement(buttonWindowTests);
        mainCanvas.AddElement(buttonTutorial);
        mainCanvas.AddElement(buttonLog);
        dropDownListLevel.transform.SetParent(mainCanvas.Element.transform);
        dropDown.transform.SetParent(mainCanvas.Element.transform);

        var rectDrop = dropDownListAssembly.GetComponent<RectTransform>();
        rectDrop.anchorMin = new Vector2(0, 1);
        rectDrop.anchorMax = new Vector2(0, 1);
        rectDrop.anchoredPosition = new Vector3(100, -40, 0);

        rectDrop = dropDownListLevel.GetComponent<RectTransform>();
        rectDrop.anchorMin = new Vector2(0, 1);
        rectDrop.anchorMax = new Vector2(0, 1);
        rectDrop.anchoredPosition = new Vector3(300, -40, 0);

        rectDrop = inputField.Element.GetComponent<RectTransform>();
        inputField.SetAnchor(0, 0, 0, 0);
        rectDrop.anchoredPosition = new Vector3(100, 40, 0);
    }
コード例 #38
0
 //---------------------------------------------------------//
 /// <summary>
 /// Add an image or a movie into the puzzle list
 /// </summary>
 /// <param name="img"></param>
 private void AddElementToPuzzleList(MyImage img)
 {
     Viewbox b = new Viewbox { Width = 200, Child = img };
     surfaceListBox1.Items.Insert(0, b);//random.Next(0, puzzles.Items.Count), b);
 }
コード例 #39
0
        private void goPrevious()
        {
            string previousFilename = globalDatasingleton.getInstance().getPrevious();
            if (previousFilename == "") return;
            if (previousFilename == null) return;
            MyImage img = new MyImage();

            img.OriginalPath = previousFilename;
            img.Source = new BitmapImage(new Uri(previousFilename));
            Viewbox vb = new Viewbox { Width = 200, Child = img };

            LoadVBox(ref vb);
        }
コード例 #40
0
        private void SendTimerForLoading()
        {
            // Set the callback to just show the time ticking away
            // NOTE: We are using a control so this has to run on
            // the UI thread
            _timer.Tick += new EventHandler(delegate(object s, EventArgs a)
            {
                if (cursor >= imgList.Count)
                {
                    WaitingAnimation.IsAnimated = false;
                    gridWating.Visibility = System.Windows.Visibility.Hidden;
                    _timer.Stop();
                }
                else
                {

                    /*
                    MyImage img = new MyImage();
                    img.OriginalPath = imgList[cursor].path;
                    //System.Windows.Controls.Image img = new System.Windows.Controls.Image();
                    img.Source =  BitmapUtil.GetImageSource(imgList[cursor].path); //new BitmapImage(new Uri(imgList[cursor].path));
                    AddElementToPuzzleList(img);

                    */

                    SurfaceListBoxItem il = new SurfaceListBoxItem();
                    StackPanel sp = new StackPanel();
                    sp.Orientation = Orientation.Horizontal;

                    MyImage img = new MyImage();
                    img.OriginalPath = imgList[cursor].path;
                    //System.Windows.Controls.Image img = new System.Windows.Controls.Image();
                    img.Source = BitmapUtil.GetImageSource(imgList[cursor].path); //new BitmapImage(new Uri(imgList[cursor].path));

                    Viewbox vb = new Viewbox { Width = 200, Child = img };
                    vb.TouchDown += ViewBox_TouchDown;
                    //vb.MouseDown += ViewBox_MouseDown;
                    vb.Margin = new Thickness(2);
                    sp.Children.Add(vb);

                    int nbImageToInsert = 0;
                    while (nbImageToInsert < nbItemInRow-1)
                    {
                        if (cursor + 1 < imgList.Count)
                        {
                            cursor++;

                            MyImage img2 = new MyImage();
                            img2.OriginalPath = imgList[cursor].path;
                            //System.Windows.Controls.Image img = new System.Windows.Controls.Image();
                            img2.Source = BitmapUtil.GetImageSource(imgList[cursor].path); //new BitmapImage(new Uri(imgList[cursor].path));

                            Viewbox vb2 = new Viewbox { Width = 200, Child = img2 };
                            vb2.TouchDown += ViewBox_TouchDown;
                            vb2.Margin = new Thickness(2);
                            sp.Children.Add(vb2);
                        }
                        nbImageToInsert++;
                    }
                    il.Content = sp;
                    surfaceListBox1.Items.Add(il);

                    cursor++;
                }
            });

            // Start the timer
            _timer.Start();
        }
コード例 #41
0
 private static extern unsafe void segment_kmeans(MyImage im, int levels);
コード例 #42
0
        private void createMarkerList(List<Bitmap> images)
        {
            unsafe
            {
                MyImageListElement* list;
                create_image_list_N(&list);
                Dictionary<Bitmap, BitmapData> bmdlist = new Dictionary<Bitmap, BitmapData>();
                foreach (Bitmap im in images)
                {
                    BitmapData bmd = im.LockBits(new Rectangle(0, 0, im.Width, im.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
                    bmdlist.Add(im, bmd);
                    MyImage mimg = new MyImage((uint*)bmd.Scan0.ToPointer(), im.Width, im.Height);
                    add_image_list_item_N(&list, mimg);
                }
                
                generate_marker_shapes_N(list);
            

                foreach (KeyValuePair<Bitmap, BitmapData> pair in bmdlist)
                {
                    pair.Key.UnlockBits(pair.Value);
                }

                delete_image_list_D(list);
            }
        }
コード例 #43
0
 private static extern unsafe void binarize(MyImage im, uint color0, uint color1);
コード例 #44
0
 private static extern unsafe void binarize2(MyImage im, bool inverse);
コード例 #45
0
ファイル: DrawBoard.cs プロジェクト: hunsteve/RobotNavigation
 private static extern unsafe void clone_image_N(MyImage src, MyImage* dest);
コード例 #46
0
ファイル: DrawBoard.cs プロジェクト: hunsteve/RobotNavigation
 private static extern unsafe void delete_image_D(MyImage im);
コード例 #47
0
        private void ReplaceImageAfterEffect()
        {
            SelectionUser._ImageSelected = null;
            MyImage img = new MyImage();
            img.OriginalPath = imgScatter.OriginalPath;
            img.Source = imgScatter.Source;
            SelectionUser.getInstance().AddImage(img);

            Viewbox b = null;
            if (img.Source.Width > img.Source.Height)
            {
                b = new Viewbox { Width = 200, Child = img };
            }
            else
            {
                b = new Viewbox { Width = (int)((float)200 * ((float)img.Source.Width / (float)img.Source.Height)), Child = img };
            }

            b.TouchDown += ViewBox_TouchDown;
            b.Margin = new Thickness(2);

            addImageFromListView(b);
            gridEffect.Visibility = System.Windows.Visibility.Hidden;

            imgScatter.Source = null;
            imgScatter.OriginalPath = "";
            GC.Collect();
            scatterViewItem.Visibility = System.Windows.Visibility.Hidden;
            UpdateShowPrice();
        }
コード例 #48
0
        private unsafe MyShapeListElement* processFrame(Bitmap cam, Bitmap back)
        {
            BitmapData backData = back.LockBits(new Rectangle(0, 0, back.Width, back.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
            BitmapData camData = cam.LockBits(new Rectangle(0, 0, cam.Width, cam.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
            MyImage afg = new MyImage((uint*)camData.Scan0.ToPointer(), cam.Width, cam.Height);
            MyImage abg = new MyImage((uint*)backData.Scan0.ToPointer(), back.Width, back.Height);
            
            MyShapeListElement* shapeList;
            find_objects_N(afg, abg, &shapeList);

            cam.UnlockBits(camData);
            back.UnlockBits(backData);

            return shapeList;
        }
コード例 #49
0
        private void surfaceButtonBackTopGallery_Click(object sender, RoutedEventArgs e)
        {
            var eog = new EaseObjectGroup();
            gridPhoto.Opacity = 0;
            var eo = ArtefactAnimator.AddEase(gridPhoto, new[] { AnimationTypes.Width, AnimationTypes.Alpha }, new object[] { 1, 0 }, 0.3, AnimationTransitions.CubicEaseOut, 0);
            eog.AddEaseObject(eo);

            eog.Complete += delegate(EaseObjectGroup easeObjectGroup)
            {
                gridListThumb.Width = System.Windows.SystemParameters.PrimaryScreenWidth - 50;
                surfaceListBox1.Width = System.Windows.SystemParameters.PrimaryScreenWidth - 50;
                    surfaceButtonAddToSelection.Visibility = System.Windows.Visibility.Hidden;
                    surfaceButtonBackTopGallery.Visibility = System.Windows.Visibility.Hidden;
            };

            globalDatasingleton.getInstance().InitCursor(LastViewBoxTouch);

            if (globalDatasingleton.getInstance().getCursorFilename() != "")
            {
                String filename = globalDatasingleton.getInstance().getCursorFilename();
                Image img = LastViewBoxTouch.Child as Image;
                MyImage img2 = new MyImage();
                if (filename != "")
                {
                    img2.Source = BitmapUtil.GetImageSource(filename);
                    img2.OriginalPath = filename;
                }
                LoadImg(img2);
            }
        }
コード例 #50
0
        private void LoadImg(MyImage img)
        {
            scatterView.Width = System.Windows.SystemParameters.PrimaryScreenWidth * 0.6;
            scatterView.Height = System.Windows.SystemParameters.PrimaryScreenWidth * 0.6;

            //scatterView.CanRotate = CommunConfig.getInstance().ImageRotate;

            if (img.Source == null) return;

            if (img.Source.Width > img.Source.Height)
            {
                scatterView.Height *= img.Source.Height/img.Source.Width;
            }
            else
            {
                scatterView.Width*= img.Source.Width/ img.Source.Height;
            }
            imgScatter.OriginalPath = img.OriginalPath;
            imgScatter.Source = img.Source;

            //Point originPoint = this.PointToScreen(new Point(0, 0));
            scatterView.Center = new Point(System.Windows.SystemParameters.PrimaryScreenWidth / 2, System.Windows.SystemParameters.PrimaryScreenHeight / 2 -50);
            // System.Windows.SystemParameters.PrimaryScreenWidth/2;
            // System.Windows.SystemParameters.PrimaryScreenHeight/2;

            scatterView.MaxWidth = System.Windows.SystemParameters.PrimaryScreenWidth * 2;
            scatterView.MaxHeight = System.Windows.SystemParameters.PrimaryScreenHeight * 2;
            imgScatter.MaxWidth= System.Windows.SystemParameters.PrimaryScreenWidth*2;
            imgScatter.MaxHeight = System.Windows.SystemParameters.PrimaryScreenHeight*2;

            scatterView.Opacity = 0;
            var eog = new EaseObjectGroup();
            var eo = ArtefactAnimator.AddEase(scatterView, new[] { AnimationTypes.Alpha}, new object[] { 1 }, 1, AnimationTransitions.CubicEaseOut, 0);
            eog.AddEaseObject(eo);
        }
コード例 #51
0
 private static extern unsafe void add_image_list_item_N(MyImageListElement** element, MyImage image);
コード例 #52
0
 private static extern unsafe void find_objects_N(MyImage foreground, MyImage background, MyShapeListElement** shapeList);       
コード例 #53
0
ファイル: DrawBoard.cs プロジェクト: hunsteve/RobotNavigation
        public Shape GetContour()
        {       
            BitmapData data = im.LockBits(new Rectangle(0, 0, im.Width, im.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
            Shape shape = null;
            unsafe
            {
                MyImage img = new MyImage((uint*)data.Scan0.ToPointer(), im.Width, im.Height);            
                MyImage img2;
                clone_image_N(img, &img2);
                binarize2(img2, true);
                closing(img2);
                MyShapeListElement* shapeList = null;
                real_contour_N(img2, &shapeList);                
                if ((shapeList != null) && (shapeList->next != null))
                {                    
                    normalize_shape(&(shapeList->shape));
                    MyShape current = shapeList->shape;
                    shape = new Shape(new Point(current.pos.X, current.pos.Y), current.scale, current.rot, current.index);
                    MyContourPoint* curp = current.contour;
                    while (curp->next != null)
                    {
                        shape.contour.Add(new Point(curp->pos.X, curp->pos.Y));
                        curp = curp->next;
                    }
                }

                delete_shape_list_D(shapeList);
                delete_image_D(img2);
            }
            im.UnlockBits(data);

            if (shape != null)
            {                
                return shape;
            }
            else return null;            
        }
コード例 #54
0
        private void LoadImg(MyImage img)
        {
            //scatterView.CanRotate = CommunConfig.getInstance().ImageRotate;

            scatterView.Width = System.Windows.SystemParameters.PrimaryScreenWidth * 0.4;
            scatterView.Height = System.Windows.SystemParameters.PrimaryScreenWidth * 0.4;

            if (img.Source == null) return;

            if (img.Source.Width > img.Source.Height)
            {
                scatterView.Height *= img.Source.Height / img.Source.Width;
                imgScatter.Height *= scatterView.Height;
            }
            else
            {
                scatterView.Width *= img.Source.Width / img.Source.Height;
                imgScatter.Width *= scatterView.Width;
            }
            imgScatter.OriginalPath = img.OriginalPath;
            imgScatter.Source = img.Source;

            //Point originPoint = this.PointToScreen(new Point(0, 0));
            scatterView.Center = new Point(gridPhoto.Width / 2  -200 , gridPhoto.Height / 2 );
            // System.Windows.SystemParameters.PrimaryScreenWidth/2;
            // System.Windows.SystemParameters.PrimaryScreenHeight / 2;

            scatterView.MaxWidth  = System.Windows.SystemParameters.PrimaryScreenWidth ;
            scatterView.MaxHeight = System.Windows.SystemParameters.PrimaryScreenHeight ;
            imgScatter.MaxWidth   = System.Windows.SystemParameters.PrimaryScreenWidth ;
            imgScatter.MaxHeight  = System.Windows.SystemParameters.PrimaryScreenHeight ;

            scatterView.Opacity = 0;
            var eog = new EaseObjectGroup();
            var eo = ArtefactAnimator.AddEase(scatterView, new[] { AnimationTypes.Alpha }, new object[] { 1 }, 1, AnimationTransitions.CubicEaseOut, 0);
            eog.AddEaseObject(eo);
            eog.Complete += delegate(EaseObjectGroup easeObjectGroup)
            {
                surfaceButtonAddToSelection.Visibility = System.Windows.Visibility.Visible;
                surfaceButtonBackTopGallery.Visibility = System.Windows.Visibility.Visible;
            };
        }
コード例 #55
0
ファイル: FrmConnected.cs プロジェクト: YiYingChuang/ADO.NET
        private void button20_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(Settings.Default.NorthwindConnectionString))
                {

                    using (SqlCommand command = new SqlCommand())
                    {
                      
                        command.CommandText = "select * from MyImageTable";
                        command.Connection = conn;
 
                        conn.Open();
                        using (SqlDataReader dataReader= command.ExecuteReader())
                        {
                            this.listBox1.Items.Clear();
                            this.listBox2.Items.Clear();
                            this.listBox3.Items.Clear();

                            while (dataReader.Read())
                            {
                                //string s = string.Format("{0} - {1}", dataReader["ImageID"], dataReader["Description"]);
                                //this.listBox1.Items.Add(s);

                                this.listBox1.Items.Add(dataReader["Description"]);
                                this.listBox2.Items.Add(dataReader["ImageID"]); //List<int> IDList

                                MyImage x = new MyImage();
                                x.ImageID = (int) dataReader["ImageID"];
                                x.ImageDesc = dataReader["Description"].ToString();
                               
                                //===========================
                                byte[] bytes = (byte[])dataReader["Image"];
                                System.IO.MemoryStream ms = new MemoryStream(bytes);
                                x.ImagePicture = Image.FromStream(ms);
                                //===========================
                                
                           
                                this.listBox3.Items.Add(x); //call ToString()
                                this.listBox4.Items.Add(x);
                            }
                            
                        }
                       
                    } //command.Dispose();

                } // auto   conn.Dispose()=>conn.Close()

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #56
0
        private void AddImageToStackPanel(ref StackPanel sp)
        {
            try
            {
                string filename = listFile.Pop();
            //                img.Source = new BitmapImage();

                MyImage img = new MyImage();
                img.OriginalPath = filename;
                //Image img = new Image();
                img.Source = BitmapUtil.GetImageSource(filename);

                Viewbox vb = null;
                if (img.Source.Width > img.Source.Height)
                {
                    vb = new Viewbox { Width = sizeViewBox, Child = img };
                }
                else
                {
                    vb = new Viewbox { Width = (int)((float)sizeViewBox * ((float)img.Source.Width/(float)img.Source.Height)), Child = img };
                }
                //img.Source = new BitmapImage(new Uri(filename));
                //DrawingContext dc =
                //Viewbox vb = new Viewbox { Width = sizeViewBox, Child = img };
                globalDatasingleton.getInstance().AddViewBox(ref vb,filename);
                vb.TouchDown += ViewBox_TouchDown;
                vb.MouseDown += ViewBox_MouseDown;
                vb.Margin = new Thickness(3);
                sp.Children.Add(vb);
                chargementLabel.Content = "Loading " + nbLoadedImage.ToString() + " / " + nbItem.ToString();
                nbLoadedImage++;
            }
            catch (Exception e)
            {
             //   MessageBox.Show("Error Adding Image " + e.Message);
            }
        }
コード例 #57
0
        private void openPagePhoto()
        {
            if (surfaceListBox1.ActualWidth != 500)
            {
                ShowArrow();
            }

            gridPhoto.Opacity = 1;
            gridListThumb.Width = 500;
            surfaceListBox1.Width = 500;
            //var eog = new EaseObjectGroup();
            //gridPhoto.Opacity = 0;
            //var eo = ArtefactAnimator.AddEase(gridPhoto, new[] { AnimationTypes.Width, AnimationTypes.Alpha }, new object[] { 700, 1 }, 1.5, AnimationTransitions.CubicEaseOut, 0);
            //eog.AddEaseObject(eo);
            gridPhoto.Width = 1400;

            globalDatasingleton.getInstance().InitCursor(LastViewBoxTouch);

            if (globalDatasingleton.getInstance().getCursorFilename() != "")
            {
                String filename = globalDatasingleton.getInstance().getCursorFilename();
                Image img = LastViewBoxTouch.Child as Image;
                MyImage img2 = new MyImage();
                if (filename != "")
                {
                    img2.Source = BitmapUtil.GetImageSource(filename);
                    img2.OriginalPath = filename;
                }
                LoadImg(img2);
            }
               //surfaceListBox1.SelectedIndex = -1;
            /*
               Image img = LastViewBoxTouch.Child as Image;

             * */
        }