Exemplo n.º 1
0
        public ChannelFactoryBuilder AddChannel(byte channelId, ChannelConstructor activator)
        {
            _activators[channelId] = activator;

            return(this);
        }
Exemplo n.º 2
0
        private void OpenModel(object sender, RoutedEventArgs e)
        {
            var btn      = sender as Button;
            var btnModel = btn.Tag as ChannelConstructor;

            if (btnModel != this.currentModel)
            {
                this.curModelType    = ModelType.Model;
                this.currentModel    = btnModel;
                ParamsHeader.Content = $"Параметры {this.currentModel.ModelName}";

                ArgumentsPanel.Children.Clear();
                argumentsFields = new TextBox[btnModel.ArgsNames.Length + 2];

                var samplesCountLabel = new Label();
                samplesCountLabel.Content = "Количество отсчетов";
                ArgumentsPanel.Children.Add(samplesCountLabel);

                var samplesCountField = new TextBox();

                DataObject.AddPastingHandler(samplesCountField, previewPasting);
                samplesCountField.PreviewTextInput += previewTextInput;

                samplesCountField.Text = this.samplesCount.ToString(CultureInfo.InvariantCulture);
                argumentsFields[btnModel.ArgsNames.Length] = samplesCountField;
                ArgumentsPanel.Children.Add(samplesCountField);

                var samplingFrqLabel = new Label();
                samplingFrqLabel.Content = "Частота дискретизации";
                ArgumentsPanel.Children.Add(samplingFrqLabel);

                var samplingFrqField = new TextBox();

                DataObject.AddPastingHandler(samplingFrqField, previewPasting);
                samplingFrqField.PreviewTextInput += previewTextInput;

                samplingFrqField.Text = this.samplingFrq.ToString(CultureInfo.InvariantCulture);
                argumentsFields[btnModel.ArgsNames.Length + 1] = samplingFrqField;
                ArgumentsPanel.Children.Add(samplingFrqField);

                for (int i = 0; i < btnModel.ArgsNames.Length; i++)
                {
                    var    label  = new Label();
                    string header = btnModel.ArgsNames[i];

                    if (btnModel.MinArgValues[i] != double.MinValue)
                    {
                        header += $" от {btnModel.MinArgValues[i]}";
                    }

                    if (btnModel.MaxArgValues[i] != double.MaxValue)
                    {
                        header += $" до {btnModel.MaxArgValues[i]}";
                    }

                    label.Content = header;
                    ArgumentsPanel.Children.Add(label);

                    var field = new TextBox();
                    field.Text              = btnModel.LastValues[i].ToString(CultureInfo.InvariantCulture);
                    field.PreviewTextInput += previewTextInput;
                    DataObject.AddPastingHandler(field, previewPasting);

                    ArgumentsPanel.Children.Add(field);
                    argumentsFields[i] = field;
                }

                varargFields = new TextBox[btnModel.VarArgNames.Length];
                varargPanels = new StackPanel[btnModel.VarArgNames.Length];

                for (int i = 0; i < btnModel.VarArgNames.Length; i++)
                {
                    varargFields[i] = new TextBox();
                    string defaultVarargs = "";

                    for (int j = 0; j < btnModel.LastVarargs[i].Length; j++)
                    {
                        defaultVarargs += btnModel.LastVarargs[i][j].ToString(CultureInfo.InvariantCulture) + ", ";
                    }

                    varargFields[i].Text = defaultVarargs[0..^ 2];