コード例 #1
0
ファイル: App.xaml.cs プロジェクト: psryland/rylogic_code
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            try
            {
                View3d.LoadDll();
                Xml_.Config
                .SupportRylogicMathsTypes()
                .SupportRylogicGraphicsTypes()
                .SupportSystemDrawingPrimitiveTypes()
                .SupportSystemDrawingCommonTypes()
                .SupportWPFTypes()
                ;

                MainWindow = new MainWindow(new Model(e.Args));
                MainWindow.Show();
            }
            catch (Exception ex)
            {
                if (Debugger.IsAttached)
                {
                    throw;
                }
                Log.Write(ELogLevel.Fatal, ex, Util.AppProductName, string.Empty, 0);
                MsgBox.Show(null, $"Application startup failure: {ex.MessageFull()}", "Solar Hot Water", MsgBox.EButtons.OK, MsgBox.EIcon.Error);
                Shutdown();
            }
        }
コード例 #2
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;
            }
        }
コード例 #3
0
        [STAThread] static void Main()
        {
            try
            {
                // Create an event handle to prevent multiple instances
                bool was_created;
                using (var app_running = new EventWaitHandle(true, EventResetMode.AutoReset, "TradeeRunningEvent", out was_created))
                {
                    // Only run the app if we created the event handle
                    if (was_created)
                    {
                        // Ensure required dlls are loaded
                        View3d.LoadDll();
                        Sci.LoadDll();
                        Sqlite.LoadDll();

                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new MainUI());
                    }
                }
            }
            catch (Exception ex)
            {
                MsgBox.Show(null, ex.MessageFull(), "Crash!", MessageBoxButtons.OK);
            }
        }
コード例 #4
0
        public MainUI()
        {
            InitializeComponent();

            Settings = new Settings(@"Settings.xml")
            {
                AutoSaveOnChanges = true
            };
            Model    = new MainModel(this, Settings);
            m_view3d = new View3d(gdi_compatibility: false);

            SetupUI();
            UpdateUI();

            // Restore the last window position
            if (Settings.UI.WindowPosition.IsEmpty)
            {
                StartPosition = FormStartPosition.WindowsDefaultLocation;
            }
            else
            {
                StartPosition = FormStartPosition.Manual;
                Bounds        = Util.OnScreen(Settings.UI.WindowPosition);
                WindowState   = Settings.UI.WindowMaximised ? FormWindowState.Maximized : FormWindowState.Normal;
            }
        }
コード例 #5
0
ファイル: Model.cs プロジェクト: psryland/rylogic_code
 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>();
 }
コード例 #6
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;
            }
        }
コード例 #7
0
ファイル: main_ui.cs プロジェクト: psryland/rylogic_code
        /// <summary>The main entry point for the application.</summary>
        [STAThread] static void Main()
        {
            // Note! Running this in the debugger causes this to be run as a 32bit
            // process regardless of the selected solution platform
            Debug.WriteLine($"\n    {Application.ExecutablePath} is a {(Environment.Is64BitProcess?"64":"32")}bit process\n");

            Sci.LoadDll();
            Sqlite.LoadDll();
            View3d.LoadDll();
            Audio.LoadDll();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainUI());
            //Application.Run(new DgvUI());
        }
コード例 #8
0
ファイル: App.xaml.cs プロジェクト: psryland/rylogic_code
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     try
     {
         View3d.LoadDll();
         MainWindow = new MainWindow();
         MainWindow.Show();
     }
     catch (Exception ex)
     {
         if (Debugger.IsAttached)
         {
             throw;
         }
         Log.Write(ELogLevel.Fatal, ex, "Application startup failure");
         MsgBox.Show(null, $"Application startup failure: {ex.MessageFull()}", Util.AppProductName, MsgBox.EButtons.OK, MsgBox.EIcon.Error);
         Shutdown();
     }
 }
コード例 #9
0
ファイル: Element.cs プロジェクト: marked23/rylogic_code
            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>();
            }
コード例 #10
0
ファイル: Element.cs プロジェクト: psryland/rylogic_code
            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>();
            }
コード例 #11
0
 /// <summary>
 /// Switches between modal sub dialog and parent form, when sub dialog does not needs to be destroyed (e.g. selecting 
 /// something from parent form)
 /// </summary>
 /// <param name="bParentActive">true to set parent form active, false - child dialog.</param>
 /// <param name="parent">parent form or window</param>
 /// <param name="dlg">sub dialog form or window</param>
 static public void SwitchParentChildWindows(bool bParentActive, object parent, object dlg)
 {
     if( parent == null || dlg == null )
         return;
     
     IntPtr hParent = getHandle(parent);
     IntPtr hDlg = getHandle(dlg);
     if( !bParentActive )
     {
         //
         // Prevent recursive loops which can be triggered from UI. (Main form => sub dialog => select (sub dialog hidden) => sub dialog in again.
         // We try to end measuring here - if parent window becomes inactive - 
         // means that we returned to dialog from where we launched measuring. Meaning nothing special needs to be done.
         //
         bool bEnabled = IsWindowEnabled(hParent);
         View3d.EndMeasuring(true);   // Potentially can trigger SwitchParentChildWindows(false,...) call.
         bool bEnabled2 = IsWindowEnabled(hParent);
         if( bEnabled != bEnabled2 )
             return;
     }
     
     if( bParentActive )
     {
         EnableWindow(hDlg, false);      // Disable so won't eat parent keyboard presses.
         ShowWindow(hDlg, 0);  //SW_HIDE
     }
     EnableWindow(hParent, bParentActive);
     
     if( bParentActive )
     {
         SetForegroundWindow(hParent);
         BringWindowToTop(hParent);
     } else {
         ShowWindow(hDlg, 5 );  //SW_SHOW
         EnableWindow(hDlg, true);
         SetForegroundWindow(hDlg);
     }
 } //SwitchParentChildWindows
コード例 #12
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);
                }
            });
コード例 #13
0
        // Notes:
        //  - This control subclasses 'Image' because the D3DImage is an 'ImageSource'
        //  - View3dControl does not have a 'Settings' class, state changes are immediate
        //    and storing the state is left to the caller. (Unlike ChartControl).

        static View3dControl()
        {
            View3d.LoadDll(throw_if_missing: false);
        }
コード例 #14
0
ファイル: App.xaml.cs プロジェクト: psryland/rylogic_code
 public App()
 {
     View3d.LoadDll();
     Xml_.Config.SupportWPFTypes();
 }
コード例 #15
0
 public void ZoomExtents()
 {
     View3d.ZoomExtents(0.5);
 }
コード例 #16
0
 public App()
 {
     View3d.LoadDll();
 }
コード例 #17
0
ファイル: view3d_ui.cs プロジェクト: psryland/rylogic_code
 static FormView3d()
 {
     Sci.LoadDll(@"..\..\..\..\lib\$(platform)\$(config)\");
     View3d.LoadDll(@"..\..\..\..\lib\$(platform)\$(config)\");
 }
コード例 #18
0
 public LdrEditorUI()
 {
     InitializeComponent();
     m_view3d = View3d.Create();
     m_sci.InitLdrStyle();
 }
コード例 #19
0
 static LdrEditorUI()
 {
     Sci.LoadDll(@"..\..\..\..\lib\$(platform)\$(config)\");
     View3d.LoadDll(@"..\..\..\..\lib\$(platform)\$(config)\");
 }
コード例 #20
0
 private void buttonAreaSelect_Click(object sender, RoutedEventArgs e)
 {
     SwitchParentChildWindows(true);
     View3d.SelectArea(AreaSelected);
 }
コード例 #21
0
 static DiagramUI()
 {
     View3d.LoadDll(@"\sdk\lib\$(platform)\$(config)\");
 }
コード例 #22
0
        /// <summary>Handle navigation keyboard shortcuts</summary>
        public virtual void OnTranslateKey(KeyEventArgs e)
        {
            // Notes:
            //  - Default chart key bindings. These are intended as default key bindings
            //    Applications should probably set DefaultKeyboardShortcuts to false and
            //    handle key bindings themselves.

            if (e.Handled)
            {
                return;
            }

            // Allow users to handle the key
            TranslateKey?.Invoke(this, e);
            if (e.Handled)
            {
                return;
            }

            // Fall back to default
            switch (e.Key)
            {
            case Key.Escape:
            {
                // Deselect all on escape
                if (AllowSelection)
                {
                    Selected.Clear();
                    Invalidate();
                    e.Handled = true;
                }
                break;
            }

            case Key.Delete:
            {
                //if (AllowEditing)
                {
                    //// Allow the caller to cancel the deletion or change the selection
                    //var res = new DiagramChangedRemoveElementsEventArgs(Selected.ToArray());
                    //if (!RaiseDiagramChanged(res).Cancel)
                    //{
                    //	foreach (var elem in res.Elements)
                    //	{
                    //		var node = elem as Node;
                    //		if (node != null)
                    //			node.DetachConnectors();

                    //		var conn = elem as Connector;
                    //		if (conn != null)
                    //			conn.DetachNodes();

                    //		Elements.Remove(elem);
                    //	}
                    //	Invalidate();
                    //}
                }
                break;
            }

            case Key.F5:
            {
                View3d.ReloadScriptSources();
                Invalidate();
                e.Handled = true;
                break;
            }

            case Key.F7:
            {
                var bounds =
                    Keyboard.Modifiers.HasFlag(ModifierKeys.Shift) ? Gfx.View3d.ESceneBounds.Selected :
                    Keyboard.Modifiers.HasFlag(ModifierKeys.Control) ? Gfx.View3d.ESceneBounds.Visible :
                    Gfx.View3d.ESceneBounds.All;

                AutoRange(who: bounds);
                Invalidate();
                e.Handled = true;
                break;
            }

            case Key.A:
            {
                if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
                {
                    Selected.Clear();
                    Selected.AddRange(Elements);
                    Invalidate();
                    Debug.Assert(CheckConsistency());
                    e.Handled = true;
                }
                break;
            }
            }
        }
コード例 #23
0
 static MainWindow()
 {
     View3d.LoadDll();
 }
コード例 #24
0
 static View3dUI()
 {
     View3d.LoadDll();
 }
コード例 #25
0
 static DiagramControlUI()
 {
     Sci.LoadDll(@"\lib\$(platform)\$(config)\");
     View3d.LoadDll(@"\lib\$(platform)\$(config)\");
 }
コード例 #26
0
 } //showDialog
 public void SwitchParentChildWindows( bool bParentActive )
 {
     View3d.SwitchParentChildWindows(bParentActive, parent, this);
 }