コード例 #1
0
        public async Task RefreshCurrentObject(bool logging = false)
        {
            int index = CurrentBridgeHueObjectsList.FindIndex(x => x.Id == SelectedObject.Id && x.GetType() == SelectedObject.GetType());

            if (index == -1)
            {
                return;
            }

            IHueObject hr = await SelectedBridge.GetObjectAsync(SelectedObject.Id, SelectedObject.GetType());

            if (hr == null)
            {
                return;
            }
            IHueObject newobj = hr;

            CurrentBridgeHueObjectsList[index].Image = newobj.Image;
            List <PropertyInfo> pi = newobj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).ToList();

            foreach (PropertyInfo p in pi)
            {
                if (CurrentBridgeHueObjectsList[index].HasProperty(p.Name))
                {
                    PropertyInfo prop = CurrentBridgeHueObjectsList[index].GetType().GetProperty(p.Name);
                    if (prop != null)
                    {
                        p.SetValue(CurrentBridgeHueObjectsList[index], prop.GetValue(newobj));
                    }
                }
            }
        }
コード例 #2
0
        private void PopulatePropertyFields()
        {
            if (SelectedObject == null)
            {
                return;
            }

            if (propertyFields != null)
            {
                propertyFields.ForEach <PropertyField>(f => f.Dispose());
            }

            #region ** Commented Out **

            //propertyFields = TypeDescriptor.GetProperties(SelectedObject)
            //    .AsEnumerable<PropertyDescriptor>()
            //    .Where(p => p.IsBrowsable && !p.DesignTimeOnly)
            //    .Select(p => new PropertyField {
            //        PropertyDescriptor =p,
            //        PropertyGrid = this,
            //        SourceObject = SelectedObject,
            //        Value = p.GetValue(SelectedObject)
            //    });

            #endregion

            propertyFields = SelectedObject.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)
                             .OrderBy(p => p.Name)
                             .Select(p => new PropertyField {
                PropertyInfo = p,
                SourceObject = SelectedObject,
                PropertyGrid = this,
                Value        = p.GetValue(SelectedObject, null)
            });
        }
コード例 #3
0
ファイル: PropertyControl.cs プロジェクト: Yahasana/Blumind
 void BeforeSelectedObjectChange()
 {
     if (propertyGrid1.SelectedGridItem != null)
     {
         History[SelectedObject.GetType()] = GetItemPath(propertyGrid1.SelectedGridItem);
     }
 }
コード例 #4
0
            // returns the properties of the selected object, instead of the activity itself
            public PropertyDescriptorCollection GetProperties()
            {
                if (SelectedObject == null)
                {
                    return(TypeDescriptor.GetProperties(this, new Attribute[] { new BrowsableAttribute(false) }, true));
                }

                var props = new PropertyDescriptorCollection(null);

                if (SelectedObject is ICustomTypeDescriptor)
                {
                    foreach (PropertyDescriptor prop in (SelectedObject as ICustomTypeDescriptor).GetProperties())
                    {
                        props.Add(new WPG_PropertyDescriptor(this, prop.Name));
                    }
                }
                else
                {
                    foreach (var prop in SelectedObject.GetType().GetProperties())
                    {
                        props.Add(new WPG_PropertyDescriptor(this, prop.Name));
                    }
                }
                return(props);
            }
コード例 #5
0
ファイル: PropertyControl.cs プロジェクト: Yahasana/Blumind
 void AfterSelectedObjectChanged()
 {
     if (SelectedObject != null)
     {
         if (History.Contains(SelectedObject.GetType()))
         {
             SelectProperty((string)History[SelectedObject.GetType()]);
         }
     }
 }
コード例 #6
0
        /// <summary>
        ///   The create tab.
        /// </summary>
        /// <param name = "tabName">
        ///   The tab name.
        /// </param>
        /// <returns>
        /// </returns>
        private TabViewModel CreateTab(string tabName)
        {
            var tab = new TabViewModel(tabName, this);

            if (ImageProvider != null)
            {
                tab.Icon = ImageProvider.GetImage(SelectedObject.GetType(), Name);
            }

            return(tab);
        }
コード例 #7
0
        //------------------------------------------------------------------
        private void SynchronizeTexteEtObjet()
        {
            m_link.Text = Text;
            Image img = null;

            if (SelectedObject != null)
            {
                img = DynamicClassAttribute.GetImage(SelectedObject.GetType());
            }
            UpdateImage();
        }
コード例 #8
0
 public void InitializeComboBox()
 {
     if (SelectedObject == null)
     {
         return;
     }
     ComboBoxItemSource.Clear();
     foreach (var property in SelectedObject.GetType().GetProperties())
     {
         ComboBoxItemSource.Add(property.Name);
     }
 }
コード例 #9
0
        //-------------------------------------------------------------------------
        private void UpdateImage()
        {
            Image img = null;

            if (m_imageSpecifique != null)
            {
                m_picType.Image = m_imageSpecifique;
            }
            else
            {
                if (m_listeConfigs.Count == 1)
                {
                    img = DynamicClassAttribute.GetImage(m_listeConfigs[0].TypeObjets);
                }
                else
                {
                    if (SelectedObject != null)
                    {
                        img = DynamicClassAttribute.GetImage(SelectedObject.GetType());
                    }
                    else
                    {
                        img = null;
                    }
                }
            }
            m_picType.Image = img;
            switch (m_modeIcone)
            {
            case EModeAffichageImageTextBoxRapide.Never:
                m_picType.Visible = false;
                break;

            case EModeAffichageImageTextBoxRapide.Always:
                m_picType.Visible = img != null;
                break;

            case EModeAffichageImageTextBoxRapide.OnSelection:
                m_picType.Visible = img != null && SelectedObject != null;
                break;

            default:
                break;
            }
        }
コード例 #10
0
        private void UpdateSelectedObject()
        {
            IsLoading = true;
            _delayedUpdateTimer.Stop();
            _properties.Clear();
            Dispatcher.BeginInvoke((Action)(() => BuildPropertyList(SelectedObject)), DispatcherPriority.Background);

            if (SelectedObject != null)
            {
                Type     = SelectedObject.GetType().Name;
                HashCode = SelectedObject.GetHashCode().ToString();
                FullType = SelectedObject.GetType().FullName;
            }
            else
            {
                Type     = "null";
                HashCode = string.Empty;
            }
        }
コード例 #11
0
        //TODO: is this useful???
        private void AddDynamicExtender()
        {
            if (SelectedObject == null)
            {
                return;
            }

            Type selectedObjectType = SelectedObject.GetType();

            if (!ApplicationOptions.Instance.HasDynamicExtenders(selectedObjectType))
            {
                return;
            }

            DynamicExtenderInfo extender = ApplicationOptions.Instance.GetDynamicExtender(selectedObjectType);

            if (extender != null)
            {
                extender.CreateExtender(SelectedObject);
            }
            // TODO: log if extender == null
        }
コード例 #12
0
 private void DisplayProperties()
 {
     _panel.Children.Clear();
     ClearGrid();
     if (SelectedObject != null)
     {
         int row = 0;
         foreach (var prop in SelectedObject.GetType().GetProperties())
         {
             var attr = prop.GetCustomAttributes(typeof(BrowsableAttribute), true);
             if (attr.Length == 0 || (attr[0] as BrowsableAttribute).Browsable)
             {
                 DisplayProperty(prop, row);
                 row += 2;
             }
         }
         _panel.Children.Add(_gridContainer);
     }
     else
     {
         _panel.Children.Add(_label);
     }
 }
コード例 #13
0
        private void WindowFunction(int windowID)
        {
            try
            {
                var next = SelectedObject;
                GUILayout.BeginHorizontal();
                {
                    if (SelectedObject != null)
                    {
                        GUILayout.Label($"{SelectedObject.name}({SelectedObject.GetType().Name}");
                        if (GUILayout.Button("Clear"))
                        {
                            next = null;
                        }
                        if (GUILayout.Button(SelectedObject.activeSelf ? "Disable" : "Enable"))
                        {
                            SelectedObject.SetActive(!SelectedObject.activeSelf);
                        }
                    }
                    else
                    {
                        GUILayout.Label("No select");
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.Label("Children");
                GUILayout.BeginVertical(GUI.skin.box);
                {
                    scrollPosition2 = GUILayout.BeginScrollView(scrollPosition2, false, true);
                    {
                        GUILayout.BeginVertical();
                        {
                            if (SelectedObject != null)
                            {
                                foreach (Transform t in SelectedObject.transform)
                                {
                                    if (ObjectControlButtons(t.gameObject))
                                    {
                                        next = t.gameObject;
                                    }
                                }
                            }
                            else
                            {
                                foreach (var obj in CurrentScene.GetRootGameObjects())
                                {
                                    if (ObjectControlButtons(obj))
                                    {
                                        next = obj;
                                    }
                                }
                            }
                        }
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndScrollView();
                }
                GUILayout.EndVertical();

                GUILayout.Label("Parent");
                GUILayout.BeginVertical(GUI.skin.box);
                {
                    scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true);
                    {
                        GUILayout.BeginVertical();
                        {
                            var current = SelectedObject;

                            while (current?.transform?.parent != null)
                            {
                                if (ObjectControlButtons(current.transform.parent.gameObject))
                                {
                                    next = current.transform.parent.gameObject;
                                }
                                current = current.transform.parent.gameObject;
                            }
                        }
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndScrollView();
                }
                GUILayout.EndVertical();

                GUI.DragWindow();

                if (SelectedObject != next)
                {
                    SelectedObject = next;
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex);
                throw;
            }
        }
        /// <summary>
        /// Main UI logic function.
        /// </summary>
        /// <returns>Y axis value of the dynamic last control.</returns>
        protected void UpdateUI()
        {
            int lastYValue = _startingYLocation; // checkBoxEnabled.Bottom + InterControlMargin;

            //lastYValue = Math.Max(checkBoxEnabled.Bottom + InterControlMargin, _startingYLocation);

            if (this.DesignMode)
            {
                return;
            }
            // Clear existing indicator custom parameters controls.
            foreach (Control control in propertiesControls)
            {
                control.Parent = null;
                control.Tag    = null;
                control.Dispose();
            }

            propertiesControls.Clear();

            if (SelectedObject == null)
            {
                OnUpdateUI(lastYValue);
                return;
            }

            // Gather indicator custom parameters.
            Type type = SelectedObject.GetType();

            PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);

            Dictionary <string, PropertyInfo> actualProperties = new Dictionary <string, PropertyInfo>();

            // Filter properties.
            foreach (PropertyInfo info in properties)
            {
                if (_filteringPropertiesNames.Contains(info.Name) == false)
                {
                    if (actualProperties.ContainsKey(info.Name) == false)
                    {// Also if a parent and child define same property, with "new" only show childs.
                        actualProperties.Add(info.Name, info);
                    }
                }
            }

            // Handle default properties of the SelectedObject class.
            foreach (PropertyInfo info in actualProperties.Values)
            {
                if (info.CanRead == false)
                {// We do not process write only properties.
                    continue;
                }

                Type propertyType = info.PropertyType;
                bool isReadOnly   = info.CanWrite == false || IsReadOnly;

                object value = info.GetValue(SelectedObject, null);

                Type underlyingType = Nullable.GetUnderlyingType(propertyType);
                if (underlyingType != null)
                {// Unwrap nullable properties.
                    propertyType = underlyingType;

                    if (value == null)
                    {// Nullable enums with null values not displayed.
                        continue;
                    }
                }

                AddDynamicPropertyValueControl(info.Name, propertyType, value, info, isReadOnly, ref lastYValue);
            }

            // Handle dynamic generic properties of the indicator as well.
            foreach (string name in SelectedObject.GetPropertiesNames())
            {
                AddDynamicPropertyValueControl(name, SelectedObject.GetPropertyType(name), SelectedObject.GetPropertyValue(name), name, IsReadOnly, ref lastYValue);
            }

            OnUpdateUI(lastYValue);
        }
コード例 #15
0
ファイル: UBL.cs プロジェクト: 15831944/EM
        updateBrkLines()
        {
            bool     exists     = false;
            ObjectId idDictHist = ObjectId.Null;

            try
            {
                idDictHist = Dict.getNamedDictionary("HISTORY", out exists);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} UBL.cs: line: 23", ex.Message));
            }
            if (!exists)
            {
                MessageBox.Show("Dictionary HISTORY not present - drawing not compatible with this command. Exiting....");
                return;
            }

            ResultBuffer rb = Dict.getXRec(idDictHist, "lastEnt");

            if (rb == null)
            {
                return;
            }

            TypedValue[] tvs         = rb.AsArray();
            string       handleLast0 = tvs[0].Value.ToString();

            tvs[0] = new TypedValue((int)DxfCode.Start, "POLYLINE");

            SelectionSet   ss    = Select.buildSSetBase(tvs, true);
            SelectedObject ssObj = ss[ss.Count - 1];

            if (ssObj.GetType() == typeof(Polyline3d))
            {
                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        Polyline3d poly3d      = (Polyline3d)tr.GetObject(ssObj.ObjectId, OpenMode.ForRead);
                        string     handleLastX = poly3d.Handle.ToString();

                        if (Int32.Parse(handleLastX, System.Globalization.NumberStyles.HexNumber) > Int32.Parse(handleLast0, System.Globalization.NumberStyles.HexNumber))
                        {
                            tvs[0] = new TypedValue(1005, poly3d.Handle);
                            Dict.addXRec(idDictHist, "lastENT", tvs);

                            var response = MessageBox.Show("Transfer new Breaklines to TOPO and CONT dwgs?", "trANSFER BREAKLINES?", MessageBoxButtons.YesNo);
                            if (response == DialogResult.Yes)
                            {
                                List <ObjectId> idPolys3d = new List <ObjectId>();
                                foreach (SelectedObject sObj in ss)
                                {
                                    if (sObj.GetType() == typeof(Polyline3d))
                                    {
                                        idPolys3d.Add(sObj.ObjectId);
                                    }
                                }

                                TransferObjs.transferObjects(idPolys3d, TemplateCONT, "CONT");
                                TransferObjs.transferObjects(idPolys3d, TemplateTOPO, "TOPO");
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(string.Format("{0} UBL.cs: line: 69", ex.Message));
                }
            }
        }