예제 #1
0
        public static void UpdateLayouts()
        {
            var task = Program.Windows.Items["landingPage"].Browser.GetZoomLevelAsync();

            task.Wait();
            double zoomLevel = Math.Round(task.Result, 2);

            //task.ContinueWith(previous => {
            //    zoomLevel = Math.Round(previous.Result, 2);
            //});

            Program.Layouts.ZoomLevel = zoomLevel;

            //foreach (FormLayout layout in Program.Layouts.Items.Values) layout.inDesktop = false;
            Program.Layouts.Items.Clear();
            foreach (BrowserPopupForm form in Windows.Items.Values)
            {
                //Program.Layouts.Items[form.WindowId] = new FormLayout
                FormLayout layout = new FormLayout
                {
                    X           = form.Bounds.X,
                    Y           = form.Bounds.Y,
                    Width       = form.Bounds.Width,
                    Height      = form.Bounds.Height,
                    targetUrl   = form.targetUrl,
                    title       = form.Text,
                    inDesktop   = (form.IsStatusBar || form.IsLandingPage) ? false : true,
                    WindowState = Convert.ToInt32(form.WindowState),
                    selectedWS  = form.getSelectedWorkspaceId(),
                    WindowType  = form.WindowType
                };
                string itemId = form.IsStatusBar ? "statusBar" : Program.Layouts.Items.Count.ToString();
                Program.Layouts.Items[itemId] = form.layout = layout;
            }
        }
예제 #2
0
        public static FormLayout GetDefaultLayout(string windowId)
        {
            FormLayout defaultLayout = new FormLayout
            {
                X          = 20,
                Y          = 20,
                Width      = 800,
                Height     = 600,
                WindowType = WindowTypes.TraderBook
            };

            if (windowId == "#statusBar")
            {
                defaultLayout = new FormLayout
                {
                    X          = 20,
                    Y          = 20,
                    Width      = 551,
                    Height     = 115,
                    WindowType = WindowTypes.StatusBar
                };
            }
            else if (windowId == "landingPage")
            {
                defaultLayout = new FormLayout
                {
                    X          = 200,
                    Y          = 200,
                    Width      = 415,
                    Height     = 265,
                    WindowType = WindowTypes.LandingPage
                };
            }
            return(defaultLayout);
        }
예제 #3
0
        public static bool openWindow(FormLayout layout)
        {
            var popup = new BrowserPopupForm(layout.title, layout.targetUrl, layout.WindowType, layout);

            popup.Show();
            return(true);
        }
예제 #4
0
        private void launchDesktop()
        {
            Program.ZoomLevel = Program.Layouts.ZoomLevel;
            setCheckedZoomLevelItem(Program.ZoomLevel);
            foreach (FormLayout layout in Program.Layouts.Items.Values)
            {
                if (layout.inDesktop)
                {
                    JObject args = JObject.FromObject(layout);
                    BoundObject.openWindow(layout);
                }
            }
            BrowserPopupForm sb       = Program.Windows.Items["statusBar"];
            FormLayout       sbLayout = Program.Layouts.Items["statusBar"];

            if (sb != null)
            {
                sb.SetBounds(sbLayout.X, sbLayout.Y, sbLayout.Width, sbLayout.Height);
            }
        }
예제 #5
0
        private void Init(string targetFrameName, ChromiumWebBrowser browser, WindowTypes windowType, FormLayout layout)
        {
            InitializeComponent();


            this.layout  = layout;
            this.Browser = browser;

            this.Browser.LoadError += ((e, o) => {
                CefSharp.CefErrorCode errCode = o.ErrorCode;
                string errText = o.ErrorText;
                //browser.Load("custom://cefsharp/Error.html#statusBar");
            });

            this.Browser.LifeSpanHandler = new Handlers.LifeSpanHandler();
            this.Browser.DownloadHandler = new Handlers.DownloadHandler {
                downloadDirectory = Program.DownloadDirectoryPath
            };

            this.targetUrl  = this.Browser.Address;
            this.WindowType = windowType;
            this.WindowId   = this.targetUrl;
            this.Text       = targetFrameName;


            this.notifyIcon1.Visible = this.IsLandingPage;
            this.contextMenuStrip1.Items.Find("devToolStripMenuItem", true)[0].Visible = (Program.AppMode == AppModes.Dev);

            //FormLayout layout = Program.Layouts.GetLayout(this.WindowId);
            if (layout == null)
            {
                layout = Layouts.GetDefaultLayout(this.WindowId);
            }

            if (!this.IsLandingPage)
            {
                browser.FrameLoadEnd += (obj, e) => {
                    IWebBrowser IW = (IWebBrowser)obj;
                    IW.SetZoomLevel(Program.ZoomLevel);
                };
            }


            this.StartPosition = FormStartPosition.Manual;
            this.WindowState   = (FormWindowState)layout.WindowState;
            this.SetBounds(layout.X, layout.Y, layout.Width, layout.Height);



            browser.IsBrowserInitializedChanged += (obj, e) => {
                if (e.IsBrowserInitialized)
                {
                }
            };

            if (Program.Windows.Items.Count == 0)
            {
                Program.Windows.Changed += (o, e) => this.updateDevtoolItems();
            }
            Program.Windows.RegisterWindow(this);


            this.Controls.Add(browser);
        }
예제 #6
0
 public BrowserPopupForm(string targetFrameName, ChromiumWebBrowser browser, WindowTypes windowType = WindowTypes.TraderBook, FormLayout layout = null)
 {
     this.Init(targetFrameName, browser, windowType, layout);
 }
예제 #7
0
        public BrowserPopupForm(string targetFrameName, string targetUrl, WindowTypes windowType, FormLayout layout = null)
        {
            string ON_LOAD_END   = windowType == WindowTypes.CBW ? CBW_LOAD_END_SCRIPT: TRB_LOAD_END_SCRIPT;
            string ON_LOAD_START = windowType == WindowTypes.CBW ? CBW_LOAD_START_SCRIPT: TRB_LOAD_START_SCRIPT;



            this.Init(targetFrameName, new ChromiumWebBrowser(targetUrl), windowType, layout);

            this.Browser.RegisterAsyncJsObject("bound", new BoundObject()
            {
                form = this
            });

            this.Browser.FrameLoadEnd += delegate {
                this.Browser.GetBrowser().MainFrame.ExecuteJavaScriptAsync(ON_LOAD_END);
            };

            this.Browser.FrameLoadStart += delegate { this.Browser.GetBrowser().MainFrame.ExecuteJavaScriptAsync(ON_LOAD_START); };
        }