コード例 #1
0
        public void SetEditWorkspaceMode(bool enable, RobotWorkspace workspace, MovableValueTypes editValues)
        {
            gbWorkspaceInfo.Text = "Рабочая зона: " + (enable ? workspace.Name : "");
            IsEditWorkspaceMode  = enable;

            lstWorkspaces.Enabled = !enable;

            var hasNotNoneFlag = !editValues.HasFlag(MovableValueTypes.None);

            setMaxValueMI.Visible(hasNotNoneFlag && editValues.HasFlag(MovableValueTypes.Max));
            setMinValueMI.Visible(hasNotNoneFlag && editValues.HasFlag(MovableValueTypes.Min));
            setZeroValueMI.Visible(hasNotNoneFlag && editValues.HasFlag(MovableValueTypes.Zero));
            removeZeroValueMI.Visible(editValues.HasFlag(MovableValueTypes.Zero));
            editValuesSeparatorMI.Visible = hasNotNoneFlag;

            setAsActiveWorkspaceMI.Visible(!enable);
            editWorkspaceValuesMI.Visible(!enable);

            editWorkspaceSeparatorMI.Visible = !enable;
            removeWorkspaceMI.Visible(!enable);
            addWorkspaceMI.Visible(!enable);
            renameWorkspace.Visible(!enable);

            saveWorkspaceValuesMI.Visible(enable);
            closeEditWorkspaceModeMI.Visible(enable);
        }
コード例 #2
0
 // Отменить изменения.
 private void View_InvokeCloseEditWorkspaceMode(object sender, WorkspaceEventArgs e)
 {
     view.SetEditWorkspaceMode(false, null, MovableValueTypes.None);
     view.SetWorkspaces(workspaceManager.RobotWorkspaces, editingWorkspaceIndex);
     editingWorkspace      = null;
     editingWorkspaceIndex = -1;
     return;
 }
コード例 #3
0
        public void SetRobotWorkspaceParams(RobotWorkspace workspace)
        {
            if (workspace == null)
            {
                return;
            }

            this.Invoke(new Action(() =>
            {
                var lever = workspace.GetLeverByType(GetEditWorkspaceModeActiveLever());

                lblWorkspaceABmax.Text  = lever.ABmax.ToString();
                lblWorkspaceABmin.Text  = lever.ABmin.ToString();
                lblWorkspaceABZero.Text = lever.ABzero.ToString();
            }));
        }
コード例 #4
0
        // Сохранить изменения.
        private void View_InvokeSaveWorkspaceValues(object sender, WorkspaceEventArgs e)
        {
            if (!view.IsEditWorkspaceMode || editingWorkspace == null)
            {
                return;
            }

            try
            {
                var errors = editingWorkspace.GetDesignParametersExceptions(this.parameters);

                if (editingWorkspaceIndex == 0)
                {
                    this.movement.DesignParameters.Lever1.ABzero          = editingWorkspace.Lever1.ABzero;
                    this.movement.DesignParameters.Lever2.ABzero          = editingWorkspace.Lever2.ABzero;
                    this.movement.DesignParameters.HorizontalLever.ABzero = editingWorkspace.HorizontalLever.ABzero;

                    UpdateDesignParameters(this.movement.DesignParameters);
                }

                if (errors.Count() == 0)
                {
                    view.SetEditWorkspaceMode(false, null, MovableValueTypes.None);

                    workspaceManager.SetWorkspace(editingWorkspaceIndex, editingWorkspace);

                    view.SetWorkspaces(workspaceManager.RobotWorkspaces, editingWorkspaceIndex);
                    editingWorkspace      = null;
                    editingWorkspaceIndex = -1;
                    return;
                }

                string errorMessage = "Рабочая зона не сохранена. Ошибки:";

                foreach (var error in errors)
                {
                    errorMessage += string.Format("\n\n{0} : {1}", (error.Key), error.Value.Message);
                }

                throw new Exception(errorMessage);
            }
            catch (Exception ex)
            {
                messageService.ShowError(ex.Message);
            }
        }
コード例 #5
0
        // Установить режим редактирования рабочей зоны.
        private void View_InvokeSetEditWorkspaceMode(object sender, WorkspaceEventArgs e)
        {
            try
            {
                workspaceManager.SetDefaultWorkspace();

                editingWorkspace = workspaceManager.GetClone(e.Index);

                var editValues = MovableValueTypes.Zero;

                if (e.Index != 0)
                {
                    editValues |= MovableValueTypes.Max | MovableValueTypes.Min;
                }

                editingWorkspaceIndex = e.Index;

                view.SetEditWorkspaceMode(true, editingWorkspace, editValues);
            }
            catch (Exception ex)
            {
                messageService.ShowError(ex.Message);
            }
        }
コード例 #6
0
 public void SetCurrentWorkspace(RobotWorkspace workspace)
 {
     statusLblWorkspace.Text = workspace.Name;
 }
コード例 #7
0
 private void SaveActiveRobotWorkspace(RobotWorkspace workspace)
 {
     Properties.Settings.Default.ActiveWorkspaceIndex = workspaceManager.ActiveWorkspaceIndex;
     Properties.Settings.Default.Save();
 }