Esempio n. 1
0
        void lb_desc_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lb_desc.SelectedItem == null)
            {
                return;
            }

            String n    = lb_desc.SelectedItem.ToString();
            String dval = "{" + n + "} ";

            if (_currentBaseDesc.Length > 0)
            {
                _currentBaseDesc += " ";
            }
            _currentBaseDesc += dval;
            rtDesc.Text       = _currentBaseDesc;
            _currentDescList.Add(n);
            if (listDs.SelectedIndex > -1)
            {
                OOBDataSource ods = OOBDataSources[listDs.SelectedItem.ToString()];
                if (ods != null)
                {
                    if (!ods.DescriptionFields.Contains(n))
                    {
                        ods.DescriptionFields.Add(n);
                    }
                }
            }
        }
Esempio n. 2
0
 private void setDescriptionType(object sender, RoutedEventArgs e)
 {
     if ((Boolean)rb_descNone.IsChecked)
     {
         _currentDescType           = DescriptionType.None;
         cbItemDesc.IsEnabled       = false;
         singleFieldGrid.Visibility = System.Windows.Visibility.Collapsed;
         CustomDescGrid.Visibility  = System.Windows.Visibility.Collapsed;
         rtDesc.IsEnabled           = false;
     }
     else if ((Boolean)rb_descSinglefld.IsChecked)
     {
         _currentDescType           = DescriptionType.SingleField;
         cbItemDesc.IsEnabled       = true;
         singleFieldGrid.Visibility = System.Windows.Visibility.Visible;
         CustomDescGrid.Visibility  = System.Windows.Visibility.Collapsed;
         rtDesc.IsEnabled           = false;
     }
     else if ((Boolean)rb_descCustom.IsChecked)
     {
         _currentDescType           = DescriptionType.Custom;
         singleFieldGrid.Visibility = System.Windows.Visibility.Collapsed;
         CustomDescGrid.Visibility  = System.Windows.Visibility.Visible;
         cbItemDesc.IsEnabled       = false;
         rtDesc.IsEnabled           = true;
     }
     if (listDs.SelectedIndex > -1)
     {
         OOBDataSource ods = OOBDataSources[listDs.SelectedItem.ToString()];
         if (ods != null)
         {
             ods.DescType = _currentDescType;
         }
     }
 }
        public OOBDataSourceTests()
        {
            using (ShimsContext.Create())
            {
                fds         = new fake.ShimDataSource();
                fds.NameGet = () => { return("Friendly Situation - Friendly Equipment"); };
                fds.IdGet   = () => { return("b8725bd2-1aa2-4a06-895b-d87a8028d75a"); };

                string currentPath = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName;
                string dataPath    = System.IO.Path.Combine(currentPath, @"..\..\resources\");
                string dataFile    = dataPath + "oobdatasources.txt";
                System.Diagnostics.Trace.WriteLine("Test data file=" + dataFile);

                if (!File.Exists(dataFile))
                {
                    throw new Exception("Test data file not found: " + dataFile);
                }

                using (FileStream fs = File.OpenRead(dataFile))
                {
                    byte[]       b    = new byte[1024];
                    UTF8Encoding temp = new UTF8Encoding(true);
                    while (fs.Read(b, 0, b.Length) > 0)
                    {
                        odsString += (temp.GetString(b));
                    }
                }
                serialized = odsString.Split(';')[1];
                ods        = OOBDataSource.marshalODS(fds, serialized);
            }
        }
 public OOBNodeTest()
 {
     using (ShimsContext.Create())
     {
         fds = new fake.ShimDataSource();
         ods = new OOBDataSource(fds, "fake");
     }
 }
Esempio n. 5
0
 public OOBTreeTest()
 {
     using (ShimsContext.Create())
     {
         fds         = new opsfake.ShimDataSource();
         fds.NameGet = () => { return("Friendly Situation - Friendly Equipment"); };
         fds.IdGet   = () => { return("b8725bd2-1aa2-4a06-895b-d87a8028d75a"); };
         ods         = new OOBDataSource(fds, "fake");
     }
 }
Esempio n. 6
0
 private void rtDesc_TextChanged(object sender, TextChangedEventArgs e)
 {
     _currentBaseDesc = rtDesc.Text;
     if (listDs.SelectedIndex > -1)
     {
         OOBDataSource ods = OOBDataSources[listDs.SelectedItem.ToString()];
         if (ods != null)
         {
             ods.BaseDescription = curLabelVal;
         }
     }
 }
Esempio n. 7
0
 private void tbLabel_TextChanged(object sender, TextChangedEventArgs e)
 {
     curLabelVal = tbLabel.Text;
     if (listDs.SelectedIndex > -1)
     {
         OOBDataSource ods = OOBDataSources[listDs.SelectedItem.ToString()];
         if (ods != null)
         {
             ods.BaseLabel = curLabelVal;
         }
     }
     if (!String.IsNullOrEmpty(tbLabel.Text))
     {
         ValidateInput(sender, e);
     }
 }
Esempio n. 8
0
 private void set_ShowIcon(object sender, RoutedEventArgs e)
 {
     if ((Boolean)rb_none.IsChecked)
     {
         _showIcon = false;
     }
     else if ((Boolean)rb_Symbol.IsChecked)
     {
         _showIcon = true;
     }
     if (listDs.SelectedIndex > -1)
     {
         OOBDataSource ods = OOBDataSources[listDs.SelectedItem.ToString()];
         if (ods != null)
         {
             ods.UseIcon = _showIcon;
         }
     }
 }
Esempio n. 9
0
        private void updateCurrentDatasource(object sender, RoutedEventArgs e)
        {
            if (listDs.SelectedIndex > -1)
            {
                if (!listDs.SelectedItem.ToString().Equals("UNITS"))
                {
                    btnRemoveDS.IsEnabled = true;
                }
                else
                {
                    btnRemoveDS.IsEnabled = false;
                }
                String        selectedDs = listDs.SelectedItem.ToString();
                OOBDataSource ods        = OOBDataSources[selectedDs];
                DataSource    ds         = ods.DataSource;
                DataSourceSelector.SelectedDataSource = ds;
                _currentDS = ds;

                foreach (client.Field f in ds.Fields)
                {
                    if (f.Name.Equals(ods.UIDField))
                    {
                        UIDComboBox.SelectedItem = f;
                    }
                    if (f.Name.Equals(ods.HFField))
                    {
                        HFComboBox.SelectedItem = f;
                    }
                }
                _currentLabelList   = ods.LabelFields;
                _currentDescList    = ods.DescriptionFields;
                rb_Symbol.IsChecked = ods.UseIcon;
                setDescType(ods.DescType);
                rtDesc.Text  = ods.BaseDescription;
                tbLabel.Text = ods.BaseLabel;
                //tbLabel.Text = curLabelVal;
            }
            else
            {
                btnRemoveDS.IsEnabled = false;
            }
        }
 public OOBDataSourceTests()
 {
     using (ShimsContext.Create())
     {
         fds         = new fake.ShimDataSource();
         fds.NameGet = () => { return("Friendly Situation - Friendly Equipment"); };
         fds.IdGet   = () => { return("b8725bd2-1aa2-4a06-895b-d87a8028d75a"); };
         using (FileStream fs = File.OpenRead("C:/Dev/VS/DefenseSolution/OrderOfBattle/OrderOfBattleUnitTests/resources/oobdatasources.txt"))
         {
             byte[]       b    = new byte[1024];
             UTF8Encoding temp = new UTF8Encoding(true);
             while (fs.Read(b, 0, b.Length) > 0)
             {
                 odsString += (temp.GetString(b));
             }
         }
         serialized = odsString.Split(';')[1];
         ods        = OOBDataSource.marshalODS(fds, serialized);
     }
 }
        private void lb_label_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lb_label.SelectedItem == null)
            {
                return;
            }
            String n = lb_label.SelectedItem.ToString();


            String lval = "{" + n + "} ";

            if (curLabelVal.Length > 0)
            {
                curLabelVal += " ";
            }
            curLabelVal += lval;
            tbLabel.Text = curLabelVal;
            if (!_currentLabelList.Contains(n))
            {
                _currentLabelList.Add(n);
            }
            if (listDs.SelectedIndex > -1)
            {
                OOBDataSource ods = OOBDataSources[listDs.SelectedItem.ToString()];
                if (ods != null)
                {
                    if (!ods.LabelFields.Contains(n))
                    {
                        ods.LabelFields.Add(n);
                    }
                    if (ods.UseIcon)
                    {
                        rb_Symbol.IsChecked = true;
                    }
                    if (ods.DescType != null)  // <-- TODO: Remove this warning (this is always true)
                    {
                        setDescType(ods.DescType);
                    }
                }
            }
        }
Esempio n. 12
0
        private void addDS(object sender, RoutedEventArgs e)
        {
            String     key = tb_dsname.Text.ToUpper();
            DataSource ds  = DataSourceSelector.SelectedDataSource;

            listDs.Items.Add(key);
            if (!tb_dsname.IsEnabled)
            {
                tb_dsname.IsEnabled = true;
            }
            tb_dsname.Clear();
            OOBDataSource ods = new OOBDataSource(ds, key);

            ods.UIDField = ((client.Field)UIDComboBox.SelectedItem).Name;
            ods.HFField  = ((client.Field)HFComboBox.SelectedItem).Name;
            if (!(Boolean)rb_descNone.IsChecked)
            {
                ods.DescField = ((client.Field)cbItemDesc.SelectedItem).Name;
            }
            else
            {
                ods.DescField = "";
            }
            foreach (String l in _currentLabelList)
            {
                ods.LabelFields.Add(l);
            }
            foreach (String d in _currentDescList)
            {
                ods.DescriptionFields.Add(d);
            }
            ods.DescType        = _currentDescType;
            ods.BaseDescription = _currentBaseDesc;
            ods.BaseLabel       = curLabelVal;
            ods.UseIcon         = _showIcon;
            _datasources.Add(ods.Key, ods);
            AddDatasourceToCache(ods);
            ResetComboBoxes(ds, sender);
            btnAddDS.IsEnabled = false;
        }
Esempio n. 13
0
        /*private void set_equipment(object sender, RoutedEventArgs e)
         * {
         *  if ((Boolean)((CheckBox)sender).IsChecked)
         *  {
         *      DataSourceSelectorEquipment.IsEnabled = true;
         *      //EquipmentUIDComboBox.IsEnabled = true;
         *      //EquipmentHFComboBox.IsEnabled = true;
         *      //EquipmentLabelComboBox.IsEnabled = true;
         *  }
         *  else
         *  {
         *      if (DataSources.Count > 1)
         *      {
         *          DataSources.Remove(DataSources[1]);
         *      }
         *      DataSourceSelectorEquipment.IsEnabled = false;
         *      //EquipmentUIDComboBox.IsEnabled = false;
         *      //EquipmentHFComboBox.IsEnabled = false;
         *      //EquipmentLabelComboBox.IsEnabled = false;
         *  }
         * }*/

        private async void AddDatasourceToCache(OOBDataSource ods)
        {
            try
            {
                String Uid       = ods.UIDField;
                String HF        = ods.HFField;
                String DF        = ods.DescField;
                String Labels    = "";
                String DescFlds  = "";
                String CacheName = ods.Key;
                Dictionary <String, String> fields = new Dictionary <String, String>();
                fields["UID"] = Uid;
                fields["HF"]  = HF;

                Int32 numBaseFlds = 2;
                if (DF != null)
                {
                    fields["DESCFIELD"] = DF;
                    numBaseFlds         = 3;
                }

                Int32    arraySize = ods.LabelFields.Count + ods.DescriptionFields.Count + numBaseFlds;
                string[] qfields   = new string[arraySize];
                qfields[0] = Uid;
                qfields[1] = HF;
                if (DF != null)
                {
                    qfields[2] = DF;
                }
                Int32   c     = numBaseFlds;
                Boolean first = true;
                foreach (String f in ods.LabelFields)
                {
                    if (!first)
                    {
                        Labels += ",";
                    }
                    else
                    {
                        first = false;
                    }
                    Labels    += f;
                    qfields[c] = f;
                    ++c;
                }
                first = true;
                foreach (String f in ods.DescriptionFields)
                {
                    if (!first)
                    {
                        DescFlds += ",";
                    }
                    else
                    {
                        first = false;
                    }
                    DescFlds  += f;
                    qfields[c] = f;
                    ++c;
                }
                fields["LABELS"]   = Labels;
                fields["DESCFLDS"] = DescFlds;
                Query q = new Query();



                q.Fields = qfields;
                cache.AddFeatuereContainer(CacheName);

                DataSource ds = ods.DataSource;
                q.ReturnGeometry = true;
                QueryResult res = await ds.ExecuteQueryAsync(q);

                var resultOids = from feature in res.Features select System.Convert.ToInt32(feature.Attributes[ds.ObjectIdFieldName]);

                MapWidget           mw = MapWidget.FindMapWidget(ds);
                client.FeatureLayer fl = mw.FindFeatureLayer(ds);
                //fl.Update();
                client.UniqueValueRenderer r = fl.Renderer as client.UniqueValueRenderer;
                foreach (client.Graphic g in fl.Graphics)
                {
                    cache.AddFeature(CacheName, g, ods.BaseDescription, ods.BaseLabel, fields, r);
                }
                ods.IsCacheCreated = true;

                //cache.AddFeature
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show(e.Message + "/n" + e.Source
                                               + "/n" + e.StackTrace);
            }
        }