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); }
// Отменить изменения. private void View_InvokeCloseEditWorkspaceMode(object sender, WorkspaceEventArgs e) { view.SetEditWorkspaceMode(false, null, MovableValueTypes.None); view.SetWorkspaces(workspaceManager.RobotWorkspaces, editingWorkspaceIndex); editingWorkspace = null; editingWorkspaceIndex = -1; return; }
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(); })); }
// Сохранить изменения. 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); } }
// Установить режим редактирования рабочей зоны. 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); } }
public void SetCurrentWorkspace(RobotWorkspace workspace) { statusLblWorkspace.Text = workspace.Name; }
private void SaveActiveRobotWorkspace(RobotWorkspace workspace) { Properties.Settings.Default.ActiveWorkspaceIndex = workspaceManager.ActiveWorkspaceIndex; Properties.Settings.Default.Save(); }