Ejemplo n.º 1
0
        public void OnFormShow(object sender, EventArgs e)
        {
            var maxHeight = Screen.PrimaryScreen.WorkingArea.Height;

            if (_propGrid.SelectedObject == null)
            {
                return;
            }

            var type = _propGrid.SelectedObject.GetType().ToString();

            switch (type)
            {
            case "CslaGenerator.Metadata.ValueProperty":
                _form.Size = new Size(_form.Size.Width, 633);
                break;

            case "CslaGenerator.Metadata.ChildProperty":
                _form.Size = new Size(_form.Size.Width, 473);
                break;

            case "CslaGenerator.Metadata.ConvertValueProperty":
                _form.Size = new Size(_form.Size.Width, 553);
                break;

            case "CslaGenerator.Metadata.Criteria":
                _propGrid.ExpandAllGridItems();
                _form.Size = new Size(_form.Size.Width, 617);
                break;

            case "CslaGenerator.Metadata.CriteriaProperty":
                _propGrid.ExpandAllGridItems();
                _form.Size = new Size(_form.Size.Width, 393);
                break;
            }

            _form.StartPosition = FormStartPosition.CenterParent;
            //var a = _form.Bounds.Top;
            //var b = _form.Bounds.Y;
            if ((_form.Bounds.Y + _form.Bounds.Height) > maxHeight)
            {
                _form.StartPosition = FormStartPosition.Manual;
                var hDiff = maxHeight - _form.Bounds.Height;
                if (hDiff == 0)
                {
                    hDiff = 0;
                }
                else
                {
                    hDiff = hDiff / 2;
                }

                _form.Bounds = new Rectangle(_form.Bounds.X, hDiff, _form.Bounds.Width, _form.Bounds.Height);
            }

            //var formSize = _form.Size.Height;
            //_form.Size = new Size(_form.Size.Width, 633);
        }
Ejemplo n.º 2
0
        protected override CollectionForm CreateCollectionForm()
        {
            CollectionForm result = base.CreateCollectionForm();

            result.HelpButton    = false;
            result.Size          = new Size(640, 480);
            result.StartPosition = FormStartPosition.CenterParent;

            PropertyGrid propertyGrid = null;

            try
            {
                propertyGrid = result.Controls[0].Controls["propertyBrowser"] as PropertyGrid;
            }
            catch
            {
            }

            if (propertyGrid != null)
            {
                propertyGrid.HelpVisible  = true;
                propertyGrid.PropertySort = PropertySort.NoSort;
                propertyGrid.ExpandAllGridItems();
            }

            return(result);
        }
Ejemplo n.º 3
0
        private void OnArgumentsLoaded(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                if (e.Cancelled)
                {
                    //We'll need to reload the next time
                    m_currentReportPath = null;
                    return;
                }
                ;

                if (e.Error != null)
                {
                    throw e.Error;
                }

                var parameters = e.Result as IEnumerable <ParameterNode>;

                Node.SetParameters(parameters);
                PropertyGrid.Enabled = true;
                PropertyGrid.Refresh();
                PropertyGrid.ExpandAllGridItems();
            } catch (Exception ex)
            {
                MessageBoxes.Error(this, "Error Loading Parameters", ex);
            } finally
            {
                this.Cursor = Cursors.Default;
            };
        }
        private static void propertyGridExpandAllClick(object sender, EventArgs e)
        {
            PropertyGrid propertyGrid = getPropertyGridParent(sender);

            if (propertyGrid != null)
            {
                propertyGrid.ExpandAllGridItems();
            }
        }
        private void _DragDrop(DragEventArgs e, Label lbl, PropertyGrid Pg, string Txt, ref EnIPAttribut cipObj)
        {
            TreeNode t = (TreeNode)e.Data.GetData(typeof(TreeNode));

            cipObj   = (EnIPAttribut)t.Tag;
            lbl.Text = Txt + "\r\nNode " + cipObj.GetStrPath();
            cipObj.ReadDataFromNetwork();

            Pg.SelectedObject = cipObj;
            Pg.ExpandAllGridItems();
        }
Ejemplo n.º 6
0
        public BudgetEditorWindow()
        {
            try
            {
                InitializeComponent();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.WriteLine(ex.InnerException);
            }


            openFileName            = createSaveFileName() + ".budget";
            propGrid.SelectedObject = props;
            propGrid.BackColor      = System.Drawing.ColorTranslator.FromHtml("#5e35b1"); //Deep Purple 500
            propGrid.ExpandAllGridItems();
            propGrid.LineColor                   = System.Drawing.Color.DarkGray;
            propGrid.PropertySort                = PropertySort.Categorized;
            wfHost.Child                         = propGrid;
            propGrid.PropertyValueChanged       += PropGrid_PropertyValueChanged;
            propGridCustom.PropertyValueChanged += PropGrid_PropertyValueChanged;



            propGridCustom.SelectedObject = myProperties;
            wfHost2.Child = propGridCustom;

            foreach (System.Windows.Forms.Control c in propGridCustom.ActiveControl.Controls)
            {
                c.MouseClick += new System.Windows.Forms.MouseEventHandler(propGridCustom_MouseClick);
            }

            fillTotalValues(props);

            this.DataContext = TotalValues.Collection;

            this.Title = string.Format("{0} - Otthoni költségvetéskezelő", openFileName);

            tryToLoadLastSaved();
        }
Ejemplo n.º 7
0
 protected override void OnSelectedItemIsChanged(object sender, SelectedItemEventArgs e)
 {
     base.OnSelectedItemIsChanged(sender, e);
     if (e.SelectedIModelNode != null)
     {
         this.PropertyGrid.Enabled = !e.SelectedIModelNode.IsReadOnly;
     }
     if (!this.PropertyGrid.Enabled)
     {
         PropertyGrid.ExpandAllGridItems();
     }
 }
Ejemplo n.º 8
0
 private void UpdateProperties(FileSystemEntry fileSystemEntry)
 {
     _propertyGridMediaFile.SelectedObject =
         (fileSystemEntry == null ? null
                                 : (fileSystemEntry is VideoFile ? new VideoFileProperties((VideoFile)fileSystemEntry)
                                         : (fileSystemEntry is ImageFile ? new ImageFileProperties((ImageFile)fileSystemEntry)
                                                 : (fileSystemEntry is MediaFile ? new MediaFileProperties((MediaFile)fileSystemEntry)
                                                         : (fileSystemEntry is MediaFolder ? new MediaFolderProperties((MediaFolder)fileSystemEntry)
                                                                 : (FileSystemEntryProperties)null
                                                            )
                                                    )
                                            )
                                    )
         );
     _propertyGridMediaFile.ExpandAllGridItems();
 }
Ejemplo n.º 9
0
        public TypeSelector(DbProc db)
        {
            _proc              = db;
            this.ShowIcon      = false;
            this.ShowInTaskbar = false;
            this.StartPosition = FormStartPosition.CenterParent;
            this.Size          = new System.Drawing.Size(600, 400);
            panel              = new Panel();
            panel.Dock         = DockStyle.Bottom;
            panel.Padding      = new System.Windows.Forms.Padding(10);
            panel.Height       = 60;
            this.Controls.Add(panel);
            grid      = new PropertyGrid();
            grid.Dock = DockStyle.Fill;
            this.Controls.Add(grid);
            btnOk        = new Button();
            btnOk.Text   = "Ok";
            btnOk.Dock   = DockStyle.Right;
            btnOk.Margin = new System.Windows.Forms.Padding(20, 0, 0, 20);
            panel.Controls.Add(btnOk);
            btnCancel        = new Button();
            btnCancel.Text   = "Cancel";
            btnCancel.Dock   = DockStyle.Right;
            btnCancel.Margin = new System.Windows.Forms.Padding(20, 0, 0, 20);
            panel.Controls.Add(btnCancel);
            this.AcceptButton   = btnOk;
            this.CancelButton   = btnCancel;
            itemType            = new ItemType();
            grid.SelectedObject = itemType;
            db.time_start       = Properties.Settings.Default.DefaultDateTimeStart;
            db.time_end         = Properties.Settings.Default.DefaultDateTimeEnd;
            string sql = string.Format("select distinct(test_item_name) from test_item_values"
                                       + " where test_time between #{0}# and #{1}#", db.time_start, db.time_end);
            DataTable     dt = db.GetDataTable(sql);
            List <string> ls = new List <string>();

            foreach (DataRow row in dt.Rows)
            {
                ls.Add((string)row["test_item_name"]);
            }
            itemType.Items = ls.ToArray();
            grid.ExpandAllGridItems();
        }
Ejemplo n.º 10
0
        void propertyGrid1_Paint(object sender, PaintEventArgs e)
        {
            PropertyGrid propertyGrid = (PropertyGrid)sender;

            if (propertyGrid.SelectedObject == null)
            {
                return;
            }

            if (propertyGrid.SelectedObject.GetType().GetInterface(typeof(IPropertyGridCategoryOrder).FullName) == null)
            {
                return;
            }

            IPropertyGridCategoryOrder propertyGridCategoryOrder = (IPropertyGridCategoryOrder)propertyGrid.SelectedObject;
            List <string> propertyGridCategoryNames = propertyGridCategoryOrder.PropertyGridCategoryNames;

            switch (propertyGridCategoryOrder.OrderType)
            {
            case PropertyGridOrderType.Ascending:
                propertyGridCategoryNames = (from tmpItem in propertyGridCategoryNames orderby tmpItem ascending select tmpItem).ToList();
                break;

            case PropertyGridOrderType.Descending:
                propertyGridCategoryNames = (from tmpItem in propertyGridCategoryNames orderby tmpItem descending select tmpItem).ToList();
                break;

            case PropertyGridOrderType.Custom:
                break;
            }

            GridItemCollection currentPropEntries = propertyGrid.GetType().GetField("currentPropEntries", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(propertyGrid1) as GridItemCollection;

            propertyGrid.CollapseAllGridItems();
            var newarray = currentPropEntries.Cast <GridItem>().OrderBy((t) => propertyGridCategoryNames.IndexOf(t.Label)).ToArray();

            currentPropEntries.GetType().GetField("entries", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(currentPropEntries, newarray);
            propertyGrid.ExpandAllGridItems();
            propertyGrid.PropertySort = (PropertySort)propertyGrid.Tag;
            propertyGrid.Paint       -= new PaintEventHandler(propertyGrid1_Paint);
        }
Ejemplo n.º 11
0
        private void ToLog()
        {
            // Create a new property grid and expand it, to access all items
            // This beats implementing the property logic to fetch all of item.
            PropertyGrid grid = new PropertyGrid();

            grid.SelectedObject = Properties.SelectedObject;
            grid.ExpandAllGridItems();
            object view = grid.GetType().GetField("gridView", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(grid);

            // Log each category recursively
            GridItemCollection items = (GridItemCollection)view.GetType().InvokeMember("GetAllGridEntries", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, view, null);

            foreach (GridItem item in items)
            {
                if (item.GridItemType == GridItemType.Category)
                {
                    LogItem(item, string.Empty);
                }
            }
        }
Ejemplo n.º 12
0
        public void ShowPropertyGridItem(string category, string label)
        {
            RefreshPropertyGrid();
            GridItem gi = propertyGrid1.SelectedGridItem;

            while (gi != null && gi.GridItemType != GridItemType.Root)
            {
                gi = gi.Parent;
            }

            if (gi != null)
            {
                // Categories
                GridItemCollection categories     = gi.GridItems;
                GridItem           sliderCategory = categories[category];
                if (sliderCategory != null)
                {
                    GridItemCollection items = sliderCategory.GridItems;
                    GridItem           item;
                    if (label == "")
                    {
                        item = items[Math.Min(10, items.Count - 1)];
                    }
                    else
                    {
                        item = items[label];
                    }
                    item.Select();
                    if (item.Expandable)
                    {
                        propertyGrid1.ExpandAllGridItems();
                        items = item.GridItems;
                        items[Math.Min(10, items.Count - 1)].Select();
                    }
                }
            }
            RefreshPropertyGrid();
        }
 public void OnGridItemChanged(object sender, EventArgs e)
 {
     _propGrid.ExpandAllGridItems();
 }
Ejemplo n.º 14
0
 public void UpdatePropertyGrid(LevelEntry[] objects)
 {
     mPropertyGrid.SelectedObjects = objects;
     mPropertyGrid.ExpandAllGridItems();
 }
Ejemplo n.º 15
0
 private void InitializeComponent()
 {
     propertyOptions = new PropertyGrid();
     buttonOk        = new Button();
     buttonCancel    = new Button();
     panelTopMain    = new Panel();
     panelBottomMain = new Panel();
     panelTopMain.SuspendLayout();
     panelBottomMain.SuspendLayout();
     base.SuspendLayout();
     propertyOptions.CommandsVisibleIfAvailable = true;
     propertyOptions.HelpVisible    = false;
     propertyOptions.LargeButtons   = false;
     propertyOptions.LineColor      = SystemColors.ScrollBar;
     propertyOptions.Location       = new Point(8, 8);
     propertyOptions.Name           = "propertyOptions";
     propertyOptions.PropertySort   = PropertySort.Alphabetical;
     propertyOptions.Dock           = DockStyle.Fill;
     propertyOptions.TabIndex       = 0;
     propertyOptions.Text           = "PropertyGrid";
     propertyOptions.ToolbarVisible = false;
     propertyOptions.ViewBackColor  = SystemColors.Window;
     propertyOptions.ViewForeColor  = SystemColors.WindowText;
     propertyOptions.SelectedObject = Configuration.MasterConfig.Copy();
     buttonOk.DialogResult          = DialogResult.Cancel;
     buttonOk.FlatStyle             = FlatStyle.Popup;
     buttonOk.Location         = new Point(8, 5);
     buttonOk.Name             = "buttonOk";
     buttonOk.Size             = new Size(50, 20);
     buttonOk.TabIndex         = 1;
     buttonOk.Text             = "OK";
     buttonOk.Click           += new EventHandler(buttonOk_Click);
     buttonCancel.DialogResult = DialogResult.Cancel;
     buttonCancel.FlatStyle    = FlatStyle.Popup;
     buttonCancel.Location     = new Point(70, 5);
     buttonCancel.Name         = "buttonCancel";
     buttonCancel.Size         = new Size(50, 20);
     buttonCancel.TabIndex     = 1;
     buttonCancel.Text         = "Cancel";
     buttonCancel.Click       += new EventHandler(buttonCancel_Click);
     panelTopMain.BorderStyle  = BorderStyle.None;
     panelTopMain.Controls.AddRange(new Control[] { propertyOptions });
     panelTopMain.Dock           = DockStyle.Fill;
     panelTopMain.Name           = "panelTopMain";
     panelTopMain.Size           = new Size(0, 250);
     panelTopMain.TabIndex       = 0;
     panelBottomMain.BorderStyle = BorderStyle.None;
     panelBottomMain.Controls.AddRange(new Control[] { buttonOk, buttonCancel });
     panelBottomMain.Dock     = DockStyle.Bottom;
     panelBottomMain.Size     = new Size(0, 30);
     panelBottomMain.Name     = "panelBottomMain";
     panelBottomMain.TabIndex = 1;
     base.AcceptButton        = buttonOk;
     base.CancelButton        = buttonCancel;
     AutoScaleBaseSize        = new Size(5, 13);
     base.ClientSize          = new Size(0x110, 0x12b);
     base.Controls.AddRange(new Control[] { panelTopMain, panelBottomMain });
     base.Name = "OptionDialog";
     Text      = "Options ";
     panelTopMain.ResumeLayout(false);
     panelBottomMain.ResumeLayout(false);
     base.ResumeLayout(false);
     propertyOptions.ExpandAllGridItems();
 }
        /// <summary>
        /// Configures the control.
        /// </summary>
        /// <param name="control">The control.</param>
        private void ConfigControl(Control control)
        {
            control.BackColor = ModernPaint.BackColor.Form(ThemeStyle);
            control.ForeColor = ModernPaint.ForeColor.Button.Normal(ThemeStyle);

            if (control is Button)
            {
                Button button = (Button)control;

                button.Enter += (s, e) =>
                {
                    button.FlatAppearance.BorderSize = 0;
                };

                button.GotFocus += (s, e) =>
                {
                    button.BackColor = ModernPaint.BackColor.Button.Press(ThemeStyle);
                    button.ForeColor = ModernPaint.ForeColor.Button.Press(ThemeStyle);
                };

                button.Leave += (s, e) =>
                {
                    button.FlatAppearance.BorderSize = 1;
                };

                button.LostFocus += (s, e) =>
                {
                    button.BackColor = ModernPaint.BackColor.Button.Normal(ThemeStyle);
                    button.ForeColor = ModernPaint.ForeColor.Button.Normal(ThemeStyle);
                };

                button.EnabledChanged += (s, e) =>
                {
                    button.BackColor = button.Enabled ? ModernPaint.BackColor.Button.Normal(ThemeStyle) : ModernPaint.BackColor.Button.Disabled(ThemeStyle);
                    button.ForeColor = button.Enabled ? ModernPaint.ForeColor.Button.Normal(ThemeStyle) : ModernPaint.ForeColor.Button.Disabled(ThemeStyle);
                };

                button.Font      = ModernFonts.Button(ModernFontSize.Small, ModernFontWeight.Bold);
                button.BackColor = button.Enabled ? ModernPaint.BackColor.Button.Normal(ThemeStyle) : ModernPaint.BackColor.Button.Disabled(ThemeStyle);
                button.ForeColor = button.Enabled ? ModernPaint.ForeColor.Button.Normal(ThemeStyle) : ModernPaint.ForeColor.Button.Disabled(ThemeStyle);
                button.FlatStyle = FlatStyle.Flat;
                button.FlatAppearance.BorderSize         = button.Focused ? 0 : 1;
                button.FlatAppearance.BorderColor        = ModernPaint.BorderColor.Button.Normal(ThemeStyle);
                button.FlatAppearance.MouseOverBackColor = ModernPaint.BackColor.Button.Hover(ThemeStyle);
                button.FlatAppearance.MouseDownBackColor = ModernPaint.BackColor.Button.Press(ThemeStyle);
                button.FlatAppearance.CheckedBackColor   = ModernPaint.BorderColor.Button.Press(ThemeStyle);
                button.Height = 25;

                if (string.IsNullOrEmpty(button.Text) || string.IsNullOrEmpty(button.Text.Trim()))
                {
                    button.Width = 25;
                }
            }

            if (control is ListBox)
            {
                ListBox listBox = (ListBox)control;

                listBox.BorderStyle = BorderStyle.FixedSingle;

                listBox.DrawItem += (s, e) =>
                {
                    if (listBox.Items.Count > 0)
                    {
                        Color backColor = listBox.BackColor;
                        Color foreColor = listBox.ForeColor;

                        bool isSelected = (e.State & DrawItemState.Selected) != 0;
                        bool isHovered  = (e.State & DrawItemState.HotLight) != 0;

                        if (isHovered)
                        {
                            backColor = ModernPaint.BackColor.Button.Hover(ThemeStyle);
                            foreColor = ModernPaint.ForeColor.Button.Hover(ThemeStyle);
                        }
                        else
                        {
                            if (isSelected)
                            {
                                backColor = listBox.Focused ? ControlPaint.Light(ModernPaint.GetStyleColor(ColorStyle), 0.2F) : ModernPaint.BackColor.Button.Disabled(ThemeStyle);
                                foreColor = listBox.Focused ? Color.FromArgb(17, 17, 17) : ModernPaint.ForeColor.Button.Normal(ThemeStyle);
                            }
                            else
                            {
                                backColor = ModernPaint.BackColor.Form(ThemeStyle);
                                foreColor = ModernPaint.ForeColor.Button.Normal(ThemeStyle);
                            }
                        }

                        e.DrawBackground();

                        using (SolidBrush brush = new SolidBrush(backColor))
                        {
                            e.Graphics.FillRectangle(brush, e.Bounds);
                        }

                        using (SolidBrush brush = new SolidBrush(foreColor))
                        {
                            e.Graphics.DrawString(listBox.Items[e.Index].ToString(), e.Font, brush, listBox.GetItemRectangle(e.Index).Location);
                        }

                        e.DrawFocusRectangle();
                    }
                };
            }

            if (control is PropertyGrid)
            {
                PropertyGrid propertyGrid = (PropertyGrid)control;

                propertyGrid.CommandsBackColor = propertyGrid.BackColor;
                propertyGrid.HelpBackColor     = propertyGrid.BackColor;
                propertyGrid.ViewBackColor     = propertyGrid.BackColor;

                propertyGrid.ForeColor         = propertyGrid.ForeColor;
                propertyGrid.CategoryForeColor = propertyGrid.ForeColor;
                propertyGrid.CommandsForeColor = propertyGrid.ForeColor;
                propertyGrid.HelpForeColor     = propertyGrid.ForeColor;
                propertyGrid.ViewForeColor     = propertyGrid.ForeColor;

                propertyGrid.CommandsLinkColor         = ModernPaint.ForeColor.Link.Normal(ThemeStyle);
                propertyGrid.CommandsActiveLinkColor   = ModernPaint.ForeColor.Link.Hover(ThemeStyle);
                propertyGrid.CommandsDisabledLinkColor = ModernPaint.ForeColor.Link.Disabled(ThemeStyle);
                propertyGrid.LineColor = UseStyleColors ? ControlPaint.Light(ModernPaint.GetStyleColor(ColorStyle), 0.2F) : ModernPaint.BackColor.Button.Normal(ThemeStyle);

                propertyGrid.HelpVisible  = true;
                propertyGrid.PropertySort = PropertySort.NoSort;
                propertyGrid.ExpandAllGridItems();

                propertyGrid.Enter += (s, e) =>
                {
                    propertyGrid.LineColor = UseStyleColors ? ControlPaint.Light(ModernPaint.GetStyleColor(ColorStyle), 0.2F) : ModernPaint.BackColor.Button.Normal(ThemeStyle);
                };

                propertyGrid.Leave += (s, e) =>
                {
                    propertyGrid.LineColor = ModernPaint.BackColor.Button.Disabled(ThemeStyle);
                };
            }

            if (control.Controls.Count > 0)
            {
                foreach (Control item in control.Controls)
                {
                    this.ConfigControl(item);
                }
            }
        }