Пример #1
0
        private void chkTreeViewItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //实现单选效果
                if ((DeviceTreeViewItem[0] as CheckBox) == null)
                {
                    DeviceTreeViewItem[0] = sender;
                }
                else
                {
                    if (sender != DeviceTreeViewItem[0])
                    {
                        ((CheckBoxTreeModel)(DeviceTreeViewItem[0] as CheckBox).DataContext).IsChecked = false;
                        (DeviceTreeViewItem[0] as CheckBox).IsChecked = false;

                        ((CheckBoxTreeModel)(sender as CheckBox).DataContext).IsChecked = true;
                        (sender as CheckBox).IsChecked = true;
                    }
                    DeviceTreeViewItem[0] = sender;
                }

                mapweb.InvokeScript("deleteAllMarker");
                mapweb.InvokeScript("existenceLngLat", new Object[] { true });
                string  SelfID       = ((CheckBoxTreeModel)(sender as CheckBox).DataContext).Id;
                string  Model        = ((CheckBoxTreeModel)(sender as CheckBox).DataContext).Mode;
                string  NodeName     = ((CheckBoxTreeModel)(sender as CheckBox).DataContext).Name;
                string  FullName     = ((CheckBoxTreeModel)(sender as CheckBox).DataContext).FullName;
                string  IsStation    = ((CheckBoxTreeModel)(sender as CheckBox).DataContext).IsStation;
                string  SelfNodeType = ((CheckBoxTreeModel)(sender as CheckBox).DataContext).SelfNodeType;
                Boolean NodeChecked  = ((CheckBoxTreeModel)(sender as CheckBox).DataContext).IsChecked;
                if (!NodeChecked)
                {
                    return;
                }
                if (NodeChecked && IsStation == "1" && SelfNodeType.Equals(NodeType.StructureNode.ToString()))
                {
                    if (NetWorkClient.ControllerServer.Connected)
                    {
                        string[] name       = FullName.Split(new char[] { '.' });
                        string   ParentName = string.Empty;
                        for (int i = 0; i < name.Length - 1; i++)
                        {
                            if (i == 0)
                            {
                                ParentName += name[i];
                            }
                            else
                            {
                                ParentName += "." + name[i];
                            }
                        }
                        NetWorkClient.ControllerServer.Send(JsonInterFace.Get_station_location_Request(ParentName, NodeName));
                    }
                    else
                    {
                        Parameters.PrintfLogsExtended("网络与服务器断开!", "Connected: Failed!");
                    }
                }
            }
            catch (Exception ex)
            {
                Parameters.PrintfLogsExtended("百度地图显示", ex.Message, ex.StackTrace);
            }
        }