Пример #1
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (identifier.Text.Length > 0)
     {
         IDrawableWidget widget = null;
         if (fieldWidget.IsChecked.Value)
         {
             var field = new DrawableField();
             widget = field;
             field.CharacterSize      = 25;
             field.DisplayedString    = "<exemple>";
             field.FillColor          = SFML.Graphics.Color.Black;
             field.OutlineColor       = SFML.Graphics.Color.Black;
             field.Font               = App.Roboto;
             field.Position           = new SFML.System.Vector2f(X, Y);
             field.Field              = new Template.Field();
             field.Field.Size         = 25;
             field.Field.InnerColor   = System.Drawing.Color.Black;
             field.Field.OutsideColor = System.Drawing.Color.Black;
             field.Field.Content      = "";
             field.Field.Font         = "Roboto";
             field.Field.Location     = new System.Numerics.Vector2(X, Y);
         }
         App.CurrentFile.Widgets.Insert(0, (identifier.Text, widget.Link));
         App.Preview.ToDraw.Insert(0, widget);
         EditorProperties.UpdateWidgetList();
         DialogResult = true;
     }
     else
     {
         identifierText.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 50, 50));
         identifier.BorderBrush    = identifierText.Foreground;
     }
 }
Пример #2
0
        public static void StartEditor(Template file)
        {
            Fonts       = new Dictionary <string, Font>();
            VBO         = new RenderTexture(1500, 1500);
            CurrentFile = file;
            Task.Run(() =>
            {
                Preview = new EditorPreview((float)file.Background.Width / file.Background.Height);
                Preview.Window.MouseButtonPressed += (sender, e) =>
                {
                    if (e.Button == Mouse.Button.Right)
                    {
                        App.Current.Dispatcher.Invoke(() => new NewWidget(Preview.Window.MapPixelToCoords(new Vector2i(e.X, e.Y))).ShowDialog());
                    }
                };
                Preview.Start();
            });
            while (Preview == null)
            {
                System.Threading.Thread.Sleep(100);
            }
            var list = new List <IDrawableWidget>();

            Preview.ToDraw     = list;
            Preview.Background = new Texture(CreateSFMLImage(file.Background))
            {
                Smooth = true
            };
            Fonts.Add("Roboto", Roboto);
            foreach (var font in file.CustomFonts)
            {
                Fonts.Add(font.Key, new Font(font.Value));
            }
            foreach (var widget in file.Widgets)
            {
                Preview.ToDraw.Add(GetDrawable(widget.Item2, true));
            }
            var dialog = new EditorProperties();

            Preview.Window.Closed += (sender, e) => dialog.Dispatcher.Invoke(() => dialog.Close());
            dialog.ShowDialog();
        }
 public EditorProperties() : base()
 {
     Instance = this;
     InitializeComponent();
     UpdateWidgetList();
 }