private void Texture_Canvas_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            bool IsLCtrlDown = (Keyboard.GetKeyStates(Key.LeftCtrl) & KeyStates.Down) == KeyStates.Down;

            if (IsLCtrlDown)
            {
                MoveStartPosition = Mouse.GetPosition(this);
            }
            else if (Select_Texture == null)
            {
                Point        MousePoint = Mouse.GetPosition(this);
                Texture_Info Info       = Get_Point_Texture(new System.Drawing.Point((int)MousePoint.X, (int)MousePoint.Y));
                if (Info != null)
                {
                    Select_Texture = Info;
                    Set_Dollet_Line(Info);
                    Dollet_Line_Visibility(true);
                }
                else
                {
                    Select_Texture = null;
                    Dollet_Line_Visibility(false);
                }
            }
            else
            {
                IsMoveWaitMode      = true;
                Move_Select_Texture = Mouse.GetPosition(this);
            }
        }
Example #2
0
        public void Change_Rotate_Texture(Texture_Info TexInfo, int Init_Index)
        {
            Texture_Image_Info Info = TexInfo.Texture_Image;
            int Minus_X             = Math.Min(Info.Left_UP_Position.X, Info.Left_Down_Position.X);
            int Minus_Y             = Math.Min(Info.Left_UP_Position.Y, Info.Right_UP_Position.Y);

            System.Drawing.Point Left_UP   = new System.Drawing.Point(Info.Left_UP_Position.X - Minus_X, Info.Left_UP_Position.Y - Minus_Y);
            System.Drawing.Point Right_UP  = new System.Drawing.Point(Info.Right_UP_Position.X + Info.Width - Minus_X, Info.Right_UP_Position.Y - Minus_Y);
            System.Drawing.Point Left_Down = new System.Drawing.Point(Info.Left_Down_Position.X - Minus_X, Info.Left_Down_Position.Y + Info.Height - Minus_Y);
            int      New_Width             = Info.Width + Info.Right_UP_Position.X - Info.Left_UP_Position.X;
            int      New_Height            = Info.Height + Info.Left_Down_Position.Y - Info.Left_UP_Position.Y;
            Bitmap   canvas = new Bitmap(New_Width, New_Height);
            Graphics g      = Graphics.FromImage(canvas);
            Bitmap   img    = new Bitmap(TexInfo.Texture_Image.Texture_Main);

            System.Drawing.Point[] destinationPoints = new System.Drawing.Point[] { Left_UP, Right_UP, Left_Down };
            g.DrawImage(img, destinationPoints);
            g.Dispose();
            img.Dispose();
            TexInfo.Texture_Image.Texture_Change       = canvas;
            TexInfo.Texture_Image.Texture_Image.Source = Sub_Code.Bitmap_To_BitmapImage(TexInfo.Texture_Image.Texture_Change);
            Matrix matrix = TexInfo.Texture_Image.Texture_Image.RenderTransform.Value;

            matrix.Translate(-Minus_X * Zoom, -Minus_Y * Zoom);
            TexInfo.Texture_Image.Texture_Image.RenderTransform = new MatrixTransform(matrix);
        }
        double Set_Texture_Zoom(Texture_Info Info, Point Center_Point, double Change_Zoom)
        {
            Matrix matrix = ((MatrixTransform)Info.Texture_Image.Texture_Image.RenderTransform).Matrix;

            matrix.ScaleAt(Change_Zoom, Change_Zoom, Center_Point.X - Info.Texture_Image.Init_Position.X, Center_Point.Y - Info.Texture_Image.Init_Position.Y);
            Info.Texture_Image.Texture_Image.RenderTransform = new MatrixTransform(matrix);
            return(matrix.M11);
        }
Example #4
0
 public void Set_Texture_Opacity(Texture_Info TexInfo, double Opacity)
 {
     System.Drawing.Bitmap Temp_Bitmap = new System.Drawing.Bitmap(TexInfo.Texture_Image.Width, TexInfo.Texture_Image.Height);
     using (System.Drawing.Graphics gfx = System.Drawing.Graphics.FromImage(Temp_Bitmap))
     {
         ColorMatrix matrix = new ColorMatrix();
         matrix.Matrix33 = (float)TexInfo.Property.Opacity.Value;
         ImageAttributes attributes = new ImageAttributes();
         attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
         gfx.DrawImage(TexInfo.Texture_Image.Texture_Main, new System.Drawing.Rectangle(0, 0, Temp_Bitmap.Width, Temp_Bitmap.Height), 0, 0, Temp_Bitmap.Width, Temp_Bitmap.Height, System.Drawing.GraphicsUnit.Pixel, attributes);
     }
     TexInfo.Texture_Image.Texture_Change.Dispose();
     TexInfo.Texture_Image.Texture_Change = Temp_Bitmap;
 }
        public bool Add_Texture(string File, System.Drawing.Point Position)
        {
            Texture_Info Info = Core.Add_Texture(File, Position, Core.All_Textures.Count, true);

            if (Info == null)
            {
                return(false);
            }
            Property_Window.Children.Add(Info.Property.Parent);
            Paint_Canvas.Children.Add(Info.Texture_Image.Texture_Image);
            Set_Texture_Zoom(Info, new Point(Position.X, Position.Y), Core.Zoom);
            Control_Events(Info);
            return(true);
        }
        void Set_Dollet_Line(Texture_Info Select_Texture_Image)
        {
            Texture_Image_Info Info   = Select_Texture_Image.Texture_Image;
            Matrix             matrix = ((MatrixTransform)Info.Texture_Image.RenderTransform).Matrix;
            int Start_X = (int)(Info.Init_Position.X + matrix.OffsetX);
            int Start_Y = (int)(Info.Init_Position.Y + matrix.OffsetY);
            int End_X   = Start_X + (int)(Info.Texture_Image.Width * matrix.M11);
            int End_Y   = Start_Y + (int)(Info.Texture_Image.Height * matrix.M11);

            Rotate_Circles[0].Margin = new Thickness(Start_X - 8 + Info.Left_UP_Position.X * Core.Zoom, Start_Y - 8 + Info.Left_UP_Position.Y * Core.Zoom, 0, 0);
            Rotate_Circles[1].Margin = new Thickness(End_X - 8 + Info.Right_UP_Position.X * Core.Zoom, Start_Y - 8 + Info.Right_UP_Position.Y * Core.Zoom, 0, 0);
            Rotate_Circles[2].Margin = new Thickness(Start_X - 8 + Info.Left_Down_Position.X * Core.Zoom, End_Y - 8 + Info.Left_Down_Position.Y * Core.Zoom, 0, 0);
            Point Left_UP   = new Point(Rotate_Circles[0].Margin.Left + 8, Rotate_Circles[0].Margin.Top + 8);
            Point Right_UP  = new Point(Rotate_Circles[1].Margin.Left + 8, Rotate_Circles[1].Margin.Top + 8);
            Point Left_Down = new Point(Rotate_Circles[2].Margin.Left + 8, Rotate_Circles[2].Margin.Top + 8);

            Draw_Dollet_Line(Left_UP, Right_UP, Left_Down);
        }
        void Control_Events(Texture_Info TexInfo)
        {
            Texture_Property_Info PInfo = TexInfo.Property;

            PInfo.Opacity.ValueChanged += delegate
            {
                TexInfo.Texture_Image.Texture_Image.Opacity = PInfo.Opacity.Value;
            };
            PInfo.ChangeCheckBox += delegate(bool IsVisibility)
            {
                if (IsVisibility)
                {
                    TexInfo.Texture_Image.Texture_Image.Visibility = Visibility.Visible;
                }
                else
                {
                    TexInfo.Texture_Image.Texture_Image.Visibility = Visibility.Hidden;
                }
            };
        }
 private void Texture_Canvas_MouseUp(object sender, MouseButtonEventArgs e)
 {
     if (IsMoveWaitMode)
     {
         IsMoveWaitMode = false;
         Point        MousePoint = Mouse.GetPosition(this);
         Texture_Info Info       = Get_Point_Texture(new System.Drawing.Point((int)MousePoint.X, (int)MousePoint.Y));
         if (Info != null)
         {
             Select_Texture = Info;
             Set_Dollet_Line(Info);
             Dollet_Line_Visibility(true);
         }
         else
         {
             Select_Texture = null;
             Dollet_Line_Visibility(false);
         }
     }
     Move_Select_Texture = Mouse.GetPosition(this);
 }
Example #9
0
 public void Update_Texture(Texture_Info TexInfo)
 {
     TexInfo.Texture_Image.Texture_Image.Source = Sub_Code.Bitmap_To_BitmapImage(TexInfo.Texture_Image.Texture_Change);
 }
Example #10
0
 public void Move_Texture(Texture_Info TexInfo, System.Drawing.Point To_Position)
 {
     TexInfo.Texture_Image.Position             = To_Position;
     TexInfo.Texture_Image.Texture_Image.Margin = new Thickness(To_Position.X, To_Position.Y, 0, 0);
 }
Example #11
0
 public Texture_Info Add_Texture(string File, System.Drawing.Point Init_Position, int Property_Position, bool IsCenterMode)
 {
     if (!IsInited)
     {
         return(null);
     }
     try
     {
         int         ID          = Sub_Code.r.Next(0, int.MaxValue);
         Bitmap      Texture_BMP = null;
         BitmapImage Texture     = null;
         if (Path.GetExtension(File) == ".dds")
         {
             //Texture_BMP = DDS_Format.Load_To_Bitmap(File);
             //Texture = Sub_Code.Bitmap_To_BitmapImage(Texture_BMP);
         }
         else
         {
             Texture     = new BitmapImage(new Uri(File));
             Texture_BMP = new Bitmap(File);
         }
         Canvas Parent = new Canvas();
         Parent.Name = "Property_Parent_" + ID;
         Parent.VerticalAlignment   = VerticalAlignment.Top;
         Parent.HorizontalAlignment = HorizontalAlignment.Left;
         Parent.Width      = 399;
         Parent.Height     = 95;
         Parent.Focusable  = false;
         Parent.Background = System.Windows.Media.Brushes.Transparent;
         Parent.Margin     = new Thickness(0, 95 * Property_Position, 0, 0);
         Slider Opacity = new Slider();
         Opacity.Name = "Opacity_Slider_" + ID;
         Opacity.VerticalAlignment   = VerticalAlignment.Top;
         Opacity.HorizontalAlignment = HorizontalAlignment.Left;
         Opacity.Width     = 200;
         Opacity.Height    = 25;
         Opacity.Focusable = false;
         Opacity.Style     = Slider_Style_Yoko;
         Opacity.Maximum   = 1;
         Opacity.Minimum   = 0;
         Opacity.Value     = 1;
         Opacity.Margin    = new Thickness(150, 70, 0, 0);
         TextBlock File_Name = new TextBlock();
         File_Name.Name = "Texture_Name_" + ID;
         File_Name.Text = Path.GetFileName(File);
         File_Name.VerticalAlignment   = VerticalAlignment.Top;
         File_Name.HorizontalAlignment = HorizontalAlignment.Left;
         File_Name.Width         = 260;
         File_Name.Height        = 70;
         File_Name.Focusable     = false;
         File_Name.Foreground    = System.Windows.Media.Brushes.Aqua;
         File_Name.FontSize      = 25;
         File_Name.TextWrapping  = TextWrapping.Wrap;
         File_Name.TextAlignment = TextAlignment.Center;
         File_Name.Margin        = new Thickness(125, 0, 0, 0);
         System.Windows.Controls.Image Check = new System.Windows.Controls.Image();
         Check.Name                = "Visibility_Image_" + ID;
         Check.Margin              = new Thickness(10, 32.5, 0, 0);
         Check.Width               = 30;
         Check.Height              = 30;
         Check.Stretch             = System.Windows.Media.Stretch.Fill;
         Check.HorizontalAlignment = HorizontalAlignment.Left;
         Check.VerticalAlignment   = VerticalAlignment.Top;
         Check.Focusable           = false;
         Check.Source              = Sub_Code.Check_03;
         System.Windows.Controls.Image Texture_Icon = new System.Windows.Controls.Image();
         Texture_Icon.Name                = "Texture_Icon_" + ID;
         Texture_Icon.Margin              = new Thickness(75, 27.5, 0, 0);
         Texture_Icon.Width               = 50;
         Texture_Icon.Height              = 50;
         Texture_Icon.Stretch             = System.Windows.Media.Stretch.UniformToFill;
         Texture_Icon.HorizontalAlignment = HorizontalAlignment.Left;
         Texture_Icon.VerticalAlignment   = VerticalAlignment.Top;
         Texture_Icon.Focusable           = false;
         Texture_Icon.Source              = Texture;
         Border Texture_Border = new Border();
         Texture_Border.Name                = "Texture_Border_" + ID;
         Texture_Border.Margin              = new Thickness(74, 26.5, 0, 0);
         Texture_Border.Width               = 52;
         Texture_Border.Height              = 52;
         Texture_Border.BorderThickness     = new Thickness(1);
         Texture_Border.BorderBrush         = System.Windows.Media.Brushes.Aqua;
         Texture_Border.HorizontalAlignment = HorizontalAlignment.Left;
         Texture_Border.VerticalAlignment   = VerticalAlignment.Top;
         Texture_Border.Focusable           = false;
         Parent.Children.Add(Opacity);
         Parent.Children.Add(File_Name);
         Parent.Children.Add(Check);
         Parent.Children.Add(Texture_Icon);
         Parent.Children.Add(Texture_Border);
         System.Windows.Controls.Image Texture_Image = new System.Windows.Controls.Image();
         Texture_Image.Name                = "Texture_Image_" + ID;
         Texture_Image.Width               = Texture_BMP.Width;
         Texture_Image.Height              = Texture_BMP.Height;
         Texture_Image.VerticalAlignment   = VerticalAlignment.Top;
         Texture_Image.HorizontalAlignment = HorizontalAlignment.Left;
         Texture_Image.Focusable           = false;
         Texture_Image.Source              = Texture;
         Texture_Image.Stretch             = Stretch.Uniform;
         System.Drawing.Point Set_Position = Init_Position;
         if (IsCenterMode)
         {
             Set_Position = Position_To_Center(Init_Position, (int)Texture.Width, (int)Texture.Height);
         }
         Texture_Image.Margin = new Thickness(Set_Position.X, Set_Position.Y, 0, 0);
         Texture_Property_Info Property_Info = new Texture_Property_Info(Parent, Opacity, File_Name, Check, Texture_Icon, Texture_Border);
         Texture_Image_Info    Image_Info    = new Texture_Image_Info(Texture_BMP, Texture_Image, Set_Position, Property_Position);
         Texture_Info          Info          = new Texture_Info(Property_Info, Image_Info, ID);
         Check.MouseEnter += delegate
         {
             if (Property_Info.IsVisibility)
             {
                 Check.Source = Sub_Code.Check_04;
             }
             else
             {
                 Check.Source = Sub_Code.Check_02;
             }
         };
         Check.MouseLeave += delegate
         {
             if (Property_Info.IsVisibility)
             {
                 Check.Source = Sub_Code.Check_03;
             }
             else
             {
                 Check.Source = Sub_Code.Check_01;
             }
         };
         All_Textures.Add(Info);
         Move_Texture(Info, Set_Position);
         return(Info);
     }
     catch (Exception e)
     {
         Sub_Code.Error_Log_Write(e.Message);
         return(null);
     }
 }