/** * #Brief : Remove the last panel in the stack and destroy it */ public void RemoveOne() { if (s_Panel.Count > 1) { Destroy(s_Panel.Pop()); ResizePanel.Resize(ContentPanel, -250); } }
private void DrawSizeButtonPanel() { containerPnl = new Panel { Location = new Point(5, 5), Size = new Size(630, 330) }; resizePanel = new ResizePanel(false, true) { Location = new Point(5, 5), Size = new Size(620, 320), BorderStyle = BorderStyle.FixedSingle, MaximumSize = new Size(620, 320), MinimumSize = new Size(115, 115) }; resizePanel.SizeChanged += ResizePanel_SizeChanged; containerPnl.Controls.Add(resizePanel); int X = 20, Y = 20; for (int i = 0; i < Constants.MAX_ROW; i++) { for (int j = 0; j < Constants.MAX_COLUMN; j++) { MaterialFlatButton but = new MaterialFlatButton { Location = new Point(X, Y), Size = new Size(20, 20), Enabled = false }; containerPnl.Controls.Add(but); X += 20; } X = 20; Y += 20; } X = 14; Y = 14; for (int i = 0; i < 15; i++) { for (int j = 0; j < 30; j++) { BoardButton but = new BoardButton { Location = new Point(X, Y), Size = new Size(20, 20), Rows = i, Columns = j }; but.Click += But_Click; resizePanel.Controls.Add(but); X += 20; board[i, j] = 3; butList.Add(new BoardPosition(i, j), but); } X = 14; Y += 20; } this.Controls.Add(containerPnl); }
private void ResizePanel_SizeChanged(object sender, EventArgs e) { ResizePanel rePnl = sender as ResizePanel; if (rePnl != null) { rowNud.Value = (rePnl.Height - 15) / 20; columnNud.Value = (rePnl.Width - 15) / 20; } }
private void ResizeMazePanel() { ResizePanel resizeScript = this.mazePanel.GetComponent <ResizePanel>(); if (resizeScript != null) { resizeScript.Execute(); } foreach (UISprite mask in this.mapMaskSprites) { StretchToFitPanel stretch = mask.gameObject.GetComponent <StretchToFitPanel>(); stretch.Stretch(); } }
/** * #Brief : Clone the GameObject src(panelEssai) and add it to the stack of panel * #args : GameObject src -> the GameObject to clone, we need to clone the panelEssai */ public void Clone(GameObject src) { // Clone the first panel and add the clone to the stack GameObject clone = Instantiate(src, src.transform.parent); s_Panel.Push(clone); clone.name += s_Panel.Count; clone.GetComponentsInChildren <Text>()[0].text = "D" + (s_Panel.Count); clone.GetComponentInChildren <InputField>().text = ""; Debug.Log("size = " + s_Panel.Count); // Scroll to the down scrollRect.velocity = new Vector2(0f, 1000f); ResizePanel.Resize(ContentPanel, 250); }
/// <summary> /// Create a new halftone algorithm configuration panel using an /// existing halftone algorithm. /// </summary> /// <param name="existingModule"></param> public HalftoneAlgorithmPanel(HalftoneAlgorithm existingModule) { BorderWidth = 3; VBox preProcessingVBox = new VBox(); Frame preResizeFrame = new Frame("Resize") { BorderWidth = 3 }; Frame preDotGainFrame = new Frame("Dot gain correction") { BorderWidth = 3 }; Frame preSharpenFrame = new Frame("Sharpen") { BorderWidth = 3 }; Frame halftoneMethodFrame = new Frame("Halftone method") { BorderWidth = 3 }; VBox postProcessingVBox = new VBox(); Frame postResizeFrame = new Frame("Resize") { BorderWidth = 3 }; Frame postSmoothenFrame = new Frame("Smoothen") { BorderWidth = 3 }; // -------- pre-processing -------- // ---- resize ---- preResizePanel = new ResizePanel(); preResizePanel.ModuleChanged += delegate { Module.PreResize = preResizePanel.Module; if (ModuleChanged != null) { ModuleChanged(this, new EventArgs()); } }; preResizeFrame.Add(preResizePanel); preProcessingVBox.PackStart(preResizeFrame); // ---- dot gain ---- preDotGainEnabledCheckButton = new CheckButton("Enabled"); preDotGainEnabledCheckButton.Toggled += delegate { bool enabled = preDotGainEnabledCheckButton.Active; if (!enabled) { Module.PreDotGain = null; } else if (Module.PreDotGain == null) { Module.PreDotGain = new HalftoneAlgorithm.GammaCorrection(); } if (Module.PreDotGain != null) { preDotGainGammaSpinButton.Value = ((HalftoneAlgorithm.GammaCorrection) Module.PreDotGain).Gamma; } preDotGainGammaSpinButton.Sensitive = enabled; if (ModuleChanged != null) { ModuleChanged(this, new EventArgs()); } }; preDotGainGammaSpinButton = new SpinButton(0.1, 10, 0.1); preDotGainGammaSpinButton.Changed += delegate { ((HalftoneAlgorithm.GammaCorrection)Module.PreDotGain).Gamma = preDotGainGammaSpinButton.Value; if (ModuleChanged != null) { ModuleChanged(this, new EventArgs()); } }; Table preDotGainTable = new Table(2, 2, false) { ColumnSpacing = 3, RowSpacing = 3, BorderWidth = 5 }; preDotGainTable.Attach(preDotGainEnabledCheckButton, 0, 2, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, 0, 0); preDotGainTable.Attach(new Label("Gamma:") { Xalign = 0.0f }, 0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Shrink, 0, 0); preDotGainTable.Attach(preDotGainGammaSpinButton, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Shrink, 0, 0); preDotGainFrame.Add(preDotGainTable); preProcessingVBox.PackStart(preDotGainFrame); // ---- sharpen ---- preSharpenEnabledCheckButton = new CheckButton("Enabled"); preSharpenEnabledCheckButton.Toggled += delegate { bool enabled = preSharpenEnabledCheckButton.Active; if (!enabled) { Module.PreSharpen = null; } else if (Module.PreSharpen == null) { Module.PreSharpen = new HalftoneAlgorithm.Sharpen(); } if (Module.PreSharpen != null) { preSharpenAmountHScale.Value = Module.PreSharpen.Amount; } preSharpenAmountHScale.Sensitive = enabled; if (ModuleChanged != null) { ModuleChanged(this, new EventArgs()); } }; preSharpenAmountHScale = new HScale(0, 1, 0.01); preSharpenAmountHScale.ChangeValue += delegate { Module.PreSharpen.Amount = preSharpenAmountHScale.Value; if (ModuleChanged != null) { ModuleChanged(this, new EventArgs()); } }; Table preSharpenTable = new Table(2, 2, false) { ColumnSpacing = 3, RowSpacing = 3, BorderWidth = 5 }; preSharpenTable.Attach(preSharpenEnabledCheckButton, 0, 2, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, 0, 0); preSharpenTable.Attach(new Label("Amount:") { Xalign = 0.0f }, 0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Shrink, 0, 0); preSharpenTable.Attach(preSharpenAmountHScale, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Shrink, 0, 0); preSharpenFrame.Add(preSharpenTable); preProcessingVBox.PackStart(preSharpenFrame); AppendPage(preProcessingVBox, new Label("Pre-processing")); // -------- halftone method -------- halftoneMethodSelector = new SubmoduleSelector<HalftoneMethod>(HalftoneMethod.createDefault()) { BorderWidth = 5 }; halftoneMethodSelector.ModuleChanged += delegate { if (Module != null) { Module.Method = halftoneMethodSelector.Module; if (ModuleChanged != null) { ModuleChanged(this, new EventArgs()); } } }; halftoneMethodFrame.Add(halftoneMethodSelector); AppendPage(halftoneMethodFrame, new Label("Halftone method")); // -------- post-processing -------- // ---- resize ---- postResizePanel = new ResizePanel(); postResizePanel.ModuleChanged += delegate { Module.PostResize = postResizePanel.Module; if (ModuleChanged != null) { ModuleChanged(this, new EventArgs()); } }; supersamplingCheckButton = new CheckButton("Supersampling"); supersamplingCheckButton.Toggled += delegate { Module.SupersamplingEnabled = supersamplingCheckButton.Active; postResizePanel.Sensitive = !supersamplingCheckButton.Active; if (ModuleChanged != null) { ModuleChanged(this, new EventArgs()); } }; Table postResizeTable = new Table(2, 1, false); postResizeTable.Attach(supersamplingCheckButton, 0, 1, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, 0, 0); postResizeTable.Attach(postResizePanel, 0, 1, 1, 2, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill | AttachOptions.Expand, 0, 0); postResizeFrame.Add(postResizeTable); postProcessingVBox.PackStart(postResizeFrame); // ---- smoothen ---- postSmoothenEnabledCheckButton = new CheckButton("Enabled"); postSmoothenEnabledCheckButton.Toggled += delegate { bool enabled = postSmoothenEnabledCheckButton.Active; if (!enabled) { Module.PostSmoothen = null; } else if (Module.PostSmoothen == null) { Module.PostSmoothen = new HalftoneAlgorithm.Smoothen(); } if (Module.PostSmoothen != null) { postSmoothenRadiusSpinButton.Value = Module.PostSmoothen.Radius; } postSmoothenRadiusSpinButton.Sensitive = enabled; if (ModuleChanged != null) { ModuleChanged(this, new EventArgs()); } }; postSmoothenRadiusSpinButton = new SpinButton(1, 20, 0.5); postSmoothenRadiusSpinButton.Changed += delegate { Module.PostSmoothen.Radius = postSmoothenRadiusSpinButton.Value; if (ModuleChanged != null) { ModuleChanged(this, new EventArgs()); } }; Table postSmoothenTable = new Table(2, 2, false) { ColumnSpacing = 3, RowSpacing = 3, BorderWidth = 5 }; postSmoothenTable.Attach(postSmoothenEnabledCheckButton, 0, 2, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, 0, 0); postSmoothenTable.Attach(new Label("Radius:") { Xalign = 0.0f }, 0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Shrink, 0, 0); postSmoothenTable.Attach(postSmoothenRadiusSpinButton, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Shrink, 0, 0); postSmoothenFrame.Add(postSmoothenTable); postProcessingVBox.PackStart(postSmoothenFrame); AppendPage(postProcessingVBox, new Label("Post-processing")); Module = existingModule; ShowAll(); Page = 1; }