Beispiel #1
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.tabControl1 = ((System.Windows.Controls.TabControl)(target));
                return;

            case 2:
                this.tabItem1 = ((System.Windows.Controls.TabItem)(target));
                return;

            case 3:
                this.realtimeCurves1 = ((SHHS.UILabs.RealtimeCurves.RealtimeCurves)(target));
                return;
            }
            this._contentLoaded = true;
        }
Beispiel #2
0
        private int _channelNumber       = 20;                                                     //通道的数量

        public RealtimeCurvesSetting(RealtimeCurves monitor)
        {
            InitializeComponent();
            this._monitor  = monitor;
            this.Resources = _monitor.Resources;
            //读取当前程序运行目录
            string assemPath  = Assembly.GetExecutingAssembly().Location;
            string currentDic = assemPath.Substring(0, assemPath.LastIndexOf("\\") + 1);
            //动态生成Y轴的控件


            //对单位数据集合进行排序
            var q = from u in _monitor.ChannelUnits
                    orderby u.Key
                    select u;
            Dictionary <string, string> tempDictionary = q.ToDictionary(pair => pair.Key, pair => pair.Value);

            for (int i = 0; i < tempDictionary.Count; i++)
            {
                CheckBox cbox    = new CheckBox();
                TextBox  tboxMax = new TextBox();
                TextBox  tboxMin = new TextBox();
                Label    lbl     = new Label();
                Button   btn     = new Button();

                cbox.Width               = 150;
                cbox.Height              = 15;
                cbox.VerticalAlignment   = VerticalAlignment.Top;
                cbox.HorizontalAlignment = HorizontalAlignment.Left;
                cbox.Content             = tempDictionary.Values.ElementAt(i) + " [ " + tempDictionary.Keys.ElementAt(i) + " ]";
                cbox.Margin              = new Thickness(8, 44 + (_yAxisSpace * i), 0, 0);

                tboxMax.Width               = 48;
                tboxMax.Height              = 19;
                tboxMax.VerticalAlignment   = VerticalAlignment.Top;
                tboxMax.HorizontalAlignment = HorizontalAlignment.Left;
                tboxMax.Text   = "100";
                tboxMax.Margin = new Thickness(150, 44 + (_yAxisSpace * i), 0, 0);

                tboxMin.Width               = 48;
                tboxMin.Height              = 19;
                tboxMin.VerticalAlignment   = VerticalAlignment.Top;
                tboxMin.HorizontalAlignment = HorizontalAlignment.Left;
                tboxMin.Text   = "0";
                tboxMin.Margin = new Thickness(205, 44 + (_yAxisSpace * i), 0, 0);

                //<Label Grid.Row="15" Grid.Column="3" Name="label30"
                //Padding="1" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
                //Background="White" Height="16" Width="35"
                //BorderBrush="{Binding Path=Background,ElementName=ChannelColor15}" BorderThickness="1">
                //    <Button Height="8" Background="Black" Name="ChannelColor15" Width="25"/>
                //</Label>

                lbl.Width                      = 37;
                lbl.Height                     = 19;
                lbl.VerticalAlignment          = VerticalAlignment.Top;
                lbl.HorizontalAlignment        = HorizontalAlignment.Left;
                lbl.Padding                    = new Thickness(1);
                lbl.VerticalContentAlignment   = VerticalAlignment.Center;
                lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                Binding bin = new Binding();
                bin.Source = btn;
                bin.Path   = new PropertyPath("Background");
                lbl.SetBinding(Label.BorderBrushProperty, bin);
                lbl.BorderThickness = new Thickness(1);
                lbl.Background      = Brushes.White;
                lbl.Content         = btn;
                lbl.Margin          = new Thickness(255, 44 + (_yAxisSpace * i), 0, 0);

                btn.Width      = 25;
                btn.Height     = 9;
                btn.Background = Brushes.Black;

                _yAxisDatas.Add(i, new YAxisData(cbox, tboxMax, tboxMin, btn, tempDictionary.Keys.ElementAt(i)));
                GridAxis.Children.Add(cbox);
                GridAxis.Children.Add(tboxMax);
                GridAxis.Children.Add(tboxMin);
                GridAxis.Children.Add(lbl);
            }

            //收集通道相关控件放在_channelDatas中
            for (int i = 1; i <= _channelNumber; i++)
            {
                _channelDatas.Add(i, new ChannelData(FindName("ItemComboBox" + i) as ComboBox, FindName("ChannelComBox" + i) as ComboBox, FindName("ChannelColor" + i) as Button));
                _channelDatas[i].ItemCBox.ItemsSource       = _monitor.ChannelMapping.Keys;
                _channelDatas[i].ItemCBox.SelectedIndex     = _monitor.ChannelMapping.Keys.Count - 1;
                _channelDatas[i].ChannelCBox.Visibility     = Visibility.Hidden;
                _channelDatas[i].ItemCBox.SelectionChanged += new SelectionChangedEventHandler(ItemCBox_SelectionChanged);
            }
            //读取设置页面的数据
            if (File.Exists(currentDic + "monitors/" + this._monitor.Name + "_" + this._monitor.TestType))
            {
                //StreamReader readFile = File.OpenText(currentDic + "monitors/" + this._monitor.Name);
                StreamReader readFile = File.OpenText(currentDic + "monitors/" + this._monitor.Name + "_" + this._monitor.TestType);
                string       str      = readFile.ReadLine();
                while (str != null)
                {
                    _fileDatas.Add(str);
                    str = readFile.ReadLine();
                }
                readFile.Close();
                //读取文件数据后,对MonitorSetter进行初始化

                //初始化时间轴--最大、最小时间
                MinTimeTextBox.Text = _fileDatas[0];
                MaxTimeTextBox.Text = _fileDatas[1];
                //初始化数据轴(YAxis)
                for (int i = 0; i < _yAxisDatas.Count; i++)
                {
                    _yAxisDatas[i].YAxisName.IsChecked   = bool.Parse(_fileDatas[2 + 4 * i]);
                    _yAxisDatas[i].YAxisMaximum.Text     = _fileDatas[3 + 4 * i];
                    _yAxisDatas[i].YAxisMinimum.Text     = _fileDatas[4 + 4 * i];
                    _yAxisDatas[i].YAxisColor.Background = new SolidColorBrush((Color)(ColorConverter.ConvertFromString(_fileDatas[5 + 4 * i])));
                }
                //初始化通道(Channel)
                if (_monitor.Channels != null)
                {
                    for (int i = 1; i <= _channelDatas.Count; i++)
                    {
                        _channelDatas[i].ItemCBox.SelectedIndex    = int.Parse(_fileDatas[2 + _monitor.ChannelUnits.Count * 4 + 3 * (i - 1)]);
                        _channelDatas[i].ChannelCBox.SelectedIndex = int.Parse(_fileDatas[3 + _monitor.ChannelUnits.Count * 4 + 3 * (i - 1)]);
                        _channelDatas[i].ChannelColor.Background   = new SolidColorBrush((Color)(ColorConverter.ConvertFromString(_fileDatas[4 + _monitor.ChannelUnits.Count * 4 + 3 * (i - 1)])));
                    }
                }
            }
        }