Exemple #1
0
        public static BitmapImage GetImageBySenderName(string skinpath, Image sender) //все методы ниже - велосипеды собственного производства
        {
            string SkinElem;

            if (sender.Name.Contains("_Copy"))
            {
                string temp = sender.Name.Remove(sender.Name.IndexOf("_Copy"));
                SkinElem = SkinWorker.Name2FileNameConv(skinpath + "\\" + temp + ".png", false);
            }
            else
            {
                SkinElem = SkinWorker.Name2FileNameConv(skinpath + "\\" + sender.Name + ".png", false);
            }

            BitmapImage NewImage;

            try
            {
                NewImage = new BitmapImage(new Uri(skinpath + "\\" + SkinElem));
            }
            catch (FileNotFoundException)
            {
                string uri = DefaultSkinAbsPath + "\\" + SkinElem; //уничтожить
                NewImage = new BitmapImage(new Uri(uri));
            }
            return(NewImage);
        }
        private void ButtonSkinScan_Click(object sender, RoutedEventArgs e)
        {
            string temp = TextBoxOsuPath.Text + "Skins";

            if (!(TextBoxOsuPath.Text.Contains("osu!/") || TextBoxOsuPath.Text.Contains("osu!\\")))
            {
                TextBoxOsuPath.Background = Brushes.Red;
                MessageBox.Show("Present", "Exception"); //отсылка к самой крутой игре в мире
                return;
            }
            TextBoxOsuPath.Background = Brushes.Green;

            SkinWorker.GetAllFiles(temp);
            SkinWorker.GetSkinNames(temp);

            ProgressBarExport.Value   = 0;
            ProgressBarExport.Maximum = SkinWorker.ExistingSkins.Length;

            ComboBoxExistingSkin.Items.Clear(); //чтобы не заполняло дубликатами
            ComboBoxExistingSkin.Items.Add(SkinWorker.DefaultSkinAbsPath);

            foreach (string elem in SkinWorker.ExistingSkins)
            {
                ComboBoxExistingSkin.Items.Add(elem);
                ProgressBarExport.Value++;
                this.UpdateLayout();
            }
            ComboBoxExistingSkin.Visibility    = Visibility.Visible;
            ComboBoxExistingSkin.SelectedIndex = 0;
        }
        private void Image_MouseEnter(object sender, MouseEventArgs e) //для экспорта файлов -over нужно проводить по ним мышкой
        {                                                              //в идеале надо захардкодить -овер элементы, их не так много
            var         HoveredImage = sender as Image;
            ImageSource CurrentHoveredImageSource = HoveredImage.Source;

            LabelStatus.Content = $"{HoveredImage.Name} hovered :)";
            HoveredImage.Source = SkinWorker.GetImageByDirectPath((HoveredImage.Source.ToString().Replace(".png", "-over.png")));
            if (HoveredImage.Source == null)
            {
                HoveredImage.Source = CurrentHoveredImageSource;
            }
            else
            {
                Image tempimage = new Image
                {
                    Name   = HoveredImage.Name + "_over", //заменить в дальнейшем на что-то более человеческое
                    Source = HoveredImage.Source
                };

                if (OnScreenImages.Contains(tempimage))
                {
                    return;
                }
                else
                {
                    OnScreenImages.Add(tempimage);
                }
            }
            HoveredImage.Opacity = 0.8;
        }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     // ???
     menu_button_background.Source = SkinWorker.ImageSourceFromBitmap(
         BitmapProcessing.MergeTwoImages(
             System.Drawing.Image.FromFile(
                 menu_button_background.Source.ToString().Remove(0, 8)
                 ),
             System.Drawing.Image.FromFile("Resources/upper.png")
             )
         );
 }
        private void ComboBoxExistingSkin_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ComboBoxExistingSkin.SelectedValue != null)
            {
                string path = ComboBoxExistingSkin.SelectedValue as string;
                foreach (Image elem in OnScreenImages)
                {
                    elem.Source = SkinWorker.GetImageBySenderName(path, elem);
                }

                ButtonSkinIni_Click(sender, e);
                SetCursor();
            }
        }
 private void ButtonSkinExport_Click(object sender, RoutedEventArgs e)
 {
     ProgressBarExport.Value = 0;
     File.WriteAllLines("export\\skin.ini", SkinIniParser.SkinIniToExport());
     Directory.CreateDirectory("export");
     foreach (Image elem in OnScreenImages)
     {
         File.Copy(elem.Source.ToString().Remove(0, 8), "export\\" + SkinWorker.Name2FileNameConv(elem.Source.ToString(), false), true);
         ZipExporter.AddFileToZip(TextBoxExportSkinName.Text + ".osk", elem.Source.ToString().Remove(0, 8)); //it just works
         ProgressBarExport.Value++;                                                                          //factory new
     }
     ZipExporter.AddFileToZip(TextBoxExportSkinName.Text + ".osk", "export\\skin.ini");
     Process.Start("export\\");
 }
        private void Image_MouseLeave(object sender, MouseEventArgs e)
        {
            var UnHoveredImage = sender as Image;

            LabelStatus.Content = $"{UnHoveredImage.Name} unhovered :(";
            try //костыль
            {
                UnHoveredImage.Source = SkinWorker.GetImageByDirectPath(UnHoveredImage.Source.ToString().Replace("-over.png", ".png"));
            }
            catch
            {
            }
            UnHoveredImage.Opacity = 1;
        }
        private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var    ClickedImage    = sender as Image;
            string SenderSkinImage = SkinWorker.Name2FileNameConv(ClickedImage.Source.ToString(), false);

            LabelStatus.Content = $"{ClickedImage.Name} clicked!";
            //сделать свой файл эксплорер

            //temporary
            OpenFileDialog myDialog = new OpenFileDialog
            {
                Filter          = $"ElementName ({SenderSkinImage}|{SenderSkinImage}",
                CheckFileExists = true,
                Multiselect     = false
            };

            if (myDialog.ShowDialog() == true)
            {
                ClickedImage.Source = SkinWorker.GetImageByDirectPath(myDialog.FileName);

                SetCursor();//костыль
            }
        }