예제 #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            comboBox1.Items.Clear();
            comboBox1.Items.Add(new WorkPath("ClarityHUD", System.AppDomain.CurrentDomain.BaseDirectory + @"\works\Clarity"));
            comboBox1.Items.Add(new WorkPath("OLD", System.AppDomain.CurrentDomain.BaseDirectory + @"\works\Normal", true));
            Statik.frm1 = this;
            foreach (var fl in Directory.GetFiles(System.AppDomain.CurrentDomain.BaseDirectory + "\\Textures\\", "*.dds"))
            {
                try
                {
                    ImageSourceConverter c   = new ImageSourceConverter();
                    DDSImage             dds = new DDSImage(File.ReadAllBytes(fl), true);
                    BitmapSource         src = Statik.ToWpfBitmap(dds.BitmapImage);

                    FileInfo fi = new FileInfo(fl);
                    Statik.textures.Add(new Ctexture()
                    {
                        Name = fi.Name.Replace(fi.Extension, ""), img = src
                    });
                }
                catch (Exception exx)
                {
                    MessageBox.Show(exx.Message);
                }
            }

            panel1.PreviewMouseLeftButtonDown += Panel1_PreviewMouseLeftButtonDown;
            panel1.OnChangeElement            += Panel1_OnChangeElement;
            var window = Window.GetWindow(this);

            window.KeyDown += Panel1_KeyDown;
        }
예제 #2
0
        private void lwFiles_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.OriginalSource is TextBlock)
            {
                if (((TextBlock)e.OriginalSource).Background == Brushes.Red)
                {
                    ((TextBlock)e.OriginalSource).Background = Brushes.Transparent;
                    HitTestResult result = VisualTreeHelper.HitTest(lwFiles, e.GetPosition(lwFiles));
                    ListBoxItem   lbi    = Statik.FindParent <ListBoxItem>(result.VisualHit);
                    WKeyVal       vl     = lbi.DataContext as WKeyVal;
                    WorkPath      wp     = ((WorkPath)comboBox1.SelectedItem);

                    panel1.removeBack(vl.Val.ToString());
                }
                else
                {
                    ((TextBlock)e.OriginalSource).Background = Brushes.Red;

                    HitTestResult result = VisualTreeHelper.HitTest(lwFiles, e.GetPosition(lwFiles));
                    ListBoxItem   lbi    = Statik.FindParent <ListBoxItem>(result.VisualHit);
                    WKeyVal       vl     = lbi.DataContext as WKeyVal;
                    WorkPath      wp     = ((WorkPath)comboBox1.SelectedItem);

                    panel1.addBack(vl.Val.ToString(), wp.OverrideOldTexture);
                }
            }
            e.Handled = true;
        }
예제 #3
0
        public void renderBackground()
        {
            gdi.Bitmap img = new gdi.Bitmap(1024, 768);

            using (var g = gdi.Graphics.FromImage(img))
            {
                gdi.Brush sl = new gdi.SolidBrush(gdi.Color.FromArgb(234, 234, 234));
                g.FillRectangle(sl, 0, 0, 1024, 768);
                foreach (var item in backElements)
                {
                    Rect rc = new Rect(item.getLeft(), item.getTop(), item.getWidth(), item.getHeight());
                    if (rc.Width == 0 || rc.Height == 0)
                    {
                        continue;
                    }
                    ImageSource si = item.getImage();
                    if (si == null)
                    {
                        continue;
                    }

                    //dc.DrawImage(CreateResizedImage(img, item.getWidth(), item.getHeight()), rc);
                    gdi.Image gi = Statik.CroppedBitmapToBitmap(si as CroppedBitmap);

                    g.DrawImage(gi, item.getLeft(), item.getTop(), item.getWidth(), item.getHeight());
                }
            }

            ImageBrush ib = new ImageBrush(Statik.ToWpfBitmap(img));

            this.Background = ib;
        }
예제 #4
0
        private void removeBackImage_Click(object sender, RoutedEventArgs e)
        {
            panel1.Background = null;
            gdi.Bitmap img = new gdi.Bitmap(1024, 768);

            using (var g = gdi.Graphics.FromImage(img))
            {
                gdi.Brush sl = new gdi.SolidBrush(gdi.Color.FromArgb(234, 234, 234));
                g.FillRectangle(sl, 0, 0, 1024, 768);
            }
            ImageBrush ib = new ImageBrush(Statik.ToWpfBitmap(img));

            panel1.Background = ib;
        }