Inheritance: UIWindowBase
コード例 #1
0
    private void RegeditNotifyScript()
    {
        if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "RegeditNotifyScript"))
        {
            Notification notify = new Notification();
            DialogWindow dw = notify.DetailDialogWindow;
            dw.AddUrlClientObjectParameter("KeyValue", "keyValue");
            dw.AddUrlClientObjectParameter("Mode", "mode");

            StringBuilder s = new StringBuilder(300);

            s.Append("function ShowNotification(mode, keyValue)");
            s.Append("{");
            s.Append("var returnValue = '';" + dw.GetShowModalDialogScript("returnValue"));
            s.Append("if(returnValue=='REFRESH'){return true;}");
            s.Append("window.event.cancelBubble = true;return false;");
            s.Append("}");

            dw = new DialogWindow();
            dw.Url = UrlHelper.UrlBase + @"/Home/Notification/NotificationDetail.aspx";
            dw.AddUrlClientObjectParameter("KeyValue", "keyValue");
            dw.Width = 1000;
            dw.Height = 700;

            s.Append("function ShowNotify(keyValue)");
            s.Append("{");
            s.Append("var returnValue = '';" + dw.GetShowModalDialogScript("returnValue"));
            s.Append("window.event.cancelBubble = true;return false;");
            s.Append("}");

            Parent.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "RegeditNotifyScript", s.ToString(), true);
        }
    }
コード例 #2
0
    private void RegditDetailScript()
    {
        if (!ClientScript.IsClientScriptBlockRegistered(this.GetType(), "JsScriptGeographyTree"))
        {
            RM rm = new RM(ResourceFile.Msg);
            StringBuilder s = new StringBuilder(700);
            DialogWindow dw = new DialogWindow();
            dw.Width = 500;
            dw.Height = 325;
            dw.DisplayScrollBar = true;
            dw.Url = UrlHelper.UrlBase + "/Setup/FileFolderDetail.aspx";
            dw.AddUrlClientObjectParameter("Mode", "mode");
            dw.AddUrlClientObjectParameter("KeyValue", "f_getSelectedNodeID(TVOrg)");
            dw.AddUrlClientObjectParameter("ParentName", "f_getSelectedNodeText(TVOrg)");
            dw.AddUrlClientObjectParameter("ParentID", "f_getSelectedNodeID(TVOrg)");//Folder_ID                                 

            s.Append("function ShowDetail(mode,type)");
            s.Append("{");
            s.AppendFormat("if(mode != 'ADD' && !CheckSelected()) {{alert('{0}');return;}}", rm["PleaseSelectNode"]);
            s.Append("var returnValue = '';" + dw.GetShowModalDialogScript("returnValue"));
            s.Append("if(returnValue=='REFRESH'){refreshParentNode(mode,type);}");
            s.Append("}\n");

            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "JsScriptGeographyTree", s.ToString(), true);
        }
    }
コード例 #3
0
ファイル: UserDialogService.cs プロジェクト: hjlfmy/Rubezh
        public bool ShowWindow(IDialogContent model)
        {
            var dialog = new DialogWindow();
            dialog.SetContent(model);

            dialog.Show();
            return true;
        }
コード例 #4
0
ファイル: Show.cs プロジェクト: kioltk/VKDesktop
 public static void DialogWindow(Dialog dialog)
 {
     if (!DialogWindowFocus(dialog))
     {
         DialogWindow dialogWindow = new DialogWindow(dialog);
         dialogWindow.Show();
         dialogWindow.Activate();
     }
 }
コード例 #5
0
        private void TerminateDialog()
        {
            this.dialog.Closed -= DialogClosed;
            this.dialog.Content = null;
            this.Region.Deactivate(this.dialog.DialogContent);
            this.dialog = null;

            Application.Current.MainWindow.Activate();
        }
コード例 #6
0
ファイル: Dialog.cs プロジェクト: StaNov/Ludum-Dare
    public void StartDialog()
    {
        Time.timeScale = 0;
        currentLineIndex = 0;
        Vector3 position = new Vector3 (transform.position.x, transform.position.y, dialogWindowPrefab.transform.position.z);
        GameObject dialogWindowObject = (GameObject) Instantiate (dialogWindowPrefab, position, Quaternion.identity);
        dialogWindow = dialogWindowObject.GetComponent<DialogWindow> ();

        ShowNextLine ();
    }
コード例 #7
0
    private void RenderShowContact()
    {
        if (!ClientScript.IsClientScriptBlockRegistered(this.GetType(), "JsShowContact"))
        {
            DialogWindow dw = new DialogWindow();
            dw.Width = 600;
            dw.Height = 600;
            dw.DisplayScrollBar = true;
            dw.Url = UrlHelper.UrlBase + "/Public/MessageContactSearch.aspx";

            dw.AddUrlClientObjectParameter("UserIds", string.Format("document.getElementById('{0}').value",this.HidReceiveUserId.ClientID));

            StringBuilder s = new StringBuilder();

            s.Append("function ShowContact()");
            s.Append("{");
            s.Append("    var tObj;");
            s.Append("    var nativeNames='';");
            s.Append("    var userIds='';");
            s.Append("    var returnValue = '';");
            s.Append("    " + dw.GetShowModalDialogScript("returnValue"));

            s.Append("if(typeof(returnValue) == 'undefined' || typeof(returnValue) == 'string')");
            s.Append("{");
            s.Append("return;");
            s.Append("}");
            s.Append("else if(typeof(returnValue) == 'object')");
            s.Append("{");
            s.Append("for(var i=0;i<returnValue.length;i++)");
            s.Append("{");
            //第一行
            s.Append("if (i==0)");
            s.Append("{");
            s.Append("tObj = returnValue[0];");
            s.Append("nativeNames = tObj.nativeName;");
            s.Append("userIds = tObj.userId;");
            s.Append("}");
            //从第二行开始,在最后先插入行,再向新行赋值
            s.Append("else");
            s.Append("{");
            s.Append("tObj = returnValue[i];");
            s.Append("nativeNames = nativeNames + ';' + tObj.nativeName;");
            s.Append("userIds = userIds + ';'+ tObj.userId;");
            s.Append("}");// end if
            s.Append("}");// end for
            s.Append("}");// end if

            s.AppendFormat("document.getElementById('{0}').value=nativeNames;", this.TxtReceiveUserName.ClientID);
            s.AppendFormat("document.getElementById('{0}').value=userIds;", this.HidReceiveUserId.ClientID);
            
            s.Append("}\n");

            ClientScript.RegisterClientScriptBlock(this.GetType(), "JsShowContact", s.ToString(), true);
        }
    }
コード例 #8
0
ファイル: DialogHelper.cs プロジェクト: sr3dna/big5sync
        /// <summary>
        /// Generates a customized Warning Dialog Box
        /// </summary>
        /// <param name="window">Parent Window</param>
        /// <param name="caption">Caption of the window</param>
        /// <param name="message">Message of the window</param>
        /// <returns>The choice of the user, which is recorded through the Application Current Properties</returns>
        public static bool ShowWarning(Window window, string caption, string message)
        {
            DialogWindow dw = new DialogWindow(window, caption, message, DialogType.Warning);
            dw.ShowDialog();

            if(Application.Current == null)
                return false;

            return (bool)Application.Current.Properties["DialogWindowChoice"];
            
        }
コード例 #9
0
    private void RenderClientScript()
    {
        if (!this.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "JsRoleFunctionOperationScript"))
        {
            StringBuilder s = new StringBuilder("");
            RM rm = new RM(ResourceFile.Msg);

            hRoleID.Value = Fn.ToString(Request.QueryString["RoleID"]);

            s.AppendFormat("{0}.treeNodeSrc='RoleFunctionOperationGetTreeNodes.aspx?RoleID={1}';", Trv1.ClientID, hRoleID.Value);
            s.AppendFormat("{0}.databind();", Trv1.ClientID);
            this.ClientScript.RegisterStartupScript(this.GetType(), "settreesrc", s.ToString(), true);

            DialogWindow detailWindow = new DialogWindow();
            detailWindow.Width = 600;
            detailWindow.Height = 650;
            detailWindow.DisplayScrollBar = false;
            detailWindow.Url = UrlHelper.UrlBase + "/Security/RoleFunctionOperationDetail.aspx";
            detailWindow.AddUrlClientObjectParameter("Mode", "mode");
            detailWindow.AddUrlParameter("RoleID", Fn.ToString(Request.QueryString["RoleID"]));
            detailWindow.AddUrlClientObjectParameter("FunctionID", String.Format("f_getSelectedNodeID({0})", this.Trv1.ClientID));

            StringBuilder sWin = new StringBuilder(500);
            sWin.AppendFormat("var userId = {0};", CurrentUser.UserID);
            sWin.Append("function CheckDelete()");
            sWin.Append("{");
            sWin.Append("if(!CheckSelected()) {alert('").Append(rm["PleaseSelectRow"]).Append("');return false;}");
            sWin.Append("if(!window.confirm('").Append(rm["ConfirmDeleteNode"]).Append("')){return false;}");
            sWin.Append("return true;");
            sWin.Append("}\n");

            sWin.Append("function CheckSelected()");
            sWin.Append("{");
            sWin.AppendFormat(@"if({0}.selectedNodeIndex == ''){{return false;}} else {{return true;}}", this.Trv1.ClientID);
            sWin.Append("}\n");

            sWin.Append("function ShowDetail(mode)");
            sWin.Append("{");
            sWin.Append("if(mode != 'ADD' && !CheckSelected()) {alert('").Append(rm["PleaseSelectNode"]).Append("');return;}");
            sWin.Append("var returnValue = '';");
            sWin.Append(detailWindow.GetShowModalDialogScript("returnValue"));
            sWin.Append("if(returnValue=='refresh'){refreshSelectedNode();}");
            sWin.Append("}\n");

            sWin.AppendFormat("var pageAddRight='{0}';", PageRight.AddRight);
            sWin.AppendFormat("var pageEditRight ='{0}';", PageRight.EditRight);
            sWin.AppendFormat("var pageDeleteRight ='{0}';", PageRight.DeleteRight);

            detailWindow = null;

            this.ClientScript.RegisterStartupScript(this.GetType(), "JsRoleFunctionOperationScript", sWin.ToString(), true);
        }
    }
コード例 #10
0
ファイル: WpfDialogService.cs プロジェクト: blindmeis/Mathe
        private bool? DoShowDialog(string titel, object datacontext,
            ApplicationSettingsBase settings, string pathHeigthSetting, string pathWidthSetting,
            double minHeigth, double minWidth, double maxHeigth = double.PositiveInfinity,
            double maxWidth = double.PositiveInfinity,
            bool showInTaskbar = false, ImageSource icon = null)
        {
            var win = new DialogWindow { Title = titel, DataContext = datacontext };

            win.Owner = Application.Current.MainWindow;
            win.ShowInTaskbar = showInTaskbar;
            win.MinHeight = minHeigth;
            win.MinWidth = minWidth;
            win.MaxHeight = maxHeigth;
            win.MaxWidth = maxWidth;

            if (icon != null)
            {
                win.Icon = icon;
            }
            else
            {
                var mainIcon = Application.Current.MainWindow.Icon;
                if (mainIcon != null)
                    win.Icon = mainIcon;
            }

            try
            {
                if (settings != null)
                {
                    win.SizeToContent = SizeToContent.Manual;

                    var height = settings[pathHeigthSetting];
                    var width = settings[pathWidthSetting];

                    BindingOperations.SetBinding(win, FrameworkElement.HeightProperty, new Binding(pathHeigthSetting) { Source = settings, Mode = BindingMode.TwoWay });
                    BindingOperations.SetBinding(win, FrameworkElement.WidthProperty, new Binding(pathWidthSetting) { Source = settings, Mode = BindingMode.TwoWay });

                    win.Height = (double)height;
                    win.Width = (double)width;
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
                win.SizeToContent = SizeToContent.WidthAndHeight;
            }

            return win.ShowDialog();
        }
コード例 #11
0
        private void ShowDialog(object item)
        {
            this.dialog = new DialogWindow
                {
                    DialogContent = item,
                    Owner = this.HostControl as Window,
                    Style = this.DialogWindowStyle,
                    WindowStartupLocation = WindowStartupLocation.CenterOwner,
                };

            this.dialog.Closed += DialogClosed;
            this.dialog.Show();

            this.dialog.Activate();
        }
コード例 #12
0
ファイル: UserDialogService.cs プロジェクト: hjlfmy/Rubezh
        public bool ShowModalWindow(IDialogContent model, Window parentWindow)
        {
            try
            {
                var dialog = new DialogWindow
                {
                    Owner = parentWindow,
                };
                dialog.SetContent(model);

                bool? result = dialog.ShowDialog();
                if (result == null)
                {
                }

                return (bool)result;
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #13
0
    private void RegeditPhotoOriginal()
    {
        PageBase page = (PageBase)this.Page;

        if (!page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "RegeditPhotoOriginal"))
        {
            DialogWindow dw = new DialogWindow();
            dw.Url = UrlHelper.UrlBase + "/UploadFile/PhotoOriginal.aspx";
            dw.AddUrlParameter("UserId", Fn.ToString(UserId));
            dw.Width = 350;
            dw.Height = 350;

            Random r = new Random();
            StringBuilder s = new StringBuilder();

            s.Append("function showOriginalImg()");
            s.Append("{");
            s.Append(dw.GetShowModalDialogScript());
            s.Append("}");

            page.ClientScript.RegisterClientScriptBlock(this.GetType(), "RegeditPhotoOriginal", s.ToString(), true);
        }
    }
コード例 #14
0
    protected virtual void RenderClientScript()
    {
        if (!this.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "JsFDefinition"))
        {
            RM rm = new RM(ResourceFile.Msg);

            DialogWindow detailWindow = new DialogWindow();
            detailWindow.Width = 700;
            detailWindow.Height = 520;
            detailWindow.DisplayScrollBar = true;
            detailWindow.Url = UrlHelper.UrlBase + "/Security/FunctionDefinitionDetail.aspx";
            detailWindow.AddUrlClientObjectParameter("Mode", "mode");
            detailWindow.AddUrlClientObjectParameter("KeyValue", String.Format("f_getSelectedNodeID({0})", UcTreeMenuList.ClientID));
            detailWindow.AddUrlClientObjectParameter("Version", String.Format("f_getSelectedNodeType({0})", UcTreeMenuList.ClientID));
            StringBuilder s = new StringBuilder(500);
            s.AppendFormat("var userId = {0};", CurrentUser.UserID); 

            //check if there is a selected node.
            s.Append("function CheckSelected()");
            s.Append("{");
            s.AppendFormat(@"if({0}.selectedNodeIndex == ''){{return false;}} else {{return true;}}", UcTreeMenuList.ClientID);
            s.Append("}\n");

            //view details.
            s.Append("function ShowDetail(mode)");
            s.Append("{");
            s.Append("if(mode != 'ADD' && !CheckSelected()) {alert('").Append(rm ["PleaseSelectNode"]).Append("');return;}");
            s.Append("var returnValue = '';");
            s.Append(detailWindow.GetShowModalDialogScript("returnValue"));
            s.Append("if(returnValue=='REFRESH'){refreshParentNode(mode);}");
            s.Append("}\n");
            detailWindow = null;

            //delete selected row
            s.Append("function CheckDelete()");
            s.Append("{");
            s.Append("if(!CheckSelected()) {alert('").Append(rm ["PleaseSelectRow"]).Append("');return false;}");
            s.Append("if(!window.confirm('").Append(rm ["ConfirmDeleteNode"]).Append("')){return false;}");
            s.Append("return true;");
            s.Append("}\n");

            //copy selected row
            s.Append("function CheckCut()");
            s.Append("{");
            s.Append("if(!CheckSelected()) {alert('").Append(rm ["PleaseSelectRow"]).Append("');return false;}");
            s.Append("if(!window.confirm('").Append(rm ["ConfirmCutNode"]).Append("')){return false;}");
            s.Append("return true;");
            s.Append("}\n");

            //cut selected row
            s.Append("function CheckCopy()");
            s.Append("{");
            s.Append("if(!CheckSelected()) {alert('").Append(rm ["PleaseSelectRow"]).Append("');return false;}");
            s.Append("if(!window.confirm('").Append(rm ["ConfirmCopyNode"]).Append("')){return false;}");
            s.Append("return true;");
            s.Append("}\n");

            s.Append("var pageAddRight='" + PageRight.AddRight + "';");
            s.Append("var pageEditRight ='" + PageRight.EditRight + "';");
            s.Append("var pageDeleteRight ='" + PageRight.DeleteRight + "';");
            s.Append("var pageReadRight ='" + PageRight.ReadRight + "';");

            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "JsFDefinition", s.ToString(), true);
        }
        
        if (!this.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "JsStartTree"))
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("{0}.treeNodeSrc='FunctionDefinitionGetChildNodes.aspx?parentNodeID={1}';", this.UcTreeMenuList.ClientID, 0);
            sb.AppendFormat("{0}.databind();", UcTreeMenuList.ClientID);
            sb.AppendFormat(";var TVOrg =document.getElementById('{0}');", this.UcTreeMenuList.ClientID);
            this.ClientScript.RegisterStartupScript(this.GetType(), "JsStartTree", sb.ToString(), true);
        }
    }
コード例 #15
0
ファイル: DialogHelper.cs プロジェクト: sr3dna/big5sync
 /// <summary>
 /// Generates a customized Error Dialog Box
 /// </summary>
 /// <param name="window">Parent Window</param>
 /// <param name="caption">Caption of the window</param>
 /// <param name="message">Message of the window</param>
 public static void ShowError(Window window, string caption, string message)
 {
     DialogWindow dw = new DialogWindow(window, caption, message, DialogType.Error);
     dw.ShowDialog();
 }
コード例 #16
0
        public PrinterConnectButton(PrinterConfig printer, ThemeConfig theme)
        {
            this.printer = printer;
            this.HAnchor = HAnchor.Left | HAnchor.Fit;
            this.VAnchor = VAnchor.Fit;
            this.Margin  = 0;
            this.Padding = 0;

            connectButton = new TextIconButton(
                "Connect".Localize(),
                AggContext.StaticData.LoadIcon("connect.png", 14, 14, theme.InvertIcons),
                theme)
            {
                Name           = "Connect to printer button",
                ToolTipText    = "Connect to the currently selected printer".Localize(),
                MouseDownColor = theme.ToolbarButtonDown,
            };
            connectButton.Click += (s, e) =>
            {
                if (connectButton.Enabled)
                {
                    if (printer.Settings.PrinterSelected)
                    {
                        UserRequestedConnectToActivePrinter();
                    }
                }
            };
            this.AddChild(connectButton);

            theme.ApplyPrimaryActionStyle(connectButton);

            // add the cancel stop button
            cancelConnectButton = new TextIconButton(
                "Cancel".Localize(),
                AggContext.StaticData.LoadIcon("connect.png", 14, 14, theme.InvertIcons),
                theme)
            {
                ToolTipText     = "Stop trying to connect to the printer.".Localize(),
                BackgroundColor = theme.ToolbarButtonBackground,
                HoverColor      = theme.ToolbarButtonHover,
                MouseDownColor  = theme.ToolbarButtonDown,
            };
            cancelConnectButton.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                listenForConnectFailed = false;
                ApplicationController.Instance.ConditionalCancelPrint();
                cancelConnectButton.Enabled = false;
            });
            this.AddChild(cancelConnectButton);

            disconnectButton = new TextIconButton(
                "Disconnect".Localize(),
                AggContext.StaticData.LoadIcon("connect.png", 14, 14, theme.InvertIcons),
                theme)
            {
                Name            = "Disconnect from printer button",
                Visible         = false,
                ToolTipText     = "Disconnect from current printer".Localize(),
                BackgroundColor = theme.ToolbarButtonBackground,
                HoverColor      = theme.ToolbarButtonHover,
                MouseDownColor  = theme.ToolbarButtonDown,
            };
            disconnectButton.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                if (printer.Connection.PrinterIsPrinting)
                {
                    StyledMessageBox.ShowMessageBox(
                        (bool disconnectCancel) =>
                    {
                        if (disconnectCancel)
                        {
                            printer.Connection.Stop(false);
                            printer.Connection.Disable();
                        }
                    },
                        "WARNING: Disconnecting will stop the current print.\n\nAre you sure you want to disconnect?".Localize(),
                        "Disconnect and stop the current print?".Localize(),
                        StyledMessageBox.MessageType.YES_NO,
                        "Disconnect".Localize(),
                        "Stay Connected".Localize());
                }
                else
                {
                    printer.Connection.Disable();
                }
            });
            this.AddChild(disconnectButton);

            foreach (var child in Children)
            {
                child.VAnchor = VAnchor.Center;
                child.Cursor  = Cursors.Hand;
                child.Margin  = theme.ButtonSpacing;
            }

            printer.Connection.EnableChanged.RegisterEvent((s, e) => SetVisibleStates(), ref unregisterEvents);
            printer.Connection.CommunicationStateChanged.RegisterEvent((s, e) => SetVisibleStates(), ref unregisterEvents);
            printer.Connection.ConnectionFailed.RegisterEvent((s, e) =>
            {
#if !__ANDROID__
                // TODO: Someday this functionality should be revised to an awaitable Connect() call in the Connect button that
                // shows troubleshooting on failed attempts, rather than hooking the failed event and trying to determine if the
                // Connect button started the task
                if (listenForConnectFailed &&
                    UiThread.CurrentTimerMs - connectStartMs < 25000)
                {
                    UiThread.RunOnIdle(() =>
                    {
                        // User initiated connect attempt failed, show port selection dialog
                        DialogWindow.Show(new SetupStepComPortOne(printer));
                    });
                }
#endif
                listenForConnectFailed = false;
            }, ref unregisterEvents);

            this.SetVisibleStates();
        }
コード例 #17
0
 public async Task ShowDiffAsync(List <string> filesPath, DialogWindow detectingWindowOwner)
 {
     await diffViewModel.DiffDocumentsAsync(filesPath, detectingWindowOwner);
 }
コード例 #18
0
ファイル: App.xaml.cs プロジェクト: ayxcjqx/ntminer
        protected override void OnStartup(StartupEventArgs e)
        {
            RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
            try {
                appMutex = new Mutex(true, s_appPipName, out createdNew);
            }
            catch (Exception) {
                createdNew = false;
            }

            if (createdNew)
            {
                AppStatic.SetIsMinerClient(false);
                SplashWindow splashWindow = new SplashWindow();
                splashWindow.Show();
                NotiCenterWindow.Instance.Show();
                bool isInnerIp = Ip.Util.IsInnerIp(NTMinerRegistry.GetControlCenterHost());
                if (isInnerIp)
                {
                    NTMinerServices.NTMinerServicesUtil.RunNTMinerServices();
                }
                NTMinerRoot.Instance.Init(() => {
                    NTMinerRoot.KernelDownloader = new KernelDownloader();
                    UIThread.Execute(() => {
                        splashWindow?.Close();
                        bool?result = true;
                        if (isInnerIp)
                        {
                            SingleUser.LoginName = "innerip";
                            SingleUser.SetPasswordSha1("123");
                            result = true;
                        }
                        else if (string.IsNullOrEmpty(SingleUser.LoginName) || string.IsNullOrEmpty(SingleUser.PasswordSha1))
                        {
                            LoginWindow loginWindow = new LoginWindow();
                            result = loginWindow.ShowDialog();
                        }
                        if (result.HasValue && result.Value)
                        {
                            ChartsWindow.ShowWindow();
                            System.Drawing.Icon icon = new System.Drawing.Icon(GetResourceStream(new Uri("pack://application:,,,/MinerStudio;component/logo.ico")).Stream);
                            AppHelper.NotifyIcon     = ExtendedNotifyIcon.Create(icon, "群控客户端", isMinerStudio: true);
                            #region 处理显示主界面命令
                            VirtualRoot.Window <ShowMainWindowCommand>("处理显示主界面命令", LogEnum.None,
                                                                       action: message => {
                                Dispatcher.Invoke((ThreadStart)ChartsWindow.ShowWindow);
                            });
                            #endregion
                            HttpServer.Start($"http://localhost:{WebApiConst.MinerStudioPort}");
                            AppHelper.RemoteDesktop = MsRdpRemoteDesktop.OpenRemoteDesktop;
                        }
                    });
                });
                VirtualRoot.Window <CloseNTMinerCommand>("处理关闭群控客户端命令", LogEnum.UserConsole,
                                                         action: message => {
                    UIThread.Execute(() => {
                        try {
                            if (MainWindow != null)
                            {
                                MainWindow.Close();
                            }
                            Shutdown();
                        }
                        catch (Exception ex) {
                            Logger.ErrorDebugLine(ex.Message, ex);
                            Environment.Exit(0);
                        }
                    });
                });
            }
            else
            {
                try {
                    AppHelper.ShowMainWindow(this, MinerServer.NTMinerAppType.MinerStudio);
                }
                catch (Exception) {
                    DialogWindow.ShowDialog(message: "另一个NTMiner正在运行,请手动结束正在运行的NTMiner进程后再次尝试。", title: "alert", icon: "Icon_Error");
                    Process currentProcess = Process.GetCurrentProcess();
                    NTMiner.Windows.TaskKill.KillOtherProcess(currentProcess);
                }
            }
            base.OnStartup(e);
        }
コード例 #19
0
 void Awake()
 {
     UIStateManager.stateChanged      += OnStateDataChanged;
     UIStateManager.debugStateChanged += OnDebugStateDataChanged;
     m_DialogWindow = GetComponent <DialogWindow>();
 }
コード例 #20
0
 private void Link()
 {
     VirtualRoot.BuildCmdPath <CloseNTMinerCommand>(action: message => {
         UIThread.Execute(() => {
             try {
                 Shutdown();
             }
             catch (Exception e) {
                 Logger.ErrorDebugLine(e);
                 Environment.Exit(0);
             }
         });
     });
     #region 周期确保守护进程在运行
     VirtualRoot.BuildEventPath <Per1MinuteEvent>("周期确保守护进程在运行", LogEnum.DevConsole,
                                                  action: message => {
         Daemon.DaemonUtil.RunNTMinerDaemon();
     });
     #endregion
     #region 开始和停止挖矿后
     VirtualRoot.BuildEventPath <MineStartedEvent>("启动1080ti小药丸、启动DevConsole? 更新挖矿按钮状态", LogEnum.DevConsole,
                                                   action: message => {
         AppContext.Instance.MinerProfileVm.IsMining       = true;
         StartStopMineButtonViewModel.Instance.BtnStopText = "正在挖矿";
         // 启动DevConsole
         if (NTMinerRoot.IsUseDevConsole)
         {
             var mineContext     = message.MineContext;
             string poolIp       = mineContext.MainCoinPool.GetIp();
             string consoleTitle = mineContext.MainCoinPool.Server;
             Daemon.DaemonUtil.RunDevConsoleAsync(poolIp, consoleTitle);
         }
         OhGodAnETHlargementPill.OhGodAnETHlargementPillUtil.Start();
     });
     VirtualRoot.BuildEventPath <MineStopedEvent>("停止挖矿后停止1080ti小药丸 挖矿停止后更新界面挖矿状态", LogEnum.DevConsole,
                                                  action: message => {
         AppContext.Instance.MinerProfileVm.IsMining       = false;
         StartStopMineButtonViewModel.Instance.BtnStopText = "尚未开始";
         OhGodAnETHlargementPill.OhGodAnETHlargementPillUtil.Stop();
     });
     #endregion
     #region 处理禁用win10系统更新
     VirtualRoot.BuildCmdPath <BlockWAUCommand>(action: message => {
         NTMiner.Windows.WindowsUtil.BlockWAU();
     });
     #endregion
     #region 优化windows
     VirtualRoot.BuildCmdPath <Win10OptimizeCommand>(action: message => {
         NTMiner.Windows.WindowsUtil.Win10Optimize();
     });
     #endregion
     #region 处理开启A卡计算模式
     VirtualRoot.BuildCmdPath <SwitchRadeonGpuCommand>(action: message => {
         if (NTMinerRoot.Instance.GpuSet.GpuType == GpuType.AMD)
         {
             SwitchRadeonGpuMode(message.On);
         }
     });
     #endregion
     #region 处理A卡驱动签名
     VirtualRoot.BuildCmdPath <AtikmdagPatcherCommand>(action: message => {
         if (NTMinerRoot.Instance.GpuSet.GpuType == GpuType.AMD)
         {
             AtikmdagPatcher.AtikmdagPatcherUtil.Run();
         }
     });
     #endregion
     #region 启用或禁用windows远程桌面
     VirtualRoot.BuildCmdPath <EnableWindowsRemoteDesktopCommand>(action: message => {
         if (NTMinerRegistry.GetIsRemoteDesktopEnabled())
         {
             return;
         }
         string msg = "确定启用Windows远程桌面吗?";
         DialogWindow.ShowDialog(new DialogWindowViewModel(
                                     message: msg,
                                     title: "确认",
                                     onYes: () => {
             Rdp.SetRdpEnabled(true);
             Firewall.AddRdpRule();
         }));
     });
     #endregion
     #region 启用或禁用windows开机自动登录
     VirtualRoot.BuildCmdPath <EnableOrDisableWindowsAutoLoginCommand>(action: message => {
         if (NTMiner.Windows.OS.Instance.IsAutoAdminLogon)
         {
             return;
         }
         NTMiner.Windows.Cmd.RunClose("control", "userpasswords2");
     });
     #endregion
 }
コード例 #21
0
 protected override void OnStartup(StartupEventArgs e)
 {
     RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
     // 之所以提前到这里是因为升级之前可能需要下载升级器,下载升级器时需要下载器
     VirtualRoot.AddCmdPath <ShowFileDownloaderCommand>(action: message => {
         FileDownloader.ShowWindow(message.DownloadFileUrl, message.FileTitle, message.DownloadComplete);
     }, location: this.GetType());
     VirtualRoot.AddCmdPath <UpgradeCommand>(action: message => {
         AppStatic.Upgrade(message.FileName, message.Callback);
     }, location: this.GetType());
     if (!string.IsNullOrEmpty(CommandLineArgs.Upgrade))
     {
         VirtualRoot.Execute(new UpgradeCommand(CommandLineArgs.Upgrade, () => {
             UIThread.Execute(() => () => { Environment.Exit(0); });
         }));
     }
     else
     {
         if (AppUtil.GetMutex(NTKeyword.MinerClientAppMutex))
         {
             Logger.InfoDebugLine($"==================NTMiner.exe {EntryAssemblyInfo.CurrentVersion.ToString()}==================");
             NotiCenterWindowViewModel.IsHotKeyEnabled = true;
             // 在另一个UI线程运行欢迎界面以确保欢迎界面的响应不被耗时的主界面初始化过程阻塞
             // 注意:必须确保SplashWindow没有用到任何其它界面用到的依赖对象
             SplashWindow splashWindow = null;
             SplashWindow.ShowWindowAsync(window => {
                 splashWindow = window;
             });
             NotiCenterWindow.Instance.ShowWindow();
             if (!NTMiner.Windows.WMI.IsWmiEnabled)
             {
                 DialogWindow.ShowHardDialog(new DialogWindowViewModel(
                                                 message: "开源矿工无法运行所需的组件,因为本机未开启WMI服务,开源矿工需要使用WMI服务检测windows的内存、显卡等信息,请先手动开启WMI。",
                                                 title: "提醒",
                                                 icon: "Icon_Error"));
                 Shutdown();
                 Environment.Exit(0);
             }
             if (!NTMiner.Windows.Role.IsAdministrator)
             {
                 NotiCenterWindowViewModel.Instance.Manager
                 .CreateMessage()
                 .Warning("提示", "请以管理员身份运行。")
                 .WithButton("点击以管理员身份运行", button => {
                     WpfUtil.RunAsAdministrator();
                 })
                 .Dismiss().WithButton("忽略", button => {
                 }).Queue();
             }
             NTMinerRoot.Instance.Init(() => {
                 _appViewFactory.Link();
                 if (VirtualRoot.IsLTWin10)
                 {
                     VirtualRoot.ThisLocalWarn(nameof(App), AppStatic.LowWinMessage, toConsole: true);
                 }
                 if (NTMinerRoot.Instance.GpuSet.Count == 0)
                 {
                     VirtualRoot.ThisLocalError(nameof(App), "没有矿卡或矿卡未驱动。", toConsole: true);
                 }
                 if (NTMinerRoot.Instance.ServerContext.CoinSet.Count == 0)
                 {
                     VirtualRoot.ThisLocalError(nameof(App), "访问阿里云失败,请尝试更换本机dns解决此问题。", toConsole: true);
                 }
                 UIThread.Execute(() => () => {
                     Window mainWindow     = null;
                     AppContext.NotifyIcon = ExtendedNotifyIcon.Create("开源矿工", isMinerStudio: false);
                     if (NTMinerRoot.Instance.MinerProfile.IsNoUi && NTMinerRoot.Instance.MinerProfile.IsAutoStart)
                     {
                         ConsoleWindow.Instance.Hide();
                         VirtualRoot.Out.ShowSuccess("以无界面模式启动,可在选项页调整设置", header: "开源矿工");
                     }
                     else
                     {
                         _appViewFactory.ShowMainWindow(isToggle: false, out mainWindow);
                     }
                     // 主窗口显式后退出SplashWindow
                     splashWindow?.Dispatcher.Invoke((Action) delegate() {
                         splashWindow?.OkClose();
                     });
                     // 启动时Windows状态栏显式的是SplashWindow的任务栏图标,SplashWindow关闭后激活主窗口的Windows任务栏图标
                     mainWindow?.Activate();
                     StartStopMineButtonViewModel.Instance.AutoStart();
                     VirtualRoot.StartTimer(new WpfTimer());
                 });
                 Task.Factory.StartNew(() => {
                     if (NTMinerRoot.Instance.MinerProfile.IsAutoDisableWindowsFirewall)
                     {
                         Firewall.DisableFirewall();
                     }
                     if (!Firewall.IsMinerClientRuleExists())
                     {
                         Firewall.AddMinerClientRule();
                     }
                     try {
                         HttpServer.Start($"http://localhost:{NTKeyword.MinerClientPort.ToString()}");
                         Daemon.DaemonUtil.RunNTMinerDaemon();
                     }
                     catch (Exception ex) {
                         Logger.ErrorDebugLine(ex);
                     }
                 });
             });
             Link();
         }
         else
         {
             try {
                 _appViewFactory.ShowMainWindow(this, NTMinerAppType.MinerClient);
             }
             catch (Exception) {
                 DialogWindow.ShowSoftDialog(new DialogWindowViewModel(
                                                 message: "另一个开源矿工正在运行但唤醒失败,请重试。",
                                                 title: "错误",
                                                 icon: "Icon_Error"));
                 Process currentProcess = Process.GetCurrentProcess();
                 NTMiner.Windows.TaskKill.KillOtherProcess(currentProcess);
             }
         }
     }
     base.OnStartup(e);
 }
コード例 #22
0
ファイル: DTOPage.xaml.cs プロジェクト: krt/OpenTouryo
        /// <summary>セーブ(ダイアログにセーブした文字列を表示する)</summary>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            DTTables dtts = new DTTables();
            dtts.Add(this.Dtt);

            DialogWindow dialogWindow = new DialogWindow(DTTables.DTTablesToString(dtts));
            dialogWindow.Show();
        }
コード例 #23
0
        private void GeneratePrinterOverflowMenu(PopupMenu popupMenu, ThemeConfig theme)
        {
            var menuActions = new List <NamedAction>()
            {
                new NamedAction()
                {
                    Icon      = AggContext.StaticData.LoadIcon("memory_16x16.png", 16, 16, theme.InvertIcons),
                    Title     = "Configure EEProm".Localize(),
                    Action    = configureEePromButton_Click,
                    IsEnabled = () => printer.Connection.IsConnected
                },
                new NamedBoolAction()
                {
                    Title       = "Show Controls".Localize(),
                    Action      = () => { },
                    GetIsActive = () => printer.ViewState.ControlsVisible,
                    SetIsActive = (value) => printer.ViewState.ControlsVisible = value
                },
                new NamedBoolAction()
                {
                    Title       = "Show Terminal".Localize(),
                    Action      = () => { },
                    GetIsActive = () => printer.ViewState.TerminalVisible,
                    SetIsActive = (value) => printer.ViewState.TerminalVisible = value
                },
                new NamedBoolAction()
                {
                    Title       = "Configure Printer".Localize(),
                    Action      = () => { },
                    GetIsActive = () => printer.ViewState.ConfigurePrinterVisible,
                    SetIsActive = (value) => printer.ViewState.ConfigurePrinterVisible = value
                },
                new ActionSeparator(),
                new NamedAction()
                {
                    Title  = "Import Presets".Localize(),
                    Action = () =>
                    {
                        AggContext.FileDialogs.OpenFileDialog(
                            new OpenFileDialogParams("settings files|*.printer"),
                            (dialogParams) =>
                        {
                            if (!string.IsNullOrEmpty(dialogParams.FileName))
                            {
                                DialogWindow.Show(new ImportSettingsPage(dialogParams.FileName, printer));
                            }
                        });
                    }
                },
                new NamedAction()
                {
                    Title  = "Export Printer".Localize(),
                    Action = () => UiThread.RunOnIdle(() =>
                    {
                        ApplicationController.Instance.ExportAsMatterControlConfig(printer);
                    }),
                    Icon = AggContext.StaticData.LoadIcon("cube_export.png", 16, 16, theme.InvertIcons),
                },
                new ActionSeparator(),

                new NamedAction()
                {
                    Title  = "Calibrate Printer".Localize(),
                    Action = () => UiThread.RunOnIdle(() =>
                    {
                        UiThread.RunOnIdle(() =>
                        {
                            DialogWindow.Show(new PrinterCalibrationWizard(printer, theme));
                        });
                    }),
                    Icon = AggContext.StaticData.LoadIcon("compass.png", 16, 16, theme.InvertIcons)
                },
                new ActionSeparator(),
                new NamedAction()
                {
                    Title  = "Update Settings...".Localize(),
                    Action = () =>
                    {
                        DialogWindow.Show(new UpdateSettingsPage(printer));
                    },
                    Icon = AggContext.StaticData.LoadIcon("fa-refresh_14.png", 16, 16, theme.InvertIcons)
                },
                new NamedAction()
                {
                    Title  = "Restore Settings...".Localize(),
                    Action = () =>
                    {
                        DialogWindow.Show(new PrinterProfileHistoryPage(printer));
                    }
                },
                new NamedAction()
                {
                    Title  = "Reset to Defaults...".Localize(),
                    Action = () =>
                    {
                        StyledMessageBox.ShowMessageBox(
                            (revertSettings) =>
                        {
                            if (revertSettings)
                            {
                                printer.Settings.ClearUserOverrides();
                                printer.Settings.ResetSettingsForNewProfile();
                                // this is user driven
                                printer.Settings.Save();
                                printer.Settings.Helpers.PrintLevelingData.SampledPositions.Clear();

                                ApplicationController.Instance.ReloadAll().ConfigureAwait(false);
                            }
                        },
                            "Resetting to default values will remove your current overrides and restore your original printer settings.\nAre you sure you want to continue?".Localize(),
                            "Revert Settings".Localize(),
                            StyledMessageBox.MessageType.YES_NO);
                    }
                },
                new ActionSeparator(),
                new NamedAction()
                {
                    Title  = "Delete Printer".Localize(),
                    Action = () =>
                    {
                        StyledMessageBox.ShowMessageBox(
                            (doDelete) =>
                        {
                            if (doDelete)
                            {
                                ProfileManager.Instance.DeletePrinter(printer.Settings.ID);
                            }
                        },
                            "Are you sure you want to delete printer '{0}'?".Localize().FormatWith(printer.Settings.GetValue(SettingsKey.printer_name)),
                            "Delete Printer?".Localize(),
                            StyledMessageBox.MessageType.YES_NO,
                            "Delete Printer".Localize());
                    },
                }
            };

            theme.CreateMenuItems(popupMenu, menuActions);
        }
コード例 #24
0
 public MinerClientViewModel(ClientData clientData)
 {
     this.ClientDataVm   = new ClientDataViewModel(clientData);
     this.RestartWindows = new DelegateCommand(() => {
         DialogWindow.ShowDialog(message: $"您确定重启{this.ClientDataVm.MinerName}电脑吗?", title: "确认", onYes: () => {
             NTMinerClientDaemon.Instance.RestartWindows(this.ClientDataVm.MinerIp, Global.ClientPort, null);
         }, icon: "Icon_Confirm");
     });
     this.ShutdownWindows = new DelegateCommand(() => {
         DialogWindow.ShowDialog(message: $"您确定关机{this.ClientDataVm.MinerName}电脑吗?", title: "确认", onYes: () => {
             NTMinerClientDaemon.Instance.ShutdownWindows(this.ClientDataVm.MinerIp, Global.ClientPort, null);
         }, icon: "Icon_Confirm");
     });
     this.StartNTMiner = new DelegateCommand(() => {
         NTMinerClientDaemon.Instance.OpenNTMiner(this.ClientDataVm.MinerIp, Global.ClientPort, this.ClientDataVm.WorkId, null);
     });
     this.RestartNTMiner = new DelegateCommand(() => {
         MinerClientRestart.ShowWindow(this);
     });
     this.CloseNTMiner = new DelegateCommand(() => {
         DialogWindow.ShowDialog(message: $"您确定关闭{this.ClientDataVm.MinerName}挖矿客户端吗?关闭客户端软件,并非关闭电脑。", title: "确认", onYes: () => {
             NTMinerClientDaemon.Instance.CloseNTMiner(this.ClientDataVm.MinerIp, Global.ClientPort, null);
         }, icon: "Icon_Confirm");
     });
     this.ShowReName = new DelegateCommand(() => {
         this.ClientDataVm.MinerNameCopy = this.ClientDataVm.MinerName;
         this.IsReNameVisible            = Visibility.Visible;
     });
     this.ReName = new DelegateCommand(() => {
         MinerClientService.Instance.SetMinerProfileProperty(
             this.ClientDataVm.MinerIp,
             this.ClientDataVm.PublicKey,
             nameof(ClientDataVm.MinerName),
             this.ClientDataVm.MinerNameCopy, null);
         TimeSpan.FromSeconds(2).Delay().ContinueWith((t) => {
             Refresh();
         });
         this.IsReNameVisible = Visibility.Collapsed;
     });
     this.CancelReName = new DelegateCommand(() => {
         this.IsReNameVisible = Visibility.Collapsed;
     });
     this.ShowChangeGroup = new DelegateCommand(() => {
         this.IsChangeGroupVisible = Visibility.Visible;
     });
     this.ChangeGroup = new DelegateCommand(() => {
         Task.Factory.StartNew(() => {
             try {
                 Server.ControlCenterService.UpdateClient(
                     this.ClientDataVm.Id,
                     nameof(ClientDataVm.GroupId),
                     this.ClientDataVm.SelectedMinerGroupCopy.Id, null);
                 this.ClientDataVm.GroupId = this.ClientDataVm.SelectedMinerGroupCopy.Id;
             }
             catch (Exception e) {
                 Global.Logger.ErrorDebugLine(e.Message, e);
             }
             TimeSpan.FromSeconds(2).Delay().ContinueWith((t) => {
                 Refresh();
             });
         });
         this.IsChangeGroupVisible = Visibility.Collapsed;
     });
     this.CancelChangeGroup = new DelegateCommand(() => {
         this.IsChangeGroupVisible = Visibility.Collapsed;
     });
     this.StartMine = new DelegateCommand(() => {
         ClientDataVm.IsMining = true;
         MinerClientService.Instance.StartMine(this.ClientDataVm.MinerIp, this.ClientDataVm.PublicKey, ClientDataVm.WorkId, null);
         TimeSpan.FromSeconds(2).Delay().ContinueWith((t) => {
             Refresh();
         });
     });
     this.StopMine = new DelegateCommand(() => {
         ClientDataVm.IsMining = false;
         MinerClientService.Instance.StopMine(this.ClientDataVm.MinerIp, this.ClientDataVm.PublicKey, null);
         TimeSpan.FromSeconds(2).Delay().ContinueWith((t) => {
             Refresh();
         });
     });
     NTMinerClientDaemon.Instance.IsNTMinerDaemonOnline(this.ClientDataVm.MinerIp, Global.ClientPort, isOnline => {
         this.IsNTMinerDaemonOnline = isOnline;
     });
 }
コード例 #25
0
 public SysDicItemViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (NTMinerRoot.Current.SysDicItemSet.ContainsKey(this.Id))
         {
             VirtualRoot.Execute(new UpdateSysDicItemCommand(this));
         }
         else
         {
             VirtualRoot.Execute(new AddSysDicItemCommand(this));
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand <FormType?>((formType) => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         SysDicItemEdit.ShowWindow(formType ?? FormType.Edit, this);
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         DialogWindow.ShowDialog(message: $"您确定删除{this.Code}系统字典项吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new RemoveSysDicItemCommand(this.Id));
         }, icon: IconConst.IconConfirm);
     });
     this.SortUp = new DelegateCommand(() => {
         SysDicItemViewModel upOne = SysDicItemViewModels.Current.List.OrderByDescending(a => a.SortNumber).FirstOrDefault(a => a.SortNumber < this.SortNumber);
         if (upOne != null)
         {
             int sortNumber   = upOne.SortNumber;
             upOne.SortNumber = this.SortNumber;
             VirtualRoot.Execute(new UpdateSysDicItemCommand(upOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdateSysDicItemCommand(this));
             SysDicViewModel sysDicVm;
             if (SysDicViewModels.Current.TryGetSysDicVm(this.DicId, out sysDicVm))
             {
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
             }
         }
     });
     this.SortDown = new DelegateCommand(() => {
         SysDicItemViewModel nextOne = SysDicItemViewModels.Current.List.OrderBy(a => a.SortNumber).FirstOrDefault(a => a.SortNumber > this.SortNumber);
         if (nextOne != null)
         {
             int sortNumber     = nextOne.SortNumber;
             nextOne.SortNumber = this.SortNumber;
             VirtualRoot.Execute(new UpdateSysDicItemCommand(nextOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdateSysDicItemCommand(this));
             SysDicViewModel sysDicVm;
             if (SysDicViewModels.Current.TryGetSysDicVm(this.DicId, out sysDicVm))
             {
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
             }
         }
     });
 }
コード例 #26
0
    private void RegeditUploadPhoto()
    {
        SetUpDetailPageBase<HRUser> page = (SetUpDetailPageBase<HRUser>)this.Page;

        if (!page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "RegeditUploadPhoto"))
        {
            DialogWindow dw = new DialogWindow();
            dw.Url = UrlHelper.UrlBase + "/UploadFile/PhotoUpload.aspx";
            dw.AddUrlParameter("UserId", Fn.ToString(page.RowData["user_id"]));
            dw.Width = 600;
            dw.Height = 450;

            Random r = new Random();
            StringBuilder s = new StringBuilder();

            //弹出文件上传的窗体
            s.Append("function onUploadPhoto()");
            s.Append("{");
            s.AppendFormat("var img = document.getElementById('{0}');", Img.ClientID);
            s.Append("var returnValue = '';" + dw.GetShowModalDialogScript("returnValue"));
            s.Append("if(returnValue =='REFRESH'){refreshImg(img);}");
            s.Append("window.event.cancelBubble = true;return false;");
            s.Append("}");

            //dw = new DialogWindow();
            //dw.Url = UrlHelper.UrlBase + "/UploadFile/PhotoOriginal.aspx";
            //dw.AddUrlParameter("UserId", Fn.ToString(page.RowData["user_id"]));
            //dw.Width = 350;
            //dw.Height = 350;

            //s.Append("function showOriginalImg()");
            //s.Append("{");
            //s.Append(dw.GetShowModalDialogScript());
            //s.Append("}");

            page.ClientScript.RegisterClientScriptBlock(this.GetType(), "RegeditUploadPhoto", s.ToString(), true);
        }
    }
コード例 #27
0
        public PartPreviewContent(ThemeConfig theme)
            : base(FlowDirection.TopToBottom)
        {
            this.AnchorAll();

            var extensionArea = new LeftClipFlowLayoutWidget()
            {
                BackgroundColor = theme.TabBarBackground,
                VAnchor         = VAnchor.Stretch,
                Padding         = new BorderDouble(left: 8)
            };

            tabControl = new ChromeTabs(extensionArea, theme)
            {
                VAnchor         = VAnchor.Stretch,
                HAnchor         = HAnchor.Stretch,
                BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor,
                BorderColor     = theme.MinimalShade,
                Border          = new BorderDouble(left: 1),
                NewTabPage      = () =>
                {
                    return(new StartTabPage(this, theme));
                }
            };
            tabControl.ActiveTabChanged += (s, e) =>
            {
                if (this.tabControl.ActiveTab?.TabContent is PartTabPage tabPage)
                {
                    var dragDropData = ApplicationController.Instance.DragDropData;

                    // Set reference on tab change
                    dragDropData.View3DWidget = tabPage.view3DWidget;
                    dragDropData.SceneContext = tabPage.sceneContext;
                }
            };

            // Force the ActionArea to be as high as ButtonHeight
            tabControl.TabBar.ActionArea.MinimumSize = new Vector2(0, theme.ButtonHeight);
            tabControl.TabBar.BackgroundColor        = theme.TabBarBackground;
            tabControl.TabBar.BorderColor            = theme.ActiveTabColor;

            // Force common padding into top region
            tabControl.TabBar.Padding = theme.TabbarPadding.Clone(top: theme.TabbarPadding.Top * 2, bottom: 0);

            // add in a what's new button
            var seeWhatsNewButton = new LinkLabel("What's New...".Localize(), theme)
            {
                Name        = "What's New Link",
                ToolTipText = "See what's new in this version of MatterControl".Localize(),
                VAnchor     = VAnchor.Center,
                Margin      = new BorderDouble(10, 0),
                TextColor   = theme.Colors.PrimaryTextColor
            };

            seeWhatsNewButton.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                UserSettings.Instance.set(UserSettingsKey.LastReadWhatsNew, JsonConvert.SerializeObject(DateTime.Now));
                DialogWindow.Show(new HelpPage("What's New"));
            });

            tabControl.TabBar.ActionArea.AddChild(seeWhatsNewButton);

            // add in the update available button
            var updateAvailableButton = new LinkLabel("Update Available".Localize(), theme)
            {
                Visible = false,
            };

            // make the function inline so we don't have to create members for the buttons
            EventHandler <StringEventArgs> SetLinkButtonsVisibility = (s, e) =>
            {
                if (UserSettings.Instance.HasLookedAtWhatsNew())
                {
                    // hide it
                    seeWhatsNewButton.Visible = false;
                }

                if (UpdateControlData.Instance.UpdateStatus == UpdateControlData.UpdateStatusStates.UpdateAvailable)
                {
                    updateAvailableButton.Visible = true;
                    // if we are going to show the update link hide the whats new link no matter what
                    seeWhatsNewButton.Visible = false;
                }
                else
                {
                    updateAvailableButton.Visible = false;
                }
            };

            UserSettings.Instance.SettingChanged += SetLinkButtonsVisibility;
            this.Closed += (s, e) => UserSettings.Instance.SettingChanged -= SetLinkButtonsVisibility;

            RunningInterval showUpdateInterval = null;

            updateAvailableButton.VisibleChanged += (s, e) =>
            {
                if (!updateAvailableButton.Visible)
                {
                    if (showUpdateInterval != null)
                    {
                        showUpdateInterval.Continue = false;
                        showUpdateInterval          = null;
                    }
                    return;
                }

                showUpdateInterval = UiThread.SetInterval(() =>
                {
                    double displayTime  = 1;
                    double pulseTime    = 1;
                    double totalSeconds = 0;
                    var textWidgets     = updateAvailableButton.Descendants <TextWidget>().Where((w) => w.Visible == true).ToArray();
                    Color startColor    = theme.Colors.PrimaryTextColor;
                    // Show a highlight on the button as the user did not click it
                    Animation flashBackground = null;
                    flashBackground           = new Animation()
                    {
                        DrawTarget      = updateAvailableButton,
                        FramesPerSecond = 10,
                        Update          = (s1, updateEvent) =>
                        {
                            totalSeconds += updateEvent.SecondsPassed;
                            if (totalSeconds < displayTime)
                            {
                                double blend = AttentionGetter.GetFadeInOutPulseRatio(totalSeconds, pulseTime);
                                var color    = new Color(startColor, (int)((1 - blend) * 255));
                                foreach (var textWidget in textWidgets)
                                {
                                    textWidget.TextColor = color;
                                }
                            }
                            else
                            {
                                foreach (var textWidget in textWidgets)
                                {
                                    textWidget.TextColor = startColor;
                                }
                                flashBackground.Stop();
                            }
                        }
                    };
                    flashBackground.Start();
                }, 120);
            };

            updateAvailableButton.Name = "Update Available Link";
            SetLinkButtonsVisibility(this, null);
            updateAvailableButton.ToolTipText = "There is a new update available for download".Localize();
            updateAvailableButton.VAnchor     = VAnchor.Center;
            updateAvailableButton.Margin      = new BorderDouble(10, 0);
            updateAvailableButton.Click      += (s, e) => UiThread.RunOnIdle(() =>
            {
                UiThread.RunOnIdle(() =>
                {
                    UpdateControlData.Instance.CheckForUpdate();
                    DialogWindow.Show <CheckForUpdatesPage>();
                });
            });

            tabControl.TabBar.ActionArea.AddChild(updateAvailableButton);

            UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent((s, e) =>
            {
                SetLinkButtonsVisibility(s, new StringEventArgs("Unknown"));
            }, ref unregisterEvents);

            this.AddChild(tabControl);

            PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
            {
                var activePrinter = ApplicationController.Instance.ActivePrinter;

                if (e is StringEventArgs stringEvent &&
                    stringEvent.Data == SettingsKey.printer_name &&
                    printerTab != null)
                {
                    printerTab.Text = activePrinter.Settings.GetValue(SettingsKey.printer_name);
                }
            }, ref unregisterEvents);

            ApplicationController.Instance.ActivePrinterChanged.RegisterEvent((s, e) =>
            {
                var activePrinter = ApplicationController.Instance.ActivePrinter;

                // If ActivePrinter has been nulled and a printer tab is open, close it
                var tab1 = tabControl.AllTabs.Skip(1).FirstOrDefault();
                if ((activePrinter == null || !activePrinter.Settings.PrinterSelected) &&
                    tab1?.TabContent is PrinterTabPage)
                {
                    tabControl.RemoveTab(tab1);
                }
                else
                {
                    this.CreatePrinterTab(activePrinter, theme);
                }
            }, ref unregisterEvents);

            ApplicationController.Instance.NotifyPrintersTabRightElement(extensionArea);

            // Show fixed start page
            tabControl.AddTab(
                new ChromeTab("Start", "Start".Localize(), tabControl, tabControl.NewTabPage(), theme, hasClose: false)
            {
                MinimumSize = new Vector2(0, theme.TabButtonHeight),
                Name        = "Start Tab",
                Padding     = new BorderDouble(15, 0)
            });

            // Add a tab for the current printer
            if (ApplicationController.Instance.ActivePrinter.Settings.PrinterSelected)
            {
                this.CreatePrinterTab(ApplicationController.Instance.ActivePrinter, theme);
            }

            // Restore active tabs
            foreach (var bed in ApplicationController.Instance.Workspaces)
            {
                this.CreatePartTab("New Part", bed, theme);
            }
        }
コード例 #28
0
        private FlowLayoutWidget NewPulldownContainer()
        {
            dropDownList = CreateDropdown();

            var container = new FlowLayoutWidget()
            {
                HAnchor = createAsFit ? HAnchor.Fit : HAnchor.MaxFitOrStretch,
                Name    = "Preset Pulldown Container"
            };

            editButton = new IconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16, theme.InvertIcons), theme)
            {
                ToolTipText = "Edit Selected Setting".Localize(),
                Enabled     = dropDownList.SelectedIndex != -1,
                VAnchor     = VAnchor.Center,
                Margin      = new BorderDouble(left: 6)
            };

            editButton.Click += (sender, e) =>
            {
                if (layerType == NamedSettingsLayers.Material)
                {
                    if (ApplicationController.Instance.EditMaterialPresetsPage == null)
                    {
                        string presetsID = printer.Settings.ActiveMaterialKey;
                        if (string.IsNullOrEmpty(presetsID))
                        {
                            return;
                        }

                        var layerToEdit = printer.Settings.MaterialLayers.Where(layer => layer.LayerID == presetsID).FirstOrDefault();

                        var presetsContext = new PresetsContext(printer.Settings.MaterialLayers, layerToEdit)
                        {
                            LayerType   = NamedSettingsLayers.Material,
                            SetAsActive = (materialKey) => printer.Settings.ActiveMaterialKey = materialKey,
                            DeleteLayer = () =>
                            {
                                printer.Settings.ActiveMaterialKey = "";
                                printer.Settings.MaterialLayers.Remove(layerToEdit);
                                printer.Settings.Save();
                            }
                        };

                        var editMaterialPresetsPage = new SlicePresetsPage(printer, presetsContext);
                        editMaterialPresetsPage.Closed += (s, e2) =>
                        {
                            ApplicationController.Instance.EditMaterialPresetsPage = null;
                        };

                        ApplicationController.Instance.EditMaterialPresetsPage = editMaterialPresetsPage;
                        DialogWindow.Show(editMaterialPresetsPage);
                    }
                    else
                    {
                        ApplicationController.Instance.EditMaterialPresetsPage.DialogWindow.BringToFront();
                    }
                }

                if (layerType == NamedSettingsLayers.Quality)
                {
                    if (ApplicationController.Instance.EditQualityPresetsWindow == null)
                    {
                        string presetsID = printer.Settings.ActiveQualityKey;
                        if (string.IsNullOrEmpty(presetsID))
                        {
                            return;
                        }

                        var layerToEdit = printer.Settings.QualityLayers.Where(layer => layer.LayerID == presetsID).FirstOrDefault();

                        var presetsContext = new PresetsContext(printer.Settings.QualityLayers, layerToEdit)
                        {
                            LayerType   = NamedSettingsLayers.Quality,
                            SetAsActive = (qualityKey) => printer.Settings.ActiveQualityKey = qualityKey,
                            DeleteLayer = () =>
                            {
                                printer.Settings.QualityLayers.Remove(layerToEdit);
                                printer.Settings.Save();

                                // Clear QualityKey after removing layer to ensure listeners see update
                                printer.Settings.ActiveQualityKey = "";
                            }
                        };

                        var editQualityPresetsWindow = new SlicePresetsPage(printer, presetsContext);
                        editQualityPresetsWindow.Closed += (s, e2) =>
                        {
                            ApplicationController.Instance.EditQualityPresetsWindow = null;
                        };

                        ApplicationController.Instance.EditQualityPresetsWindow = editQualityPresetsWindow;
                        DialogWindow.Show(editQualityPresetsWindow);
                    }
                    else
                    {
                        ApplicationController.Instance.EditQualityPresetsWindow.DialogWindow.BringToFront();
                    }
                }
            };

            container.AddChild(dropDownList);
            container.AddChild(editButton);

            return(container);
        }
コード例 #29
0
        private void onClickRent(object sender, RoutedEventArgs e)
        {
            Status = " ";
            Vehicle Item = Client.Server.ConnectProvider.GetUserVehicle(Client.User);

            if (_activeVehicle.ClientId != 0)
            {
                Status = "Цей транспорт вже орендований.";
                return;
            }

            if (Item.VIN != "null")
            {
                Status = "Ви вже маєте орендований автомобіль.";
                return;
            }

            if (date_Picker.Visibility != Visibility.Visible)
            {
                date_Picker.Visibility = Visibility.Visible;

                date_Picker.DisplayDateStart = DateTime.Now.AddDays(1);
                date_Picker.DisplayDateEnd   = DateTime.Now.AddDays(50);

                return;
            }
            else
            {
                if (string.IsNullOrEmpty(date_Picker.Text))
                {
                    Status = "Виберіть дату.";

                    return;
                }
            }

            float TotalPrice = 0;

            DateTime Time  = date_Picker.SelectedDate ?? DateTime.Now;
            TimeSpan delta = Time - DateTime.Now;
            int      days  = delta.Days;

            TotalPrice = days * _activeVehicle.Price;



            //if (TotalPrice > )

            string message = $"Ви дійсно хочете орендувати {_activeVehicle.Name} {_activeVehicle.Model} за ₴ {TotalPrice}?";

            if (DialogWindow.Show(message, "Підтвердження оренди", DialogButtons.OkNo, DialogStyle.Information) == DialogResult.Ok)
            {
                if (TotalPrice > Client.User.Balance)
                {
                    Status = "Недостатньо грошей на рахунку.";
                    return;
                }

                Client.User.Balance -= TotalPrice;

                _activeVehicle.StartDate = DateTime.Now;
                _activeVehicle.FinalDate = Time;

                _activeVehicle.ClientId = Client.User.Id;

                CashVoucher ReceiptItem = Client.CollectReceipt(Client.User, _activeVehicle, TotalPrice, _activeVehicle.StartDate, _activeVehicle.FinalDate);
                int         Id          = Client.Server.ConnectProvider.writeCashVoucher(ReceiptItem);

                _activeVehicle.RentLogId = Client.Server.ConnectProvider.log_TakeRent(
                    Client.User.Id,
                    _activeVehicle.VIN,
                    TotalPrice,
                    Id,
                    _activeVehicle.StartDate,
                    _activeVehicle.FinalDate
                    );

                Client.Server.ConnectProvider.SaveUser(Client.User);
                Client.Server.ConnectProvider.saveVehicle(_activeVehicle);

                UiOperation.SetPage(UIPage.Main);
            }
        }
コード例 #30
0
ファイル: AppViewFactory.cs プロジェクト: zhcui8899/NtMiner
        public override void BuildPaths()
        {
            var location = this.GetType();

            VirtualRoot.BuildCmdPath <ShowDialogWindowCommand>(path: message => {
                UIThread.Execute(() => {
                    DialogWindow.ShowSoftDialog(new DialogWindowViewModel(message: message.Message, title: message.Title, onYes: message.OnYes, icon: message.Icon));
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowCalcCommand>(path: message => {
                UIThread.Execute(() => {
                    Calc.ShowWindow(message.CoinVm);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowLocalIpsCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerClientUcs.LocalIpConfig.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowAboutPageCommand>(path: message => {
                UIThread.Execute(() => {
                    AboutPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowKernelOutputPageCommand>(path: message => {
                UIThread.Execute(() => {
                    KernelOutputPage.ShowWindow(message.SelectedKernelOutputVm);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowKernelInputPageCommand>(path: message => {
                UIThread.Execute(() => {
                    KernelInputPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowTagBrandCommand>(path: message => {
                if (NTMinerContext.IsBrandSpecified)
                {
                    return;
                }
                UIThread.Execute(() => {
                    BrandTag.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowCoinPageCommand>(path: message => {
                UIThread.Execute(() => {
                    CoinPage.ShowWindow(message.CurrentCoin, message.TabType);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowCoinGroupsCommand>(path: message => {
                UIThread.Execute(() => {
                    CoinGroupPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowSysDicPageCommand>(path: message => {
                UIThread.Execute(() => {
                    SysDicPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowVirtualMemoryCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerClientUcs.VirtualMemory.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowRestartWindowsCommand>(path: message => {
                UIThread.Execute(() => {
                    RestartWindows.ShowDialog(new RestartWindowsViewModel(message.CountDownSeconds));
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowNotificationSampleCommand>(path: message => {
                UIThread.Execute(() => {
                    NotificationSample.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowPropertyCommand>(path: message => {
                UIThread.Execute(() => {
                    Property.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowMessagePathIdsCommand>(path: message => {
                UIThread.Execute(() => {
                    MessagePathIds.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowKernelsWindowCommand>(path: message => {
                UIThread.Execute(() => {
                    KernelsWindow.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowKernelDownloaderCommand>(path: message => {
                UIThread.Execute(() => {
                    KernelDownloading.ShowWindow(message.KernelId, message.DownloadComplete);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditEnvironmentVariableCommand>(path: message => {
                UIThread.Execute(() => {
                    EnvironmentVariableEdit.ShowWindow(message.CoinKernelVm, message.EnvironmentVariable);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditInputSegmentCommand>(path: message => {
                UIThread.Execute(() => {
                    InputSegmentEdit.ShowWindow(message.CoinKernelVm, message.Segment);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditCoinKernelCommand>(path: message => {
                UIThread.Execute(() => {
                    CoinKernelEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditCoinCommand>(path: message => {
                UIThread.Execute(() => {
                    CoinEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowSpeedChartsCommand>(path: message => {
                UIThread.Execute(() => {
                    SpeedCharts.ShowWindow(message.GpuSpeedVm);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowFileWriterPageCommand>(path: message => {
                UIThread.Execute(() => {
                    FileWriterPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditFileWriterCommand>(path: message => {
                UIThread.Execute(() => {
                    FileWriterEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowFragmentWriterPageCommand>(path: message => {
                UIThread.Execute(() => {
                    FragmentWriterPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditFragmentWriterCommand>(path: message => {
                UIThread.Execute(() => {
                    FragmentWriterEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditGroupCommand>(path: message => {
                UIThread.Execute(() => {
                    GroupEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditServerMessageCommand>(path: message => {
                UIThread.Execute(() => {
                    ServerMessageEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditKernelInputCommand>(path: message => {
                UIThread.Execute(() => {
                    KernelInputEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditKernelOutputKeywordCommand>(path: message => {
                UIThread.Execute(() => {
                    KernelOutputKeywordEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditKernelOutputTranslaterCommand>(path: message => {
                UIThread.Execute(() => {
                    KernelOutputTranslaterEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditKernelOutputCommand>(path: message => {
                UIThread.Execute(() => {
                    KernelOutputEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowPackagesWindowCommand>(path: message => {
                UIThread.Execute(() => {
                    PackagesWindow.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditKernelCommand>(path: message => {
                UIThread.Execute(() => {
                    KernelEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditPackageCommand>(path: message => {
                UIThread.Execute(() => {
                    PackageEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditPoolKernelCommand>(path: message => {
                UIThread.Execute(() => {
                    PoolKernelEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditPoolCommand>(path: message => {
                UIThread.Execute(() => {
                    PoolEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditSysDicItemCommand>(path: message => {
                UIThread.Execute(() => {
                    SysDicItemEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditSysDicCommand>(path: message => {
                UIThread.Execute(() => {
                    SysDicEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowKernelOutputKeywordsCommand>(path: message => {
                UIThread.Execute(() => {
                    KernelOutputKeywords.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditWalletCommand>(path: message => {
                UIThread.Execute(() => {
                    WalletEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);

            #region MinerStudio
            VirtualRoot.BuildCmdPath <ShowQQGroupQrCodeCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.QQGroupQrCode.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowCalcConfigCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.CalcConfig.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowMinerClientsWindowCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioViews.MinerClientsWindow.ShowWindow(message.IsToggle);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowNTMinerUpdaterConfigCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.NTMinerUpdaterConfig.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowMinerClientFinderConfigCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.MinerClientFinderConfig.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowOverClockDataPageCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.OverClockDataPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowMinerStudioVirtualMemoryCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.VirtualMemory.ShowWindow(message.Vm);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowMinerStudioLocalIpsCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.LocalIpConfig.ShowWindow(message.Vm);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowNTMinerWalletPageCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.NTMinerWalletPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowUserPageCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.UserPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowGpuNamePageCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.GpuNameCounts.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowChangePassword>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.ChangePassword.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowWsServerNodePageCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.WsServerNodePage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowRemoteDesktopLoginDialogCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.RemoteDesktopLogin.ShowWindow(message.Vm);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowMinerClientSettingCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.MinerClientSetting.ShowWindow(message.Vm);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowMinerNamesSeterCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.MinerNamesSeter.ShowWindow(message.Vm);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowGpuProfilesPageCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.GpuProfilesPage.ShowWindow(message.MinerClientsWindowVm);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <ShowMinerClientAddCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.MinerClientAdd.ShowWindow();
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditMinerGroupCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.MinerGroupEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditNTMinerWalletCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.NTMinerWalletEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditMineWorkCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.MineWorkEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditOverClockDataCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.OverClockDataEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.BuildCmdPath <EditColumnsShowCommand>(path: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.ColumnsShowEdit.ShowWindow(message.Source);
                });
            }, location: location);
            #endregion
        }
コード例 #31
0
ファイル: VsUtils.cs プロジェクト: ajmal017/QUANT_tradeengine
 public static void DisplayDialogWindow(DialogWindow dialogWindow)
 {
     dialogWindow.HasMinimizeButton = false;
     dialogWindow.HasMaximizeButton = false;
     dialogWindow.ShowModal();
 }
コード例 #32
0
        public static async void ExecuteCommandJoinServer(ViewModelServerInfo serverInfo)
        {
            if (Api.IsEditor)
            {
                DialogWindow.ShowDialog(
                    DialogEditorMode_Title,
                    DialogEditorMode_Message);
                return;
            }

            var address = serverInfo.Address;

            if (address == default)
            {
                // should be impossible
                throw new Exception("Bad server address");
            }

            if (address.IsLocalServer)
            {
                Api.Client.LocalServer.Load(address.LocalServerSlotId);
                return;
            }

            if (serverInfo.IsInaccessible)
            {
                var title = serverInfo.IsOfficial
                                ? null
                                : GameServerLoginFailedDialogHelper.TitleDefault;

                var message = serverInfo.IsOfficial
                                  ? DialogServerInaccessible
                                  : GameServerLoginFailedDialogHelper.ServerUnreachable;

                DialogWindow.ShowDialog(
                    title: title,
                    message,
                    okAction: () =>
                {
                    if (!serverInfo.IsInaccessible)
                    {
                        // became accessible while dialog was displayed
                        ExecuteCommandJoinServer(serverInfo);
                        return;
                    }

                    // still inaccessible
                    serverInfo.CommandRefresh?.Execute(serverInfo);
                    serverInfo.RefreshAndDisplayPleaseWaitDialog(
                        onInfoReceivedOrCannotReach: () => ExecuteCommandJoinServer(serverInfo));
                },
                    cancelAction: () => { },
                    okText: CoreStrings.Button_Retry,
                    cancelText: CoreStrings.Button_Cancel,
                    closeByEscapeKey: true,
                    zIndexOffset: 100000);
                return;
            }

            if (!serverInfo.IsInfoReceived)
            {
                serverInfo.RefreshAndDisplayPleaseWaitDialog(
                    onInfoReceivedOrCannotReach: () => ExecuteCommandJoinServer(serverInfo));
                return;
            }

            if (!(serverInfo.IsCompatible ?? false))
            {
                var    serverVersion = serverInfo.Version;
                var    clientVersion = Api.Shared.GameVersionNumber;
                string problemTitle, advice;
                if (serverVersion > clientVersion)
                {
                    problemTitle = DialogIncompatibleServer_VersionTitle_Newer;
                    advice       = DialogIncompatibleServer_Advice_UpdateClient;
                }
                else
                {
                    problemTitle = DialogIncompatibleServer_VersionTitle_Older;
                    advice       = DialogIncompatibleServer_Advice_ConnectNewServer;
                }

                var message = problemTitle
                              // ReSharper disable once CanExtractXamlLocalizableStringCSharp
                              + ":[br]"
                              + string.Format(DialogIncompatibleServer_MessageFormat,
                                              serverVersion,
                                              clientVersion)
                              // ReSharper disable once CanExtractXamlLocalizableStringCSharp
                              + "[br][br]"
                              + advice;

                DialogWindow.ShowDialog(
                    DialogIncompatibleServer_Title,
                    message,
                    closeByEscapeKey: true,
                    zIndexOffset: 100000);
                return;
            }

            if (Api.Client.MasterServer.IsDemoVersion &&
                !serverInfo.IsOfficial &&
                !serverInfo.IsFeatured)
            {
                DemoVersionDialogWindow.ShowDialog();
                return;
            }

            // can display a dialog before player joins the server
            //await JoinServerAgreementDialogHelper.Display();

            Api.Client.CurrentGame.ConnectToServer(address);
        }
コード例 #33
0
        internal ControlContentExtruder(PrinterConfig printer, int extruderIndex, ThemeConfig theme)
            : base(FlowDirection.TopToBottom)
        {
            this.HAnchor = HAnchor.Stretch;
            this.printer = printer;

            GuiWidget loadUnloadButtonRow = null;

            // We do not yet support loading filament into extruders other than 0 & 1, fix it when needed.
            if (extruderIndex < 2)
            {
                // add in load and unload buttons
                loadUnloadButtonRow = new FlowLayoutWidget()
                {
                    Padding = theme.ToolbarPadding,
                };

                var loadButton = theme.CreateDialogButton("Load".Localize());
                loadButton.ToolTipText = "Load filament".Localize();
                loadButton.Name        = "Load Filament Button";
                loadButton.Click      += (s, e) => UiThread.RunOnIdle(() =>
                {
                    DialogWindow.Show(
                        new LoadFilamentWizard(printer, extruderIndex, showAlreadyLoadedButton: false));
                });

                loadUnloadButtonRow.AddChild(loadButton);

                var unloadButton = theme.CreateDialogButton("Unload".Localize());
                unloadButton.ToolTipText = "Unload filament".Localize();
                unloadButton.Click      += (s, e) => UiThread.RunOnIdle(() =>
                {
                    DialogWindow.Show(new UnloadFilamentWizard(printer, extruderIndex));
                });
                loadUnloadButtonRow.AddChild(unloadButton);

                this.AddChild(new SettingsItem("Filament".Localize(), loadUnloadButtonRow, theme, enforceGutter: false));
            }

            // Add the Extrude buttons
            var extrudeRetractButtonRow = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Fit,
                VAnchor = VAnchor.Fit,
                Padding = theme.ToolbarPadding,
            };

            int extruderButtonTopMargin = loadUnloadButtonRow == null ? 8 : 0;

            var extrudeButton = theme.CreateDialogButton("Extrude".Localize());

            extrudeButton.Name        = "Extrude Button";
            extrudeButton.ToolTipText = "Extrude filament".Localize();
            extrudeButton.Click      += (s, e) =>
            {
                printer.Connection.MoveExtruderRelative(moveAmount, printer.Settings.EFeedRate(extruderIndex), extruderIndex);
            };
            extrudeRetractButtonRow.AddChild(extrudeButton);

            var retractButton = theme.CreateDialogButton("Retract".Localize());

            retractButton.ToolTipText = "Retract filament".Localize();
            retractButton.Click      += (s, e) =>
            {
                printer.Connection.MoveExtruderRelative(moveAmount * -1, printer.Settings.EFeedRate(extruderIndex), extruderIndex);
            };
            extrudeRetractButtonRow.AddChild(retractButton);

            this.AddChild(new SettingsItem(
                              loadUnloadButtonRow == null ? "Filament".Localize() : "",   // Don't put the name if we put in a load and unload button (it has the name)
                              extrudeRetractButtonRow,
                              theme,
                              enforceGutter: false));

            var moveButtonsContainer = new FlowLayoutWidget()
            {
                VAnchor = VAnchor.Fit | VAnchor.Center,
                HAnchor = HAnchor.Fit,
                Padding = theme.ToolbarPadding,
            };

            var oneButton = theme.CreateMicroRadioButton("1");

            oneButton.CheckedStateChanged += (s, e) =>
            {
                if (oneButton.Checked)
                {
                    moveAmount = 1;
                }
            };
            moveButtonsContainer.AddChild(oneButton);

            var tenButton = theme.CreateMicroRadioButton("10");

            tenButton.CheckedStateChanged += (s, e) =>
            {
                if (tenButton.Checked)
                {
                    moveAmount = 10;
                }
            };
            moveButtonsContainer.AddChild(tenButton);

            var oneHundredButton = theme.CreateMicroRadioButton("100");

            oneHundredButton.CheckedStateChanged += (s, e) =>
            {
                if (oneHundredButton.Checked)
                {
                    moveAmount = 100;
                }
            };
            moveButtonsContainer.AddChild(oneHundredButton);

            switch (moveAmount)
            {
            case 1:
                oneButton.Checked = true;
                break;

            case 10:
                tenButton.Checked = true;
                break;

            case 100:
                oneHundredButton.Checked = true;
                break;
            }

            moveButtonsContainer.AddChild(new TextWidget("mm", textColor: theme.TextColor, pointSize: 8)
            {
                VAnchor = VAnchor.Center,
                Margin  = new BorderDouble(3, 0)
            });

            this.AddChild(new SettingsItem("Distance".Localize(), moveButtonsContainer, theme, enforceGutter: false));
        }
コード例 #34
0
        protected override void OnStartup(StartupEventArgs e)
        {
            RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
            // 通过群控升级挖矿端的时候升级器可能不存在所以需要下载,下载的时候需要用到下载器所以下载器需要提前注册
            VirtualRoot.BuildCmdPath <ShowFileDownloaderCommand>(action: message => {
                UIThread.Execute(() => {
                    FileDownloader.ShowWindow(message.DownloadFileUrl, message.FileTitle, message.DownloadComplete);
                });
            });
            VirtualRoot.BuildCmdPath <UpgradeCommand>(action: message => {
                AppStatic.Upgrade(message.FileName, message.Callback);
            });
            if (!string.IsNullOrEmpty(CommandLineArgs.Upgrade))
            {
                VirtualRoot.Execute(new UpgradeCommand(CommandLineArgs.Upgrade, () => {
                    UIThread.Execute(() => { Environment.Exit(0); });
                }));
            }
            else
            {
                try {
                    appMutex = new Mutex(true, s_appPipName, out createdNew);
                }
                catch (Exception) {
                    createdNew = false;
                }
                if (createdNew)
                {
                    Logger.InfoDebugLine($"==================NTMiner.exe {MainAssemblyInfo.CurrentVersion.ToString()}==================");
                    if (!NTMiner.Windows.WMI.IsWmiEnabled)
                    {
                        DialogWindow.ShowDialog(new DialogWindowViewModel(
                                                    message: "开源矿工无法运行所需的组件,因为本机未开启WMI服务,开源矿工需要使用WMI服务检测windows的内存、显卡等信息,请先手动开启WMI。",
                                                    title: "提醒",
                                                    icon: "Icon_Error"));
                        Shutdown();
                        Environment.Exit(0);
                    }

                    NotiCenterWindowViewModel.IsHotKeyEnabled = true;
                    ConsoleWindow.Instance.Show();
                    NotiCenterWindow.ShowWindow();
                    if (!NTMiner.Windows.Role.IsAdministrator)
                    {
                        NotiCenterWindowViewModel.Instance.Manager
                        .CreateMessage()
                        .Warning("请以管理员身份运行。")
                        .WithButton("点击以管理员身份运行", button => {
                            WpfUtil.RunAsAdministrator();
                        })
                        .Dismiss().WithButton("忽略", button => {
                        }).Queue();
                    }
                    VirtualRoot.BuildEventPath <StartingMineFailedEvent>("开始挖矿失败", LogEnum.DevConsole,
                                                                         action: message => {
                        AppContext.Instance.MinerProfileVm.IsMining = false;
                        VirtualRoot.Out.ShowError(message.Message);
                    });
                    NTMinerRoot.Instance.Init(() => {
                        _appViewFactory.Link();
                        if (VirtualRoot.IsLTWin10)
                        {
                            VirtualRoot.ThisLocalWarn(nameof(App), AppStatic.LowWinMessage, toConsole: true);
                        }
                        if (NTMinerRoot.Instance.GpuSet.Count == 0)
                        {
                            VirtualRoot.ThisLocalError(nameof(App), "没有矿卡或矿卡未驱动。", toConsole: true);
                        }
                        if (NTMinerRoot.Instance.CoinSet.Count == 0)
                        {
                            VirtualRoot.ThisLocalError(nameof(App), "访问阿里云失败,请尝试更换本机dns解决此问题。", toConsole: true);
                        }
                        UIThread.Execute(() => {
                            if (NTMinerRoot.Instance.MinerProfile.IsNoUi && NTMinerRoot.Instance.MinerProfile.IsAutoStart)
                            {
                                ConsoleWindow.Instance.Hide();
                                VirtualRoot.Out.ShowSuccess("已切换为无界面模式运行,可在选项页调整设置", "开源矿工");
                            }
                            else
                            {
                                _appViewFactory.ShowMainWindow(isToggle: false);
                            }
                            StartStopMineButtonViewModel.Instance.AutoStart();
                            AppContext.NotifyIcon = ExtendedNotifyIcon.Create("开源矿工", isMinerStudio: false);
                            ConsoleWindow.Instance.HideSplash();
                        });
                        #region 处理显示主界面命令
                        VirtualRoot.BuildCmdPath <ShowMainWindowCommand>(action: message => {
                            ShowMainWindow(message.IsToggle);
                        });
                        #endregion
                        Task.Factory.StartNew(() => {
                            if (NTMinerRoot.Instance.MinerProfile.IsAutoDisableWindowsFirewall)
                            {
                                Firewall.DisableFirewall();
                            }
                            if (!Firewall.IsMinerClientRuleExists())
                            {
                                Firewall.AddMinerClientRule();
                            }
                            try {
                                HttpServer.Start($"http://localhost:{NTKeyword.MinerClientPort}");
                                Daemon.DaemonUtil.RunNTMinerDaemon();
                            }
                            catch (Exception ex) {
                                Logger.ErrorDebugLine(ex);
                            }
                        });
                    });
                    Link();
                }
                else
                {
                    try {
                        _appViewFactory.ShowMainWindow(this, MinerServer.NTMinerAppType.MinerClient);
                    }
                    catch (Exception) {
                        DialogWindow.ShowDialog(new DialogWindowViewModel(
                                                    message: "另一个NTMiner正在运行,请手动结束正在运行的NTMiner进程后再次尝试。",
                                                    title: "提醒",
                                                    icon: "Icon_Error"));
                        Process currentProcess = Process.GetCurrentProcess();
                        NTMiner.Windows.TaskKill.KillOtherProcess(currentProcess);
                    }
                }
            }
            base.OnStartup(e);
        }
コード例 #35
0
        private void AddStandardUi(ThemeConfig theme)
        {
            var extensionArea = new LeftClipFlowLayoutWidget()
            {
                BackgroundColor = theme.TabBarBackground,
                VAnchor         = VAnchor.Stretch,
                Padding         = new BorderDouble(left: 8)
            };

            SearchPanel searchPanel = null;

            bool searchPanelOpenOnMouseDown = false;

            var searchButton = theme.CreateSearchButton();

            searchButton.Name       = "App Search Button";
            searchButton.MouseDown += (s, e) =>
            {
                searchPanelOpenOnMouseDown = searchPanel != null;
            };

            searchButton.Click += SearchButton_Click;
            extensionArea.AddChild(searchButton);

            async void SearchButton_Click(object sender, EventArgs e)
            {
                if (searchPanel == null && !searchPanelOpenOnMouseDown)
                {
                    void ShowSearchPanel()
                    {
                        searchPanel         = new SearchPanel(this.TabControl, searchButton, theme);
                        searchPanel.Closed += SearchPanel_Closed;

                        var systemWindow = this.Parents <SystemWindow>().FirstOrDefault();

                        systemWindow.ShowRightSplitPopup(
                            new MatePoint(searchButton),
                            new MatePoint(searchPanel),
                            borderWidth: 0);
                    }

                    if (HelpIndex.IndexExists)
                    {
                        ShowSearchPanel();
                    }
                    else
                    {
                        searchButton.Enabled = false;

                        try
                        {
                            // Show popover
                            var popover = new Popover(ArrowDirection.Up, 7, 5, 0)
                            {
                                TagColor = theme.AccentMimimalOverlay
                            };

                            popover.AddChild(new TextWidget("Preparing help".Localize() + "...", pointSize: theme.DefaultFontSize - 1, textColor: theme.TextColor));

                            popover.ArrowOffset = (int)(popover.Width - (searchButton.Width / 2));

                            this.Parents <SystemWindow>().FirstOrDefault().ShowPopover(
                                new MatePoint(searchButton)
                            {
                                Mate    = new MateOptions(MateEdge.Right, MateEdge.Bottom),
                                AltMate = new MateOptions(MateEdge.Right, MateEdge.Bottom),
                                Offset  = new RectangleDouble(12, 0, 12, 0)
                            },
                                new MatePoint(popover)
                            {
                                Mate    = new MateOptions(MateEdge.Right, MateEdge.Top),
                                AltMate = new MateOptions(MateEdge.Left, MateEdge.Bottom)
                            });

                            await Task.Run(async() =>
                            {
                                // Start index generation
                                await HelpIndex.RebuildIndex();

                                UiThread.RunOnIdle(() =>
                                {
                                    // Close popover
                                    popover.Close();

                                    // Continue to original task
                                    ShowSearchPanel();
                                });
                            });
                        }
                        catch
                        {
                        }

                        searchButton.Enabled = true;
                    }
                }
                else
                {
                    searchPanel?.CloseOnIdle();
                    searchPanelOpenOnMouseDown = false;
                }
            }

            void SearchPanel_Closed(object sender, EventArgs e)
            {
                // Unregister
                searchPanel.Closed -= SearchPanel_Closed;

                // Release
                searchPanel = null;
            }

            tabControl = new ChromeTabs(extensionArea, theme)
            {
                VAnchor         = VAnchor.Stretch,
                HAnchor         = HAnchor.Stretch,
                BackgroundColor = theme.BackgroundColor,
                BorderColor     = theme.MinimalShade,
                Border          = new BorderDouble(left: 1),
            };

            tabControl.PlusClicked += (s, e) => UiThread.RunOnIdle(() =>
            {
                this.CreatePartTab().ConfigureAwait(false);
            });

            // Force the ActionArea to be as high as ButtonHeight
            tabControl.TabBar.ActionArea.MinimumSize = new Vector2(0, theme.ButtonHeight);
            tabControl.TabBar.BackgroundColor        = theme.TabBarBackground;
            tabControl.TabBar.BorderColor            = theme.BackgroundColor;

            // Force common padding into top region
            tabControl.TabBar.Padding = theme.TabbarPadding.Clone(top: theme.TabbarPadding.Top * 2, bottom: 0);

            if (Application.EnableNetworkTraffic)
            {
                // add in the update available button
                updateAvailableButton = new LinkLabel("Update Available".Localize(), theme)
                {
                    Visible     = false,
                    Name        = "Update Available Link",
                    ToolTipText = "There is a new update available for download".Localize(),
                    VAnchor     = VAnchor.Center,
                    Margin      = new BorderDouble(10, 0)
                };

                // Register listeners
                UserSettings.Instance.SettingChanged += SetLinkButtonsVisibility;

                SetLinkButtonsVisibility(this, null);

                updateAvailableButton.Click += (s, e) =>
                {
                    UpdateControlData.Instance.CheckForUpdate();
                    DialogWindow.Show <CheckForUpdatesPage>();
                };

                tabControl.TabBar.ActionArea.AddChild(updateAvailableButton);

                UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent((s, e) =>
                {
                    SetLinkButtonsVisibility(s, new StringEventArgs("Unknown"));
                }, ref unregisterEvents);
            }

            this.AddChild(tabControl);

            ApplicationController.Instance.NotifyPrintersTabRightElement(extensionArea);

            // Upgrade tab
            if (!ApplicationController.Instance.IsMatterControlPro())
            {
                GuiWidget tab;
                tabControl.AddTab(
                    tab = new ChromeTab("Upgrade", "Upgrade".Localize(), tabControl, new UpgradeToProTabPage(theme), theme, hasClose: false)
                {
                    MinimumSize = new Vector2(0, theme.TabButtonHeight),
                    Name        = "Upgrade",
                    Padding     = new BorderDouble(15, 0),
                });
            }
            else
            {
                // Store tab
                tabControl.AddTab(
                    new ChromeTab("Store", "Store".Localize(), tabControl, new StoreTabPage(theme), theme, hasClose: false)
                {
                    MinimumSize = new Vector2(0, theme.TabButtonHeight),
                    Name        = "Store Tab",
                    Padding     = new BorderDouble(15, 0),
                });
            }

            // Library tab
            var libraryWidget = new LibraryWidget(this, theme)
            {
                BackgroundColor = theme.BackgroundColor
            };

            tabControl.AddTab(
                new ChromeTab("Library", "Library".Localize(), tabControl, libraryWidget, theme, hasClose: false)
            {
                MinimumSize = new Vector2(0, theme.TabButtonHeight),
                Name        = "Library Tab",
                Padding     = new BorderDouble(15, 0),
            });

            // Hardware tab
            tabControl.AddTab(
                new ChromeTab(
                    "Hardware",
                    "Hardware".Localize(),
                    tabControl,
                    new HardwareTabPage(theme)
            {
                BackgroundColor = theme.BackgroundColor
            },
                    theme,
                    hasClose: false)
            {
                MinimumSize = new Vector2(0, theme.TabButtonHeight),
                Name        = "Hardware Tab",
                Padding     = new BorderDouble(15, 0),
            });

            SetInitialTab();

            var brandMenu = new BrandMenuButton(theme)
            {
                HAnchor         = HAnchor.Fit,
                VAnchor         = VAnchor.Fit,
                BackgroundColor = theme.TabBarBackground,
                Padding         = theme.TabbarPadding.Clone(right: theme.DefaultContainerPadding)
            };

            tabControl.TabBar.ActionArea.AddChild(brandMenu, 0);

            // Restore active workspace tabs
            foreach (var workspace in ApplicationController.Instance.Workspaces)
            {
                ChromeTab newTab;

                // Create and switch to new printer tab
                if (workspace.Printer?.Settings.PrinterSelected == true)
                {
                    newTab = this.CreatePrinterTab(workspace, theme);
                }
                else
                {
                    newTab = this.CreatePartTab(workspace);
                }

                if (newTab.Key == ApplicationController.Instance.MainTabKey)
                {
                    tabControl.ActiveTab = newTab;
                }

                tabControl.RefreshTabPointers();
            }

            statusBar = new Toolbar(theme)
            {
                HAnchor         = HAnchor.Stretch,
                VAnchor         = VAnchor.Absolute,
                Padding         = 1,
                Height          = 22,
                BackgroundColor = theme.BackgroundColor,
                Border          = new BorderDouble(top: 1),
                BorderColor     = theme.BorderColor20,
            };
            this.AddChild(statusBar);

            statusBar.ActionArea.VAnchor = VAnchor.Stretch;

            tasksContainer = new FlowLayoutWidget(FlowDirection.LeftToRight)
            {
                HAnchor         = HAnchor.Fit,
                VAnchor         = VAnchor.Stretch,
                BackgroundColor = theme.MinimalShade,
                Name            = "runningTasksPanel"
            };
            statusBar.AddChild(tasksContainer);

            stretchStatusPanel = new GuiWidget()
            {
                HAnchor         = HAnchor.Stretch,
                VAnchor         = VAnchor.Stretch,
                Padding         = new BorderDouble(right: 3),
                Margin          = new BorderDouble(right: 2, top: 1, bottom: 1),
                Border          = new BorderDouble(1),
                BackgroundColor = theme.MinimalShade.WithAlpha(10),
                BorderColor     = theme.SlightShade,
                Width           = 200
            };
            statusBar.AddChild(stretchStatusPanel);

            var panelBackgroundColor = theme.MinimalShade.WithAlpha(10);

            statusBar.AddChild(
                this.CreateThemeStatusPanel(theme, panelBackgroundColor));

            statusBar.AddChild(
                this.CreateNetworkStatusPanel(theme));

            this.RenderRunningTasks(theme, ApplicationController.Instance.Tasks);
        }
コード例 #36
0
 public GroupViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (NTMinerRoot.Current.GroupSet.Contains(this.Id))
         {
             Global.Execute(new UpdateGroupCommand(this));
         }
         else
         {
             Global.Execute(new AddGroupCommand(this));
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand(() => {
         GroupEdit.ShowEditWindow(this);
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         DialogWindow.ShowDialog(message: $"您确定删除{this.Name}组吗?", title: "确认", onYes: () => {
             Global.Execute(new RemoveGroupCommand(this.Id));
         }, icon: "Icon_Confirm");
     });
     this.SortUp = new DelegateCommand(() => {
         GroupViewModel upOne = GroupViewModels.Current.List.OrderByDescending(a => a.SortNumber).FirstOrDefault(a => a.SortNumber < this.SortNumber);
         if (upOne != null)
         {
             int sortNumber   = upOne.SortNumber;
             upOne.SortNumber = this.SortNumber;
             Global.Execute(new UpdateGroupCommand(upOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdateGroupCommand(this));
             GroupViewModels.Current.OnPropertyChanged(nameof(GroupViewModels.List));
         }
     });
     this.SortDown = new DelegateCommand(() => {
         GroupViewModel nextOne = GroupViewModels.Current.List.OrderBy(a => a.SortNumber).FirstOrDefault(a => a.SortNumber > this.SortNumber);
         if (nextOne != null)
         {
             int sortNumber     = nextOne.SortNumber;
             nextOne.SortNumber = this.SortNumber;
             Global.Execute(new UpdateGroupCommand(nextOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdateGroupCommand(this));
             GroupViewModels.Current.OnPropertyChanged(nameof(GroupViewModels.List));
         }
     });
     this.AddCoinGroup = new DelegateCommand <CoinViewModel>((coinVm) => {
         if (coinVm == null)
         {
             return;
         }
         var coinGroupVms = CoinGroupViewModels.Current.GetCoinGroupsByGroupId(this.Id);
         int sortNumber   = coinGroupVms.Count == 0 ? 1 : coinGroupVms.Count + 1;
         CoinGroupViewModel coinGroupVm = new CoinGroupViewModel(Guid.NewGuid())
         {
             CoinId     = coinVm.Id,
             GroupId    = this.Id,
             SortNumber = sortNumber
         };
         Global.Execute(new AddCoinGroupCommand(coinGroupVm));
     });
 }
コード例 #37
0
ファイル: Probe-Util.cs プロジェクト: An-dir/vmPing
        private void TriggerStatusChange(StatusChangeLog status)
        {
            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                if (ApplicationOptions.PopupOption == ApplicationOptions.PopupNotificationOption.Always ||
                    (ApplicationOptions.PopupOption == ApplicationOptions.PopupNotificationOption.WhenMinimized &&
                     Application.Current.MainWindow.WindowState == WindowState.Minimized))
                {
                    mutex.WaitOne();
                    if (!Application.Current.Windows.OfType <PopupNotificationWindow>().Any())
                    {
                        // Mark all existing status changes as read.
                        for (int i = 0; i < StatusChangeLog.Count; ++i)
                        {
                            StatusChangeLog[i].HasStatusBeenCleared = true;
                        }
                    }
                    StatusChangeLog.Add(status);
                    mutex.ReleaseMutex();

                    if (StatusWindow != null && StatusWindow.IsLoaded)
                    {
                        if (StatusWindow.WindowState == WindowState.Minimized)
                        {
                            StatusWindow.WindowState = WindowState.Normal;
                        }
                        StatusWindow.Focus();
                    }
                    else if (!Application.Current.Windows.OfType <PopupNotificationWindow>().Any())
                    {
                        new PopupNotificationWindow(StatusChangeLog).Show();
                    }
                }
                else
                {
                    mutex.WaitOne();
                    StatusChangeLog.Add(status);
                    mutex.ReleaseMutex();
                }
            }));

            if (ApplicationOptions.IsLogStatusChangesEnabled && ApplicationOptions.LogStatusChangesPath.Length > 0)
            {
                mutex.WaitOne();
                WriteToStatusChangesLog(status);
                mutex.ReleaseMutex();
            }

            if ((ApplicationOptions.IsAudioDownAlertEnabled) && (status.Status == ProbeStatus.Down))
            {
                try
                {
                    using (SoundPlayer player = new SoundPlayer(ApplicationOptions.AudioDownFilePath))
                    {
                        player.Play();
                    }
                }
                catch (Exception ex)
                {
                    ApplicationOptions.IsAudioDownAlertEnabled = false;
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        DialogWindow.ErrorWindow($"Failed to play audio file. Audio alerts have been disabled. {ex.Message}").ShowDialog();
                    }));
                }
            }
            else if ((ApplicationOptions.IsAudioUpAlertEnabled) && (status.Status == ProbeStatus.Up))
            {
                try
                {
                    using (SoundPlayer player = new SoundPlayer(ApplicationOptions.AudioUpFilePath))
                    {
                        player.Play();
                    }
                }
                catch (Exception ex)
                {
                    ApplicationOptions.IsAudioUpAlertEnabled = false;
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        DialogWindow.ErrorWindow($"Failed to play audio file. Audio alerts have been disabled. {ex.Message}").ShowDialog();
                    }));
                }
            }
        }
コード例 #38
0
        public override string ReadLine()
        {
            string lineToSend = null;

            if (WaitingForUserInput)
            {
                lineToSend = "";
                Thread.Sleep(100);

                if (timeHaveBeenWaiting.IsRunning &&
                    timeHaveBeenWaiting.Elapsed.TotalSeconds > maxTimeToWaitForOk)
                {
                    if (commandsToRepeat.Count > 0)
                    {
                        // We timed out without the user responding. Cancel the operation.
                        Reset();
                    }
                    else
                    {
                        // everything normal continue after time waited
                        Continue();
                    }
                }

                if (maxTimeToWaitForOk > 0 &&
                    timeHaveBeenWaiting.Elapsed.TotalSeconds < maxTimeToWaitForOk &&
                    commandsToRepeat.Count > 0)
                {
                    lineToSend = commandsToRepeat[repeatCommandIndex % commandsToRepeat.Count];
                    repeatCommandIndex++;
                }
            }
            else
            {
                lineToSend = base.ReadLine();

                if (!string.IsNullOrEmpty(lineToSend))
                {
                    if (lineToSend.StartsWith(MacroPrefix) && lineToSend.TrimEnd().EndsWith(")"))
                    {
                        if (!runningMacro)
                        {
                            runningMacro = true;
                            int extruderCount = printer.Settings.GetValue <int>(SettingsKey.extruder_count);
                            for (int i = 0; i < extruderCount; i++)
                            {
                                startingExtruderTemps.Add(printer.Connection.GetTargetHotendTemperature(i));
                            }

                            if (printer.Settings.GetValue <bool>(SettingsKey.has_heated_bed))
                            {
                                startingBedTemp = printer.Connection.TargetBedTemperature;
                            }
                        }
                        int    parensAfterCommand = lineToSend.IndexOf('(', MacroPrefix.Length);
                        string command            = "";
                        if (parensAfterCommand > 0)
                        {
                            command = lineToSend.Substring(MacroPrefix.Length, parensAfterCommand - MacroPrefix.Length);
                        }

                        RunningMacroPage.MacroCommandData macroData = new RunningMacroPage.MacroCommandData();

                        string value = "";
                        if (TryGetAfterString(lineToSend, "title", out value))
                        {
                            macroData.title = value;
                        }
                        if (TryGetAfterString(lineToSend, "expire", out value))
                        {
                            double.TryParse(value, out macroData.expireTime);
                            maxTimeToWaitForOk = macroData.expireTime;
                            timeHaveBeenWaiting.Restart();
                        }
                        if (TryGetAfterString(lineToSend, "count_down", out value))
                        {
                            double.TryParse(value, out macroData.countDown);
                        }
                        if (TryGetAfterString(lineToSend, "markdown", out value))
                        {
                            macroData.markdown = value.Replace("\\n", "\n");
                        }
                        if (TryGetAfterString(lineToSend, "wait_ok", out value))
                        {
                            macroData.waitOk = value == "true";
                        }
                        if (TryGetAfterString(lineToSend, "repeat_gcode", out value))
                        {
                            foreach (string line in value.Split('|'))
                            {
                                commandsToRepeat.Add(line);
                            }
                        }

                        switch (command)
                        {
                        case "choose_material":
                            WaitingForUserInput            = true;
                            macroData.showMaterialSelector = true;
                            macroData.waitOk = true;

                            UiThread.RunOnIdle(() =>
                            {
                                // we are continuing normaly
                                if (currentPage != null)
                                {
                                    currentPage.ContinueToNextPage = true;
                                }
                                DialogWindow.Show(currentPage = new RunningMacroPage(printer, macroData, ApplicationController.Instance.Theme));
                            });
                            break;

                        case "close":
                            runningMacro = false;
                            // we are closing normaly
                            if (currentPage != null)
                            {
                                currentPage.ContinueToNextPage = true;
                            }
                            UiThread.RunOnIdle(() => DialogWindow.Close(typeof(RunningMacroPage)));
                            break;

                        case "ding":
                            AppContext.Platform.PlaySound("timer-done.wav");
                            break;

                        case "done_load_unload":
                            if (!printer.Connection.PrinterIsPrinting &&
                                !printer.Connection.PrinterIsPaused)
                            {
                                // turn off the temps
                                printer.Connection.TurnOffBedAndExtruders(TurnOff.AfterDelay);
                            }
                            break;

                        case "show_message":
                            WaitingForUserInput = macroData.waitOk | macroData.expireTime > 0;

                            UiThread.RunOnIdle(() =>
                            {
                                // we are continuing normaly
                                if (currentPage != null)
                                {
                                    currentPage.ContinueToNextPage = true;
                                }
                                DialogWindow.Show(currentPage = new RunningMacroPage(printer, macroData, ApplicationController.Instance.Theme));
                            });

                            break;

                        default:
                            // Don't know the command. Print to terminal log?
                            break;
                        }
                    }
                }
            }

            return(lineToSend);
        }
コード例 #39
0
 public KernelViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (NTMinerRoot.Current.KernelSet.Contains(this.Id))
         {
             Global.Execute(new UpdateKernelCommand(this));
         }
         else
         {
             Global.Execute(new AddKernelCommand(this));
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand(() => {
         if (this == Empty)
         {
             return;
         }
         KernelEdit.ShowEditWindow(this);
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         DialogWindow.ShowDialog(message: $"您确定删除{this.FullName}内核吗?", title: "确认", onYes: () => {
             Global.Execute(new RemoveKernelCommand(this.Id));
         }, icon: "Icon_Confirm");
     });
     this.SortUp = new DelegateCommand(() => {
         KernelViewModel upOne = KernelViewModels.Current.AllKernels.OrderByDescending(a => a.SortNumber).FirstOrDefault(a => a.SortNumber < this.SortNumber);
         if (upOne != null)
         {
             int sortNumber   = upOne.SortNumber;
             upOne.SortNumber = this.SortNumber;
             Global.Execute(new UpdateKernelCommand(upOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdateKernelCommand(this));
             KernelViewModels.Current.OnPropertyChanged(nameof(KernelViewModels.AllKernels));
             KernelPageViewModel.Current.OnPropertyChanged(nameof(KernelPageViewModel.QueryResults));
             KernelPageViewModel.Current.OnPropertyChanged(nameof(KernelPageViewModel.DownloadingVms));
         }
     });
     this.SortDown = new DelegateCommand(() => {
         KernelViewModel nextOne = KernelViewModels.Current.AllKernels.OrderBy(a => a.SortNumber).FirstOrDefault(a => a.SortNumber > this.SortNumber);
         if (nextOne != null)
         {
             int sortNumber     = nextOne.SortNumber;
             nextOne.SortNumber = this.SortNumber;
             Global.Execute(new UpdateKernelCommand(nextOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdateKernelCommand(this));
             KernelViewModels.Current.OnPropertyChanged(nameof(KernelViewModels.AllKernels));
             KernelPageViewModel.Current.OnPropertyChanged(nameof(KernelPageViewModel.QueryResults));
             KernelPageViewModel.Current.OnPropertyChanged(nameof(KernelPageViewModel.DownloadingVms));
         }
     });
     this.Publish = new DelegateCommand(() => {
         DialogWindow.ShowDialog(message: $"您确定发布{this.Code} (v{this.Version})吗?", title: "确认", onYes: () => {
             this.PublishState = PublishStatus.Published;
             this.PublishOn    = Global.GetTimestamp();
             Global.Execute(new UpdateKernelCommand(this));
         }, icon: "Icon_Confirm");
     });
     this.UnPublish = new DelegateCommand(() => {
         DialogWindow.ShowDialog(message: $"您确定取消发布{this.Code} (v{this.Version})吗?", title: "确认", onYes: () => {
             this.PublishState = PublishStatus.UnPublished;
             Global.Execute(new UpdateKernelCommand(this));
         }, icon: "Icon_Confirm");
     });
     this.BrowsePackage = new DelegateCommand(() => {
         OpenFileDialog openFileDialog = new OpenFileDialog {
             InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
             Filter           = "zip (*.zip)|*.zip",
             FilterIndex      = 1
         };
         if (openFileDialog.ShowDialog() == DialogResult.OK)
         {
             string package = Path.GetFileName(openFileDialog.FileName);
             this.Sha1      = HashUtil.Sha1(File.ReadAllBytes(openFileDialog.FileName));
             this.Package   = package;
             this.Size      = new FileInfo(openFileDialog.FileName).Length;
             this.KernelProfileVm.Refresh();
         }
     });
     this.AddCoinKernel = new DelegateCommand <CoinViewModel>((coinVm) => {
         int sortNumber = coinVm.CoinKernels.Count == 0 ? 1 : coinVm.CoinKernels.Max(a => a.SortNumber) + 1;
         Global.Execute(new AddCoinKernelCommand(new CoinKernelViewModel(Guid.NewGuid())
         {
             Args        = string.Empty,
             CoinId      = coinVm.Id,
             Description = string.Empty,
             KernelId    = this.Id,
             SortNumber  = sortNumber
         }));
     });
     this.AddKernelOutputFilter = new DelegateCommand(() => {
         new KernelOutputFilterViewModel(Guid.NewGuid())
         {
             KernelId = this.Id
         }.Edit.Execute(null);
     });
     this.AddKernelOutputTranslater = new DelegateCommand(() => {
         int sortNumber = this.KernelOutputTranslaters.Count == 0 ? 1 : this.KernelOutputTranslaters.Count + 1;
         new KernelOutputTranslaterViewModel(Guid.NewGuid())
         {
             KernelId   = this.Id,
             SortNumber = sortNumber
         }.Edit.Execute(null);
     });
     this.ShowKernelHelp = new DelegateCommand(() => {
         if (string.IsNullOrEmpty(HelpArg))
         {
             return;
         }
         string helpArg        = this.HelpArg.Trim();
         string asFileFullName = Path.Combine(this.GetKernelDirFullName(), helpArg);
         // 如果当前内核不处在挖矿中则可以解压缩,否则不能解压缩因为内核文件处在使用中无法覆盖
         if (!NTMinerRoot.Current.IsMining || NTMinerRoot.Current.CurrentMineContext.Kernel.GetId() != this.GetId())
         {
             if (!this.IsPackageFileExist())
             {
                 DialogWindow.ShowDialog(icon: "Icon_Info", title: "提示", message: "内核未安装");
                 return;
             }
             this.ExtractPackage();
         }
         string helpText;
         if (File.Exists(asFileFullName))
         {
             helpText = File.ReadAllText(asFileFullName);
             KernelHelpPage.ShowWindow("内核帮助 - " + this.FullName, helpText);
         }
         else
         {
             string commandName           = this.GetCommandName(fromHelpArg: true);
             string kernelExeFileFullName = Path.Combine(this.GetKernelDirFullName(), commandName);
             int exitCode = -1;
             Windows.Cmd.RunClose(kernelExeFileFullName, helpArg.Substring(commandName.Length), ref exitCode, out helpText);
         }
         KernelHelpPage.ShowWindow("内核帮助 - " + this.FullName, helpText);
     });
     this.ClearTranslaterKeyword = new DelegateCommand(() => {
         this.TranslaterKeyword = string.Empty;
     });
     this.SelectCopySourceKernel = new DelegateCommand <string>((tag) => {
         KernelCopySourceSelect.ShowWindow(this, tag);
     });
 }
コード例 #40
0
 private static void RunTroubleShooting()
 {
     DialogWindow.Show(
         new SetupWizardTroubleshooting(ApplicationController.Instance.ActivePrinter));
 }
コード例 #41
0
 public MinerClientViewModel(ClientData clientData)
 {
     _data = clientData;
     RefreshMainCoinIncome();
     RefreshDualCoinIncome();
     this.OneKeyOverClock = new DelegateCommand(() => {
     });
     this.OneKeyUpgrade   = new DelegateCommand(() => {
     });
     this.Remove          = new DelegateCommand(() => {
         DialogWindow.ShowDialog(message: $"确定删除该矿机吗?", title: "确认", onYes: () => {
             Server.ControlCenterService.RemoveClientsAsync(new List <string> {
                 this.Id
             }, (response, e) => {
                 if (!response.IsSuccess())
                 {
                     Write.UserFail(response.ReadMessage(e));
                 }
                 else
                 {
                     AppContext.Instance.MinerClientsWindowVm.QueryMinerClients();
                 }
             });
         }, icon: IconConst.IconConfirm);
     });
     this.Refresh = new DelegateCommand(() => {
         Server.ControlCenterService.RefreshClientsAsync(new List <string> {
             this.Id
         }, (response, e) => {
             if (!response.IsSuccess())
             {
                 Write.UserFail(response.ReadMessage(e));
             }
             else
             {
                 var data = response.Data.FirstOrDefault(a => a.Id == this.Id);
                 if (data != null)
                 {
                     this.Update(data);
                 }
             }
         });
     });
     this.RemoteDesktop = new DelegateCommand(() => {
         if (string.IsNullOrEmpty(this.WindowsLoginName) || string.IsNullOrEmpty(this.WindowsPassword))
         {
             NotiCenterWindowViewModel.Instance.Manager.ShowErrorMessage("没有填写远程桌面用户名密码", 4);
             return;
         }
         AppHelper.RemoteDesktop?.Invoke(new RemoteDesktopInput(this.MinerIp, this.WindowsLoginName, this.WindowsPassword, this.MinerName, message => {
             NotiCenterWindowViewModel.Instance.Manager.ShowErrorMessage(message, 4);
         }));
     });
     this.RestartWindows = new DelegateCommand(() => {
         DialogWindow.ShowDialog(message: $"您确定重启{this.MinerName}({this.MinerIp})电脑吗?", title: "确认", onYes: () => {
             Server.MinerClientService.RestartWindowsAsync(this, (response, e) => {
                 if (!response.IsSuccess())
                 {
                     Write.UserFail(response.ReadMessage(e));
                 }
             });
         }, icon: IconConst.IconConfirm);
     });
     this.ShutdownWindows = new DelegateCommand(() => {
         DialogWindow.ShowDialog(message: $"确定关闭{this.MinerName}({this.MinerIp})电脑吗?", title: "确认", onYes: () => {
             Server.MinerClientService.ShutdownWindowsAsync(this, (response, e) => {
                 if (!response.IsSuccess())
                 {
                     Write.UserFail(response.ReadMessage(e));
                 }
             });
         }, icon: IconConst.IconConfirm);
     });
     this.RestartNTMiner = new DelegateCommand(() => {
         DialogWindow.ShowDialog(message: $"确定重启{this.MinerName}({this.MinerIp})挖矿客户端吗?", title: "确认", onYes: () => {
             Server.MinerClientService.RestartNTMinerAsync(this, (response, e) => {
                 if (!response.IsSuccess())
                 {
                     Write.UserFail(response.ReadMessage(e));
                 }
             });
         }, icon: IconConst.IconConfirm);
     });
     this.StartMine = new DelegateCommand(() => {
         IsMining = true;
         Server.MinerClientService.StartMineAsync(this, WorkId, (response, e) => {
             if (!response.IsSuccess())
             {
                 Write.UserFail($"{this.MinerIp} {response.ReadMessage(e)}");
             }
         });
         Server.ControlCenterService.UpdateClientAsync(this.Id, nameof(IsMining), IsMining, null);
     });
     this.StopMine = new DelegateCommand(() => {
         DialogWindow.ShowDialog(message: $"{this.MinerName}({this.MinerIp}):确定停止挖矿吗?", title: "确认", onYes: () => {
             IsMining = false;
             Server.MinerClientService.StopMineAsync(this, (response, e) => {
                 if (!response.IsSuccess())
                 {
                     Write.UserFail($"{this.MinerIp} {response.ReadMessage(e)}");
                 }
             });
             Server.ControlCenterService.UpdateClientAsync(this.Id, nameof(IsMining), IsMining, null);
         }, icon: IconConst.IconConfirm);
     });
 }
コード例 #42
0
    void RenderClientScript()
    {

        RM rm = new RM(ResourceFile.Msg);

        RadioButtonList RblOperation = (RadioButtonList)GrdActivity.Rows[GrdActivity.EditIndex].FindControl("RblOperation");
        UcButton BtnSubmit = (UcButton)GrdActivity.Rows[GrdActivity.EditIndex].FindControl("BtnSubmit");
        BtnSubmit.OnClientClick = string.Format("if(!window.confirm('{0}')) return false;", rm["ConfirmSubmitForm"]);

        StringBuilder s = new StringBuilder(200);
        s.Append("function OnClientSubmit()");
        s.Append("{");

        s.Append("var selectedVal='';");
        s.Append("var grd;");
        s.Append("var grds =document.getElementsByTagName('TABLE');");
        s.AppendFormat("for(var i=0;i<grds.length;i++){{if(grds[i].getAttribute('id')=='{0}'){{grd=grds[i];break;}}}}", RblOperation.ClientID);//定位gridview
        s.Append("var a =grd.getElementsByTagName(\"input\");");
        s.Append("for (var i=0;i<a.length;i++){if (a[i].type == 'radio'){if (a[i].checked){selectedVal=a[i].value;break;}}}");

        foreach (ListItem item in RblOperation.Items)
        {
            if (item.Value.ToUpper() == "FORWARD")
            {
                DialogWindow w = new DialogWindow();
                w.Url = UrlHelper.UrlBase + "/DSS/IDMP/GetForwardPerson.aspx";

                w.Width = 400;
                w.Height = 280;
                s.Append("if(selectedVal=='FORWARD')");
                s.Append("{");
                s.Append("var returnValue = '';");
                s.Append(w.GetShowModalDialogScript("returnValue"));
                s.Append("if(returnValue == null || returnValue == ''){ return false;}");
                s.AppendFormat("document.all('{0}').value = returnValue;", HidForwardPerson.ClientID);
                s.Append("}");
            }
        }
        s.AppendFormat("if (selectedVal==''){{alert('{0}');return false;}}", rm["PleaseSelectOperation"]);

        s.AppendFormat("if(!window.confirm('{0}')) return false;", rm["ConfirmSubmitForm"]);
        s.Append("return true;");
        s.Append("}\n");

        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientscript", s.ToString(), true);

        BtnSubmit.OnClientClick = "if(!OnClientSubmit()){return false;} window.returnValue='REFRESH';";

        if (mode != PageMode.View)
        {
            BtnSubmit.Enabled = false;
        }
        else
        {
            BtnSubmit.Enabled = true;
        }
    }
コード例 #43
0
        public void Show(IDialogModel dataContext, Style style)
        {
            DialogWindow dialog = CreateDialog(dataContext, style, false);

            dialog.Show();
        }
コード例 #44
0
ファイル: DialogHelper.cs プロジェクト: sr3dna/big5sync
 /// <summary>
 /// Generates a customized Information Dialog Box
 /// </summary>
 /// <param name="window">Parent Window</param>
 /// <param name="caption">Caption of the window</param>
 /// <param name="message">Message of the window</param>
 public static void ShowInformation(Window window, string caption, string message)
 {
     DialogWindow dw = new DialogWindow(window, caption, message, DialogType.Information);
     dw.ShowDialog();
 }
コード例 #45
0
        public bool?ShowDialog(IDialogModel dataContext, Style style)
        {
            DialogWindow dialog = CreateDialog(dataContext, style, true);

            return(dialog.ShowDialog());
        }
コード例 #46
0
ファイル: DialogHelper.cs プロジェクト: sr3dna/big5sync
 /// <summary>
 /// Generates an unclosable DialogBox with an indeterminate progress bar. Eg. TerminationWindow
 /// </summary>
 /// <param name="window">Parent Window</param>
 /// <param name="caption">Caption of the window</param>
 /// <param name="message">Message of the window</param>
 /// <returns>The dialog window itself</returns>
 public static DialogWindow ShowIndeterminate(Window window, string caption, string message)
 {
     DialogWindow dw = new DialogWindow(window, caption, message, DialogType.Indeterminate);
     return dw;
 }
コード例 #47
0
    private void RenderViewClientScript()
    {
        if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "JsProcessListView"))
        {
            DialogWindow dw = new DialogWindow();
            dw.Url = UrlHelper.UrlBase + VersionCompareFormPath;           
            dw.AddUrlClientObjectParameter("CurBakID", "bakId");
            dw.AddUrlClientObjectParameter("CurVersion", "version");
            dw.AddUrlParameter("FunctionID", RightFunctionID.ToString());
            dw.AddUrlParameter("BakFormPath", BakFormPath);
            dw.AddUrlParameter("VersionCompareProcName", VersionCompareProcName);
            dw.AddUrlParameter("VersionCompareAllProcName", VersionCompareAllProcName);
            dw.Width = 1000;
            dw.Height = 700;

            StringBuilder s = new StringBuilder(300);                       

            s.Append("function ShowVersionCompare(bakId,version)");
            s.Append("{");            
            s.Append(dw.GetShowModalDialogScript());
            s.Append("}");

            dw = new DialogWindow();
            dw.Url = UrlHelper.UrlBase + BakFormPath;
            dw.AddUrlClientObjectParameter("Mode", "mode");
            dw.AddUrlClientObjectParameter("KeyValue", "keyvalue");
            dw.AddUrlClientObjectParameter("Version", "version");
            dw.AddUrlParameter("FunctionID", RightFunctionID.ToString());            
            dw.Width = 1000;
            dw.Height = 700;

            s.Append("function ShowBakForm(mode,keyvalue,version)");
            s.Append("{");            
            s.Append(dw.GetShowModalDialogScript());
            s.Append("}");

            Parent.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "JsProcessListView", s.ToString().Trim(), true);
        }
    }
コード例 #48
0
    private void RegeditBackUpDetail()
    {
        if (!this.Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "RegeditBackUpDetail"))
        {
            DialogWindow dw = new DialogWindow();
            dw.Url = UrlHelper.UrlBase + BakFormPath;
            dw.AddUrlClientObjectParameter("Mode", "mode");
            dw.AddUrlClientObjectParameter("KeyValue", "keyvalue");
            dw.AddUrlClientObjectParameter("Version", "version");
            dw.AddUrlParameter("FunctionID", FunctionID);
            dw.Width = 1000;
            dw.Height = 700;

            StringBuilder s = new StringBuilder(100);

            s.Append("function ShowBakForm(mode,keyvalue,version)");
            s.Append("{");
            s.Append(dw.GetShowModalDialogScript());
            s.Append("}");

            this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "RegeditBackUpDetail", s.ToString().Trim(), true);
        }
    }
コード例 #49
0
ファイル: PoolViewModel.cs プロジェクト: ouguochong/ntminer
 public PoolViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (NTMinerRoot.Current.PoolSet.Contains(this.Id))
         {
             Global.Execute(new UpdatePoolCommand(this));
         }
         else
         {
             Global.Execute(new AddPoolCommand(this));
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand(() => {
         PoolEdit.ShowEditWindow(this);
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         DialogWindow.ShowDialog(message: $"您确定删除{this.Name}矿池吗?", title: "确认", onYes: () => {
             Global.Execute(new RemovePoolCommand(this.Id));
         }, icon: "Icon_Confirm");
     });
     this.SortUp = new DelegateCommand(() => {
         PoolViewModel upOne = PoolViewModels.Current.AllPools.OrderByDescending(a => a.SortNumber).FirstOrDefault(a => a.CoinId == this.CoinId && a.SortNumber < this.SortNumber);
         if (upOne != null)
         {
             int sortNumber   = upOne.SortNumber;
             upOne.SortNumber = this.SortNumber;
             Global.Execute(new UpdatePoolCommand(upOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdatePoolCommand(this));
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Pools));
                 coinVm.OnPropertyChanged(nameof(coinVm.OptionPools));
             }
         }
     });
     this.SortDown = new DelegateCommand(() => {
         PoolViewModel nextOne = PoolViewModels.Current.AllPools.OrderBy(a => a.SortNumber).FirstOrDefault(a => a.CoinId == this.CoinId && a.SortNumber > this.SortNumber);
         if (nextOne != null)
         {
             int sortNumber     = nextOne.SortNumber;
             nextOne.SortNumber = this.SortNumber;
             Global.Execute(new UpdatePoolCommand(nextOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdatePoolCommand(this));
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Pools));
                 coinVm.OnPropertyChanged(nameof(coinVm.OptionPools));
             }
         }
     });
     this.ViewPoolIncome = new DelegateCommand <WalletViewModel>((wallet) => {
         if (!string.IsNullOrEmpty(this.Url))
         {
             string url = this.Url;
             if (this.IsUserMode)
             {
                 url = url.Replace("{userName}", this.PoolProfileVm.UserName);
                 url = url.Replace("{worker}", NTMinerRoot.Current.MinerProfile.MinerName);
             }
             else
             {
                 url = url.Replace("{wallet}", wallet.Address);
                 url = url.Replace("{worker}", NTMinerRoot.Current.MinerProfile.MinerName);
             }
             Process.Start(url);
         }
     });
 }
コード例 #50
0
    private void RegeditAddAttachmentScript()
    {
        PageBase page = this.Page as PageBase;

        //弹出文件上传的窗体
        if (!page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "RegeditAddAttachmentScript"))
        {
            DialogWindow dw = new DialogWindow();
            dw.Url = UrlHelper.UrlBase + "/UploadFile/FileUpload.aspx";
            dw.AddUrlParameter("ApplicationId", Fn.ToString(ApplicationId));
            dw.AddUrlParameter("InstanceId", Fn.ToString(InstanceId));
            dw.AddUrlParameter("FolderId", Fn.ToString(FolderId));
            dw.AddUrlParameter("Version", Version);
            dw.AddUrlParameter("DeleteRight", DeleteRight.ToString());
            dw.AddUrlParameter("CheckDeleteProc", CheckDeleteProc);
            dw.Width = 700;
            dw.Height = 490;

            StringBuilder s = new StringBuilder();

            s.Append("function onAddAttachmentClick()");
            s.Append("{");
            s.Append("var returnValue = '';" + dw.GetShowModalDialogScript("returnValue"));
            s.Append("if(returnValue =='REFRESH'){return true;}");
            s.Append("window.event.cancelBubble = true;return false;");
            s.Append("}");

            page.ClientScript.RegisterClientScriptBlock(this.GetType(), "RegeditAddAttachmentScript", s.ToString(), true);
        }
    }
コード例 #51
0
        public SetupStepComPortOne(PrinterConfig printer)
        {
            this.WindowTitle = "Setup Wizard".Localize();

            var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                VAnchor = VAnchor.Stretch,
                Margin  = new BorderDouble(5),
                HAnchor = HAnchor.Stretch
            };

            BorderDouble elementMargin = new BorderDouble(top: 5);

            var printerMessageOne = new TextWidget("MatterControl will now attempt to auto-detect printer.".Localize(), 0, 0, 10)
            {
                TextColor = ActiveTheme.Instance.PrimaryTextColor,
                HAnchor   = HAnchor.Stretch,
                Margin    = elementMargin
            };

            container.AddChild(printerMessageOne);

            var printerMessageTwo = new TextWidget(string.Format("1.) {0} ({1}).", "Disconnect printer".Localize(), "if currently connected".Localize()), 0, 0, 12)
            {
                TextColor = ActiveTheme.Instance.PrimaryTextColor,
                HAnchor   = HAnchor.Stretch,
                Margin    = elementMargin
            };

            container.AddChild(printerMessageTwo);

            var printerMessageThree = new TextWidget(string.Format("2.) {0} '{1}'.", "Press".Localize(), "Continue".Localize()), 0, 0, 12)
            {
                TextColor = ActiveTheme.Instance.PrimaryTextColor,
                HAnchor   = HAnchor.Stretch,
                Margin    = elementMargin
            };

            container.AddChild(printerMessageThree);

            GuiWidget vSpacer = new GuiWidget();

            vSpacer.VAnchor = VAnchor.Stretch;
            container.AddChild(vSpacer);

            var setupManualConfigurationOrSkipConnectionWidget = new TextWidget("You can also".Localize() + ":", 0, 0, 10)
            {
                TextColor = ActiveTheme.Instance.PrimaryTextColor,
                HAnchor   = HAnchor.Stretch,
                Margin    = elementMargin
            };

            container.AddChild(setupManualConfigurationOrSkipConnectionWidget);

            Button manualLink = linkButtonFactory.Generate("Manually Configure Connection".Localize());

            manualLink.Margin = new BorderDouble(0, 5);
            manualLink.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                DialogWindow.ChangeToPage(new SetupStepComPortManual(printer));
            });
            container.AddChild(manualLink);

            var printerMessageFour = new TextWidget("or".Localize(), 0, 0, 10)
            {
                TextColor = ActiveTheme.Instance.PrimaryTextColor,
                HAnchor   = HAnchor.Stretch,
                Margin    = elementMargin
            };

            container.AddChild(printerMessageFour);

            Button skipConnectionLink = linkButtonFactory.Generate("Skip Connection Setup".Localize());

            skipConnectionLink.Margin = new BorderDouble(0, 8);
            skipConnectionLink.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                printer.Connection.HaltConnectionThread();
                Parent.Close();
            });
            container.AddChild(skipConnectionLink);

            contentRow.AddChild(container);

            //Construct buttons
            var nextButton = theme.CreateDialogButton("Continue".Localize());

            nextButton.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                DialogWindow.ChangeToPage(new SetupStepComPortTwo(printer));
            });

            this.AddPageAction(nextButton);
        }
コード例 #52
0
ファイル: CoinViewModel.cs プロジェクト: oyangjian/ntminer
        public CoinViewModel(Guid id)
        {
            _id = id;
            this.ApplyTemplateOverClock = new DelegateCommand <OverClockDataViewModel>((data) => {
                DialogWindow.ShowDialog(message: data.Tooltip, title: "确定应用该超频设置吗?", onYes: () => {
                    FillOverClock(data);
                    ApplyOverClock();
                }, icon: IconConst.IconConfirm);
            });
            this.ApplyCustomOverClock = new DelegateCommand(() => {
                DialogWindow.ShowDialog(message: $"确定应用您的自定义超频吗?", title: "确认自定义超频", onYes: () => {
                    ApplyOverClock();
                }, icon: IconConst.IconConfirm);
            });
            this.FillOverClockForm = new DelegateCommand <OverClockDataViewModel>((data) => {
                FillOverClock(data);
            });
            this.AddOverClockData = new DelegateCommand(() => {
                new OverClockDataViewModel(Guid.NewGuid())
                {
                    CoinId = this.Id
                }.Edit.Execute(FormType.Add);
            });
            this.Save = new DelegateCommand(() => {
                if (this.Id == Guid.Empty)
                {
                    return;
                }
                if (NTMinerRoot.Current.CoinSet.Contains(this.Id))
                {
                    VirtualRoot.Execute(new UpdateCoinCommand(this));
                }
                else
                {
                    VirtualRoot.Execute(new AddCoinCommand(this));
                }
                CloseWindow?.Invoke();
            });
            this.ViewCoinInfo = new DelegateCommand(() => {
                Process.Start("https://www.feixiaohao.com/currencies/" + this.EnName + "/");
            });
            this.Edit = new DelegateCommand <FormType?>((formType) => {
                if (this.Id == Guid.Empty)
                {
                    return;
                }
                CoinEdit.ShowWindow(formType ?? FormType.Edit, this);
            });
            this.Remove = new DelegateCommand(() => {
                if (this.Id == Guid.Empty)
                {
                    return;
                }
                DialogWindow.ShowDialog(message: $"您确定删除{this.Code}币种吗?", title: "确认", onYes: () => {
                    VirtualRoot.Execute(new RemoveCoinCommand(this.Id));
                }, icon: IconConst.IconConfirm);
            });
            this.SortUp = new DelegateCommand(() => {
                CoinViewModel upOne = CoinViewModels.Current.AllCoins.OrderByDescending(a => a.SortNumber).FirstOrDefault(a => a.SortNumber < this.SortNumber);
                if (upOne != null)
                {
                    int sortNumber   = upOne.SortNumber;
                    upOne.SortNumber = this.SortNumber;
                    VirtualRoot.Execute(new UpdateCoinCommand(upOne));
                    this.SortNumber = sortNumber;
                    VirtualRoot.Execute(new UpdateCoinCommand(this));
                    CoinPageViewModel.Current.OnPropertyChanged(nameof(CoinPageViewModel.List));
                    CoinViewModels.Current.OnPropertyChanged(nameof(CoinViewModels.MainCoins));
                    CoinViewModels.Current.OnPropertyChanged(nameof(CoinViewModels.AllCoins));
                }
            });
            this.SortDown = new DelegateCommand(() => {
                CoinViewModel nextOne = CoinViewModels.Current.AllCoins.OrderBy(a => a.SortNumber).FirstOrDefault(a => a.SortNumber > this.SortNumber);
                if (nextOne != null)
                {
                    int sortNumber     = nextOne.SortNumber;
                    nextOne.SortNumber = this.SortNumber;
                    VirtualRoot.Execute(new UpdateCoinCommand(nextOne));
                    this.SortNumber = sortNumber;
                    VirtualRoot.Execute(new UpdateCoinCommand(this));
                    CoinPageViewModel.Current.OnPropertyChanged(nameof(CoinPageViewModel.List));
                    CoinViewModels.Current.OnPropertyChanged(nameof(CoinViewModels.MainCoins));
                    CoinViewModels.Current.OnPropertyChanged(nameof(CoinViewModels.AllCoins));
                }
            });

            this.AddPool = new DelegateCommand(() => {
                int sortNumber = this.Pools.Count == 0 ? 1 : this.Pools.Max(a => a.SortNumber) + 1;
                new PoolViewModel(Guid.NewGuid())
                {
                    CoinId     = Id,
                    SortNumber = sortNumber
                }.Edit.Execute(FormType.Add);
            });
            this.AddWallet = new DelegateCommand(() => {
                int sortNumber = this.Wallets.Count == 0 ? 1 : this.Wallets.Max(a => a.SortNumber) + 1;
                new WalletViewModel(Guid.NewGuid())
                {
                    CoinId     = Id,
                    SortNumber = sortNumber
                }.Edit.Execute(FormType.Add);
            });
            this.AddCoinKernel = new DelegateCommand(() => {
                KernelSelect.ShowWindow(this);
            });
        }
コード例 #53
0
 public BaseDialogUserControl()
 {
     _dialogWindow           = new DialogWindow();
     _dialogWindow.ViewModel = new DialogViewModel(_dialogWindow);
 }