// in order to react to more than one edit mode at once
        // use + as OR; * as AND
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || parameter == null)
            {
                return(false);
            }

            EditMode em = EditMode.NONE;

            if (value is EditMode)
            {
                em = (EditMode)value;
            }

            // OR - split
            string str_param = parameter.ToString();

            string[] str_params_OR = str_param.Split(new char[] { '+' });

            if (str_params_OR.Count() < 2)
            {
                return(em == NodePropertyValues.StringToEditMode(str_param));
            }
            else
            {
                foreach (string p in str_params_OR)
                {
                    if (em == NodePropertyValues.StringToEditMode(p))
                    {
                        return(true);
                    }
                }
                return(false);
            }
        }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value is NodeManagerType)
     {
         NodeManagerType nmt = (NodeManagerType)value;
         return(NodePropertyValues.NodeManagerTypeToColor(nmt));
     }
     else
     {
         return((Color)ColorConverter.ConvertFromString("#ff000000"));
     }
 }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value is NodeManagerType)
     {
         NodeManagerType nmt = (NodeManagerType)value;
         return(NodePropertyValues.NodeManagerTypeToDescrDE(nmt));
     }
     else
     {
         return("unknown");
     }
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || parameter == null)
            {
                return(false);
            }

            ParameterType pt = ParameterType.NONE;

            if (value is ParameterType)
            {
                pt = (ParameterType)value;
            }

            string str_param = parameter.ToString();

            return(pt == NodePropertyValues.StringToParameterType(str_param));
        }
Exemplo n.º 5
0
        public override string ToString()
        {
            string node_str = "Node ";

            node_str += this.NodeName + "[";
            node_str += (this.SyncByName) ? Node.NODE_SYNCED + " " : Node.NODE_NOT_SYNCED + " ";
            node_str += NodePropertyValues.NodeManagerTypeToString(this.NodeManager) + " ";
            node_str += "[";
            if (this.ContainedNodes.Count > 0)
            {
                foreach (Node sN in this.ContainedNodes)
                {
                    node_str += sN.NodeName;
                    node_str += (sN.SyncByName) ? Node.NODE_SYNCED : Node.NODE_NOT_SYNCED;
                    node_str += " ";
                }
            }
            node_str += "]]";

            return(node_str);
        }
        private static List <string> GetNodeRecordSimple(Node _node)
        {
            List <string> node_record = new List <string>();

            if (_node == null)
            {
                return(node_record);
            }

            node_record.Add(_node.NodeName);
            string sync_by_name = (_node.SyncByName) ? "1" : "0";

            node_record.Add(sync_by_name);
            node_record.Add(_node.NodeDescr);
            node_record.Add(_node.NodeUnit);
            node_record.Add(_node.NodeDefaultVal);
            node_record.Add(_node.NodeSource);
            node_record.Add(NodePropertyValues.NodeManagerTypeToString(_node.NodeManager));

            string has_geom = (_node.HasGeometry) ? "1" : "0";

            node_record.Add(has_geom);

            string contained = "";

            if (_node.ContainedNodes.Count > 0)
            {
                foreach (Node subN in _node.ContainedNodes)
                {
                    contained += subN.NodeName + NODE_SEPARATORS[0] + " ";
                }
                contained = contained.Substring(0, contained.Length - 2);
            }
            node_record.Add(contained);

            return(node_record);
        }
        private static void ExtractInfoFromNodeStrings(List <List <string> > _string_data, int _nr_entries_per_node,
                                                       out List <Node> nodes_at_level0, out List <string> nodes_names,
                                                       out List <List <string> > nodes_contained_node_names, out List <int> nodes_levels)
        {
            nodes_at_level0            = new List <Node>();
            nodes_names                = new List <string>();
            nodes_contained_node_names = new List <List <string> >();
            nodes_levels               = new List <int>();

            // check data consistency
            if (_string_data == null)
            {
                return;
            }
            if (_nr_entries_per_node < 1)
            {
                return;
            }

            int nrRows = _string_data.Count;

            if (nrRows < 2)
            {
                return;
            }

            int nrFields = _string_data[0].Count;

            if (nrFields < _nr_entries_per_node)
            {
                return;
            }

            if (_nr_entries_per_node > 0 && !string.Equals(_string_data[0][0], NODE_NAME))
            {
                return;
            }
            if (_nr_entries_per_node > 1 && !string.Equals(_string_data[0][1], NODE_SYNC_BY_NAME))
            {
                return;
            }
            if (_nr_entries_per_node > 2 && !string.Equals(_string_data[0][2], NODE_DESCR))
            {
                return;
            }
            if (_nr_entries_per_node > 3 && !string.Equals(_string_data[0][3], NODE_UNIT))
            {
                return;
            }
            if (_nr_entries_per_node > 4 && !string.Equals(_string_data[0][4], NODE_DEFAULT_VALUE))
            {
                return;
            }
            if (_nr_entries_per_node > 5 && !string.Equals(_string_data[0][5], NODE_SOURCE))
            {
                return;
            }
            if (_nr_entries_per_node > 6 && !string.Equals(_string_data[0][6], NODE_MANAGER))
            {
                return;
            }
            if (_nr_entries_per_node > 7 && !string.Equals(_string_data[0][7], NODE_GEOMETRY))
            {
                return;
            }
            if (_nr_entries_per_node > 8 && !string.Equals(_string_data[0][8], NODE_CONTAINED_NODES))
            {
                return;
            }
            if (_nr_entries_per_node > 9 && !string.Equals(_string_data[0][9], NODE_LEVEL))
            {
                return;
            }

            // extract data
            for (int i = 1; i < nrRows; i++)
            {
                List <string> current = _string_data[i];

                int nrFields_current = current.Count;
                if (nrFields_current < _nr_entries_per_node)
                {
                    continue;
                }

                // cannot process nodes without a name
                if (string.IsNullOrEmpty(current[0]))
                {
                    continue;
                }

                // 0: extract NODE_NAME
                string name_current = current[0];
                // 1: extract NODE_SYNC_BY_NAME
                bool sync_by_name_current = true;
                if (_nr_entries_per_node > 1)
                {
                    string sync_by_name_current_str = string.IsNullOrEmpty(current[1]) ? "0" : current[1];
                    int    sync_by_name_int_val     = 0;
                    Int32.TryParse(sync_by_name_current_str, out sync_by_name_int_val);
                    sync_by_name_current = (sync_by_name_int_val == 1);
                }
                // 2: extract NODE_DESCR
                string descr_current = string.Empty;
                if (_nr_entries_per_node > 2)
                {
                    descr_current = current[2];
                }
                // 3: extract NODE_UNIT
                string unit_current = Node.NO_DATA;
                if (_nr_entries_per_node > 3)
                {
                    unit_current = string.IsNullOrEmpty(current[3]) ? Node.NO_DATA : current[3];
                }
                // 4: extract NODE_DEFAULT_VALUE
                string defVal_current = Node.NO_DATA;
                if (_nr_entries_per_node > 4)
                {
                    defVal_current = string.IsNullOrEmpty(current[4]) ? Node.NO_DATA : current[4];
                }
                // 5: extract NODE_SOURCE
                string source_current = Node.NO_DATA;
                if (_nr_entries_per_node > 5)
                {
                    source_current = string.IsNullOrEmpty(current[5]) ? Node.NO_DATA : current[5];
                }
                // 6: extract NODE_MANAGER
                string manager_current = Node.NO_DATA;
                if (_nr_entries_per_node > 6)
                {
                    manager_current = string.IsNullOrEmpty(current[6]) ? Node.NO_DATA : current[6];
                }
                // 7: extract NODE_GEOMETRY
                bool has_geometry_current = false;
                if (_nr_entries_per_node > 7)
                {
                    string geometry_current = string.IsNullOrEmpty(current[7]) ? "0" : current[7];
                    int    geometry_int_val = 0;
                    Int32.TryParse(geometry_current, out geometry_int_val);
                    has_geometry_current = (geometry_int_val == 1);
                }
                // 8: extract NODE_CONTAINED_NODES
                List <string> contained_names_current = new List <string>();
                if (_nr_entries_per_node > 8)
                {
                    string   contained_current        = current[8];
                    string[] contained_single_current = contained_current.Split(NODE_SEPARATORS);
                    contained_names_current = new List <string>(contained_single_current);
                    contained_names_current.RemoveAll(x => x == string.Empty);
                }
                // 9: extract NODE_LEVEL
                int level_current = NODE_ROOT_LEVEL;
                if (_nr_entries_per_node > 9)
                {
                    Int32.TryParse(current[9], out level_current);
                }


                // ... and create NODE
                Node node_current = new Node(name_current, descr_current, unit_current, defVal_current, source_current,
                                             sync_by_name_current, has_geometry_current);
                node_current.NodeManager = NodePropertyValues.StringToNodeManagerType(manager_current);

                // ... add the information to the OUT ARRAYS
                nodes_at_level0.Add(node_current);
                nodes_names.Add(name_current);
                nodes_contained_node_names.Add(contained_names_current);
                nodes_levels.Add(level_current);
            }
        }