private void InitializeControls() { this.SuspendLayout(); // (this) Timeline Control this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; this.Name = "TimelineControl"; // Split Container splitContainer = new SplitContainer() { Dock = DockStyle.Fill, Orientation = Orientation.Vertical, Name = "splitContainer", FixedPanel = FixedPanel.Panel1, Panel1MinSize = 100, }; this.Controls.Add(this.splitContainer); // Split container panels splitContainer.BeginInit(); splitContainer.SuspendLayout(); InitializePanel1(); InitializePanel2(); splitContainer.ResumeLayout(false); splitContainer.EndInit(); splitContainer.PerformAutoScale(); this.ResumeLayout(false); }
public void RestoreFromSettings(ISettingsSource settings) { _splitter.BeginInit(); _splitter.SuspendLayout(); int prevDpi = settings.GetInt(DpiSettingsKey) ?? DpiUtil.DpiX; int prevSize = settings.GetInt(SizeSettingsKey) ?? 0; int prevDistance = settings.GetInt(DistanceSettingsKey) ?? 0; if (prevSize > 0 && prevDistance > 0) { var fixedPanel = _splitter.FixedPanel; var splitterWidth = _splitter.SplitterWidth; if (SplitterSize == prevSize && _dpi == prevDpi) { SetSplitterDistance(fixedPanel == FixedPanel.Panel2 ? prevDistance + splitterWidth : prevDistance); } else { switch (fixedPanel) { case FixedPanel.None: // At this point, the property "SplitterSize" has its original value from design time, // i.e. the actual size after opening the window is unknown yet. The calculation below // determines the resulting splitter distance by the ratio of both sides of the splitter. SetSplitterDistance((float)SplitterSize * prevDistance / prevSize); break; case FixedPanel.Panel1: SetSplitterDistance(DpiUtil.Scale(prevDistance, prevDpi)); break; case FixedPanel.Panel2: int panel2PrevSize = DpiUtil.Scale(prevSize, prevDpi) - DpiUtil.Scale(prevDistance, prevDpi); const int paddingOffset = 2; // Refer to FormCommit.ctor+WorkaroundPaddingIncreaseBug SetSplitterDistance(SplitterSize - panel2PrevSize - paddingOffset + splitterWidth); break; } } } _splitter.Panel1Collapsed = settings.GetBool(Panel1CollapsedSettingsKey, defaultValue: false); _splitter.ResumeLayout(); _splitter.EndInit(); }
public void RestoreFromSettings(ISettingsSource settings) { Splitter.BeginInit(); Splitter.SuspendLayout(); int prevDpi = settings.GetInt(DpiSettingsKey) ?? DpiUtil.DpiX; int prevSize = settings.GetInt(SizeSettingsKey) ?? 0; int prevDistance = settings.GetInt(DistanceSettingsKey) ?? 0; if (prevSize > 0 && prevDistance > 0) { if (SplitterSize == prevSize && Dpi == prevDpi) { SetSplitterDistance(prevDistance); } else { switch (Splitter.FixedPanel) { case FixedPanel.None: SetSplitterDistance((float)SplitterSize * prevDistance / prevSize); break; case FixedPanel.Panel1: SetSplitterDistance(DpiUtil.Scale(prevDistance, prevDpi)); break; case FixedPanel.Panel2: int panel2PrevSize = DpiUtil.Scale(prevSize, prevDpi) - DpiUtil.Scale(prevDistance, prevDpi); SetSplitterDistance(SplitterSize - panel2PrevSize); break; } } } Splitter.Panel1Collapsed = settings.GetBool(Panel1CollapsedSettingsKey, defaultValue: false); Splitter.ResumeLayout(); Splitter.EndInit(); }
private void Init() { if (s_schemaLoader == null) { s_schemaLoader = new SchemaLoader(); } m_PropertyGrid = new PropertyGrid(PropertyGridMode.PropertySorting | PropertyGridMode.DisplayDescriptions | PropertyGridMode.HideResetAllButton); m_treeControl = new TreeControl(); m_menu = new MenuStrip(); var fileMenu = new ToolStripMenuItem(); var newMenu = new ToolStripMenuItem(); var openMenu = new ToolStripMenuItem(); var exitMenu = new ToolStripMenuItem(); var splitter = new SplitContainer(); m_menu.SuspendLayout(); splitter.BeginInit(); splitter.Panel1.SuspendLayout(); splitter.Panel2.SuspendLayout(); splitter.SuspendLayout(); SuspendLayout(); // m_menu m_menu.Location = new System.Drawing.Point(0, 0); m_menu.Name = "m_menu"; m_menu.TabIndex = 0; m_menu.Text = "m_menu"; m_menu.Items.Add(fileMenu); // file fileMenu.Name = "fileToolStripMenuItem"; fileMenu.Size = new System.Drawing.Size(37, 20); fileMenu.Text = "File".Localize(); fileMenu.DropDownOpening += new EventHandler(fileMenu_DropDownOpening); fileMenu.DropDownItems.AddRange(new ToolStripItem[] { newMenu, openMenu, m_openFolderMenu, m_saveMenu, m_saveAsMenu, exitMenu }); // new newMenu.Name = "newToolStripMenuItem"; newMenu.ShortcutKeys = Keys.Control | Keys.N; newMenu.Text = "New".Localize(); newMenu.Click += NewToolStripMenuItem_Click; //open openMenu.Name = "openToolStripMenuItem"; openMenu.ShortcutKeys = Keys.Control | Keys.O; openMenu.Text = "Open...".Localize(); openMenu.Click += OpenToolStripMenuItem_Click; // open containing folder m_openFolderMenu.Name = "OpenFolderMenu"; m_openFolderMenu.Text = "Open Containing Folder".Localize(); m_openFolderMenu.Click += new EventHandler(OpenFolderMenu_Click); //save m_saveMenu.Name = "saveToolStripMenuItem"; m_saveMenu.ShortcutKeys = Keys.Control | Keys.S; m_saveMenu.Text = "Save".Localize(); m_saveMenu.Click += SaveToolStripMenuItem_Click; // save as m_saveAsMenu.Name = "saveAsToolStripMenuItem"; m_saveAsMenu.Text = "Save As...".Localize(); m_saveAsMenu.Click += SaveAsToolStripMenuItem_Click; // exit exitMenu.Name = "exitToolStripMenuItem"; exitMenu.Text = "Exit".Localize(); exitMenu.Click += ExitToolStripMenuItem_Click; // tree control m_treeControl.Dock = DockStyle.Fill; m_treeControl.Name = "m_treeControl"; m_treeControl.TabIndex = 1; m_treeControl.Width = 150; m_treeControl.ShowRoot = false; m_treeControl.AllowDrop = false; m_treeControl.SelectionMode = SelectionMode.One; m_treeControlAdapter = new TreeControlAdapter(m_treeControl); // propertyGrid1 m_PropertyGrid.Dock = DockStyle.Fill; m_PropertyGrid.Name = "propertyGrid1"; m_PropertyGrid.TabIndex = 3; m_PropertyGrid.PropertySorting = PropertySorting.None; // splitter splitter.Dock = DockStyle.Fill; splitter.Name = "splitContainer1"; splitter.Panel1.Controls.Add(m_treeControl); splitter.Panel2.Controls.Add(m_PropertyGrid); splitter.SplitterDistance = 100; splitter.TabIndex = 1; AutoScaleMode = AutoScaleMode.Font; ClientSize = new System.Drawing.Size(600, 400); Controls.Add(splitter); Controls.Add(m_menu); MainMenuStrip = m_menu; Name = "SkinEditor"; Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage)); UpdateTitleText(); m_menu.ResumeLayout(false); m_menu.PerformLayout(); splitter.Panel1.ResumeLayout(false); splitter.Panel2.ResumeLayout(false); splitter.EndInit(); splitter.ResumeLayout(false); ResumeLayout(false); PerformLayout(); splitter.SplitterDistance = 170; }
void InitializeComponents() { SuspendLayout(); // // appContainer // appContainer = new Panel { Dock = DockStyle.Fill, BorderStyle = BorderStyle.None, Visible = false, }; appContainer.SuspendLayout(); // // statusBar // statusBar = new StatusStrip() { Dock = DockStyle.Bottom, Size = new Size(400, 32), SizingGrip = true, Stretch = true, AutoSize = false }; statusBar.Items.Add(statusLabel = new ToolStripStatusLabel() { Spring = true, Text = "Ready", TextAlign = ContentAlignment.MiddleLeft }); // // toolStrip // toolStrip = new BlackToolStrip(); var mainMenuButton = toolStrip.AddMenuItem(Program.BarsImage); mainMenuButton.DropDownOpening += (sender, args) => { mainMenuButton.DropDownItems.Clear(); mainMenuButton.DropDownItems.AddRange(MainMenu()); }; toolStrip.Items.Add(gameStatusLabel = new ToolStripLabel() { AutoSize = false, Height = toolStrip.Height, Width = 382 /* 314 */, TextAlign = ContentAlignment.MiddleLeft, BackColor = Color.White }); //toolStrip.AddMenuItem(Program.BarsImage); toolStrip.Items.Add(new ToolStripSeparator()); toolStrip.NextAlignment = ToolStripItemAlignment.Right; progressBar = toolStrip.AddProgressBar(); discardButton = toolStrip.AddButton(Program.TrashImage, "Discard", DiscardChanges); applyButton = toolStrip.AddButton(Program.SaveImage, "Apply", ApplyChanges); changesLabel = toolStrip.AddLabel(); progressBar.Visible = false; // // splitContainer // splitContainer = new SplitContainer { BackColor = SystemColors.Control, Dock = DockStyle.Fill, Location = new Point(0, 0), Name = "splitContainer", FixedPanel = FixedPanel.Panel1, Size = new Size(1422, 1006), SplitterDistance = 450, TabIndex = 0, }; splitContainer.BeginInit(); splitContainer.Panel1.SuspendLayout(); splitContainer.Panel2.SuspendLayout(); splitContainer.SuspendLayout(); splitContainer.Panel1.DockPadding.All = 9; // // folderTreeView // folderTreeView = new BufferedTreeView { BackColor = SystemColors.Control, BorderStyle = BorderStyle.None, Dock = DockStyle.Fill, Font = new Font("Tahoma", 9.0F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))), Name = "folderTreeView", Size = new Size(474, 1006), TabIndex = 0, ItemHeight = 40, FullRowSelect = true, HideSelection = false, DrawMode = TreeViewDrawMode.OwnerDrawText, ImageList = new ImageList { ImageSize = new Size(32, 20), ColorDepth = ColorDepth.Depth32Bit } }; folderTreeView.ImageList.Images.Add(Program.FolderIconSmall); folderTreeView.AfterSelect += FolderTreeView_AfterSelect; folderTreeView.NodeMouseClick += FolderTreeView_MouseClick; folderTreeView.DrawNode += FolderTreeView_DrawNode; splitContainer.Panel1.Controls.Add(folderTreeView); // // imageListView // imageListView = new BufferedListView { BackColor = SystemColors.ControlDark, BorderStyle = BorderStyle.None, Dock = DockStyle.Fill, Location = new Point(0, 0), Name = "imageListView", Size = new Size(944, 1006), TabIndex = 0, View = View.LargeIcon, LargeImageList = new ImageList { ImageSize = new Size(200, 200), ColorDepth = ColorDepth.Depth32Bit } }; imageListView.SelectedIndexChanged += ImageListView_SelectedIndexChanged; imageListView.DoubleClick += ImageListView_DoubleClick; imageListView.MouseClick += ImageListView_MouseClick; imageListView.ItemDrag += ImageListView_ItemDrag; splitContainer.Panel2.Controls.Add(imageListView); // // DragInstructions // dragInstructions = new Panel() { Dock = DockStyle.Fill }; instructionsLabel = new Label() { Dock = DockStyle.Fill, Font = new Font("Tahoma", 20), TextAlign = ContentAlignment.MiddleCenter, }; instructionsLabel.Paint += InstructionsLabel_Paint; dragInstructions.Controls.Add(instructionsLabel); // // ExplorerForm // AutoScaleDimensions = new SizeF(12F, 25F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(1522, 1006); appContainer.Controls.Add(splitContainer); appContainer.Controls.Add(statusBar); appContainer.Controls.Add(toolStrip); Controls.Add(appContainer); Controls.Add(dragInstructions); Name = "ExplorerForm"; Text = "SOR4 Explorer"; DoubleBuffered = true; AllowDrop = true; Icon = Program.Icon; FormClosing += ExplorerForm_FormClosing; DragDrop += ExplorerForm_DragDrop; DragEnter += ExplorerForm_DragEnter; splitContainer.Panel1.ResumeLayout(false); splitContainer.Panel2.ResumeLayout(false); splitContainer.EndInit(); splitContainer.ResumeLayout(false); appContainer.ResumeLayout(false); ResumeLayout(false); }