public bool SetVarName(string name) { System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9_\\.\\[\\]]"); if (reg.IsMatch(name)) { return(false); } if (name.IndexOfAny(new char[] { '.', '[', ']' }) != -1) { this.global = true; } foreach (Panel p in Derma.GetPanels()) { if (p.varname == name) { return(false); } } varname = name; Derma.RefreshProperties(); return(true); }
private void Toolbox_Move(object sender, EventArgs e) { if (this.snapToWorkspace) { this.Location = new System.Drawing.Point(Derma.GetWorkspace().Location.X - Derma.toolbox.ClientSize.Width - 20, Derma.GetWorkspace().Location.Y); } }
private void FindPanelByVar_Load(object sender, EventArgs e) { foreach (Panel p in Derma.GetPanels()) { this.PanelList.Items.Add(p.varname); } }
private static void MouseUp(object sender, MouseEventArgs e) { bool doneAlready = false; foreach (Panel p in panels) { if (Derma.MouseIsOverPanel(p) && !doneAlready && p.MouseUpHandler != null) { p.MouseUpHandler(p, e); doneAlready = true; } if (p.dragging) { p.dragging = false; Panel h = GetHighlightedPanel(); if (h) { p.SetParent(h); p.z = nextz; nextz++; ResortPanelsByZ(); RefreshProperties(); h.highlighted = false; } } } }
public static bool Resize_MouseDown(object sender, MouseEventArgs e) { if (host != null && Derma.GetSelected() == host && !host.locked && host.sizable && host.sizablex && Derma.IsMouseOverArea(host.x + host.width - halfSize - 2, host.y + host.height / 2 - halfSize, 16, 16)) { resizing = true; resizingx = true; mouseOrigin.X = e.X; mouseOrigin.Y = e.Y; return(true); } else if (host != null && Derma.GetSelected() == host && !host.locked && host.sizable && host.sizabley && Derma.IsMouseOverArea(host.x + host.width / 2 - halfSize, host.y + host.height - halfSize - 2, 16, 16)) { resizing = true; resizingy = true; mouseOrigin.X = e.X; mouseOrigin.Y = e.Y; return(true); } else if (host != null && Derma.GetSelected() == host && !host.locked && host.sizable && host.sizablex && host.sizabley && Derma.IsMouseOverArea(host.x + host.width - twoThirdsSize, host.y + host.height - twoThirdsSize, 16, 16)) { resizing = true; resizinga = true; mouseOrigin.X = e.X; mouseOrigin.Y = e.Y; return(true); } return(false); }
private void PropertiesWindow_Move(object sender, EventArgs e) { if (this.snapToWorkspace) { this.Location = new System.Drawing.Point(Derma.GetWorkspace().Location.X + Derma.GetWorkspace().ClientSize.Width + 24, Derma.GetWorkspace().Location.Y); } }
static void CreateControl(object sender, EventArgs e) { TreeView t = (TreeView)sender; Derma.New(t.SelectedNode.Text.ToString()); Derma.Repaint(); }
private void Form1_DragDrop(object sender, DragEventArgs e) { string pName = (string)e.Data.GetData(typeof(string)); Point newPos = Derma.GetRelativeMousePos(e.X, e.Y); Derma.New(pName, newPos.X, newPos.Y); Derma.Repaint(); }
private void menuItem44_Click(object sender, EventArgs e) { LargeTextBox l = new LargeTextBox(); l.luaOutput.Text = Derma.GenerateLua(); l.ShowDialog(this); }
public bool IsCentered() { if (this.x == (Derma.GetWorkspace().Width / 2) - (this.width / 2) && this.y == (Derma.GetWorkspace().Width / 2) - (this.height / 2)) { return(true); } return(false); }
private void menuItem40_Click(object sender, EventArgs e) { if (Derma.GetSelected() && Derma.GetSelected().hasParent&& Derma.GetSelected().parent) { Derma.GetSelected().UnParent(); } Derma.Repaint(); }
private static void MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e) { foreach (Panel p in panels) { if (Derma.MouseIsOverPanel(p) && p.MouseDoubleClickHandler != null) { p.MouseDoubleClickHandler(p, e); break; } } }
private void menuItem29_Click(object sender, EventArgs e) { MenuItem t = (MenuItem)sender; t.Checked = !t.Checked; Derma.toolbox.snapToWorkspace = t.Checked; if (t.Checked) { Derma.toolbox.Location = new System.Drawing.Point(Derma.GetWorkspace().Location.X - Derma.toolbox.ClientSize.Width - 20, Derma.GetWorkspace().Location.Y); } }
private static void MouseClick(object sender, MouseEventArgs e) { foreach (Panel p in panels) { if (Derma.MouseIsOverPanel(p) && p.MouseClickHandler != null && !p.hidden) { p.MouseClickHandler(p, e); break; } } }
private static void MouseWheel(object sender, MouseEventArgs e) { foreach (Panel p in panels) { if (Derma.MouseIsOverPanel(p) && p.MouseWheelHandler != null) { p.MouseWheelHandler(p, e); break; } } }
public void Center() { if (this.hasParent && this.parent) { this.SetPos(parent.x + (parent.width / 2) - (this.width / 2), parent.y + (parent.height / 2) - (this.height / 2)); } else { this.SetPos((Derma.GetWorkspace().Width / 2) - (this.width / 2), (Derma.GetWorkspace().Height / 2) - (this.height / 2)); } }
private void Form1_Move(object sender, EventArgs e) { if (Derma.toolbox != null && Derma.toolbox.snapToWorkspace) { Derma.toolbox.Location = new System.Drawing.Point(Derma.GetWorkspace().Location.X - Derma.toolbox.ClientSize.Width - 20, Derma.GetWorkspace().Location.Y); } if (Derma.prop != null && Derma.prop.snapToWorkspace) { Derma.prop.Location = new System.Drawing.Point(Derma.GetWorkspace().Location.X + Derma.GetWorkspace().ClientSize.Width + 24, Derma.GetWorkspace().Location.Y); } }
public DFrame(int xpos, int ypos) : base(xpos, ypos, 120, 60) { numOfThisType++; if (!this.SetVarName(type + numOfThisType.ToString())) { while (!this.SetVarName(type + numOfThisType.ToString() + Derma.RandomString(4, false))) { continue; } } }
public DTextEntry(int x, int y) : base(x, y, 50, 20) { numOfThisType++; if (!this.SetVarName(type + numOfThisType.ToString())) { while (!this.SetVarName(type + numOfThisType.ToString() + Derma.RandomString(4, false))) { continue; } } }
public SpawnIcon(int x, int y) : base(x, y, 61, 61) { numOfThisType++; if (!this.SetVarName(type + numOfThisType.ToString())) { while (!this.SetVarName(type + numOfThisType.ToString() + Derma.RandomString(4, false))) { continue; } } }
public static void Load(string filename) { try { Packer.ReadAllFromFile(filename); } catch (Exception e) { MessageBox.Show("Unable to load file\n" + e.Message, "Unable to load", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return; } SetEnvironment(filename); Derma.Repaint(); }
private void RefreshListing() { this.PanelList.Items.Clear(); foreach (Panel p in Derma.GetPanels()) { if (p.varname.ToLower().Contains(this.TEntry.Text.ToLower())) { this.PanelList.Items.Add(p.varname); } } }
public void Remove() { foreach (Panel p in children) { p.Remove(); } if (ResizeGrip.host == this) { ResizeGrip.host = null; } Derma.GetPanels().Remove(this); Derma.Repaint(); }
private void SelectBtn_Click(object sender, EventArgs e) { foreach (Panel p in Derma.GetPanels()) { if (p.varname == this.TEntry.Text) { Derma.SetSelected(p); Derma.Repaint(); return; } } MessageBox.Show("No panel exists with the variable name '" + this.TEntry.Text + "'.", "Panel not found"); }
public DNumSlider(int x, int y) : base(x, y, 154, 40) { numOfThisType++; this.text = "DNumSlider"; if (!this.SetVarName(type + numOfThisType.ToString())) { while (!this.SetVarName(type + numOfThisType.ToString() + Derma.RandomString(4, false))) { continue; } } }
private void menuItem5_Click(object sender, EventArgs e) { if (Derma.GetPanels().Count > 0) { DialogResult reply = MessageBox.Show("Are you sure you want to open a saved project?\nAny unsaved data in the current project will be lost.", "Open project", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (reply != DialogResult.Yes) { return; } } DSave.SetDialogDefaults(); Derma.prop.propertyGrid.SelectedObject = null; OpenDialog.ShowDialog(); }
public void PackAllToFile(string filename) { List <Panel> panels = Derma.GetPanels(); PanelData = new List <DPanelInfo>(); foreach (Panel p in panels) { InsertPanelInfo(PanelToInfo(p)); } FileStream Fstream = File.OpenWrite(filename); Byte[] Data = GetData(); Fstream.Write(Data, 0, Data.Length); Fstream.Close(); }
public DLabel(int xpos, int ypos) : base(xpos, ypos, 60, 20) { numOfThisType++; if (!this.SetVarName(type + numOfThisType.ToString())) { while (!this.SetVarName(type + numOfThisType.ToString() + Derma.RandomString(4, false))) { continue; } } this.width = (int)labelSize.Width; this.height = (int)labelSize.Height; }
// to set the selected panel static void SelectedItem_MouseHandler(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } foreach (Panel p in panels) { if (Derma.MouseIsOverPanel(p)) { SetSelected(p); Repaint(); break; } } }
/// <summary> /// Must be called directly after any PanelFromPanelInfo calls /// </summary> public static void MatchParentsWithIdentitifiers() { foreach (Panel p in Derma.GetPanels()) { if (p.parentIdentifier != null) { foreach (Panel p2 in Derma.GetPanels()) { if (p.parentIdentifier == p2.varname) { p.SetParent(p2); p.parentIdentifier = null; } } } } Derma.ResortPanelsByZ(); }