Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 00:05

    cwensley on develop

    Wpf: Fix crash when setting the… Merge pull request #2358 from c… (compare)

  • 00:05
    cwensley closed #2358
  • Nov 29 23:54
    cwensley milestoned #2358
  • Nov 29 23:54
    cwensley labeled #2358
  • Nov 29 23:54
    cwensley opened #2358
  • Nov 29 23:54
    cwensley milestoned #2358
  • Nov 28 20:02
    cwensley commented #2357
  • Nov 28 19:58
    dsoronda commented #2357
  • Nov 25 18:30
    cwensley milestoned #2353
  • Nov 25 18:30
    cwensley labeled #2353
  • Nov 25 18:29
    cwensley closed #2353
  • Nov 25 18:29
    cwensley milestoned #2354
  • Nov 25 18:29
    cwensley milestoned #2354
  • Nov 25 18:29
    cwensley labeled #2354
  • Nov 25 18:28

    cwensley on develop

    Bump Eto.WinForms support down … Merge pull request #2354 from B… (compare)

  • Nov 25 18:28
    cwensley closed #2354
  • Nov 25 18:28
    cwensley commented #2354
  • Nov 25 18:26
    Beyley commented #2354
  • Nov 25 17:42
    cwensley commented #2354
  • Nov 25 10:23
    Beyley commented #2354
Eternal
@EternalClickbait
Still can't get the sizing to work though :(
Eternal
@EternalClickbait

@cwensley Really sorry to keep bothering you, but I've had a look through the repo issues and done some googling, and I can't find a solution.
I followed what you said, and I set the sizes like so:

        this.MinimumSize                = new Size(160, 90);
        imageContainer.MinimumSize = new Size(160, 90);
        imageContainer.Size        = new Size(-1,  -1);
        imageContainer.ClientSize  = new Size(-1,  -1);
        imageView.Size             = new Size(-1,  -1);

But the image still scales itself to 1920*1080 not the available space.

Curtis Wensley
@cwensley
-1, -1 means auto size. Set imageView.Size = new Size(100, 100), or the minimum size you want it to be.
the ImageView, when auto sized, will default to the size of the image, which is your problem here.
you have to override that and tell it "hey control, it's okay if you're smaller dude"
Eternal
@EternalClickbait
But If I set it to new Size(100,100), then it's too small. What I want is for it to go as big as it can, just not outside the available space it has. So if the available space is 19201080, then it will be 19201080. If the screen is half the size, it'll be 960*540, etc. Like i need auto scaling that changes when i resize the app window, not a fixed size
image.png
Like this is too small now, and I can't just hardcode something in
Eternal
@EternalClickbait

Actually, the docs say

By default, the ImageView will automatically size to the size of the specified Image, otherwise the image will be scaled to fit inside the available area for the control.

How do i get it to limit the available are to the onscreen area.
I would have to constrain the GroupBox right?
Curtis Wensley
@cwensley
No, it depends on where you are placing the ImageView. If you are placing it in a non-scaled row/column in a TableLayout or something then yes, it won't grow. You need to put it in a container that will allow it to expand.
Seeing your entire layout code would help.
Eternal
@EternalClickbait
RenderProgressDisplayPanel:
using Eto.Drawing;
using Eto.Forms;
using Gtk;
using LibEternal.ObjectPools;
using RayTracer.Core.Graphics;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using static Serilog.Log;
using Application = Eto.Forms.Application;
using Orientation = Eto.Forms.Orientation;
using Size = Eto.Drawing.Size;

namespace RayTracer.Display.EtoForms;

internal sealed class RenderProgressDisplayPanel : Panel
{
    /*Properties storing sub-controls*/

    public RenderProgressDisplayPanel(AsyncRenderJob renderJob)
    {
        //TODO
        this.renderJob = renderJob;
        Verbose("Creating StackPanelLayout for content");
        statsTable = new TableLayout
                { ID = "Stats Table" };
        statsContainer = new GroupBox
                { ID = "Stats Container", Text = "Statistics", Content = statsTable };
        previewImage = new Bitmap(renderJob.RenderOptions.Width, renderJob.RenderOptions.Height, PixelFormat.Format24bppRgb)
                { ID = "Preview Image" };
        imageView = new ImageView
                { ID = "Image View", Image = previewImage };
        imageContainer = new GroupBox
                { Text = "Preview", Content = imageView, ID = "Image Container" };
        Content = new StackLayout
        {
                Items       = { statsContainer, imageContainer },
                Orientation = Orientation.Horizontal,
                Spacing     = 10,
                ID          = "Main Content StackLayout"
        };

        TaskWatcher.Watch(Task.Run(UpdatePreviewWorker), false);
    }

    private async Task UpdatePreviewWorker()
    {
        //Updates the content of the image and table
    }

    private void UpdateImagePreview()
    {
        //HACK WARN: Auto sizing doesn't work so need to manually set it
        imageView.Size = new Size(1000, 700);
        using BitmapData data         = previewImage.Lock();
        Stopwatch        stop         = Stopwatch.StartNew();
        int              xSize        = previewImage.Width, ySize = previewImage.Height;
        Image<Rgb24>     renderBuffer = renderJob.ImageBuffer;
        Verbose("Updating image");
        IntPtr offset = data.Data;
        for (int y = 0; y < ySize; y++)
            unsafe
            {
                Span<Rgb24> renderBufRow = renderBuffer.GetPixelRowSpan(y);
                void*       destPtr      = offset.ToPointer();
                Span<Rgb24> destRow      = new(destPtr, xSize);

                renderBufRow.CopyTo(destRow);
                offset += data.ScanWidth;
            }

        Verbose("Finished updating image in {Elapsed}", stop.Elapsed);
    }

    private void UpdateStatsTable()
    {
        //...
    }
Main Form:
using Eto.Drawing;
using Eto.Forms;
using RayTracer.Core.Graphics;
using RayTracer.Core.Scenes;
using System;
using System.Reflection;
using System.Threading.Tasks;
using static Serilog.Log;

namespace RayTracer.Display.EtoForms;

public sealed class MainForm : Form
{
    private readonly RenderOptionSelectorPanel? selectorPanel = null;
    private readonly Label                      titleLabel;
    private          AsyncRenderJob?            renderJob = null;

    public MainForm()
    {
        Verbose("MainForm.Ctor()");

        string title = $"RayTracer.Display - v{Assembly.GetEntryAssembly()!.GetName().Version}";
        Title = title;
        Verbose("Title is {Title}", Title);
        MinimumSize = new Size(200, 200);
        Verbose("Minimum app size set to {MinSize}", MinimumSize);
        Padding = 10;

        Verbose("Creating UI elements");
        titleLabel = new Label { Text = title, Font = new Font(FontFamilies.Sans!, 32f, FontStyle.Bold) };
        StackLayoutItem displayedWindowItem = new() { HorizontalAlignment = HorizontalAlignment.Stretch, Expand = true };
        StackLayoutItem titleItem           = new(titleLabel, HorizontalAlignment.Center);
        Content = new StackLayout
        {
                Items   = { titleItem, displayedWindowItem },
                Spacing = 10
        };


        Verbose("Generating commands");
        Command quitCommand = new() { MenuText = "Quit", Shortcut = Application.Instance!.CommonModifier | Keys.Q };
        quitCommand.Executed += (_, _) => Application.Instance.Quit();

        Command aboutCommand = new() { MenuText = "About..." };
        aboutCommand.Executed += (_, _) => new AboutDialog().ShowDialog(this);

        // create menu
        Verbose("Creating menu bar");
        Menu = new MenuBar
        {
                Items =
                {
                        // File submenu
                        // new SubMenuItem { Text = "&File", Items = { clickMe } }
                        // new SubMenuItem { Text = "&Edit", Items = { /* commands/items */ } },
                        // new SubMenuItem { Text = "&View", Items = { /* commands/items */ } },
                },
                ApplicationItems =
                {
                        // application (OS X) or file menu (others)
                        // new ButtonMenuItem { Text = "&Preferences..." }
                },
                QuitItem  = quitCommand,
                AboutItem = aboutCommand
        };
        const string iconPath = "RayTracer.Display.EtoForms.Appearance.icon.png";
        Verbose("Loading and setting icon from {IconPath}", iconPath);
        Icon = Icon.FromResource(iconPath);

        Verbose("Toolbar disabled");
        ToolBar = null; //new ToolBar { Items = { clickMe } };

        //We start off with an options selection panel, then once the user clicks the 'continue' button, we start the render and change it to the render progress panel
        Verbose("Initializing render options selector subview");
        selectorPanel               = new RenderOptionSelectorPanel((_, _) =>  StartRenderButtonClicked());
        displayedWindowItem.Control = selectorPanel;
    }

    private void StartRenderButtonClicked()
    {
        //Assume that the sender is the same selector panel we have stored
        //Might be bad practice but hey who cares it's easier
        RenderOptions options = selectorPanel!.RenderOptions;
        Scene         scene   = selectorPanel.Scene;

        Information("Render start button clicked");
        Debug("Scene is {Scene}, Options are {Options}", scene, options);

        Debug("Creating render job");
        renderJob = new AsyncRenderJob(scene, options);
        Debug("Starting render job");
        Task renderTask = renderJob.TryStartAsync();
        TaskWatcher.Watch(renderTask, true);

        //Create the display panel
        //TODO: Honestly this is a really bad way to do it and I don't like it, but for some reason removing the children from the stack panel
        // does not work (some weird logical child not equal behaviour) so i gotta create a new layout instead :(
        Verbose("Creating render progress display panel");
        RenderProgressDisplayPanel displayPanel = new(renderJob);
        StackLayoutItem            titleItem    = new(titleLabel, HorizontalAlignment.Center);
        Content = new StackLayout
        {
                Items   = { titleItem, displayPanel },
                Spacing = 10
        };
    }
}
Curtis Wensley
@cwensley
Yikes.. gist maybe?
Eternal
@EternalClickbait
Haha sure
1 second
As you can tell, I'm quite a noob at creating UI's, especially in ETO
Curtis Wensley
@cwensley
The problem here is you're using StackLayout without specifying which item(s) should Expand to fill/shrink to the space available.
you need to use new StackLayoutItem(displayPanel, HorizontalAlignment.Stretch, true), and new StackLayoutItem(imageContainer, VerticalAlignment.Stretch, true) for the respective places those are added to the StackLayout.Items.
Curtis Wensley
@cwensley
The *.Stretch tells it to stretch horizontally/vertically (opposite to the orientation), and the True tells it to fill the available space in the direction/orientation of the stack.
Eternal
@EternalClickbait
Oh my god that was it. Thanks so much it's done now
Curtis Wensley
@cwensley
No problem! One difference between other UI's and Eto is that the container is responsible for the final layout of the control, not the control itself.
Eternal
@EternalClickbait
Ah ok
Eternal
@EternalClickbait
Hey very sorry to do this to you again lol but I'm getting super confused from this - adding items to a table causes NullReferenceExcetpions to be thrown by GTK (see picoe/Eto#2181)
Brian Gallaway
@greatawesome
I ported ZedGraph to Eto: https://github.com/greatawesome/ZedGraph
Curtis Wensley
@cwensley
Cool! Are you planning on publishing a nuget package?
Brian Gallaway
@greatawesome
I'll do some more testing first. I've run the test app on WinForms, WPF, and GTK on Windows, but I still need to test it on Mac and Linux.
Curtis Wensley
@cwensley
Sweet! once you're ready we can add it to the 3rd party library list if you like.
Eternal
@EternalClickbait
Hey can anyone help me with #2181? I have no idea what is going on to be honest
Curtis Wensley
@cwensley
@EternalClickbait I responded on the issue.
Eternal
@EternalClickbait
Thanks so much <3
philstopford
@philstopford
@cwensley : is there a way to assign a context menu to a dropdown or numeric stepper? The ContextMenu doesn't seem to be listed, so I'm curious.
i.e. right-click on the dropdown (instead of left click), or right-click on the numeric stepper.
Curtis Wensley
@cwensley
@philstopford MouseDown then show a ContextMenu manually doesn’t work?
Brian Gallaway
@greatawesome

I think I know the answer, but I don't suppose there is an Expander control that can expand other directions (left to right, right to left, etc), instead of just top down?

I think WPF's expander can do that, but I don't believe the other platforms can.

Curtis Wensley
@cwensley
@greatawesome: Unfortunately not that I'm aware of.
Youness KAFIA
@ykafia
Hi there people!
Just wanna point out i am making a parser for a shader language over there, using Eto.Parse. Really thankful that you guys put this library out, i've been using it for a few weeks and it's really amazing
Curtis Wensley
@cwensley
@ykafia you're very welcome! It was a fun project to put together. Your parser looks very well structured!
Brian Gallaway
@greatawesome
EtoDateTime.png
I'm looking to use the ExtendedDateTimePicker to get a better DarkMode in WinForms, but in Extended mode it gives strange text. Any pointers of where I should look before I dig into this?
Laura Stasiulewicz
@Laura_4R_gitlab
image.png
Hello, I'm looking for tips for styling controls in ETO.
I'm using only code to make my forms, no XAML or JSON is involved.
I was wonderig if adding an 'eye' icon to password box is possible, since passwordbox control has no 'children' property, therefore I dont think I can put anything inside of the input, can I?
SSmall preview from Micrsoft docs with what I have in mind:
LuciferSam86
@LuciferSam86
Hi, just a question. Is the addin required for building Eto.Forms apps compatible with VS 2022? Thanks!
Curtis Wensley
@cwensley
Hey @LuciferSam86, no, you do not need the addin. It adds templates, xaml autocomplete, and a previewer
Curtis Wensley
@cwensley
Otherwise, Eto can be consumed as nuget packages, including the templates using the dotnet command line.
Miepee
@miepee:matrix.org
[m]
Is it possible to make some runtime dependencies on linux (e.g webkit if you use it, libappindicator etc.) Optional and to not cause a runtime crash?
It would make a few things more convenient, e.g newer Debian which changed the appindicator file would still be able to run the application, just not with all bells and whistles.
Miepee
@miepee:matrix.org
[m]
:point_up: Edit: Is it possible to make some runtime dependencies on linux/gtk (e.g webkit if you use it, libappindicator etc.) Optional and to not cause a runtime crash?
It would make a few things more convenient, e.g newer Debian which changed the appindicator file would still be able to run the application, just not with all bells and whistles.