예제 #1
0
        public void ImportImageGreyScale(string FileName)
        {
            MatrixTransform myT = new MatrixTransform();
            Matrix          mt  = myT.Matrix;

            mt.OffsetY = 200;
            mt.OffsetX = 200;

            ImageBrush ib = new ImageBrush();

            ib.ImageSource = Helper.ConvertToGrayScale(FileName);

            Rectangle image = new Rectangle();

            //image.Width = ib.ImageSource.Width;
            //image.Height = ib.ImageSource.Height;
            image.Width  = mainImg.Width;
            image.Height = mainImg.Height;
            image.Fill   = ib;
            image.IsManipulationEnabled = true;
            image.RenderTransform       = myT;
            ImageDetail tmpImg = new ImageDetail();

            tmpImg.myImg = image;
            tmpImg.OriginalImg.Source = Helper.ConvertToGrayScale(FileName);
            tmpImg.X = (int)(tmpImg.OriginalImg.Source.Width / 2);
            tmpImg.Y = (int)(tmpImg.OriginalImg.Source.Height / 2);
            Images.Add(tmpImg);

            mainImg.Children.Add(image);

            LastAddedItems tmpItem = new LastAddedItems();

            tmpItem.ShapeType = 1;
            tmpItem.shapeIdx  = Images.Count() - 1;
            LastAddIdx.Add(tmpItem);

            SelectedRec = image;
            ImgSelIdx   = Images.Count() - 1;
            //DrawImages();
        }
예제 #2
0
        //////////////Text
        public void ImportText(string myStr, FontFamily myFamily)
        {
            MatrixTransform myT = new MatrixTransform();
            Matrix          mt  = myT.Matrix;

            mt.OffsetY = 200;
            mt.OffsetX = 200;

            int       size   = 48;
            TextBlock tmpBrd = new TextBlock();

            tmpBrd.Text       = myStr;
            tmpBrd.FontFamily = myFamily;
            tmpBrd.FontSize   = size;

            Border myBrd = new Border();

            myBrd.Child = tmpBrd;
            myBrd.IsManipulationEnabled = true;
            myBrd.RenderTransform       = myT;
            mainImg.Children.Add(myBrd);

            TextDetail tmpTxt = new TextDetail();

            tmpTxt.myTextObj = myBrd;
            tmpTxt.myOrgStr  = myStr;
            tmpTxt.myFontFam = myFamily;
            Texts.Add(tmpTxt);

            LastAddedItems tmpItem = new LastAddedItems();

            tmpItem.ShapeType = 3;
            tmpItem.shapeIdx  = Texts.Count() - 1;
            LastAddIdx.Add(tmpItem);

            SelectedBor = myBrd;

            AlignLastSelectedItem();
        }
예제 #3
0
        public void Undo()
        {
            if (LastAddIdx.Count == 0)
            {
                return;
            }

            int            idx     = LastAddIdx.Count - 1;
            LastAddedItems tmpItem = new LastAddedItems();

            tmpItem = LastAddIdx[idx];

            switch (tmpItem.ShapeType)
            {
            case 1:
            {
                mainImg.Children.Remove(Images[tmpItem.shapeIdx].myImg);
                Images.RemoveAt(tmpItem.shapeIdx);
                LastAddIdx.RemoveAt(idx); break;
            }

            case 2:
            {
                int cnt = myInkCanvas.Strokes.Count();
                if (cnt != 0)
                {
                    myInkCanvas.Strokes.RemoveAt(cnt - 1);
                }
                break;
            }

            case 3:
            {
                mainImg.Children.Remove(Texts[tmpItem.shapeIdx].myTextObj);
                Texts.RemoveAt(tmpItem.shapeIdx);
                LastAddIdx.RemoveAt(idx); break;
            }
            }
        }