Exemple #1
0
        private void GameCompleteStatus(bool status, String message)
        {
            if (status)
            {
                for (int i = 0; i < modelLevel.Levels.Count(); i++)
                {
                    if (modelLevel.Levels[i].Equals(modelLevel.CurrentLevel))
                    {
                        if (i + 1 >= modelLevel.Levels.Count())
                        {
                            status = false;
                        }
                        else
                        {
                            nextMap = modelLevel.Levels[i + 1];
                            status  = true;
                        }
                        break;
                    }
                }
            }
            modelLevel.inGame = false;
            StatusDialog failedDialog = new StatusDialog(status, message, new NextLevel(nextLevel), new RetryLevel(retry), new PreviousLevel(retry));

            failedDialog.Owner = this;
            failedDialog.ShowDialog();
        }
            // on correct thread
            private void Run()
            {
                //

                try {
                    lock (this) {
                        if (alreadyStopped)
                        {
                            return;
                        }

                        dialog = new StatusDialog(this, parent.dialogTitle);
                        ThreadUnsafeUpdateLabel();
                        dialog.Visible = true;
                    }

                    if (!alreadyStopped)
                    {
                        Application.Run(dialog);
                    }
                }
                finally {
                    lock (this) {
                        if (dialog != null)
                        {
                            dialog.Dispose();
                            dialog = null;
                        }
                    }
                }
            }
            private void Run()
            {
                //

                try
                {
                    lock (this)
                    {
                        if (_alreadyStopped)
                        {
                            return;
                        }

                        _dialog = new StatusDialog(this, _parent._dialogTitle);
                        ThreadUnsafeUpdateLabel();
                        _dialog.Visible = true;
                    }

                    if (!_alreadyStopped)
                    {
                        Application.Run(_dialog);
                    }
                }
                finally
                {
                    lock (this)
                    {
                        if (_dialog is not null)
                        {
                            _dialog.Dispose();
                            _dialog = null;
                        }
                    }
                }
            }
            private void Run()
            {
                // SECREVIEW : need all permissions to make the window not get adorned...
                //
                try {
                    lock (this) {
                        if (alreadyStopped)
                        {
                            return;
                        }

                        dialog = new StatusDialog(this, parent.dialogTitle);
                        ThreadUnsafeUpdateLabel();
                        dialog.Visible = true;
                    }

                    if (!alreadyStopped)
                    {
                        Application.Run(dialog);
                    }
                }
                finally {
                    lock (this) {
                        if (dialog != null)
                        {
                            dialog.Dispose();
                            dialog = null;
                        }
                    }
                }
            }
Exemple #5
0
        public StatusDialog UpdateApplication(EventWaitHandle asyncHandle)
        {
            var feedManager = new FeedManager(this.publicKey);
            var newVersions = feedManager.GetNewVersions(feedUrl, this.context.ApplicationVersion);

            if (dialog == null)
            {
                this.dialog          = new StatusDialog();
                this.dialog.AppTitle = this.context.ApplicationTitle;

                this.dialogAdapter = new StatusDialogAdapter(dialog);
            }

            worker = new UpdateWorker(
                () =>
            {
                var downloadManager = new DownloadManager(this.context, dialogAdapter);
                var files           = downloadManager.DownloadFiles(newVersions);

                var installer = new InstallationManager(this.context, new TraceLogger());
                foreach (var file in files.OrderBy(f => f.Key))
                {
                    installer.Install(file.Value, file.Key);
                }
            });

            worker.WorkCompleted += (object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
                                    =>
            {
                if (dialog != null)
                {
                    dialog.Close();
                    dialog.Dispose();

                    dialogAdapter = null;
                    dialog        = null;
                }

                if (asyncHandle != null)
                {
                    asyncHandle.Set();
                }
            };

            worker.Start();

            return(this.dialog);
        }
Exemple #6
0
        /// <summary>
        /// set active status
        /// </summary>
        private void toolbarStatus_Click(object sender, EventArgs e)
        {
            EntityStatus oldStatus = _param.Status;
            //show dialog
            StatusDialog status = new StatusDialog(_param);

            status.ShowDialog();

            if (_param.Status != oldStatus)
            {
                //set page control status according to status
                if (_param.Status == EntityStatus.Active || _param.Status == EntityStatus.Archive)
                {
                    CtrlState = ControlState.ReadOnly;
                }
            }
        }
Exemple #7
0
        private void tsbStatus_Click(object sender, EventArgs e)
        {
            EntityStatus oldStatus = _computerEntity.Status;
            StatusDialog status    = new StatusDialog(_computerEntity);

            status.ShowDialog();
            if (oldStatus != _computerEntity.Status)
            {
                if (_computerEntity.Status == EntityStatus.Active)
                {
                    State = ControlState.Read;
                }
                if (_computerEntity.Status == EntityStatus.Archive)
                {
                    State = ControlState.ReadOnly;
                }
            }
        }
Exemple #8
0
        private void toolbarStatus_Click(object sender, EventArgs e)
        {
            EntityStatus oldStatus = _part.Status;
            StatusDialog status    = new StatusDialog(_part);

            status.ShowDialog();
            if (oldStatus != _part.Status)
            {
                if (_part.Status == EntityStatus.Active)
                {
                    State = ControlState.Edit;
                }
                if (_part.Status == EntityStatus.Archive)
                {
                    State = ControlState.ReadOnly;
                }
            }
        }
Exemple #9
0
        public void RestartListeners()
        {
            if (listeners == null)
            {
                return;
            }
            StatusDialog d = new StatusDialog();

            new Thread(delegate()
            {
                d.SetStatus("Restarting listeners...");
                EventLogger.LogEvent("Restarting", "Listeners are restarting");
                foreach (Listener l in listeners)
                {
                    l.Stop();
                }

                listeners.Clear();

                for (int i = 0; i < Settings.Ports.Count; i++)
                {
                    Listener l = new Listener();
                    int port   = Settings.Ports[i];
                    if (l.Listen(port))
                    {
                        l.SocketAccepted += listener_SocketAccepted;
                        EventLogger.LogEvent("Listening", "Successfully listening on port " + port.ToString());
                    }
                    else
                    {
                        EventLogger.LogEvent("Listening Failed", "Unable to listen on port " + port.ToString());
                    }
                    if (l.Running)
                    {
                        listeners.Add(l);
                    }
                }
                Invoke((MethodInvoker) delegate
                {
                    d.Close();
                });
            }).Start();
            d.ShowDialog();
        }
Exemple #10
0
        /// <summary>
        /// 状态按钮事件。
        /// </summary>
        private void toolbarStatus_Click(object sender, EventArgs e)
        {
            EntityStatus oldStatus = _operation.Status;
            StatusDialog status    = new StatusDialog(_operation);

            status.ShowDialog();

            if (_operation.Status != oldStatus)
            {
                if (_operation.Status == EntityStatus.Active)
                {
                    CtrlState = ControlState.Read;
                }
                if (_operation.Status == EntityStatus.Archive)
                {
                    CtrlState = ControlState.ReadOnly;
                }
            }
        }
Exemple #11
0
        public static bool?Show(DialogType type, OptionType option, string header, string message)
        {
            dialog       = new StatusDialog();
            dialog.Owner = Core.win.mainWindow;

            switch (type)
            {
            case DialogType.QUESTION:
                dialog.iconBox.Child = (XamlReader.Parse(Properties.Resources.question) as Canvas);
                break;

            case DialogType.WARNING:
                dialog.iconBox.Child = (XamlReader.Parse(Properties.Resources.warning) as Canvas);
                break;

            case DialogType.ERROR:
                dialog.iconBox.Child = (XamlReader.Parse(Properties.Resources.error) as Canvas);
                break;
            }

            switch (option)
            {
            case OptionType.YESNO:
                dialog.okButton.Content     = "YES";
                dialog.cancelButton.Content = "NO";
                break;

            case OptionType.OKCANCEL:
                dialog.okButton.Content     = "OK";
                dialog.cancelButton.Content = "CANCEL";
                break;
            }

            dialog.statusWindow.Title = header;
            dialog.textBlock.Text     = message;
            return(dialog.ShowDialog());
        }
            private void Run() {
                // SECREVIEW : need all permissions to make the window not get adorned...
                //
                try {
                    lock (this) {
                        if (alreadyStopped) {
                            return;
                        }

                        dialog = new StatusDialog(this, parent.dialogTitle);
                        ThreadUnsafeUpdateLabel();
                        dialog.Visible = true;
                    }

                    if (!alreadyStopped) {
                        Application.Run(dialog);
                    }
                }
                finally {
                    lock (this) {
                        if (dialog != null) {
                            dialog.Dispose();
                            dialog = null;
                        }
                    }
                }
            }
 public StatusDialogAdapter(StatusDialog dialog)
 {
     this.dialog = dialog;
 }
Exemple #14
0
        /// <summary>
        /// 状态按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolbarStatus_Click(object sender, EventArgs e)
        {
            if (this.gvEDCPoint.State == GridState.Editing && this.gvEDCPoint.IsEditorFocused &&
                this.gvEDCPoint.EditingValueModified)
            {
                this.gvEDCPoint.SetFocusedRowCellValue(this.gvEDCPoint.FocusedColumn, this.gvEDCPoint.EditingValue);
            }
            if (string.IsNullOrEmpty(edcPoint.PointRowKey))
            {
                return;
            }
            for (int i = 0; i < gvEDCPoint.RowCount; i++)
            {
                string upperBoundary = gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_UPPER_BOUNDARY).ToString().Trim();
                string lowerBoundary = gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_LOWER_BOUNDARY).ToString().Trim();
                string paramCount    = gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_COUNT).ToString().Trim();
                string paramType     = gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_TYPE).ToString().Trim();
                string paramIndex    = gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_INDEX).ToString().Trim();
                if (upperBoundary.Length == 0)
                {
                    MessageService.ShowMessage("参数上线值不能为空", "提示");
                    this.gvEDCPoint.FocusedRowHandle = i;
                    this.gvEDCPoint.FocusedColumn    = this.gvEDCPoint.Columns[EDC_POINT_PARAMS_FIELDS.FIELD_UPPER_BOUNDARY];
                    return;
                }
                if (lowerBoundary.Length == 0)
                {
                    MessageService.ShowMessage("参数下线值不能为空", "提示");
                    this.gvEDCPoint.FocusedRowHandle = i;
                    this.gvEDCPoint.FocusedColumn    = this.gvEDCPoint.Columns[EDC_POINT_PARAMS_FIELDS.FIELD_LOWER_BOUNDARY];
                    return;
                }
                if (paramCount.Length == 0)
                {
                    MessageService.ShowMessage("抽检片数不能为空", "提示");
                    this.gvEDCPoint.FocusedRowHandle = i;
                    this.gvEDCPoint.FocusedColumn    = this.gvEDCPoint.Columns[EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_COUNT];
                    return;
                }
                if (paramType.Length == 0)
                {
                    MessageService.ShowMessage("参数类型不能为空", "提示");
                    this.gvEDCPoint.FocusedRowHandle = i;
                    this.gvEDCPoint.FocusedColumn    = this.gvEDCPoint.Columns[EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_TYPE];
                    return;
                }
                if (paramIndex.Length == 0)
                {
                    MessageService.ShowMessage("序号不能为空", "提示");
                    this.gvEDCPoint.FocusedRowHandle = i;
                    this.gvEDCPoint.FocusedColumn    = this.gvEDCPoint.Columns[EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_INDEX];
                    return;
                }
            }

            EntityObject pointObject = new EntityObject();

            if (CtrlState == ControlState.New)
            {
                pointObject.Status = EntityStatus.InActive;
            }
            if (CtrlState == ControlState.Edit)
            {
                string pointState = edcPoint.PointState;
                switch (pointState)
                {
                case "0":
                    pointObject.Status = EntityStatus.InActive;
                    break;

                case "1":
                    pointObject.Status = EntityStatus.Active;
                    break;

                case "2":
                    pointObject.Status = EntityStatus.Archive;
                    break;

                default:
                    pointObject.Status = EntityStatus.InActive;
                    break;
                }
            }
            EntityStatus oldStatus = pointObject.Status;
            StatusDialog status    = new StatusDialog(pointObject);

            status.ShowDialog();


            if (pointObject.Status != oldStatus)
            {
                string newPointStatus = string.Empty;
                newPointStatus = (Convert.ToInt32(pointObject.Status)).ToString();

                if (newPointStatus != "1")
                {
                    if (edcPoint.UpdateEDCPointStatus(edcPoint.GroupKey, newPointStatus))
                    {
                        edcPoint.PointState = newPointStatus;
                        MessageService.ShowMessage("状态修改成功", "提示");
                    }
                    else
                    {
                        MessageService.ShowError("状态修改失败");
                    }
                }
                else
                {
                    DataSet dsReturn = new DataSet();
                    bool    bExist   = edcPoint.FindExistUsedEDCPoint(edcPoint.GroupKey);
                    if (bExist)
                    {
                        MessageService.ShowError("存在可用的抽检设置,状态修改失败。");
                        return;
                    }
                    else
                    {
                        if (edcPoint.UpdateEDCPointStatus(edcPoint.GroupKey, newPointStatus))
                        {
                            edcPoint.PointState = newPointStatus;
                            MessageService.ShowMessage("状态修改成功", "提示");
                        }
                        else
                        {
                            MessageService.ShowError("状态修改失败");
                        }
                    }
                }
                if (edcPoint.PointState == "1")
                {
                    this.toolbarDelete.Enabled = false;
                }
            }
        }
Exemple #15
0
        void listen()
        {
            if (listeners == null)
            {
                listeners = new List <Listener>();
                Clients   = new List <Client>();
                foreach (int port in Settings.Ports)
                {
                    Listener l = new Listener();
                    if (l.Listen(port))
                    {
                        l.SocketAccepted += listener_SocketAccepted;
                        EventLogger.LogEvent("Listening", "Successfully listening on port " + port.ToString());
                    }
                    else
                    {
                        EventLogger.LogEvent("Listening Failed", "Unable to listen on port " + port.ToString());
                    }
                    if (l.Running)
                    {
                        listeners.Add(l);
                    }
                }

                EventLogger.LogEvent("Started", "Net-Weave R has been started");

                startToolStripMenuItem.Text = startToolStripMenuItem.Text.Replace("Listen", "Stop");
                Pinger.Start(ref Clients);
            }
            else
            {
                Pinger.Stop();
                StatusDialog d = new StatusDialog();
                d.SetStatus("Stopping Listeners...");
                new Thread(delegate()
                {
                    foreach (Listener l in listeners)
                    {
                        if (l.Running)
                        {
                            l.SocketAccepted -= listener_SocketAccepted;
                            l.Stop();
                            EventLogger.LogEvent("Listening Stopped", "The listener for port " + l.Port + " has been stopped");
                        }
                    }
                    Restart();
                    d.SetStatus("Disconnecting Clients...");
                    if (Clients.Count > 0)
                    {
                        for (int i = 0; i < Clients.Count; i++)
                        {
                            Clients[i].DataReceived -= client_DataReceived;
                            Clients[i].DataSent     -= client_DataSent;
                            Clients[i].Disconnected -= client_Disconnected;
                            Clients[i].Close();
                        }
                    }
                    listeners.Clear();
                    listeners = null;
                    Clients.Clear();
                    Clients = null;
                    Invoke((MethodInvoker) delegate
                    {
                        EventLogger.LogEvent("Stopped", "Net-Weave R has been stopped");
                        startToolStripMenuItem.Text = startToolStripMenuItem.Text.Replace("Stop", "Listen");

                        lstClients.Items.Clear();
                        d.Close();
                    });
                }).Start();
                d.ShowDialog();
            }
        }