PanelData CreatePanel(DocumentWindow document, object[] key, bool willSelected)
        {
            PanelData panel = new PanelData();

            panels.Add(panel);
            panel.selectedObjects = key;

            panel.CreateAndAddPanel(this);

            //hide
            if (!willSelected && panel.layoutPanel != null)
            {
                panel.layoutPanel.Visible = false;
                panel.layoutPanel.Enabled = false;
            }

            SettingsProvider.Create(document, panel.selectedObjects, panel.layoutPanel, null, true);

            return(panel);
        }
示例#2
0
        PanelData CreatePanel(DocumentWindow documentWindow, object[] key)          //, bool willSelected )
        {
            PanelData panel = new PanelData();

            panels.Add(panel);
            panel.documentWindow     = documentWindow;
            panel.selectedObjects    = key;
            panel.selectedObjectsSet = new ESet <object>(panel.selectedObjects);

            panel.CreateAndAddPanel(this);

            ////hide
            //if( !willSelected && panel.layoutPanel != null )
            //{
            //	panel.layoutPanel.Visible = false;
            //	panel.layoutPanel.Enabled = false;
            //}

            //init panel
            if (panel.selectedObjects != null && panel.selectedObjects.Length != 0)             //!!!!так?
            {
                //no sense. same speed
                //bool canSuspendLayout = !ProjectSettings.Get.DisplayHierarchyOfObjectsInSettingsWindow.Value;

                try
                {
                    //!!!!
                    //!!!!может раньше

                    //if( canSuspendLayout )
                    //	panel.layoutPanel.SuspendLayout();

                    //!!!! отключено. для правильного расчёта splitContainer.SplitterDistance. см ниже.
                    //layoutPanel.SuspendLayout();

                    //!!!!!

                    //if( clear )
                    //	Clear();

                    //UpdateBegin?.Invoke( this );
                    //AllProviders_UpdateBegin?.Invoke( this );

                    //OnUpdate();


                    var objInfoHeader = new SettingsHeader_ObjectInfo();
                    objInfoHeader.Dock = DockStyle.Fill;
                    panel.layoutPanel.Controls.Add(objInfoHeader);

                    bool allComponentsSelected = Array.TrueForAll(panel.selectedObjects, obj => obj is Component);
                    if (allComponentsSelected)
                    {
                        if (ProjectSettings.Get.DisplayHierarchyOfObjectsInSettingsWindow.Value)
                        {
                            //with components hierarchy on second level

                            var splitContainer = new KryptonSplitContainer();
                            splitContainer.SplitterWidth = 8;
                            splitContainer.Orientation   = Orientation.Horizontal;
                            splitContainer.Dock          = DockStyle.Fill;
                            DarkThemeUtility.ApplyToSplitter(splitContainer);
                            panel.layoutPanel.Controls.Add(splitContainer);

                            {
                                var componentsHeader = new SettingsHeader_Components();
                                //header.Init( documentWindow );
                                componentsHeader.Dock = DockStyle.Fill;
                                splitContainer.Panel1.Controls.Add(componentsHeader);

                                // components panel autosize.
                                float splitterPercent = (float)componentsHeader.CalculateHeight() / splitContainer.Height;
                                float minCoef         = 0.33f;
                                if (splitterPercent < minCoef)
                                {
                                    splitContainer.SplitterDistance = componentsHeader.CalculateHeight() + 25;
                                }
                                else
                                {
                                    splitContainer.SplitterDistance = (int)(splitContainer.Height * minCoef);
                                }
                            }

                            {
                                var window = new SettingsLevel2Window();
                                window.Dock = DockStyle.Fill;
                                splitContainer.Panel2.Controls.Add(window);
                            }

                            //теперь ниже
                            ////select root of level 2
                            ////!!!!всегда Component? если нет, то и окна этого нет
                            //panel.GetControl<SettingsHeader_Components>()?.SelectObjects( new Component[] { (Component)panel.selectedObjects[ 0 ] } );

                            //UpdateEnd?.Invoke( this );
                            //AllProviders_UpdateEnd?.Invoke( this );

                            //provider.PerformUpdate( false );
                        }
                        else
                        {
                            //without components hierarchy on second level

                            var window = new SettingsLevel2Window();
                            window.Dock = DockStyle.Fill;
                            panel.layoutPanel.Controls.Add(window);

                            window.SelectObjects(panel.documentWindow, panel.selectedObjects);
                        }
                    }
                    else
                    {
                        //not components. can be flowchart Connector.

                        //!!!!можно показать свойства в гриде read only
                    }
                }
                finally
                {
                    //if( canSuspendLayout )
                    //	panel.layoutPanel.ResumeLayout();

                    //!!!! отключено. для правильного расчёта splitContainer.SplitterDistance
                    //layoutPanel.ResumeLayout();
                }
            }

            return(panel);
        }
        PanelData CreatePanel(/*DocumentWindow documentWindow, */ object[] key, bool willSelected)
        {
            PanelData panel = new PanelData();

            panels.Add(panel);
            panel.selectedObjects = key;
            panel.CreateAndAddPanel(panelSettings);

            //hide
            if (!willSelected && panel.layoutPanel != null)
            {
                panel.layoutPanel.Visible = false;
                panel.layoutPanel.Enabled = false;
            }

            SettingsProvider.Create(this /*documentWindow*/, panel.selectedObjects, panel.layoutPanel, null, true);

            //!!!!!было
            ////init panel
            //if( panel.selectedObjects != null && panel.selectedObjects.Length != 0 )//!!!!так?
            //{
            //try
            //{
            //	//!!!!
            //	//!!!!может раньше
            //	//!!!!где еще такое
            //	layoutPanel.SuspendLayout();

            //	//!!!!!

            //	//if( clear )
            //	//	Clear();

            //	//UpdateBegin?.Invoke( this );
            //	//AllProviders_UpdateBegin?.Invoke( this );

            //	//OnUpdate();

            //	xx xx;

            //	{
            //		var header = new SettingsHeader_ObjectInfo();
            //		header.Anchor = AnchorStyles.Left | AnchorStyles.Right;
            //		layoutPanel.Controls.Add( header );
            //	}

            //	{
            //		var header = new SettingsHeader_Components();
            //		header.Anchor = AnchorStyles.Left | AnchorStyles.Right;
            //		layoutPanel.Controls.Add( header );

            //		//!!!!!

            //		////!!!!не так видать. надо не создавать совсем контрол
            //		//bool showComponents = false;

            //		//if( panel.selectedObjects.Length == 1 )
            //		//{
            //		//	var obj = panel.selectedObjects[ 0 ] as Component;
            //		//	if( obj != null && obj.ShowComponentsInSettings )
            //		//		showComponents = true;
            //		//}

            //		////!!!!!
            //		//if( !showComponents )
            //		//	header.Visible = false;
            //	}

            //	//!!!!
            //	//separator
            //	{
            //		var header = new GroupBox();
            //		header.Size = new Size( 20, 20 );
            //		header.Anchor = AnchorStyles.Left | AnchorStyles.Right;
            //		layoutPanel.Controls.Add( header );
            //	}

            //	{
            //		var window = new SettingsLevel2Window();
            //		window.Dock = DockStyle.Fill;
            //		layoutPanel.Controls.Add( window );
            //	}

            //	//select root of level 2
            //	//!!!!всегда Component? если нет, то и окна этого нет
            //	xx xx;
            //	if( panel.GetControl<SettingsHeader_Components>() != null )
            //		panel.GetControl<SettingsHeader_Components>().SelectObjects( new Component[] { (Component)panel.selectedObjects[ 0 ] } );

            //	//UpdateEnd?.Invoke( this );
            //	//AllProviders_UpdateEnd?.Invoke( this );

            //	//provider.PerformUpdate( false );
            //}
            //finally
            //{
            //	layoutPanel.ResumeLayout();
            //}
            //}

            return(panel);
        }