Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
 private void FindPanelByVar_Load(object sender, EventArgs e)
 {
     foreach (Panel p in Derma.GetPanels())
     {
         this.PanelList.Items.Add(p.varname);
     }
 }
Ejemplo n.º 4
0
        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;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 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);
     }
 }
Ejemplo n.º 7
0
        static void CreateControl(object sender, EventArgs e)
        {
            TreeView t = (TreeView)sender;

            Derma.New(t.SelectedNode.Text.ToString());
            Derma.Repaint();
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
        private void menuItem44_Click(object sender, EventArgs e)
        {
            LargeTextBox l = new LargeTextBox();

            l.luaOutput.Text = Derma.GenerateLua();

            l.ShowDialog(this);
        }
Ejemplo n.º 10
0
 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);
 }
Ejemplo n.º 11
0
        private void menuItem40_Click(object sender, EventArgs e)
        {
            if (Derma.GetSelected() && Derma.GetSelected().hasParent&& Derma.GetSelected().parent)
            {
                Derma.GetSelected().UnParent();
            }

            Derma.Repaint();
        }
Ejemplo n.º 12
0
 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;
         }
     }
 }
Ejemplo n.º 13
0
        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);
            }
        }
Ejemplo n.º 14
0
 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;
         }
     }
 }
Ejemplo n.º 15
0
 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;
         }
     }
 }
Ejemplo n.º 16
0
 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));
     }
 }
Ejemplo n.º 17
0
        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);
            }
        }
Ejemplo n.º 18
0
        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;
                }
            }
        }
Ejemplo n.º 19
0
        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;
                }
            }
        }
Ejemplo n.º 20
0
        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;
                }
            }
        }
Ejemplo n.º 21
0
 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();
 }
Ejemplo n.º 22
0
        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);
                }
            }
        }
Ejemplo n.º 23
0
 public void Remove()
 {
     foreach (Panel p in children)
     {
         p.Remove();
     }
     if (ResizeGrip.host == this)
     {
         ResizeGrip.host = null;
     }
     Derma.GetPanels().Remove(this);
     Derma.Repaint();
 }
Ejemplo n.º 24
0
        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");
        }
Ejemplo n.º 25
0
        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;
                }
            }
        }
Ejemplo n.º 26
0
 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();
 }
Ejemplo n.º 27
0
        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();
        }
Ejemplo n.º 28
0
        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;
        }
Ejemplo n.º 29
0
 // 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;
         }
     }
 }
Ejemplo n.º 30
0
 /// <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();
 }