Exemplo n.º 1
0
        /// <summary>
        /// 移除面板中的信息
        /// </summary>
        private void RemoveDeviceInfo(IList items)
        {
            foreach (var item in items)
            {
                DeviveInfo deviveInfo = item as DeviveInfo;

                PortIsDevice portIsDevice = AppConfigInfos.PortDeviceList.PortevList.Find(p => p.PortName.Equals(deviveInfo.PortCode));
                if (portIsDevice != null)
                {
                    portIsDevice.IsDeviceInfo = false;
                }

                // 寻找在面板的位置编号
                PortPairInfo portInfo = AppConfigInfos.PortPairInfos.Find(p => p.PortCode.Equals(deviveInfo.PortCode));

                if (portInfo == null)
                {
                    return;
                }

                DeviceInfoItem deviceInfoItem = deviceControls.Find(p => p.Index.ToString().Equals(portInfo.Index));

                if (deviceInfoItem != null)
                {
                    deviceInfoItem.ClearData();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSure_Click(object sender, RoutedEventArgs e)
        {
            if (!isChangedValue && !firstChanged)
            {
                this.Close();
                return;
            }

            if (!AppHelper.CheckAppState(this))
            {
                return;
            }

            if (firstChanged)
            {
                // 设置优先端口
                string       portIndex    = (cbFirst.SelectedValue ?? string.Empty).ToString();
                string       portCode     = string.Empty;
                PortPairInfo portPairInfo = AppConfigInfos.PortPairInfos.Find(p => p.Index.Equals(portIndex));
                if (portPairInfo != null)
                {
                    portCode = portPairInfo.PortCode.Equals("----") ? string.Empty : portPairInfo.PortCode;
                }

                Conditions con = new Conditions();
                con.AddItem("PortCode", portCode);
                con.AddItem("Respond", "0");

                // 发送配对消息
                ResultWindow     resultWindow = WindowsHelper.ShowDialogWindow <ResultWindow>(this, MsgType.SetFirstPortRequest, MsgType.SetFirstPortRespond, con, TryFindResource("appMainSetFirstPorting").ToString());
                MessageBoxResult msgBoxResult = resultWindow.MessageBoxResult;
                if (msgBoxResult == MessageBoxResult.Cancel)
                {
                    NewMessageBox.Show(TryFindResource("appMainSetPortOvertime").ToString(), this);
                    return;
                }
                else if (msgBoxResult == MessageBoxResult.Yes)
                {
                    AppConfigInfos.PortDeviceList.FirstPort     = portIndex;
                    AppConfigInfos.PortDeviceList.FirstPortCode = portCode;
                    AppConfigHelper.SaveFirstPort();
                }
                else if (msgBoxResult == MessageBoxResult.No)
                {
                    NewMessageBox.Show(TryFindResource("appMainSetPortFailed").ToString(), this);
                    return;
                }
            }

            if (isChangedValue)
            {
                AppConfigHelper.SavePortPairInfos();
            }

            AppConfigInfos.PortDeviceList.IsChanged = !AppConfigInfos.PortDeviceList.IsChanged;
            this.Close();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 重置
        /// </summary>
        public void ResetValue()
        {
            comboBox.SelectionChanged -= comboBox_SelectionChanged;
            comboBox.SelectedValue     = OldPhysicsCode;
            lastOldValue = OldPhysicsCode;

            PortPairInfo portPairInfo = AppConfigInfos.PortPairInfos.Find(p => p.PortCode.Equals(OldPhysicsCode) && p.Index.Equals(InventedIndex.ToString()));

            if (portPairInfo != null)
            {
                if (string.IsNullOrEmpty(OldPhysicsCode))
                {
                    AppConfigInfos.PortPairInfos.Remove(portPairInfo);
                }
                else
                {
                    portPairInfo.PortCode = OldPhysicsCode;
                }
            }

            comboBox.SelectionChanged += comboBox_SelectionChanged;
        }
Exemplo n.º 4
0
        private void CreatGrid()
        {
            Dictionary <string, string> firstSource = new Dictionary <string, string>(); // 优先端口

            firstSource.Add("0", "----");

            int row    = AppConfigInfos.AppStateInfos.FaceplateRow;
            int column = AppConfigInfos.AppStateInfos.FaceplateColumn;

            sv.HorizontalScrollBarVisibility = column <= 4 ? ScrollBarVisibility.Disabled : ScrollBarVisibility.Auto;
            sv.VerticalScrollBarVisibility   = row <= 5 ? ScrollBarVisibility.Disabled : ScrollBarVisibility.Auto;

            int    itemWith    = 173;
            int    itemHeight  = 81;
            double spaceHeight = 5;
            double spaceWidth  = 5;

            canvasMain.Width  = column * (itemWith + spaceWidth);
            canvasMain.Height = row * (itemHeight + spaceHeight);

            Style  syPort   = TryFindResource("syPort") as Style;
            string portMark = TryFindResource("appMainInventedPort").ToString();

            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < column; j++)
                {
                    int index = i * column + j + 1;

                    PortControl portControl = new PortControl()
                    {
                        Name          = "prot" + index,
                        InventedIndex = index,
                        Width         = itemWith,
                        Height        = itemHeight,
                        Style         = syPort
                    };

                    portControl.Source = AppConfigInfos.PortDeviceList.PortevList;

                    PortPairInfo portPairInfo = AppConfigInfos.PortPairInfos.Find(p => p.Index.Equals(index.ToString()));
                    if (portPairInfo != null)
                    {
                        portControl.OldPhysicsCode = portPairInfo.PortCode;
                    }

                    firstSource.Add(index.ToString(), portMark + index);
                    PortControlList.Add(portControl);

                    portControl.SelectedHandler    += deviceInfoItem_SelectedHandler;
                    portControl.ChangeValueHandler += portControl_ChangeValueHandler;

                    double left = (itemWith + spaceWidth) * j;
                    double top  = (itemHeight + spaceHeight) * i;

                    Canvas.SetLeft(portControl, left);
                    Canvas.SetTop(portControl, top);
                    canvasMain.Children.Add(portControl);
                }
            }

            cbFirst.SelectedValuePath = "Key";
            cbFirst.DisplayMemberPath = "Value";
            cbFirst.ItemsSource       = firstSource;

            if (string.IsNullOrEmpty(AppConfigInfos.PortDeviceList.FirstPort))
            {
                cbFirst.SelectedIndex = 0;
            }
            else
            {
                cbFirst.SelectedValue = AppConfigInfos.PortDeviceList.FirstPort;
            }
        }