Exemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public outputPortType()
        {
            // loading the asterics.ini file to get the correct colors for the components
            if (File.Exists(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\asterics.ini"))
            {
                ini = new Asterics.ACS.IniFile(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\asterics.ini");
            }
            else if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini"))
            {
                ini = new Asterics.ACS.IniFile(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini");
            }
            else
            {
                MessageBox.Show(Asterics.ACS.Properties.Resources.IniFileNotFoundText, Asterics.ACS.Properties.Resources.IniFileNotFoundHeader, MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }

            portRectangle         = new Rectangle();
            portRectangle.Height  = ACS.LayoutConstants.OUTPORTRECTANGLEHEIGHT;
            portRectangle.Width   = ACS.LayoutConstants.OUTPORTRECTANGLEWIDTH;
            portRectangle.RadiusX = 3;
            portRectangle.RadiusY = 3;
            portRectangle.Stroke  = new SolidColorBrush(Colors.Black);
            BrushConverter bc           = new BrushConverter();
            String         outPortColor = ini.IniReadValue("Layout", "outportcolor");

            if (outPortColor.Equals(""))
            {
                outPortColor = ACS.LayoutConstants.OUTPORTRECTANGLECOLOR;
            }
            portRectangle.Fill    = (Brush)bc.ConvertFrom(outPortColor);
            this.descriptionField = "Output port description";
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public componentTypesComponentType()
        {
            // loading the asterics.ini file to get the correct colors for the components
            if (File.Exists(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\asterics.ini"))
            {
                ini = new Asterics.ACS.IniFile(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\asterics.ini");
            }
            else if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini"))
            {
                ini = new Asterics.ACS.IniFile(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini");
            }
            else
            {
                MessageBox.Show(Asterics.ACS.Properties.Resources.IniFileNotFoundText, Asterics.ACS.Properties.Resources.IniFileNotFoundHeader, MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }
            // init graphical elements
            componentCanvas = new Canvas();
            label           = new TextBlock();

            mainRectangle        = new Rectangle();
            mainRectangle.Height = ACS.LayoutConstants.MAINRECTANGLEHEIGHT;
            mainRectangle.Width  = ACS.LayoutConstants.MAINRECTANGLEWIDTH;
            mainRectangle.Stroke = new SolidColorBrush(Colors.Black);
            BrushConverter bc        = new BrushConverter();
            String         bodyColor = ini.IniReadValue("Layout", "bodycolor");

            if (bodyColor.Equals(""))
            {
                bodyColor = ACS.LayoutConstants.MAINRECTANGLECOLOR;
            }
            mainRectangle.Fill    = (Brush)bc.ConvertFrom(bodyColor);
            mainRectangle.RadiusX = 4;
            mainRectangle.RadiusY = 4;
            label.FontSize        = 12;

            componentCanvas.Children.Add(mainRectangle);
            componentCanvas.Children.Add(label);
            Canvas.SetLeft(mainRectangle, ACS.LayoutConstants.MAINRECTANGLEOFFSETX);
            Canvas.SetTop(mainRectangle, ACS.LayoutConstants.MAINRECTANGLEOFFSETY);
            Canvas.SetLeft(label, 20);
            Canvas.SetTop(label, 70);
            componentCanvas.Width  = ACS.LayoutConstants.COMPONENTCANVASWIDTH;
            componentCanvas.Height = ACS.LayoutConstants.COMPONENTCANVASHEIGHT;

            portsList = new OrderedDictionary();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        public componentTypesComponentType()
        {
            // loading the asterics.ini file to get the correct colors for the components
            if (File.Exists(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\asterics.ini")) {
                ini = new Asterics.ACS.IniFile(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\asterics.ini");
            } else if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini")) {
                ini = new Asterics.ACS.IniFile(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini");
            } else {
                MessageBox.Show(Asterics.ACS.Properties.Resources.IniFileNotFoundText, Asterics.ACS.Properties.Resources.IniFileNotFoundHeader, MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }
            // init graphical elements
            componentCanvas = new Canvas();
            label = new TextBlock();

            mainRectangle = new Rectangle();
            mainRectangle.Height = ACS.LayoutConstants.MAINRECTANGLEHEIGHT;
            mainRectangle.Width = ACS.LayoutConstants.MAINRECTANGLEWIDTH;
            mainRectangle.Stroke = new SolidColorBrush(Colors.Black);
            BrushConverter bc = new BrushConverter();
            String bodyColor = ini.IniReadValue("Layout", "bodycolor");
            if (bodyColor.Equals("")) bodyColor = ACS.LayoutConstants.MAINRECTANGLECOLOR;
            mainRectangle.Fill = (Brush)bc.ConvertFrom(bodyColor);
            mainRectangle.RadiusX = 4;
            mainRectangle.RadiusY = 4;
            label.FontSize=12;

            componentCanvas.Children.Add(mainRectangle);
            componentCanvas.Children.Add(label);
            Canvas.SetLeft(mainRectangle, ACS.LayoutConstants.MAINRECTANGLEOFFSETX);
            Canvas.SetTop(mainRectangle, ACS.LayoutConstants.MAINRECTANGLEOFFSETY);
            Canvas.SetLeft(label, 20);
            Canvas.SetTop(label, 70);
            componentCanvas.Width = ACS.LayoutConstants.COMPONENTCANVASWIDTH;
            componentCanvas.Height = ACS.LayoutConstants.COMPONENTCANVASHEIGHT;

            portsList = new OrderedDictionary();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor
        /// </summary>
        public outputPortType()
        {
            // loading the asterics.ini file to get the correct colors for the components
            if (File.Exists(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\asterics.ini")) {
                ini = new Asterics.ACS.IniFile(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\asterics.ini");
            } else if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini")) {
                ini = new Asterics.ACS.IniFile(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini");
            } else {
                MessageBox.Show(Asterics.ACS.Properties.Resources.IniFileNotFoundText, Asterics.ACS.Properties.Resources.IniFileNotFoundHeader, MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }

            portRectangle = new Rectangle();
            portRectangle.Height = ACS.LayoutConstants.OUTPORTRECTANGLEHEIGHT;
            portRectangle.Width = ACS.LayoutConstants.OUTPORTRECTANGLEWIDTH;
            portRectangle.RadiusX = 3;
            portRectangle.RadiusY = 3;
            portRectangle.Stroke = new SolidColorBrush(Colors.Black);
            BrushConverter bc = new BrushConverter();
            String outPortColor = ini.IniReadValue("Layout", "outportcolor");
            if (outPortColor.Equals("")) outPortColor = ACS.LayoutConstants.OUTPORTRECTANGLECOLOR;
            portRectangle.Fill = (Brush)bc.ConvertFrom(outPortColor);
            this.descriptionField = "Output port description";
        }
Exemplo n.º 5
0
        private void CollectProperties(object instance, PropertyDescriptor descriptor, List<Property> propertyCollection, bool automaticlyExpandObjects, string filter)
        {
            Asterics.ACS.IniFile langFile = null;
            Asterics.ACS.IniFile ini = null;
            // read lang from lini-file, then try to find a file, named like the file

            // loading the asterics.ini file, containing some basic settings
            // UNCOMMENT to activate language support in the property editor. Currentyl in Beta
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini")) {
                ini = new Asterics.ACS.IniFile(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini");
            }
            if ((ini != null) && (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "lang\\" + ini.IniReadValue("Options", "language") + ".txt"))) {
                langFile = new Asterics.ACS.IniFile(AppDomain.CurrentDomain.BaseDirectory + "lang\\" + ini.IniReadValue("Options", "language") + ".txt");
            }

            if (descriptor.Attributes[typeof(FlatAttribute)] == null) {
                Property property = new Property(instance, descriptor);

                if (descriptor.IsBrowsable) {

                    // new with lang-support
                    // replace the internal properties
                    if (langFile != null) {
                        if (property.Value != null && langFile.IniReadValue(componentID, property.Value.ToString()) != "") {
                            if (property.Value.GetType() == typeof(string)) {
                                property.Value = langFile.IniReadValue(componentID, property.Value.ToString());
                            }
                        }
                        if (langFile.IniReadValue(componentID, property.Name) != "") {
                            property.Name = langFile.IniReadValue(componentID, property.Name);
                        }
                    }

                    //Add a property with Name: AutomaticlyExpandObjects
                    Type propertyType = descriptor.PropertyType;
                    if (automaticlyExpandObjects && propertyType.IsClass && !propertyType.IsArray && propertyType != typeof(string)) {
                        propertyCollection.Add(new ExpandableProperty(instance, descriptor, automaticlyExpandObjects, filter));
                    } else if (descriptor.Converter.GetType() == typeof(ExpandableObjectConverter)) {
                        propertyCollection.Add(new ExpandableProperty(instance, descriptor, automaticlyExpandObjects, filter));
                    } else if (descriptor.Name.Equals("PropertyArrayList")) {
                        // NEW CODE for AsTeRICS
                        // Beside changes here, also Properties.cs has beed edited
                        ArrayList propList = (ArrayList)property.Value;
                        foreach (Asterics.ACS.propertyType propFromList in propList) {
                            // Sets an PropertyDescriptor to the specific property.
                            propertyType pT = new propertyType();
                            PropertyDescriptorCollection innerProperties = TypeDescriptor.GetProperties(pT);
                            System.ComponentModel.PropertyDescriptor myProperty = null;
                            Type propType = typeof(string);
                            object objectValue = null;
                            switch (propFromList.DataType) {
                                case Asterics.ACS2.dataType.boolean:
                                    propType = typeof(bool);
                                    myProperty = properties.Find("boolType", true);
                                    try {
                                        pT.BoolType = Boolean.Parse(propFromList.value);
                                    } catch (Exception) {
                                        pT.BoolType = false;
                                    }
                                    objectValue = pT.BoolType;
                                    break;
                                case Asterics.ACS2.dataType.integer:
                                    propType = typeof(int);
                                    myProperty = properties.Find("intType", true);
                                    try {
                                        pT.IntType = int.Parse(propFromList.value);
                                    } catch (Exception) {
                                        pT.IntType = 0;
                                    }
                                    objectValue = pT.IntType;
                                    break;
                                case Asterics.ACS2.dataType.@byte:
                                    propType = typeof(byte);
                                    myProperty = properties.Find("byteType", true);
                                    try {
                                        pT.ByteType = byte.Parse(propFromList.value);
                                    } catch (Exception) {
                                        pT.ByteType = 0;
                                    }
                                    objectValue = pT.ByteType;
                                    break;
                                case Asterics.ACS2.dataType.@char:
                                    propType = typeof(char);
                                    myProperty = properties.Find("charType", true);
                                    try {
                                        pT.CharType = char.Parse(propFromList.value);
                                    } catch (Exception) {
                                        pT.CharType = ' ';
                                    }
                                    objectValue = pT.CharType;
                                    break;
                                case Asterics.ACS2.dataType.@double:
                                    propType = typeof(double);
                                    myProperty = properties.Find("doubleType", true);
                                    try {
                                        pT.DoubleType = double.Parse(propFromList.value, System.Globalization.CultureInfo.InvariantCulture);
                                    } catch (Exception) {
                                        pT.DoubleType = 0;
                                    }
                                    objectValue = pT.DoubleType;
                                    break;
                                case Asterics.ACS2.dataType.@string:
                                    propType = typeof(string);
                                    myProperty = properties.Find("stringType", true);
                                    objectValue = propFromList.value;
                                    break;
                            }
                            if ((propType == typeof(string)) && propFromList.ComboBoxStrings != null) {
                                // text
                                propType = typeof(IList);
                                List<string> stringList = new List<string>(propFromList.ComboBoxStrings.Length);
                                foreach (string s in propFromList.ComboBoxStrings) {
                                    stringList.Add(s);
                                }
                                myProperty = properties.Find("listType", true);
                                objectValue = stringList;
                            } else if ((propType == typeof(int)) && propFromList.ComboBoxStrings != null) {
                                // text

                                // new with lang-support
                                //compProperty.ComboBoxStrings = sourceProperties[outPortIndex].combobox.Split(new String[] { "//" }, StringSplitOptions.None);
                                string stringToCompare = "";
                                foreach (string comboString in propFromList.ComboBoxStrings) {
                                    stringToCompare += comboString + "//";
                                }
                                stringToCompare = stringToCompare.Substring(0, stringToCompare.Length - 2);
                                if (langFile != null) {
                                    if (langFile.IniReadValue(componentID, stringToCompare) != "") {
                                        stringToCompare = langFile.IniReadValue(componentID, stringToCompare);
                                    }
                                }
                                propFromList.ComboBoxStrings = stringToCompare.Split(new String[] { "//" }, StringSplitOptions.None);

                                propType = typeof(IList);
                                List<string> stringList = new List<string>(propFromList.ComboBoxStrings.Length);
                                foreach (string s in propFromList.ComboBoxStrings) {
                                    stringList.Add(s);
                                }
                                myProperty = properties.Find("listType", true);
                                objectValue = stringList;
                            }
                            Property innerProperty = new Property(objectValue, myProperty, propFromList.name, propFromList.Description, propType, propFromList);

                            // new with lang-support
                            // replace the properties
                            if (langFile != null) {
                                if (langFile.IniReadValue(componentID, innerProperty.Name) != "") {
                                    innerProperty.Name = langFile.IniReadValue(componentID, innerProperty.Name);
                                }
                                if (langFile.IniReadValue(componentID, innerProperty.Description) != "") {
                                    innerProperty.Description = langFile.IniReadValue(componentID, innerProperty.Description);
                                }
                            }

                            propertyCollection.Add(innerProperty);
                        }
                    } else
                        propertyCollection.Add(property);
                }
            } else {
                instance = descriptor.GetValue(instance);
                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(instance);
                foreach (PropertyDescriptor propertyDescriptor in properties) {
                    CollectProperties(instance, propertyDescriptor, propertyCollection, automaticlyExpandObjects, filter);
                }
            }
        }
Exemplo n.º 6
0
        private void CollectProperties(object instance, PropertyDescriptor descriptor, List <Property> propertyCollection, bool automaticlyExpandObjects, string filter)
        {
            Asterics.ACS.IniFile langFile = null;
            Asterics.ACS.IniFile ini      = null;
            // read lang from lini-file, then try to find a file, named like the file

            // loading the asterics.ini file, containing some basic settings
            // UNCOMMENT to activate language support in the property editor. Currentyl in Beta
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini"))
            {
                ini = new Asterics.ACS.IniFile(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini");
            }
            if ((ini != null) && (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "lang\\" + ini.IniReadValue("Options", "language") + ".txt")))
            {
                langFile = new Asterics.ACS.IniFile(AppDomain.CurrentDomain.BaseDirectory + "lang\\" + ini.IniReadValue("Options", "language") + ".txt");
            }

            if (descriptor.Attributes[typeof(FlatAttribute)] == null)
            {
                Property property = new Property(instance, descriptor);

                if (descriptor.IsBrowsable)
                {
                    // new with lang-support
                    // replace the internal properties
                    if (langFile != null)
                    {
                        if (property.Value != null && langFile.IniReadValue(componentID, property.Value.ToString()) != "")
                        {
                            if (property.Value.GetType() == typeof(string))
                            {
                                property.Value = langFile.IniReadValue(componentID, property.Value.ToString());
                            }
                        }
                        if (langFile.IniReadValue(componentID, property.Name) != "")
                        {
                            property.Name = langFile.IniReadValue(componentID, property.Name);
                        }
                    }



                    //Add a property with Name: AutomaticlyExpandObjects
                    Type propertyType = descriptor.PropertyType;
                    if (automaticlyExpandObjects && propertyType.IsClass && !propertyType.IsArray && propertyType != typeof(string))
                    {
                        propertyCollection.Add(new ExpandableProperty(instance, descriptor, automaticlyExpandObjects, filter));
                    }
                    else if (descriptor.Converter.GetType() == typeof(ExpandableObjectConverter))
                    {
                        propertyCollection.Add(new ExpandableProperty(instance, descriptor, automaticlyExpandObjects, filter));
                    }
                    else if (descriptor.Name.Equals("PropertyArrayList"))
                    {
                        // NEW CODE for AsTeRICS
                        // Beside changes here, also Properties.cs has beed edited
                        ArrayList propList = (ArrayList)property.Value;
                        foreach (Asterics.ACS.propertyType propFromList in propList)
                        {
                            // Sets an PropertyDescriptor to the specific property.
                            propertyType pT = new propertyType();
                            PropertyDescriptorCollection             innerProperties = TypeDescriptor.GetProperties(pT);
                            System.ComponentModel.PropertyDescriptor myProperty      = null;
                            Type   propType    = typeof(string);
                            object objectValue = null;
                            switch (propFromList.DataType)
                            {
                            case Asterics.ACS2.dataType.boolean:
                                propType   = typeof(bool);
                                myProperty = properties.Find("boolType", true);
                                try {
                                    pT.BoolType = Boolean.Parse(propFromList.value);
                                } catch (Exception) {
                                    pT.BoolType = false;
                                }
                                objectValue = pT.BoolType;
                                break;

                            case Asterics.ACS2.dataType.integer:
                                propType   = typeof(int);
                                myProperty = properties.Find("intType", true);
                                try {
                                    pT.IntType = int.Parse(propFromList.value);
                                } catch (Exception) {
                                    pT.IntType = 0;
                                }
                                objectValue = pT.IntType;
                                break;

                            case Asterics.ACS2.dataType.@byte:
                                propType   = typeof(byte);
                                myProperty = properties.Find("byteType", true);
                                try {
                                    pT.ByteType = byte.Parse(propFromList.value);
                                } catch (Exception) {
                                    pT.ByteType = 0;
                                }
                                objectValue = pT.ByteType;
                                break;

                            case Asterics.ACS2.dataType.@char:
                                propType   = typeof(char);
                                myProperty = properties.Find("charType", true);
                                try {
                                    pT.CharType = char.Parse(propFromList.value);
                                } catch (Exception) {
                                    pT.CharType = ' ';
                                }
                                objectValue = pT.CharType;
                                break;

                            case Asterics.ACS2.dataType.@double:
                                propType   = typeof(double);
                                myProperty = properties.Find("doubleType", true);
                                try {
                                    pT.DoubleType = double.Parse(propFromList.value, System.Globalization.CultureInfo.InvariantCulture);
                                } catch (Exception) {
                                    pT.DoubleType = 0;
                                }
                                objectValue = pT.DoubleType;
                                break;

                            case Asterics.ACS2.dataType.@string:
                                propType    = typeof(string);
                                myProperty  = properties.Find("stringType", true);
                                objectValue = propFromList.value;
                                break;
                            }
                            if ((propType == typeof(string)) && propFromList.ComboBoxStrings != null)
                            {
                                // text
                                propType = typeof(IList);
                                List <string> stringList = new List <string>(propFromList.ComboBoxStrings.Length);
                                foreach (string s in propFromList.ComboBoxStrings)
                                {
                                    stringList.Add(s);
                                }
                                myProperty  = properties.Find("listType", true);
                                objectValue = stringList;
                            }
                            else if ((propType == typeof(int)) && propFromList.ComboBoxStrings != null)
                            {
                                // text

                                // new with lang-support
                                //compProperty.ComboBoxStrings = sourceProperties[outPortIndex].combobox.Split(new String[] { "//" }, StringSplitOptions.None);
                                string stringToCompare = "";
                                foreach (string comboString in propFromList.ComboBoxStrings)
                                {
                                    stringToCompare += comboString + "//";
                                }
                                stringToCompare = stringToCompare.Substring(0, stringToCompare.Length - 2);
                                if (langFile != null)
                                {
                                    if (langFile.IniReadValue(componentID, stringToCompare) != "")
                                    {
                                        stringToCompare = langFile.IniReadValue(componentID, stringToCompare);
                                    }
                                }
                                propFromList.ComboBoxStrings = stringToCompare.Split(new String[] { "//" }, StringSplitOptions.None);


                                propType = typeof(IList);
                                List <string> stringList = new List <string>(propFromList.ComboBoxStrings.Length);
                                foreach (string s in propFromList.ComboBoxStrings)
                                {
                                    stringList.Add(s);
                                }
                                myProperty  = properties.Find("listType", true);
                                objectValue = stringList;
                            }
                            Property innerProperty = new Property(objectValue, myProperty, propFromList.name, propFromList.Description, propType, propFromList);

                            // new with lang-support
                            // replace the properties
                            if (langFile != null)
                            {
                                if (langFile.IniReadValue(componentID, innerProperty.Name) != "")
                                {
                                    innerProperty.Name = langFile.IniReadValue(componentID, innerProperty.Name);
                                }
                                if (langFile.IniReadValue(componentID, innerProperty.Description) != "")
                                {
                                    innerProperty.Description = langFile.IniReadValue(componentID, innerProperty.Description);
                                }
                            }


                            propertyCollection.Add(innerProperty);
                        }
                    }
                    else
                    {
                        propertyCollection.Add(property);
                    }
                }
            }
            else
            {
                instance = descriptor.GetValue(instance);
                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(instance);
                foreach (PropertyDescriptor propertyDescriptor in properties)
                {
                    CollectProperties(instance, propertyDescriptor, propertyCollection, automaticlyExpandObjects, filter);
                }
            }
        }