コード例 #1
0
        public PreviewPage()
        {
            var vm = Dependency.Resolve <PreviewViewModel>();

            DataContext = vm;

            InitializeComponent();

            this.DefaulInitForBaseViewModel();

            ToggleSettings();

            Global.Instance.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == nameof(Global.SizeX) || e.PropertyName == nameof(Global.SizeY))
                {
                    gcode.SizeX = (double)Global.Instance.SizeX;
                    gcode.SizeY = (double)Global.Instance.SizeY;
                }
            };

            if (vm.GetLoadInfo == null)
            {
                vm.GetLoadInfo = arg =>
                {
                    var dlg   = new LoadOptionView();
                    var vmdlg = dlg.DataContext as LoadOptionViewModel;
                    if (vmdlg != null)
                    {
                        vmdlg.LoadOptionsValue =
                            Dependency.Resolve <IMapper>().Map <GCode.GUI.Models.LoadOptions>(arg.LoadOption);
                        vmdlg.UseAzure = arg.UseAzure;
                        if (!dlg.ShowDialog() ?? false)
                        {
                            return(false);
                        }

                        arg.LoadOption = Dependency.Resolve <IMapper>()
                                         .Map <Logic.Contracts.DTO.LoadOptions>(vmdlg.LoadOptionsValue);
                        arg.UseAzure = vmdlg.UseAzure;
                    }
                    return(true);
                }
            }
            ;


            if (vm.RefreshPreview == null)
            {
                vm.RefreshPreview = () =>
                {
                    gcode.Dispatcher.Invoke(() => gcode.InvalidateVisual());
                };
            }
        }
コード例 #2
0
        public PreviewPage()
        {
            var vm = AppService.GetRequiredService <PreviewViewModel>();

            DataContext = vm;

            InitializeComponent();

            this.DefaultInitForBaseViewModel();

            ToggleSettings();

            vm.Global.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == nameof(Global.SizeX) || e.PropertyName == nameof(Global.SizeY))
                {
                    gcode.SizeX = (double)vm.Global.SizeX;
                    gcode.SizeY = (double)vm.Global.SizeY;
                }
            };

            if (vm.GetLoadInfo == null)
            {
                vm.GetLoadInfo = arg =>
                {
                    var dlg       = new LoadOptionView();
                    var viewModel = dlg.DataContext as LoadOptionViewModel;
                    if (viewModel != null)
                    {
                        viewModel.LoadOptionsValue = viewModel.MapLoadOptions(arg.LoadOption);
                        viewModel.UseAzure         = arg.UseAzure;
                        if (!dlg.ShowDialog() ?? false)
                        {
                            return(false);
                        }

                        arg.LoadOption = viewModel.MapLoadOptions(viewModel.LoadOptionsValue);
                        arg.UseAzure   = viewModel.UseAzure;
                    }

                    return(true);
                };
            }

            if (vm.RefreshPreview == null)
            {
                vm.RefreshPreview = () => { gcode.Dispatcher.Invoke(() => gcode.InvalidateVisual()); };
            }
        }