コード例 #1
0
        /// <summary>
        /// Generates the code.
        /// </summary>
        /// <param name="behavior">The behavior.</param>
        private void GenerateCode(InformationBoxBehavior behavior, Language language)
        {
            InformationBoxButtons buttons             = this.GetButtons();
            InformationBoxIcon    icon                = this.GetIcon();
            string iconFileName                       = this.txbIcon.Text;
            InformationBoxDefaultButton defaultButton = this.GetDefaultButton();
            InformationBoxButtonsLayout buttonsLayout = this.GetButtonsLayout();
            InformationBoxAutoSizeMode  autoSize      = this.GetAutoSize();
            InformationBoxPosition      position      = this.GetPosition();
            HelpNavigator                navigator    = this.GetHelpNavigator();
            InformationBoxCheckBox       checkState   = this.GetCheckBoxState();
            InformationBoxStyle          style        = this.GetStyle();
            AutoCloseParameters          autoClose    = this.GetAutoClose();
            DesignParameters             design       = this.GetDesign();
            InformationBoxTitleIconStyle titleStyle   = this.GetTitleStyle();
            InformationBoxOpacity        opacity      = this.GetOpacity();
            InformationBoxOrder          order        = this.GetOrder();

            ICodeGeneratorFactory factory = new CodeGeneratorFactory();
            ICodeGenerator        codeGen = factory.CreateGenerator(language);

            String generatedCode = codeGen.GenerateSingleCall(
                behavior, this.txbText.Text, this.txbTitle.Text, buttons, this.txbUser1.Text, this.txbUser2.Text,
                icon, iconFileName, defaultButton, buttonsLayout, autoSize, position, this.chbHelpButton.Checked,
                this.txbHelpFile.Text, this.txbHelpTopic.Text, navigator, checkState, style, this.chbActivateAutoClose.Checked,
                autoClose, design, titleStyle, this.txbTitleIconFile.Text, opacity, order);

            this.txbCode.Text = generatedCode;
        }
コード例 #2
0
        private void UpdateDesignParameters(DesignParameters designParameters)
        {
            var settings = new JsonSerializerSettings()
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            };

            File.WriteAllText("design.settings", JsonConvert.SerializeObject(designParameters, settings));

            if (parameters == designParameters)
            {
                return;
            }

            parameters.HorizontalLever = designParameters.HorizontalLever;
            parameters.L1     = designParameters.L1;
            parameters.L2     = designParameters.L2;
            parameters.Lc     = designParameters.Lc;
            parameters.Lever1 = designParameters.Lever1;
            parameters.Lever2 = designParameters.Lever2;

            GetSavedCurrentPositionFromDesignParameters(designParameters);

            workspaceManager.DesignParametersWorkspace = workspaceManager.RobotWorkspaces.First();

            view.SetWorkspaces(workspaceManager.RobotWorkspaces, workspaceManager.ActiveWorkspace != null ? workspaceManager.RobotWorkspaces.IndexOf(workspaceManager.ActiveWorkspace) : 0);
            SetCurrentPositionOnView();
            view.SetZeroPositionState(movement.IsOnZeroPosition(LeverType.Horizontal), movement.IsOnZeroPosition(LeverType.Lever1) && movement.IsOnZeroPosition(LeverType.Lever2));

            movement.UpdateLocation();
        }
コード例 #3
0
        /// <summary>
        /// Предоставляет класс для управления рабочими зонами робота-манипулятора.
        /// </summary>
        /// <param name="parameters">Конструкртивные параметры робота</param>
        /// <param name="robotWorkspaces">Рабочие зоны робота</param>
        /// <param name="activeWorkspaceIndex">Индекс активной рабочей зоны</param>
        public WorkspaceManager(DesignParameters parameters, List <RobotWorkspace> robotWorkspaces, int activeWorkspaceIndex = 0)
        {
            this.parameters = parameters;

            Add(GetDesignParametersWorkspace("Конструктивные параметры"));
            this.robotWorkspaces.AddRange(robotWorkspaces);

            ActiveWorkspace = this.robotWorkspaces[activeWorkspaceIndex];
        }
コード例 #4
0
        /// <summary>
        /// Shows the box.
        /// </summary>
        /// <param name="behavior">The behavior.</param>
        private void ShowBox(InformationBoxBehavior behavior)
        {
            InformationBoxButtons buttons             = this.GetButtons();
            InformationBoxIcon    icon                = this.GetIcon();
            string iconFileName                       = this.txbIcon.Text;
            InformationBoxDefaultButton defaultButton = this.GetDefaultButton();
            InformationBoxButtonsLayout buttonsLayout = this.GetButtonsLayout();
            InformationBoxAutoSizeMode  autoSize      = this.GetAutoSize();
            InformationBoxPosition      position      = this.GetPosition();
            HelpNavigator                navigator    = this.GetHelpNavigator();
            InformationBoxCheckBox       checkState   = this.GetCheckBoxState();
            CheckState                   state        = 0;
            InformationBoxStyle          style        = this.GetStyle();
            AutoCloseParameters          autoClose    = this.GetAutoClose();
            DesignParameters             design       = this.GetDesign();
            InformationBoxTitleIconStyle titleStyle   = this.GetTitleStyle();
            InformationBoxOpacity        opacity      = this.GetOpacity();
            InformationBoxOrder          order        = this.GetOrder();
            InformationBoxSound          sound        = this.GetSound();

            InformationBoxTitleIcon titleIcon = null;

            if (titleStyle == InformationBoxTitleIconStyle.Custom)
            {
                titleIcon = new InformationBoxTitleIcon(this.txbTitleIconFile.Text);
            }

            if (String.IsNullOrEmpty(iconFileName))
            {
                InformationBox.Show(this.txbText.Text, out state, this.txbTitle.Text, buttons, new string[] { this.txbUser1.Text, this.txbUser2.Text, this.txbUser3.Text }, icon, defaultButton, buttonsLayout, autoSize, position, this.chbHelpButton.Checked, this.txbHelpFile.Text, navigator, this.txbHelpTopic.Text, checkState, style, autoClose, design, titleStyle, titleIcon, behavior, new AsyncResultCallback(BoxClosed), opacity, order, sound);
            }
            else
            {
                InformationBox.Show(this.txbText.Text, out state, this.txbTitle.Text, buttons, new string[] { this.txbUser1.Text, this.txbUser2.Text, this.txbUser3.Text }, new Icon(iconFileName), defaultButton, buttonsLayout, autoSize, position, this.chbHelpButton.Checked, this.txbHelpFile.Text, navigator, this.txbHelpTopic.Text, checkState, style, autoClose, design, titleStyle, titleIcon, behavior, new AsyncResultCallback(BoxClosed), opacity, order, sound);
            }

            if (checkState != 0)
            {
                InformationBox.Show(
                    String.Format(CultureInfo.InvariantCulture, "The state of the checkbox was {0}", state),
                    InformationBoxIcon.Information);
            }
        }
コード例 #5
0
        private IEnumerable <Item> GetGeneralItems(DesignParameters parameters)
        {
            yield return(new Item(parameters.L1)
            {
                Name = "Длина плеча 1, мм.",
                Type = ValueType.L1,
                Sign = "L1"
            });

            yield return(new Item(parameters.L2)
            {
                Name = "Длина плеча 2, мм.",
                Type = ValueType.L2,
                Sign = "L2"
            });

            yield return(new Item(parameters.Lc)
            {
                Name = "Расстояние от центра схвата до точки его подвеса на плече 2, мм.",
                Type = ValueType.Lc,
                Sign = "Lc"
            });
        }
コード例 #6
0
        /// <summary>
        /// Displays a message box with the specified text and parameters.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="checkBoxState">The final value of the "Do not show this dialog again" checkbox.</param>
        /// <param name="title">The title.</param>
        /// <param name="helpFile">The help file.</param>
        /// <param name="helpTopic">The help topic.</param>
        /// <param name="initialization">The initialization.</param>
        /// <param name="buttons">The buttons.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="customIcon">The custom icon.</param>
        /// <param name="defaultButton">The default button.</param>
        /// <param name="customButtons">The custom buttons.</param>
        /// <param name="buttonsLayout">The buttons layout.</param>
        /// <param name="autoSizeMode">The auto size mode.</param>
        /// <param name="position">The position.</param>
        /// <param name="showHelpButton">if set to <c>true</c> shows help button.</param>
        /// <param name="helpNavigator">The help navigator.</param>
        /// <param name="showDoNotShowAgainCheckBox">if set to <c>true</c> shows the do not show again check box.</param>
        /// <param name="style">The style.</param>
        /// <param name="autoClose">The auto close configuration.</param>
        /// <param name="design">The design.</param>
        /// <param name="titleStyle">The title style.</param>
        /// <param name="titleIcon">The title icon.</param>
        /// <param name="legacyButtons">The legacy buttons.</param>
        /// <param name="legacyIcon">The legacy icon.</param>
        /// <param name="legacyDefaultButton">The legacy default button.</param>
        /// <param name="behavior">The behavior.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="opacity">The opacity.</param>
        /// <param name="parent">The parent form.</param>
        /// <param name="order">The z-order</param>
        /// <returns>
        /// One of the <see cref="InformationBoxResult"/> values.
        /// </returns>
        public static InformationBoxResult Show(string text,
                                                out CheckState checkBoxState,
                                                string title     = "",
                                                string helpFile  = "",
                                                string helpTopic = "",
                                                InformationBoxInitialization initialization = InformationBoxInitialization.FromScopeAndParameters,
                                                InformationBoxButtons buttons = InformationBoxButtons.OK,
                                                InformationBoxIcon icon       = InformationBoxIcon.None,
                                                Icon customIcon = null,
                                                InformationBoxDefaultButton defaultButton = InformationBoxDefaultButton.Button1,
                                                string[] customButtons = null,
                                                InformationBoxButtonsLayout buttonsLayout = InformationBoxButtonsLayout.GroupMiddle,
                                                InformationBoxAutoSizeMode autoSizeMode   = InformationBoxAutoSizeMode.None,
                                                InformationBoxPosition position           = InformationBoxPosition.CenterOnParent,
                                                bool showHelpButton         = false,
                                                HelpNavigator helpNavigator = HelpNavigator.TableOfContents,
                                                InformationBoxCheckBox showDoNotShowAgainCheckBox = 0,
                                                InformationBoxStyle style                   = InformationBoxStyle.Standard,
                                                AutoCloseParameters autoClose               = null,
                                                DesignParameters design                     = null,
                                                InformationBoxTitleIconStyle titleStyle     = InformationBoxTitleIconStyle.None,
                                                InformationBoxTitleIcon titleIcon           = null,
                                                MessageBoxButtons?legacyButtons             = null,
                                                MessageBoxIcon?legacyIcon                   = null,
                                                MessageBoxDefaultButton?legacyDefaultButton = null,
                                                InformationBoxBehavior behavior             = InformationBoxBehavior.Modal,
                                                AsyncResultCallback callback                = null,
                                                InformationBoxOpacity opacity               = InformationBoxOpacity.NoFade,
                                                Form parent = null,
                                                InformationBoxOrder order = InformationBoxOrder.Default)
        {
            var parameters = new object[] { title, helpFile, helpTopic, initialization, buttons, icon, customIcon, defaultButton,
                                            customButtons, buttonsLayout, autoSizeMode, position, showHelpButton, helpNavigator, showDoNotShowAgainCheckBox,
                                            style, autoClose, design, titleStyle, titleIcon, legacyButtons, legacyIcon, legacyDefaultButton, behavior, callback, opacity, parent, order };

            return(new InformationBoxStandardForm(text, parameters).Show(out checkBoxState));
        }
コード例 #7
0
 public PiecewiseLinearSpendingFunction(DesignParameters designParameters, SpendingFunctionBounds bounds)
     : base(designParameters, bounds)
 {
 }
コード例 #8
0
 /// <summary>
 /// Удаляет рабочие зоны из конструктивных параметров робота, тем самым задает рабочую зону по умолчанию.
 /// </summary>
 /// <param name="parameters">Уонструктивные параметры робота</param>
 public static void RemoveWorkspacesFromDesignParameters(DesignParameters parameters)
 {
     parameters.Lever1.Workspace          = null;
     parameters.Lever2.Workspace          = null;
     parameters.HorizontalLever.Workspace = null;
 }
コード例 #9
0
 protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options)
 {
     base.setJSON(obj, host, options);
     obj["GeometricParameters"] = DesignParameters.getJson(this, options);
 }
        /// <summary>
        /// Merges the specified parameters.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns>The result of the merge operation </returns>
        public InformationBoxScopeParameters Merge(InformationBoxScopeParameters parameters)
        {
            if (parameters.Icon.HasValue && !this.Icon.HasValue)
            {
                this.icon = parameters.Icon.Value;
            }

            if (parameters.CustomIcon != null && null == this.CustomIcon)
            {
                this.customIcon = parameters.CustomIcon;
            }

            if (parameters.Buttons.HasValue && !this.Buttons.HasValue)
            {
                this.buttons = parameters.Buttons.Value;
            }

            if (parameters.DefaultButton.HasValue && !this.DefaultButton.HasValue)
            {
                this.defaultButton = parameters.DefaultButton.Value;
            }

            if (parameters.Layout.HasValue && !this.Layout.HasValue)
            {
                this.layout = parameters.Layout.Value;
            }

            if (parameters.AutoSizeMode.HasValue && !this.AutoSizeMode.HasValue)
            {
                this.autoSizeMode = parameters.AutoSizeMode.Value;
            }

            if (parameters.Position.HasValue && !this.Position.HasValue)
            {
                this.position = parameters.Position.Value;
            }

            if (parameters.CheckBox.HasValue && !this.CheckBox.HasValue)
            {
                this.checkbox = parameters.CheckBox.Value;
            }

            if (parameters.Style.HasValue && !this.Style.HasValue)
            {
                this.style = parameters.Style.Value;
            }

            if (parameters.AutoClose != null && null == this.AutoClose)
            {
                this.autoClose = parameters.AutoClose;
            }

            if (parameters.Design != null && null == this.Design)
            {
                this.design = parameters.Design;
            }

            if (parameters.TitleIconStyle.HasValue && !this.TitleIconStyle.HasValue)
            {
                this.titleIconStyle = parameters.TitleIconStyle.Value;
            }

            if (parameters.TitleIcon != null && null == this.TitleIcon)
            {
                this.titleIcon = parameters.TitleIcon;
            }

            if (parameters.Behavior.HasValue && !this.Behavior.HasValue)
            {
                this.behavior = parameters.Behavior.Value;
            }

            if (parameters.Opacity.HasValue && !this.Opacity.HasValue)
            {
                this.opacity = parameters.Opacity.Value;
            }

            if (parameters.Help.HasValue && !this.Help.HasValue)
            {
                this.help = parameters.Help.Value;
            }

            if (parameters.HelpNavigator.HasValue && !this.HelpNavigator.HasValue)
            {
                this.helpNavigator = parameters.HelpNavigator.Value;
            }

            if (parameters.Order.HasValue && !this.Order.HasValue)
            {
                this.order = parameters.Order.Value;
            }

            return(this);
        }
コード例 #11
0
 private void GetSavedCurrentPositionFromDesignParameters(DesignParameters parameters)
 {
     currentPositionLoader.SaveCurrentPosition(LeverType.Horizontal, parameters.HorizontalLever.AB);
     currentPositionLoader.SaveCurrentPosition(LeverType.Lever1, parameters.Lever1.AB);
     currentPositionLoader.SaveCurrentPosition(LeverType.Lever2, parameters.Lever2.AB);
 }
コード例 #12
0
 private void SetSavedCurrentPositionToDesignParameters(DesignParameters parameters)
 {
     parameters.HorizontalLever.AB = currentPositionLoader.GetCurrentPosition(LeverType.Horizontal);
     parameters.Lever1.AB          = currentPositionLoader.GetCurrentPosition(LeverType.Lever1);
     parameters.Lever2.AB          = currentPositionLoader.GetCurrentPosition(LeverType.Lever2);
 }
コード例 #13
0
 public TwoParameterSpendingFunction(DesignParameters designParameters, SpendingFunctionBounds bounds)
     : base(designParameters, bounds)
 {
 }
コード例 #14
0
 public SpendingFunction(DesignParameters designParameters, SpendingFunctionBounds bounds)
 {
     DesignParameters = designParameters;
     SpendingFunctionBounds = bounds;
 }
コード例 #15
0
 /// <summary>
 /// Предоставляет класс для рассчетов значений перемещения робота.
 /// </summary>
 /// <param name="designParams">Конструктивные параметры робота</param>
 public Calculation(DesignParameters designParams)
 {
     this.DesignParameters = designParams;
 }
コード例 #16
0
        public string GenerateScript(DesignParameters designParameters)
        {
            if (designParameters == null) return null;

            DesignParameters = designParameters;

            GeneratedTimestamp = DateTime.Now;

            _writer = new StringWriter();

            AppendHeader();
            AppendK();
            AppendTestType();
            AppendAlpha();
            AppendBeta();
            AppendBinomial();
            AppendTTE();
            AppendNFix();
            AppendTiming();
            AppendSpendingFunctions();
            AppendEndpoint();

            //Writer.WriteLine();
            //Writer.WriteLine("##################################################");
            //Writer.WriteLine("### (still in work)");
            //Writer.WriteLine("# =================================");
            //Writer.WriteLine("# Sample Size tab");
            //Writer.WriteLine("# ---------------------------------");
            //Writer.WriteLine("(Active tab: {0})", DesignParameters.SampleSizeParameters.SampleSizeCategory);
            //Writer.WriteLine("# =================================");
            //Writer.WriteLine("# Sample Size - User Input tab");
            //Writer.WriteLine("# ---------------------------------");
            //AppendAssignment("FixedDesignSampleSize", DesignParameters.SampleSizeParameters.FixedDesignSampleSize);
            //Writer.WriteLine("# =================================");
            //Writer.WriteLine("# Sample Size - Binomial tab");
            //Writer.WriteLine("# ---------------------------------");
            //AppendAssignment("Randomization Ratio", DesignParameters.SampleSizeParameters.BinomialRandomizationRatio);
            //AppendAssignment("Control", DesignParameters.SampleSizeParameters.BinomialControlEventRate);
            //AppendAssignment("Experimental", DesignParameters.SampleSizeParameters.BinomialExperimentalEventRate);
            //AppendAssignment("Non-Inferiority Testing", DesignParameters.SampleSizeParameters.BinomialNonInferiorityTesting.ToString());
            //AppendAssignment("Delta", DesignParameters.SampleSizeParameters.BinomialDelta);
            //AppendAssignment("Binomial Fixed Design Sample Size", DesignParameters.SampleSizeParameters.BinomialFixedDesignSampleSize);
            //Writer.WriteLine("# =================================");
            //Writer.WriteLine("# Sample Size - Time to Event tab");
            //Writer.WriteLine("# ---------------------------------");
            //AppendAssignment("Specification", DesignParameters.SampleSizeParameters.TimeToEventSpecification.ToString());
            //AppendAssignment("Control", DesignParameters.SampleSizeParameters.TimeToEventControl);
            //AppendAssignment("Experimental", DesignParameters.SampleSizeParameters.TimeToEventExperimental);
            //AppendAssignment("Dropout", DesignParameters.SampleSizeParameters.TimeToEventDropout);
            //AppendAssignment("Hazard Ratio", DesignParameters.SampleSizeParameters.TimeToEventHazardRatio);
            //AppendAssignment("Accrual Duration", DesignParameters.SampleSizeParameters.TimeToEventAccrualDuration);
            //AppendAssignment("Minimum Follow-Up", DesignParameters.SampleSizeParameters.TimeToEventMinimumFollowUp);
            //AppendAssignment("Randomization Ratio", DesignParameters.SampleSizeParameters.TimeToEventRandomizationRatio);
            //AppendAssignment("Hypothesis", DesignParameters.SampleSizeParameters.TimeToEventHypothesis.ToString());
            //AppendAssignment("Accrual Patient Entry Type", DesignParameters.SampleSizeParameters.TimeToEventAccrual.ToString());
            //AppendAssignment("Gamma", DesignParameters.SampleSizeParameters.TimeToEventGamma);
            //AppendAssignment("Time to Event Fixed Design Sample Size", DesignParameters.SampleSizeParameters.TimeToEventFixedDesignSampleSize);
            //AppendAssignment("Time to Event Fixed Design Events", DesignParameters.SampleSizeParameters.TimeToEventFixedDesignEvents);
            //Writer.WriteLine("# =================================");
            //Writer.WriteLine("# Spending Functions tab");
            //Writer.WriteLine("# ---------------------------------");
            //Writer.WriteLine("(Active tab: {0})", DesignParameters.SpendingFunctionParameters.CurrentSpendingFunctionBounds);
            //Writer.WriteLine("# =================================");
            //Writer.WriteLine("# Spending Functions - Lower Spending tab");
            //Writer.WriteLine("# ---------------------------------");
            //Writer.WriteLine("Test type: {0})", DesignParameters.SpendingFunctionParameters.LowerSpendingFunction.SpendingFunctionTestingParameters.SpendingFunctionTestType);
            //Writer.WriteLine("Lower bound spending: {0})", DesignParameters.SpendingFunctionParameters.LowerSpendingFunction.SpendingFunctionTestingParameters.SpendingFunctionLowerBoundSpending);
            //Writer.WriteLine("Lower bound testing: {0})", DesignParameters.SpendingFunctionParameters.LowerSpendingFunction.SpendingFunctionTestingParameters.SpendingFunctionLowerBoundTesting);
            //Writer.WriteLine("(Selected lower spending function: {0})", DesignParameters.SpendingFunctionParameters.LowerSpendingFunction.SpendingFunctionParameterCategory);
            //Writer.WriteLine("Parameter free spending function: {0})", DesignParameters.SpendingFunctionParameters.LowerSpendingFunction.ParameterFreeSpendingFunction.LanDeMetsApproximation);
            //Writer.WriteLine("# =================================");
            //Writer.WriteLine("# Spending Functions - Upper Spending tab");
            //Writer.WriteLine("# ---------------------------------");
            //Writer.WriteLine("Test type: {0})", DesignParameters.SpendingFunctionParameters.UpperSpendingFunction.SpendingFunctionTestingParameters.SpendingFunctionTestType);
            //Writer.WriteLine("Lower bound spending: {0})", DesignParameters.SpendingFunctionParameters.UpperSpendingFunction.SpendingFunctionTestingParameters.SpendingFunctionLowerBoundSpending);
            //Writer.WriteLine("Lower bound testing: {0})", DesignParameters.SpendingFunctionParameters.UpperSpendingFunction.SpendingFunctionTestingParameters.SpendingFunctionLowerBoundTesting);
            //Writer.WriteLine("(Selected upper spending function: {0})", DesignParameters.SpendingFunctionParameters.UpperSpendingFunction.SpendingFunctionParameterCategory);
            //Writer.WriteLine("Parameter free spending function: {0})", DesignParameters.SpendingFunctionParameters.UpperSpendingFunction.ParameterFreeSpendingFunction.LanDeMetsApproximation);
            //Writer.WriteLine("###");
            //Writer.WriteLine();
            //Writer.WriteLine("gsDesign function parameters (TBD)");

            //AppendAssignment("astar", "[TBD]");
            //AppendAssignment("tol", "[TBD]");
            //AppendAssignment("r", "[TBD]");
            //AppendAssignment("upper", "[TBD]");
            //AppendAssignment("lower", "[TBD]");
            //AppendAssignment("n.I", "[TBD]");
            //AppendAssignment("maxn.IPlan", "[TBD]");

            //Writer.WriteLine("##################################################");

            Writer.WriteLine();
            AppendGSDesignFunction();
            Writer.WriteLine();
            AppendPlot();

            string script = _writer.ToString();
            _writer.Close();
            _writer = null;
            return script;
        }
コード例 #17
0
        /// <summary>
        /// Generates a single method call to display an InfoBox.
        /// </summary>
        /// <param name="behavior">The behavior.</param>
        /// <param name="text">The text.</param>
        /// <param name="title">The title.</param>
        /// <param name="buttons">The buttons.</param>
        /// <param name="button1Text">The button1 text.</param>
        /// <param name="button2Text">The button2 text.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="iconFileName">Name of the icon file.</param>
        /// <param name="defaultButton">The default button.</param>
        /// <param name="buttonsLayout">The buttons layout.</param>
        /// <param name="autoSize">The autosize parameters</param>
        /// <param name="position">The position.</param>
        /// <param name="showHelp">if set to <c>true</c> [show help].</param>
        /// <param name="helpFile">The help file.</param>
        /// <param name="helpTopic">The help topic.</param>
        /// <param name="navigator">The navigator.</param>
        /// <param name="checkState">The state of the checkbox.</param>
        /// <param name="style">The style.</param>
        /// <param name="useAutoClose">if set to <c>true</c> [use auto close].</param>
        /// <param name="autoClose">The auto-close parameters.</param>
        /// <param name="design">The design.</param>
        /// <param name="titleStyle">The title style.</param>
        /// <param name="titleIconFileName">Filename of the title icon .</param>
        /// <param name="opacity">The opacity.</param>
        /// <param name="order">The order.</param>
        /// <returns></returns>
        public string GenerateSingleCall(InformationBoxBehavior behavior, string text, string title, InformationBoxButtons buttons, string button1Text, string button2Text, InformationBoxIcon icon, string iconFileName, InformationBoxDefaultButton defaultButton, InformationBoxButtonsLayout buttonsLayout, InformationBoxAutoSizeMode autoSize, InformationBoxPosition position, bool showHelp, string helpFile, string helpTopic, System.Windows.Forms.HelpNavigator navigator, InformationBoxCheckBox checkState, InformationBoxStyle style, bool useAutoClose, AutoCloseParameters autoClose, DesignParameters design, InformationBoxTitleIconStyle titleStyle, string titleIconFileName, InformationBoxOpacity opacity, InformationBoxOrder order)
        {
            StringBuilder codeBuilder = new StringBuilder();

            if (checkState == 0)
            {
                codeBuilder.AppendFormat("InformationBox.Show(\"{0}\", ", text.Replace(Environment.NewLine, "\\n"));
            }
            else
            {
                codeBuilder.Append("Dim doNotShowState as CheckState = CheckState.Indeterminate");
                codeBuilder.Append(Environment.NewLine);
                codeBuilder.AppendFormat("InformationBox.Show(\"{0}\", doNotShowState, ", text.Replace(Environment.NewLine, "\\n"));
            }

            if (!String.IsNullOrEmpty(helpFile) || !String.IsNullOrEmpty(title))
            {
                codeBuilder.AppendFormat("\"{0}\", ", title);
            }

            if (buttons != InformationBoxButtons.OK)
            {
                codeBuilder.AppendFormat("InformationBoxButtons.{0}, ", buttons);
            }

            if (buttons == InformationBoxButtons.OKCancelUser1 ||
                buttons == InformationBoxButtons.User1User2 ||
                buttons == InformationBoxButtons.YesNoUser1)
            {
                codeBuilder.AppendFormat("New String() {{ \"{0}\", \"{1}\" }}, ", button1Text, button2Text);
            }

            if (icon != InformationBoxIcon.None)
            {
                codeBuilder.AppendFormat("InformationBoxIcon.{0}, ", icon);
            }

            if (!String.IsNullOrEmpty(iconFileName))
            {
                codeBuilder.AppendFormat("New System.Drawing.Icon(@\"{0}\"), ", iconFileName);
            }

            if (defaultButton != InformationBoxDefaultButton.Button1)
            {
                codeBuilder.AppendFormat("InformationBoxDefaultButton.{0}, ", defaultButton);
            }

            if (buttonsLayout != InformationBoxButtonsLayout.GroupMiddle)
            {
                codeBuilder.AppendFormat("InformationBoxButtonsLayout.{0}, ", buttonsLayout);
            }

            if (autoSize != InformationBoxAutoSizeMode.None)
            {
                codeBuilder.AppendFormat("InformationBoxAutoSizeMode.{0}, ", autoSize);
            }

            if (position != InformationBoxPosition.CenterOnParent)
            {
                codeBuilder.AppendFormat("InformationBoxPosition.{0}, ", position);
            }

            if (showHelp)
            {
                codeBuilder.Append("True, ");
            }

            if (!String.IsNullOrEmpty(helpFile))
            {
                codeBuilder.AppendFormat("\"{0}\", ", helpFile);
            }

            if (navigator != 0)
            {
                codeBuilder.AppendFormat("HelpNavigator.{0}, ", navigator);
            }

            if (!String.IsNullOrEmpty(helpTopic))
            {
                codeBuilder.AppendFormat("\"{0}\", ", helpTopic);
            }

            if (checkState != 0)
            {
                codeBuilder.Append("InformationBoxCheckBox.Show");
                if ((checkState & InformationBoxCheckBox.Checked) == InformationBoxCheckBox.Checked)
                {
                    codeBuilder.Append(" Or InformationBoxCheckBox.Checked");
                }

                if ((checkState & InformationBoxCheckBox.RightAligned) == InformationBoxCheckBox.RightAligned)
                {
                    codeBuilder.Append(" Or InformationBoxCheckBox.RightAligned");
                }

                codeBuilder.Append(", ");
            }

            if (style != InformationBoxStyle.Standard)
            {
                codeBuilder.AppendFormat("InformationBoxStyle.{0}, ", style);
            }

            if (order != InformationBoxOrder.Default)
            {
                codeBuilder.AppendFormat("InformationBoxOrder.{0}, ", order);
            }

            if (useAutoClose)
            {
                if (autoClose.Seconds == AutoCloseParameters.Default.Seconds &&
                    autoClose.DefaultButton == InformationBoxDefaultButton.Button1 &&
                    autoClose.Result == InformationBoxResult.None)
                {
                    codeBuilder.Append("AutoCloseParameters.Default, ");
                }
                else
                {
                    if (autoClose.Mode == AutoCloseDefinedParameters.Button)
                    {
                        codeBuilder.AppendFormat("New AutoCloseParameters({0}, InformationBoxDefaultButton.{1}), ", autoClose.Seconds, autoClose.DefaultButton);
                    }
                    else if (autoClose.Mode == AutoCloseDefinedParameters.Result)
                    {
                        codeBuilder.AppendFormat("New AutoCloseParameters({0}, InformationBoxResult.{1}), ", autoClose.Seconds, autoClose.Result);
                    }
                    else
                    {
                        codeBuilder.AppendFormat("New AutoCloseParameters({0}), ", autoClose.Seconds);
                    }
                }
            }

            if (null != design)
            {
                codeBuilder.AppendFormat(CultureInfo.InvariantCulture, "New DesignParameters(Color.FromArgb({0},{1},{2}), Color.FromArgb({3},{4},{5})), ", design.FormBackColor.R, design.FormBackColor.G, design.FormBackColor.B, design.BarsBackColor.R, design.BarsBackColor.G, design.BarsBackColor.B);
            }

            if (titleStyle == InformationBoxTitleIconStyle.Custom)
            {
                codeBuilder.AppendFormat(CultureInfo.InvariantCulture, "New InformationBoxTitleIcon(@\"{0}\"), ", titleIconFileName);
            }
            else if (titleStyle == InformationBoxTitleIconStyle.SameAsBox)
            {
                codeBuilder.Append("InformationBoxTitleIconStyle.SameAsBox, ");
            }

            if (behavior == InformationBoxBehavior.Modeless)
            {
                codeBuilder.Append("InformationBoxBehavior.Modeless, ");
            }

            if (opacity != InformationBoxOpacity.NoFade)
            {
                codeBuilder.AppendFormat("InformationBoxOpacity.{0}, ", opacity);
            }

            codeBuilder[codeBuilder.Length - 2] = ')';

            return(codeBuilder.ToString().Replace("\"\"", "String.Empty"));
        }
コード例 #18
0
        /// <summary>
        /// Предоставляет класс презентера приложения.
        /// </summary>
        /// <param name="view">Представление приложения</param>
        /// <param name="settingsView">Представление изменения параметров</param>
        /// <param name="currentPositionLoader">Объект класса, описывающего механизм получения и сохранения текущего положения робота</param>
        /// <param name="messageService">Объект класса, описывающего механизм обмены сообщения с пользователем</param>
        public ManipulatorPresenter(IManipulatorControlView view, ISettingsView settingsView, ICurrentPositionLoader currentPositionLoader, IMessageService messageService)
        {
            this.view = view;
            this.currentPositionLoader = currentPositionLoader;
            this.settings       = settingsView;
            this.messageService = messageService;

            this.parameters = LoadDesignParameters();

            this.settings.SaveSettings += Settings_SaveSettings;

            this.view.OnViewClosing += View_OnViewClosing;

            this.view.ManualControlStart  += View_ManualControlStart;
            this.view.ManualControlStop   += View_ManualControlStop;
            this.view.InvokeStepperAbort  += View_InvokeStepperAbort;
            this.view.InvokeStepperStop   += View_InvokeStepperStop;
            this.view.RunGCodeInterpreter += View_RunGCodeInterpreter;
            this.view.OpenSettings        += View_OpenSettings;

            // Подписка на события для редактирования рабочих зон.
            this.view.InvokeSetActiveWorkspace     += View_InvokeSetActiveWorkspace;
            this.view.InvokeSetEditWorkspaceMode   += View_InvokeSetEditWorkspaceMode;
            this.view.OnActiveEditingLeverChanged  += View_OnActiveEditingLeverChanged;
            this.view.InvokeWorkspaceValueChange   += View_InvokeWorkspaceValueChange;
            this.view.InvokeRemoveZeroPosition     += View_InvokeRemoveZeroPosition;
            this.view.InvokeSaveWorkspaceValues    += View_InvokeSaveWorkspaceValues;
            this.view.InvokeCloseEditWorkspaceMode += View_InvokeCloseEditWorkspaceMode;
            this.view.InvokeRemoveWorkspace        += View_InvokeRemoveWorkspace;
            this.view.InvokeAddWorkspace           += View_InvokeAddWorkspace;
            this.view.InvokeRenameWorkspace        += View_InvokeRenameWorkspace;

            this.view.InvokeCreateScript         += View_InvokeCreateScript;
            this.view.InvokeSaveScript           += View_InvokeSaveScript;
            this.view.InvokeCancelCreatingScript += View_InvokeCancelCreatingScript;

            this.view.InvokeRemoveScript += View_InvokeRemoveScript;
            this.view.InvokeScriptRename += View_InvokeScriptRename;


            this.view.InvokeRunScript         += View_InvokeRunScript;
            this.view.InvokeRunScriptReverse  += View_InvokeRunScriptReverse;
            this.view.InvokeSetCurrentAsStart += View_InvokeSetCurrentAsStart;
            this.view.InvokeSetCurrentAsEnd   += View_InvokeSetCurrentAsEnd;
            this.view.InvokeMoveToStartScript += View_InvokeMoveToStartScript;
            this.view.InvokeMoveToEndScript   += View_InvokeMoveToEndScript;

            this.view.InvokeScriptBackTo += View_InvokeScriptBackTo;


            LoadApplicationSettings();
            this.levers = GetRobotLever().ToArray();

            leverMovement = new LeverMovement(port, levers);

            movement         = new RobotMovement(new Calculation(parameters), leverMovement);
            workspaceManager = new WorkspaceManager(parameters, LoadWorkspaces(), Properties.Settings.Default.ActiveWorkspaceIndex);
            scriptExecutor   = new ScriptExecutor(movement);

            workspaceManager.OnActiveWorkspaceChanged += WorkspaceManager_OnActiveWorkspaceChanged;
            workspaceManager.ActiveWorkspace           = workspaceManager.ActiveWorkspace;

            movement.LocationChanged       += Movement_LocationChanged;
            movement.LeverPositionChanged  += Movement_LeverPositionChanged;
            movement.OnZeroPositionChanged += Movement_OnZeroPositionChanged;
            movement.OnMovingStart         += Movement_OnMovingStart;
            movement.OnMovingEnd           += Movement_OnMovingEnd;

            scriptExecutor.StepPassed       += ScriptExecutor_StepPassed;
            scriptExecutor.OnExecutingStart += ScriptExecutor_OnExecutingStart;
            scriptExecutor.OnExecutingEnd   += ScriptExecutor_OnExecutingEnd;

            Movement_LocationChanged(false, movement.Calculation.GetCurrentLocation());

            view.SetWorkspaces(workspaceManager.RobotWorkspaces, workspaceManager.ActiveWorkspaceIndex);

            SetCurrentPositionOnView();
        }
コード例 #19
0
 public SpendingFunctionParameters(DesignParameters designParameters)
 {
     DesignParameters = designParameters;
 }
コード例 #20
0
        /// <summary>
        /// Возвращает ошибки, связанные с данной рабочей зоной.
        /// </summary>
        /// <param name="parameters">Уонструктивные параметры робота</param>
        /// <returns>Коллекция ошибок</returns>
        public IEnumerable <KeyValuePair <LeverType, DesignParametersException> > GetDesignParametersExceptions(DesignParameters parameters)
        {
            var exceptions = new List <KeyValuePair <LeverType, DesignParametersException> >();

            exceptions.AddRange(GetExeptions(LeverType.Horizontal, LeverWorkspace.GetDesignParametersExceptions(parameters.HorizontalLever.AB, HorizontalLever)));
            exceptions.AddRange(GetExeptions(LeverType.Lever1, LeverWorkspace.GetDesignParametersExceptions(parameters.Lever1.AB, Lever1)));
            exceptions.AddRange(GetExeptions(LeverType.Lever2, LeverWorkspace.GetDesignParametersExceptions(parameters.Lever2.AB, Lever2)));

            return(exceptions);
        }