Exemple #1
0
        public void SetParameters(ref List <ushort> arr, int wid, int hei, double windowWidth,
                                  double windowCentre, bool resetScroll, DXWindow mainFrm)
        {
            bpp       = DossierPatient.ImageBitsPerPixel.Sixteen;
            imgWidth  = wid;
            imgHeight = hei;
            winWidth  = Convert.ToInt32(windowWidth);
            winCentre = Convert.ToInt32(windowCentre);

            sizeImg  = imgWidth * imgHeight;
            sizeImg3 = sizeImg * 3;
            double sizeImg3By4 = sizeImg3 / 4.0;

            DetermineMouseSensitivity();

            pix16         = arr;
            imagePixels16 = new byte[sizeImg3];

            mf             = mainFrm;
            imageAvailable = true;
            if (bmp != null)
            {
                bmp.Dispose();
            }
            ResetValues();
            ComputeLookUpTable16();
            bmp = new Bitmap(imgWidth, imgHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            CreateImage16();
            if (resetScroll == true)
            {
                ComputeScrollBarParameters();
            }
            Invalidate();
        }
        private void NavigationOpenDialog(Type viewModelType)
        {
            var viewModel = Activator.CreateInstance(viewModelType, _navigationUtility);
            var window    = new DXWindow();

            window.Content = viewModel;
        }
        private static void OpenViewInDialog(View view, View parent)
        {
            var container = new DXWindow
            {
                Width                 = 800,
                Height                = 500,
                ShowInTaskbar         = true,
                Title                 = view.GetText() ?? string.Empty,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                Content               = view.GetControl()
            };

            if (parent != null)
            {
                container.ShowIcon    = false;
                container.WindowState = WindowState.Normal;
                container.WindowStyle = WindowStyle.ToolWindow;

                // Закрытие диалога по нажатию на Escape
                container.PreviewKeyDown += (s, e) =>
                {
                    if (e.Key == Key.Escape)
                    {
                        container.Close();
                    }
                };
            }
            else
            {
                container.ShowIcon    = true;
                container.WindowState = WindowState.Maximized;
                container.WindowStyle = WindowStyle.SingleBorderWindow;
                container.Icon        = ImageRepository.GetImage(view.GetImage());
            }

            var closingHandling = false;
            var closeHandling   = false;

            view.OnClosing +=
                (c, a) =>
                TryExecuteBlock(ref closingHandling, () => a.IsCancel = (a.IsCancel == true) || !CloseView(view));
            view.OnClosed     += (c, a) => TryExecuteBlock(ref closeHandling, container.Close);
            container.Closing +=
                (c, a) => TryExecuteBlock(ref closeHandling, () => a.Cancel = a.Cancel || !view.Close());

            var gotFocusHandling = false;

            view.OnGotFocus    += (c, a) => TryExecuteBlock(ref gotFocusHandling, () => container.Focus());
            container.GotFocus +=
                (s, e) => TryExecuteBlock(ref gotFocusHandling, () => view.InvokeScript(view.OnGotFocus));

            var lostFocusHandling = false;

            container.LostFocus +=
                (s, e) => TryExecuteBlock(ref lostFocusHandling, () => view.InvokeScript(view.OnLostFocus));

            view.OnTextChanged += (c, a) => container.Title = a.Value;

            container.ShowDialog();
        }
Exemple #4
0
        public virtual void AddNewRow()
        {
            DXWindow dialog = CreateDialogWindow(CreateNewRow(), false);

            dialog.Closed += OnNewRowDialogClosed;
            dialog.ShowDialog();
        }
        void ShowWindow()
        {
            if (window != null)
            {
                window.Close();
            }
            window = new DXWindow();

            if (enableEffect.IsChecked.HasValue)
            {
                window.BorderEffect = enableEffect.IsChecked.Value ? BorderEffect.Default : BorderEffect.None;
            }
            if (enableCustomization.IsChecked.Value)
            {
                SetBorderEffectCustomColors();
            }
            rootWindow = LayoutHelper.GetRoot(this) as Window;
            if (rootWindow != null)
            {
                window.SetBounds(GetWindowSuggestedRect(rootWindow.GetBounds()));
                window.Icon        = rootWindow.Icon;
                rootWindow.Closed += rootWindow_Closed;
                window.Owner       = rootWindow;
            }
            window.Title   = "DXWindow";
            window.Topmost = true;
            window.Show();
        }
 protected virtual void ConfigureWindow(DXWindow window)
 {
     window.ShowInTaskbar         = true;
     window.WindowStyle           = WindowStyle.ToolWindow;
     window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
     window.ResizeMode            = ResizeMode.NoResize;
 }
        public void CreateEditDialog()
        {
            DXWindow dialog = CreateDialogWindow(EditRowItem, true);

            dialog.Closed += OnEditRowDialogClosed;
            dialog.ShowDialog();
        }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CityDetailWindow"/> class.
 /// </summary>
 /// <param name="controlHost"></param>
 /// <param name="parent"></param>
 /// <param name="city"></param>
 public CityDetailWindow(IDirectXControlHost controlHost, DXWindow parent, City city)
     : base(controlHost)
 {
     this.city   = city;
     this.Parent = parent;
     InitializeComponent();
 }
Exemple #9
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public Form1()
        {
            // デザイナー設定
            InitializeComponent();
            child = new DXWindow(this);

            // DirectXウィンドウの追加
            //child = new DirectXWindow(this);
        }
        public FormDefaultActions(DXWindow window, Control initialControl)
        {
            IsEnableShortcuts = true;

            Window = window;
            ConfigureWindow(window);
            AddEvents(window);
            initialControl.Focus();
        }
Exemple #11
0
 public void ChangePopupContainerEditSizeTest()
 {
     using (new EditorsTestInitializer()) {
         this.UIMap.SwitchToPopupContainerEditDemoModule();
         this.UIMap.ChangePopupContainerEditSize();
         DXWindow uIPopupContainerFormWindow = UIMap.UIXtraEditorsTutorialsWindow.UIPcMainClient.UIGcContainerClient.UIModulePopupContainerCustom.UIXtraTabControl1TabList.UIXtraTabPage1Client.UIPanelControl1Client.UIPopupContainerEditSaEdit.UIPopupContainerFormWindow;
         Assert.AreEqual(UIMap.CheckPopupContainerEditSizeExpectedValues.UIPopupContainerFormWindowSize, CodedUIUtils.ConvertToString(uIPopupContainerFormWindow.Size));
     }
 }
Exemple #12
0
 public void ChangeMemoExEditSizeTest()
 {
     using (new EditorsTestInitializer()) {
         this.UIMap.SwitchToMemoExEditDemoModule();
         this.UIMap.ChangeMemoExEditSize();
         DXWindow uIMemoExPopupFormWindow = UIMap.UITheXtraEditorsSuiteDWindow2.UIPanelControl1Client.UIGcContainerClient.UIModuleMemoExEditCustom.UIXtraTabControl1TabList.UIXtraTabPage1Client.UIPanelControl1Client.UIMemoExEditSamplePopupEdit.UIMemoExPopupFormWindow;
         Assert.AreEqual(UIMap.CheckMemoExEditSizeExpectedValues.UIMemoExPopupFormWindowSize, CodedUIUtils.ConvertToString(uIMemoExPopupFormWindow.Size));
     }
 }
Exemple #13
0
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     MainWindow = new DXWindow()
     {
         Width = 525, Height = 350
     };
     MainWindow.Content = new MainPage();
     MainWindow.Show();
 }
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     ApplicationThemeHelper.ApplicationThemeName = "Office2007Silver";
     MainWindow = new DXWindow()
     {
         Title = "How to use the DevExpress components with MVVM pattern", Width = 525, Height = 350
     };
     MainWindow.Content     = new MainPage();
     MainWindow.DataContext = PersonsViewModelCreator.PersonsViewModel;
     MainWindow.Show();
 }
        public SelectionDefaultActions(DXWindow window, Control filterControl)
        {
            Window = window;
            window.PreviewKeyDown       += window_PreviewKeyDown;
            window.IsVisibleChanged     += window_IsVisibleChanged;
            window.ShowInTaskbar         = true;
            window.WindowStyle           = WindowStyle.ToolWindow;
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.ResizeMode            = ResizeMode.NoResize;

            CreateBindings();
            FilterControl = filterControl;
            filterControl.Focus();
        }
Exemple #16
0
        private void ShowPreview(object sender, RoutedEventArgs e)
        {
            Report report  = new Report();
            var    preview = new MyDocumentPreviewControl()
            {
                DocumentSource = report
            };
            var window = new DXWindow()
            {
                Content = preview
            };

            report.CreateDocument(true);
            window.ShowDialog();
        }
 public void MaximizeAndMinimizeFloatDocumentFormViaWindowTitleButtonTest()
 {
     using (new ApplicationUITestInitializer()) {
         this.SwitchToDemoModule(MultipleDocumentsUIGroup, DockingUIIntegrationModuleName);
         this.UIDockingMap.MakeDocumentFormFloatViaContextMenuOption();
         DXWindow document0Window      = UIDockingMap.UIItemWindow.UIDocument0Window;
         Size     sizeBeforeMaximizing = DevExpress.Utils.CodedUISupport.CodedUIUtils.ConvertFromString <Size>((string)document0Window.GetProperty("Size"));
         this.UIDockingMap.MaximizeFloatDocumentFormViaClickMaximizeButton();
         Size sizeAfterMaximizing = DevExpress.Utils.CodedUISupport.CodedUIUtils.ConvertFromString <Size>((string)document0Window.GetProperty("Size"));
         Assert.IsTrue(sizeAfterMaximizing.Width > sizeBeforeMaximizing.Width && sizeAfterMaximizing.Height > sizeBeforeMaximizing.Height);
         this.UIDockingMap.MinimizeFloatDocumentFormViaClickRestoreButton();
         Size sizeAfterMinimizing = DevExpress.Utils.CodedUISupport.CodedUIUtils.ConvertFromString <Size>((string)document0Window.GetProperty("Size"));
         Assert.IsTrue(sizeAfterMaximizing.Width > sizeAfterMinimizing.Width && sizeAfterMaximizing.Height > sizeAfterMinimizing.Height);
     }
 }
Exemple #18
0
        /// <summary>
        /// 新建文档管理弹窗
        /// </summary>
        /// <param name="beLongFunction">所属模块</param>
        /// <param name="functionPKNO">所属模块PKNO</param>
        /// <param name="Istate">文档状态 0:普通文档 1:封面</param>
        /// <param name="groupNo">分组编号</param>
        /// <param name="mode">是否可读可写</param>
        public static void NewDocumentManage(string beLongFunction, string functionPKNO, string groupNo, int Istate, DocumentMangMode mode)
        {
            DXWindow           window             = new DXWindow();
            DocumentManageView documentManageView = new DocumentManageView(mode);

            documentManageView.BelongFunction = beLongFunction;
            documentManageView.FunctionPKNO   = functionPKNO;
            documentManageView.GroupNo        = groupNo;

            //documentManageView.IsRead = mode;
            documentManageView.BindGridView();
            documentManageView.Istate    = Istate;
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.Content = documentManageView;
            window.ShowDialog();
        }
        public static void ApplyAuthorization(DXWindow control)
        {
            //UserMode.DisplayOptionsVisibility(cc_DisplayOptions);

            //UserMode.DetailPaneVisibility(lc_ItemDetail);

            //UserMode.LayoutPanelVisibility(lp_ToolBox, false);
            //UserMode.LayoutPanelVisibility(lp_AdminToolBox, true);

            //UserMode.SnapShotDetailsVisibility(lc_SnapShotDetails);

            //UserMode.AutoHideGroupVisibility(ahg_Left);
            //UserMode.AutoHideGroupVisibility(ahg_Top);
            //UserMode.AutoHideGroupVisibility(ahg_Right);
            //UserMode.AutoHideGroupVisibility(ahg_Bottom);
        }
        private void SwapControl(DXWindow control)
        {
            if (this.activeWindow != null)
            {
                this.activeWindow.Hide();
            }

            this.activeWindow = control;

            if (!this.Controls.Contains(control))
            {
                this.activeWindow.Parent = this;
                this.Controls.Add(this.activeWindow);
            }

            this.activeWindow.Show();
        }
Exemple #21
0
        public virtual void EditRow()
        {
            if (View == null || Grid.CurrentItem == null || PrimaryKey == string.Empty)
            {
                return;
            }
            var en = DataServiceContext.Entities.GetEnumerator();

            while (en.MoveNext())
            {
                if (en.Current.Identity.EndsWith(string.Format("({0})", Grid.GetFocusedRowCellValue(PrimaryKey))))
                {
                    DXWindow dialog = CreateDialogWindow(en.Current.Entity, true);
                    dialog.Closed += OnEditRowDialogClosed;
                    dialog.ShowDialog();
                    break;
                }
            }
        }
        public static void ShowDialog(this IElement target, string title)
        {
            if (target != null)
            {
                var dialogWindow = new DXWindow
                {
                    Title                 = title ?? string.Empty,
                    Content               = target.GetControl(),
                    Width                 = 600,
                    Height                = 300,
                    ShowIcon              = false,
                    ShowInTaskbar         = true,
                    WindowState           = WindowState.Normal,
                    WindowStyle           = WindowStyle.ToolWindow,
                    WindowStartupLocation = WindowStartupLocation.CenterScreen
                };

                dialogWindow.ShowDialog();
            }
        }
        private DXWindow CreateWindowInternal <TUserControl>(String title = "", WindowStyle style = WindowStyle.SingleBorderWindow, double height = 750, double width = 1200, double minHeight = 750, double minWidth = 1200) where TUserControl : UserControl
        {
            var control = (UserControl)Activator.CreateInstance(typeof(TUserControl));

            var window = new DXWindow()
            {
                MinWidth              = minWidth,
                MinHeight             = minHeight,
                Width                 = width,
                Height                = height,
                Margin                = new Thickness(0, 0, 0, 0),
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                WindowState           = WindowState.Maximized,
                ShowIcon              = false,
                Title                 = title,
                WindowStyle           = style,
            };

            window.Content = control;

            return(window);
        }
        // TODO(crhodes): Figure out why FindChild does not find deeply embedded content control.
        public static void ReflectUserMode(DXWindow window)
        {
            if (Common.UserMode.Administrator || Common.UserMode.Advanced)
            {
                var cc_DisplayOptions = VNC.Xaml.PhysicalTree.FindChild <ContentControl>(window, "cc_DisplayOptions");

                if (cc_DisplayOptions == null)
                {
                    VNC.AppLog.Warning(string.Format("Can't locate element {0}", "cc_DisplayOptions"), Common.LOG_APPNAME);
                    return;
                }

                var adminOptions = VNC.Xaml.PhysicalTree.FindChild <WrapPanel>(cc_DisplayOptions, "AdminOptions");

                if (adminOptions == null)
                {
                    VNC.AppLog.Warning(string.Format("Can't locate element {0}", "adminOptions"), Common.LOG_APPNAME);
                    return;
                }

                ((WrapPanel)adminOptions).Visibility = Visibility.Visible;
            }
        }
        /// <summary>
        /// Makes sure the view is a DX window or is wrapped by one.
        /// Same as the original version of WindowManager.EnsureWindow axcept that it creates a DXWindow instead of Window.
        /// </summary>
        /// <param name="model">The view model.</param>
        /// <param name="view">The view.</param>
        /// <param name="isDialog">Whethor or not the window is being shown as a dialog.</param>
        /// <returns>The window.</returns>
        protected override Window EnsureWindow(object model, object view, bool isDialog)
        {
            var window = view as Window;

            if (window == null)
            {
                window = new DXWindow
                {
                    Content       = view,
                    SizeToContent = SizeToContent.WidthAndHeight
                };

                window.SetValue(View.IsGeneratedProperty, true);

                var owner = InferOwnerOf(window);
                if (owner != null)
                {
                    window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                    window.Owner = owner;
                }
                else
                {
                    window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                }
            }
            else
            {
                var owner = InferOwnerOf(window);
                if (owner != null && isDialog)
                {
                    window.Owner = owner;
                }
            }

            return(window);
        }
        public DXApplication(String s)
            : base(s)
        {
            theDXApplication = this;
            anchor = null;
            serverDisconnectScheduled = false;
            network = null;

            // Create the local command scope.
            commandScope = new CommandScope();

            // Initialize the packet interface.
            serverInfo.packet = null;
            applicationPacket = null;
            messageWindow = null;

            genericHelpCmd = new HelpMenuCommand("genericAppHelp",
                null, true, HelpMenuCommand.HelpType.GenericHelp);
            helpTutorialCmd = new HelpMenuCommand("helpTutorial",
                null, true, HelpMenuCommand.HelpType.HelpTutorial);

            quitCmd = new ConfirmedQuitCommand("quit", commandScope,
                true, this);
            exitCmd = new ConfirmedExitCommand("exit", commandScope,
                true, this);
            openFileCmd = new OpenCommand("open", commandScope,
                true, this);
            messageWindowCmd = new NoUndoDXAppCommand("messageWindowCmd",
                commandScope, true, this, CommandType.OpenMessageWindow);

            openSequencerCmd = new NoUndoDXAppCommand("openSequencerCmd",
                commandScope, false, this, CommandType.OpenSequencer);
            openAllColormapCmd = new NoUndoDXAppCommand("openAllColormapCmd",
                commandScope, false, this, CommandType.OpenAllColormaps);
            loadMacroCmd = new NoUndoDXAppCommand("Load Macro Command",
                commandScope, true, this, CommandType.LoadMacro);
            executeOnceCmd = new NoUndoDXAppCommand("Execute Once",
                commandScope, false, this, CommandType.ExecuteOnce);
            executeOnChangeCmd = new NoUndoDXAppCommand("Execute On Change",
                commandScope, false, this, CommandType.ExecuteOnChange);
            endExecutionCmd = new NoUndoDXAppCommand("End Execution",
                commandScope, false, this, CommandType.EndExecution);
            connectedToServerCmd = new NoOpCommand("Connected To Server",
                commandScope, true);
            disconnectedFromServerCmd = new NoOpCommand("Disconnected From Server",
                commandScope, true);
            executingCmd = new NoOpCommand("executingCmd", commandScope, true);
            notExecutingCmd = new NoOpCommand("notExecutingCmd", commandScope, true);
            connectToServerCmd = new NoUndoDXAppCommand("Start Server",
                commandScope, true, this, CommandType.StartServer);
            resetServerCmd = new NoUndoDXAppCommand("Reset Server",
                commandScope, false, this, CommandType.ResetServer);
            disconnectFromServerCmd = new DisconnectFromServerCommand("disconnectFromServer",
                commandScope, false);
            loadMDFCmd = new NoUndoDXAppCommand("Load MDF...",
                commandScope, true, this, CommandType.LoadUserMDF);
            toggleInfoEnable = new NoUndoDXAppCommand("Enable Information",
                commandScope, true, this, CommandType.ToggleInfoEnabled);
            toggleWarningEnable = new NoUndoDXAppCommand("Enable Warnings",
                commandScope, true, this, CommandType.ToggleWarningEnabled);
            toggleErrorEnable = new NoUndoDXAppCommand("Enable Errors",
                commandScope, true, this, CommandType.ToggleErrorEnabled);
            assignProcessGroupCmd = new NoUndoDXAppCommand("assignProcessGroup",
                commandScope, true, this, CommandType.AssignProcessGroup);

            connectedToServerCmd.autoActivate(executeOnceCmd);
            connectedToServerCmd.autoActivate(executeOnChangeCmd);
            connectedToServerCmd.autoActivate(endExecutionCmd);
            connectedToServerCmd.autoActivate(disconnectedFromServerCmd);
            connectedToServerCmd.autoActivate(resetServerCmd);
            connectedToServerCmd.autoActivate(connectedToServerCmd);

            disconnectedFromServerCmd.autoActivate(connectedToServerCmd);
            disconnectedFromServerCmd.autoActivate(executeOnceCmd);
            disconnectedFromServerCmd.autoActivate(executeOnChangeCmd);
            disconnectedFromServerCmd.autoActivate(endExecutionCmd);
            disconnectedFromServerCmd.autoActivate(disconnectedFromServerCmd);
            disconnectedFromServerCmd.autoActivate(resetServerCmd);

            //
            // Once in execute on change don't allow it again until the user
            // does an endExecutionCmd
            //
            executeOnChangeCmd.autoDeactivate(executeOnChangeCmd);
            endExecutionCmd.autoActivate(executeOnChangeCmd);
            openFileCmd.autoActivate(executeOnChangeCmd);

            //
            // Set the automatic activation of any commands that depend on whether
            // or not we are currently executing.
            //
            executingCmd.autoDeactivate(openFileCmd);
            notExecutingCmd.autoActivate(openFileCmd);
            executingCmd.autoDeactivate(executeOnceCmd);
            notExecutingCmd.autoActivate(executeOnceCmd);

            //
            // Don't allow execute on change during an execute once.
            //
            executeOnceCmd.autoDeactivate(executeOnChangeCmd);
            notExecutingCmd.autoActivate(executeOnChangeCmd);

            NDAllocatorDictionary.theNDAllocatorDictionary = new NDAllocatorDictionary();

            readFirstNetwork = false;
        }
 public virtual void AddEvents(DXWindow window)
 {
     window.PreviewKeyDown += window_PreviewKeyDown;
     window.Loaded         += WindowOnLoaded;
     Model.Fechar          += Model_Fechar;
 }
        private async Task <TViewModel> HandleCreateWindow <TUserControl, TViewModel>(DXWindow window, bool isModal = false) where TUserControl : UserControl where TViewModel : IViewModel
        {
            var model = AppCore.Instance.ObjectProvider.GetInstance <TViewModel>();

            await model.Initialize();

            //injaect via DI
            model.Host = window;

            window.DataContext = null;
            window.DataContext = model;

            window.Closing += (sender, e) =>
            {
                var win       = (DXWindow)sender;
                var todispose = win.DataContext as IDisposable;
                todispose?.Dispose();
                _windowsRegistry.Remove(win);
            };

            window.Show();
            window.Activate();
            window.Topmost = true;
            window.Topmost = false;
            window.Focus();

            _windowsRegistry.Add(window);

            return(model);
        }
Exemple #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewCityWindow"/> class.
 /// </summary>
 /// <param name="controlHost"></param>
 /// <param name="parent"></param>
 public NewCityWindow(IDirectXControlHost controlHost, DXWindow parent) : base(controlHost)
 {
     this.Parent = parent;
     InitializeComponent();
 }
Exemple #30
0
        public void SetParameters(ref List <byte> arr, int wid, int hei, double windowWidth,
                                  double windowCentre, int samplesPerPixel, bool resetScroll, DXWindow mainFrm)
        {
            if (samplesPerPixel == 1)
            {
                bpp             = DossierPatient.ImageBitsPerPixel.Eight;
                imgWidth        = wid;
                imgHeight       = hei;
                winWidth        = Convert.ToInt32(windowWidth);
                winCentre       = Convert.ToInt32(windowCentre);
                changeValWidth  = 0.1;
                changeValCentre = 20.0;
                sizeImg         = imgWidth * imgHeight;
                sizeImg3        = sizeImg * 3;

                pix8         = arr;
                imagePixels8 = new byte[sizeImg3];

                mf             = mainFrm;
                imageAvailable = true;
                if (bmp != null)
                {
                    bmp.Dispose();
                }
                ResetValues();
                ComputeLookUpTable8();
                bmp = new Bitmap(imgWidth, imgHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                CreateImage8();
            }

            if (samplesPerPixel == 3)
            {
                bpp             = DossierPatient.ImageBitsPerPixel.TwentyFour;
                imgWidth        = wid;
                imgHeight       = hei;
                winWidth        = Convert.ToInt32(windowWidth);
                winCentre       = Convert.ToInt32(windowCentre);
                changeValWidth  = 0.1;
                changeValCentre = 0.1;
                sizeImg         = imgWidth * imgHeight;
                sizeImg3        = sizeImg * 3;

                pix24         = arr;
                imagePixels24 = new byte[sizeImg3];

                mf             = mainFrm;
                imageAvailable = true;
                if (bmp != null)
                {
                    bmp.Dispose();
                }
                ResetValues();
                ComputeLookUpTable8();
                bmp = new Bitmap(imgWidth, imgHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                CreateImage24();
            }
            if (resetScroll == true)
            {
                ComputeScrollBarParameters();
            }
            Invalidate();
        }
Exemple #31
0
        static void Main(string[] args)
        {
            DXWindow           window           = new DXWindow();
            DXRenderingManager renderingManager = new DXRenderingManager();

            DXCamera camera = new DXCamera();

            DXDeltaTime deltaTimer = new DXDeltaTime();

            window.Create(Process.GetCurrentProcess(),
                          "Test",
                          1280,
                          720,
                          false);

            renderingManager.Init(window);

            DXStaticMesh cubeMesh = new DXStaticMesh();

            DXTexture texture      = new DXTexture();
            DXTexture normal       = new DXTexture();
            DXTexture metallic     = new DXTexture();
            DXTexture displacement = new DXTexture();

            DXDrawable drawable = new DXDrawable();

            DXDirectionalLight directionalLight = new DXDirectionalLight(renderingManager, window);

            directionalLight.Init();


            directionalLight.Intensity = 10;
            directionalLight.SetDirection(new DXVector(0, -1, -1, 0));
            directionalLight.Update();

            bool loadSucceeded = true;

            if (cubeMesh.Init())
            {
                if (cubeMesh.LoadStaticMesh("../../Models/Cube.fbx"))
                {
                    if (!cubeMesh.CreateBuffer(renderingManager))
                    {
                        loadSucceeded = false;
                    }
                }
            }

            if (!texture.LoadDDSTexture("../../Texture/Brick/Brick_diffuse.DDS", true, renderingManager))
            {
                loadSucceeded = false;
            }
            if (!normal.LoadDDSTexture("../../Texture/Brick/Brick_normal.DDS", true, renderingManager))
            {
                loadSucceeded = false;
            }
            if (!metallic.LoadDDSTexture("../../Texture/Brick/Brick_metallic.DDS", true, renderingManager))
            {
                loadSucceeded = false;
            }
            if (!displacement.LoadDDSTexture("../../Texture/Brick/Brick_height.DDS", true, renderingManager))
            {
                loadSucceeded = false;
            }

            drawable.SetStaticMesh(cubeMesh);
            drawable.SetTexture(texture);
            drawable.SetNormalMap(normal);
            drawable.SetMetallicMap(metallic);
            drawable.SetDisplacementMap(displacement);
            drawable.SetPosition(new DXVector(0, 0, -5, 1));
            drawable.Update();

            camera.SetPosition(new DXVector(0, 0, 0, 1));
            camera.SetDirection(new DXVector(0, 0, -1, 0));
            camera.Update();

            deltaTimer.Init();
            while (window.IsOpen && loadSucceeded)
            {
                float deltaTime = deltaTimer.GetDeltaTime();
                if (window.Updating())
                {
                    //Window is updating
                }

                MoveCamera(ref camera, deltaTime);

                if (DXInput.IsKeyPressed('Q'))
                {
                    directionalLight.Queue();
                }

                drawable.Draw(renderingManager);
                renderingManager.Flush(camera);
            }
            texture.Release();
            normal.Release();
            metallic.Release();
            displacement.Release();
            cubeMesh.Release();

            directionalLight.Release();


            renderingManager.Release();
        }
        public override bool initialize(ref string[] argv)
        {
            bool wasSetBusy = false;

            base.initialize(ref argv);

            if (!DXApplication.DXApplicationClassInitialized)
            {
                installDefaultResources();
                DXApplicationClassInitialized = true;
            }

            if (resource.executiveModule == null)
                resource.executiveModule = "lib/dx.mdf";
            if (resource.uiModule == null)
                resource.uiModule = "ui/ui.mdf";
            if (resource.userModules == null)
                resource.userModules = Environment.GetEnvironmentVariable("DXMDF");
            if (resource.macros == null)
                resource.macros = Environment.GetEnvironmentVariable("DXMACROS");
            if (resource.server == null)
                resource.server = Environment.GetEnvironmentVariable("DXHOST");
            if (resource.server == null)
                resource.server = "localhost";
            if (resource.server.Contains(","))
            {
                // Remove the port number if it exists (i.e DXHOST=slope,1920)
                resource.server = resource.server.Substring(0, resource.server.IndexOf(','));
            }
            if (resource.netPath == null)
                resource.netPath = Environment.GetEnvironmentVariable("DXNETPATH");
            if (resource.cryptKey == null)
                resource.cryptKey = Environment.GetEnvironmentVariable("DXCRYPTKEY");

            // If the app does not allow editor access or we are starting up without
            // displaying the anchor window, force one of (image or menubar) mode.
            if ((InEditMode && !appAllowsEditorAccess()) ||
                resource.noAnchorAtStartup)
            {
                if (InMenuBarMode)
                    resource.anchorMode = MENUBAR_ANCHOR_MODE;
                else
                    resource.anchorMode = IMAGE_ANCHOR_MODE;
            }

            // Echo the resources.
            if (resource.debugMode)
            {
                if (resource.port != 0)
                    Console.WriteLine("port        = {0}", resource.port);
                if (resource.memorySize != 0)
                    Console.WriteLine("memory size = {0}", resource.memorySize);
                if (resource.server != null)
                    Console.WriteLine("server = {0}", resource.server);
                if (resource.executive != null)
                    Console.WriteLine("executive = {0}", resource.executive);
                if (resource.workingDirectory != null)
                    Console.WriteLine("working directory = {0}",
                     resource.workingDirectory);
                if (resource.netPath != null)
                    Console.WriteLine("net path = {0}", resource.netPath);
                if (resource.program != null)
                    Console.WriteLine("program = {0}", resource.program);
                if (resource.cfgfile != null)
                    Console.WriteLine("cfgfile = {0}", resource.cfgfile);
                if (getUIRoot() != null)
                    Console.WriteLine("root = {0}", getUIRoot());
                if (resource.macros != null)
                    Console.WriteLine("macros = {0}", resource.macros);
                if (resource.errorPath != null)
                    Console.WriteLine("error path = {0}", resource.errorPath);
                if (resource.echoVersion)
                    Console.WriteLine("echo version");
                if (resource.anchorMode != null)
                    Console.WriteLine("anchor mode = {0}", resource.anchorMode);
                if (resource.noAnchorAtStartup)
                    Console.WriteLine("hiding anchor at startup");
                if (resource.debugMode)
                    Console.WriteLine("debug mode");
                if (resource.runUIOnly)
                    Console.WriteLine("run UI only");
                if (resource.showHelpMessage)
                    Console.WriteLine("show help message");
                if (resource.userModules != null)
                    Console.WriteLine("user mdf = {0}", resource.userModules);
                if (resource.executiveModule != null)
                    Console.WriteLine("executive mdf = {0}", resource.executiveModule);
                if (resource.uiModule != null)
                    Console.WriteLine("ui mdf = {0}", resource.uiModule);
                if (resource.suppressStartupWindows)
                    Console.WriteLine("suppress startup windows");

                if (resource.applicationPort != 0)
                    Console.WriteLine("application port = {0}", resource.applicationPort);
                if (resource.applicationHost != null)
                    Console.WriteLine("application host = {0}", resource.applicationHost);

                //
                // Image printing resources.
                //
                if (resource.printImageCommand != null)
                    Console.WriteLine("print image command = '{0}'",
                        resource.printImageCommand);
                if (resource.printImageFormat != null)
                    Console.WriteLine("print image format = '{0}'",
                        resource.printImageFormat);
                if (resource.printImagePageSize != null)
                    Console.WriteLine("print image page size = '{0}'",
                        resource.printImagePageSize);
                Console.WriteLine("print image resolution = {0}",
                        resource.printImageResolution);

                //
                // Image saving resources.
                //
                if (resource.saveImageFormat != null)
                    Console.WriteLine("save image format = '{0}'",
                        resource.saveImageFormat);
                if (resource.saveImagePageSize != null)
                    Console.WriteLine("save image page size = '{0}'",
                        resource.saveImagePageSize);
                Console.WriteLine("save image resolution = {0}",
                        resource.saveImageResolution);

                //
                // UI restrictions
                //
                if (resource.restrictionLevel != null)
                    Console.WriteLine("restriction level {0}",
                            resource.restrictionLevel);
                if (resource.noEditorAccess)
                    Console.WriteLine("no editor access");
                if (resource.limitedNetFileSelection)
                    Console.WriteLine("limited network file selection");
                if (resource.noImageRWNetFile)
                    Console.WriteLine("no net file read/write");
                if (resource.noImageSaving)
                    Console.WriteLine("no image saving");
                if (resource.noImagePrinting)
                    Console.WriteLine("no image printing");
                if (resource.noImageLoad)
                    Console.WriteLine("no image load ");
                if (resource.limitImageOptions)
                    Console.WriteLine("limit image options");
                if (resource.noRWConfig)
                    Console.WriteLine("no cfg save");
                if (resource.noPanelEdit)
                    Console.WriteLine("no panel edit");
                if (resource.noInteractorEdits)
                    Console.WriteLine("no interactor style");
                if (resource.noInteractorAttributes)
                    Console.WriteLine("no interactor attributes");
                if (resource.noInteractorMovement)
                    Console.WriteLine("no interactor movement");
                if (resource.noOpenAllPanels)
                    Console.WriteLine("no open all panels");
                if (resource.noPanelAccess)
                    Console.WriteLine("no panel access");
                if (resource.noPanelOptions)
                    Console.WriteLine("no panel options");
                if (resource.noMessageInfoOption)
                    Console.WriteLine("no message info option");
                if (resource.noMessageWarningOption)
                    Console.WriteLine("no message warning option");
                if (resource.noDXHelp)
                    Console.WriteLine("no DX help");

                //
                // automatic graph layout
                //
                if (resource.autoLayoutHeight > 0)
                    Console.WriteLine("automatic graph layout height = {0}",
                    resource.autoLayoutHeight);
                if (resource.autoLayoutGroupSpacing > 0)
                    Console.WriteLine("automatic graph layout group spacing = {0}",
                    resource.autoLayoutGroupSpacing);
                if (resource.autoLayoutNodeSpacing > 0)
                    Console.WriteLine("automatic graph layout node spacing = {0}",
                    resource.autoLayoutNodeSpacing);
            }

            if (resource.echoVersion)
            {
                String vers = String.Format("{0} User Interface, version {1}.{2}.{3} ({4})",
                    getFormalName(), global::WinDX.UI.Resources.MAJOR_VERSION,
                global::WinDX.UI.Resources.MINOR_VERSION,
                global::WinDX.UI.Resources.MICRO_VERSION,
                File.GetLastWriteTime(Application.ExecutablePath));

                MessageBox.Show(vers, "Version");
                Application.Exit();
            }

            // Fix me! May need to turn off help here.

            // Validate and set automatic graph layout values
            if (resource.autoLayoutHeight > 0)
            {
                String errmsg = GraphLayout.SetHeightPerLevel(resource.autoLayoutHeight);
                if (errmsg != null)
                {
                    MessageBox.Show(errmsg, "Startup Error");
                    return false;
                }
            }
            if (resource.autoLayoutGroupSpacing > 0)
            {
                String errmsg = GraphLayout.SetGroupSpacing(resource.autoLayoutGroupSpacing);
                if (errmsg != null)
                {
                    MessageBox.Show(errmsg, "Startup Error");
                    return false;
                }
            }
            if (resource.autoLayoutNodeSpacing > 0)
            {
                String errmsg = GraphLayout.SetNodeSpacing(resource.autoLayoutNodeSpacing);
                if (errmsg != null)
                {
                    MessageBox.Show(errmsg, "Startup Error");
                    return false;
                }
            }

            // Post the copyright message if the anchor window came up.
            if (!resource.noAnchorAtStartup)
                postCopyrightNotice();

            // Validate the resources and options
            if (InEditMode && !appAllowsEditorAccess())
            {
                MessageBox.Show("-edit and -noEditorAccess options are incompatible.", "Startup Error");
                return false;
            }

            if (appAllowsImageRWNetFile() && appLimitsNetFileSelection() &&
                resource.netPath == null)
            {
                MessageBox.Show("The \"limitedNetFileSelection\" or \"noImageRWNetFile\" " +
                    "option requires\na directory pathname specified by " +
                    "the \"DXNETPATH\" environment variable, \n" +
                    "the -netPath command line option, or\n" +
                    "the *netPath resource.", "Startup Error");
                return false;
            }

            // Setup Server Information
            serverInfo.autoStart = (resource.port <= 0);
            serverInfo.server = resource.server;
            serverInfo.executive = resource.executive;
            serverInfo.workingDirectory = resource.workingDirectory;
            serverInfo.userModules = resource.userModules;
            serverInfo.port = (resource.port == 0 ? 1900 : resource.port);
            serverInfo.memorySize = resource.memorySize;
            serverInfo.executiveFlags = "";
            serverInfo.children = new List<DXChild>();
            serverInfo.queuedPackets = new List<DXPacketIF>();

            if (argv != null)
            {
                foreach (String arg in argv)
                {
                    serverInfo.executiveFlags += arg + " ";
                }
            }

            if (InDataViewerMode)
            {
                resource.executeOnChange = true;
                resource.noImageRWNetFile = true;
                resource.noRWConfig = true;
                resource.noImageLoad = true;
                resource.noDXHelp = true;
                resource.noPGroupAssignment = true;
                resource.limitImageOptions = true;
                resource.noScriptCommands = true;
                resource.noConnectionMenus = true;
                resource.noWindowsMenus = true;
                resource.anchorMode = IMAGE_ANCHOR_MODE;
                resource.noAnchorAtStartup = true;
                resource.suppressStartupWindows = true;
                resource.noConfirmedQuit = true;
            }

            // Create the first/root/anchor network and place it in the
            // network list.
            network = newNetwork();

            if (appAllowsEditorAccess())
            {
                // Initialize the ConfigurationDialog allocator for the editor
                CDBAllocatorDictionary.theCDBAllocatorDictionary = new CDBAllocatorDictionary();

                // Initialize the StandIn allocator for the editor.
                SIAllocatorDictionary.theSIAllocatorDictionary = new SIAllocatorDictionary();
            }
            // Move to the indicated directory
            if (serverInfo.workingDirectory != null)
            {
                try
                {
                    Directory.SetCurrentDirectory(serverInfo.workingDirectory);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Unable to set Working Directory");
                }
            }

            loadMDF();
            loadIDF();
            if (resource.userModules != null)
                loadUDF(resource.userModules, null, false);

            // Decorator Styles
            DecoratorStyle.BuildtheDecoratorStyleDictionary();

            // load the initial set of user macros.
            MacroDefinition.LoadMacroDirectories(resource.macros);

            // Create the anchor window
            if (!InEditMode)
            {
                if (InImageMode)
                    anchor = newImageWindow(network);
                else if (InMenuBarMode)
                    anchor = new DXAnchorWindow("dxAnchor", true, true);
                else
                {
                    MessageBox.Show("Unrecognized anchor mode.", "Startup Error");
                    Application.Exit();
                }
                // Initialize the anchor window so it can handle reading in the network
                // before being managed.
                if (applyWindowPlacements() ||
                    resource.noAnchorAtStartup)
                {
                    anchor.Show();
                    anchor.Visible = true;
                }
                else
                {
                    anchor.Show();
                    anchor.Visible = true;
                    setBusyCursor(true);
                    wasSetBusy = true;
                }
            }
            else
            {
                anchor = newNetworkEditor(network);
                if (anchor == null)
                    return false;

                anchor.Show();
                setBusyCursor(true);
                wasSetBusy = true;
            }

            // Create the message and debug windows
            messageWindow = newMsgWin();

            // If quested, read in the network.  This is after opening the anchor
            // window because image nodes may wish to bind with the initial image
            // window, etc.
            if (resource.program != null)
                openFile(resource.program, resource.cfgfile);

            if (InDataViewerMode)
            {
                Node n = network.findNode("Import");
                if (n == null)
                {
                    ErrorDialog ed = new ErrorDialog();
                    ed.post("Can not find Import tool in viewing program.");
                }
                else
                {
                    String s = resource.viewDataFile;
                    Debug.Assert(s != null);
                    n.setInputValue(1, s);
                }
            }

            if (resource.noAnchorAtStartup)
            {
                anchor.Show();
            }
            else if (!anchor.Visible)
            {
                anchor.Show();
                setBusyCursor(true);
                wasSetBusy = true;
            }

            if (!resource.runUIOnly)
            {
                // Connect to exec first
                DXChild c = startServer();

                completeConnection(c);
            }

            // If there is an application to talk to, connect to it.
            if (resource.applicationPort != 0)
                connectToApplication(resource.applicationHost,
                    resource.applicationPort);

            if (wasSetBusy)
                setBusyCursor(false);

            return true;
        }