Ejemplo n.º 1
0
        public void Update(string FileName)
        {
            if (Equals(FileName, "Empty"))
            {
                SetEmpty();
            }
            else
            {
                Image = new BitmapImage(new Uri(FileName));
                string xml = Path.GetDirectoryName(FileName) + "\\" + Path.GetFileNameWithoutExtension(FileName) + ".xml";
                ParseDescription(xml);
            }

            BackgroundImageChanged?.Invoke();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 选择图片
        /// </summary>
        /// <param name="bgPath">被选择的图片路径</param>
        private void SelectImage(string bgPath)
        {
            string thumbPath = Path.Combine(AyuiConfig.AYUI_BackgroundImageThumbDirectoryPath, "z自定义", Path.GetFileName(bgPath));

            ConfigSetting.SetXmlValue("skinBg", "path", bgPath.Replace(Environment.CurrentDirectory, ""));
            if (!File.Exists(thumbPath))
            {
                Bitmap      bm          = new Bitmap(bgPath);
                BitmapImage bi          = bm.SetSize(128, 72).ToBitmapImage();
                byte[]      thumbBuffer = bi.ToBytes();
                if (!Directory.Exists(Path.GetDirectoryName(thumbPath)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(thumbPath));
                }
                FileStream fs = new FileStream(thumbPath, FileMode.Create);
                fs.Write(thumbBuffer, 0, thumbBuffer.Length);
                fs.Close();
            }
            ConfigSetting.SetXmlValue("skinBg", "thumb", thumbPath.Replace(Environment.CurrentDirectory, ""));
            //更新主题色,使出反编译大法才找到下面这个方法↓
            ThemeManager.AYUI(Application.Current);
            BackgroundImageChanged?.Invoke(this, new StringEventArgs(bgPath));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Raises the BackgroundImageChanged event.
 /// </summary>
 /// <param name="e">An EventArgs containing the event data.</param>
 protected override void OnBackgroundImageChanged(EventArgs e)
 {
     BackgroundImageChanged?.Invoke(this, e);
 }