Esempio n. 1
0
        public static Task RunNewWindowAsync <TWindow>() where TWindow : System.Windows.Window, new()
        {
            TaskCompletionSource <object> tc = new TaskCompletionSource <object>();

            // 新线程
            Thread t = new Thread(() =>
            {
                TWindow win = new TWindow();
                win.Closed += (sender, args) =>
                {
                    // 当窗口关闭后马上结束消息循环
                    System.Windows.Threading.Dispatcher.ExitAllFrames();
                };
                win.Show();

                // Run 方法必须调用,否则窗口一打开就会关闭
                // 因为没有启动消息循环
                System.Windows.Threading.Dispatcher.Run();
                // 这句话是必须的,设置Task的运算结果
                // 但由于此处不需要结果,故用null
                tc.SetResult(null);
            });

            t.IsBackground = true;
            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            // 新线程启动后,将Task实例返回
            // 以便支持 await 操作符
            return(tc.Task);
        }
Esempio n. 2
0
        /// <summary>
        /// ウィンドウを取得します。
        /// </summary>
        /// <typeparam name="TWindow">ウィンドウの型</typeparam>
        /// <typeparam name="TViewModel">ViewModelの型</typeparam>
        /// <returns>ウィンドウのインスタンス</returns>
        private TWindow GetWindow <TWindow, TViewModel>()
            where TWindow : Window, new()
            where TViewModel : WindowViewModel, new()
        {
            var windowName = typeof(TWindow).Name;

            if (!this.container.ContainsKey(windowName))
            {
                var viewModel = new TViewModel();
                var window    = new TWindow()
                {
                    DataContext = viewModel
                };

                Observable.FromEventPattern(window, nameof(window.Closed))
                .Subscribe(x => this.container.Remove(windowName))
                .AddTo(this);
                Observable.FromEventPattern(window, nameof(window.ContentRendered))
                .Subscribe(x => (x.Sender as TWindow).Activate())
                .AddTo(this);

                Observable.FromEventPattern(window, nameof(window.Activated))
                .Select(x => (x.Sender as TWindow).DataContext as TViewModel)
                .Where(x => x.IsInitialized)
                .Subscribe(_ => viewModel.Initialize())
                .AddTo(this);

                this.container.Add(windowName, window);
            }

            return(this.container[windowName] as TWindow);
        }
Esempio n. 3
0
        public TWindowButton GetButton(TWindow wnd)
        {
            TWindowButton bt = null;

            buthash2.TryGetValue(wnd, out bt);
            return(bt);
        }
Esempio n. 4
0
            /// <summary>
            ///     Create a new <see cref="SigmaWindow" /> when a tab is dragged out.
            ///     Provide a new host window so a tab can be teared from an existing window into
            ///     a new window.
            /// </summary>
            /// <param name="interTabClient"></param>
            /// <param name="partition">Provides the partition where the drag operation was initiated.</param>
            /// <param name="source">The source control where a dragging operation was initiated.</param>
            /// <returns></returns>
            public INewTabHost <Window> GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source)
            {
                TWindow window = Construct(new[] { typeof(WPFMonitor), typeof(Application), typeof(string), typeof(TWindow) },
                                           new object[] { _monitor, _app, _title, _monitor.Window });

                return(new NewTabHost <WPFWindow>(window, window.TabControl.InitialTabablzControl));
            }
Esempio n. 5
0
        public void ShowWindow <TWindow>() where TWindow : Window, new()
        {
            var w = new TWindow();

            w.Show();

            Application.Current.MainWindow.Hide();
        }
Esempio n. 6
0
        private TWindow ShowWindow <TWindow>()
            where TWindow : Window, new()
        {
            TWindow form = new TWindow();

            form.Show();
            return(form);
        }
Esempio n. 7
0
        public void AddWindow(int key, TWindow window)
        {
            if (mWindowTable.ContainsKey(key))
            {
                return;
            }

            mWindowTable.Add(key, window);
        }
        public TWindow Create <TWindow, TViewModel>()
            where TWindow : IWindow, new()
        {
            var window = new TWindow()
            {
                DataContext = _compositionContainer.GetExportedValue <TViewModel>()
            };

            return(window);
        }
Esempio n. 9
0
        protected static void Navigate <TWindow, TViewModel>()
            where TWindow : Window, new()
            where TViewModel : class
        {
            TWindow w = new TWindow();

            w.Show();
            TViewModel vm = Activator.CreateInstance(typeof(TViewModel)) as TViewModel;

            w.DataContext = vm;
        }
Esempio n. 10
0
        internal void SaveToStream(IDataStream DataStream, TSaveData SaveData, TWindow win)
        {
            byte[] RecordOrder = { 3, 1, 2, 0 };

            for (int i = 0; i < Panes.Length; i++)
            {
                if (MustSavePane(RecordOrder[i], win))
                {
                    Panes[RecordOrder[i]].SaveToStream(DataStream, SaveData, (byte)RecordOrder[i]);
                }
            }
        }
Esempio n. 11
0
 internal bool MustSavePane(int i, TWindow win)
 {
     if (Panes[i] == null || win == null)
     {
         return(false);
     }
     if (win.Window2.IsFrozen)
     {
         return(i == (int)win.Pane.ActivePaneForSelection());
     }
     return(true);
 }
 public static void SetDialogStandardSize(this TWindow control)
 {
     if (SystemParameters.PrimaryScreenWidth < 1400)
     {
         control.Width  = 635;
         control.Height = 420;
     }
     else
     {
         control.Width  = 850;
         control.Height = 565;
     }
 }
Esempio n. 13
0
        internal long TotalSize(TWindow win)
        {
            long Result = 0;

            for (int i = Panes.Length - 1; i >= 0; i--)
            {
                if (MustSavePane(i, win))
                {
                    Result += Panes[i].TotalSize();
                }
            }
            return(Result);
        }
        public static void ShowAsActive(this TWindow window)
        {
            window.ShowActivated = true;
            window.Topmost       = true;

            window.Show();
            Screen s = Screen.FromPoint(Cursor.Position);

            window.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
            window.Left           = s.WorkingArea.Right / HIOStaticValues.scale - window.Width - 16;
            window.Top            = (s.WorkingArea.Top / HIOStaticValues.scale) + 60;
            HIOStaticValues.scale = PresentationSource.FromVisual(window).CompositionTarget.TransformToDevice.M11;
            window.Activate();
            window.Focus();
        }
Esempio n. 15
0
 public WindowContext(TWindow window,
                      WindowAssigner <TInput, TWindow> windowAssigner,
                      AbstractKeyedStateBackend <TKey> keyedStateBackend,
                      ExecutionConfig executionConfig,
                      IInternalTimerService <TWindow> internalTimerService,
                      IOutput <StreamRecord <TOutput> > output,
                      WindowOperator <TKey, TInput, TAccumulator, TOutput, TWindow> windowOperator)
 {
     Window = window;
     _internalTimerService = internalTimerService;
     _output          = output;
     _windowOperator  = windowOperator;
     WindowStateStore = windowAssigner is MergingWindowAssigner <TInput, TWindow>
                        ?(AbstractPerWindowStateStore) new MergingWindowStateStore(keyedStateBackend, executionConfig)
                            : new PerWindowStateStore(keyedStateBackend, executionConfig);
 }
Esempio n. 16
0
            public Tab(string text, TWindow window, bool modifiesAsset = true)
                : base(text)
            {
                var scrollPanel = new Panel(ScrollBars.Vertical)
                {
                    AnchorPreset = AnchorPresets.StretchAll,
                    Offsets      = Margin.Zero,
                    Parent       = this
                };

                Presenter = new CustomEditorPresenter(null);
                Presenter.Panel.Parent = scrollPanel;
                if (modifiesAsset)
                {
                    Presenter.Modified += window.MarkAsEdited;
                }
            }
Esempio n. 17
0
        public static void ShowOrActivate <TWindow>()
            where TWindow : Window, new()
        {
            // 対象Windowが開かれているか探す
            var window = Application.Current.Windows.OfType <TWindow>().FirstOrDefault();

            if (window == null)
            {
                // 開かれてなかったら開く
                window = new TWindow();
                window.Show();
            }
            else
            {
                // 既に開かれていたらアクティブにする
                window.Activate();
            }
        }
Esempio n. 18
0
        private Task RunNewWindowAsync <TWindow>() where TWindow : System.Windows.Window, new()
        {
            TaskCompletionSource <object> tc = new TaskCompletionSource <object>();
            Thread thread = new Thread(() =>
            {
                TWindow win = new TWindow();
                win.Closed += (d, k) =>
                {
                    System.Windows.Threading.Dispatcher.ExitAllFrames();
                };
                win.Show();
                System.Windows.Threading.Dispatcher.Run();
                tc.SetResult(null);
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            return(tc.Task);
        }
    public static void CreateWindow <TWindow>()
        where TWindow : Window, new()
    {
        // Create a thread
        Thread newWindowThread = new Thread(new ThreadStart(() =>
        {
            SynchronizationContext.SetSynchronizationContext(
                new DispatcherSynchronizationContext(
                    Dispatcher.CurrentDispatcher));
            TWindow tempWindow = new TWindow();
            tempWindow.Closed += (s, e) => Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);
            tempWindow.Show();
            System.Windows.Threading.Dispatcher.Run();
        }));

        newWindowThread.SetApartmentState(ApartmentState.STA);
        newWindowThread.IsBackground = true;
        newWindowThread.Start();
    }
Esempio n. 20
0
        private void createButton(TWindow wnd)
        {
            CoreLib.Log(wnd.hwnd.ToString());

            var but = new TWindowButton(wnd);

            var img = wnd.GetIcon(new Size(22, 22));

            if (img != null)
            {
                but.Image = img;
                img.Show();
            }

            but.Label = wnd.GetName();
            buttonTable.Add(but);

            buthash2.Add(wnd, but);

            //but.Clicked += (s, e) => {
            //wnd.BringToFront();
            //};
        }
Esempio n. 21
0
 public virtual void OnClean()
 {
     Window = null;
     Asset  = null;
 }
Esempio n. 22
0
 public virtual void OnLoad(TWindow window)
 {
     Window = window;
     Asset  = window.Asset;
 }
Esempio n. 23
0
 public WindowTriggerContext(TKey key, TWindow window)
 {
     Key    = key;
     Window = window;
 }
Esempio n. 24
0
        private void createButton(TWindow wnd)
        {
            CoreLib.Log(wnd.hwnd.ToString());

            var but = new TWindowButton(wnd);

            var img = wnd.GetIcon(new Size(22, 22));
            if (img != null) {
                but.Image = img;
                img.Show();
            }

            but.Label = wnd.GetName();
            buttonTable.Add(but);

            buthash2.Add(wnd, but);

            //but.Clicked += (s, e) => {
            //wnd.BringToFront();
            //};
        }
Esempio n. 25
0
 public TWindowButton GetButton(TWindow wnd)
 {
     TWindowButton bt = null;
     buthash2.TryGetValue(wnd, out bt);
     return bt;
 }
Esempio n. 26
0
 public TWindowButton(TWindow wnd)
 {
     this.wnd = wnd;
 }
Esempio n. 27
0
 public _OpenInNewWindow(TWindow window) => this.window = window;
Esempio n. 28
0
 public TWindowButton(TWindow wnd)
 {
     this.wnd = wnd;
 }