public void ShowWindow(Action <UserControl> beforeShow = null)
 {
     beforeShow?.Invoke(_uc);
     if (Vm.IsDialogWindow)
     {
         this.ShowInTaskbar         = false;
         this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
         var owner = TopWindow.GetTopWindow();
         if (this != owner)
         {
             this.Owner = owner;
         }
         double ownerOpacity = this.Owner.Opacity;
         this.Owner.Opacity = 0.6;
         this.ShowDialog();
         this.Owner.Opacity = ownerOpacity;
     }
     else
     {
         this.ShowActivated = true;
         this.Show();
         if (this.WindowState == WindowState.Minimized)
         {
             this.WindowState = WindowState.Normal;
         }
         this.Activate();
     }
 }
Example #2
0
 public NTMinerFileEdit(string iconName, NTMinerFileViewModel vm)
 {
     this.DataContext = vm;
     InitializeComponent();
     this.PathIcon.Data = (Geometry)Application.Current.Resources[iconName];
     this.Owner         = TopWindow.GetTopWindow();
 }
Example #3
0
        private DialogWindow(
            string icon,
            string title,
            string message,
            Action onYes,
            Action onNo)
        {
            InitializeComponent();
            ResourceDictionarySet.Instance.FillResourceDic(this, this.Resources);
            this.Resources["Title"]   = title;
            this.Resources["Message"] = message;
            if (!string.IsNullOrEmpty(icon) && Application.Current.Resources.Contains(icon))
            {
                this.Resources["Icon"] = Application.Current.Resources[icon];
            }

            var owner = TopWindow.GetTopWindow();

            if (this != owner)
            {
                this.Owner = owner;
            }
            _onYes = onYes;
            _onNo  = onNo;
            if (onYes != null || onNo != null)
            {
                this.BtnOk.Visibility = Visibility.Collapsed;
            }
            if (onYes == null && onNo == null)
            {
                this.BtnYes.Visibility = Visibility.Collapsed;
                this.BtnNo.Visibility  = Visibility.Collapsed;
            }
        }
        /// <summary>
        /// Remove window from stack.
        /// </summary>
        private void RemoveWindow()
        {
            UserInterfaceWindow oldWindow = TopWindow;

            if (oldWindow != null && !(TopWindow is UserInterfaceWindows.DaggerfallHUD))
            {
                windows.Pop();
                oldWindow.OnPop();
                if (TopWindow != null)
                {
                    TopWindow.OnReturn();
                }
            }

            if (DaggerfallUI.Instance.enableHUD)
            {
                if (windows.Count <= 1 && GameManager.HasInstance)
                {
                    GameManager.Instance.PauseGame(false);
                    GameManager.Instance.PlayerActivate.SetClickDelay();
                }
            }
            else
            {
                if (windows.Count < 1 && GameManager.HasInstance)
                {
                    GameManager.Instance.PauseGame(false);
                    GameManager.Instance.PlayerActivate.SetClickDelay();
                }
            }
        }
Example #5
0
 public static void ShowWindow()
 {
     ContainerWindow.ShowWindow(new ContainerWindowViewModel {
         Title        = "收益计算器设置",
         IconName     = "Icon_Calc",
         Width        = 500,
         Height       = 450,
         CloseVisible = System.Windows.Visibility.Visible,
         SaveVisible  = System.Windows.Visibility.Visible,
         OnOk         = (uc) => {
             CalcConfigViewModels vm = (CalcConfigViewModels)uc.DataContext;
             NTMinerRoot.Current.CalcConfigSet.SaveCalcConfigs(vm.CalcConfigVms.Select(a => new CalcConfigData(a)).ToList());
             TopWindow.GetTopWindow()?.Close();
             return(true);
         }
     }, ucFactory: (window) => {
         var uc = new CalcConfig();
         uc.ItemsControl.MouseDown += (object sender, System.Windows.Input.MouseButtonEventArgs e) => {
             if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
             {
                 window.DragMove();
             }
         };
         return(uc);
     }, fixedSize: false);
 }
Example #6
0
 protected void CreateWindow()
 {
     string[] args = new string[0x00];
     Application.Init("idpgie", ref args);
     GraphicsContext.ShareContexts   = false;
     GraphicsContext.DirectRendering = true;
     Gdk.Threads.Init();
     tw = new TopWindow();
 }
Example #7
0
 public UIWindow Backward()
 {
     if (TopWindow != null && TopWindow != RootWindow)
     {
         DestroyWindow(TopWindow);
         TopWindow.Reshow();
         return(TopWindow);
     }
     return(null);
 }
        public MinerClientAdd(MinerClientAddViewModel vm)
        {
            this.DataContext = vm;
            InitializeComponent();
            var owner = TopWindow.GetTopWindow();

            if (this != owner)
            {
                this.Owner = owner;
            }
        }
 private bool Login()
 {
     if (string.IsNullOrEmpty(SingleUser.LoginName) || string.IsNullOrEmpty(SingleUser.PasswordSha1))
     {
         LoginWindow window = new LoginWindow()
         {
             WindowStartupLocation = WindowStartupLocation.CenterOwner,
             Owner = TopWindow.GetTopWindow()
         };
         var result = window.ShowDialogEx();
         return(result.HasValue && result.Value);
     }
     return(true);
 }
Example #10
0
 void DestroyWindow(UIWindow layer)
 {
     if (!m_dictWindows.ContainsKey(layer.name))
     {
         Debug.LogWarning("Try to destroy an unexist layer!");
     }
     m_dictWindows.Remove(layer.name);
     m_listWindows.Remove(layer);
     layer.Destroy();
     Object.DestroyImmediate(layer.gameObject);
     if (TopWindow != null)
     {
         TopWindow.Reshow();
     }
 }
Example #11
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="parentWindow">
        ///     This accesses the window that contains the stack.
        ///     The buttons need to go through the stack
        /// </param>
        /// <param name="title">Set title bar</param>
        public TopLevelPage(TopWindow parentWindow, String title)
            : base(parentWindow)
        {
            InitializeComponent();

            // initalize the stacks and set the title of the screen
            stackOfContent = new Stack<UIElement>();
            TitleBar.Title.Content = title;
            TitleBar.setTopPage(this);
            stackSubtitle = new Stack<String>();
            RightButtons.setButtons(Util.getLinks(title));

            components = new List<Animatiable>();

            components.Add(RightButtons);
        }
        /// <summary>
        /// Remove window from stack.
        /// </summary>
        private void RemoveWindow()
        {
            UserInterfaceWindow oldWindow = TopWindow;

            if (oldWindow != null)
            {
                oldWindow.OnPop();
                windows.Pop();
                if (TopWindow != null)
                {
                    TopWindow.OnReturn();
                }
            }
            if (windows.Count <= 1 && GameManager.HasInstance)
            {
                GameManager.Instance.PauseGame(false);
            }
        }
Example #13
0
 public LangViewItemViewModel(Guid id)
 {
     _id       = id;
     this.Edit = new DelegateCommand(() => {
         LangViewItemEdit.ShowWindow(new LangViewItemViewModel(this));
     });
     this.Save = new DelegateCommand(() => {
         if (LangViewItemViewModels.Current.Contains(this.Id))
         {
             VirtualRoot.Execute(new UpdateLangViewItemCommand(this));
         }
         else
         {
             VirtualRoot.Execute(new AddLangViewItemCommand(this));
         }
         TopWindow.GetTopWindow()?.Close();
     });
 }
Example #14
0
        public InputWindow(
            string title,
            string text,
            Func <string, string> check,
            Action <string> onOk)
        {
            InitializeComponent();
            TbTitle.Text = title;
            TbText.Text  = text;

            var owner = TopWindow.GetTopWindow();

            if (this != owner)
            {
                this.Owner = owner;
            }
            _check = check;
            _onOk  = onOk ?? throw new ArgumentNullException(nameof(onOk));
        }
Example #15
0
 public NTMinerFileViewModel()
 {
     _id        = Guid.NewGuid();
     _publishOn = DateTime.Now;
     this.Save  = new DelegateCommand(() => {
         if (Login())
         {
             OfficialServer.FileUrlService.AddOrUpdateNTMinerFileAsync(new NTMinerFileData().Update(this), (response, e) => {
                 if (response.IsSuccess())
                 {
                     MainWindowViewModel.Instance.Refresh();
                     UIThread.Execute(() => {
                         TopWindow.GetTopWindow()?.Close();
                     });
                 }
                 else
                 {
                     Logger.ErrorDebugLine($"AddOrUpdateNTMinerFileAsync失败");
                 }
             });
         }
     });
     this.Edit = new DelegateCommand(() => {
         NTMinerFileEdit window = new NTMinerFileEdit("Icon_Edit", new NTMinerFileViewModel(this));
         window.ShowDialogEx();
     });
     this.Remove = new DelegateCommand(() => {
         if (Login())
         {
             this.ShowDialog(message: $"确定删除{this.Version}({this.VersionTag})吗?", title: "确认", onYes: () => {
                 OfficialServer.FileUrlService.RemoveNTMinerFileAsync(this.Id, (response, e) => {
                     MainWindowViewModel.Instance.SelectedNTMinerFile = MainWindowViewModel.Instance.NTMinerFiles.FirstOrDefault();
                     if (this == MainWindowViewModel.Instance.ServerLatestVm)
                     {
                         MainWindowViewModel.Instance.ServerLatestVm = MainWindowViewModel.Instance.NTMinerFiles
                                                                       .FirstOrDefault(a => a != this && a.VersionData > MainWindowViewModel.Instance.LocalNTMinerVersion);
                     }
                     MainWindowViewModel.Instance.Refresh();
                 });
             }, icon: IconConst.IconConfirm);
         }
     });
 }
 public void ShowWindow(Action <UserControl> beforeShow = null)
 {
     beforeShow?.Invoke(_uc);
     if (Vm.IsDialogWindow || Vm.HasOwner)
     {
         var owner = TopWindow.GetTopWindow();
         if (this != owner && owner != null)
         {
             this.Owner = owner;
         }
     }
     if (Vm.IsDialogWindow || Vm.HasOwner || Vm.HeaderVisible == Visibility.Collapsed)
     {
         this.ShowInTaskbar = false;
     }
     if (Vm.IsDialogWindow)
     {
         this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
         if (this.Owner != null)
         {
             double ownerOpacity = this.Owner.Opacity;
             this.Owner.Opacity = 0.6;
             this.ShowDialog();
             this.Owner.Opacity = ownerOpacity;
         }
         else
         {
             this.ShowDialog();
         }
     }
     else
     {
         this.Topmost       = Vm.IsTopMost;
         this.ShowActivated = true;
         this.Show();
         if (this.WindowState == WindowState.Minimized)
         {
             this.WindowState = WindowState.Normal;
         }
         this.Activate();
     }
 }
 public NTMinerFileViewModel()
 {
     _id        = Guid.NewGuid();
     _publishOn = DateTime.Now;
     this.Save  = new DelegateCommand(() => {
         if (Login())
         {
             Server.FileUrlService.AddOrUpdateNTMinerFile(new NTMinerFileData().Update(this), response => {
                 if (response != null && response.IsSuccess())
                 {
                     MainWindowViewModel.Current.Refresh();
                     Execute.OnUIThread(() => {
                         TopWindow.GetTopWindow()?.Close();
                     });
                 }
             });
         }
     });
     this.Edit = new DelegateCommand(() => {
         NTMinerFileEdit window = new NTMinerFileEdit("编辑", "Icon_Edit", new NTMinerFileViewModel(this));
         window.ShowDialogEx();
     });
     this.Remove = new DelegateCommand(() => {
         if (Login())
         {
             DialogWindow.ShowDialog(message: $"确定删除{this.Version}({this.VersionTag})吗?", title: "确认", onYes: () => {
                 Server.FileUrlService.RemoveNTMinerFile(this.Id, isSuccess => {
                     MainWindowViewModel.Current.SelectedNTMinerFile = MainWindowViewModel.Current.NTMinerFiles.FirstOrDefault();
                     if (this == MainWindowViewModel.Current.ServerLatestVm)
                     {
                         MainWindowViewModel.Current.ServerLatestVm = MainWindowViewModel.Current.NTMinerFiles
                                                                      .FirstOrDefault(a => a != this && a.VersionData > MainWindowViewModel.Current.LocalNTMinerVersion);
                     }
                     MainWindowViewModel.Current.Refresh();
                 });
             }, icon: "Icon_Confirm");
         }
     });
 }
Example #18
0
        public static void ShowDialog(string icon    = null,
                                      string title   = null,
                                      string message = null,
                                      Action onYes   = null,
                                      Action onNo    = null)
        {
            Window window = new DialogWindow(icon, title, message, onYes, onNo);
            var    owner  = TopWindow.GetTopWindow();

            if (owner != window)
            {
                window.Owner = owner;
                double ownerOpacity = window.Owner.Opacity;
                window.Owner.Opacity = 0.6;
                window.ShowDialog();
                window.Owner.Opacity = ownerOpacity;
            }
            else
            {
                window.ShowDialog();
            }
        }
Example #19
0
        private DialogWindow(
            string icon,
            string title,
            string message,
            string helpUrl,
            Action onYes,
            Action onNo)
        {
            _helpUrl = helpUrl;
            InitializeComponent();
            if (!string.IsNullOrEmpty(helpUrl))
            {
                this.BtnHelp.Visibility = Visibility.Visible;
            }
            this.TextBlockTitle.Text   = title;
            this.TextBlockMessage.Text = message;
            if (!string.IsNullOrEmpty(icon) && Application.Current.Resources.Contains(icon))
            {
                this.Resources["Icon"] = Application.Current.Resources[icon];
            }

            var owner = TopWindow.GetTopWindow();

            if (this != owner)
            {
                this.Owner = owner;
            }
            _onYes = onYes;
            _onNo  = onNo;
            if (onYes != null || onNo != null)
            {
                this.BtnOk.Visibility = Visibility.Collapsed;
            }
            if (onYes == null && onNo == null)
            {
                this.BtnYes.Visibility = Visibility.Collapsed;
                this.BtnNo.Visibility  = Visibility.Collapsed;
            }
        }
Example #20
0
        private DialogWindow(
            string icon,
            string title,
            string message,
            Action onYes,
            Action onNo)
        {
            InitializeComponent();
            var owner = TopWindow.GetTopWindow();

            if (this != owner)
            {
                this.Owner = owner;
            }
            if (!string.IsNullOrEmpty(icon))
            {
                PathIcon.Data = (Geometry)Application.Current.Resources[icon];
            }
            if (!string.IsNullOrEmpty(title))
            {
                TxtTitle.Text = title;
            }
            if (!string.IsNullOrEmpty(message))
            {
                TxtMessage.Text = message;
            }
            _onYes = onYes;
            _onNo  = onNo;
            if (onYes != null || onNo != null)
            {
                this.BtnOk.Visibility = Visibility.Collapsed;
            }
            if (onYes == null && onNo == null)
            {
                this.BtnYes.Visibility = Visibility.Collapsed;
                this.BtnNo.Visibility  = Visibility.Collapsed;
            }
        }
Example #21
0
    public void Init()
    {
        if (inited)
        {
            return;
        }
        inited = true;
        //Canvas[] roots = GameObject.FindObjectsOfType<Canvas>();
        //foreach (Canvas root in roots)
        //{
        //    if (root.tag == "Debug")
        //    {
        //        debugRoot = root;
        //    }
        //    else
        //    {
        //        if (root.gameObject.layer == LayerMask.NameToLayer("UI"))
        //        {
        //            if (uiRoot != null) Debug.LogWarning("UIRoot has more than 1!");
        //            uiRoot = root;
        //        }
        //        else if (root.gameObject.layer == LayerMask.NameToLayer("SceneUI"))
        //        {
        //            if (sceneuiRoot != null) Debug.LogWarning("UIRoot has more than 1!");
        //            sceneuiRoot = root;
        //        }
        //    }
        //}

        if (uiRoot == null)
        {
            GameObject prefabUIRoot = Resources.Load <GameObject>("Prefabs/UIRoot");
            if (prefabUIRoot)
            {
                GameObject objRoot = GameObject.Instantiate(prefabUIRoot);
                if (Application.isPlaying)
                {
                    GameObject.DontDestroyOnLoad(objRoot);
                }
                Canvas[] roots = objRoot.GetComponentsInChildren <Canvas>(true);
                foreach (Canvas root in roots)
                {
                    if (root.tag == "Debug")
                    {
                        debugRoot = root;
                    }
                    else
                    {
                        if (root.name.Contains("UI"))
                        {
                            if (uiRoot != null)
                            {
                                Debug.LogWarning("UIRoot has more than 1!");
                            }
                            uiRoot = root;
                        }
                        else if (root.name.Contains("Scene"))
                        {
                            if (sceneuiRoot != null)
                            {
                                Debug.LogWarning("SceneUIRoot has more than 1!");
                            }
                            sceneuiRoot = root;
                        }
                        else if (root.name.Contains("Effect"))
                        {
                            if (effectRoot != null)
                            {
                                Debug.LogWarning("EffectRoot has more than 1!");
                            }
                            effectRoot = root;
                        }
                    }
                }
            }
        }
        if (uiRoot == null)
        {
            Debug.LogWarning("No UIRoot found!");
            return;
        }

        m_dictWindows.Clear();
        m_listWindows.Clear();

        if (TopWindow)
        {
            TopWindow.Create();
        }
    }
Example #22
0
 public virtual void Start()
 {
     parent = CommonSys.GetSystem<TopWindow>();
 }