Exemple #1
0
 public static string openFileDialog(string filter, string currentfile, string themeFile)
 {
     if (!File.Exists(themeFile))
     {
         MessageBox.Show("To specify relative paths, select the platform with the theme.xml file", "Attention", MessageBoxButton.OK);
         return(null);
     }
     else
     {
         OpenFileDialog myDialog = new OpenFileDialog();
         myDialog.Filter = filter;
         if (currentfile != "")
         {
             currentfile = SomeUtilities.MakeAbsolutePath(themeFile, currentfile);
         }
         if (File.Exists(currentfile))
         {
             myDialog.FileName = currentfile;
         }
         myDialog.CheckFileExists = true;
         myDialog.Multiselect     = true;
         //myDialog.InitialDirectory = tb_themefolder.Text;
         if (myDialog.ShowDialog() == true)
         {
             return(SomeUtilities.MakeRelativePath(themeFile, myDialog.FileName));
         }
         return(null);
     }
 }
 public string getImagePath()
 {
     if (tb_filledPath.Text == "")
     {
         return("");
     }
     return(SomeUtilities.MakeAbsolutePath(((App)Application.Current).themefolder + ((App)Application.Current).gameplatformtheme + "\\theme.xml", tb_filledPath.Text));
 }
        public void setProperty(string name, string value)
        {
            //if (name == "")
            //    return;

            switch (name)
            {
            case "path":
            case "filledPath":    //сюда же будем показывать и рейтинг
            case "unfilledPath":  //сюда же будем показывать и рейтинг
                if (value != "")
                {
                    value = SomeUtilities.MakeAbsolutePath(((App)Application.Current).themefolder + ((App)Application.Current).gameplatformtheme + "\\theme.xml", value);
                }
                if (setImage(value))
                {
                    this.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    this.Visibility = System.Windows.Visibility.Hidden;
                }
                break;

            case "color":
                image.Opacity = SomeUtilities.getOpacityFromHex(value);
                break;

            case "tile":
                if (value == "1")
                {
                    image.Stretch = Stretch.Fill;
                }
                if (value == "0")
                {
                    image.Stretch = Stretch.Uniform;
                }
                break;
            }
        }
Exemple #4
0
 private void btn_read_XML_Click(object sender, RoutedEventArgs e)
 {
     include = "";
     views.Clear();
     readXML();
     if (include != "")
     {
         string filename = SomeUtilities.MakeAbsolutePath(tb_themefolder.Text + "\\" + cbx_gameplatformtheme.SelectedItem.ToString() + "\\theme.xml", include);
         if (File.Exists(filename))
         {
             tb_log.Text = File.ReadAllText(filename);
         }
         try
         {
             readXML();
         }
         catch (Exception err)
         {
             Logger.Write(err);
             return;
         }
     }
 }
        public bool setImage(string filename)
        {
            if (!File.Exists(filename))
            {
                filename = SomeUtilities.MakeAbsolutePath(((App)Application.Current).themefolder + ((App)Application.Current).gameplatformtheme + "\\theme.xml", filename);
                if (!File.Exists(filename))
                {
                    return(false);
                }
            }

            BitmapImage bitmap = new BitmapImage();

            bitmap.BeginInit();
            bitmap.UriSource = new Uri(filename);
            bitmap.EndInit();
            image.Source = bitmap;
            if (bitmap != null)
            {
                return(true);
            }

            return(false);
        }
Exemple #6
0
        public void setProperty(string name, string value)
        {
            if (name == "")
            {
                return;
            }
            switch (name)
            {
            case "alignment":
                if (value.ToLower() == "center")
                {
                    alignment = "Center";
                }
                if (value.ToLower() == "right")
                {
                    alignment = "Right";
                }
                if (value.ToLower() == "left")
                {
                    alignment = "Left";
                }
                setStyle();
                break;

            case "primaryColor":
                if (primaryColor != value)
                {
                    primaryColor = value;
                    setStyle();
                }
                break;

            case "selectedColor":
                if (selectedColor != value)
                {
                    selectedColor = value;
                    setStyle();
                }
                break;

            case "selectorColor":
                if (selectorColor != value)
                {
                    selectorColor = value;
                    setStyle();
                }
                break;

            case "fontSize":
                double fontsize;
                if (!double.TryParse(value.Replace(".", ","), out fontsize))
                {
                    return;
                }
                if (fontsize > 0)
                {
                    fontsize             = ((App)Application.Current).Height * fontsize;
                    lb_gamelist.FontSize = fontsize;
                    ScrollToLastItem();
                    this.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    this.Visibility = System.Windows.Visibility.Hidden;
                }
                break;

            case "fontPath":
                value = SomeUtilities.MakeAbsolutePath(((App)Application.Current).themefolder + ((App)Application.Current).gameplatformtheme + "\\theme.xml", value);
                if (File.Exists(value))
                {
                    PrivateFontCollection fileFonts = new PrivateFontCollection();
                    fileFonts.AddFontFile(value);
                    value = value.Replace(System.IO.Path.GetFileName(value), "#" + fileFonts.Families[0].Name).Replace("\\", "/");
                    lb_gamelist.FontFamily = new FontFamily("file:///" + value);
                    this.Visibility        = System.Windows.Visibility.Visible;
                    lb_gamelist.UpdateLayout();
                }
                else
                {
                    this.Visibility = System.Windows.Visibility.Hidden;
                }
                break;

            case "forceUppercase":
                if (value == "1")
                {
                    fillCBX(true);
                }
                if (value == "0")
                {
                    fillCBX();
                }
                break;
            }
        }
        private void btn_setBackground_Click(object sender, RoutedEventArgs e)
        {
            string filename;

            filename = toolbox.currentView.background;
            if (filename == "")
            {
                return;
            }
            //if (this.Title.ToLower() == "system")
            //    filename = ((App)Application.Current).backgroundImagePath;
            //else
            //    filename = ((App)Application.Current).backgroundSystemImagePath;
            filename = SomeUtilities.MakeAbsolutePath(((App)Application.Current).themefolder + ((App)Application.Current).gameplatformtheme + "\\theme.xml", filename);
            if (!File.Exists(filename))
            {
                return;
            }
            Image image = SomeUtilities.FindChild <Image>(canvas, "Backgroundimage");

            if (image != null)
            {
                if (image.Visibility == System.Windows.Visibility.Visible)
                {
                    image.Visibility = System.Windows.Visibility.Hidden;
                }
                else
                {
                    image.Visibility = System.Windows.Visibility.Visible;
                    BitmapImage bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.UriSource = new Uri(filename);
                    bitmap.EndInit();

                    //image = new Image();
                    image.Name       = "Backgroundimage";
                    image.Source     = bitmap;
                    image.Width      = canvas1.Width;
                    image.Height     = canvas1.Height;
                    image.MouseDown += canvas1_MouseDown;
                    //Panel.SetZIndex(image, 0);
                    //canvas1.Children.Add(image);
                }
            }
            else
            {
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.UriSource = new Uri(filename);
                bitmap.EndInit();

                image            = new Image();
                image.Name       = "Backgroundimage";
                image.Source     = bitmap;
                image.Width      = canvas1.Width;
                image.Height     = canvas1.Height;
                image.MouseDown += canvas1_MouseDown;
                Panel.SetZIndex(image, 0);
                canvas1.Children.Add(image);
            }
        }
        public void setProperty(string name, string value)
        {
            if (name == "")
            {
                return;
            }
            switch (name)
            {
            case "text":
                if (value != "")
                {
                    somestring = value;
                }
                fill(forceUppercase);
                break;

            case "alignment":
                if (value.ToLower() == "center")
                {
                    date.TextAlignment = TextAlignment.Center;
                }
                if (value.ToLower() == "right")
                {
                    date.TextAlignment = TextAlignment.Right;
                }
                if (value.ToLower() == "left")
                {
                    date.TextAlignment = TextAlignment.Left;
                }
                break;

            case "color":
                if (color != value)
                {
                    color           = value;
                    date.Foreground = SomeUtilities.GetBrushFromHex(value);
                }
                break;

            case "fontSize":
                double fontsize;
                if (!double.TryParse(value.Replace(".", ","), out fontsize))
                {
                    return;
                }
                if (fontsize > 0)
                {
                    fontsize        = ((App)Application.Current).Height * fontsize;
                    date.FontSize   = fontsize;
                    this.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    this.Visibility = System.Windows.Visibility.Hidden;
                }
                break;

            case "fontPath":
                value = SomeUtilities.MakeAbsolutePath(((App)Application.Current).themefolder + ((App)Application.Current).gameplatformtheme + "\\theme.xml", value);
                if (File.Exists(value))
                {
                    PrivateFontCollection fileFonts = new PrivateFontCollection();
                    fileFonts.AddFontFile(value);
                    value           = value.Replace(System.IO.Path.GetFileName(value), "#" + fileFonts.Families[0].Name).Replace("\\", "/");
                    date.FontFamily = new FontFamily("file:///" + value);
                    this.Visibility = System.Windows.Visibility.Visible;
                    date.UpdateLayout();
                }
                else
                {
                    this.Visibility = System.Windows.Visibility.Hidden;
                }
                break;

            case "forceUppercase":
                if (value == "1")
                {
                    forceUppercase = true;
                }
                if (value == "0")
                {
                    forceUppercase = false;
                }
                fill(forceUppercase);
                break;
            }
            fill(forceUppercase);
        }