Пример #1
0
        public View3dControl(string name, bool gdi_compatible_backbuffer)
        {
            try
            {
                BackColor = Color.Gray;
                if (this.IsInDesignMode())
                {
                    return;
                }
                SetStyle(ControlStyles.Selectable, false);

                View3d        = View3d.Create();
                Window        = new View3d.Window(View3d, Handle, gdi_compatible_backbuffer, dbg_name: name);
                Window.Error += (s, a) => ReportError?.Invoke(this, new ReportErrorEventArgs(a.Message));

                InitializeComponent();

                Name                     = name;
                ClickTimeMS              = 180;
                MouseNavigation          = true;
                DefaultKeyboardShortcuts = true;
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Пример #2
0
 public Model(string[] args)
 {
     Sync           = SynchronizationContext.Current ?? throw new Exception("No synchronisation context available");
     View3d         = View3d.Create();
     StartupOptions = new StartupOptions(args);
     Settings       = new SettingsData(StartupOptions.SettingsPath);
     FileWatchTimer = new DispatcherTimer(DispatcherPriority.ApplicationIdle);
     Scenes         = new ObservableCollection <SceneUI>();
     Scripts        = new ObservableCollection <ScriptUI>();
     Assets         = new ObservableCollection <AssetUI>();
 }
Пример #3
0
        public View3dControl()
        {
            InitializeComponent();
            Stretch           = Stretch.Fill;
            StretchDirection  = StretchDirection.Both;
            UseLayoutRounding = true;
            Focusable         = true;

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            try
            {
                // Initialise View3d in off-screen only mode (i.e. no window handle)
                View3d        = View3d.Create();
                Window        = new View3d.Window(View3d, IntPtr.Zero);
                Window.Error += (s, a) => OnReportError(new ReportErrorEventArgs(a.Message));
                Camera.Lookat(new v4(0, 0, 10, 1), v4.Origin, v4.YAxis);
                Camera.ClipPlanes(0.01f, 1000f, true);

                // Create a D3D11 off-screen render target image source
                Source = D3DImage = new D3D11Image();

                // Set defaults
                BackgroundColour         = Window.BackgroundColour;
                DesiredPixelAspect       = 1;
                ClickTimeMS              = 180;
                MouseNavigation          = true;
                DefaultKeyboardShortcuts = true;
                ViewPreset = EViewPreset.Current;

                // Default context menu implementation
                if (ContextMenu != null && ContextMenu.DataContext == null)
                {
                    ContextMenu.DataContext = this;
                }

                InitCommands();
                DataContext = this;
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Пример #4
0
            protected Element(Guid id, m4x4 position, string name)
            {
                View3d = View3d.Create();
                m_vbuf = new List <View3d.Vertex>();
                m_nbuf = new List <View3d.Nugget>();
                m_ibuf = new List <ushort>();

                Id              = id;
                Name            = name;
                m_chart         = null;
                m_impl_position = position;
                m_impl_bounds   = new BBox(position.pos, v4.Zero);
                m_impl_selected = false;
                m_impl_hovered  = false;
                m_impl_visible  = true;
                m_impl_visible_to_find_range = true;
                m_impl_screen_space          = false;
                m_impl_enabled = true;
                IsInvalidated  = true;
                UserData       = new Dictionary <Guid, object>();
            }
Пример #5
0
            protected Element(Guid id, string?name = null, m4x4?position = null)
            {
                View3d = View3d.Create();
                m_vbuf = new List <View3d.Vertex>();
                m_nbuf = new List <View3d.Nugget>();
                m_ibuf = new List <ushort>();

                Id         = id;
                m_name     = name ?? string.Empty;
                m_colour   = Colour32.Black;
                m_chart    = null;
                m_o2w      = position ?? m4x4.Identity;
                m_selected = false;
                m_hovered  = false;
                m_visible  = true;
                m_visible_to_find_range = true;
                m_screen_space          = false;
                m_enabled     = true;
                IsInvalidated = true;
                UserData      = new Dictionary <Guid, object>();
            }
Пример #6
0
 public LdrEditorUI()
 {
     InitializeComponent();
     m_view3d = View3d.Create();
     m_sci.InitLdrStyle();
 }
Пример #7
0
        public MainWindow()
        {
            InitializeComponent();
            View3d        = View3d.Create();
            View3d.Error += (object?sender, View3d.ErrorEventArgs e) => MsgBox.Show(this, e.Message, "View3d Error");

            Things = new ListCollectionView(m_things);
#if DEBUG
            PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Critical;
#endif
            m_recent_files.Add("One", false);
            m_recent_files.Add("Two", false);
            m_recent_files.Add("Three");
            m_recent_files.RecentFileSelected += s => Debug.WriteLine(s);

            ShowColourPicker = Command.Create(this, () =>
            {
                new ColourPickerUI().Show();
            });
            ShowChart = Command.Create(this, () =>
            {
                new ChartUI().Show();
            });
            ShowDiagram = Command.Create(this, () =>
            {
                new DiagramUI().Show();
            });
            ShowDiagram2 = Command.Create(this, () =>
            {
                new Diagram2UI().Show();
            });
            ShowDirectionPicker = Command.Create(this, () =>
            {
                var win = new Window
                {
                    Owner = this,
                    WindowStartupLocation = WindowStartupLocation.CenterOwner,
                };
                win.Content = new DirectionPicker();
                win.ShowDialog();
            });
            ShowDockContainer = Command.Create(this, () =>
            {
                new DockContainerUI().Show();
            });
            ShowJoystick = Command.Create(this, () =>
            {
                new JoystickUI().Show();
            });
            ShowMsgBox = Command.Create(this, () =>
            {
                var msg =
                    "Informative isn't it\nThis is a really really really long message to test the automatic resizing of the dialog window to a desirable aspect ratio. " +
                    "It's intended to be used for displaying error messages that can sometimes be really long. Once I had a message that was so long, it made the message " +
                    "box extend off the screen and you couldn't click the OK button. That was a real pain so that's why I've added this auto aspect ratio fixing thing. " +
                    "Hopefully it'll do the job in all cases and I'll never have to worry about it again...\n Hopefully...";
                var dlg = new MsgBox(this, msg, "Massage Box", MsgBox.EButtons.YesNoCancel, MsgBox.EIcon.Exclamation)
                {
                    ShowAlwaysCheckbox = true
                };
                dlg.ShowDialog();
            });
            ShowListUI = Command.Create(this, () =>
            {
                var dlg = new ListUI(this)
                {
                    Title         = "Listing to the Left",
                    Prompt        = "Select anything you like",
                    SelectionMode = SelectionMode.Multiple,
                    AllowCancel   = false,
                };
                dlg.Items.AddRange(new[] { "One", "Two", "Three", "Phooore, was that you?" });
                if (dlg.ShowDialog() == true)
                {
                    MsgBox.Show(this, $"{string.Join(",", dlg.SelectedItems.Cast<string>())}! Good Choice!", "Result", MsgBox.EButtons.OK);
                }
            });
            ShowLogUI = Command.Create(this, () =>
            {
                var log_ui = new LogControl {
                    LogEntryPattern = new Regex(@"^(?<Tag>.*?)\|(?<Level>.*?)\|(?<Timestamp>.*?)\|(?<Message>.*)", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.Compiled)
                };
                var dlg = new Window {
                    Title = "Log UI", Content = log_ui, ResizeMode = ResizeMode.CanResizeWithGrip
                };
                dlg.Show();
            });
            ShowPatternEditor = Command.Create(this, () =>
            {
                new PatternEditorUI().Show();
            });
            ShowProgressUI = Command.Create(this, () =>
            {
                var dlg = new ProgressUI(this, "Test Progress", "Testicles", System.Drawing.SystemIcons.Exclamation.ToBitmapSource(), CancellationToken.None, (u, _, p) =>
                {
                    for (int i = 0, iend = 100; !u.CancelPending && i != iend; ++i)
                    {
                        p(new ProgressUI.UserState
                        {
                            Description      = $"Testicle: {i / 10}",
                            FractionComplete = 1.0 * i / iend,
                            ProgressBarText  = $"I'm up to {i}/{iend}",
                        });
                        Thread.Sleep(100);
                    }
                })
                {
                    AllowCancel = true
                };

                // Modal
                using (dlg)
                {
                    var res = dlg.ShowDialog(500);
                    if (res == true)
                    {
                        MessageBox.Show("Completed");
                    }
                    if (res == false)
                    {
                        MessageBox.Show("Cancelled");
                    }
                }

                // Non-modal
                //dlg.Show();
            });
            ShowPromptUI = Command.Create(this, () =>
            {
                var dlg = new PromptUI(this)
                {
                    Title     = "Prompting isn't it...",
                    Prompt    = "I'll have what she's having. Really long message\r\nwith new lines in and \r\n other stuff\r\n\r\nEnter a positive number",
                    Value     = "Really long value as well, that hopefully wraps around",
                    Units     = "kgs",
                    Validate  = x => double.TryParse(x, out var v) && v >= 0 ? ValidationResult.ValidResult : new ValidationResult(false, "Enter a positive number"),
                    Image     = (BitmapImage)FindResource("pencil"),
                    MultiLine = true,
                };
                if (dlg.ShowDialog() == true)
                {
                    double.Parse(dlg.Value);
                }
            });